/* ====================================================================
   XUẤT NHẬP KHO LONG PHÁT — giao diện
   --------------------------------------------------------------------
   Bảng màu: một gam xanh lá duy nhất đi từ đậm tới nhạt, thêm vàng hổ
   phách làm điểm nhấn. Không dùng nhiều màu rực cạnh nhau — chỉ việc
   cần chú ý (thiếu hàng, quá hạn) mới được tô đỏ, nên nhìn là thấy ngay.

   Bo góc theo ba cỡ thống nhất: thẻ lớn 16px, nút và ô nhập 10px,
   nhãn nhỏ bo tròn hẳn.

   Mọi tên lớp giữ nguyên như cũ, chỉ đổi phần nhìn.
   ==================================================================== */

:root {
  /* Nền và chữ */
  --bg: #eef2f0;
  --bg-2: #f6faf8;
  --card: #ffffff;
  --line: #e4ebe8;
  --line-2: #eff4f2;
  --text: #16241f;
  --text-2: #3d504a;
  --muted: #6d817a;

  /* Một gam xanh duy nhất */
  --brand-900: #0a3b2c;
  --brand-700: #0b6b4f;
  --brand-500: #11936b;
  --brand-300: #4cb995;
  --brand-100: #d9efe6;
  --brand-50: #eef7f3;
  --brand: var(--brand-700);
  --brand-2: var(--brand-500);
  --brand-3: var(--brand-300);
  --brand-soft: var(--brand-50);
  --brand-grad: linear-gradient(135deg, #0b6b4f, #11936b);

  /* Điểm nhấn ấm, dùng rất tiết chế */
  --gold: #b4791c;
  --gold-soft: #fbf3e3;

  --accent: #1a6a63;          /* xanh ngọc — cùng họ với xanh lá */
  --accent-soft: #e4f1ef;
  --warn: #a4711f;
  --warn-soft: #fbf4e6;
  --danger: #b93b2c;
  --danger-soft: #fcecea;
  --ok: #15804c;
  --ok-soft: #e3f3ea;

  /* Bo góc — ba cỡ, dùng thống nhất toàn phần mềm */
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 7px;
  --radius: var(--r-lg);
  --radius-sm: var(--r-md);

  --shadow: 0 1px 2px rgba(12, 40, 31, .04), 0 3px 12px rgba(12, 40, 31, .05);
  --shadow-lg: 0 12px 32px rgba(12, 40, 31, .12);
  --ring: 0 0 0 3px rgba(17, 147, 107, .16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 480px at 100% -5%, rgba(17, 147, 107, .09), transparent 62%),
    radial-gradient(700px 420px at -5% 105%, rgba(180, 121, 28, .07), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* Thanh cuộn mảnh, hợp tông */
* { scrollbar-width: thin; scrollbar-color: #c6d6d0 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: #c6d6d0; border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #a9bdb6; background-clip: content-box; }

/* ---------- Khung trang ---------- */
.app { display: grid; grid-template-columns: 246px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #0d3528 0%, #0a2a20 60%, #082018 100%);
  color: #cfe3dc;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .05);
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); background-clip: content-box; }

.brand {
  padding: 18px 16px 15px; display: flex; gap: 11px; align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(140deg, var(--brand-300), var(--brand-500) 75%);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 17px;
  box-shadow: 0 5px 14px rgba(17, 147, 107, .35), inset 0 1px 0 rgba(255, 255, 255, .3);
}
.brand b { font-size: 14.5px; color: #fff; display: block; line-height: 1.3; }
.brand small { color: #87ad9f; font-size: 11px; }

.nav { padding: 8px 10px 26px; flex: 1; }
.nav .grp-label {
  padding: 16px 10px 6px; font-size: 10.5px; letter-spacing: .09em;
  text-transform: uppercase; color: #6b9185; font-weight: 700;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0; border-radius: var(--r-md);
  color: #c8ded7; font-size: 13.5px; position: relative;
  transition: background .14s ease, color .14s ease;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.on {
  background: linear-gradient(100deg, rgba(76, 185, 149, .22), rgba(76, 185, 149, .06));
  color: #fff; font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(76, 185, 149, .26);
}
.nav a.on::before {
  content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--brand-300);
}
.nav a .ico { width: 19px; text-align: center; opacity: .9; font-size: 15px; }
.nav a .badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; font-weight: 700;
}

/* Nút ba gạch — chỉ hiện trên màn hình hẹp */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(160%) blur(8px);
  -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 11px 20px; display: flex; align-items: center; gap: 13px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  font-size: 17.5px; margin: 0; font-weight: 700; letter-spacing: -.2px;
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.topbar h1::before {
  content: ''; width: 4px; height: 19px; border-radius: 99px;
  background: var(--brand-grad); flex: none;
}
.topbar .spacer { flex: 1; }

.wh-picker {
  display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 6px 3px 13px;
}
.wh-picker select {
  border: none; background: none; padding: 4px 6px; width: auto;
  min-width: 120px; font-weight: 600; color: var(--text);
}
.wh-picker select:focus { box-shadow: none; }

/* Dải trạng thái đồng bộ tự động */
.autosync {
  display: flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(21, 128, 76, .16);
  white-space: nowrap; user-select: none; transition: box-shadow .15s ease;
}
.autosync:hover { box-shadow: 0 2px 8px rgba(21, 128, 76, .16); }
.autosync.off { background: #eef2f1; color: var(--muted); border-color: var(--line); }
.autosync.err { background: var(--warn-soft); color: var(--warn); border-color: rgba(164, 113, 31, .2); }
.autosync .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.autosync .dot.spin-dot {
  background: none; border: 2px solid currentColor; border-top-color: transparent;
  width: 12px; height: 12px; animation: sp .7s linear infinite;
}
@media (max-width: 1150px) { .autosync .txt { display: none; } }

.who { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.who .av {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--brand-grad); color: #fff;
  display: grid; place-items: center; font-weight: 700;
  box-shadow: 0 3px 10px rgba(11, 107, 79, .25);
}
.content { padding: 20px; flex: 1; min-width: 0; animation: fadeUp .2s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(5px); } }

/* ---------- Thẻ ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  background: linear-gradient(180deg, #fbfdfc, #fff);
}
.card-head h2 {
  margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.1px;
  display: flex; align-items: center; gap: 8px;
}
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ---------- Nút ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: var(--r-md);
  padding: 8px 14px; cursor: pointer; font-size: 13.5px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap; color: var(--text-2); min-height: 38px;
  box-shadow: 0 1px 2px rgba(12, 40, 31, .04);
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.btn:hover { background: var(--bg-2); border-color: #d2e0da; }
.btn:active { background: #eef3f1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: var(--brand-grad); border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px rgba(11, 107, 79, .22);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); border-color: #edc8c3; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; min-height: 32px; border-radius: var(--r-sm); }
.btn.link { border: none; background: none; color: var(--brand-700); padding: 2px 4px; box-shadow: none; min-height: 0; }
.btn.link:hover { text-decoration: underline; background: none; }

/* ---------- Ô nhập ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=number], input[type=date], input[type=time],
input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 9px 11px;
  background: #fff; width: 100%; outline: none; min-height: 38px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: var(--ring); }
input[readonly] { background: var(--bg-2); color: var(--muted); }
textarea { resize: vertical; min-height: 62px; }
input[type=checkbox] { accent-color: var(--brand-2); width: 17px; height: 17px; }

.grid { display: grid; gap: 15px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* ---------- Bảng ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 11px 14px; color: var(--muted);
  background: #f4f8f6;
  font-weight: 700; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tbl tbody tr { transition: background .12s ease; }
table.tbl tbody tr:nth-child(even) { background: #fafcfb; }
table.tbl tbody tr:hover { background: var(--brand-50); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl tfoot td,
table.tbl tr:has(td[colspan]) td { font-weight: 700; background: #f4f8f6; }
table.tbl tfoot td { padding: 11px 14px; border-top: 2px solid var(--line); }
table.tbl td.danger, table.tbl .num.danger { color: var(--danger); font-weight: 650; }
table.tbl td.warn, table.tbl .num.warn { color: var(--warn); font-weight: 650; }

.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 32px; margin-bottom: 8px; opacity: .4; }

/* ---------- Nhãn tròn ---------- */
.pill {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(21, 128, 76, .16); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(164, 113, 31, .18); }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(185, 59, 44, .16); }
.pill.muted { background: #eff3f1; color: var(--muted); border-color: var(--line); }
.pill.info { background: var(--accent-soft); color: var(--accent); border-color: rgba(26, 106, 99, .14); }

/* ---------- Ô số liệu ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(214px, 1fr)); gap: 15px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 17px; box-shadow: var(--shadow);
  transition: transform .16s ease, box-shadow .16s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
/* Vạch màu mảnh trên đầu — cùng một gam xanh, đậm nhạt khác nhau */
.kpi::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--brand-700);
}
.kpis .kpi:nth-child(2)::before { background: var(--brand-500); }
.kpis .kpi:nth-child(3)::before { background: var(--brand-300); }
.kpis .kpi:nth-child(4)::before { background: var(--accent); }
.kpis .kpi:nth-child(5)::before { background: var(--gold); }
.kpi.alert::before { background: var(--danger); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.kpi .val {
  font-size: clamp(19px, 1.7vw, 26px); font-weight: 800; letter-spacing: -.5px;
  overflow-wrap: anywhere; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.kpi.alert .val { color: var(--danger); }

/* ---------- Hộp thoại ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(8, 26, 21, .5);
  display: grid; place-items: center; z-index: 100; padding: 18px;
  animation: fadeIn .14s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: var(--r-lg); width: min(980px, 100%);
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(5, 22, 17, .34);
  animation: popIn .18s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes popIn { from { transform: translateY(12px) scale(.99); opacity: 0; } }
.modal.sm { width: min(520px, 100%); }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #fbfdfc, #fff);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head .x {
  margin-left: auto; border: none; background: none; font-size: 21px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 4px 9px; border-radius: var(--r-sm);
}
.modal-head .x:hover { background: var(--bg-2); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line-2);
  display: flex; gap: 10px; justify-content: flex-end; background: #fafcfb;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal-foot .spacer { flex: 1; }

/* ---------- Tin nổi ---------- */
#toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: #12291f; color: #fff; padding: 12px 16px; border-radius: var(--r-md);
  box-shadow: 0 10px 26px rgba(5, 22, 17, .3); font-size: 13.5px; max-width: 420px;
  font-weight: 500; border-left: 3px solid rgba(255, 255, 255, .25);
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.15);
}
.toast.err { background: #8e2d22; border-left-color: #e8a79e; }
.toast.ok { background: #115c3d; border-left-color: var(--brand-300); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Đăng nhập ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(800px 460px at 18% 12%, rgba(76, 185, 149, .26), transparent 60%),
    radial-gradient(700px 440px at 85% 88%, rgba(180, 121, 28, .16), transparent 60%),
    linear-gradient(145deg, #0a2a21, #10402f 60%, #0b2b22);
}
.login-box {
  background: #fff; padding: 32px 30px; border-radius: 20px;
  width: min(392px, 94vw);
  box-shadow: 0 24px 60px rgba(3, 18, 14, .4);
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.15);
}
.login-box .logo-lg {
  width: 56px; height: 56px; border-radius: 17px; margin: 0 auto 15px;
  background: linear-gradient(140deg, var(--brand-300), var(--brand-500) 75%);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px;
  box-shadow: 0 8px 22px rgba(17, 147, 107, .4);
}
.login-box h2 { margin: 0 0 5px; text-align: center; font-size: 19.5px; font-weight: 750; }
.login-box p.sub { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.login-box .field + .field { margin-top: 13px; }
.login-box .btn { width: 100%; margin-top: 20px; padding: 12px; font-size: 14.5px; min-height: 46px; }
.login-err {
  background: var(--danger-soft); color: var(--danger); padding: 10px 13px;
  border-radius: var(--r-md); font-size: 13px; margin-bottom: 15px;
  border: 1px solid rgba(185, 59, 44, .16);
}

/* ---------- Dòng hàng trong phiếu ---------- */
.line-tbl input { padding: 7px 9px; border-radius: var(--r-sm); min-height: 34px; }
.line-tbl input.num { text-align: right; }
.picker-wrap { position: relative; }
.picker-list {
  position: absolute; z-index: 50; top: 100%; left: 0; right: 0;
  max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); margin-top: 4px; padding: 4px;
}
.picker-list div { padding: 10px 11px; cursor: pointer; border-radius: var(--r-sm); }
.picker-list div:hover, .picker-list div.hl { background: var(--brand-50); }
.picker-list .sku { color: var(--muted); font-size: 12px; }

/* Ô chọn có gõ tìm */
.o-chon-tim { position: relative; }
.o-chon-tim > input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 2px), calc(100% - 10px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px; cursor: text;
}
.o-chon-tim .picker-list div.dang-chon { background: var(--brand-50); font-weight: 600; }
.o-chon-tim .picker-list div.dang-chon::after { content: ' ✓'; color: var(--brand-2); }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.tot-box {
  margin-left: auto; width: min(360px, 100%);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 16px;
}
.tot-box .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.tot-box .row.grand {
  border-top: 1px dashed var(--line); margin-top: 7px; padding-top: 10px;
  font-weight: 800; font-size: 16px; color: var(--brand-700);
}
.toolbar { display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .field { min-width: 150px; }

.spin {
  display: inline-block; width: 13px; height: 13px; border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite;
}
.btn:not(.primary) .spin { border-color: rgba(0, 0, 0, .14); border-top-color: var(--brand-2); }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Băng tin kết quả kéo tồn từ Google Sheet ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px 17px; border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.banner::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--muted); }
.banner.ok { border-color: #c3e3cf; background: linear-gradient(100deg, var(--ok-soft), #fbfefc); }
.banner.ok::before { background: var(--ok); }
.banner.warn { border-color: #ebdcb6; background: linear-gradient(100deg, var(--warn-soft), #fffdf8); }
.banner.warn::before { background: var(--gold); }
.banner.danger { border-color: #efc9c3; background: linear-gradient(100deg, var(--danger-soft), #fffbfa); }
.banner.danger::before { background: var(--danger); }
.banner-ico { font-size: 20px; line-height: 1.2; flex: none; }
.banner-body { flex: 1; min-width: 0; }
.banner-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.banner.ok .banner-title { color: var(--ok); }
.banner.warn .banner-title { color: var(--warn); }
.banner.danger .banner-title { color: var(--danger); }
.banner-sub { font-size: 13px; color: var(--muted); line-height: 1.55; }
.banner .btn { flex: none; margin-top: 2px; }

/* ====================================================================
   ĐIỆN THOẠI — thanh bên trượt ra, mọi thứ một cột, nút to dễ bấm
   ==================================================================== */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  /* Thanh bên nằm ngoài màn hình, bấm nút ba gạch mới trượt vào */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; z-index: 60;
    height: 100dvh; transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.3, .8, .4, 1);
    box-shadow: 8px 0 28px rgba(6, 26, 20, .3);
  }
  body.nav-mo .sidebar { transform: translateX(0); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 26, 21, .45);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  body.nav-mo .nav-backdrop { opacity: 1; pointer-events: auto; }

  /* Nút ba gạch */
  .nav-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 40px; height: 40px; flex: none; padding: 0 9px;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--text-2); }

  .topbar {
    padding: 9px 12px; gap: 9px; flex-wrap: nowrap;
    /* Thanh trên cùng gọn trong MỘT hàng */
  }
  /* Tựa đề co giãn theo chỗ trống, dài quá thì cắt bớt bằng dấu … */
  .topbar h1 {
    font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1 1 auto; min-width: 36px; display: block;
  }
  .topbar h1::before { display: none; }
  .topbar .spacer { display: none; }
  .autosync { display: none; }              /* dải đồng bộ để dành cho máy tính */
  /* font-size:0 làm chữ "Kho:" biến mất, chỉ còn tên kho trong ô chọn */
  .wh-picker { flex: 0 1 auto; max-width: 40vw; padding: 2px; font-size: 0; }
  .wh-picker select {
    min-width: 0; max-width: 100%; font-size: 12.5px; padding: 5px 6px; font-weight: 600;
  }
  .who { flex: 0 0 auto; gap: 6px; }
  .who > div:not(.av) { display: none; }    /* chỉ còn chữ cái đầu */
  .who .av { width: 32px; height: 32px; font-size: 13px; }
  .who .btn { padding: 6px 9px; min-height: 32px; font-size: 12.5px; }

  .content { padding: 13px; }
  .card { border-radius: 14px; }
  .card + .card { margin-top: 13px; }
  .card-head { padding: 13px 14px; gap: 9px; }
  .card-head h2 { font-size: 14.5px; }
  .card-body { padding: 14px; }

  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 11px; }
  .kpi { padding: 13px 14px; border-radius: 14px; }
  .kpi .val { font-size: 20px; }
  .kpi .lbl { font-size: 12px; }
  .kpi .sub { font-size: 11.5px; }

  /* Bảng trên điện thoại: thà kéo ngang còn hơn bóp chữ xuống 3 dòng.
     Cột mã SKU dính lại bên trái để kéo ngang vẫn biết đang xem dòng nào. */
  table.tbl { font-size: 13px; min-width: 580px; }
  table.tbl th { padding: 9px 10px; font-size: 11px; }
  table.tbl td { padding: 9px 10px; white-space: nowrap; }
  table.tbl td:nth-child(2), table.tbl th:nth-child(2) { white-space: normal; min-width: 150px; }
  table.tbl th:first-child, table.tbl td:first-child {
    position: sticky; left: 0; z-index: 1;
    box-shadow: 1px 0 0 var(--line-2);
  }
  table.tbl td:first-child { background: #fff; }
  table.tbl tbody tr:nth-child(even) td:first-child { background: #fafcfb; }
  table.tbl th:first-child { background: #f4f8f6; z-index: 3; }
  table.tbl tfoot td:first-child { background: #f4f8f6; }
  .table-wrap { border-radius: 0 0 14px 14px; }

  /* Ô nhập cao hơn cho dễ chạm, 16px để iPhone không tự phóng to */
  input[type=text], input[type=number], input[type=date], input[type=time],
  input[type=password], select, textarea {
    font-size: 16px; min-height: 44px; border-radius: var(--r-md);
  }
  .btn { min-height: 42px; padding: 9px 15px; }
  .btn.sm { min-height: 34px; }
  .toolbar { gap: 9px; }
  .toolbar .field { min-width: 100%; }

  .banner { padding: 13px 14px; gap: 11px; flex-wrap: wrap; }
  .banner-title { font-size: 14.5px; }
  .banner .btn { width: 100%; margin-top: 8px; }

  .modal { max-height: 94dvh; border-radius: 16px; }
  .modal-body { padding: 15px; }
  .modal-foot { padding: 12px 15px; }
  .modal-foot .btn { flex: 1; }

  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }

  .tot-box { width: 100%; }
}

/* Điện thoại hẹp: tên trang chiếm trọn hàng trên, ô chọn kho xuống hàng dưới
   — nhét hết vào một hàng thì tên trang bị cắt cụt, nhìn không biết đang ở đâu */
@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar h1 { flex: 1 1 auto; font-size: 16.5px; }
  .wh-picker {
    order: 10; flex: 1 0 100%; max-width: none;
    padding: 2px 2px 2px 10px; font-size: 12px; color: var(--muted);
    justify-content: space-between;
  }
  .wh-picker select { max-width: none; flex: 1; text-align: right; }
}

/* Màn hình rất hẹp */
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .val { font-size: 18px; }
}
