/* ══════════════════════════════════════════════════════════════
   Recepción Sport Fit — estilos
   Dirección visual: "etiqueta térmica de bodega". Fondo papel,
   tinta negra, datos de máquina en monospace, acento azul cinta.
   Pensado para leerse bajo la luz fuerte de una bodega.
   ══════════════════════════════════════════════════════════════ */

:root {
  --papel:  #F2F1EC;
  --blanco: #FFFFFF;
  --tinta:  #1B1F26;
  --gris:   #5C6470;
  --linea:  #D9D6CC;
  --cinta:  #2049C8;   /* acción principal (azul cinta de embalaje) */
  --cinta2: #17379B;
  --ok:     #1F7A3D;
  --okbg:   #E4F3E8;
  --avi:    #8A5A06;   /* aviso: producto nuevo / pendiente */
  --avibg:  #FCF0D3;
  --aviln:  #E4B450;
  --rojo:   #B42318;
  --rojobg: #FBE9E7;
  --radio:  14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
code, output, .mono { font-family: var(--mono); }
.hide { display: none !important; }
.sp { width: 64px; }

:focus-visible { outline: 3px solid var(--cinta); outline-offset: 2px; border-radius: 6px; }

/* ── Vistas ──────────────────────────────────────────────────── */
.view { display: none; min-height: 100dvh; flex-direction: column; }
.view.on { display: flex; }
.pagepad { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.grow { flex: 1 1 auto; }

/* ── Tipografía utilitaria ───────────────────────────────────── */
.eyebrow {
  display: block;
  font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--gris); margin: 0 0 4px;
}
.sub  { color: var(--gris); margin: 2px 0 0; font-size: 14px; }
.hint { color: var(--gris); font-size: 13.5px; margin: 10px 0; }
.center { text-align: center; }
.err {
  background: var(--rojobg); color: var(--rojo);
  border: 1px solid #EBC2BC; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; margin: 10px 0;
}
.empty { color: var(--gris); text-align: center; padding: 40px 16px; }
.steptitle { font-size: 21px; line-height: 1.25; margin: 18px 0 14px; letter-spacing: -0.01em; }

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px; padding: 0 18px;
  border: 1.5px solid var(--tinta); border-radius: var(--radio);
  background: var(--blanco); color: var(--tinta);
  font-weight: 700; font-size: 16px; letter-spacing: .01em;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-p { background: var(--cinta); border-color: var(--cinta); color: #fff; }
.btn-p:active { background: var(--cinta2); }
.btn.big { width: 100%; min-height: 60px; font-size: 17px; margin-top: 18px; }
.btn-ghost { border-color: transparent; background: transparent; font-weight: 600; }
.btn.sm { min-height: 40px; padding: 0 10px; font-size: 14.5px; border-radius: 10px; }

.row2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 14px; }
.row2 .btn { width: 100%; }

/* ── Marca (barras de código) ────────────────────────────────── */
.brandbars { display: flex; gap: 3px; height: 26px; margin-bottom: 10px; }
.brandbars i { display: block; width: 4px; background: var(--tinta); }
.brandbars i:nth-child(2n)  { width: 2px; }
.brandbars i:nth-child(3n)  { width: 7px; }
.brandbars i:nth-child(5)   { background: var(--cinta); }
.brandbars.sm { height: 16px; margin: 0; }
.brandline { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .12em; font-size: 13px; }
.chip {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  background: var(--tinta); color: var(--papel);
  border-radius: 6px; padding: 2px 7px; letter-spacing: .08em;
}

/* ── Clave de acceso ─────────────────────────────────────────── */
.pinwrap { margin: auto; width: min(340px, 88vw); padding: 24px 0; }
.pinwrap .brand { text-align: left; margin-bottom: 34px; }
.pinwrap h1 { font-size: 30px; letter-spacing: .16em; margin: 0; }
#inp-pin, #inp-prov, #inp-cod {
  width: 100%; min-height: 54px;
  border: 1.5px solid var(--tinta); border-radius: var(--radio);
  background: var(--blanco); padding: 0 14px;
  font: inherit; font-size: 17px;
}
#inp-pin { font-family: var(--mono); letter-spacing: .3em; }
#btn-pin { width: 100%; margin-top: 14px; }

/* ── Encabezado de vista ─────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--linea);
  background: var(--papel);
  position: sticky; top: 0; z-index: 5;
}
.topmid { text-align: center; min-width: 0; }
.topmid .eyebrow { margin: 0; }
.topprov {
  margin: 0; font-weight: 800; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw;
}

/* ── Inicio: proveedor ───────────────────────────────────────── */
.provlist { list-style: none; margin: 6px 0 0; padding: 0; }
.provlist button {
  width: 100%; text-align: left; background: var(--blanco);
  border: 1px solid var(--linea); border-top: none; padding: 13px 14px;
  cursor: pointer; font-size: 15.5px;
}
.provlist li:first-child button { border-top: 1px solid var(--linea); border-radius: 10px 10px 0 0; }
.provlist li:last-child button { border-radius: 0 0 10px 10px; }
.provlist small { display: block; color: var(--gris); font-family: var(--mono); font-size: 12px; }
.provsel {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--blanco); border: 1.5px solid var(--tinta); border-radius: var(--radio);
  padding: 12px 14px; margin-bottom: 8px;
}
.provnom { margin: 0; font-weight: 800; font-size: 17px; }
.card { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px; }
.resume { margin-bottom: 16px; border-left: 4px solid var(--aviln); }
.dot {
  display: inline-block; min-width: 19px; height: 19px; margin-left: 6px;
  background: var(--avi); color: #fff; border-radius: 10px;
  font-size: 12px; line-height: 19px; text-align: center; font-family: var(--mono);
  padding: 0 4px;
}

/* ── Escaneo ─────────────────────────────────────────────────── */
.scan-wrap { position: relative; background: #10131A; }
#scan-box { min-height: 44dvh; max-height: 52dvh; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#scan-box video, #scan-box .cam { width: 100%; height: 44dvh; object-fit: cover; display: block; }
#scan-box > div { width: 100%; }
.scan-ol { position: absolute; inset: 0; pointer-events: none; }
.scan-ol .c { position: absolute; width: 26px; height: 26px; border: 3px solid #fff; opacity: .9; }
.c1 { top: 14%; left: 8%;  border-right: none; border-bottom: none; }
.c2 { top: 14%; right: 8%; border-left: none;  border-bottom: none; }
.c3 { bottom: 14%; left: 8%;  border-right: none; border-top: none; }
.c4 { bottom: 14%; right: 8%; border-left: none;  border-top: none; }
.scanline {
  position: absolute; left: 10%; right: 10%; top: 20%; height: 2px;
  background: linear-gradient(90deg, transparent, #7DF29B, transparent);
  animation: sweep 2.4s ease-in-out infinite alternate;
}
@keyframes sweep { from { top: 20%; } to { top: 78%; } }

.banners { padding: 0 14px; }
.banner {
  margin: 10px 0 0; padding: 11px 13px; border-radius: 10px;
  font-size: 14.5px; font-weight: 600;
  background: var(--avibg); color: var(--avi); border: 1px solid var(--aviln);
}
.banner.ok { background: var(--okbg); color: var(--ok); border-color: #A9D6B6; }
.lastadd {
  margin: 10px 14px 0; padding: 10px 13px; border-radius: 10px;
  background: var(--okbg); color: var(--ok); border: 1px dashed #A9D6B6;
  font-size: 14.5px;
}
.lastadd code { font-size: 13px; }

/* ── Barra inferior fija ─────────────────────────────────────── */
.bar {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--blanco); border-top: 1.5px solid var(--tinta);
  position: sticky; bottom: 0; z-index: 5;
}
.bar-info { font-size: 14.5px; color: var(--gris); }
.bar-info strong { color: var(--tinta); font-family: var(--mono); font-size: 17px; }

/* ── Revisión ────────────────────────────────────────────────── */
.revlist { list-style: none; margin: 8px 0 0; padding: 0; }
.revlist li {
  background: var(--blanco); border: 1px solid var(--linea); border-radius: 12px;
  padding: 12px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
}
.revlist .rnom { font-weight: 700; font-size: 15px; line-height: 1.3; }
.revlist .rref { color: var(--gris); font-family: var(--mono); font-size: 12.5px; }
.rqty {
  grid-row: 1 / span 2;
  min-width: 76px; min-height: 56px; padding: 4px 10px;
  border: 1.5px solid var(--tinta); border-radius: 12px; background: var(--papel);
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  cursor: pointer;
}
.rqty small { font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--gris); }
.rrow2 { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; margin-top: 2px; }
.rdel { background: none; border: none; color: var(--rojo); font-weight: 700; font-size: 13.5px; padding: 6px 0; cursor: pointer; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; border-radius: 6px; padding: 3px 8px;
  background: var(--avibg); color: var(--avi); border: 1px solid var(--aviln);
}

/* ── Éxito ───────────────────────────────────────────────────── */
.okwrap { margin: auto; text-align: center; width: min(360px, 90vw); padding: 30px 0; }
.okmark {
  width: 76px; height: 76px; margin: 0 auto 16px; border-radius: 50%;
  background: var(--okbg); color: var(--ok); border: 2px solid var(--ok);
  font-size: 40px; line-height: 72px; font-weight: 800;
  animation: pop .35s ease;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.okwrap h2 { margin: 0; font-size: 24px; }
.okcod {
  font-family: var(--mono); font-size: 26px; font-weight: 800;
  background: var(--blanco); border: 1.5px dashed var(--tinta); border-radius: 12px;
  padding: 12px; margin: 16px 0 6px; letter-spacing: .04em;
  overflow-wrap: anywhere;
}
.okwrap .btn { width: 100%; margin-top: 10px; }

/* ── Hojas (overlays) ────────────────────────────────────────── */
.ovl {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(20, 23, 30, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.panel {
  width: min(480px, 100%);
  background: var(--blanco);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .22s ease;
  max-height: 92dvh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.panel h2 { margin: 0 0 2px; font-size: 19px; }

/* Tarjeta-etiqueta del producto (elemento firma) */
.labelcard { border-top: none; }
.perf {
  height: 0; border-top: 2px dashed var(--linea);
  margin: -6px -16px 14px; position: relative;
}
.perf::before, .perf::after {
  content: ""; position: absolute; top: -7px; width: 14px; height: 14px;
  background: rgba(20, 23, 30, .55); border-radius: 50%;
}
.perf::before { left: -7px; } .perf::after { right: -7px; }
.shdesc { font-size: 20px; line-height: 1.25; margin: 6px 0 0; overflow-wrap: anywhere; }
.coderow { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }
.bars { display: flex; align-items: stretch; gap: 2px; height: 30px; flex: 0 0 auto; }
.bars i { display: block; background: var(--tinta); }
#sh-cod { font-size: 13.5px; color: var(--gris); overflow-wrap: anywhere; }
.metagrid {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px;
  border-top: 1px solid var(--linea); border-bottom: 1px solid var(--linea);
  padding: 10px 0; margin: 10px 0;
}
.metagrid strong, .metagrid code { font-size: 15.5px; font-family: var(--mono); overflow-wrap: anywhere; }
.dup {
  background: var(--avibg); color: var(--avi); border: 1px solid var(--aviln);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; font-weight: 600; margin: 4px 0 8px;
}
.qtyrow { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 8px; }
#qty {
  min-width: 96px; text-align: center;
  border: 1.5px solid var(--tinta); border-radius: 12px; background: var(--papel);
  font-size: 30px; font-weight: 800; padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button {
  min-height: 56px; font-size: 22px; font-weight: 700; font-family: var(--mono);
  border: 1.5px solid var(--linea); border-radius: 12px; background: var(--papel);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pad button:active { background: var(--linea); }
.pad .padx { background: var(--blanco); color: var(--gris); }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--tinta); color: var(--papel);
  border-radius: 12px; padding: 11px 16px;
  font-size: 14.5px; font-weight: 600; z-index: 30;
  max-width: 92vw; text-align: center;
  animation: up .2s ease;
}
.toast.err { background: var(--rojo); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
