/* Control de stock · imprenta — tema "papel y tinta" */
:root {
  --bg: #f3f4f1;
  --panel: #ffffff;
  --panel-2: #f8f8f5;
  --ink: #16202b;
  --muted: #5d6874;
  --line: #dfe2dc;
  --nav: #101a26;
  --nav-2: #182636;
  --nav-ink: #c9d3de;
  --brand: #0a7ea4;
  --brand-ink: #ffffff;
  --brand-soft: #dff1f7;
  --c: #00a3d9; --m: #d6247f; --y: #f2c200; --k: #1b1f24;
  --ok: #1f8a4c; --ok-bg: #def3e6;
  --warn: #b26a00; --warn-bg: #fdecc8;
  --err: #c0392b; --err-bg: #fbdcd7;
  --info: #1d62c9; --info-bg: #dce8fb;
  --viol: #6b46c1; --viol-bg: #e8e0f8;
  --grey: #5a6572; --grey-bg: #e5e8eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 26, 38, .06), 0 4px 14px rgba(16, 26, 38, .06);
  --mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d141c; --panel: #151f2b; --panel-2: #111a24; --ink: #e6ebf0; --muted: #93a0ae; --line: #263445;
    --brand: #35b6dd; --brand-ink: #06202a; --brand-soft: #12384a;
    --ok: #52c585; --ok-bg: #123a27; --warn: #f0b24a; --warn-bg: #3c2e0e; --err: #ff8a7a; --err-bg: #43211d;
    --info: #7fb0ff; --info-bg: #15294a; --viol: #b79cf5; --viol-bg: #2a2046; --grey: #a5b0bc; --grey-bg: #222d3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d141c; --panel: #151f2b; --panel-2: #111a24; --ink: #e6ebf0; --muted: #93a0ae; --line: #263445;
  --brand: #35b6dd; --brand-ink: #06202a; --brand-soft: #12384a;
  --ok: #52c585; --ok-bg: #123a27; --warn: #f0b24a; --warn-bg: #3c2e0e; --err: #ff8a7a; --err-bg: #43211d;
  --info: #7fb0ff; --info-bg: #15294a; --viol: #b79cf5; --viol-bg: #2a2046; --grey: #a5b0bc; --grey-bg: #222d3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14.5px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4em 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { text-align: right; }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── layout ── */
#app { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; }
.brand b { font-size: 1.05rem; letter-spacing: .01em; display: block; line-height: 1.1; }
.brand span { font-size: .75rem; color: #8fa1b4; }
.cmyk { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 30px; height: 30px; flex: none; }
.cmyk i { border-radius: 50%; display: block; }
.cmyk i:nth-child(1) { background: var(--c); } .cmyk i:nth-child(2) { background: var(--m); }
.cmyk i:nth-child(3) { background: var(--y); } .cmyk i:nth-child(4) { background: #fff; box-shadow: inset 0 0 0 3px var(--k); }
.nav-group { margin: 12px 8px 4px; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #6f8296; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--nav-ink); font-weight: 500; }
.nav a:hover { background: var(--nav-2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--brand); color: var(--brand-ink); }
.nav .badge-n { margin-left: auto; background: var(--m); color: #fff; border-radius: 99px; font-size: .7rem; padding: 1px 7px; font-weight: 700; }
.userbox { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid #243447; font-size: .85rem; }
.userbox b { color: #fff; display: block; }
.userbox .row { display: flex; gap: 8px; margin-top: 8px; }
.userbox button { flex: 1; background: var(--nav-2); color: var(--nav-ink); border: 0; border-radius: 8px; padding: 7px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; font: inherit; }
.userbox button:hover { color: #fff; }
main { padding: 22px 28px 60px; min-width: 0; max-width: 1500px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: .85rem; margin-bottom: 8px; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--nav); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 0; color: #fff; cursor: pointer; padding: 4px; }
  main { padding: 16px 14px 60px; }
}

/* ── componentes ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card + .card, .grid + .card, .card + .grid { margin-top: 16px; }
.card > h2, .card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g3, .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .g2 { grid-template-columns: minmax(0, 1fr); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.kpi.c-warn::before { background: var(--y); } .kpi.c-err::before { background: var(--m); } .kpi.c-ok::before { background: var(--ok); }
.kpi-l { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi-v { font-size: 1.7rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-s { font-size: .8rem; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { background: var(--panel-2); text-decoration: none; border-color: #b9c0b6; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: var(--grey-bg); color: var(--grey); }
.b-DISPONIBLE, .b-APROBADO, .b-APROBADA, .b-CERRADA, .b-RESUELTA, .b-INSPECCIONADA, .b-OK { background: var(--ok-bg); color: var(--ok); }
.b-PENDIENTE_INSPECCION, .b-PENDIENTE, .b-EN_INSPECCION, .b-ABIERTA, .b-EN_CURSO { background: var(--warn-bg); color: var(--warn); }
.b-RESERVADA, .b-RECLAMADA { background: var(--info-bg); color: var(--info); }
.b-EN_PRODUCCION { background: var(--viol-bg); color: var(--viol); }
.b-CUARENTENA, .sev-MAYOR { background: #ffe3cf; color: #b8540d; }
.b-RECHAZADA, .b-RECHAZADO, .sev-CRITICO { background: var(--err-bg); color: var(--err); }
.sev-LEVE { background: var(--grey-bg); color: var(--grey); }
.b-CONSUMIDA, .b-BAJA, .b-DEVUELTA, .b-ANULADA { background: var(--grey-bg); color: var(--grey); }
@media (prefers-color-scheme: dark) { .b-CUARENTENA, .sev-MAYOR { background: #4a2a12; color: #ffab6b; } }

.alert-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin: 10px 0; font-weight: 500; }
.alert-box.err { background: var(--err-bg); color: var(--err); }
.alert-box.ok { background: var(--ok-bg); color: var(--ok); }
.alert-box.info { background: var(--info-bg); color: var(--info); }

/* ── tablas ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.card > .table-wrap { margin-top: 2px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--panel-2); padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr[data-go] { cursor: pointer; }
.tbl tbody tr[data-go]:hover, .tbl tbody tr.sel { background: var(--brand-soft); }
.tbl tr.fila-alerta td:first-child { box-shadow: inset 3px 0 0 var(--m); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }

/* ── formularios ── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .lbl { font-size: .8rem; font-weight: 600; color: var(--muted); }
.req { color: var(--m); margin-left: 2px; }
.field small { color: var(--muted); font-size: .78rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid #c6cbc3; border-radius: 8px; padding: 8px 10px; width: 100%; min-height: 38px; }
@media (prefers-color-scheme: dark) { input, select, textarea { border-color: #33455a; } }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; flex: 1 1 150px; max-width: 260px; }
.filters .field.grow { flex: 2 1 260px; max-width: 420px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs .on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ── modales y avisos ── */
.overlay { position: fixed; inset: 0; background: rgba(10, 18, 28, .55); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 14px; z-index: 100; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); display: flex; flex-direction: column; max-height: 90vh; }
.m-sm { max-width: 440px; } .m-md { max-width: 640px; } .m-lg { max-width: 960px; } .m-xl { max-width: 1200px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--panel-2); border-radius: 0 0 14px 14px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 11px 16px; border-radius: 10px; color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); transition: opacity .3s, transform .3s; }
.toast.t-ok { background: #1f7a45; } .toast.t-err { background: #b8321f; } .toast.t-warn { background: #a86400; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ── detalle ── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel-2); font-size: .82rem; cursor: pointer; user-select: none; }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 14px 28px; }
.timeline li::before { content: ""; position: absolute; left: 1px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 3px solid var(--brand); }
.timeline li.t-warn::before { border-color: var(--y); } .timeline li.t-err::before { border-color: var(--m); } .timeline li.t-ok::before { border-color: var(--ok); }
.timeline .t-h { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.timeline .t-h b { font-size: .9rem; }
.chain { display: flex; align-items: stretch; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.chain .nodo { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 130px; }
.chain .nodo small { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.chain .nodo b { display: block; }
.chain .sep { align-self: center; color: var(--muted); }
.bar { height: 8px; background: var(--grey-bg); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.warn > i { background: var(--y); } .bar.err > i { background: var(--m); } .bar.ok > i { background: var(--ok); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.spark i { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.spark i:hover { opacity: 1; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list li:hover { background: var(--panel-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--grey); }
.dot.alta { background: var(--m); } .dot.media { background: var(--y); } .dot.baja { background: var(--c); }

/* ── mapa de depósito ── */
.mapa-zona { margin-bottom: 22px; }
.mapa-grid { display: grid; gap: 6px; }
.celda { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 8px; cursor: pointer; min-height: 62px; font-size: .78rem; position: relative; text-align: left; font: inherit; color: var(--ink); }
.celda:hover { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.celda b { display: block; font-size: .78rem; }
.celda.vacia { background: var(--panel-2); color: var(--muted); }
.celda.ocupada { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.celda.llena { background: var(--info-bg); border-color: var(--info); }
.celda.retenida { background: #ffe3cf; border-color: #e09a62; }
.celda.inactiva { opacity: .45; }
.celda .mini { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 4px; border-radius: 3px; background: rgba(0, 0, 0, .12); }
.celda .mini i { display: block; height: 100%; background: var(--ink); opacity: .55; border-radius: 3px; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line); }

/* ── escáner ── */
.scan-big { font-size: 1.4rem; padding: 14px 16px; font-family: var(--mono); letter-spacing: .04em; }
.scan-list { max-height: 360px; overflow: auto; }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 15% -10%, #12384a 0, transparent 60%), var(--nav); }
.login-card { background: var(--panel); border-radius: 16px; padding: 30px; width: 100%; max-width: 400px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); }
.login-card .brand { color: var(--ink); padding: 0 0 18px; }
.login-card .brand span { color: var(--muted); }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; }
.hint-demo { margin-top: 14px; font-size: .8rem; color: var(--muted); text-align: center; }

/* ── etiquetas (impresión) ── */
.etiquetas { display: flex; flex-wrap: wrap; gap: 10px; }
.etiqueta { width: 100mm; min-height: 62mm; background: #fff; color: #000; border: 1.5px solid #000; border-radius: 4px; padding: 3mm 4mm; display: flex; flex-direction: column; gap: 1.5mm; page-break-inside: avoid; break-inside: avoid; }
.etiqueta .et-top { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1.5px solid #000; padding-bottom: 1mm; }
.etiqueta .et-tipo { font-weight: 800; font-size: 11pt; letter-spacing: .05em; }
.etiqueta .et-mat { font-weight: 700; font-size: 11pt; line-height: 1.15; }
.etiqueta .et-datos { display: grid; grid-template-columns: 1fr 1fr; gap: .5mm 4mm; font-size: 8.5pt; }
.etiqueta .et-datos span { color: #444; font-size: 7pt; text-transform: uppercase; }
.etiqueta svg.barcode { width: 100%; height: auto; max-height: 20mm; margin-top: auto; }
.etiqueta.ub { width: 90mm; min-height: 40mm; align-items: center; text-align: center; }
.etiqueta.ub .et-big { font-size: 24pt; font-weight: 800; letter-spacing: .03em; }

@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  .sidebar, .topbar, .page-head .actions, .no-print, #toasts, .crumb { display: none !important; }
  #app { display: block; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #bbb; }
  .etiquetas { gap: 4mm; }
  .tbl th { position: static; }
}
