:root {
  --acento: #0b5cad;
  --acento-oscuro: #08457f;
  --texto: #1d2230;
  --suave: #4a5163;
  --fondo: #f5f6f8;
  --tarjeta: #ffffff;
  --borde: #c5cad6;
  --error: #8a1010;
  --ok: #0d5a25;
  --radio: 8px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem; line-height: 1.45; font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--acento); }
:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }
.solo-lector { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Estructura */
.cabecera { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  background: var(--acento); color: #fff; padding: .6rem 1rem; }
.cabecera strong { font-size: 1.1rem; }
.cabecera .quien { display: flex; gap: .75rem; align-items: center; }
.contenido { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 1rem; margin-bottom: 1rem; }
.fila { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.fila > * { flex: 1 1 160px; }
.fila > .fijo { flex: 0 0 auto; }
.suave { color: var(--suave); }
.mudo { color: var(--suave); font-size: .95rem; }

/* Pestañas: botones redondeados, la activa en azul */
.pestanas { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.pestanas button { border: 1px solid var(--borde); background: #fff; color: var(--texto); padding: 0 1rem; min-height: 48px; font: inherit; font-weight: 400;
  border-radius: 999px; cursor: pointer; }
.pestanas button:hover { background: #e9f1fa; }
.pestanas button[aria-selected="true"], .pestanas button[aria-selected="true"]:hover { background: var(--acento); border-color: var(--acento); color: #fff; font-weight: 700; }

/* Campos y botones: 48 px o más */
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; min-height: 48px; padding: .5rem .75rem; border: 1px solid #767d90; border-radius: var(--radio);
  background: #fff; color: var(--texto); }
textarea { min-height: 96px; }
input[type=checkbox], input[type=radio] { width: 24px; height: 24px; vertical-align: middle; margin-right: .5rem; }
.casilla { display: flex; align-items: center; min-height: 48px; font-weight: 400; }
button, .boton { min-height: 48px; padding: .5rem 1.1rem; border: 1px solid var(--acento); border-radius: var(--radio);
  background: var(--acento); color: #fff; font-weight: 600; cursor: pointer; }
button:hover { background: var(--acento-oscuro); }
button.secundario { background: #fff; color: var(--acento-oscuro); }
button.secundario:hover { background: #e9f1fa; }
button.peligro { background: #fff; color: var(--error); border-color: var(--error); }
button:disabled { background: #e3e5ea; color: #555b6b; border-color: #aab0be; cursor: not-allowed; }
button.chico { min-height: 48px; padding: .25rem .75rem; }
.error { color: var(--error); font-weight: 600; }
.exito { color: var(--ok); font-weight: 600; }
.aviso-caja { border-left: 6px solid #b36b00; background: #fff4de; padding: .75rem 1rem; border-radius: var(--radio); margin: .75rem 0; }
.error-caja { border-left: 6px solid var(--error); background: #fdeaea; padding: .75rem 1rem; border-radius: var(--radio); margin: .75rem 0; }

/* Estados: siempre con texto */
.estado { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.e-faltante { background: #fde8e8; color: #8a1010; }
.e-sobrante { background: #e3eefc; color: #0b3a82; }
.e-averia { background: #fff1d6; color: #7a4a00; }
.e-cuadrado { background: #e1f4e6; color: #0d5a25; }
.e-nocreado { background: #efe6fb; color: #5b25a3; }
.e-revisar { background: #e8e8ea; color: #33333a; }
.e-otro { background: #fff; color: var(--suave); }

/* Tablas */
.tabla-caja { overflow: auto; max-height: 70vh; border: 1px solid var(--borde); border-radius: var(--radio); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid #e0e3ea; text-align: left; vertical-align: top; }
td.num, th.num { text-align: right; white-space: nowrap; }
thead th { position: sticky; top: 0; background: #e9ecf3; z-index: 1; white-space: nowrap; }
.pagina { display: flex; gap: .75rem; align-items: center; margin-top: .5rem; flex-wrap: wrap; }
.indicadores { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.indicador { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: .5rem .75rem; }
.indicador b { display: block; font-size: 1.25rem; }
.barra { height: 10px; background: #e0e3ea; border-radius: 5px; overflow: hidden; min-width: 80px; }
.barra > span { display: block; height: 100%; background: var(--ok); }
.cero { color: var(--error); font-weight: 700; }
.parcial { color: #7a4a00; font-weight: 700; }

/* Pantalla Contar */
.contar-cab { position: sticky; top: 0; z-index: 5; background: var(--fondo); padding: .5rem 0; border-bottom: 1px solid var(--borde); }
.contar-cab .progreso { font-size: 1.2rem; font-weight: 700; }
.grupo-ub { margin: 1rem 0 .25rem; font-weight: 700; color: var(--acento-oscuro); }
.item { background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: .75rem; margin-bottom: .5rem; }
.item.contado { border-left: 6px solid var(--ok); }
.item .codigo { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.item .nombre { color: var(--suave); }
.cantidades { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .5rem 0; }
.cantidades input { font-size: 1.25rem; text-align: right; }
.sin-conteo { color: var(--suave); }

@media (min-width: 700px) {
  .contenido { padding: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* v2: catálogo */
button.grande { min-height: 56px; font-size: 1.15rem; width: 100%; }
details.tarjeta > summary, .tarjeta details > summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; align-items: center; }
.tarjeta details > summary { display: list-item; padding: .75rem 0; }
form.tarjeta > .fila { margin-top: .75rem; }
.codigos-sin { overflow-wrap: anywhere; font-family: monospace; }

a.boton { display: flex; align-items: center; justify-content: center; text-decoration: none; margin: .5rem 0; }

/* v3: asistente por pasos y conteo en filas */
[hidden] { display: none !important; }
.centrado { text-align: center; }
progress { width: 100%; height: 14px; accent-color: var(--acento); }
.paso > .tarjeta, .paso > div > .tarjeta, .saludo { border-radius: 14px; box-shadow: 0 1px 3px rgb(20 30 60 / .08); }
.saludo { font-size: 1.15rem; text-align: center; padding: 2rem 1rem; }

/* Barra de pasos */
.pasos { display: flex; list-style: none; margin: 0 0 .5rem; padding: 0; }
.pasos li { flex: 1; position: relative; display: flex; justify-content: center; }
.pasos li::before { content: ""; position: absolute; top: 23px; right: 50%; width: 100%; height: 3px; background: var(--borde); }
.pasos li:first-child::before { display: none; }
.pasos li.andado::before { background: var(--acento); }
.pasos button, .pasos .sin-toque { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem; min-height: 48px; padding: 8px 0 0;
  border: 0; background: none; color: var(--suave); font-weight: 400; font-size: .9rem; }
.pasos button:hover { background: none; color: var(--acento-oscuro); }
.pasos .punto { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 2px solid var(--borde); font-weight: 700; }
.pasos .hecho .punto { background: var(--ok); border-color: var(--ok); color: #fff; }
.pasos .actual .punto { background: var(--acento); border-color: var(--acento); color: #fff; box-shadow: 0 0 0 4px #d3e4f6; }
.pasos .actual .sin-toque { color: var(--acento-oscuro); font-weight: 700; }
.paso-movil { display: none; text-align: center; font-weight: 700; color: var(--acento-oscuro); margin: 0 0 .75rem; }
@media (max-width: 699px) {
  .pasos .nombre-paso { display: none; }
  .pasos li::before { top: 22px; }
  .pasos button, .pasos .sin-toque { min-width: 44px; }
  .pasos .punto { width: 28px; height: 28px; }
  .paso-movil { display: block; }
}

/* Pie fijo */
.pie-fijo { position: sticky; bottom: 0; z-index: 6; background: var(--fondo); padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--borde); }
.pie-fijo p { margin: 0 0 .35rem; }
.pie-fijo .aviso-caja { margin: 0 0 .5rem; }
.pie-asistente .botones { display: flex; gap: .75rem; justify-content: flex-end; }
.pie-asistente .principal { min-height: 56px; font-size: 1.1rem; flex: 1 1 auto; max-width: 360px; }
.pie-asistente .secundario { min-height: 56px; }

.opcion { display: flex; align-items: center; gap: .5rem; border: 2px solid var(--borde); border-radius: 12px; padding: .9rem; margin-bottom: .6rem; cursor: pointer; }
.opcion:has(input:checked) { border-color: var(--acento); background: #eef5fd; }
.opcion span span { display: block; font-weight: 400; }
.equipo { padding-left: .5rem; }
.renglon { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .6rem 0; border-top: 1px solid #e0e3ea; }
.renglon-avance { display: grid; grid-template-columns: minmax(90px, 1fr) 1.4fr; gap: .5rem; align-items: center; padding: .25rem 0; overflow-wrap: anywhere; }
.avance { display: block; }
.avance .barra { display: block; }
.avance .mudo { display: block; font-size: .85rem; }
.personas { list-style: none; padding: 0; margin: .75rem 0 0; }
.personas li { padding: .35rem 0; border-top: 1px solid #e0e3ea; }
@media (min-width: 900px) {
  .paso.dos { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
}

/* Conteo en filas */
.conteo-filas .tope { position: sticky; top: 0; z-index: 5; background: var(--fondo); padding: .35rem 0 .5rem; border-bottom: 1px solid var(--borde); }
.titulo-conteo { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado-conteo { color: var(--suave); font-size: .95rem; margin-bottom: .35rem; }
input.campo-unico { min-height: 56px; font-size: 1.15rem; border: 2px solid var(--acento); border-radius: 12px; margin-bottom: .35rem; }
.sugerencias:not(:empty) { max-height: 45vh; overflow: auto; margin-bottom: .35rem; }
.sugerencias > p { margin: .25rem 0; }
button.sugerencia { display: block; width: 100%; text-align: left; background: #fff; color: var(--texto); border: 1px solid var(--borde); margin-bottom: .25rem; padding: .5rem .75rem; font-weight: 400; }
button.sugerencia:hover { background: #e9f1fa; }
button.sugerencia .fc-nombre, button.sugerencia .fc-cod { display: block; }
button.sugerencia.siguiente { border: 3px solid var(--acento); background: #eef5fd; }
.filas { list-style: none; margin: .5rem 0; padding: 0; }
.fila-c { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .5rem; align-items: center; min-height: 72px; background: #fff;
  border: 1px solid var(--borde); border-radius: 12px; padding: .6rem; margin-bottom: .5rem; transition: background-color .4s; scroll-margin: 13rem 0 6rem; }
.fila-c.resaltada { background: #fff2c2; border-color: #b36b00; }
.fc-nombre { font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.fc-cod { color: var(--suave); font-size: .85rem; font-weight: 400; overflow-wrap: anywhere; }
.fc-nota span { display: block; font-size: .85rem; }
.etiqueta-averia { color: #7a4a00; font-weight: 700; }
.contador { display: flex; gap: .25rem; align-items: center; }
.contador button { width: 56px; height: 56px; padding: 0; font-size: 1.6rem; line-height: 1; border-radius: 12px; touch-action: manipulation; }
.contador input[type=text] { width: 5.2ch; min-width: 0; height: 56px; padding: 0 .25rem; font-size: 1.5rem; font-weight: 700; text-align: right; box-sizing: content-box; }
.contador input[aria-invalid="true"] { border: 3px solid var(--error); }
.fc-acciones { grid-column: 1 / -1; display: flex; gap: 1.25rem; }
button.enlace { min-height: 44px; padding: 0; border: 0; background: none; color: var(--acento); text-decoration: underline; font-weight: 400; }
button.enlace:hover { background: none; }
.fc-averia { grid-column: 1 / -1; border-top: 1px dashed var(--borde); padding-top: .5rem; }
.fc-averiadas { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; font-weight: 600; }
.vacio { color: var(--suave); text-align: center; padding: 1.5rem 1rem; }
.toast { position: fixed; left: 1rem; right: 1rem; bottom: 6.5rem; z-index: 8; max-width: 520px; margin: 0 auto; display: flex; gap: .75rem; align-items: center; justify-content: space-between;
  background: var(--texto); color: #fff; border-radius: 12px; padding: .5rem .5rem .5rem 1rem; }
.toast button { background: #fff; color: var(--acento-oscuro); border-color: #fff; flex: 0 0 auto; }
dialog.hoja { width: min(100%, 640px); max-width: 100%; height: 90dvh; max-height: 90dvh; margin: auto auto 0; border: 0; border-radius: 16px 16px 0 0; padding: 0 .75rem .75rem; background: var(--fondo); color: var(--texto); }
dialog.hoja::backdrop { background: rgb(15 20 35 / .55); }
.hoja-cab { position: sticky; top: 0; background: var(--fondo); display: flex; gap: .5rem; align-items: center; justify-content: space-between; padding: .75rem 0; }
.hoja-cab h2 { margin: 0; flex: 1; }

/* Revisar */
.revisar { border-top: 1px solid #e0e3ea; padding: .75rem 0; }
.revisar > .fila { margin-top: .5rem; }
.reconteo { border: 2px solid var(--acento); border-radius: 12px; padding: .75rem; margin-top: .5rem; }

@media (max-width: 699px) {
  .contenido { padding: .75rem; }
  .cabecera .quien { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .fila-c { transition: none; } }
@media print {
  .cabecera, nav, .pie-fijo, .no-imprimir, .centrado, button, input, select, label, .pagina, .aviso-caja { display: none !important; }
  body { background: #fff; }
  .tarjeta { border: 0; box-shadow: none; padding: 0; }
  .tabla-caja { max-height: none; overflow: visible; border: 0; }
  thead th { position: static; }
}

/* Cámara */
.campo-fila { display: flex; gap: .4rem; }
.campo-fila .campo-unico { flex: 1; min-width: 0; }
.btn-camara { min-height: 56px; border-radius: 12px; padding-inline: .6rem; }
.campo-fila .campo-unico::placeholder { font-size: .95rem; }
.btn-camara[aria-pressed="true"], .camara button[aria-pressed="true"] { background: var(--acento-oscuro); color: #fff; }
.camara .visor { position: relative; height: 32vh; background: #000; border-radius: 12px; overflow: hidden; }
.camara video { width: 100%; height: 100%; object-fit: cover; display: block; }
.franja { position: absolute; left: 7.5%; top: 30%; width: 85%; height: 40%; border: 3px solid #fff; border-radius: 10px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / .35); }
.franja.ok { border-color: #35d06a; background: rgb(53 208 106 / .35); }
.camara-estado { margin: .25rem 0; text-align: center; font-size: .95rem; }
.camara-botones { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-bottom: .35rem; }
.camara-botones > div { margin: 0; flex: 1; justify-content: flex-start; }
.con-camara .titulo-conteo { display: none; }
/* Con la cámara leyendo, el campo se guarda: así las filas caben debajo. Si la cámara falla, se queda a la vista. */
.con-camara .tope:has(.camara.activa) > .buscador, .con-camara .tope:has(.camara.activa) > button { display: none; }

/* Paso 6 en el celular: cada ajuste es una tarjeta, sin desplazar de lado (columnas: código, nombre, tipo, cantidad…). */
@media (max-width: 699px) {
  .pos-pasos thead { display: none; }
  .pos-pasos table, .pos-pasos tbody { display: block; }
  .pos-pasos tr { display: flex; flex-wrap: wrap; gap: .2rem .75rem; padding: .7rem; border-bottom: 1px solid var(--borde); }
  .pos-pasos td { display: block; border: 0; padding: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .pos-pasos td:empty { display: none; }
  .pos-pasos td:nth-child(2) { order: -1; width: 100%; font-weight: 700; }
  .pos-pasos td:nth-child(4)::before { content: "Cantidad: "; }
  .pos-pasos td:nth-child(5):not(:empty)::before { content: "Nota para el kardex: "; font-weight: 600; }
  .pos-pasos td:nth-child(5) { width: 100%; }
  .pos-pasos td:last-child { width: 100%; }
}
.fc-sistema { font-weight: 700; }
.opcion-sistema { margin-top: .75rem; border-top: 1px solid var(--borde); padding-top: .5rem; }

/* Código leído que no existe: imposible no verlo. */
.no-existe { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgb(0 0 0 / .65); }
.no-existe-caja { width: min(100%, 28rem); max-height: 100%; overflow: auto; background: #c00; color: #fff; border-radius: 16px; padding: 1.25rem; text-align: center; font-size: 1.15rem; display: flex; flex-direction: column; gap: .75rem; }
.no-existe-caja p { margin: 0; overflow-wrap: anywhere; }
.no-existe-signo { font-size: 4rem; line-height: 1; }
.no-existe-titulo { font-size: 2.25rem; font-weight: 800; }
.no-existe-caja button { background: #fff; color: #8a1010; border-color: #fff; }
.no-existe-caja button.secundario { background: transparent; color: #fff; border: 2px solid #fff; }
.no-existe-linea { background: #c00; color: #fff; font-size: 1.35rem; font-weight: 800; padding: .75rem 1rem; border-radius: var(--radio); overflow-wrap: anywhere; }

/* Reportes */
.reportes { display: grid; gap: .75rem; }
button.reporte { display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; text-align: left; min-height: 72px; width: 100%; }

/* v4: pulido de la interfaz (2026-12-04) */
/* Cabecera: menú con botones de 44 px; nombre y Salir arriba a la derecha en el celular */
.cabecera .menu { display: flex; flex-wrap: wrap; gap: .25rem; }
.cabecera .menu a { color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 .85rem; border-radius: 999px; }
.cabecera .menu a:hover { background: rgb(255 255 255 / .18); }
.cabecera .menu a[aria-current="page"] { background: #fff; color: var(--acento-oscuro); font-weight: 700; }
@media (min-width: 900px) { .cabecera .menu { flex: 1; margin-left: 1rem; } }
@media (max-width: 899px) {
  .cabecera { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: .5rem .75rem; }
  .cabecera .quien { grid-column: 2; grid-row: 1; flex-wrap: nowrap; gap: .5rem; }
  .cabecera .quien span { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cabecera .menu { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 699px) {
  .cabecera .quien span { max-width: 6.5rem; }
  .cabecera .menu { gap: .1rem; }
  .cabecera .menu a { flex: 1 1 auto; padding: 0 .3rem; font-size: .9rem; }
}

/* Plegables con flecha visible */
details.tarjeta > summary { justify-content: space-between; }
details.tarjeta > summary::after { content: "▾"; font-size: 1.3rem; }
details.tarjeta[open] > summary::after { content: "▴"; }
details > summary:hover { color: var(--acento-oscuro); }

/* Enlaces sueltos con área de toque */
.centrado > a, a[target="_blank"] { display: inline-block; padding: .7rem .25rem; }

/* Celular: las tablas son tarjetas, sin desplazar de lado (panel.js pone la clase .apilar y data-et) */
@media screen and (max-width: 699px) {
  .indicador b { font-size: 1.1rem; overflow-wrap: anywhere; }
  .tabla-caja.apilar { overflow: visible; max-height: none; border: 0; background: none; }
  .tabla-caja.apilar table, .tabla-caja.apilar tbody { display: block; }
  .tabla-caja.apilar thead { display: none; }
  .tabla-caja.apilar tr { display: block; background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: .4rem .75rem; margin-bottom: .5rem; }
  .tabla-caja.apilar td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .3rem 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }
  .tabla-caja.apilar td::before { content: attr(data-et); flex: 0 0 38%; max-width: 38%; text-align: left; font-weight: 600; color: var(--suave); }
  .tabla-caja.apilar td:first-child { font-weight: 700; }
  .tabla-caja.apilar td:empty { display: none; }
  .tabla-caja.apilar td.num { white-space: normal; }
  .tabla-caja.apilar td:has(button, input, select) { flex-direction: column; align-items: stretch; text-align: left; gap: .25rem; }
  .tabla-caja.apilar td:has(button, input, select)::before { max-width: none; flex-basis: auto; }
  .tabla-caja.apilar td input[style] { min-width: 0 !important; }
}
@media (max-width: 699px) {
  .fila > .fijo { flex: 1 1 100%; }
  .fila > .fijo > button, .fila > button.fijo { width: 100%; }
}
button.secundario + h2 { margin-top: .75rem; }
@media (max-width: 699px) { .pos-pasos .tabla-caja { max-height: none; overflow: visible; } }
.tarjeta h3:not(:first-child) { margin-top: 1rem; }
::placeholder { color: #5a6173; opacity: 1; }
