/* Mau theo quy uoc so do cua Mar: navy = nen tang quang cao, rust = CRM Preny, green = bao cao */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sunk: #eaeef4;
  --ink: #16213a;
  --muted: #586379;
  --line: #d9dfe9;
  --navy: #1f3a63;
  --navy-soft: #e3eaf5;
  --rust: #9b3a1c;
  --green: #11684f;
  --good: #1b7a49;
  --good-bg: #dff3e7;
  --warn: #8a5508;
  --warn-bg: #fbefd8;
  --bad: #b73225;
  --bad-bg: #f9e0dc;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
/* Giao dien toi: khi chon "Toi" (data-theme="dark"), hoac "Theo may" (khong co data-theme) va may dang toi. Hai khoi phai giong nhau. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1420; --surface: #161e2e; --sunk: #1c2639; --ink: #e6ebf4; --muted: #9ba6bb; --line: #2a3650;
    --navy: #8fb2e6; --navy-soft: #1d2b45; --rust: #ec9a78; --green: #6fd0b0;
    --good: #5fd497; --good-bg: #153424; --warn: #e9b65a; --warn-bg: #3a2c12; --bad: #f2877b; --bad-bg: #3d1d1a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1420; --surface: #161e2e; --sunk: #1c2639; --ink: #e6ebf4; --muted: #9ba6bb; --line: #2a3650;
  --navy: #8fb2e6; --navy-soft: #1d2b45; --rust: #ec9a78; --green: #6fd0b0;
  --good: #5fd497; --good-bg: #153424; --warn: #e9b65a; --warn-bg: #3a2c12; --bad: #f2877b; --bad-bg: #3d1d1a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14.5px; line-height: 1.55; }
a { color: var(--navy); }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page { display: flex; flex-direction: column; gap: 16px; padding-block: 24px 56px; }
.page-head { display: flex; flex-direction: column; gap: 4px; }
/* Noi dung gian het be ngang, nhung dong chu mo ta khong qua dai de de doc */
.page-head p, p.muted { max-width: 120ch; }

/* khung trang: menu ben trai + noi dung. Body van la vung cuon (help.js dinh vi theo window.scrollY) */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px 12px max(12px, env(safe-area-inset-left, 0px)); }
.side-head { padding: 0 10px 10px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--rust); }
.brand.big { font-size: 1.35rem; }
.side-toggle { display: none; }
.side-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; min-height: 0; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-group { margin: 14px 0 4px; padding: 0 10px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links:first-child .side-group { margin-top: 6px; }
main:focus { outline: none; }
.side-nav a, .side-me a { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px 10px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.9rem; }
.side-nav a:hover, .side-me a:hover { color: var(--ink); background: color-mix(in srgb, var(--sunk) 55%, transparent); }
.side-nav a.on, .side-me a.on { background: var(--sunk); color: var(--ink); font-weight: 600; }
.side-nav a.on .ico, .side-me a.on .ico { color: var(--rust); }
.ico { flex: none; }
.side-me { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-me a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me form { margin: 0; }
.theme-switch { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin-bottom: 8px; padding: 3px; background: var(--sunk); border-radius: 8px; }
/* Chi hien khi co JS (lop "js" gan o <head>), khong cho nav.js chay xong moi hien */
html:not(.js) .theme-switch { display: none; }
.theme-switch button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 5px 2px 4px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 0.72rem; font-weight: 500; line-height: 1.2; cursor: pointer; }
.theme-switch button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(10, 20, 40, 0.18); }
.side-me button.link { padding: 5px 10px 5px 36px; font-size: 0.84rem; text-align: left; }
.content { min-width: 0; display: flex; flex-direction: column; }
.content .wrap { max-width: none; margin: 0; padding-left: 28px; padding-right: max(28px, env(safe-area-inset-right, 0px)); }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px 10px; }
button.link:hover { color: var(--ink); }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { z-index: 30; height: auto; overflow: visible; padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); border-right: 0; border-bottom: 1px solid var(--line); }
  .side-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
  .side-toggle { display: inline-flex; align-items: center; gap: 8px; max-width: 60%; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--sunk); color: var(--ink); font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer; }
  .side-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-body { display: none; max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow-y: auto; padding: 4px 0 6px; }
  .sidebar.open .side-body { display: flex; }
  .content .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}
.banner-mock { background: var(--warn-bg); color: var(--warn); font-size: 0.85rem; padding-block: 8px; border-bottom: 1px solid var(--line); }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; font-size: 0.9rem; }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.card .pad, .card-head.pad { padding: 14px 18px; }
.card.narrow { max-width: 480px; }
.card.empty { align-items: flex-start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; margin-right: 6px; }
.pill { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-decoration: none; font-size: 0.85rem; }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.field.stack { gap: 4px; }
input, select { font: inherit; font-size: 0.9rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.btn { font: inherit; font-size: 0.88rem; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.9; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.wrap-row { flex-wrap: wrap; }
.inline { display: flex; gap: 6px; align-items: center; margin: 0; flex-wrap: wrap; }
.inline input { width: 150px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.sync-form { display: flex; flex-direction: column; gap: 10px; }
.radio { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .l { font-size: 0.78rem; color: var(--muted); }
.kpi .v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi .s { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* chart */
/* Cao theo be ngang de man rat rong bieu do khong det */
.chart-box { position: relative; height: clamp(280px, 16vw, 420px); }
.legend { display: flex; gap: 6px 14px; align-items: center; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.sw.spend { background: var(--navy); }
.sw.msg { background: var(--rust); border-radius: 50%; }

/* tables */
/* Bang dai cuon doc + ngang ngay trong khung, ghim hang tieu de, cot dau va dong tong (nhu bang thong ke cua Preny) */
.tbl-wrap { overflow: auto; max-height: min(72vh, 680px); }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
/* O ghim can vien di cung o: collapse lam vien o ghim troi mat khi cuon */
.tbl-wrap table { border-collapse: separate; border-spacing: 0; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; background: var(--sunk); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
/* Nen dac (tron voi --surface) de o ghim khong lo chu cuon ben duoi */
tbody tr:hover td { background: color-mix(in srgb, var(--sunk) 50%, var(--surface)); }
.tbl-wrap thead th { position: sticky; top: 0; z-index: 2; }
.tbl-wrap :is(th, td):first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
/* :where = do uu tien 0, de nen cua dong tong / dong to dam / hover van de len */
:where(.tbl-wrap td:first-child) { background: var(--surface); }
.tbl-wrap thead th:first-child { z-index: 3; }
.tbl-wrap tr.total td { position: sticky; bottom: 0; z-index: 2; }
.tbl-wrap tr.total td:first-child { z-index: 3; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { min-width: 240px; }
/* Man hep: cot dau ghim hep lai, ten dai xuong dong */
@media (max-width: 600px) { td.name { min-width: 140px; } }
.sub { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 400; }
tr.dim td { opacity: 0.6; }
/* O ghim mo bang opacity thi lo chu cuon ben duoi: lam mo bang mau chu */
.tbl-wrap tr.dim td:first-child { opacity: 1; color: color-mix(in srgb, var(--ink) 60%, var(--surface)); }

/* tabs, chips */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tabs a.on { color: var(--ink); border-bottom: 2px solid var(--ink); margin-bottom: -1px; }
/* Tab ben trai, o tim ben phai, chung mot duong ke duoi */
.tabs-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; border-bottom: 1px solid var(--line); }
.tabs-row .tabs { border-bottom: 0; }
.tbl-search { display: flex; align-items: center; gap: 6px; padding-bottom: 6px; }
.tbl-search input[type="search"] { width: 280px; }
@media (max-width: 600px) { .tbl-search { width: 100%; } .tbl-search input[type="search"] { flex: 1; width: auto; } }
.chip { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--navy-soft); color: var(--navy); }

/* facts, details */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
details summary { cursor: pointer; color: var(--navy); font-size: 0.82rem; }
ul.details { margin: 6px 0 0; padding-left: 1.1em; font-size: 0.8rem; display: flex; flex-direction: column; gap: 2px; }
ul.details li.bad { color: var(--bad); }
ul.details li.warn { color: var(--warn); }

/* settings, leads */
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings { display: flex; flex-direction: column; gap: 16px; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
textarea { font: inherit; font-size: 0.88rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; resize: vertical; min-width: 0; width: 100%; }
textarea:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
.grid-2.tight { align-items: start; }
tr.hl td { background: var(--navy-soft); }
tr.sep td { background: var(--sunk); padding-block: 4px; }
.kpi.accent { border-color: var(--navy); }

/* cost, coverage */
.note-warn { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: 0.85rem; }
.kpi.alert { border-color: var(--warn); background: var(--warn-bg); }
.kpi.alert .v { color: var(--warn); }
.chip.neutral { background: var(--sunk); color: var(--muted); }
.bench { position: relative; width: 110px; height: 10px; background: var(--sunk); border-radius: 3px; display: inline-block; vertical-align: middle; }
.bench i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.bench::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0.55; }
.meter { width: 90px; height: 8px; background: var(--sunk); border-radius: 3px; display: inline-block; vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; }
.warn-text { color: var(--warn); }

.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mini-kpis > div { display: flex; flex-direction: column; gap: 2px; }
.mini-kpis .l { font-size: 0.78rem; color: var(--muted); }
.mini-kpis b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* chon tag o trang Cai dat */
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.tag-field .tag-label { font-size: 0.78rem; color: var(--muted); }
.tchip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; font-size: 0.76rem; line-height: 1.4; padding: 2px 4px 2px 8px; border-radius: 999px; background: var(--navy-soft); color: var(--ink); border: 1px solid transparent; }
.tchip-name { overflow-wrap: anywhere; }
.tchip .n { font-size: 0.7rem; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tchip.unknown { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.tchip.unknown .n { color: var(--bad); }
.tchip.deleted, .tchip.inactive { background: var(--warn-bg); color: var(--warn); }
.tchip-x { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin: -4px -4px -4px -6px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; font: inherit; font-size: 0.95rem; line-height: 1; opacity: 0.65; cursor: pointer; }
.tchip-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 16%, transparent); }

/* o chon tag dang dropdown: hop chip + o tim + danh sach tich chon */
.tsel { position: relative; }
.tsel-box { display: flex; align-items: flex-start; gap: 4px; min-height: 40px; padding: 6px 4px 6px 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; }
.tsel-box:hover { border-color: color-mix(in srgb, var(--navy) 50%, var(--line)); }
.tsel.open .tsel-box { border-color: var(--navy); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 18%, transparent); }
fieldset:disabled .tsel-box { cursor: default; border-color: var(--line); }
.tsel-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.tsel-ph { font-size: 0.84rem; color: var(--muted); padding: 1px 2px; }
.tsel-toggle { flex: none; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.tsel-toggle svg { transition: transform 0.15s; }
.tsel.open .tsel-toggle svg { transform: rotate(180deg); }
.tsel-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: max(100%, 340px); max-width: calc(100vw - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 36px rgba(10, 20, 40, 0.24); overflow: hidden; }
.tsel-pop.right { left: auto; right: 0; }
.tsel-pop.up { top: auto; bottom: calc(100% + 6px); }
.tsel-pop[hidden] { display: none; }
.tsel-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); }
.tsel-search input { flex: 1; border: 0; border-radius: 0; padding: 4px 0; background: none; font-size: 0.88rem; }
.tsel-search input:focus-visible { outline: none; }
.tsel-list { list-style: none; margin: 0; padding: 4px; max-height: 288px; overflow-y: auto; overscroll-behavior: contain; }
.tsel-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; font-size: 0.86rem; cursor: pointer; }
.tsel-opt:hover, .tsel-opt.active { background: var(--sunk); }
.tsel-opt.active { box-shadow: inset 2px 0 0 var(--navy); }
.tsel-opt[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
.tsel-check { flex: none; display: grid; place-items: center; width: 16px; height: 16px; border: 1.5px solid var(--muted); border-radius: 4px; }
.tsel-opt[aria-selected="true"] .tsel-check { background: var(--navy); border-color: var(--navy); }
.tsel-opt[aria-selected="true"] .tsel-check::after { content: ""; width: 4px; height: 8px; margin-top: -2px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tsel-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tsel-n { flex: none; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tsel-flag { flex: none; font-size: 0.72rem; }
.tsel-flag.bad { color: var(--bad); }
.tsel-flag.warn { color: var(--warn); }
.tsel-where { flex: none; font-size: 0.7rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); white-space: nowrap; }
.tsel-where.info { background: var(--sunk); color: var(--muted); }
.tsel-more { margin: 0; padding: 4px 8px 10px; font-size: 0.78rem; color: var(--muted); text-align: center; }
.tsel-more[hidden], .tsel-note[hidden] { display: none; }
.tsel-note { margin: 0; padding: 8px 12px; font-size: 0.8rem; background: var(--navy-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.tsel-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; border-top: 1px solid var(--line); }
.tsel-clear { padding: 4px 0; border: 0; background: none; color: var(--navy); font: inherit; font-size: 0.84rem; cursor: pointer; }
.tsel-clear:hover { text-decoration: underline; }
@media (max-width: 600px) { .tsel-pop { width: 100%; max-width: none; } }
.add-buttons { display: flex; flex-wrap: wrap; gap: 4px; }
label.radio.small { font-size: 0.8rem; color: var(--muted); }

/* login */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; gap: 14px; }

/* Moc 1192px = 960px noi dung + 232px sidebar (sidebar thu thanh thanh tren cung khi <= 900px) */
@media (max-width: 1192px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Huong dan + nut "?" (tuan 5) ---------- */
.help { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; border-radius: 50%; border: 1px solid var(--line); background: var(--sunk); color: var(--muted); font-size: 0.68rem; font-weight: 700; line-height: 1; text-decoration: none; vertical-align: 1px; cursor: help; text-transform: none; letter-spacing: 0; }
.help:hover, .help:focus-visible, .help[aria-expanded="true"] { color: var(--surface); background: var(--navy); border-color: var(--navy); }
.help.static { cursor: default; }
button.help { padding: 0; font-family: inherit; }
h1 .help { margin-left: 8px; vertical-align: 3px; }
.help-pop { position: absolute; z-index: 50; width: min(340px, calc(100vw - 16px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(10, 20, 40, 0.18); padding: 12px 14px; font-size: 0.86rem; font-weight: 400; text-align: left; white-space: normal; text-transform: none; letter-spacing: 0; }
.help-pop p { margin: 6px 0 0; }
.help-pop p:first-child { margin-top: 0; }
.help-pop a { display: inline-block; margin-top: 8px; }
.guide-formula { background: var(--sunk); border-radius: 6px; padding: 6px 9px; font-size: 0.9em; }
.guide-formula span { font-weight: 600; color: var(--green); margin-right: 4px; }
.guide { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.guide-toc { position: sticky; top: 12px; gap: 10px; }
.guide-toc ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.guide-toc input { width: 100%; }
.guide-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.guide-list { margin: 0; display: flex; flex-direction: column; }
.guide-entry { padding: 10px 0; border-top: 1px solid var(--line); scroll-margin-top: 12px; }
.guide-entry:first-child { border-top: 0; }
.guide-entry.on { background: var(--navy-soft); margin-inline: -18px; padding-inline: 18px; }
.guide-entry dt { font-weight: 700; }
.guide-entry dd { margin: 4px 0 0; }
.guide-entry dd p { margin: 4px 0 0; }
.guide-pages a { margin-left: 2px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 12px; border-radius: 6px; background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* 760px noi dung: man hep, hoac 901-992px khi con sidebar 232px */
@media (max-width: 760px), (min-width: 901px) and (max-width: 992px) {
  .guide { grid-template-columns: minmax(0, 1fr); }
  .guide-toc { position: static; }
}
/* Man hep: thanh menu dinh o tren (cao ~52px) khong duoc che dich cua link neo va muc luc dinh */
@media (max-width: 900px) {
  html { scroll-padding-top: 64px; }
  .guide-toc { top: 64px; }
}
.guide-section[hidden], .guide-entry[hidden] { display: none; }

/* Dong tong cuoi bang */
tr.total td { font-weight: 700; background: var(--sunk); border-top: 2px solid var(--line); }
tr.total td .sub { font-weight: 400; }
