/* Tokens theo dataviz reference palette — light & dark được chọn riêng, không tự đảo */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --sidebar: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --model-hj: #eda100;
  --model-tl: #6250d6;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.08);
  --warning-wash: rgba(250, 178, 25, 0.14);
  --good-wash: rgba(12, 163, 12, 0.10);
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #242423; --sidebar: #141413;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --model-hj: #c98500; --model-tl: #9085e9;
    --good-text: #0ca30c; --critical-wash: rgba(208, 59, 59, 0.16); --warning-wash: rgba(250, 178, 25, 0.12); --good-wash: rgba(12, 163, 12, 0.14);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #242423; --sidebar: #141413;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --accent-wash: rgba(57, 135, 229, 0.16);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --model-hj: #c98500; --model-tl: #9085e9;
  --good-text: #0ca30c; --critical-wash: rgba(208, 59, 59, 0.16); --warning-wash: rgba(250, 178, 25, 0.12); --good-wash: rgba(12, 163, 12, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text-primary); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 48px; color: var(--text-muted); }
.num, td.r, th.r { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.small { font-size: 12px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; flex: none; }
.s0 { background: var(--series-1); } .s1 { background: var(--series-2); } .s2 { background: var(--series-3); }
.m-hj { background: var(--model-hj); } .m-tl { background: var(--model-tl); }

/* ---------- Shell: sidebar trái + vùng nội dung ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--sidebar); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; font-weight: 650; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.nav-group { margin-top: 12px; padding: 0 8px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-secondary); text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.nav a.on { background: var(--accent-wash); color: var(--text-primary); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.nav .badge { margin-left: auto; background: var(--critical); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid var(--border); display: grid; gap: 8px; font-size: 12px; }
.side-foot .who { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
.side-foot .row { display: flex; gap: 6px; flex-wrap: wrap; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--page) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding: 14px 28px 12px; }
.topbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 650; margin: 0; margin-right: auto; }
.freshness { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.live-dot.mock { background: var(--warning); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--text-secondary); white-space: nowrap; display: inline-flex; align-items: center; }
.seg button:hover { color: var(--text-primary); }
.seg button.on { background: var(--text-primary); color: var(--surface-1); font-weight: 600; }
.range-label { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.menu-btn { display: none; }

.content { padding: 22px 28px 60px; display: grid; gap: 18px; max-width: 1480px; }

/* ---------- Card & grid ---------- */
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.src { font-size: 11px; color: var(--text-muted); border: 1px dashed var(--axis); border-radius: 6px; padding: 1px 6px; cursor: pointer; background: none; white-space: nowrap; }
.src:hover { color: var(--accent); border-color: var(--accent); }
.section-title { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin: 6px 0 -6px; }

/* Stat tiles */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
button.tile { text-align: left; cursor: pointer; }
button.tile:hover { border-color: var(--accent); }
.tile .lbl { font-size: 12px; color: var(--text-secondary); }
.tile .val { font-size: 24px; font-weight: 650; margin-top: 2px; letter-spacing: -0.01em; }
.tile .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.hero .val { font-size: 34px; }
.delta { font-weight: 600; }
.delta.up-good, .delta.down-good { color: var(--good-text); }
.delta.up-bad, .delta.down-bad { color: var(--critical); }

/* Alerts */
.alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.alert { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 1px solid var(--border); background: var(--surface-1); border-radius: 9px; padding: 10px 12px; cursor: pointer; }
.alert:hover { border-color: var(--accent); }
.alert .ic { font-weight: 700; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; font-size: 12px; }
.alert.critical .ic { background: var(--critical); color: #fff; }
.alert.warning .ic { background: var(--warning); color: #0b0b0b; }
.alert .n { font-weight: 700; font-size: 16px; margin-right: 4px; }
.alert .grp { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.alert .txt { font-size: 13px; color: var(--text-secondary); }

/* Status pills — luôn có chữ, không chỉ màu */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.pill.good { background: var(--good-wash); color: var(--good-text); }
.pill.warn { background: var(--warning-wash); color: var(--text-primary); }
.pill.bad { background: var(--critical-wash); color: var(--critical); }
.pill.info { background: var(--accent-wash); color: var(--text-primary); }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }
td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td .t2 { display: block; font-size: 12px; color: var(--text-muted); }
td .mono { white-space: nowrap; }
.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.empty { padding: 20px; text-align: center; color: var(--text-muted); }

.btn { border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); }
.input { border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 6px 10px; min-width: 0; }
.input:focus, .btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Bar list (ngang) */
.barlist { display: grid; gap: 8px; }
.barlist .it { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline; }
.barlist .it.click { cursor: pointer; border-radius: 6px; }
.barlist .it.click:hover .nm { color: var(--accent); }
.barlist .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.barlist .nm img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; flex: none; background: var(--surface-2); }
.barlist .nm .thumb.none { width: 26px; height: 26px; }

/* Ảnh sản phẩm + popup ảnh lớn */
.prod { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prod-t { min-width: 0; }
/* Dòng có ảnh sản phẩm: mọi ô căn giữa theo chiều dọc để thẳng hàng với ảnh + tên (ô top sẽ lệch so với ảnh) */
tr:has(.prod) > td { vertical-align: middle; }
.thumb { width: 36px; height: 36px; flex: none; border-radius: 6px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); cursor: zoom-in; display: inline-block; }
.thumb:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.thumb.none { cursor: default; outline: none; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(0,0,0,.78); padding: 24px; cursor: zoom-out; }
.lightbox.open { display: grid; }
.lightbox figure { margin: 0; display: grid; gap: 8px; justify-items: center; max-width: min(1100px, 96vw); }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; background: #fff; border-radius: 8px; min-width: 120px; min-height: 120px; }
.lightbox figcaption { color: #f2f2f2; font-size: 13px; text-align: center; max-width: 900px; }
.lightbox figcaption a { color: #9ec1ff; white-space: nowrap; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255,255,255,.12); }
.barlist .v { font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.barlist .track { grid-column: 1 / -1; height: 6px; display: flex; gap: 2px; }
.barlist .track span { height: 100%; border-radius: 0 3px 3px 0; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; }
.chart .cap { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: var(--text-primary); fill-opacity: .04; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14); opacity: 0; transition: opacity .1s; max-width: 280px; }
.tooltip.on { opacity: 1; }
.tooltip .tt-h { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-r { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }

/* Meter (điểm listing, chỉ số) */
.meter { height: 6px; border-radius: 3px; background: var(--accent-wash); overflow: hidden; min-width: 60px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }

/* Drawer phải cho xem chi tiết */
.drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.32); opacity: 0; transition: opacity .15s; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(920px, 100vw); background: var(--surface-1); transform: translateX(100%); transition: transform .18s ease; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-scrim { opacity: 1; }
.drawer.open .drawer-panel { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; margin-right: auto; }
.drawer-body { overflow-y: auto; padding: 16px 20px 40px; display: grid; gap: 16px; align-content: start; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { width: min(380px, 100%); display: grid; gap: 12px; }
.auth h1 { font-size: 20px; margin: 0 0 4px; }
.err { color: var(--critical); font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.note { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.callout { border-left: 3px solid var(--warning); background: var(--warning-wash); padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 13px; }
.callout.info { border-color: var(--accent); background: var(--accent-wash); }
.log { background: var(--surface-2); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

@media (max-width: 1100px) {
  .g3 { grid-template-columns: 1fr 1fr; }
  .g-7-5 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; width: 260px; transform: translateX(-100%); transition: transform .18s; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .side { transform: none; }
  .menu-btn { display: inline-block; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .range-label { margin-left: 0; width: 100%; }
  .seg { overflow-x: auto; max-width: 100%; }
}

/* Mã không còn trong Item Report: thông tin lấy từ lịch sử (rê chuột để xem nguồn) */
.gone { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--warning-wash); color: var(--text-primary); border: 1px solid var(--warning); white-space: nowrap; cursor: help; }
/* Cột sản phẩm (ảnh + tên) chiếm phần còn lại của bảng và tự cắt "…" thay vì làm tràn bảng */
td:has(> .prod) { width: 100%; max-width: 0; }
.prod-t { flex: 1; }
.prod-t .clip, .prod-t > span.clip { display: block; max-width: 100%; }
.cell-clip { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Loại: xuống dòng thay vì cắt, để không che nhãn ⚠ */
.type-c { display: inline-block; max-width: 150px; white-space: normal; line-height: 1.35; }

/* ================= Quy luật giao diện (xem docs/DESIGN-RULES.md) =================
   Thang mức độ dùng chung cho mọi chỗ cần lưu ý — luôn có chữ/ký hiệu, không chỉ màu:
   urgent (✕ khẩn, nền đỏ đặc) > critical (! đỏ nhạt) > warning (! vàng) > info (xanh) > neutral (xám) > good (✓ xanh lá) */
:root { --critical-strong: #b42323; --info-wash: var(--accent-wash); }
:root[data-theme="dark"] { --critical-strong: #c43c3c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --critical-strong: #c43c3c; } }

.grid { align-items: start; }

/* Pill: bậc mức độ */
.pill { font-weight: 600; }
.pill.urgent { background: var(--critical-strong); color: #fff; }
.pill.neutral { background: var(--surface-2); color: var(--text-secondary); font-weight: 500; }

/* Đếm ngược hạn ship: luôn 1 dòng, độ rộng đều nhau để cột thẳng hàng */
.countdown { min-width: 118px; justify-content: center; font-variant-numeric: tabular-nums; }
td.fit, th.fit { width: 1%; white-space: nowrap; }
td.num, td.r { white-space: nowrap; }

/* Hàng cảnh báo: nhãn nhóm bên trái + chip tô màu theo mức độ (giống bản gốc) */
.alert-rows { display: grid; gap: 8px; }
.ar { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: start; }
.ar-l { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding-top: 9px; }
.ar-chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chip { display: inline-flex; align-items: baseline; gap: 8px; max-width: 100%; min-height: 36px; padding: 7px 12px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; text-align: left; font-size: 13px; line-height: 1.35; }
.chip .n { font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; }
.chip .t { color: var(--text-primary); }
.chip .go { color: var(--text-muted); }
.chip:hover { border-color: currentColor; }
.chip.critical, .chip.urgent { background: var(--critical-wash); color: var(--critical); }
.chip.urgent { border-color: var(--critical); }
.chip.warning { background: var(--warning-wash); color: #8a5700; }
:root[data-theme="dark"] .chip.warning { color: var(--warning); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.warning { color: var(--warning); } }
.chip.info { background: var(--accent-wash); color: var(--accent); }

/* Tile có mức độ: viền trái + số tô màu, để thấy ngay ô cần chú ý */
.tile { min-height: 92px; position: relative; }
.tile.tone-bad { border-left: 3px solid var(--critical); }
.tile.tone-bad .val { color: var(--critical); }
.tile.tone-warn { border-left: 3px solid var(--warning); }
.tile.tone-good { border-left: 3px solid var(--good); }
.tile .val small { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }

/* Link sản phẩm sang walmart.com */
a.wm { color: inherit; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 2px; }
a.wm:hover { color: var(--accent); text-decoration-color: currentColor; }
a.wm .ext { font-size: 10px; color: var(--text-muted); margin-left: 3px; text-decoration: none; display: inline-block; }

/* Ô sức khoẻ bấm được */
td.health-cell { white-space: nowrap; }
td.health-cell.click { cursor: pointer; }
td.health-cell.click:hover { background: var(--surface-2); }
.metric-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; }
.metric-card.urgent { border-left: 3px solid var(--critical-strong); }
.metric-card.critical, .metric-card.warning { border-left: 3px solid var(--warning); }
.metric-card .mh { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.metric-card .mv { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Tiêu đề nhóm trong card (ví dụ "Đã ship trễ · 30 ngày") */
.sub-head { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--grid); }
.sub-head h3 { margin: 0; font-size: 14px; }
.legend-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }

/* HJ vs Tự list */
.mh-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mh-card { border: 1px solid var(--border); border-top: 4px solid var(--c); border-radius: 10px; padding: 14px 16px; display: grid; gap: 6px; }
.mh-card .big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mh-card .row { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-secondary); font-size: 13px; }
.share { display: grid; grid-template-columns: 170px minmax(0, 1fr) 190px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; }
.share .bar { display: flex; height: 18px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.share .bar i { display: grid; place-items: center; color: #fff; font-style: normal; font-size: 11px; font-weight: 600; min-width: 2px; }
.share .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); white-space: nowrap; }
td.better { font-weight: 750; color: var(--text-primary); }
td.better::after { content: ' ◆'; font-size: 9px; color: var(--good); vertical-align: 2px; }
@media (max-width: 820px) { .ar { grid-template-columns: 1fr; gap: 4px; } .ar-l { padding-top: 0; } .mh-two { grid-template-columns: 1fr; } .share { grid-template-columns: 1fr; gap: 4px; } .share .v { text-align: left; } }
/* Cột sản phẩm không bị ép quá hẹp khi bảng nhiều cột (tràn thì cuộn ngang) */
td:has(> .prod) { min-width: 220px; }

/* Cột xếp chồng nhiều card ngắn cạnh một card dài (quy tắc L4) */
.stack { display: grid; gap: 18px; align-content: start; min-width: 0; }

/* Mã bấm để chép */
.chep { cursor: copy; border-bottom: 1px dotted var(--axis); }
.chep:hover { color: var(--accent); }
[data-tap] { cursor: pointer; }

/* Dải tóm tắt ở Tổng quan: mỗi dải một hàng, trọn chiều ngang (như bản gốc) */
.strips { display: grid; gap: 8px; }
.strip { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; border: 1px dashed var(--axis); border-radius: 9px; padding: 9px 14px; cursor: pointer; background: var(--surface-1); }
.strip:hover { border-color: var(--accent); }
.strip .grp { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.strip .txt { font-size: 13px; color: var(--text-secondary); }

/* Đầu popup: ‹ Quay lại · tiêu đề + dòng phụ · Đóng (như bản gốc) */
.drawer-head { align-items: flex-start; }
.drawer-ttl { margin-right: auto; min-width: 0; }
.drawer-ttl h2 { margin: 0; font-size: 16px; }
.drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.drawer-sub:empty { display: none; }
.reason { display: grid; gap: 6px; border-top: 1px solid var(--grid); padding-top: 12px; }
.reason h3 { margin: 0; font-size: 14px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.reason-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Lưới ô số 2 cột trong card hẹp (tránh ô lẻ hàng, quy tắc L5) */
.tiles.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Hàng 5 ô bán hàng ở Tổng quan: luôn đủ 5 ô một hàng như bản gốc (màn hẹp thì xuống 2 cột) */
.tiles.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tiles.cols-5 .hero .val { font-size: 28px; }
@media (max-width: 1100px) { .tiles.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .tiles.cols-5 .hero { grid-column: 1 / -1; } }

/* Màu shop thứ 4, 5 theo thứ tự bảng màu dataviz (đã chạy validate_palette cho 5 màu, sáng + tối: đạt).
   Từ shop thứ 6: chấm xám — tên shop luôn hiện cạnh chấm nên vẫn phân biệt được. */
:root { --series-4: #eda100; --series-5: #e87ba4; --series-6: var(--text-muted); --series-7: var(--text-muted); --series-8: var(--text-muted); --series-9: var(--text-muted); --series-10: var(--text-muted); }
:root[data-theme="dark"] { --series-4: #c98500; --series-5: #d55181; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-4: #c98500; --series-5: #d55181; } }
.s3 { background: var(--series-4); } .s4 { background: var(--series-5); }
.s5, .s6, .s7, .s8, .s9 { background: var(--text-muted); }

/* Trang Kết nối shop */
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.form-grid .input { width: 100%; }
.danger { border-color: var(--critical) !important; color: var(--critical); }
.danger:hover { background: var(--critical-wash); }

/* Sản phẩm đăng bán */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cat-tools select.input { padding: 5px 8px; }
span.link { color: var(--accent); cursor: pointer; font-weight: 650; border-bottom: 1px dashed currentColor; }
span.link:hover { color: var(--text-primary); }
td.hl, th.hl { background: var(--accent-wash); }
.cat-tools { margin-bottom: 12px; }

/* Giải thích lý do Walmart gỡ / chặn mã */
button.pill-btn { cursor: pointer; border: 0; font: inherit; font-size: 12px; }
button.pill-btn:hover { filter: brightness(1.08); text-decoration: underline; }
.reason-box { border-left: 3px solid var(--critical); background: var(--critical-wash); border-radius: 0 8px 8px 0; padding: 10px 12px; }
.reason-box.warn { border-color: var(--warning); background: var(--warning-wash); }
.reason-box.neutral { border-color: var(--border); background: var(--surface-2); }
.reason-box .reason-t { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.reason-box p { margin: 8px 0 0; font-size: 13px; line-height: 1.6; }
blockquote.wm-reason { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 6px 6px 0; font-size: 13px; line-height: 1.55; font-style: italic; }
.h3 { font-size: 13px; margin: 0 0 6px; }
ol.steps, ul.steps { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.6; display: grid; gap: 4px; }
mark { background: var(--warning-wash); color: var(--text-primary); padding: 0 3px; border-radius: 3px; font-weight: 650; }

/* Chi tiết đơn: tem địa chỉ giao (điểm nhấn), tiến trình đơn */
.order-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.order-total { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.order-total .sec { font-size: 12px; font-weight: 400; }
.ship-label { border: 1.5px solid var(--text-primary); border-radius: 6px; padding: 12px 16px 14px; background: var(--surface-1); max-width: 460px; }
.ship-label .sl-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ship-label .sl-top .btn { margin-left: auto; }
.ship-label .sl-k { font-size: 12px; color: var(--text-muted); }
.ship-label .sl-name { font-size: 18px; font-weight: 750; line-height: 1.3; }
.ship-label .sl-line { font-size: 15px; line-height: 1.5; }
.order-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; counter-reset: st; }
.order-steps li { position: relative; padding: 18px 8px 0 0; font-size: 12px; color: var(--text-muted); border-top: 3px solid var(--border); }
.order-steps li::before { content: ''; position: absolute; top: -8px; left: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--surface-1); border: 3px solid var(--border); }
.order-steps li.done { border-top-color: var(--good); color: var(--text-secondary); }
.order-steps li.done::before { background: var(--good); border-color: var(--good); }
.order-steps li.bad { border-top-color: var(--critical); }
.order-steps li.bad::before { background: var(--critical); border-color: var(--critical); }
.order-steps b { display: block; font-size: 13px; color: var(--text-primary); }
@media (max-width: 560px) { .order-steps { grid-template-columns: 1fr; } .order-steps li { border-top: 0; border-left: 3px solid var(--border); padding: 0 0 12px 16px; } .order-steps li::before { top: 0; left: -8px; } .order-steps li.done { border-left-color: var(--good); } .order-steps li.bad { border-left-color: var(--critical); } }
.ship-label { max-width: min(460px, 100%); box-sizing: border-box; overflow-wrap: anywhere; }
.drawer-body .kv dd { min-width: 0; overflow-wrap: anywhere; }
.drawer-body .kv .chep { overflow-wrap: anywhere; }
/* Cột "Phân loại" khách đã chọn (chi tiết đơn) */
.variant-v { font-weight: 650; white-space: nowrap; }
.drawer-body { grid-template-columns: minmax(0, 1fr); } /* không cho bảng rộng kéo giãn cả cửa sổ; bảng tự cuộn ngang trong khung của nó */

/* Tình trạng mã dưới tên sản phẩm: chấm màu + chữ nhỏ (đỏ = đã xoá khỏi Walmart, vàng = mã mới web chưa cập nhật) */
.gone-tag { display: flex; align-items: center; gap: 6px; cursor: help; color: var(--text-secondary); }
.gone-tag::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.gone-tag.del::before { background: var(--critical); }

/* Form tạo tài khoản: ô nhập không tràn khung khi màn hẹp */
#new-user { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#new-user .input { max-width: 100%; min-width: 0; }
#new-user .err { color: var(--critical); font-size: 12px; }
