:root {
  /* Azul y rojo del logo, los mismos tokens que la landing (landing/public/styles.css). */
  --navy: #0B2F5E;
  --navy-deep: #071E3D;
  --red: #D00F17;
  --red-press: #A80C12;

  --ink: #0E1B2E;          /* texto: el azul del logo llevado a casi negro */
  --steel: #1E3C5C;
  --slate: #5B6875;
  --line: #D6DCE2;
  --surface: #FFFFFF;
  --page: #EEF1F4;
  --success: #1F8A54;
  --danger: #C0392B;
  --radius: 12px;
  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

/* --- Barra superior --- */
/* Fondo claro a propósito: el logo es azul sobre transparente y sobre una
   barra oscura la niñera se perdería contra el fondo. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(14,27,46,.06);
}
.topbar-inner {
  max-width: 640px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand-logo { height: 40px; width: auto; flex: 0 0 auto; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
  font-weight: 700; font-size: 1.02rem; letter-spacing: .2px; color: var(--navy);
}
.brand-sub { font-size: .78rem; color: var(--slate); margin-top: 1px; }

/* --- Contenedor --- */
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 0; }
.intro { color: var(--slate); font-size: .92rem; margin: 6px 2px 16px; }
.spacer { height: 96px; }

/* --- Tarjetas --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.seccion-title { margin: 0; font-size: 1rem; font-weight: 700; }

/* --- Campos --- */
.field { display: flex; flex-direction: column; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--slate); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: none; overflow-y: hidden; line-height: 1.4; }
input:focus, select:focus, textarea:focus {
  border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(11,47,94,.14);
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; letter-spacing: .5px; text-transform: uppercase; }
.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(192,57,43,.12) !important; }

.row { display: flex; gap: 10px; }
.field-tipo { width: 96px; flex: 0 0 auto; }
.field-grow { flex: 1 1 auto; }

/* --- Firma --- */
/* Las firmas van al final del formulario: se firma después de revisar
   las unidades, nunca antes (evita firmar "un cheque en blanco"). */
.card-firmas { margin-top: 22px; }
.firmas-nota { margin: -4px 0 14px; font-size: .82rem; color: var(--slate); }
.firma-wrap { margin-top: 4px; }
.firma-wrap + .firma-wrap { margin-top: 18px; }
/* Nombre de quien firma, tomado del campo de arriba: en la tarjeta de
   firmas ya no se ve a quién corresponde cada recuadro. */
.firma-nombre { color: var(--ink); font-weight: 700; }
.firma-nombre:not(:empty)::before { content: " · "; color: var(--slate); font-weight: 400; }
.firma-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.firma-head > span { font-size: .82rem; font-weight: 600; color: var(--slate); }
.firma {
  width: 100%;
  height: 180px;
  border: 1px dashed #B9C2CC;
  border-radius: 10px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(45deg, #FafBfC, #FafBfC 6px, #F2F5F8 6px, #F2F5F8 12px);
  touch-action: none;
  display: block;
}
.btn-link {
  background: none; border: none; color: var(--steel);
  font: inherit; font-weight: 600; font-size: .82rem;
  padding: 6px 2px; cursor: pointer;
}

/* --- Unidades --- */
.unidades-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 2px 12px;
}
.contador {
  background: var(--navy); color: #fff;
  font-size: .78rem; font-weight: 700;
  min-width: 24px; height: 24px; padding: 0 8px;
  border-radius: 12px; display: inline-flex;
  align-items: center; justify-content: center;
}
.unidad { padding: 0; overflow: hidden; }
.unidad-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer;
  min-height: var(--tap);
}
.unidad-titulo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.unidad-n { font-weight: 700; font-size: .95rem; }
.unidad-resumen {
  font-size: .8rem; color: var(--slate);
  font-family: "IBM Plex Mono", monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw;
}
.unidad-acciones { display: flex; align-items: center; gap: 6px; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 8px;
  border: none; background: #F3F5F7; color: var(--danger);
  font-size: 1rem; cursor: pointer;
}
.chevron { color: var(--slate); font-size: 1rem; transition: transform .15s; }
.unidad.colapsada .chevron { transform: rotate(-90deg); }
.unidad-body { padding: 0 16px 16px; }
.unidad.colapsada .unidad-body { display: none; }

/* Segmento VIN / Placa */
.seg {
  display: flex; background: #EEF1F4; border-radius: 10px;
  padding: 4px; margin-bottom: 14px; gap: 4px;
}
.seg-btn {
  flex: 1; min-height: 40px; border: none; border-radius: 7px;
  background: transparent; color: var(--slate); font: inherit; font-weight: 600;
  cursor: pointer; transition: background .12s, color .12s;
}
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
/* Dentro de un .field el margen lo pone el propio campo, no el segmento. */
.field > .seg { margin-bottom: 0; }

/* --- Fotos de la unidad --- */
.opcional {
  font-style: normal; font-weight: 500; color: var(--slate);
  opacity: .75; font-size: .76rem; margin-left: 4px;
}
.fotos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px; margin-bottom: 10px;
}
.foto-item { position: relative; aspect-ratio: 4 / 3; }
.foto-item img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); display: block;
}
/* Tap target amplio: se pulsa con guantes y a pleno sol. */
.foto-quitar {
  position: absolute; top: -7px; right: -7px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff; background: var(--danger); color: #fff;
  font-size: .78rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(14,27,46,.3);
}
.fotos-acciones { display: flex; gap: 8px; }
.btn-foto {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); border: 1.5px dashed var(--line);
  border-radius: 10px; color: var(--navy); font-weight: 600;
  cursor: pointer; background: #fff; user-select: none;
}
.btn-foto:active { background: #F3F5F7; }
/* La cámara es el camino principal: el conductor fotografía el daño en el
   momento. La galería queda como alternativa, con menos peso visual. */
.btn-foto-camara { border-style: solid; border-color: var(--navy); }
.btn-foto-camara::before { content: "📷"; font-size: 1.05rem; }

/* Peso acumulado del conforme, junto al contador de unidades. */
.peso-fotos {
  font-size: .78rem; font-weight: 600; color: var(--slate);
  margin-left: auto; white-space: nowrap;
}
.peso-fotos.apretado { color: var(--red); }

/* --- Botones --- */
.btn-primary, .btn-secondary {
  width: 100%; min-height: var(--tap);
  border-radius: 10px; font: inherit; font-weight: 700; font-size: 1rem;
  cursor: pointer; border: none;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:active { background: var(--red-press); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-secondary {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  margin-bottom: 12px;
}
.btn-secondary:active { background: #F3F5F7; }

/* --- Barra de acción fija --- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(238,241,244,.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.actionbar > .btn-primary { max-width: 640px; margin: 0 auto; display: block; }

/* --- Error --- */
.error-box {
  background: #FCEBEA; border: 1px solid #F2C4bf; color: #8A2A20;
  border-radius: 10px; padding: 12px 14px; font-size: .9rem; margin-bottom: 14px;
}

/* --- Éxito --- */
.vista-exito { padding-top: 40px; }
.exito-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 24px; text-align: center;
}
.check {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success); color: #fff;
  font-size: 2rem; line-height: 64px; margin: 0 auto 16px;
}
.exito-card h2 { margin: 0 0 8px; }
.exito-card p { color: var(--slate); margin: 0 0 6px; }
.folio-line { font-size: .9rem; margin-bottom: 22px !important; }
.folio-line strong { font-family: "IBM Plex Mono", monospace; color: var(--ink); }
.exito-card .btn-secondary { margin-bottom: 12px; }
.warn { color: #9A6A00 !important; font-weight: 600; }
