/* Stratum: private-client report styling --------------------------------- */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --page: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --surface-3: #f0ede6;
  --border: rgba(20, 28, 45, 0.08);
  --border-strong: rgba(20, 28, 45, 0.15);
  --text: #111827;
  --text-2: #475064;
  --muted: #7f8697;
  --grid: #ece9e2;
  --axis: #cfcbc2;
  --brand: #13294b;          /* deep navy */
  --brand-ink: #1f4f8f;
  --brand-soft: rgba(31, 79, 143, 0.09);
  --gold: #a8844f;           /* champagne accent */
  --gold-soft: rgba(168, 132, 79, 0.14);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 2px 6px rgba(17, 24, 39, 0.05);
  --shadow-lg: 0 24px 60px rgba(17, 24, 39, 0.20);

  --good: #0b8f4d;
  --good-ink: #067a40;
  --warning: #c98500;
  --critical: #c9372c;
  --critical-ink: #b3261e;

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --div-neg: #c9372c; --div-mid: #f3efe8; --div-pos: #1f6fbf;

  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 252px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b1018;
    --surface: #111826;
    --surface-2: #151d2d;
    --surface-3: #1c2537;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #eef1f6;
    --text-2: #b8c0cf;
    --muted: #8089a0;
    --grid: #1f283a;
    --axis: #364055;
    --brand: #d9c29a;
    --brand-ink: #8fb7ee;
    --brand-soft: rgba(143, 183, 238, 0.12);
    --gold: #d2b27c;
    --gold-soft: rgba(210, 178, 124, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
    --good: #2fb872; --good-ink: #45c985;
    --critical: #e8645a; --critical-ink: #f08178;
    --warning: #e0a537;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --div-neg: #e8645a; --div-mid: #1a2233; --div-pos: #5aa0ee;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1018;
  --surface: #111826;
  --surface-2: #151d2d;
  --surface-3: #1c2537;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef1f6;
  --text-2: #b8c0cf;
  --muted: #8089a0;
  --grid: #1f283a;
  --axis: #364055;
  --brand: #d9c29a;
  --brand-ink: #8fb7ee;
  --brand-soft: rgba(143, 183, 238, 0.12);
  --gold: #d2b27c;
  --gold-soft: rgba(210, 178, 124, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --good: #2fb872; --good-ink: #45c985;
  --critical: #e8645a; --critical-ink: #f08178;
  --warning: #e0a537;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --div-neg: #e8645a; --div-mid: #1a2233; --div-pos: #5aa0ee;
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--page);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
button, input, select { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
kbd { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface-2); }
a { color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.pos { color: var(--good-ink); } .neg { color: var(--critical-ink); }

.app { display: flex; min-height: 100vh; }

/* Sidebar ---------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 20px 14px 16px;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); padding: 2px 8px 18px; }
.brand-mark { width: 36px; height: 36px; stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 20px; font-weight: 600; letter-spacing: 0.01em; }
.brand-text small { color: var(--muted); font-size: 11.5px; letter-spacing: 0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--gold); padding: 14px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.nav a kbd { margin-left: auto; opacity: .7; }
.nav a .badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 0 7px; border-radius: 99px; background: var(--critical); color: #fff; line-height: 18px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; color: var(--muted); }
.source-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.source-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

/* Main / topbar ---------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title { flex: 1 1 260px; min-width: 0; }
.page-title h1 { font-family: var(--serif); font-size: 25px; font-weight: 600; margin: 0; letter-spacing: -0.005em; line-height: 1.2; }
.page-title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.control, .icon-btn, .select {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow);
}
.control:hover, .icon-btn:hover, .select:hover { border-color: var(--brand-ink); }
.icon-btn { width: 36px; padding: 0; justify-content: center; }
.select { appearance: none; padding-right: 30px; max-width: 230px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.select-wrap { display: inline-flex; flex-direction: column; }
.select-wrap label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 2px 2px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-3); border: 1px solid var(--border); height: 36px; }
.segmented button { border: 0; background: transparent; padding: 0 10px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-weight: 500; font-size: 13px; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.date-inputs { display: inline-flex; align-items: center; gap: 4px; }
.date-inputs input { height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); padding: 0 8px; font-size: 12.5px; width: 136px; }
.menu-btn { display: none; }
.cmdk-btn span { color: var(--muted); }
#themeBtn .i-moon { display: none; }
:root[data-theme="dark"] #themeBtn .i-sun { display: none; }
:root[data-theme="dark"] #themeBtn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) #themeBtn .i-sun { display: none; }
  :root:not([data-theme]) #themeBtn .i-moon { display: block; }
}
.filter-note { width: 100%; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.filter-note b { color: var(--text-2); font-weight: 600; }

.content { padding: 22px 28px 48px; max-width: 1560px; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; } .col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }

/* Cards ------------------------------------------------------------------ */
.card { background: var(--surface); 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: flex-start; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head > div:first-child { flex: 1 1 220px; min-width: 0; }
.card-head h2 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
.card-actions .mini-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.card-actions button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.card-actions button:hover { background: var(--surface-3); color: var(--text); }
.card-actions button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.card-actions .mini-seg { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 2px; margin-right: 4px; }
.card-actions .mini-seg button { width: auto; padding: 0 8px; height: 26px; font-size: 12px; font-weight: 500; border-radius: 6px; color: var(--text-2); }
.card-actions .mini-seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chart { width: 100%; height: 320px; }
.card.fill { display: flex; flex-direction: column; }
.card.fill > .chart { flex: 1 1 auto; min-height: 400px; }
.chart.tall { height: 400px; } .chart.short { height: 240px; } .chart.xl { height: 480px; }
.table-view { display: none; }
.card.show-table .chart { display: none; }
.card.show-table .table-view { display: block; }
.empty { color: var(--muted); padding: 30px; text-align: center; }

/* KPI tiles -------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; overflow: hidden; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--gold), transparent 70%); opacity: .8; }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi-label svg { width: 15px; height: 15px; color: var(--gold); }
.kpi-value { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-value small { font-family: var(--font); font-size: 13px; color: var(--muted); margin-left: 3px; font-weight: 500; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; min-height: 20px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; padding: 1px 7px 1px 4px; border-radius: 99px; font-size: 11.5px; }
.delta svg { width: 13px; height: 13px; stroke-width: 2.4; }
.delta.good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 13%, transparent); }
.delta.bad { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 13%, transparent); }
.delta.flat { color: var(--muted); background: var(--surface-3); }
.kpi-spark { height: 34px; margin: 2px -4px -4px; }

/* Insights --------------------------------------------------------------- */
.insights { display: flex; flex-direction: column; gap: 10px; }
.insight { display: flex; gap: 11px; align-items: flex-start; padding: 10px 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.insight .ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.insight .ic svg { width: 16px; height: 16px; }
.insight .ic.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-ink); }
.insight .ic.bad { background: color-mix(in srgb, var(--critical) 14%, transparent); color: var(--critical-ink); }
.insight .ic.info { background: var(--brand-soft); color: var(--brand-ink); }
.insight .ic.warn { background: var(--gold-soft); color: var(--gold); }
.insight b { display: block; font-size: 13px; font-weight: 600; }
.insight span { font-size: 12.5px; color: var(--text-2); }

/* Tables ----------------------------------------------------------------- */
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--border); border-radius: 10px; }
.table-wrap.flat { max-height: none; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--text-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; z-index: 1; }
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--text); }
thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.flagged { background: color-mix(in srgb, var(--critical) 7%, transparent); }
td.wrap { white-space: normal; min-width: 200px; }
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.table-tools input[type="search"] { height: 32px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); padding: 0 10px; min-width: 200px; flex: 1 1 200px; max-width: 320px; }
.table-tools label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; font-size: 12px; color: var(--muted); }
.pager button { height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

/* Chips & badges --------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-weight: 500; }
.chip .dot, .dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.status svg { width: 14px; height: 14px; stroke-width: 2.4; }
.status.pass { color: var(--good-ink); } .status.fail { color: var(--critical-ink); } .status.warn { color: var(--warning); }
.big-status { display: flex; align-items: center; gap: 14px; }
.big-status .ring { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.big-status .ring.pass { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-ink); }
.big-status .ring.fail { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical-ink); }
.big-status .ring svg { width: 28px; height: 28px; stroke-width: 2.4; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--serif); font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

/* Report-style prose (methods) ------------------------------------------ */
.prose { font-size: 13.5px; color: var(--text-2); max-width: 900px; }
.prose h3 { font-family: var(--serif); color: var(--text); font-size: 17px; margin: 18px 0 6px; }
.prose code { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.formula { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; color: var(--text); }
.disclaimer { font-size: 12px; color: var(--muted); border-left: 3px solid var(--gold); padding: 8px 12px; background: var(--gold-soft); border-radius: 0 8px 8px 0; }
.bench-table td:first-child { font-weight: 600; color: var(--text); white-space: normal; min-width: 160px; }
.win { color: var(--good-ink); font-weight: 600; }

/* Command palette -------------------------------------------------------- */
.cmdk { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.cmdk[hidden] { display: none; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 20, 0.45); backdrop-filter: blur(3px); }
.cmdk-panel { position: relative; width: min(620px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk-list li { padding: 9px 12px; border-radius: 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.cmdk-list li small { color: var(--muted); }
.cmdk-list li.group { cursor: default; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); padding: 10px 12px 4px; }
.cmdk-list li[aria-selected="true"] { background: var(--brand-soft); color: var(--brand-ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: var(--text); color: var(--surface); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 120; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 50vh; color: var(--muted); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scrim { display: none; }

/* Responsive ------------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .col-3 { grid-column: span 6; } .col-4, .col-5, .col-7, .col-8 { grid-column: span 12; }
}
@media (max-width: 1080px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(8, 12, 20, .35); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .col-6 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .page-title h1 { font-size: 21px; }
  .page-title p { display: none; }
  .toolbar { width: 100%; justify-content: flex-start; }
  .select { max-width: none; width: 100%; }
  .select-wrap { flex: 1 1 150px; min-width: 0; }
  .date-inputs-wrap { display: none; }
  .cmdk-btn span, .cmdk-btn kbd { display: none; }
  .content { padding: 14px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .col-3 { grid-column: span 12; }
  .chart { height: 280px; } .chart.tall, .chart.xl { height: 340px; }
  .card { padding: 14px; }
  .card-head { flex-wrap: wrap; }
  .segmented button { padding: 0 8px; }
}
@media (max-width: 340px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .sidebar, .topbar .toolbar, .card-actions { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}
