:root {
  --azul: #1f5fa8; --azul-suave: #dfe8f5; --verde: #2e8b57; --rojo: #c0392b; --ambar: #b7791f;
  --fondo: #f4f6f9; --blanco: #fff; --texto: #1d2733; --gris: #5f6b7a; --borde: #d5dbe3;
  --radio: 12px; --toque: 48px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 17px; color: var(--texto);
}
@media (prefers-color-scheme: dark) {
  :root { --fondo: #14181d; --blanco: #1e242b; --texto: #e6ebf1; --gris: #9aa6b4; --borde: #333c47;
          --azul-suave: #22344b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); min-height: 100vh; }
.oculto { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { min-height: var(--toque); padding: 0 18px; border-radius: var(--radio); border: 1px solid var(--borde);
         background: var(--blanco); cursor: pointer; }
button.principal { background: var(--azul); color: #fff; border-color: var(--azul); font-weight: 600; }
button.peligro { color: var(--rojo); border-color: var(--rojo); }
button:disabled { opacity: .45; cursor: default; }
button.icono { min-width: var(--toque); padding: 0; font-size: 22px; background: transparent; border: 0; color: #fff; }
input, select { min-height: var(--toque); padding: 0 12px; border-radius: var(--radio); border: 1px solid var(--borde);
                background: var(--blanco); width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 3px solid var(--azul); outline-offset: 1px; }
label { display: block; margin: 12px 0 4px; color: var(--gris); font-size: 15px; }

.cabecera { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 6px 10px;
            padding-top: max(6px, env(safe-area-inset-top)); background: var(--azul); color: #fff; }
.cabecera h1 { flex: 1; margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pastilla { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.franja { padding: 10px 14px; background: #fff3cd; color: #5c4400; display: flex; gap: 10px; align-items: center;
          flex-wrap: wrap; }
main { max-width: 980px; margin: 0 auto; padding: 14px 12px 90px; }

.tarjeta { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px;
           margin-bottom: 14px; }
.tarjeta h2 { margin: 0 0 8px; font-size: 18px; }
.suave { color: var(--gris); font-size: 15px; }
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fila > .crece { flex: 1; min-width: 0; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; gap: 10px; align-items: center; padding: 10px 4px; border-top: 1px solid var(--borde); }
.lista li:first-child { border-top: 0; }
.lista li.tocable { cursor: pointer; }
.lista li.tocable:active { background: var(--azul-suave); }
.lista .nombre { font-weight: 600; overflow-wrap: anywhere; }
.etiqueta { font-size: 13px; padding: 3px 9px; border-radius: 99px; background: var(--azul-suave); white-space: nowrap; }
.etiqueta.verde { background: #d9f2e3; color: #14532d; }
.etiqueta.ambar { background: #fbeccc; color: #6b4700; }
.etiqueta.rojo { background: #f8d9d5; color: #7a1d12; }

.buscador { position: sticky; top: 60px; z-index: 4; background: var(--fondo); padding: 6px 0; }
.buscador input { font-size: 19px; min-height: 56px; }
.resultados li { padding: 12px 6px; }
.opciones { display: flex; gap: 6px; flex-wrap: wrap; }
.opciones button { flex: 1; min-width: 92px; }
.opciones button[aria-pressed="true"] { background: var(--azul); border-color: var(--azul); color: #fff; }
.opciones.estado button[data-v="02"][aria-pressed="true"] { background: var(--ambar); border-color: var(--ambar); }
.opciones.estado button[data-v="03"][aria-pressed="true"] { background: var(--rojo); border-color: var(--rojo); }
details summary { cursor: pointer; min-height: var(--toque); display: flex; align-items: center; font-weight: 600; }

.fondo-dialogo { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45); display: flex;
                 align-items: flex-end; justify-content: center; }
.dialogo { background: var(--blanco); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
           border-radius: 16px 16px 0 0; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .fondo-dialogo { align-items: center; } .dialogo { border-radius: 16px; } }
.dialogo h2 { margin: 0 0 4px; font-size: 19px; }
.botones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.botones .izquierda { margin-right: auto; }

#avisos { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; display: grid; gap: 8px;
          width: min(560px, 94vw); }
.aviso { padding: 12px 16px; border-radius: var(--radio); background: #263240; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.aviso.ok { background: var(--verde); } .aviso.error { background: var(--rojo); }
.barra-abajo { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; background: var(--blanco);
               border-top: 1px solid var(--borde); padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
.barra-abajo .fila { max-width: 980px; margin: 0 auto; }
video.camara { width: 100%; border-radius: var(--radio); background: #000; }
.arriba { margin-top: 10px; }
