[hidden]{display:none!important}
*,*::before,*::after{box-sizing:border-box}
:root{padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}

/* Layout: tabbed report — one tab per view (Overall / Chronic / Acute); each tab = ledger table, then 2x2 charts, then consultant read-out */
:root{
  --bg:#f6f7f8; --surface:#ffffff; --fg:#1d2329; --muted:#6b7580; --line:#e2e6ea;
  --chronic:#0f72a8; --chronic-soft:#e5f0f7;
  --acute:#c0611a; --acute-soft:#fbeee3;
  --s3:#6250d6; --neutral:#aab2bb; --ink2:#7b8590;
  --total-soft:#eef0f3;
  --warn:#d9a21b; --good:#1f7a4a; --good-soft:#e2f3e9; --bad:#b3261e; --bad-soft:#fbe5e3;
  --cost:#5d6670;
  --hl:#eef3f8; --hl-t:#e1e9f1; --hl-strong:#dfe8f2; --group:#4a5560;
  --font-body:"IBM Plex Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
  --font-num:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace;
}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){
  --bg:#13171b; --surface:#1b2026; --fg:#e7ebef; --muted:#97a1ab; --line:#2c333b;
  --chronic:#2f93cc; --chronic-soft:#16303f; --acute:#d0702a; --acute-soft:#3a2a1b;
  --s3:#9085e9; --neutral:#59626c; --ink2:#8a949e;
  --total-soft:#232931; --warn:#d8a73a; --good:#6fd39b; --good-soft:#173527; --bad:#f08a82; --bad-soft:#3d1d1b;
  --cost:#a3adb7; --hl:#1f2833; --hl-t:#26303c; --hl-strong:#263241; --group:#aab4be; color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#13171b; --surface:#1b2026; --fg:#e7ebef; --muted:#97a1ab; --line:#2c333b;
  --chronic:#2f93cc; --chronic-soft:#16303f; --acute:#d0702a; --acute-soft:#3a2a1b;
  --s3:#9085e9; --neutral:#59626c; --ink2:#8a949e;
  --total-soft:#232931; --warn:#d8a73a; --good:#6fd39b; --good-soft:#173527; --bad:#f08a82; --bad-soft:#3d1d1b;
  --cost:#a3adb7; --hl:#1f2833; --hl-t:#26303c; --hl-strong:#263241; --group:#aab4be; color-scheme:dark}
body{background:var(--bg);color:var(--fg);font-family:var(--font-body);font-size:14px}
.wrap{max-width:1320px;margin:0 auto;padding-block:28px 48px;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));display:grid;gap:18px}
h1{font-size:22px;margin:0;font-weight:600;text-wrap:balance}
.sub{color:var(--muted);margin:4px 0 0;font-size:13px}
.top{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap}
.theme{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface)}
.theme button{appearance:none;border:0;background:none;font:inherit;font-size:13px;font-weight:500;color:var(--muted);padding:7px 14px;cursor:pointer}
.theme button+button{border-left:1px solid var(--line)}
.theme button[aria-pressed="true"]{background:var(--fg);color:var(--surface)}
.theme button:focus-visible{outline:2px solid var(--s3);outline-offset:-2px}

/* tabs */
.tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid var(--line);background:var(--bg);padding-top:6px;position:sticky;top:env(safe-area-inset-top,0px);z-index:20}
.tab{appearance:none;border:1px solid var(--line);border-bottom:0;background:var(--total-soft);font:inherit;font-size:14px;font-weight:600;color:var(--muted);padding:10px 18px 11px;cursor:pointer;border-radius:8px 8px 0 0;display:inline-flex;align-items:center;gap:8px;margin-bottom:-1px;box-shadow:inset 0 -3px 0 transparent}
.tab:hover{color:var(--fg)}
.tab .dot{width:9px;height:9px;border-radius:50%;background:var(--fg)}
.tab[data-seg="C"] .dot{background:var(--chronic)}
.tab[data-seg="A"] .dot{background:var(--acute)}
.tab[aria-selected="true"]{background:var(--surface);color:var(--fg);box-shadow:inset 0 -3px 0 var(--fg)}
.tab[data-seg="C"][aria-selected="true"]{box-shadow:inset 0 -3px 0 var(--chronic)}
.tab[data-seg="A"][aria-selected="true"]{box-shadow:inset 0 -3px 0 var(--acute)}
.tab:focus-visible{outline:2px solid var(--s3);outline-offset:2px}
body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:21;background:var(--bg)}
.panel{display:grid;gap:22px}
.h2{margin:4px 0 0;font-size:13px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--group)}

/* table */
.scroll{overflow-x:auto;background:var(--surface);border:1px solid var(--line);border-radius:8px}
thead th{position:relative;background:var(--surface);z-index:3;will-change:transform}
thead th:first-child{position:sticky;left:0;z-index:4}
thead tr.month th{box-shadow:inset 0 -1px 0 var(--line)}
table.floating thead tr.month th{box-shadow:inset 0 -1px 0 var(--line),0 6px 8px -6px rgba(0,0,0,.25)}
table{border-collapse:collapse;width:100%;min-width:1280px;font-variant-numeric:tabular-nums;table-layout:fixed}
th,td{padding:12px 12px;text-align:right;white-space:nowrap;border-bottom:1px solid var(--line)}
th:first-child,td:first-child{text-align:left;position:sticky;left:0;background:var(--surface);z-index:1;font-weight:500;width:290px}
thead th{font-size:12px;font-weight:600;letter-spacing:.03em;padding-block:10px}
thead tr.qtr th{text-align:center;font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);border-bottom:1px solid var(--line);padding-block:8px 6px}
thead tr.qtr th.q{background:var(--total-soft);color:var(--fg)}
thead tr.month th{font-size:13px;text-align:right;white-space:normal;vertical-align:bottom;line-height:1.3}
thead tr.month th:first-child{text-align:left}
thead tr.month th.proj{font-style:italic}
td{font-family:var(--font-num);font-size:13px;overflow:hidden;text-overflow:ellipsis}
td.qs,th.qs,thead tr.qtr th.q{border-left:2px solid var(--line)}
tr.cost td:not(:first-child){color:var(--cost)}
tr.cost td:first-child{color:var(--cost);font-weight:400;padding-left:24px}
tr.key td{font-weight:600}
tr.key td:first-child{font-weight:700}
tr.ratio td:first-child{color:var(--muted);font-weight:400}
tr.group td{background:var(--bg);font-family:var(--font-body);font-size:11px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--group);text-align:left;padding:16px 12px 6px}
tr.has-sub td{border-bottom:none;padding-bottom:4px}
tr.mix td{color:var(--muted);padding-top:0;padding-bottom:10px;font-size:11.5px}
tr.mix td:first-child{padding-left:24px;font-weight:400;font-style:italic}
tr.hl td,tr.hl td:first-child{background:var(--hl)}
tr.contrib td{font-size:14px}
tr.contrib td:first-child{background:var(--hl-strong)}
.sec-T tr.hl td:first-child,.sec-T tr.contrib td:first-child{box-shadow:inset 3px 0 0 var(--fg)}
.sec-C tr.hl td:first-child,.sec-C tr.contrib td:first-child{box-shadow:inset 3px 0 0 var(--chronic)}
.sec-A tr.hl td:first-child,.sec-A tr.contrib td:first-child{box-shadow:inset 3px 0 0 var(--acute)}
td.ratio-cell .cc{color:var(--chronic);font-weight:600}
td.ratio-cell .aa{color:var(--acute);font-weight:600}
.pos{background:var(--good-soft)!important;color:var(--good)}
.neg{background:var(--bad-soft)!important;color:var(--bad)}

/* charts */
.charts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
@media (max-width:860px){.charts{grid-template-columns:minmax(0,1fr)}}
.card{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:14px 14px 10px;display:grid;gap:6px;min-width:0;position:relative}
.card h3{margin:0;font-size:14px;font-weight:600}
.card .cap{margin:0;font-size:12px;color:var(--muted)}
.legend{display:flex;flex-wrap:wrap;gap:12px;font-size:12px;color:var(--muted)}
.legend span{display:inline-flex;align-items:center;gap:6px}
.sw{width:12px;height:3px;border-radius:2px;display:inline-block}
.sw.box{height:10px;width:10px;border-radius:2px}
.sw.dash{background:repeating-linear-gradient(90deg,var(--muted) 0 4px,transparent 4px 7px)!important}
svg.ch{width:100%;height:auto;display:block;overflow:visible}
svg.ch text{font-family:var(--font-body);font-size:11px;fill:var(--muted)}
svg.ch .grid{stroke:var(--line);stroke-width:1}
svg.ch .zero{stroke:var(--muted);stroke-width:1}
svg.ch .lbl{fill:var(--fg);font-weight:600;font-size:11px}
svg.ch .hit{fill:transparent}
svg.ch .hit:hover{fill:var(--fg);fill-opacity:.04}
.tip{position:absolute;pointer-events:none;background:var(--fg);color:var(--bg);font-size:12px;line-height:1.5;padding:7px 9px;border-radius:6px;white-space:nowrap;z-index:5;font-variant-numeric:tabular-nums}
.tip b{display:block;font-weight:600;margin-bottom:2px}
.tip i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px;font-style:normal}

/* insights */
.readout{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:20px 22px;display:grid;gap:16px}
.readout .lead{margin:0;font-size:18px;font-weight:600;line-height:1.35;max-width:70ch;text-wrap:balance}
.ins{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 28px}
@media (max-width:860px){.ins{grid-template-columns:minmax(0,1fr)}}
.ins article{display:grid;gap:4px;align-content:start;padding-top:10px;border-top:1px solid var(--line)}
.ins .k{font-family:var(--font-num);font-size:20px;font-weight:500}
.ins h4{margin:0;font-size:14px;font-weight:600}
.ins p{margin:0;font-size:13px;line-height:1.55;color:var(--muted);max-width:62ch}
.acts{display:grid;gap:8px;padding-top:6px}
.acts h4{margin:0;font-size:13px;letter-spacing:.08em;text-transform:uppercase;color:var(--group)}
.acts ol{margin:0;padding-left:20px;display:grid;gap:6px;font-size:13.5px;line-height:1.5;max-width:90ch}
.acts li b{font-weight:600}
.notes{font-size:12.5px;color:var(--muted);line-height:1.6;max-width:90ch;display:grid;gap:4px}
.notes p{margin:0}
.notes b{color:var(--fg);font-weight:600}
@media (prefers-reduced-motion:no-preference){.panel{animation:fade .18s ease-out}@keyframes fade{from{opacity:.4}to{opacity:1}}}

/* app shell additions */
.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.btn{appearance:none;border:1px solid var(--line);background:var(--surface);color:var(--fg);font:inherit;font-size:13px;font-weight:600;padding:7px 14px;border-radius:8px;cursor:pointer;display:inline-flex;align-items:center;gap:8px}
.btn:hover{border-color:var(--muted)}
.btn:disabled{opacity:.6;cursor:progress}
.btn:focus-visible{outline:2px solid var(--s3);outline-offset:2px}
.btn .spin{width:12px;height:12px;border:2px solid var(--line);border-top-color:var(--fg);border-radius:50%;display:none}
.btn[aria-busy="true"] .spin{display:inline-block;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.who{font-size:12px;color:var(--muted)}
.who a{color:var(--muted)}
.status{font-size:12.5px;color:var(--muted)}
.banner{border:1px solid var(--bad);background:var(--bad-soft);color:var(--bad);padding:10px 14px;border-radius:8px;font-size:13px}
.loading{padding:40px 0;color:var(--muted);text-align:center}
/* login */
.login-wrap{min-height:100vh;display:grid;place-items:center;padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px))}
.login{width:100%;max-width:360px;background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:28px;display:grid;gap:10px}
.login h1{margin:0}
.login label{font-size:13px;font-weight:600;margin-top:8px}
.login input{font:inherit;font-size:15px;padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--fg)}
.login input:focus-visible{outline:2px solid var(--s3);outline-offset:1px}
.login .err{margin:0;color:var(--bad);font-size:13px}
.btn.primary{background:var(--fg);color:var(--surface);border-color:var(--fg);justify-content:center;padding:10px 14px;margin-top:6px}

thead th .thru{font-weight:400;font-style:normal;font-size:11px;color:var(--muted)}

/* compact header row */
thead tr.month th{white-space:nowrap;padding-top:8px;padding-bottom:8px;vertical-align:middle}
