:root {
  --bg: #f3f5f8; --card: #fff; --ink: #18202b; --muted: #64707d; --line: #e2e6ec; --line-strong: #cfd5dd;
  --accent: #2457c5; --accent-ink: #fff; --accent-soft: #e8eefb;
  --ok: #17824a; --ok-bg: #e4f4ea; --bad: #c0392b; --bad-bg: #fbe9e6; --warn: #9a6400; --warn-bg: #fff4d9;
  --info: #2457c5; --info-bg: #e8eefb; --gray-bg: #eef0f3;
  --nav-bg: #14213d; --nav-ink: #c9d3e3; --nav-active: #fff;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 2px 8px rgba(20, 33, 61, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Thanh điều hướng trên cùng */
header.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 60px; background: var(--nav-bg); color: var(--nav-ink); box-shadow: 0 1px 0 rgba(0,0,0,.2); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; text-decoration: none; margin-right: 12px; white-space: nowrap; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand .logo svg.i { width: 20px; height: 20px; color: #fff; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-weight: 600; white-space: nowrap; }
nav.tabs a:hover { background: rgba(255,255,255,.08); color: #fff; }
nav.tabs a.active { background: rgba(255,255,255,.14); color: var(--nav-active); box-shadow: inset 0 -3px 0 var(--accent); }
.user { display: flex; align-items: center; gap: 10px; margin-left: auto; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #3b5bdb; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.user .who { line-height: 1.15; }
.user .who b { display: block; color: #fff; font-size: 14px; }
.user .who span { font-size: 12px; color: var(--nav-ink); }
.user button { background: transparent; color: var(--nav-ink); border-color: rgba(255,255,255,.25); padding: 7px 12px; }
.user button:hover { background: rgba(255,255,255,.1); color: #fff; }
.role-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.14); color: #fff; }
/* Điện thoại: tab chuyển xuống đáy màn hình, nút to dễ bấm */
@media (max-width: 760px) {
  header.topbar { padding: 0 12px; min-height: 52px; }
  .user .who b { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .user .logout-label { display: none; }
  .user button { min-height: 44px; min-width: 44px; }
  nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--nav-bg); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); gap: 2px; box-shadow: 0 -1px 0 rgba(0,0,0,.2); }
  nav.tabs a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; min-height: 52px; font-size: 12px; justify-content: center; }
  nav.tabs a svg.i { width: 22px; height: 22px; }
  nav.tabs a.active { box-shadow: inset 0 3px 0 var(--accent); }
  body { padding-bottom: 72px; }
}

/* Bố cục */
main { padding: 20px 16px 40px; max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card > h2, .card-title { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta { color: var(--muted); }

/* Nút và ô nhập */
input, select, button { font: inherit; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 600; text-decoration: none; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 16px; background: #fff; color: var(--ink); transition: background .15s, border-color .15s; }
button:hover, .btn:hover { background: #f6f8fb; border-color: #b8c1cc; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover, .btn.primary:hover { background: #1d48a8; }
button.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
button.ok:hover { background: #126b3c; }
button.bad { background: var(--bad); color: #fff; border-color: var(--bad); }
button.bad:hover { background: #a32f23; }
button.big { font-size: 20px; padding: 16px 24px; min-width: 180px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Thẻ số liệu */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--line-strong); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.total { border-top-color: var(--ink); }
.stat.moi { border-top-color: #8792a2; }
.stat.da_in { border-top-color: var(--info); }
.stat.qc_loi, .stat.huy { border-top-color: var(--bad); }
.stat.qc_dat, .stat.da_ship { border-top-color: var(--ok); }

/* Bảng */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
td, th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: #f8f9fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fafbfd; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--gray-bg); color: #4a5563; white-space: nowrap; }
.pill.qc_dat, .pill.da_ship { background: var(--ok-bg); color: var(--ok); }
.pill.qc_loi, .pill.huy { background: var(--bad-bg); color: var(--bad); }
.pill.da_in { background: var(--info-bg); color: var(--info); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* Thông báo */
.banner { border-radius: var(--radius); padding: 14px 18px; font-size: 19px; font-weight: 700; margin-bottom: 16px; border: 1px solid transparent; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cc; }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: #f2c4bd; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: #f0dca6; }

/* Trang quét */
#code { font-size: 22px; width: 100%; padding: 14px 16px; border-width: 2px; }
.stations { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.stations button { padding: 14px 10px; font-size: 17px; min-height: 52px; }
@media (max-width: 520px) { .stations button { flex-direction: column; gap: 4px; font-size: 14px; padding: 10px 4px; } }
.stations button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.grid { display: grid; grid-template-columns: 280px 1fr; gap: 16px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } .mockup { max-height: 240px; object-fit: contain; } }
.mockup { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.variant { white-space: pre-wrap; font-size: 22px; font-weight: 600; background: var(--warn-bg); border-radius: 8px; padding: 12px; }
.current td { background: #fffbe8; }
tbody tr:nth-child(even) td { background: #fafbfc; }
tbody tr:hover td { background: #f2f5fa; }
