:root {
  --paper: #EFF2F0;
  --surface: #FFFFFF;
  --surface-2: #F6F8F7;
  --ink: #1C2A2E;
  --ink-2: #4A5A5E;
  --ink-3: #78878A;
  --line: #D6DEDA;
  --line-2: #E6ECE9;
  --olive: #4E6427;
  --olive-hover: #3F521F;
  --on-olive: #FFFFFF;
  --olive-tint: #E5ECD6;
  --pass: #2D7647;
  --pass-tint: #DDEFE3;
  --warn: #9C6210;
  --warn-tint: #F7EAD2;
  --bad: #AE3838;
  --bad-tint: #F6DEDE;
  --c-nen: #3A5874;
  --c-cjm: #7A8C35;
  --c-canhan: #D09630;
  --c-chung: #3A8880;
  --c-s5c: #8A69A2;
  --c-tt: #C05A54;
  --shadow: 0 1px 0 rgba(28, 42, 46, .04), 0 6px 24px rgba(28, 42, 46, .06);
  --r-sm: 6px;
  --r-md: 10px;
  --font: 'Be Vietnam Pro', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111819; --surface: #182224; --surface-2: #1D2829; --ink: #E4EBE8; --ink-2: #AFBCB8; --ink-3: #7E8C89;
    --line: #2D3B3D; --line-2: #233032; --olive: #A9BF6E; --olive-hover: #BCD083; --on-olive: #172005; --olive-tint: #2A3420;
    --pass: #6CC08A; --pass-tint: #1E3527; --warn: #E2AE57; --warn-tint: #3A2E18; --bad: #EA8484; --bad-tint: #3D2222;
    --c-nen: #6E97BC; --c-cjm: #A6B95A; --c-canhan: #E5B455; --c-chung: #5DB6AC; --c-s5c: #B593CF; --c-tt: #E58A83;
    --shadow: 0 1px 0 rgba(0,0,0,.2), 0 8px 28px rgba(0,0,0,.28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111819; --surface: #182224; --surface-2: #1D2829; --ink: #E4EBE8; --ink-2: #AFBCB8; --ink-3: #7E8C89;
  --line: #2D3B3D; --line-2: #233032; --olive: #A9BF6E; --olive-hover: #BCD083; --on-olive: #172005; --olive-tint: #2A3420;
  --pass: #6CC08A; --pass-tint: #1E3527; --warn: #E2AE57; --warn-tint: #3A2E18; --bad: #EA8484; --bad-tint: #3D2222;
  --c-nen: #6E97BC; --c-cjm: #A6B95A; --c-canhan: #E5B455; --c-chung: #5DB6AC; --c-s5c: #B593CF; --c-tt: #E58A83;
  --shadow: 0 1px 0 rgba(0,0,0,.2), 0 8px 28px rgba(0,0,0,.28);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; min-height: 100%; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 14.5px; line-height: 1.5; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: env(safe-area-inset-top, 0px); height: calc(100vh - env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 4px; padding: 22px 14px 16px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand svg { flex: none; }
.brand b { display: block; font-size: 19px; letter-spacing: .14em; font-weight: 700; line-height: 1.1; }
.brand small { display: block; color: var(--ink-3); font-size: 12px; letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  all: unset; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; position: relative;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--olive-tint); color: var(--ink); font-weight: 600; }
.nav button[aria-current="page"]::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--olive); }
.nav button:focus-visible { outline: 2px solid var(--olive); }
.nav .count { font-size: 11.5px; font-weight: 600; min-width: 20px; text-align: center; padding: 0 6px; border-radius: 10px; background: var(--warn-tint); color: var(--warn); }
.rail-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-3); display: grid; gap: 6px; }
.rail-foot .who { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.rail-foot .who img { width: 22px; height: 22px; border-radius: 50%; }
.theme-btn { all: unset; cursor: pointer; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px; width: max-content; }

.main { min-width: 0; padding: 22px clamp(14px, 3vw, 36px) 64px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.topbar .sub { color: var(--ink-3); margin: 4px 0 0; font-size: 13.5px; }
.period-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-ctl label { font-size: 12.5px; color: var(--ink-3); }
.banner { border: 1px solid var(--line); background: var(--surface); border-left: 4px solid var(--warn); border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 16px; color: var(--ink-2); font-size: 13.5px; }
.banner.info { border-left-color: var(--olive); }

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-sm);
  padding: 7px 13px; font-weight: 500; font-size: 13.5px; line-height: 1.3;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--olive); border-color: var(--olive); color: var(--on-olive); font-weight: 600; }
.btn.primary:hover { background: var(--olive-hover); border-color: var(--olive-hover); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.select, .field input, .field select, .field textarea, .inp {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 7px 10px; min-width: 0; width: 100%;
}
.select { width: auto; padding-right: 28px; }
.field input:focus, .field select:focus, .field textarea:focus, .inp:focus, .select:focus { outline: 2px solid var(--olive); outline-offset: -1px; border-color: transparent; }
.inp.num { text-align: right; }
.inp[readonly], .field input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.field { display: grid; gap: 4px; align-content: start; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { all: unset; cursor: pointer; white-space: nowrap; padding: 5px 0; width: 34px; text-align: center; font-weight: 600; font-size: 13px; border-right: 1px solid var(--line); color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--olive); color: var(--on-olive); }
.seg button:focus-visible { outline: 2px solid var(--olive); outline-offset: -2px; }
.toggle { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.toggle i { width: 30px; height: 18px; border-radius: 10px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.toggle i::after { content: ''; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: left .15s; }
.toggle[aria-pressed="true"] i { background: var(--olive); }
.toggle[aria-pressed="true"] i::after { left: 14px; }
.toggle:focus-visible { outline: 2px solid var(--olive); outline-offset: 2px; border-radius: 4px; }

/* ---------- surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px; }
.panel + .panel, .section + .section { margin-top: 18px; }
.panel h2, .section h2 { margin: 0 0 4px; font-size: 16.5px; font-weight: 600; letter-spacing: -.005em; }
.panel h3 { margin: 16px 0 8px; font-size: 14px; font-weight: 600; }
.panel .lead, .section .lead { margin: 0 0 14px; color: var(--ink-3); font-size: 13px; max-width: 72ch; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head .lead { margin-bottom: 0; }
.cols { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
.cols > * + *, .cols > .panel + .panel { margin-top: 0; }
.cols + .panel, .panel + .cols, .facts + .cols, .cols + .cols { margin-top: 18px; }
.topbar .tb-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface); }
.empty p { margin: 0 0 12px; }

/* ---------- facts strip */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.fact { padding: 12px 16px; border-right: 1px solid var(--line-2); }
.fact:last-child { border-right: 0; }
.fact > span { display: block; font-size: 12.5px; color: var(--ink-3); }
.fact > b { display: block; font-size: 19px; font-weight: 600; margin-top: 2px; }
.fact em { font-style: normal; font-size: 12px; color: var(--ink-3); }

/* ---------- revenue ruler (signature element) */
.ruler-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px 14px; margin-bottom: 18px; }
.ruler-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.ruler-head .rev { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.ruler-head .rev small { font-size: 14px; font-weight: 500; color: var(--ink-3); margin-left: 6px; letter-spacing: 0; }
.ruler-svg { width: 100%; height: auto; display: block; margin-top: 10px; overflow: visible; }
.ruler-svg text { font-family: var(--font); fill: var(--ink-3); font-size: 11px; }
.ruler-svg .lbl { fill: var(--ink-2); font-weight: 600; font-size: 11.5px; }
.ruler-svg .trk-name { fill: var(--ink-2); font-weight: 500; font-size: 11.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin-top: 14px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.kpi { padding: 0 12px; border-left: 1px solid var(--line-2); }
.kpi:first-child { border-left: 0; padding-left: 0; }
.kpi span { font-size: 12px; color: var(--ink-3); display: block; }
.kpi b { font-size: 16px; font-weight: 600; }
.kpi i { font-style: normal; font-size: 12px; color: var(--ink-3); margin-left: 4px; }
.meter { height: 4px; border-radius: 2px; background: var(--line-2); margin-top: 6px; overflow: hidden; }
.meter > div { height: 100%; background: var(--olive); }

/* ---------- tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl td.nm { white-space: nowrap; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); background: var(--surface-2); }
.tbl .grp td { background: var(--surface-2); font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 6px 12px; }
.name-cell b { font-weight: 600; display: block; }
.name-cell span { font-size: 12px; color: var(--ink-3); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.chip.pass { background: var(--pass-tint); color: var(--pass); }
.chip.check, .chip.pending { background: var(--warn-tint); color: var(--warn); }
.chip.bad { background: var(--bad-tint); color: var(--bad); }
.chip.neutral { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }
.chip.lock { background: var(--ink); color: var(--paper); }
.lvl { display: inline-block; min-width: 30px; text-align: center; font-weight: 700; font-size: 12.5px; border-radius: 4px; padding: 1px 6px; background: var(--olive-tint); color: var(--ink); }
.lvl.N0 { background: var(--bad-tint); color: var(--bad); }
.lvl.off { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.ruler-scroll { overflow-x: auto; }

/* 6-component bar */
.cbar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--line-2); min-width: 120px; position: relative; }
.cbar > i { display: block; height: 100%; }
.cbar > i + i { box-shadow: inset 1px 0 0 var(--surface); }
.cbar .neg { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(135deg, var(--c-tt) 0 3px, transparent 3px 6px); opacity: .9; }
.c-nen { background: var(--c-nen); } .c-cjm { background: var(--c-cjm); } .c-canhan { background: var(--c-canhan); }
.c-chung { background: var(--c-chung); } .c-s5c { background: var(--c-s5c); } .c-thanhtich { background: var(--c-tt); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.comp-sums { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin-top: 14px; }
.comp-sums div { padding: 0 10px; border-left: 3px solid; }
.comp-sums span { display: block; font-size: 12px; color: var(--ink-3); }
.comp-sums b { font-size: 14.5px; font-weight: 600; }

/* ---------- CJM journey */
.journey { display: flex; align-items: center; gap: 0; flex-wrap: nowrap; }
.journey .node { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 52px; }
.journey .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-3); }
.journey .node.ok .dot { background: var(--pass); border-color: var(--pass); color: var(--surface); }
.journey .node.keep .dot { background: var(--surface); border-color: var(--pass); color: var(--pass); }
.journey .node.no .dot { border-color: var(--bad); color: var(--bad); }
.journey .node.req .dot { box-shadow: 0 0 0 3px var(--olive-tint); }
.journey .node small { font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.journey .link { flex: 1; height: 2px; background: var(--line); min-width: 10px; margin-bottom: 18px; }
.journey.mini .node { min-width: 0; }
.journey.mini .dot { width: 12px; height: 12px; border-width: 2px; font-size: 0; }
.journey.mini .link { min-width: 6px; width: 8px; flex: none; margin-bottom: 0; }

/* ---------- inputs view */
.split { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; align-items: start; }
.roster { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); }
.roster h4 { margin: 0; padding: 8px 12px; font-size: 12px; color: var(--ink-3); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; align-items: center; }
.roster button.who { all: unset; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; box-sizing: border-box; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.roster button.who:hover { background: var(--surface-2); }
.roster button.who[aria-current="true"] { background: var(--olive-tint); }
.roster button.who:focus-visible { outline: 2px solid var(--olive); outline-offset: -2px; }
.roster .st { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.roster .st.saved { background: var(--pass); } .roster .st.check { background: var(--warn); }
.form-area { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.steps-tbl td:first-child { min-width: 110px; }
details.desc { margin-top: 10px; font-size: 13px; color: var(--ink-2); }
details.desc summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
details.desc dl { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; }
details.desc dt { font-weight: 600; }
details.desc dd { margin: 0; }
.save-bar .tot { font-weight: 700; font-size: 15px; margin-right: 6px; }
.preview { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); }
.preview .total { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0 10px; }
.preview dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13.5px; }
.preview dt { color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.preview dt i { width: 9px; height: 9px; border-radius: 2px; }
.preview dd { margin: 0; text-align: right; font-weight: 600; }
.preview .kpiline { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-top: 1px solid var(--line-2); }
.preview .issues { margin-top: 12px; font-size: 12.5px; }
.preview .issues li { margin-bottom: 3px; }
.steps-tbl td, .steps-tbl th { padding: 7px 8px; }
.steps-tbl .inp { width: 74px; padding: 5px 7px; }
.steps-tbl .inp.w { width: 64px; }
.level-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.level-row .need { display: inline-flex; gap: 4px; align-items: center; }
.save-bar { display: flex; justify-content: flex-end; gap: 8px; align-items: center; position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); margin-top: 16px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); }
.save-bar .msg { margin-right: auto; font-size: 13px; color: var(--ink-3); }
.save-bar .msg.dirty { color: var(--warn); font-weight: 600; }
.score-row { display: grid; grid-template-columns: minmax(140px, 1fr) auto 70px; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.score-row:last-child { border-bottom: 0; }
.score-row .k { text-align: right; font-weight: 600; font-size: 13px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.rv-grid .cell { border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px; display: grid; gap: 6px; }
.rv-grid .cell b { font-size: 12.5px; }
.rv-grid label { display: grid; grid-template-columns: 1fr 60px; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }

/* ---------- drawer & modal */
.scrim { position: fixed; inset: 0; background: rgba(15, 22, 24, .42); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(760px, 100%); height: 100%; background: var(--paper); overflow-y: auto; padding: calc(env(safe-area-inset-top, 0px) + 20px) 24px calc(env(safe-area-inset-bottom, 0px) + 28px); box-shadow: var(--shadow); animation: slidein .22s ease-out; }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.drawer-head h2 { margin: 0; font-size: 21px; }
.modal-scrim { position: fixed; inset: 0; background: rgba(15, 22, 24, .45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { width: min(460px, 100%); background: var(--surface); border-radius: var(--r-md); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toasts { position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 80; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: var(--r-sm); font-size: 13.5px; box-shadow: var(--shadow); max-width: 340px; }
.toast.err { background: var(--bad); color: #fff; }

/* ---------- payslip */
.slip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px 22px; }
.slip-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin: 14px 0 18px; padding: 12px 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.slip-meta span { display: block; font-size: 12px; color: var(--ink-3); }
.slip-meta b { font-weight: 600; }
.slip .grand { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 4px; border-top: 2px solid var(--ink); margin-top: 6px; }
.slip .grand b { font-size: 24px; letter-spacing: -.02em; }
.why { font-size: 12.5px; color: var(--ink-3); }
.dot-c { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 7px; vertical-align: 0; }

/* ---------- charts */
.chart { max-width: 760px; display: block; }
.chart text { font-family: var(--font); fill: var(--ink-3); font-size: 11px; }
.chart .axis { stroke: var(--line); }
.chart .grid { stroke: var(--line-2); }
.chart .bar { fill: var(--c-nen); }
.chart .ref { stroke: var(--olive); stroke-dasharray: 4 4; }
.chart .line { fill: none; stroke: var(--olive); stroke-width: 2; }
.chart .line2 { fill: none; stroke: var(--c-canhan); stroke-width: 2; }
.chart .pt { fill: var(--surface); stroke: var(--olive); stroke-width: 2; }
.chart .now { fill: var(--c-tt); }

.tests td.ok { color: var(--pass); font-weight: 600; } .tests td.ko { color: var(--bad); font-weight: 600; }
.ref-tbl td { vertical-align: top; font-size: 13px; }
.matrix button { all: unset; cursor: pointer; width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; }
.matrix button[aria-pressed="true"] { background: var(--olive); border-color: var(--olive); color: var(--on-olive); }
.matrix button:disabled { cursor: default; }
.matrix button:focus-visible { outline: 2px solid var(--olive); }
.range-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 110px; align-items: center; gap: 12px; padding: 6px 0; }
.range-row input[type=range] { width: 100%; accent-color: var(--olive); }
.range-row b { text-align: right; }
.delta-up { color: var(--pass); } .delta-down { color: var(--bad); }
.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }

/* ---------- responsive */
@media (max-width: 1480px) {
  .form-area { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; order: -1; }
  .preview .pv { display: grid; grid-template-columns: minmax(170px, 0.8fr) minmax(0, 1fr) minmax(0, 1fr); gap: 4px 28px; align-items: start; }
  .preview .pv .pv-kpi { margin-top: 0 !important; }
  .preview .pv .issues, .preview .pv .ok { grid-column: 1 / -1; }
}
@media (max-width: 1200px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .roster { position: static; display: flex; flex-wrap: wrap; }
  .roster h4 { flex-basis: 100%; }
  .roster button.who { width: auto; flex: 1 1 170px; border-right: 1px solid var(--line-2); }
}
@media (max-width: 700px) {
  .preview .pv { grid-template-columns: minmax(0, 1fr); }
  .ruler-svg { min-width: 620px; }
  .ruler-head .right { text-align: left; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px; margin-top: calc(-1 * env(safe-area-inset-top, 0px)); border-right: 0; border-bottom: 1px solid var(--line); z-index: 20; overflow-x: auto; }
  .brand { padding: 0 6px 0 2px; }
  .brand small, .rail-foot { display: none; }
  .nav { flex-direction: row; }
  .nav button { white-space: nowrap; padding: 7px 10px; }
  .nav button[aria-current="page"]::before { display: none; }
  .roster { max-height: 280px; overflow-y: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 0; }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 0; }
  .comp-sums { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 0; }
  .rv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .range-row { grid-template-columns: 1fr 90px; }
  .range-row input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  .topbar h1 { font-size: 22px; }
  .drawer { padding-left: 14px; padding-right: 14px; }
}

/* ---------- đăng nhập (bản tự host) */
body.login-mode .shell { grid-template-columns: minmax(0, 1fr); }
body.login-mode .rail { display: none; }
.login-wrap { min-height: calc(100vh - 140px); display: grid; place-items: center; }
.login { width: min(380px, 100%); display: grid; gap: 14px; padding: 26px 26px 22px; box-shadow: var(--shadow); }
.login .brand b { font-size: 21px; }
.rail-foot .theme-btn + .theme-btn { margin-top: 2px; }
