/*
 * Invix web styles. The UI/design guideline is DESIGN.md at the repository root: warm cream canvas, warm ink, one orange
 * CTA colour used scarcely, display type at weight 400 with negative tracking, hairline-only depth (no shadows), 8px CTA
 * radius, 12px card radius, 80px section rhythm, monospace on every code surface. Use the tokens below — never inline hex.
 */
:root {
  /* colors (DESIGN.md › colors) */
  --primary: #f54e00;
  --primary-active: #d04200;
  --ink: #26251e;
  --body: #5a5852;
  --muted: #807d72;
  --muted-soft: #a09c92;
  --hairline: #e6e5e0;
  --hairline-soft: #efeee8;
  --hairline-strong: #cfcdc4;
  --canvas: #f7f7f4;
  --canvas-soft: #fafaf7;
  --surface-card: #ffffff;
  --surface-strong: #e6e5e0;
  --on-primary: #ffffff;
  --success: #1f8a65;
  --error: #cf2d56;
  /* Invix extensions (DESIGN.md › Invix adaptation): a caution tone for partial/stale data, and tints for status badges */
  --warning: #9a5b12;
  --success-tint: #e2f0ea;
  --warning-tint: #f6ebd9;
  --error-tint: #f9e3e9;

  /* typography (the licensed display face is substituted: see DESIGN.md › Invix adaptation) */
  --font-sans: "Inter", "InterVariable", system-ui, -apple-system, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* rounded */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* spacing */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-base: 16px;
  --s-md: 20px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;
  --s-section: 80px;

  --container: 1200px;
  --gutter: 32px;
}

/* Dark mode: the same tokens on a warm near-black canvas. Follows the system unless the viewer picks a theme (theme.js sets
   data-theme on <html>). Keep both dark blocks identical. */
:root { color-scheme: light; --chart-estimate: #f54e00; --chart-estimate-bench: #a09c92; --chart-verified: #1f8a65; --chart-verified-bench: #5a5852; --chart-sleeve: #5b3fd6; --slice-1: #2a78d6; --slice-2: #1baf7a; --slice-3: #4a3aa7; --slice-4: #eda100; --slice-5: #e87ba4; --slice-6: #008300; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: #f54e00; --primary-active: #ff6a1f; --on-primary: #ffffff;
    --ink: #edece5; --body: #b9b6ac; --muted: #8e8b81; --muted-soft: #6d6a61;
    --hairline: #2f2e28; --hairline-soft: #262520; --hairline-strong: #45433b;
    --canvas: #171612; --canvas-soft: #1c1b17; --surface-card: #1f1e1a; --surface-strong: #33322b;
    --success: #4cc095; --error: #f06b8e; --warning: #e3a857;
    --success-tint: #16332a; --warning-tint: #3a2d18; --error-tint: #3e1b26;
    --chart-estimate: #ff6a1f; --chart-estimate-bench: #8e8b81; --chart-verified: #4cc095; --chart-verified-bench: #b9b6ac; --chart-sleeve: #a48bff;
    --slice-1: #3987e5; --slice-2: #199e70; --slice-3: #9085e9; --slice-4: #c98500; --slice-5: #d55181; --slice-6: #008300;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #f54e00; --primary-active: #ff6a1f; --on-primary: #ffffff;
  --ink: #edece5; --body: #b9b6ac; --muted: #8e8b81; --muted-soft: #6d6a61;
  --hairline: #2f2e28; --hairline-soft: #262520; --hairline-strong: #45433b;
  --canvas: #171612; --canvas-soft: #1c1b17; --surface-card: #1f1e1a; --surface-strong: #33322b;
  --success: #4cc095; --error: #f06b8e; --warning: #e3a857;
  --success-tint: #16332a; --warning-tint: #3a2d18; --error-tint: #3e1b26;
  --chart-estimate: #ff6a1f; --chart-estimate-bench: #8e8b81; --chart-verified: #4cc095; --chart-verified-bench: #b9b6ac; --chart-sleeve: #a48bff;
  --slice-1: #3987e5; --slice-2: #199e70; --slice-3: #9085e9; --slice-4: #c98500; --slice-5: #d55181; --slice-6: #008300;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 16px/1.5 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  color: var(--body);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--surface-strong); color: var(--ink) }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--hairline-strong); text-underline-offset: 3px }
a:hover { text-decoration-color: var(--ink) }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px }
b, strong { color: var(--ink); font-weight: 600 }

h1, h2, h3 { color: var(--ink); margin: 0 }
/* display-lg */
h1 { font-size: 36px; font-weight: 400; line-height: 1.2; letter-spacing: -0.72px }
/* display-md, with section rhythm above */
h2 { font-size: 26px; font-weight: 400; line-height: 1.25; letter-spacing: -0.325px; margin: var(--s-xxl) 0 var(--s-sm) }
/* title-sm */
h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 0 0 var(--s-sm) }
h3 .muted, h3 .pill { font-weight: 400; margin-left: var(--s-xs) }
h1 + .pill, h1 ~ .pill { align-self: center }
p { margin: var(--s-xs) 0 }
ul, ol { margin: var(--s-xs) 0; padding-left: 20px }
li + li { margin-top: var(--s-xxs) }

.muted { color: var(--muted) }
.small { font-size: 14px }
.card .small, td.small, .meta { font-size: 13px }
.error { color: var(--error) }
.gain { color: var(--success) }
.loss { color: var(--error) }
/* caption-uppercase */
.eyebrow { display: block; font-size: 11px; font-weight: 600; line-height: 1.4; letter-spacing: 0.88px; text-transform: uppercase; color: var(--muted); margin-bottom: var(--s-xs) }

/* ------------------------------------------------------------------ top nav */
.top { position: sticky; top: 0; z-index: 10; background: var(--canvas); border-bottom: 1px solid var(--hairline) }
.top-inner { max-width: var(--container); height: 64px; margin: 0 auto; padding: 0 var(--gutter); display: flex; align-items: center; gap: var(--s-xl) }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 500; letter-spacing: -0.3px; white-space: nowrap }
.brand-logo { width: 24px; height: 24px; flex: none; fill: currentColor }
.brand-sub { color: var(--muted); font-weight: 400 }
nav#nav { display: flex; align-items: center; gap: var(--s-xxs); flex: 1 }
nav#nav a { font-size: 14px; font-weight: 500; line-height: 1.4; color: var(--body); text-decoration: none; padding: 8px 12px; border-radius: var(--r-md) }
nav#nav a:hover { color: var(--ink); background: var(--hairline-soft) }
nav#nav a.active { color: var(--ink); background: var(--surface-strong) }
nav#nav a.nav-end { margin-left: auto }
body { transition: background-color .2s ease }
.nav-toggle { display: none }
.theme-toggle { flex: none; width: 36px; height: 36px; padding: 0; background: transparent; color: var(--body); border: 1px solid transparent }
.theme-toggle:hover, .theme-toggle:active { background: var(--hairline-soft); color: var(--ink) }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
.theme-toggle .fill { fill: currentColor; stroke: none }
.theme-toggle g { display: none }
.theme-toggle[data-mode="system"] .i-system, .theme-toggle[data-mode="light"] .i-light, .theme-toggle[data-mode="dark"] .i-dark { display: inline }

/* ------------------------------------------------------------------ layout */
.wrap { width: 100%; max-width: var(--container); margin: 0 auto; padding: var(--s-xxl) var(--gutter) var(--s-section); flex: 1 }
.page-head { display: flex; align-items: flex-end; gap: var(--s-base); flex-wrap: wrap; margin-bottom: var(--s-xs) }
.page-head .right { align-self: center }
.page-lede { max-width: 720px; margin: var(--s-xs) 0 var(--s-xl); color: var(--body) }
.row { display: flex; gap: var(--s-sm); align-items: center; flex-wrap: wrap }
.right { margin-left: auto }
.grid { display: grid; gap: var(--s-base) }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); margin-bottom: var(--s-base) }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); margin-bottom: var(--s-base) }
.grid.two > .card { margin-bottom: 0 }

.foot { border-top: 1px solid var(--hairline); background: var(--canvas) }
.foot-inner { max-width: var(--container); margin: 0 auto; padding: var(--s-xxl) var(--gutter) var(--s-section); display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: var(--s-xl); font-size: 14px; color: var(--body) }
.foot-inner p { margin: 0; max-width: 640px }
.foot-inner .brand { font-size: 16px }

/* ------------------------------------------------------------------ cards (hairline-only depth) */
.card { background: var(--surface-card); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s-lg); margin-bottom: var(--s-base); overflow-x: auto; color: var(--body) }
.card > h3:first-child, .card > .row:first-child h3 { margin-bottom: var(--s-sm) }
.card > .row:first-child { margin-bottom: var(--s-xs) }
.card > .row:first-child h3 { margin-bottom: 0 }
.card.error { color: var(--error); border-color: var(--error-tint); background: var(--surface-card) }
a.card { text-decoration: none; transition: border-color .15s ease }
a.card:hover { border-color: var(--hairline-strong) }

/* portfolio list */
.pf-list { display: grid; gap: var(--s-base); grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); margin-top: var(--s-xl) }
.pf-card { display: flex !important; flex-direction: column; gap: var(--s-sm); margin: 0; min-height: 168px }
.pf-card .pf-name { font-size: 22px; font-weight: 400; line-height: 1.3; letter-spacing: -0.11px; color: var(--ink) }
.pf-card .pf-foot { margin-top: auto; padding-top: var(--s-sm); border-top: 1px solid var(--hairline-soft); display: flex; justify-content: space-between; gap: var(--s-sm); font-size: 13px; color: var(--muted) }
.pf-card .pf-open { color: var(--ink); font-weight: 500 }

/* KPI tiles */
.kpi .card { margin: 0; display: flex; flex-direction: column; gap: var(--s-xxs); min-height: 128px }
.kpi .card.kpi-lead { min-height: 0 }
.kpi .card.kpi-lead .sub { margin-top: 0 }
.kpi .label { font-size: 11px; font-weight: 600; line-height: 1.4; letter-spacing: 0.88px; text-transform: uppercase; color: var(--muted) }
.kpi .value { font-size: 30px; font-weight: 400; line-height: 1.2; letter-spacing: -0.6px; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: var(--s-xs) }
.kpi .sub { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: auto }
/* Overview: the value with its chart, then the period table, stacked full-width. The Performance tab's metric tiles
   use the same grid, three to a row. */
.grid.kpi.kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) }
.kpi .kpi-delta { font-size: 14px; line-height: 1.4; font-variant-numeric: tabular-nums }
.grid.kpi.kpi-3 > .card.kpi-lead,
.grid.kpi.kpi-3 > .card.kpi-chart,
.grid.kpi.kpi-3 > .card.kpi-table { grid-column: 1 / -1 }
.kpi .card.kpi-table { min-height: 0 }
.kpi-table td { vertical-align: middle }
th .th-sort { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit }
th .th-sort:hover, th .th-sort.active { color: var(--body) }
th .th-sort:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-xs) }
.kpi .card.kpi-chart { min-height: 280px; padding-top: var(--s-md); padding-bottom: var(--s-md) }
@media (max-width: 899px) {
  .grid.kpi.kpi-3 { grid-template-columns: repeat(2, minmax(0, 1fr)) }
}

/* ------------------------------------------------------------------ tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; color: var(--body) }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--hairline-soft); vertical-align: top }
tr:last-child > td { border-bottom: 0 }
th { color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.4; letter-spacing: 0.88px; text-transform: uppercase; border-bottom-color: var(--hairline); white-space: nowrap; vertical-align: bottom }
th:first-child, td:first-child { padding-left: 0 }
th:last-child, td:last-child { padding-right: 0 }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums }
td b { font-weight: 600 }
/* A group (Holdings: cash) and its breakdown lines, indented under it. */
tr.group-row > td { border-top: 1px solid var(--hairline) }
tr.sub-row > td:first-child { padding-left: var(--s-base) }
.group-label { display: inline-flex; align-items: center; gap: 2px; margin-left: -6px }
button.row-toggle svg { transition: transform .15s ease }
button.row-toggle[aria-expanded="true"] svg { transform: rotate(90deg) }
td.nowrap { white-space: nowrap }
.card table + h3, .card table + p { margin-top: var(--s-base) }
.card h3 + table, .card p + table { margin-top: var(--s-xs) }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: var(--s-xs); border-bottom: 1px solid var(--hairline); margin: var(--s-xl) 0 var(--s-lg); overflow-x: auto; scrollbar-width: none }
.tabs::-webkit-scrollbar { display: none }
.tabs a { flex: none; padding: 10px 4px 12px; margin-right: var(--s-base); font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px }
.tabs a:hover { color: var(--ink) }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink) }

/* ------------------------------------------------------------------ buttons */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-xs);
  height: 40px; padding: 10px 18px;
  font: 500 14px/1 var(--font-sans);
  color: var(--on-primary); background: var(--primary);
  border: 1px solid transparent; border-radius: var(--r-md);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .btn:hover, button:active, .btn:active { background: var(--primary-active); color: var(--on-primary) }
button.secondary { background: var(--surface-card); color: var(--ink); border-color: var(--hairline-strong); padding: 9px 17px }
button.secondary:hover, button.secondary:active { background: var(--canvas); color: var(--ink); border-color: var(--muted-soft) }
/* destructive actions stay outlined: orange is the only filled action colour */
button.danger { background: var(--surface-card); color: var(--error); border-color: var(--hairline-strong) }
button.danger:hover, button.danger:active { background: var(--error-tint); color: var(--error); border-color: var(--error) }
button.small { height: 30px; padding: 6px 12px; font-size: 13px }
button:disabled, button:disabled:hover { opacity: .45; cursor: default }
button.secondary:disabled:hover { background: var(--surface-card); border-color: var(--hairline-strong) }
.card button + button, .row button + button { margin-left: 0 }

/* ------------------------------------------------------------------ forms */
input, select, textarea {
  width: 100%; height: 44px; padding: 10px 14px;
  font: 400 16px/1.4 var(--font-sans); color: var(--ink);
  background: var(--surface-card); border: 1px solid var(--hairline-strong); border-radius: var(--r-md);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: var(--muted-soft) }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--hairline) }
input:disabled, select:disabled { background: var(--canvas-soft); color: var(--muted) }
select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat }
select[multiple] { height: auto; padding: 6px; background-image: none }
select[multiple] option { padding: 6px 8px; border-radius: var(--r-xs) }
input[type="checkbox"], input[type="radio"] { width: 16px !important; height: 16px; padding: 0; margin: 0; flex: none; accent-color: var(--ink); box-shadow: none }
input[type="file"] { height: auto; padding: 10px; font-size: 14px; background: var(--canvas-soft); border-style: dashed }
input[type="file"]::file-selector-button { font: 500 13px/1 var(--font-sans); color: var(--ink); background: var(--surface-card); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm); padding: 8px 12px; margin-right: 12px; cursor: pointer }
textarea { height: auto; font-family: var(--font-mono); font-size: 13px }
label { display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin: var(--s-base) 0 6px }
label.row { font-weight: 400; color: var(--body); margin: var(--s-sm) 0 }
form > button, form .row > button { margin-top: var(--s-lg) }

/* ------------------------------------------------------------------ badges */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; line-height: 1.4; letter-spacing: 0.88px; text-transform: uppercase;
  background: var(--surface-strong); color: var(--ink); white-space: nowrap; vertical-align: middle;
}
.pill.ok { background: var(--success-tint); color: var(--success) }
.pill.warn { background: var(--warning-tint); color: var(--warning) }
.pill.bad { background: var(--error-tint); color: var(--error) }
.pill button { height: auto; padding: 0 2px !important; background: transparent; color: var(--muted); border: 0; font-size: 14px; line-height: 1 }
.pill button:hover { background: transparent; color: var(--error) }
td .pill + br + select { margin-top: var(--s-xs) }
td select { height: 36px; font-size: 14px; min-width: 190px }

.warn-list { margin: var(--s-sm) 0 0; padding-left: 18px; color: var(--warning); font-size: 13px }

/* ------------------------------------------------------------------ code surfaces (monospace everywhere) */
code, pre, kbd { font-family: var(--font-mono) }
code { font-size: 0.86em; background: var(--hairline-soft); color: var(--ink); padding: 2px 6px; border-radius: var(--r-xs); word-break: break-word }
pre { background: var(--canvas-soft); color: var(--ink); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: var(--s-md); overflow: auto; font-size: 13px; line-height: 1.5; margin: var(--s-sm) 0 }
pre code { background: none; padding: 0 }

/* calculation metadata footer on each analytics card */
.meta { color: var(--muted); margin-top: var(--s-base); border-top: 1px solid var(--hairline-soft); padding-top: var(--s-sm); line-height: 1.6 }
/* A card that is only provenance (the overview) needs no rule above the first line. */
.card > .meta:first-child { margin-top: 0; border-top: 0; padding-top: 0 }
.meta b { color: var(--body); font-weight: 500 }

/* ------------------------------------------------------------------ auth */
.auth-split { display: grid; grid-template-columns: 1.15fr 1fr; gap: var(--s-section); align-items: center; padding: var(--s-xl) 0 }
.auth-hero h1 { font-size: 64px; line-height: 1.08; letter-spacing: -1.9px; max-width: 12ch }
.auth-hero p { font-size: 18px; color: var(--body); max-width: 460px; margin-top: var(--s-lg) }
.auth-points { list-style: none; padding: 0; margin: var(--s-xl) 0 0; display: grid; gap: var(--s-sm); font-size: 14px }
.auth-points li { display: flex; gap: var(--s-sm); align-items: baseline; margin: 0 }
.auth-points li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); flex: none; transform: translateY(-2px) }
.card.auth { max-width: 440px; width: 100%; padding: var(--s-xl); margin: 0 }
.card.auth h1 { font-size: 26px; letter-spacing: -0.325px; margin-bottom: var(--s-xxs) }
.auth-split .card.auth { justify-self: end }
.card.auth button[type="submit"] { min-width: 120px }
.wrap > .card.auth { margin: var(--s-xl) auto }

/* ------------------------------------------------------------------ AI prompts + allocation bars */
.prompts { display: flex; flex-wrap: wrap; gap: var(--s-xs); margin-top: var(--s-sm) }
.prompts span { background: var(--surface-card); color: var(--ink); border: 1px solid var(--hairline-strong); border-radius: var(--r-pill); padding: 7px 14px; font-size: 14px; cursor: pointer; transition: border-color .15s ease, background-color .15s ease }
.prompts span:hover { border-color: var(--ink) }
.prompts span.copied { background: var(--ink); border-color: var(--ink); color: var(--canvas) }
.bar { height: 6px; background: var(--hairline-soft); border-radius: var(--r-pill); overflow: hidden; margin-top: 9px }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: var(--r-pill) }

/* ------------------------------------------------------------------ performance chart */
.chart-ranges { gap: var(--s-xxs); margin: var(--s-xxs) 0 var(--s-sm) }
button.chip { height: 30px; padding: 4px 12px; font-size: 13px; border-radius: var(--r-pill) }
button.chip:hover { background: var(--hairline-soft); color: var(--ink) }
button.chip.active, button.chip.active:hover { background: var(--ink); color: var(--canvas); border-color: var(--ink) }
.chart-box { position: relative }
svg.chart { display: block; max-width: 100%; touch-action: pan-y; font-family: var(--font-sans) }
svg.chart .grid { stroke: var(--hairline-soft) }
svg.chart .grid.zero { stroke: var(--hairline-strong) }
svg.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums }
svg.chart .cursor { stroke: var(--muted-soft); stroke-dasharray: 3 3 }
.chart-tip { position: absolute; top: 8px; background: var(--surface-card); border: 1px solid var(--hairline-strong); border-radius: var(--r-md); padding: 8px 12px; font-size: 12px; line-height: 1.6; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--body) }
.chart-tip i, .chart-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle }
.chart-legend { display: flex; gap: var(--s-base); flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: var(--s-sm) }
.chart-legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums }

/* Stacked bars: a 2px surface gap between segments (the card behind them, drawn as a stroke); a square swatch per series. */
svg.chart .bar-seg { stroke: var(--surface-card); stroke-width: 2; paint-order: stroke }
svg.chart .bar-hover { fill: var(--hairline-soft) }
svg.chart .net-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round }
svg.chart .net-dot { fill: var(--ink); stroke: var(--surface-card); stroke-width: 1.5 }
.chart-legend i.net-key { width: 14px; height: 2px; background: var(--ink) }
.chart-tip i.swatch, .chart-legend i.swatch { width: 10px; height: 10px; border-radius: 2px }
.income-head { gap: var(--s-sm); flex-wrap: wrap }
.income-head .chart-ranges { margin: 0 0 0 auto }
.income-head .chart-ranges + .chart-ranges { margin-left: var(--s-sm) }

/* Info button beside a card title, and the modal holding that card's notes. */
.card .row > h3 + .info-btn { margin-left: calc(var(--s-xs) - var(--s-sm)) }
button.info-btn { width: 26px; height: 22px; padding: 0; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: var(--r-pill) }
button.info-btn:hover, button.info-btn:active { background: var(--hairline-soft); color: var(--ink) }
button.info-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round }
button.info-btn svg .fill { fill: currentColor; stroke: none }
dialog.info-dialog { width: min(480px, calc(100vw - 32px)); padding: var(--s-lg); background: var(--surface-card); color: var(--body); border: 1px solid var(--hairline-strong); border-radius: var(--r-lg, 12px) }
dialog.info-dialog::backdrop { background: rgb(0 0 0 / .35) }
dialog.info-dialog h3 { margin: 0 }
dialog.info-dialog p { margin: var(--s-sm) 0 0 }
button.info-close { width: 32px; height: 32px; padding: 0; font-size: 22px; background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: var(--r-pill) }
button.info-close:hover, button.info-close:active { background: var(--hairline-soft); color: var(--ink) }

/* The Holdings tab's breakdown chips sit opposite the card title (no .chart-ranges margins, which would defeat .right). */
.bd-modes { gap: var(--s-xxs) }

/* Session line: under the value, in the same card. The stroke is currentColor, so .gain / .loss on the
   wrapper colours it. The 0% gridline is the previous close. While the session is still open (.is-live), the last
   print blinks slowly and a halo expands from it. */
.kpi-spark { flex: 1 1 0; min-height: 240px; margin: 0; display: flex; flex-direction: column }
.kpi-spark .chart-box { flex: 1 1 0; min-height: 0 }
.kpi-spark svg.chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible }
.kpi-spark .session-line { stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round }
.kpi-spark .session-dot { fill: currentColor }
.kpi-spark .session-dot-pulse { fill: currentColor; pointer-events: none; transform-box: fill-box; transform-origin: center }
.kpi-spark.is-live .session-dot { animation: session-live-dot 2.4s ease-in-out infinite }
.kpi-spark.is-live .session-dot-pulse { animation: session-live-pulse 2.4s ease-out infinite }
@keyframes session-live-dot {
  0%, 100% { opacity: 1 }
  50% { opacity: 0.32 }
}
@keyframes session-live-pulse {
  0% { transform: scale(1); opacity: 0.55 }
  65% { transform: scale(4); opacity: 0 }
  100% { transform: scale(4); opacity: 0 }
}
@media (prefers-reduced-motion: reduce) {
  .kpi-spark.is-live .session-dot,
  .kpi-spark.is-live .session-dot-pulse { animation: none }
  .kpi-spark.is-live .session-dot-pulse { opacity: 0.22; transform: scale(2.2) }
}
.kpi-spark .chart-tip { top: 8px; z-index: 1 }

/* Donut (part-to-whole): ring left, legend right — the legend is also the table view, so no value is colour-only. */
.donut { display: flex; align-items: center; gap: var(--s-xl); flex-wrap: wrap; margin-top: var(--s-sm) }
.donut-ring { position: relative; flex: 0 0 220px; width: 220px; height: 220px }
.donut-ring svg { display: block; width: 100%; height: 100% }
/* The 2px surface gap between segments is the card behind them, drawn as a stroke. */
.donut-slice { stroke: var(--surface-card); stroke-width: 2; transition: opacity .12s ease }
.donut-slice.dim { opacity: .35 }
.donut-center { position: absolute; inset: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; line-height: 1.25 }
.donut-center b { font-size: 22px; font-weight: 400; letter-spacing: -0.3px; color: var(--ink); font-variant-numeric: tabular-nums }
.donut-center span { font-size: 12px; color: var(--muted); max-width: 96px; overflow: hidden }
.donut-center .donut-sub { font-variant-numeric: tabular-nums }
.donut-legend { flex: 1 1 260px; list-style: none; margin: 0; padding: 0; min-width: 0 }
.donut-legend li { display: flex; align-items: baseline; gap: var(--s-sm); padding: 7px 0; border-bottom: 1px solid var(--hairline-soft); font-size: 14px; color: var(--body); cursor: default }
.donut-legend li:last-child { border-bottom: 0 }
.donut-legend li.on { color: var(--ink) }
.donut-legend li:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-xs) }
.donut-legend i { flex: 0 0 auto; width: 10px; height: 10px; border-radius: var(--r-xs); align-self: center }
.donut-legend .donut-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.donut-legend .donut-name em { display: block; font-style: normal; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.donut-legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums }
.donut-legend .donut-val { flex: 0 0 auto; width: 90px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums }
.donut-legend li.donut-off i { background: none; border: 1.5px solid var(--muted) }
.donut-legend li.donut-off b { color: var(--body) }
@media (max-width: 640px) {
  .donut { gap: var(--s-base); justify-content: center }
  .donut-legend .donut-val { width: 72px }
}

/* ------------------------------------------------------------------ responsive (DESIGN.md › Responsive Behavior) */
@media (max-width: 1024px) {
  /* Tablet: the signed-in header only fits between 769px and ~900px without the subtitle and with tighter gaps */
  .top-inner { gap: var(--s-base) }
  .brand-sub { display: none }
  .auth-split { grid-template-columns: 1fr; gap: var(--s-xxl) }
  .auth-split .card.auth { justify-self: start }
  .auth-hero h1 { font-size: 52px; letter-spacing: -1.5px }
}
@media (max-width: 768px) {
  :root { --gutter: 16px }
  .top-inner { gap: var(--s-sm) }
  .theme-toggle { margin-left: auto }
  .nav-toggle { display: inline-flex; height: 40px; width: 40px; padding: 0; background: transparent; border: 1px solid var(--hairline-strong); color: var(--ink) }
  .nav-toggle:hover, .nav-toggle:active { background: var(--hairline-soft); color: var(--ink) }
  .nav-toggle span, .nav-toggle span::before, .nav-toggle span::after { display: block; width: 16px; height: 1.5px; background: currentColor; position: relative; content: "" }
  .nav-toggle span::before { position: absolute; top: -5px }
  .nav-toggle span::after { position: absolute; top: 5px }
  nav#nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 2px; padding: var(--s-xs) var(--gutter) var(--s-base); background: var(--canvas); border-bottom: 1px solid var(--hairline) }
  .top.open nav#nav { display: flex }
  nav#nav a { padding: 12px }
  nav#nav a.nav-end { margin-left: 0 }
  .wrap { padding-top: var(--s-xl) }
  h1 { font-size: 30px; letter-spacing: -0.6px }
  h2 { font-size: 22px; letter-spacing: -0.11px; margin-top: var(--s-xl) }
  .auth-hero h1 { font-size: 36px; letter-spacing: -0.9px }
  .auth-hero p { font-size: 16px }
  .card { padding: var(--s-md) }
  .card.auth { padding: var(--s-lg) }
  .foot-inner { grid-template-columns: 1fr; gap: var(--s-base); padding-bottom: var(--s-xxl) }
  .kpi .value { font-size: 26px }
}
@media (min-width: 900px) {
  .grid.kpi.kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) }
}
@media (max-width: 640px) {
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-sm) }
  .kpi .card { min-height: 112px; padding: var(--s-base) }
  .kpi .card.kpi-chart { min-height: 220px }
  .kpi .value { font-size: 22px; letter-spacing: -0.3px }
}
.eyebrow a { color: inherit; text-decoration: none }
.eyebrow a:hover { color: var(--ink) }

/* Overview value and chart, one card: the value and the period's change above the line, the period buttons below it
   (fixed, so they never shift). */
.kpi-chart .kpi-delta { min-height: 20px; margin-bottom: var(--s-sm) }
.kpi-chart .chart-ranges { gap: var(--s-xxs); margin: var(--s-sm) 0 0 }
.kpi-chart .chart-ranges button.chip { height: 26px; padding: 2px 10px; font-size: 12px }
#spark-note { margin: var(--s-xs) 0 0 }
#spark-note:empty { display: none }
/* Overview provenance: collapsed to one summary line until opened. */
.meta-details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--s-xs); font-size: 13px; color: var(--muted) }
.meta-details > summary::-webkit-details-marker { display: none }
.meta-details > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px }
.meta-details[open] > summary::before { transform: rotate(45deg) }
.meta-details[open] > summary { margin-bottom: var(--s-sm) }
