:root {
  --ground: #F4F1EA; --card: #FFFFFF; --ink: #14201F; --muted: #5A6664; --line: #DDD7C8;
  --teal: #0F5C55; --teal-dark: #0B4A44; --teal-soft: #DCEBE8; --amber-soft: #FBEBC4; --amber-ink: #6B4A00;
  --red-soft: #F6D8D3; --red-ink: #8A2A1D; --band: #2B3E4C; --side: #14201F;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: #E7E1D2; }
body { font-family: var(--body); color: var(--ink); font-size: 16px; line-height: 1.4; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--teal); }

#marco { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--ground); display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0,0,0,.08); }
.band { height: 52px; background: var(--band); display: flex; justify-content: center; flex-shrink: 0; padding-top: env(safe-area-inset-top); }
.band img { height: 52px; width: auto; display: block; }
.raiz { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pie-app { background: var(--side); color: #E9E4D8; font-size: 11px; text-align: center; padding: 7px 0 calc(7px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.cargando { padding: 40px 20px; text-align: center; color: var(--muted); }

.pantalla { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 20px; }
.org { font-size: 12px; font-weight: 600; color: var(--teal); }
.fila-cab { display: flex; align-items: center; gap: 12px; }
.fila-cab h1 { font-family: var(--display); font-size: 24px; font-weight: 700; }
.saludo { display: flex; justify-content: space-between; align-items: center; }
.saludo .fecha { font-size: 14px; color: var(--muted); }
.saludo h1 { font-family: var(--display); font-size: 28px; font-weight: 700; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: #DCE6E3; color: var(--teal); font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.atras { width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.atras svg, .ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tarjeta .fila { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tarjeta .et { font-size: 14px; color: var(--muted); }
.tarjeta .puesto { font-family: var(--display); font-size: 22px; font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 5px 10px; border-radius: 999px; background: #EFE9DA; color: var(--muted); font-weight: 500; }
.chip.ok { background: var(--teal-soft); color: var(--teal-dark); }
.chip.aviso { background: var(--amber-soft); color: var(--amber-ink); }
.chip.mal { background: var(--red-soft); color: var(--red-ink); }
.chip svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.boton-grande { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 76px; border-radius: 20px; background: var(--teal); color: #fff; font-family: var(--display); font-size: 22px; font-weight: 600; border: 0; cursor: pointer; text-decoration: none; width: 100%; }
.boton-grande:active { background: var(--teal-dark); }
.boton-grande:disabled { opacity: .5; }
.boton-grande svg { width: 28px; height: 28px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boton-borde { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; border-radius: 14px; border: 1.5px solid var(--teal); color: var(--teal); font-weight: 600; background: transparent; cursor: pointer; text-decoration: none; width: 100%; }
.boton-borde svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.boton-texto { background: none; border: 0; color: var(--teal); text-decoration: underline; padding: 8px; cursor: pointer; }
.boton-grande:focus-visible, .boton-borde:focus-visible, .atras:focus-visible, .nav-item:focus-visible, .opcion:focus-visible { outline: 3px solid #7FB8B1; outline-offset: 2px; }

.caja-aviso { display: flex; gap: 10px; align-items: flex-start; border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.4; background: var(--amber-soft); color: var(--amber-ink); }
.caja-aviso.mal { background: var(--red-soft); color: var(--red-ink); }
.caja-aviso.ok { background: var(--teal-soft); color: var(--teal-dark); }
.caja-aviso svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.caja-aviso .boton-texto { color: inherit; padding: 4px 0 0; display: block; font-size: 14px; }

.lista h2 { font-family: var(--display); font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.item .t { font-weight: 500; }
.item .d { font-size: 13px; color: var(--muted); }
.item .h { text-align: right; font-weight: 600; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.vacio { color: var(--muted); padding: 14px 0; }

.nav-inferior { margin-top: auto; display: flex; background: var(--card); border-top: 1px solid var(--line); position: sticky; bottom: 0; }
.nav-item { flex: 1; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
.nav-item.activo { color: var(--teal); font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label, .etiqueta { font-size: 14px; font-weight: 600; }
.campo input, .campo textarea, .campo select { min-height: 52px; border-radius: 12px; border: 1px solid #C9C2AF; background: #fff; padding: 0 14px; font-size: 18px; width: 100%; }
.campo textarea { padding: 12px 14px; min-height: 84px; font-size: 16px; resize: none; }
.campo input:focus, .campo textarea:focus { outline: 3px solid #7FB8B1; outline-offset: 1px; }
.campo .ayuda { font-size: 13px; color: var(--muted); }
.codigo-in { letter-spacing: .4em; text-align: center; font-family: var(--display); font-size: 26px !important; }
.opciones { display: flex; flex-wrap: wrap; gap: 8px; }
.opcion { min-height: 44px; padding: 0 16px; border-radius: 999px; background: #fff; border: 1px solid #C9C2AF; cursor: pointer; font-size: 16px; }
.opcion[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.segmento { display: flex; background: #E7E1D2; border-radius: 14px; padding: 4px; }
.segmento button { flex: 1; min-height: 44px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 500; }
.segmento button[aria-pressed="true"] { background: #fff; color: var(--teal); font-weight: 600; }
.segmento svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Registro */
.mapa { height: 210px; border-radius: 18px; background: #DCE6E3; position: relative; overflow: hidden; border: 1px solid #C9D6D2; }
.mapa svg { width: 100%; height: 100%; display: block; }
.mapa .rotulo { position: absolute; left: 12px; bottom: 12px; background: #fff; border-radius: 10px; padding: 5px 10px; font-size: 13px; font-weight: 600; max-width: calc(100% - 24px); }
.escaner { height: 250px; border-radius: 18px; background: #14201F; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; color: #E9E4D8; text-align: center; padding: 16px; }
.escaner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.escaner .marco-qr { position: absolute; width: 60%; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.escaner p { position: relative; z-index: 1; }
.foto-fila { display: flex; gap: 14px; align-items: center; }
.foto-caja { width: 104px; height: 128px; border-radius: 14px; background: #14201F; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0; color: #E9E4D8; font-size: 12px; overflow: hidden; border: 0; cursor: pointer; padding: 0; }
.foto-caja img { width: 100%; height: 100%; object-fit: cover; }
.foto-caja svg { width: 34px; height: 34px; stroke: #E9E4D8; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.foto-fila h3 { font-family: var(--display); font-size: 18px; font-weight: 600; }
.foto-fila p { font-size: 14px; color: var(--muted); margin-top: 4px; }
.camara { position: fixed; inset: 0; background: #000; z-index: 30; display: flex; flex-direction: column; }
.camara video { flex: 1; width: 100%; min-height: 0; object-fit: cover; transform: scaleX(-1); }
.camara .controles { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px calc(18px + env(safe-area-inset-bottom)); background: #000; }
.camara .disparo { width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; background: #fff; box-shadow: inset 0 0 0 4px #000; cursor: pointer; }
.camara button.txt { background: none; border: 0; color: #fff; font-size: 16px; padding: 12px; }
.pie-accion { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.pie-accion .nota { text-align: center; font-size: 13px; color: var(--muted); }

.exito { align-items: center; text-align: center; justify-content: center; gap: 14px; }
.exito .grande { width: 96px; height: 96px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: flex; align-items: center; justify-content: center; }
.exito .grande.aviso { background: var(--amber-soft); color: var(--amber-ink); }
.exito .grande svg { width: 52px; height: 52px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.exito h1 { font-family: var(--display); font-size: 28px; }
.exito p { color: var(--muted); }
.toast { position: fixed; left: 16px; right: 16px; bottom: 80px; max-width: 448px; margin: 0 auto; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 40; text-align: center; }
.toast.error { background: var(--red-ink); }
