*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--txt); font-family: var(--font);
  font-size: 18px; line-height: 1.45; -webkit-text-size-adjust: 100%;
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.ico { width: 1.25em; height: 1.25em; vertical-align: -0.22em; flex: none; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ── encabezado ── */
.marco {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.marco-logo { height: 28px; width: auto; }
:root[data-tema="claro"] .marco-logo { filter: brightness(0); }
.marco-titulo { font-weight: 900; font-size: 18px; }
.marco-espacio { flex: 1; }
.marco-persona { color: var(--muted); font-weight: 700; font-size: 15px; }
.marco-boton, .marco-volver {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--txt); cursor: pointer;
}

/* ── contenido ── */
.contenido { max-width: 720px; margin: 0 auto; padding: 20px 16px 48px; }
.titulo { font-size: 30px; font-weight: 900; margin: 8px 0 4px; letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 20px; }
.tarjeta { background: var(--card); border-radius: var(--radius); box-shadow: var(--sombra); padding: 18px; margin: 14px 0; overflow-wrap: anywhere; }
.nota { color: var(--muted); font-size: 15px; margin: 8px 0 0; }
.vacio { color: var(--muted); padding: 16px 0; display: flex; gap: 10px; align-items: center; }
.mensaje-error { color: var(--red); font-weight: 700; min-height: 1.4em; }

/* ── botones: pensados para dedos, guantes y una sola mano ── */
.boton-primario, .boton-secundario, .boton-grande, .boton-nombre {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 20px; border-radius: 14px; font-weight: 900; font-size: 18px;
  cursor: pointer; border: 2px solid transparent; text-decoration: none; user-select: none;
  transition: transform .08s ease, filter .15s ease;
}
.boton-primario { background: var(--primary); color: var(--on-primary); }
.boton-secundario { background: transparent; color: var(--txt); border-color: var(--line); }
.boton-grande { width: 100%; min-height: 72px; font-size: 21px; background: var(--primary); color: var(--on-primary); }
.boton-primario:active, .boton-secundario:active, .boton-grande:active, .boton-nombre:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ── entrar ── */
.rejilla-nombres { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.boton-nombre { background: var(--card); color: var(--txt); border-color: var(--line); min-height: 72px; }
.pin-puntos { display: flex; gap: 14px; justify-content: center; margin: 18px 0 6px; min-height: 22px; }
.pin-puntos span { width: 18px; height: 18px; border-radius: 50%; background: var(--txt); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 360px; margin: 0 auto; }
.teclado button {
  min-height: 72px; border-radius: 16px; border: 1px solid var(--line); background: var(--card);
  font-size: 28px; font-weight: 900; cursor: pointer;
}
.teclado .tecla-entrar { background: var(--primary); color: var(--on-primary); font-size: 20px; }
.volver { background: none; border: 0; color: var(--blue); font-weight: 700; min-height: 48px; cursor: pointer; padding: 0; display: inline-flex; gap: 8px; align-items: center; }

/* ── inicio ── */
.lista-herramientas { display: grid; gap: 14px; margin: 20px 0; }
.herramienta {
  display: flex; align-items: center; gap: 16px; padding: 18px; min-height: 88px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--sombra);
  color: var(--txt); text-decoration: none;
}
.herramienta .ico { width: 40px; height: 40px; color: var(--blue); }
.herramienta b { display: block; font-size: 21px; }
.herramienta span { color: var(--muted); font-size: 15px; }
textarea {
  width: 100%; min-height: 110px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); resize: vertical;
}

/* ── casilla ── */
.buscador { display: flex; gap: 10px; margin-top: 12px; }
.buscador input {
  flex: 1; min-height: var(--tap); padding: 0 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); font-family: var(--mono); font-size: 20px; text-transform: uppercase;
}
.camara { position: relative; margin: 14px 0; border-radius: var(--radius); overflow: hidden; background: #000; }
.camara video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.camara .mira { position: absolute; inset: 18% 22%; border: 4px solid var(--gold); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.camara .boton-secundario { position: absolute; right: 12px; top: 12px; background: rgba(0, 0, 0, .55); color: #fff; }
.casilla-cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.direccion { font-family: var(--mono); font-size: 36px; font-weight: 900; letter-spacing: .02em; line-height: 1.1; }
.donde { color: var(--muted); margin-top: 4px; }
.sello { display: inline-flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: 999px; font-weight: 900; font-size: 15px; white-space: nowrap; }
.sello-ok { background: var(--green-bg); color: var(--green); }
.sello-error { background: var(--red-bg); color: var(--red); }
.banda { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--card-2); font-weight: 700; }
.banda-alerta { background: var(--gold-bg); color: var(--gold); display: flex; gap: 10px; align-items: center; }
.producto { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.producto-nombre { font-size: 21px; margin: 0; }
.etiquetas { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.etiqueta { padding: 4px 10px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.existencia b { font-size: 22px; }
.lotes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.lote {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px;
  border-radius: 12px; background: var(--card-2); border-left: 6px solid var(--line);
}
.lote-num { font-family: var(--mono); font-weight: 900; }
.lote-cant { grid-row: span 2; align-self: center; font-weight: 900; font-size: 20px; }
.lote-vence { font-size: 15px; color: var(--muted); }
.lote-vencido { border-left-color: var(--red); } .lote-vencido .lote-vence { color: var(--red); font-weight: 700; }
.lote-pronto  { border-left-color: var(--gold); } .lote-pronto .lote-vence { color: var(--gold); font-weight: 700; }
.lote-ok      { border-left-color: var(--green); }
.lote-sin_fecha { border-left-style: dashed; border-left-color: var(--muted); }
.primero { margin-left: 6px; padding: 2px 8px; border-radius: 6px; background: var(--green-bg); color: var(--green); font-size: 13px; }
.casilla-pie { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.dato-sap { color: var(--muted); font-size: 15px; display: inline-flex; gap: 6px; align-items: center; }
.form-aviso { margin-top: 14px; display: grid; gap: 12px; }

/* ── avisos ── */
.filtros { display: flex; gap: 10px; }
.filtros button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.aviso-cabeza { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.aviso-texto { margin: 10px 0 0; font-size: 19px; }
.aviso-no_cuadra { border-left: 6px solid var(--gold); }
.aviso-sistema   { border-left: 6px solid var(--red); }
.aviso-mejora    { border-left: 6px solid var(--blue); }

/* ── cargando ── */
.esqueleto { height: 18px; margin: 10px 0; border-radius: 8px; background: linear-gradient(90deg, var(--card-2), var(--line), var(--card-2)); background-size: 200% 100%; animation: brillo 1.2s linear infinite; }
.esqueleto.alto { height: 44px; }
@keyframes brillo { to { background-position: -200% 0; } }

/* ── toast y destello de escaneo ── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 14px 18px; border-radius: 14px; font-weight: 900; z-index: 30;
  background: var(--card); box-shadow: var(--sombra); border-left: 6px solid var(--green);
}
.toast-error { border-left-color: var(--red); }
.destello { position: fixed; inset: 0; z-index: 40; pointer-events: none; animation: destello .55s ease-out forwards; }
.destello-ok { background: var(--green); }
.destello-error { background: var(--red); }
@keyframes destello { from { opacity: .55; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
