:root, [data-theme="light"] {
  --text-xs: .75rem; --text-sm: .8125rem; --text-base: .9375rem; --text-lg: 1.0625rem; --text-xl: 1.375rem;
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f8fafc; --offset: #eaeef3;
  --border: rgba(20,35,60,.10); --border-strong: rgba(20,35,60,.2);
  --text: #14233a; --muted: #56647a; --faint: #8590a0;
  --primary: #07376b; --primary-hover: #05274d; --primary-hl: #e3ebf5; --on-primary: #fff;
  --accent: #fbd32b; --accent-ink: #5c4a00;
  --ok: #23703a; --ok-hl: #def0e2; --warn: #94560c; --warn-hl: #f8ead2; --danger: #a12a3a; --danger-hl: #f7e0e3; --info: #1d63a8; --info-hl: #e0ecf8;
  --c1: #07376b; --c2: #2f86d6; --c3: #46b2a4; --c4: #e0a326; --c5: #8a67c9; --c6: #9aa6b5;
  --shadow: 0 1px 2px rgba(20,35,60,.05), 0 4px 16px rgba(20,35,60,.05);
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 10px; --side-w: 236px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1117; --surface: #141a22; --surface-2: #18202a; --offset: #1f2833;
  --border: rgba(220,230,245,.09); --border-strong: rgba(220,230,245,.18);
  --text: #e4e9f0; --muted: #a0abba; --faint: #6f7b8b;
  --primary: #8fb8ea; --primary-hover: #abcaf0; --primary-hl: #182a40; --on-primary: #0a1626;
  --accent: #fbd32b; --accent-ink: #fbd32b;
  --ok: #7cc58f; --ok-hl: #17301f; --warn: #e3a95c; --warn-hl: #352816; --danger: #ec8d9a; --danger-hl: #3a1d23; --info: #84b7ec; --info-hl: #172a40;
  --c1: #8fb8ea; --c2: #4e9be0; --c3: #5fc2b4; --c4: #e8b54a; --c5: #a68ad9; --c6: #6c7a8c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: var(--text-base); line-height: 1.55; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg { display: block; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--c2); outline-offset: 2px; border-radius: 6px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; }
.num { font-family: var(--font); font-feature-settings: "tnum" 1, "lnum" 1; }
.faint { color: var(--faint); } .muted { color: var(--muted); }

/* shell */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100dvh; }
.side { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.brand { padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); }
.logo { width: 108px; height: auto; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; } [data-theme="dark"] .logo-dark { display: block; }
.brand-sub { font-size: var(--text-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.brand-sub::before { content: ""; width: 14px; height: 3px; background: var(--accent); border-radius: 2px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { font-size: var(--text-xs); color: var(--faint); padding: 12px 10px 4px; font-weight: 500; }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-size: var(--text-sm); font-weight: 500; transition: background .15s, color .15s; }
.nav button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav button:hover { background: var(--offset); color: var(--text); }
.nav button[aria-current="page"] { background: var(--primary-hl); color: var(--primary); font-weight: 600; }
.nav .badge { margin-left: auto; font-size: 11px; background: var(--warn-hl); color: var(--warn); padding: 0 7px; border-radius: 99px; font-weight: 600; }
.side-foot { padding: 14px 18px; border-top: 1px solid var(--border); }
.tenant { display: flex; flex-direction: column; font-size: var(--text-sm); line-height: 1.4; gap: 2px; }
.tenant .mono { font-size: 11px; }

.main-col { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.top { display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.crumbs { min-width: 0; }
.crumbs span { font-size: var(--text-xs); display: block; }
.crumbs h1 { font-size: var(--text-xl); font-weight: 600; line-height: 1.25; letter-spacing: -.005em; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.updated { font-size: var(--text-xs); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); background: var(--surface); }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn { display: none; }
.main { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 40px; }
.main:focus { outline: none; }
.wrap { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* chips & status */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; line-height: 1.5; }
.chip-sample { background: var(--accent); color: #3d3100; }
.s-ok { background: var(--ok-hl); color: var(--ok); } .s-warn { background: var(--warn-hl); color: var(--warn); }
.s-danger { background: var(--danger-hl); color: var(--danger); } .s-info { background: var(--info-hl); color: var(--info); }
.s-mute { background: var(--offset); color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2 { font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
.card-h .sub { font-size: var(--text-xs); color: var(--faint); }
.card-h .right { margin-left: auto; }
.grid { display: grid; gap: 18px; }
.g-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.g-2 { grid-template-columns: 1.6fr 1fr; } .g-2e { grid-template-columns: 1fr 1fr; } .g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.kpi { padding: 15px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .lbl { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.kpi .val { font-size: 1.5rem; font-weight: 600; line-height: 1.2; font-feature-settings: "tnum" 1; letter-spacing: -.01em; }
.kpi .val small { font-size: var(--text-sm); color: var(--muted); font-weight: 500; margin-left: 3px; }
.kpi .meta { font-size: var(--text-xs); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.up { color: var(--ok); } .down { color: var(--danger); }
.bar { height: 6px; border-radius: 99px; background: var(--offset); overflow: hidden; position: relative; margin-top: 4px; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--c2); }
.bar.warn > i { background: var(--c4); } .bar.ok > i { background: var(--c3); }

/* banner */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border); font-size: var(--text-sm); }
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.banner.warn { background: var(--warn-hl); color: var(--warn); border-color: transparent; }
.banner.info { background: var(--info-hl); color: var(--info); border-color: transparent; }
.banner b { font-weight: 600; }
.banner .act { margin-left: auto; white-space: nowrap; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; color: inherit; }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.li:first-child { border-top: 0; padding-top: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 500; } .li .d { font-size: var(--text-xs); color: var(--faint); }
.ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* table */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--offset); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 5px 11px; border-radius: 6px; font-size: var(--text-sm); color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg .n { font-size: 11px; color: var(--faint); margin-left: 4px; }
.search { margin-left: auto; position: relative; }
.search input { height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px 0 32px; background: var(--surface); width: 240px; font-size: var(--text-sm); }
.search svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: var(--text-xs); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
.empty { padding: 30px; text-align: center; color: var(--faint); font-size: var(--text-sm); }

/* charts */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--faint); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); font-size: var(--text-xs); padding: 6px 9px; border-radius: 6px; z-index: 60; white-space: nowrap; opacity: 0; transition: opacity .1s; }
.tip.on { opacity: 1; }

/* cost breakdown */
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; gap: 2px; margin: 4px 0 14px; }
.stack i { display: block; height: 100%; }
.rows .row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.rows .row:first-child { border-top: 0; }
.rows .sw { width: 10px; height: 10px; border-radius: 3px; }
.rows .pct { color: var(--faint); font-size: var(--text-xs); width: 40px; text-align: right; }

/* budget gauge */
.thresholds { position: relative; height: 14px; border-radius: 99px; background: var(--offset); margin: 26px 0 26px; }
.thresholds .fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: linear-gradient(90deg, var(--c3), var(--c4)); }
.thresholds .fc { position: absolute; top: 0; bottom: 0; border-radius: 0 99px 99px 0; background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--c4) 45%, transparent) 0 5px, transparent 5px 10px); }
.thresholds .mk { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--text); opacity: .55; }
.thresholds .mk span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.thresholds .now { position: absolute; top: 20px; transform: translateX(-50%); font-size: 11px; font-weight: 600; white-space: nowrap; }

/* sliders */
.ctl { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--border); }
.ctl:first-child { border-top: 0; padding-top: 0; }
.ctl label { display: flex; justify-content: space-between; font-size: var(--text-sm); color: var(--muted); }
.ctl label b { color: var(--text); font-weight: 600; font-feature-settings: "tnum" 1; }
input[type=range] { width: 100%; accent-color: var(--primary); }
.scen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scen > div { border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.scen .lbl { font-size: var(--text-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.scen .v { font-size: 1.375rem; font-weight: 600; font-feature-settings: "tnum" 1; }
.scen .v small { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.scen .base { border-color: var(--primary); background: var(--primary-hl); }
.note { font-size: var(--text-xs); color: var(--faint); line-height: 1.6; }
.note a { color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; font-size: var(--text-sm); font-weight: 500; border: 1px solid var(--border-strong); background: var(--surface); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }

/* pilot timeline */
.tl { position: relative; padding-top: 30px; }
.tl-track { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tl-ph { border-radius: 6px; padding: 10px 12px 12px; background: var(--offset); position: relative; overflow: hidden; }
.tl-ph .p { position: absolute; inset: 0 auto 0 0; background: var(--primary-hl); z-index: 0; }
.tl-ph > * { position: relative; z-index: 1; }
.tl-ph .w { font-size: var(--text-xs); color: var(--muted); font-family: var(--mono); }
.tl-ph .n { font-weight: 600; }
.tl-ph .d { font-size: var(--text-xs); color: var(--muted); }
.tl-ph.done { background: var(--ok-hl); } .tl-ph.done .w, .tl-ph.done .d { color: var(--ok); }
.tl-now { position: absolute; top: 0; bottom: -6px; width: 2px; background: var(--primary); }
.tl-now span { position: absolute; top: 0; left: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--primary); white-space: nowrap; }
.tl-gate { position: absolute; top: 18px; bottom: -6px; width: 0; border-left: 2px dashed var(--c4); }
.tl-gate span { position: absolute; top: -18px; left: 6px; font-size: var(--text-xs); color: var(--warn); white-space: nowrap; font-weight: 600; }
.gate-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.gate-row:first-child { border-top: 0; }
.gate-row .num { font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; font-size: var(--text-sm); border-top: 1px solid var(--border); }
.check:first-child { border-top: 0; }
.check .bx { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border-strong); flex: none; margin-top: 2px; display: grid; place-items: center; }
.check.done .bx { background: var(--ok); border-color: var(--ok); }
.check.done .bx svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3; }
.check.done .t { color: var(--muted); }
.check .d { font-size: var(--text-xs); color: var(--faint); }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(8,15,28,.38); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border); z-index: 50; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.dr-h { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.dr-h h3 { font-size: var(--text-lg); font-weight: 600; }
.dr-b { padding: 18px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; }
.cmp { width: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cmp td, .cmp th { white-space: normal; }
.conf { display: inline-flex; align-items: center; gap: 6px; }
.conf .bar { width: 54px; margin: 0; }
.dr-f { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: var(--text-sm); opacity: 0; transition: .2s; z-index: 70; pointer-events: none; }
.toast.on { opacity: 1; transform: translateX(-50%); }

/* contact */
.person { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.person:first-child { border-top: 0; padding-top: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 600; font-size: var(--text-xs); flex: none; }

/* responsive */
@media (max-width: 1180px) { .g-kpi { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 980px) {
  .g-2, .g-2e, .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 45; transform: translateX(-100%); transition: transform .22s ease; }
  .side.open { transform: none; box-shadow: 10px 0 30px rgba(0,0,0,.15); }
  .menu-btn { display: grid; }
  .top { padding: 10px 14px; gap: 10px; }
  .main { padding: 16px 14px 32px; }
  .updated { display: none; }
}
@media (max-width: 560px) {
  .g-kpi { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-kpi > :last-child { grid-column: 1 / -1; }
  .crumbs span { display: none; }
  .crumbs h1 { font-size: var(--text-lg); }
  .search { margin-left: 0; width: 100%; } .search input { width: 100%; }
  .scen { grid-template-columns: 1fr; }
  .gate-row { grid-template-columns: 1fr auto auto; gap: 10px; } .gate-row .hide-sm { display: none; }
  .tl { padding-top: 0; } .tl-now, .tl-gate { display: none; } .tl-track { grid-template-columns: 1fr; } .tl-ph .d { display: block !important; }
  .tl-ph { padding: 8px; } .tl-ph .d { display: none; }
  .kpi .val { font-size: 1.25rem; }
  .chip-sample { font-size: 11px; padding: 2px 7px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
