:root {
  --bg: #f3f4f1;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #6b736f;
  --line: #dfe3df;
  --brand: #12395b;
  --brand-2: #1f5f92;
  --ok: #1e8a4c;
  --ok-bg: #e3f4ea;
  --warn: #b26a00;
  --warn-bg: #fff3d6;
  --bad: #c0392b;
  --bad-bg: #fde7e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* barra superior */
.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  padding: 10px 14px calc(10px); display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; line-height: 1.2; }
.top h1 small { display: block; font-weight: 400; font-size: 12.5px; opacity: .8; }
.top .back { background: rgba(255,255,255,.14); border: 0; color: #fff; width: 40px; height: 40px;
  border-radius: 10px; font-size: 22px; line-height: 1; }
.top .who { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 14px; max-width: 760px; margin: 0 auto; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 18px 4px 8px; font-weight: 650; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.list > * + * { border-top: 1px solid var(--line); }

/* pantallas simples */
.center { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.big-input { width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; }
.big-input:focus { outline: none; border-color: var(--brand-2); }
.btn { border: 0; border-radius: 12px; padding: 14px 16px; font-weight: 650; font-size: 16px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: #e7ebe8; color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-block { width: 100%; }

/* rondas */
.ronda { display: flex; align-items: center; gap: 14px; padding: 16px; border: 0; background: none;
  width: 100%; text-align: left; }
.ronda b { font-size: 17px; display: block; }

/* progreso */
.prog { height: 6px; background: #e8ebe8; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.prog > i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.prog.done > i { background: var(--ok); }

/* pasillos */
.pas-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%;
  border: 0; background: none; text-align: left; }
.pas-num { font-size: 22px; font-weight: 750; min-width: 64px; }
.pas-num small { display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }
.pas-info { flex: 1; }
.pas-info .cnt { font-size: 14px; color: var(--muted); }
.chev { color: var(--muted); font-size: 20px; transition: transform .15s; }
.open .chev { transform: rotate(90deg); }
.alturas { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
  padding: 0 14px 14px; }
.alt { border: 1.5px solid var(--line); background: #fafbfa; border-radius: 12px; padding: 10px 8px;
  text-align: center; }
.alt b { display: block; font-size: 18px; }
.alt span { font-size: 12.5px; color: var(--muted); }
.alt.done { border-color: #b9e0c7; background: var(--ok-bg); }
.alt.done span { color: var(--ok); font-weight: 600; }

/* barra de escaneo */
.scanbar { position: sticky; top: 60px; z-index: 15; background: var(--bg); padding: 10px 14px 8px;
  margin: 0 -14px; display: flex; gap: 8px; }
.scanbar input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; font-size: 16px; }
.scanbar input:focus { outline: none; border-color: var(--brand-2); }
.icon-btn { width: 48px; flex: none; border: 0; border-radius: 12px; background: var(--brand); color: #fff;
  font-size: 20px; display: grid; place-items: center; }
.icon-btn svg { width: 24px; height: 24px; }

.summary { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 8px;
  font-size: 14px; color: var(--muted); }
.summary b { color: var(--ink); }

/* filas */
.ubic-title { font-size: 12.5px; font-weight: 700; color: var(--brand-2); padding: 12px 16px 2px;
  letter-spacing: .03em; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; border: 0;
  background: none; text-align: left; }
.row .info { flex: 1; min-width: 0; }
.row .item { font-weight: 700; font-size: 16px; }
.row .desc { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .lote { font-size: 14px; margin-top: 2px; }
.row .lote span { color: var(--muted); font-size: 12px; }
.qty { flex: none; min-width: 58px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 750; font-size: 20px; background: #eef1ee; color: var(--muted); border: 1.5px dashed #c9cfca; }
.qty.has { background: var(--ok-bg); color: var(--ok); border: 1.5px solid #b9e0c7; }
.row.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #fff3b0; } 100% { background: transparent; } }

/* hoja inferior */
.backdrop { position: fixed; inset: 0; background: rgba(10,20,15,.45); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff;
  border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow: auto; max-width: 760px; margin: 0 auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,.15); }
.sheet h2 { margin: 0 0 2px; font-size: 19px; }
.sheet .sub { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; margin: 10px 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.display { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.display .num { flex: 1; text-align: center; font-size: 44px; font-weight: 800; padding: 6px;
  border-radius: 14px; background: #f1f4f2; min-height: 72px; }
.display .num.empty { color: #b7beb9; }
.step { width: 64px; height: 64px; border-radius: 14px; border: 0; background: #e7ebe8; font-size: 26px; font-weight: 700; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keys button { height: 56px; border: 0; border-radius: 12px; background: #f1f4f2; font-size: 24px; font-weight: 650; }
.keys button:active { background: #dfe5e1; }
.actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 10px; }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 12px; border-radius: 10px;
  border: 1.5px solid var(--line); font-size: 16px; background: #fff; }

/* toast */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 80; background: #16241c; color: #fff; padding: 12px 14px; border-radius: 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: 736px; margin: 0 auto; }
.toast.bad { background: #6b1d14; }
.toast .t { flex: 1; font-size: 14.5px; }
.toast button { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 10px;
  padding: 8px 12px; font-weight: 650; }

/* cámara */
.cam { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.cam-top { color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.cam-top b { flex: 1; }
.cam-top button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 650; }
#lector { flex: 1; width: 100%; }
#lector video { object-fit: cover; }
.cam-last { color: #fff; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); min-height: 64px;
  font-size: 15px; background: rgba(255,255,255,.06); }
.cam-last.ok { background: rgba(30,138,76,.45); }
.cam-last.bad { background: rgba(192,57,43,.45); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px;
  background: var(--warn-bg); color: var(--warn); }
.link-btn { background: none; border: 0; color: var(--brand-2); font-weight: 650; padding: 12px 4px; }

/* sin conexión */
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: #c0392b; color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); animation: latido 1.6s ease-in-out infinite; }
.offline .ico { font-size: 26px; line-height: 1; }
.offline b { display: block; font-size: 16px; }
.offline span { font-size: 13.5px; opacity: .92; }
@keyframes latido { 0%,100% { background: #c0392b; } 50% { background: #a12b1f; } }
body.sin-red main, body.sin-red .sheet, body.sin-red .cam { filter: grayscale(.6); }
body.sin-red #kGuardar, body.sin-red #hGuardar { background: #9aa39e !important; }
.ok-red { background: #1e8a4c !important; }

/* buscador global */
.buscador { position: relative; margin: 6px 0 4px; }
.buscador input { width: 100%; padding: 13px 40px 13px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; font-size: 16px; }
.buscador input:focus { outline: none; border-color: var(--brand-2); }
.buscador .x { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none;
  font-size: 22px; color: var(--muted); width: 34px; height: 34px; }
.res-ubic { font-size: 12.5px; font-weight: 700; color: var(--brand-2); }
.row.foco { background: #fff3b0; }
