/* Kho Lasanra — giao diện điện thoại trước: thẻ phiếu như tem kho, chữ hẹp in hoa cho nhãn */
:root {
  --paper: #f1f3f5;
  --card: #ffffff;
  --ink: #14202c;
  --muted: #5a6573;
  --line: #d5dbe1;
  --line-strong: #b7c0ca;
  --accent: #2246b0;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9fb;
  --ok: #1c6c45;
  --ok-soft: #dff1e7;
  --warn: #8a4f00;
  --warn-soft: #fbeed6;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --top: #14202c;
  --top-ink: #eef2f6;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Be Vietnam Pro", "Segoe UI", Roboto, Arial, sans-serif;
  --f-mono: "JetBrains Mono", Consolas, "Courier New", monospace;
  --tabs-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1318; --card: #161d24; --ink: #e4e9ee; --muted: #9aa5b1; --line: #2a333d; --line-strong: #3b4652;
    --accent: #8ba7ff; --accent-ink: #0e1318; --accent-soft: #1d2747; --ok: #6fcf9b; --ok-soft: #12301f;
    --warn: #f1b85c; --warn-soft: #33260f; --bad: #ff8a80; --bad-soft: #3a1c1a; --top: #0a0e12; --top-ink: #e4e9ee;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font: 15px/1.5 var(--f-body);
  -webkit-text-size-adjust: 100%; min-height: 100vh;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
}
body.no-tabs { padding-bottom: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; }
h2 { font-size: 22px; letter-spacing: .01em; }
h3 { font-size: 18px; letter-spacing: .02em; }
p { margin: 0; }
.mono { font-family: var(--f-mono); font-size: .9em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label {
  font-family: var(--f-display); font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  font-size: 12.5px; color: var(--muted);
}

/* khung */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--top); color: var(--top-ink);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: var(--f-display); font-weight: 700; font-size: 19px; letter-spacing: .08em; }
.brand-mark { width: 18px; height: 18px; border: 2px solid currentColor; position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 3px; background: currentColor; }
.who { color: inherit; text-decoration: none; font-size: 13px; text-align: right; line-height: 1.25; min-width: 0; }
.who b { display: block; font-weight: 600; }
.who span { opacity: .75; }
.banner {
  background: var(--warn-soft); color: var(--warn); font-size: 13px; text-align: center;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
}
main {
  max-width: 820px; margin: 0 auto; display: grid; gap: 18px; outline: none;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) 28px max(16px, env(safe-area-inset-left, 0px));
}
.loading { color: var(--muted); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.tabs a {
  display: grid; place-items: center; gap: 2px; height: var(--tabs-h); text-decoration: none; color: var(--muted);
  font-family: var(--f-display); font-weight: 600; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a.on { color: var(--accent); }
.tabs a.plus span.ic { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; }

/* khối */
.stack { display: grid; gap: 12px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.empty { color: var(--muted); font-size: 14px; padding: 14px; border: 1px dashed var(--line-strong); border-radius: 4px; text-align: center; }
.err { color: var(--bad); font-size: 14px; }

/* nút */
.btn {
  appearance: none; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 3px; padding: 10px 16px; font-weight: 600; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.light { color: #fff; border-color: rgba(255,255,255,.6); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 140px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick a {
  display: grid; gap: 4px; padding: 14px; border-radius: 4px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--accent);
}
.quick a b { font-family: var(--f-display); font-size: 18px; letter-spacing: .02em; }
.quick a span { font-size: 13px; color: var(--muted); }

/* biểu mẫu */
label.f { display: grid; gap: 4px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--card); border-radius: 3px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
input[type=number] { font-variant-numeric: tabular-nums; }
.search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

/* trạng thái */
.pill {
  display: inline-block; font-family: var(--f-display); font-weight: 600; font-size: 12.5px; letter-spacing: .07em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 3px; background: var(--paper); color: var(--muted); white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.strike { text-decoration: line-through; }

/* thẻ phiếu */
.tlist { display: grid; gap: 8px; }
.tcard {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: 3px;
}
.tcard.s-dang_chuyen { border-left-color: var(--accent); }
.tcard.s-nhan_lech, .tcard.s-tra_lai { border-left-color: var(--bad); }
.tcard.s-cho_duyet { border-left-color: var(--warn); }
.tcard.s-da_nhan, .tcard.s-da_duyet { border-left-color: var(--ok); }
.tcard .code { font-family: var(--f-mono); font-weight: 500; font-size: 14px; }
.tcard .route { font-size: 14px; }
.tcard .meta { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.tcard .qty { text-align: right; font-family: var(--f-display); font-weight: 700; font-size: 22px; line-height: 1; }
.tcard .qty small { display: block; font-family: var(--f-body); font-weight: 400; font-size: 11px; color: var(--muted); }

/* chi tiết */
.head { display: grid; gap: 6px; }
.route-big { font-family: var(--f-display); font-weight: 700; font-size: 20px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.route-big .arr { color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; }
.facts div { display: grid; gap: 1px; min-width: 0; }
.facts b { font-weight: 500; }
.tbl-wrap { overflow-x: auto; min-width: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-family: var(--f-display); font-weight: 600; font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: var(--paper); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.minus { color: var(--bad); font-weight: 600; }
td.plus { color: var(--ok); font-weight: 600; }
td input[type=number] { width: 84px; min-height: 38px; padding: 6px 8px; text-align: right; }
td select { min-height: 38px; padding: 6px 8px; width: auto; }
.sku { font-family: var(--f-mono); font-size: 13px; }
.sub { font-size: 12.5px; color: var(--muted); }
.log { display: grid; gap: 0; border-left: 2px solid var(--line-strong); margin-left: 6px; }
.log div { position: relative; padding: 0 0 12px 16px; font-size: 14px; }
.log div::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid var(--accent); }
.log time { font-size: 12.5px; color: var(--muted); }
details.payload summary { cursor: pointer; font-size: 13px; color: var(--muted); }
details.payload pre { font-family: var(--f-mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; margin: 6px 0 0; background: var(--paper); padding: 8px; border-radius: 3px; }

/* chọn sản phẩm */
.lines { display: grid; gap: 6px; }
.line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center;
  padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 3px;
}
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--paper); cursor: pointer; font-size: 18px; }
.stepper input { width: 56px; min-height: 40px; border: 0; border-radius: 0; text-align: center; padding: 0; }
.results { display: grid; gap: 6px; }
.res { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 3px; cursor: pointer; text-align: left; }
.res:hover { border-color: var(--accent); }
.matrix th, .matrix td { text-align: center; padding: 6px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix input { width: 58px; min-height: 38px; text-align: center; padding: 4px; }
.matrix .st { display: block; font-size: 11px; color: var(--muted); }
.sticky-foot {
  position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); z-index: 5;
  background: var(--paper); padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px;
}
.total { font-family: var(--f-display); font-weight: 700; font-size: 18px; }

/* bộ lọc */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.chips button { flex: 0 0 auto; border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chips button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: 3px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--card); padding: 10px; cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* đăng nhập */
.login { max-width: 380px; margin: 8vh auto 0; display: grid; gap: 16px; }
.login .brand { color: var(--ink); font-size: 26px; }

/* thông báo, quét */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50; max-width: min(92vw, 520px);
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.toast.bad { background: var(--bad); color: #fff; }
.scan { position: fixed; inset: 0; z-index: 60; background: #000; display: grid; place-items: center; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; width: min(78vw, 360px); height: 160px; border: 2px solid #fff; border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.scan-hint { position: absolute; top: calc(18% + env(safe-area-inset-top, 0px)); color: #fff; font-size: 15px; }
.scan .btn { position: absolute; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }

@media (min-width: 760px) {
  h1 { font-size: 34px; }
  .tcard .route { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
