/* Control de Stock - DAY · negro, blanco y un detalle amarillo sutil */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --fg2: #3a3a3a;
  --muted: #737373;
  --line: #e7e7e7;
  --soft: #f6f6f6;
  --card: #ffffff;
  --ink: #0a0a0a;        /* superficies negras */
  --on-ink: #ffffff;
  --accent: #e9c33b;     /* amarillo sutil */
  --accent-soft: #fbf4d9;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1d6b3a;
  --radius: 14px;
  --edge: #0a0a0a;       /* líneas negras de contorno */
  --shadow: none;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;   /* siempre fondo blanco, también con el móvil en modo oscuro */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; min-height: 100vh; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .01em; }
.hidden { display: none !important; }

/* ---------- arranque ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.mark { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: .08em;
  background: var(--ink); color: var(--on-ink); border-radius: 8px; padding: 4px 8px; font-size: 13px; position: relative; }
.mark::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 3px; height: 2px; background: var(--accent); border-radius: 2px; }

/* ---------- barra superior ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); color: var(--fg); display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1.5px solid var(--edge); box-shadow: 0 1.5px 0 var(--accent); }

.top .ttl { font-weight: 650; font-size: 15px; letter-spacing: .01em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .ttl small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.top .ib { background: transparent; border: 0; color: var(--fg); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; }
.top .ib:active { background: var(--soft); }
.uchip { border: 1.5px solid var(--edge); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; }
.demo-pill { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #0a0a0a; background: var(--accent); border-radius: 999px; padding: 2px 7px; font-weight: 700; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(110px + var(--safe-b)); }
h1 { font-size: 22px; line-height: 1.2; margin: 6px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
h2 .count { background: var(--soft); color: var(--fg2); border-radius: 999px; padding: 1px 8px; font-size: 12px; letter-spacing: 0; }
h3 { font-size: 16px; margin: 0 0 4px; }

/* ---------- inicio ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.tile { text-align: left; border-radius: 18px; padding: 18px 16px 16px; min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; border-width: 2px !important;
  border: 1.5px solid var(--ink); background: var(--card); box-shadow: var(--shadow); }
.tile .i { width: 30px; height: 30px; }
.tile b { font-size: 21px; display: block; letter-spacing: -.01em; }
.tile span { font-size: 12.5px; color: var(--muted); }
.tile.dark { background: var(--card); color: var(--fg); }
.tile.dark .i { color: var(--fg); }
.tile:active { transform: scale(.985); }

.menu { margin-top: 8px; border: 1.5px solid var(--edge); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.menu button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; border: 0; background: transparent; text-align: left; border-top: 1px solid var(--line); }
.menu button:first-child { border-top: 0; }
.menu button:active { background: var(--soft); }
.menu .lbl { flex: 1; }
.menu .lbl small { display: block; color: var(--muted); font-size: 12.5px; }

.alert { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; width: 100%; text-align: left; }
.alert.err { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.alert b { display: block; }

/* ---------- formularios ---------- */
.card { background: var(--card); border: 1.5px solid var(--edge); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 12px; }
.field { display: block; margin-top: 12px; }
.field:first-child { margin-top: 0; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--fg2); margin-bottom: 6px; letter-spacing: .01em; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.in, select.in, textarea.in { width: 100%; height: 46px; border: 1.5px solid var(--edge); background: var(--bg); border-radius: 11px; padding: 0 12px; font-size: 16px; outline: none; }
textarea.in { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.in:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.in.upper { text-transform: uppercase; }
.seg { display: flex; background: var(--bg); border: 1.5px solid var(--edge); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; font-size: 14px; color: var(--fg2); }
.seg button.on { background: var(--bg); color: var(--fg); box-shadow: inset 0 0 0 1.5px var(--edge), inset 0 -3px 0 var(--accent); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
.search { position: relative; }
.search .i { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.search .in { padding-left: 40px; }

/* ---------- botones ---------- */
.btn { height: 48px; border-radius: 12px; border: 1.5px solid var(--ink); background: var(--card); padding: 0 16px; font-weight: 650; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.pri { background: var(--ink); color: var(--on-ink); }
.btn.ghost { border-color: var(--edge); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { height: 60px; font-size: 17px; border-radius: 14px; }
.btn.sm { height: 36px; font-size: 13.5px; padding: 0 12px; border-radius: 10px; }
.btn:disabled { opacity: .4; }
.btn:active { transform: scale(.99); }
.btn .i { width: 22px; height: 22px; }
.linkbtn { background: none; border: 0; padding: 4px 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--accent); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--edge); background: var(--card); display: grid; place-items: center; flex: none; }
.footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1.5px solid var(--edge); padding: 12px 16px calc(12px + var(--safe-b)); }
.footer > div { max-width: 720px; margin: 0 auto; display: flex; gap: 10px; }
.footer > div > * { flex: 1; }

/* ---------- listas ---------- */
.list { border: 1.5px solid var(--edge); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); width: 100%; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.item:first-child { border-top: 0; }
button.item:active { background: var(--soft); }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; font-size: 14.5px; }
.item .main .sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .qty { text-align: right; font-weight: 700; font-size: 17px; white-space: nowrap; }
.item .qty small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.item .qty.low { color: var(--danger); }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 6px; padding: 2px 6px; border: 1px solid var(--line); color: var(--fg2); }
.badge.Entrada { background: var(--bg); color: var(--fg); border: 1.5px solid var(--edge); }
.badge.Salida { border-color: var(--ink); color: var(--fg); }
.badge.Ajuste { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.badge.pv { border-color: var(--accent); }
.badge.low { border-color: var(--danger); color: var(--danger); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chips button { flex: none; height: 34px; padding: 0 13px; border-radius: 999px; border: 1.5px solid var(--edge); background: var(--card); font-size: 13.5px; font-weight: 600; color: var(--fg2); }
.chips button.on { background: var(--accent-soft); color: var(--fg); border-color: var(--edge); }
.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--edge); overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.tabs button { flex: none; border: 0; background: none; padding: 12px 12px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--fg); border-bottom: 3px solid var(--edge); box-shadow: 0 1px 0 var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- líneas del movimiento ---------- */
.line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line .main { flex: 1; min-width: 0; }
.line .main b { display: block; }
.line .main .sub { font-size: 12.5px; color: var(--muted); }
.line .q { font-size: 19px; font-weight: 750; white-space: nowrap; }
.line .q small { font-size: 12px; font-weight: 500; color: var(--muted); }
.scanbtn { margin-top: 12px; }

/* ---------- capas (hojas, modales) ---------- */
#overlay:empty { display: none; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: up .2s ease; }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 20px; } }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-h > div { flex: 1; min-width: 0; }
.sheet-h .sub { color: var(--muted); font-size: 13px; }
.grab { width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto 12px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* teclado de cantidad */
.qd { text-align: center; padding: 8px 0 6px; }
.qd .n { font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; min-height: 52px; }
.qd .n.zero { color: var(--line); }
.qd .u { color: var(--muted); font-size: 13px; }
.avail { text-align: center; font-size: 13px; color: var(--fg2); background: var(--soft); border-radius: 10px; padding: 7px 10px; margin-bottom: 4px; }
.avail.bad { color: var(--danger); background: var(--danger-soft); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.quick button { height: 38px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--edge); background: var(--card); font-weight: 650; }
.quick button.box { border-color: var(--accent); background: var(--accent-soft); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.pad button { height: 56px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--bg); font-size: 22px; font-weight: 650; }
.pad button:active { background: var(--line); }

/* escáner */
#scanner { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; }
#scanner[hidden] { display: none; }
#scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sc-top, .sc-bot { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: linear-gradient(rgba(0,0,0,.65), transparent); }
.sc-bot { margin-top: auto; flex-direction: column; align-items: stretch; background: linear-gradient(transparent, rgba(0,0,0,.75)); padding-bottom: calc(18px + var(--safe-b)); }
.sc-top .t { flex: 1; font-weight: 650; }
.sc-top .t small { display: block; color: #bdbdbd; font-weight: 400; font-size: 12.5px; }
.sc-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; }
.sc-btn.on { background: var(--accent); color: #000; border-color: var(--accent); }
.frame { position: absolute; z-index: 1; left: 50%; top: 44%; width: min(76vw, 340px); height: min(50vw, 220px); transform: translate(-50%, -50%); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.frame::before, .frame::after { content: ""; position: absolute; inset: -2px; border-radius: 18px; border: 3px solid transparent; border-top-color: var(--accent); border-bottom-color: var(--accent); clip-path: polygon(0 0, 22% 0, 22% 100%, 0 100%, 0 0, 100% 0, 100% 100%, 78% 100%, 78% 0); }
.frame.hit::before { border-color: #fff; }
.sc-msg { text-align: center; font-size: 14px; color: #e5e5e5; min-height: 20px; }
.sc-count { align-self: center; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.sc-manual { display: flex; gap: 8px; }
.sc-manual input { flex: 1; height: 46px; border-radius: 11px; border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.5); color: #fff; padding: 0 12px; font-size: 16px; text-transform: uppercase; }

/* ocupado y avisos */
#busy { position: fixed; inset: 0; z-index: 80; background: color-mix(in srgb, var(--bg) 80%, transparent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-weight: 600; }
#busy[hidden] { display: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%) translateY(20px); z-index: 90; background: #0a0a0a; color: #fff; border-radius: 12px;
  padding: 11px 16px; font-size: 14px; max-width: calc(100vw - 32px); width: max-content; opacity: 0; pointer-events: none; transition: .2s; border-left: 3px solid var(--accent); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { border-left-color: #ff6b5e; }

/* acceso */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 32px 22px; }
.auth .mark { font-size: 20px; padding: 10px 14px; border-radius: 12px; align-self: flex-start; }
.auth h1 { font-size: 28px; margin-top: 22px; }
.auth p { color: var(--muted); }
.auth .btn { margin-top: 18px; }

/* resultado */
.done { text-align: center; padding-top: 18px; }
.done .ok { width: 64px; height: 64px; border-radius: 50%; background: var(--bg); color: var(--fg); border: 2px solid var(--edge); display: grid; place-items: center; margin: 0 auto 12px; box-shadow: 0 0 0 6px var(--accent-soft); }
.done .ok .i { width: 32px; height: 32px; }
.done .doc { font-size: 15px; margin-top: 4px; }

/* etiquetas (vista previa en pantalla) */
.lab-prev { display: flex; justify-content: center; padding: 14px; background: var(--soft); border-radius: var(--radius); overflow: hidden; }
.lab-prev .lab { background: #fff; color: #000; box-shadow: var(--shadow); }
.cnt { display: inline-flex; align-items: center; border: 1.5px solid var(--edge); border-radius: 10px; overflow: hidden; }
.cnt button { width: 34px; height: 34px; border: 0; background: var(--soft); font-weight: 700; }
.cnt span { min-width: 30px; text-align: center; font-weight: 650; }
.check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--edge); display: grid; place-items: center; flex: none; }
.check.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.check .i { width: 15px; height: 15px; }

/* ---------- impresión ---------- */
#print { display: none; }
.lab { font-family: Arial, Helvetica, sans-serif; color: #000; background: #fff; overflow: hidden; position: relative; }
.lab .lm { position: absolute; font-weight: 800; letter-spacing: .08em; background: #000; color: #fff; border-radius: 3px; }
.lab-art { width: 62mm; height: 29mm; padding: 2mm 3mm; display: flex; flex-direction: column; }
.lab-art .lm { right: 2.5mm; top: 2mm; font-size: 6.5pt; padding: .5mm 1.2mm; }
.lab-art .c { font-size: 12pt; font-weight: 800; letter-spacing: .02em; padding-right: 10mm; white-space: nowrap; overflow: hidden; }
.lab-art .r { font-size: 7pt; line-height: 1.15; height: 2.3em; overflow: hidden; }
.lab-art .bc { flex: 1; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.lab-art .bc svg { width: 100%; height: 100%; max-height: 13mm; }
.lab-art.qr { flex-direction: row; gap: 2.5mm; align-items: center; }
.lab-art.qr .qrbox { width: 24mm; height: 24mm; flex: none; }
.lab-art.qr .qrbox img { width: 100%; height: 100%; image-rendering: pixelated; }
.lab-art.qr .txt { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.lab-art.qr .lm { position: static; align-self: flex-start; margin-bottom: 1.5mm; }
.lab-art .bx { font-size: 9pt; font-weight: 800; margin-top: 1mm; border-top: .3mm solid #000; padding-top: .8mm; }
.sheet-a4 { width: 210mm; height: 297mm; padding: 0; display: grid; grid-template-columns: repeat(3, 70mm); grid-auto-rows: 37.125mm; page-break-after: always; break-after: page; }
.sheet-a4 .lab-art { width: 70mm; height: 37.125mm; padding: 4mm 5mm; }
.sheet-a4 .lab-art.qr .qrbox { width: 27mm; height: 27mm; }
.sheet-a4 .lab-art .bc svg { max-height: 15mm; }

.lab-ship { width: 100mm; height: 150mm; padding: 5mm; display: flex; flex-direction: column; gap: 3mm; font-size: 9pt; }
.lab-ship.a5 { width: 148mm; height: 210mm; padding: 8mm; font-size: 11pt; }
.ship-top { display: flex; align-items: center; gap: 2.5mm; border-bottom: .8mm solid #000; padding-bottom: 2mm; }
.ship-top .lm { position: static; font-size: 9pt; padding: .8mm 2mm; }
.ship-top .t { flex: 1; font-weight: 700; letter-spacing: .06em; font-size: 8pt; }
.ship-top .d { font-weight: 800; font-size: 10pt; }
.ship-sec .k { font-size: 6.5pt; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #444; }
.ship-sec .v { font-weight: 600; }
.ship-dest { border: .5mm solid #000; border-radius: 2mm; padding: 3mm; flex: none; }
.ship-dest .v { font-size: 11pt; line-height: 1.35; }
.ship-dest .blank { border-bottom: .3mm solid #999; height: 6.5mm; }
.ship-boat { display: flex; justify-content: space-between; align-items: center; gap: 3mm; }
.ship-boat .b { font-size: 20pt; font-weight: 800; letter-spacing: .02em; }
.ship-boat .f { border: .4mm solid #000; padding: .8mm 2mm; font-weight: 700; font-size: 8pt; text-transform: uppercase; }
.ship-tbl { width: 100%; border-collapse: collapse; font-size: 8pt; }
.ship-tbl td { border-bottom: .2mm solid #bbb; padding: .8mm 0; vertical-align: top; }
.ship-tbl td:last-child { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 2mm; }
.ship-foot { margin-top: auto; display: flex; align-items: flex-end; gap: 3mm; border-top: .3mm solid #000; padding-top: 2mm; font-size: 7.5pt; }
.ship-foot .qrbox { width: 18mm; height: 18mm; flex: none; }
.ship-foot .qrbox img { width: 100%; height: 100%; image-rendering: pixelated; }
.ship-foot > div:first-child { flex: 1; }
.ship-acc { height: 1.2mm; background: #e9c33b; margin: -5mm -5mm 0; }

@media print {
  html, body { background: #fff !important; }
  body > *:not(#print) { display: none !important; }
  #print { display: block !important; }
  #print .lab-art.roll, #print .lab-ship { page-break-after: always; break-after: page; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
