/* ICORBUS · Control de almacén — identidad tomada de icorbus.com (Sora + Inter, azul marino y ámbar) */
:root {
  --navy: #1B3358; --navy-900: #0D1F38; --navy-700: #24436f; --blue: #0073A3; --blue-50: #e6f3f9;
  --amber: #FFB700; --amber-600: #e5a400; --amber-50: #fff6dc;
  --ok: #1E9E5A; --ok-50: #e5f5ec; --warn: #D98E04; --warn-50: #fdf1dc; --bad: #D64545; --bad-50: #fbe9e9;
  --bg: #F3F5F9; --card: #fff; --line: #E3E8F0; --text: #1c2738; --muted: #66748a;
  --r: 14px; --r-sm: 10px; --shadow: 0 1px 2px rgba(13,31,56,.06), 0 4px 16px rgba(13,31,56,.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-h: "Sora", "Inter", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .h { font-family: var(--font-h); color: var(--navy); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; } .wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; } .end { justify-content: flex-end; } .between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topbar h1 { color: #fff; font-size: 17px; }
.topbar .logo { height: 30px; display: block; background: #fff; border-radius: 6px; padding: 2px 6px; }
.topbar .wordmark { font-family: var(--font-h); font-weight: 800; letter-spacing: .04em; font-size: 18px; color: #fff; }
.topbar .wordmark b { color: var(--amber); }
.iconbtn { background: transparent; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { background: rgba(255,255,255,.1); }
.iconbtn svg { width: 22px; height: 22px; }
.demo-banner { background: var(--amber); color: var(--navy-900); text-align: center; font-weight: 600; font-size: 12.5px; padding: 5px 10px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-sm);
  padding: 11px 16px; font-weight: 600; cursor: pointer; background: var(--blue); color: #fff; min-height: 44px; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.amber { background: var(--amber); color: var(--navy-900); }
.btn.ok { background: var(--ok); } .btn.bad { background: var(--bad); } .btn.ghost { background: transparent; color: var(--blue); }
.btn.lg { min-height: 56px; font-size: 17px; border-radius: var(--r); padding: 14px 20px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn svg { width: 20px; height: 20px; }

/* ---------- Tarjetas y layout ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 16px 14px calc(110px + var(--safe-b)); }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .g2.collapse { grid-template-columns: 1fr; } }

/* ---------- Inicio técnico ---------- */
.hello { padding: 6px 2px 4px; }
.tiles { display: grid; gap: 12px; margin-top: 14px; }
.tile { display: flex; align-items: center; gap: 16px; padding: 20px 18px; border-radius: 18px; border: 0; text-align: left; cursor: pointer;
  background: #fff; box-shadow: var(--shadow); color: var(--navy); width: 100%; }
.tile .ic { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.tile .ic svg { width: 30px; height: 30px; }
.tile b { font-family: var(--font-h); font-size: 18px; display: block; }
.tile span { color: var(--muted); font-size: 13.5px; }
.tile.main { background: var(--navy); color: #fff; } .tile.main span { color: #c8d6ea; } .tile.main .ic { background: var(--amber); color: var(--navy-900); }
.tile.ret .ic { background: var(--ok-50); color: var(--ok); }
.tile.his .ic { background: var(--blue-50); color: var(--blue); }
.tile.qr .ic { background: var(--amber-50); color: var(--amber-600); }

/* ---------- Selección de materiales ---------- */
.dest-chip { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 10px 12px; width: 100%; cursor: pointer; text-align: left; }
.dest-chip.empty { border-color: var(--amber); background: var(--amber-50); }
.dest-chip .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.dest-chip .val { font-weight: 700; color: var(--navy); }
.searchbar { display: flex; gap: 8px; margin: 12px 0 8px; position: sticky; top: 56px; z-index: 10; background: var(--bg); padding: 6px 0; }
.searchbar input { flex: 1; min-width: 0; height: 50px; border-radius: var(--r); border: 1px solid var(--line); background: #fff; padding: 0 14px 0 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366748a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 13px center; background-size: 20px; font-size: 16px; }
.searchbar .btn { height: 50px; min-width: 56px; padding: 0 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 600; color: var(--navy); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.mats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.mat { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: var(--r); padding: 10px; box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent; text-align: left; width: 100%; }
.mat.incart { border-color: var(--amber); }
.mat .ph { width: 64px; height: 64px; border-radius: 12px; flex: none; overflow: hidden; display: grid; place-items: center; background: var(--blue-50); color: var(--navy); }
.mat .ph img { width: 100%; height: 100%; object-fit: cover; }
.mat .ph svg { width: 34px; height: 34px; }
.mat .nm { font-weight: 650; color: var(--navy); line-height: 1.25; }
.mat .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mat .add { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--amber); color: var(--navy-900); font-weight: 800; font-size: 15px; }
.mat .add svg { width: 22px; height: 22px; }

.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-50); color: var(--ok); } .badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.bad { background: var(--bad-50); color: var(--bad); } .badge.info { background: var(--blue-50); color: var(--blue); }
.badge.plain::before { display: none; } .badge.gray { background: #eef1f5; color: var(--muted); }

.stockbar { height: 8px; border-radius: 99px; background: #edf0f5; position: relative; overflow: visible; min-width: 90px; }
.stockbar > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.stockbar > em { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--navy); opacity: .45; }

/* Barra inferior del carrito */
.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 14px calc(10px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); }
.cartbar .btn { width: 100%; max-width: 640px; margin: 0 auto; display: flex; justify-content: space-between; box-shadow: 0 6px 24px rgba(13,31,56,.25); }
.cartbar .count { background: rgba(0,0,0,.15); border-radius: 999px; padding: 2px 10px; }

/* ---------- Hojas / modales ---------- */
.overlay { position: fixed; inset: 0; z-index: 160; background: rgba(13,31,56,.45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); animation: up .2s ease-out; }
.sheet.wide { max-width: 980px; }
@media (min-width: 760px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: -6px auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } } @keyframes fade { from { opacity: 0; } }
.qty { display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; }
.qty button { width: 64px; height: 64px; border-radius: 16px; border: 0; background: var(--blue-50); color: var(--navy); font-size: 30px; font-weight: 700; cursor: pointer; flex: none; }
.qty input { flex: 1; min-width: 0; height: 64px; text-align: center; font-size: 30px; font-weight: 800; font-family: var(--font-h); border: 2px solid var(--line); border-radius: 16px; color: var(--navy); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.quick button { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 700; color: var(--navy); cursor: pointer; }
.lines .line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines .line:last-child { border-bottom: 0; }
.lines input.q { width: 84px; height: 42px; text-align: center; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; }

/* Formularios */
label.f { display: block; } label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.inp, select.inp, textarea.inp { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; background: #fff; font-size: 15px; }
textarea.inp { height: 84px; padding: 10px 12px; resize: vertical; }
.inp:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Lista de destinos */
.dlist button { display: flex; width: 100%; gap: 12px; align-items: center; text-align: left; padding: 14px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.dlist button:hover { background: var(--bg); }
.dlist .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); flex: none; }
.dlist .ico svg { width: 22px; height: 22px; }

/* Éxito */
.success { text-align: center; padding: 30px 10px; }
.success .check-big { width: 96px; height: 96px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; animation: pop .35s ease-out; }
.success .check-big svg { width: 54px; height: 54px; }
@keyframes pop { 0% { transform: scale(.4); } 80% { transform: scale(1.08); } }

/* Toast */
.toasts { pointer-events: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-b)); z-index: 200; display: grid; gap: 8px; width: min(92vw, 460px); }
.toast { background: var(--navy-900); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 500; animation: up .2s; }
.toast.err { background: var(--bad); } .toast.ok { background: var(--ok); }

/* Escáner */
.scanner { position: fixed; inset: 0; z-index: 150; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.scanner .frame { position: absolute; left: 50%; top: 42%; width: min(70vw, 300px); aspect-ratio: 1; transform: translate(-50%,-50%);
  border-radius: 24px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); border: 3px solid var(--amber); }
.scanner .bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(16px + var(--safe-b)); display: flex; gap: 10px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.scanner .msg { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; color: #fff; text-align: center; font-weight: 600; text-shadow: 0 1px 3px #000; }

/* ---------- Administración ---------- */
.adminnav { display: flex; gap: 4px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); padding: 0 10px; position: sticky; top: 56px; z-index: 15; scrollbar-width: none; }
.adminnav a { padding: 13px 14px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-size: 14.5px; }
.adminnav a.on { color: var(--navy); border-color: var(--amber); }
.adminnav a .n { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.toolbar .inp { height: 42px; width: auto; min-width: 130px; }
.toolbar .btn { min-height: 42px; }
.kpi { padding: 14px 16px; }
.kpi .v { font-family: var(--font-h); font-weight: 700; font-size: 24px; color: var(--navy); margin-top: 2px; }
.kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi.alert .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); }
.kpi[data-go] { cursor: pointer; } .kpi[data-go]:hover { outline: 2px solid var(--blue-50); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f7f9fc; }
table.t .r { text-align: right; } table.t tr.off td { opacity: .5; }
.tablewrap { overflow: auto; max-height: 70vh; border-radius: var(--r-sm); border: 1px solid var(--line); background: #fff; }
.thumb { width: 38px; height: 38px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--blue-50); color: var(--navy); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; } .thumb svg { width: 22px; height: 22px; }
.bars .b { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; margin: 7px 0; }
.bars .b .track { height: 10px; background: #edf0f5; border-radius: 99px; overflow: hidden; } .bars .b .track i { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.vbars .c { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.vbars .c i { width: 100%; max-width: 42px; background: var(--navy); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.vbars .c:last-child i { background: var(--amber); }
.vbars .c span { font-size: 11px; color: var(--muted); } .vbars .c b { font-size: 10.5px; color: var(--navy); white-space: nowrap; }
.alert-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.ped { border: 1px solid var(--line); border-radius: var(--r); background: #fff; margin-bottom: 12px; overflow: hidden; }
.ped header { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: #fafbfd; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ped .body { padding: 6px 14px 12px; }
.ped footer { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.segmented { display: inline-flex; background: #e9edf3; border-radius: 12px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, var(--navy-700), var(--navy-900) 60%); }
.login .card { width: 100%; max-width: 400px; padding: 26px; }
.login .brand { text-align: center; margin-bottom: 18px; }
.login .brand img { height: 64px; }
.login .brand .wordmark { font-family: var(--font-h); font-weight: 800; font-size: 30px; letter-spacing: .05em; color: var(--navy); }
.login .brand .wordmark b { color: var(--amber); }
.demo-users { display: grid; gap: 8px; margin-top: 14px; }
.demo-users button { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; text-align: left; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--blue-50); color: var(--navy); flex: none; }

/* Etiquetas QR imprimibles (A4, 3 columnas) */
.labels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; padding: 8mm; background: #fff; }
.label { border: 1px dashed #b9c3d3; border-radius: 3mm; padding: 3mm; display: flex; gap: 3mm; align-items: center; page-break-inside: avoid; height: 38mm; overflow: hidden; }
.label .qr { width: 30mm; height: 30mm; flex: none; display: grid; place-items: center; }
.label .qr svg, .label .qr img { width: 100%; height: 100%; }
.label .tx { min-width: 0; font-size: 9pt; line-height: 1.2; }
.label .tx b { display: block; font-family: var(--font-h); font-size: 10pt; color: #0D1F38; margin-bottom: 1mm; }
.label .tx .code { font-weight: 800; font-size: 12pt; color: #1B3358; letter-spacing: .03em; }
.label .tx .brandline { font-size: 7pt; color: #66748a; margin-top: 1mm; }
@media (min-width: 900px) { .toasts { left: auto; right: 20px; transform: none; bottom: 20px; width: 380px; } }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .noprint, .topbar, .adminnav, .demo-banner, .toasts { display: none !important; }
  .page { padding: 0; max-width: none; }
  .label { border-color: #ddd; }
}
