:root {
  --navy: #1F2557;
  --navy-90: #2A305F;
  --mint: #2DD881;
  --mint-dark: #25BF72;
  --mint-tint: rgba(45, 216, 129, 0.08);
  --mint-ring: rgba(45, 216, 129, 0.20);
  --gold: #FFD23F;
  --white: #FFFFFF;
  --bg: #F7F8FA;
  --gray-text: #6B7280;
  --gray-border: #E5E7EB;
  --gray-border-strong: #D1D5DB;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --red-border: #FECACA;
  --radius-input: 8px;
  --radius-card: 12px;
  --radius-btn: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--navy);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  font-size: 16px;
  min-height: 100vh;
  min-height: 100dvh;
}

.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header__inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-tag {
  font-size: 13px;
  color: var(--gray-text);
  font-weight: 500;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.hero { margin-bottom: 24px; }
.hero h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--navy);
  margin: 0 0 10px;
  line-height: 1.1;
}
.hero p {
  font-size: 16px;
  color: var(--gray-text);
  margin: 0;
  max-width: 44ch;
}

.marker {
  background: var(--mint);
  color: var(--navy);
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.marker--gold { background: var(--gold); }

.card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-card);
  padding: 26px;
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}
.req { color: var(--red); font-weight: 600; }

.badge-prefilled {
  display: inline-flex;
  align-items: center;
  background: var(--gold);
  color: var(--navy);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  line-height: 1;
}

.input, .textarea, .select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-input);
  padding: 14px 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder, .textarea::placeholder { color: #9CA3AF; font-weight: 400; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 3px var(--mint-ring);
}
.input:disabled, .select:disabled {
  background: #f1f5f9;
  color: var(--gray-text);
  cursor: not-allowed;
}
.textarea { resize: vertical; min-height: 110px; line-height: 1.45; }

.select-wrap { position: relative; }
.select { padding-right: 44px; cursor: pointer; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--navy);
  border-bottom: 2px solid var(--navy);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 400px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Transpaleta: input + chip de confirmación */
.maquina-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.maquina-chip {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid;
}
.maquina-chip.is-ok {
  display: flex;
  background: var(--mint-tint);
  border-color: var(--mint);
  color: var(--mint-dark);
}
.maquina-chip.is-warn {
  display: flex;
  background: #FFFBEB;
  border-color: #FCD34D;
  color: #92400E;
}
.maquina-chip.is-loading {
  display: flex;
  background: var(--bg);
  border-color: var(--gray-border);
  color: var(--gray-text);
}
.maquina-chip__icon { flex-shrink: 0; }

.photo-zone {
  position: relative;
  border: 2px dashed var(--gray-border-strong);
  background: var(--bg);
  border-radius: var(--radius-input);
  padding: 22px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.photo-zone:hover { border-color: var(--navy); }
.photo-zone__icon { width: 32px; height: 32px; color: var(--navy); }
.photo-zone__text { font-weight: 600; color: var(--navy); font-size: 15px; }
.photo-zone__hint { font-size: 13px; color: var(--gray-text); }
.photo-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-zone.is-loaded { border-style: solid; border-color: var(--mint); background: var(--mint-tint); }
.photo-zone.is-loaded .photo-zone__icon { display: none; }
.photo-zone.is-loaded .photo-zone__icon--check { display: inline-block; color: var(--mint-dark); }
.photo-zone__icon--check { display: none; }
.photo-zone.is-processing { pointer-events: none; opacity: 0.75; }

/* Grilla de previews de fotos */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.photo-grid:empty { display: none; margin-top: 0; }
.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--gray-border);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.photo-item__remove:hover { background: rgba(0, 0, 0, 0.8); }

.submit-btn {
  width: 100%;
  background: var(--mint);
  color: var(--navy);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.005em;
  border: none;
  border-radius: var(--radius-btn);
  padding: 16px 20px;
  cursor: pointer;
  transition: background-color 150ms ease, transform 80ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}
.submit-btn:hover:not(:disabled) { background: var(--mint-dark); }
.submit-btn:active:not(:disabled) { transform: translateY(1px); }
.submit-btn:disabled { background: #E5E7EB; color: #9CA3AF; cursor: not-allowed; }

.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(31, 37, 87, 0.25);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  display: none;
  background: var(--red-soft);
  border: 1px solid var(--red-border);
  color: var(--red);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 8px;
  margin-top: 4px;
}
.form-error.is-visible { display: block; }

.field--error .input,
.field--error .textarea,
.field--error .select,
.field--error .photo-zone { border-color: var(--red); }
.field__msg { font-size: 12.5px; color: var(--red); font-weight: 500; margin-top: 2px; display: none; }
.field--error .field__msg { display: block; }

/* Banner de carga del mapeo */
.mapeo-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-text);
  padding: 8px 0 2px;
}
.mapeo-status.hidden { display: none; }

.success { display: none; text-align: center; padding: 12px 4px 4px; }
.success.is-visible { display: block; }
.success__check {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--mint);
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
  animation: pop 380ms cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes pop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.success__check svg { width: 52px; height: 52px; }
.success__check path {
  stroke: var(--white); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; fill: none;
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: draw 420ms 220ms ease-out forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.success h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--navy); margin: 0 0 6px; }
.success p { color: var(--gray-text); margin: 0 0 22px; font-size: 15px; }
.success__id-label { font-size: 12px; color: var(--gray-text); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 8px; }
.success__id-chip { display: inline-block; background: var(--gold); color: var(--navy); font-family: var(--font-mono); font-weight: 700; font-size: 15px; padding: 8px 14px; border-radius: 6px; margin-bottom: 28px; letter-spacing: 0.02em; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--white); color: var(--navy);
  border: 1px solid var(--gray-border-strong);
  font-family: inherit; font-weight: 600; font-size: 15px;
  padding: 13px 22px; border-radius: var(--radius-btn);
  cursor: pointer; transition: background-color 150ms ease, border-color 150ms ease;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--navy); }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .hero h1 { font-size: 27px; }
  .card { padding: 20px; }
  .page { padding: 24px 16px 56px; }
  .site-header { padding: 14px 16px; }
}

/* ─── Visor de fotos (src/lightbox.js) ──────────────────────────────────────
   Tocar una miniatura del formulario la amplía a pantalla completa. Misma
   estructura que el visor de las apps React (apps/fleet-web/src/styles/
   photo-lightbox.css), con prefijo propio `.sw-lightbox`. Este formulario es
   una página aparte (no se monta en el shell), así que no aplica el scope de
   scripts/audit-css-scope.py; igual todo va bajo un prefijo único. */
.sw-lightbox {
  position: fixed;
  inset: 0;
  height: 100dvh;
  /* Si la página de abajo desborda en horizontal, Chrome móvil agranda el
     layout viewport y `inset: 0` quedaría más ancho que la pantalla (la X
     fuera de vista). `100vw` es el ancho de pantalla; como tope (no como
     `width`) no mete el overlay bajo la barra de scroll en escritorio. */
  max-width: 100vw;
  z-index: 1000;
  /* Marino de marca, casi opaco: la foto es lo único que importa acá. */
  background: rgba(20, 21, 42, 0.96);
  color: #ffffff;
  font-family: inherit;
  /* El overlay no scrollea ni deja que el gesto llegue al fondo; los gestos
     (swipe, pinch, doble tap) los maneja el componente. */
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  animation: sw-lightbox-in 160ms ease-out;
}

.sw-lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Aire arriba para la barra (contador / Descargar / cerrar), respetando el
     notch. Abajo solo el safe-area: la foto usa todo lo que queda. */
  padding: calc(64px + env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px)
    calc(12px + env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px);
  box-sizing: border-box;
  overflow: hidden;
  cursor: zoom-out;
}
.sw-lightbox__stage--multi {
  /* Con varias fotos, en móvil anterior/siguiente van abajo (alcance del
     pulgar); se les deja su franja. */
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

.sw-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  opacity: 0;
  transform-origin: center center;
  transition:
    transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 160ms ease-out;
  will-change: transform;
  -webkit-user-drag: none;
}
.sw-lightbox__img--loaded {
  opacity: 1;
}
.sw-lightbox__img--gesturing {
  /* Mientras el dedo arrastra, la foto sigue al dedo sin retraso. */
  transition: opacity 160ms ease-out;
}

.sw-lightbox__loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
  pointer-events: none;
}

.sw-lightbox__error {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  margin: 0 16px;
  padding: 20px;
  border: 1px solid rgba(255, 77, 77, 0.55);
  border-radius: 12px;
  background: rgba(255, 77, 77, 0.12);
  font-size: 15px;
  line-height: 1.45;
  text-align: center;
  cursor: default;
}
.sw-lightbox__error strong {
  font-size: 16px;
}

/* Barra superior: el contenedor no captura toques (pasan al escenario), solo
   sus controles. */
.sw-lightbox__bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 10px
    max(12px, env(safe-area-inset-left, 0px));
  pointer-events: none;
}
.sw-lightbox__bar > * {
  pointer-events: auto;
}
.sw-lightbox__counter {
  font-family: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}
.sw-lightbox__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sw-lightbox__btn,
.sw-lightbox__download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background-color 150ms ease,
    border-color 150ms ease;
}
.sw-lightbox__btn {
  width: 48px;
  height: 48px;
  padding: 0;
}
.sw-lightbox__download {
  gap: 8px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.sw-lightbox__btn svg,
.sw-lightbox__download svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sw-lightbox__download svg {
  width: 18px;
  height: 18px;
}
.sw-lightbox__btn:hover:not(:disabled),
.sw-lightbox__download:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.34);
}
.sw-lightbox__btn:focus-visible,
.sw-lightbox__download:focus-visible {
  outline: none;
  border-color: #00d97e;
  box-shadow: 0 0 0 3px rgba(0, 217, 126, 0.45);
}
.sw-lightbox__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Anterior / siguiente: en móvil, abajo y centrados (alcance del pulgar). */
.sw-lightbox__nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 12px 12px max(14px, env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.sw-lightbox__nav > * {
  pointer-events: auto;
}

/* Escritorio: flechas a los costados, centradas en alto, y la foto con aire. */
@media (min-width: 901px) {
  .sw-lightbox__stage,
  .sw-lightbox__stage--multi {
    padding: 72px 88px 32px;
  }
  .sw-lightbox__nav {
    top: 0;
    bottom: 0;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
  }
}

@keyframes sw-lightbox-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sw-lightbox {
    animation: none;
  }
  .sw-lightbox__img,
  .sw-lightbox__img--gesturing {
    transition: none;
  }
}


/* Miniatura: la imagen es un botón que abre el visor. El botón de quitar (×)
   queda por encima y es hermano, no hijo, así que su toque nunca abre el
   visor. Su área táctil crece a 44px con un ::before invisible (web/DESIGN.md
   §7) sin cambiar cómo se ve: ahora que el resto de la miniatura hace algo,
   errarle por poco al × ya no es un toque inofensivo. */
.photo-item__open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}
.photo-item__open:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px var(--mint);
}
.photo-item__remove { z-index: 1; }
.photo-item__remove::before {
  content: "";
  position: absolute;
  top: -11px;
  right: -11px;
  width: 44px;
  height: 44px;
}
