[hidden] { display: none !important; }
:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1d2330; --muted: #6b7385; --border: #e3e6ec;
  --accent: #2f6fde; --accent-text: #fff; --good: #1f8a4c; --bad: #c8372d; --warn: #b7791f;
  --m-VN: #d64545; --m-ID: #2f6fde; --m-TH: #1f8a4c; --m-MY: #b7791f; --m-PH: #7b4fc9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1b1f27; --text: #e7eaf0; --muted: #98a0b0; --border: #2c323d;
    --accent: #5b8ff0; --good: #45b97a; --bad: #ec6a5f; --warn: #e0a53c;
    --m-VN: #ec6a5f; --m-ID: #5b8ff0; --m-TH: #45b97a; --m-MY: #e0a53c; --m-PH: #a283e0;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; font: inherit; }
.tabs button.active { background: var(--bg); color: var(--text); font-weight: 600; }
.sync { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn { background: var(--accent); color: var(--accent-text); border: 0; padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; display: inline-block; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; font-weight: 600; }
.badge.warn { background: var(--warn); color: #fff; }
.filters { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.filters .group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filters label { color: var(--muted); font-size: 12px; }
select, input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; }
.chip { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 99px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { border-color: var(--text); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
main { padding: 16px 20px 40px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.card h2 { font-size: 14px; margin: 0 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; }
tr.total td { font-weight: 700; }
table.orders td.wrap { white-space: normal; min-width: 180px; }
.st { padding: 2px 8px; border-radius: 99px; font-size: 12px; border: 1px solid var(--border); }
.st.good { color: var(--good); border-color: currentColor; }
.st.bad { color: var(--bad); border-color: currentColor; }
.st.warn { color: var(--warn); border-color: currentColor; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
#search { flex: 1; min-width: 260px; }
.pager { margin-top: 10px; }
.chart svg { width: 100%; height: 240px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.bar-h { height: 8px; background: var(--accent); border-radius: 4px; opacity: .8; }
table.form input { width: 100%; min-width: 90px; }
.ok { color: var(--good); } .err { color: var(--bad); }
.small { font-size: 12px; margin: 8px 0 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 7px 16px; font: inherit; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.report-wrap { max-height: 75vh; overflow: auto; }
table.report th, table.report td { padding: 6px 10px; }
table.report thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; text-align: right; }
table.report th:first-child, table.report td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; min-width: 240px; }
table.report thead th:first-child { z-index: 3; }
table.report td.tot, table.report th.tot { font-weight: 700; background: var(--bg); }
table.report tr.grp td { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); background: var(--bg); }
table.report tr.grp td:first-child { background: var(--bg); }
table.report td.zero { color: var(--muted); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 640px) {
  .top, .filters, main { padding-left: 12px; padding-right: 12px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---- bảng báo cáo Daily / Weekly / Monthly (cùng tông với dashboard, sáng & tối) ---- */
.report-wrap { max-height: 78vh; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.sheet { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }
table.sheet td, table.sheet th { padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.sheet tr.t1 td { padding: 12px 14px 6px; border-bottom: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; color: var(--accent); text-align: left; background: var(--surface); }
table.sheet tr.t2 th { position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; text-align: right; border-bottom: 2px solid var(--border); }
table.sheet tr.t2 th:first-child, table.sheet.daily tr.t2 th:nth-child(2) { text-align: left; }
table.sheet td.num { text-align: right; }
table.sheet td.tot, table.sheet th.tot { background: color-mix(in srgb, var(--accent) 9%, var(--surface)); font-weight: 700; }
table.sheet td.b { font-weight: 600; }
table.sheet td.lbl { font-weight: 500; min-width: 200px; }
table.sheet td.lbl.sub { font-weight: 700; }
table.sheet td.dept { font-weight: 700; font-size: 13px; min-width: 120px; vertical-align: middle; border-right: 1px solid var(--border); }
table.sheet td.d-admin { background: color-mix(in srgb, var(--m-MY) 13%, var(--surface)); color: color-mix(in srgb, var(--m-MY) 70%, var(--text)); }
table.sheet td.d-sales { background: color-mix(in srgb, var(--m-ID) 13%, var(--surface)); color: color-mix(in srgb, var(--m-ID) 70%, var(--text)); }
table.sheet td.d-kho { background: color-mix(in srgb, var(--m-TH) 13%, var(--surface)); color: color-mix(in srgb, var(--m-TH) 70%, var(--text)); }
table.sheet td.d-vc { background: color-mix(in srgb, var(--m-PH) 13%, var(--surface)); color: color-mix(in srgb, var(--m-PH) 70%, var(--text)); }
table.sheet tbody tr:hover td:not(.dept) { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
table.sheet.weekly td.lbl { min-width: 270px; }
table.sheet.weekly th { white-space: normal; min-width: 110px; }
table.sheet.weekly tr.hl td { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); font-weight: 600; }
table.sheet.weekly tr.hl td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.sheet.weekly tr.hl td.tot { background: color-mix(in srgb, var(--warn) 24%, var(--surface)); }
table.sheet.weekly tr.sec td { padding-top: 16px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); border-bottom: 1px solid var(--border); background: var(--surface); }

/* ---- cố định cột: Daily = Bộ Phận + Chỉ Số + Tổng (trái); Weekly/Monthly = Thông tin (trái) + Tổng (phải) ---- */
table.sheet .stk { position: sticky; z-index: 1; }
table.sheet tr.t2 th.stk { z-index: 3; }
table.sheet td.stk:not(.tot):not(.dept), table.sheet th.stk:not(.tot) { background: var(--surface); }
table.sheet.weekly tr.hl td.stk.l0 { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); }
table.sheet.daily .c1 { left: 0; width: 130px; min-width: 130px; max-width: 130px; }
table.sheet.daily .c2 { left: 130px; width: 230px; min-width: 230px; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
table.sheet.daily .c3 { left: 360px; width: 120px; min-width: 120px; box-shadow: 6px 0 8px -6px rgba(0,0,0,.25); }
table.sheet.weekly .l0 { left: 0; box-shadow: 6px 0 8px -6px rgba(0,0,0,.25); }
table.sheet.weekly .r0 { right: 0; box-shadow: -6px 0 8px -6px rgba(0,0,0,.25); }
table.sheet .pin { position: sticky; left: 14px; }

.tabs a.tab-link { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font: inherit; }
.tabs a.tab-link:hover { background: var(--bg); color: var(--text); }
.pick { position: relative; display: inline-block; }
.pick summary { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 99px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 13px; }
.pick-list { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; max-height: 260px; overflow: auto; z-index: 20; min-width: 200px; }
.pick-list label { display: flex; align-items: center; gap: 6px; padding: 3px 0; white-space: nowrap; }
.pick-list input { width: auto; }
