/* Folio — styles. Colour roles follow the data-viz reference palette (light & dark selected, not flipped). */

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-3: #ecebe6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --s1: #2a78d6;           /* categorical slot 1 — blue */
  --s2: #eb6834;           /* slot 2 — orange */
  --s3: #1baf7a;           /* slot 3 — aqua */
  --s1-soft: rgba(42, 120, 214, 0.10);
  --s2-soft: rgba(235, 104, 52, 0.13);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #006300;
  --down: #b3261e;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-ink: #ffffff;
  --focus: rgba(42, 120, 214, 0.45);
  --topbar: rgba(249, 249, 247, 0.82);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 10px 30px -18px rgba(11, 11, 11, 0.18);
  --shadow-pop: 0 2px 6px rgba(11, 11, 11, 0.08), 0 18px 40px -16px rgba(11, 11, 11, 0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2a2a28;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s1-soft: rgba(57, 135, 229, 0.16);
    --s2-soft: rgba(217, 89, 38, 0.20);
    --up: #0ca30c;
    --down: #f07167;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --focus: rgba(57, 135, 229, 0.55);
    --topbar: rgba(13, 13, 13, 0.78);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 40px -16px rgba(0, 0, 0, 0.95);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2a2a28;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s1-soft: rgba(57, 135, 229, 0.16);
  --s2-soft: rgba(217, 89, 38, 0.20);
  --up: #0ca30c;
  --down: #f07167;
  --accent: #3987e5;
  --accent-hover: #5598e7;
  --focus: rgba(57, 135, 229, 0.55);
  --topbar: rgba(13, 13, 13, 0.78);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, 0.5), 0 18px 40px -16px rgba(0, 0, 0, 0.95);
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.25rem; line-height: 1.3; font-weight: 650; letter-spacing: -0.012em; color: var(--ink); }
h3 { font-size: 0.95rem; font-weight: 620; color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.up { color: var(--up); }
.down { color: var(--down); }
.nowrap { white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; }
.delta svg.i { stroke-width: 2.2; }
.foot svg.i { vertical-align: -2px; }
.noscript { padding: 24px; text-align: center; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 14px; height: 14px; }

/* ── Brand ───────────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 680; letter-spacing: -0.02em; font-size: 1.08rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: url('/favicon.svg') center / cover no-repeat; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.brand-lg { font-size: 1.6rem; gap: 12px; }
.brand-lg .brand-mark { width: 40px; height: 40px; border-radius: 12px; }

/* ── Buttons & controls ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); font-weight: 560; font-size: 0.92rem;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.84rem; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 8px; color: var(--ink-2); font-size: 0.86rem; font-weight: 560; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }

.field { display: grid; gap: 6px; }
.field-label { font-size: 0.8rem; font-weight: 560; color: var(--ink-2); }
.field-hint { font-size: 0.76rem; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], input[inputmode] {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
  font-variant-numeric: tabular-nums;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 44px; }
.input-btn { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.input-btn:hover { color: var(--ink); background: var(--surface-2); }
.affix { position: relative; display: block; }
.affix > span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.86rem; pointer-events: none; }
.affix > input { padding-left: 38px; text-align: right; }
.check { display: inline-flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; color: var(--ink-2); cursor: pointer; line-height: 1.35; }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }

/* ── Login ───────────────────────────────────────────────────────────── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 36px 32px 28px; box-shadow: var(--shadow-pop); display: grid; gap: 18px;
}
.login-sub { color: var(--ink-2); margin-top: -8px; }
.login-foot { font-size: 0.78rem; color: var(--muted); text-align: center; }
.form-error { color: var(--down); font-size: 0.88rem; display: flex; gap: 8px; align-items: center; }

/* ── Boot splash ─────────────────────────────────────────────────────── */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--page); z-index: 50; transition: opacity .25s; }
.boot .brand-mark { width: 44px; height: 44px; border-radius: 13px; animation: pulse 1.2s ease-in-out infinite; }
.boot.gone { opacity: 0; pointer-events: none; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.ribbon { background: var(--s1-soft); color: var(--ink); text-align: center; font-size: 0.82rem; padding: 7px 16px; border-bottom: 1px solid var(--border); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 20px; }
.nav { display: flex; gap: 2px; flex: 1; justify-content: center; min-width: 0; }
.nav a { color: var(--ink-2); font-size: 0.88rem; font-weight: 540; padding: 7px 11px; border-radius: 9px; white-space: nowrap; }
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--ink-2); margin-right: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.dot.busy { background: var(--s1); animation: pulse 1s ease-in-out infinite; box-shadow: none; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 56px; display: grid; gap: 28px; }
.section { min-width: 0; }
.section-head { margin: 4px 2px 14px; display: grid; gap: 4px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
.grid-2 > .section { display: contents; }
.grid-tight { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.grid-tight > .card + .card { margin-top: 0; }
.grid-tight { align-items: stretch; }
.span-2 { grid-column: 1 / -1; }
.banners { display: grid; gap: 10px; }
.banners:empty { display: none; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.card + .card { margin-top: 20px; }
.card-head { display: grid; gap: 4px; margin-bottom: 20px; }
.card-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.card-head-row > div:first-child { display: grid; gap: 4px; }
.eyebrow { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.card-sub { color: var(--ink-2); font-size: 0.9rem; }
.subhead { font-size: 0.78rem; font-weight: 620; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; border: 0; }
.note { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.note + .note { margin-top: 4px; }

/* ── Banners & chips ─────────────────────────────────────────────────── */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 0.9rem; color: var(--ink); box-shadow: var(--shadow); }
.banner .i { margin-top: 1px; }
.banner-body { flex: 1; display: grid; gap: 2px; }
.banner strong { font-weight: 620; }
.banner.info .i { color: var(--s1); }
.banner.warning { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); background: color-mix(in srgb, var(--warning) 8%, var(--surface)); }
.banner.warning .i { color: color-mix(in srgb, var(--warning) 70%, var(--ink)); }
.banner.critical { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); background: color-mix(in srgb, var(--critical) 6%, var(--surface)); }
.banner.critical .i { color: var(--critical); }
.banner .btn { flex: none; }

.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; color: var(--ink); background: var(--surface-2); border: 1px solid var(--border); }
.chip .i { width: 14px; height: 14px; stroke-width: 2.2; }
.chip.ok { background: color-mix(in srgb, var(--good) 10%, var(--surface)); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.chip.ok .i { color: var(--good); }
.chip.warning { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.chip.warning .i { color: color-mix(in srgb, var(--warning) 70%, var(--ink)); }
.chip.serious { background: color-mix(in srgb, var(--serious) 14%, var(--surface)); border-color: color-mix(in srgb, var(--serious) 45%, transparent); }
.chip.serious .i { color: var(--serious); }
.chip.critical { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.chip.critical .i { color: var(--critical); }
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-size: 0.7rem; font-weight: 650; letter-spacing: 0.02em; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.core { color: var(--ink); background: var(--s1-soft); border-color: color-mix(in srgb, var(--s1) 30%, transparent); }
.badge.legacy { color: var(--ink); background: var(--s2-soft); border-color: color-mix(in srgb, var(--s2) 30%, transparent); }

/* ── Snapshot hero ───────────────────────────────────────────────────── */
.hero { padding: 28px 28px 24px; overflow: hidden; position: relative; }
.hero-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 28px; align-items: end; }
.hero-label { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 0.88rem; }
.hero-value { font-size: clamp(2.4rem, 5.2vw, 3.6rem); font-weight: 660; letter-spacing: -0.035em; line-height: 1.05; margin: 8px 0 10px; }
.hero-value .ccy { font-size: 0.42em; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-right: 6px; vertical-align: 0.95em; }
.hero-delta { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; font-size: 0.95rem; }
.hero-delta .muted { font-weight: 450; }
.spark-wrap { position: relative; min-width: 0; }
.spark-cap { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--muted); margin-top: 4px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; padding: 14px 16px; min-width: 0; }
.tile-label { font-size: 0.78rem; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.tile-value { font-size: 1.32rem; font-weight: 640; letter-spacing: -0.02em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.tile.flag { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); background: color-mix(in srgb, var(--warning) 7%, var(--surface-2)); }
.hero .banner { margin-top: 16px; box-shadow: none; }

/* ── Plan vs actual ──────────────────────────────────────────────────── */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--ink-2); margin-bottom: 14px; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; background: var(--s1); }
.sw.s2 { background: var(--s2); }
.sw.s3 { background: var(--s3); }
.sw.muted-sw { background: var(--muted); }
.sw.line { height: 2px; border-radius: 1px; width: 16px; }
.sw.tick { width: 2px; height: 14px; border-radius: 1px; background: var(--ink); }
.sw.band { background: color-mix(in srgb, var(--s2) 22%, transparent); border: 1px solid color-mix(in srgb, var(--s2) 55%, transparent); }
.sw.after { background: var(--s1); }
.sw.before { background: var(--axis); }

.alloc { display: grid; gap: 18px; }
.alloc-row { display: grid; gap: 7px; min-width: 0; }
.alloc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; min-width: 0; }
.alloc-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.alloc-name strong { font-weight: 660; letter-spacing: 0.01em; }
.alloc-name span { color: var(--muted); font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-bar { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 12px; align-items: center; }
.alloc-figs { text-align: right; font-size: 0.84rem; color: var(--ink-2); white-space: nowrap; }
.alloc-figs strong { color: var(--ink); font-weight: 650; font-size: 0.95rem; }
.alloc-foot { font-size: 0.8rem; color: var(--muted); }
.bullet { position: relative; height: 22px; }
.bullet::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--grid); border-radius: 1px; }
.bullet .bar { position: absolute; left: 0; top: 5px; height: 12px; width: var(--w, 0%); background: var(--s1); border-radius: 0 4px 4px 0; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.bullet .tick { position: absolute; top: 0; height: 22px; width: 2px; left: var(--x, 0%); margin-left: -1px; background: var(--ink); border-radius: 1px; }
.bullet .tick::after { content: ''; position: absolute; inset: 0 -1px; box-shadow: 0 0 0 2px var(--surface); border-radius: 2px; z-index: -1; }
.summary-line { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--border); font-size: 0.84rem; color: var(--ink-2); }
.summary-line strong { color: var(--ink); font-weight: 640; }

/* ── Planner ─────────────────────────────────────────────────────────── */
.pl-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.check-in { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.fund-id { cursor: pointer; }
.pl-cash { display: grid; gap: 6px; }
.pl-cash-value { height: 40px; display: flex; align-items: center; font-size: 1.12rem; font-weight: 640; letter-spacing: -0.01em; }
.pl-funds { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.fund-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 128px; gap: 12px; align-items: center; padding: 10px 14px; background: var(--surface); }
.fund-row + .fund-row { border-top: 1px solid var(--border); }
.fund-row.off { background: var(--surface-2); }
.fund-row.off .fund-id { opacity: .55; }
.fund-id { display: grid; gap: 1px; min-width: 0; }
.fund-id strong { font-weight: 650; display: flex; gap: 8px; align-items: center; }
.fund-id small { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fund-row .affix input { height: 34px; border-radius: 8px; font-size: 0.9rem; }
.fund-row .affix > span { font-size: 0.78rem; }
.price-src { display: block; font-size: 0.7rem; color: var(--muted); text-align: right; margin-top: 3px; white-space: nowrap; }
.price-src.stale { color: var(--down); }
details.adv { margin-top: 12px; }
details.adv summary { cursor: pointer; font-size: 0.84rem; color: var(--ink-2); list-style: none; display: inline-flex; gap: 6px; align-items: center; padding: 4px 0; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary .i { transition: transform .15s; }
details.adv[open] summary .i { transform: rotate(90deg); }
.adv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 10px; padding: 14px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--border); }
.adv-grid input { height: 34px; }

.result { margin-top: 22px; }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.result-head h3 { font-size: 1rem; }
.tickets { display: grid; gap: 10px; }
.ticket {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.ticket-side { font-size: 0.7rem; font-weight: 750; letter-spacing: 0.08em; color: var(--accent-ink); background: var(--accent); border-radius: 7px; padding: 5px 8px; }
.ticket-main { min-width: 0; display: grid; gap: 2px; }
.ticket-line { font-size: 1.02rem; font-weight: 640; letter-spacing: -0.005em; }
.ticket-line .qty { font-size: 1.12rem; }
.ticket-meta { font-size: 0.8rem; color: var(--ink-2); }
.ticket .icon-btn { width: 34px; height: 34px; }
.ticket.copied { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.total { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.total-label { font-size: 0.76rem; color: var(--ink-2); }
.total-value { font-size: 1.08rem; font-weight: 640; margin-top: 2px; }
.total-sub { font-size: 0.74rem; color: var(--muted); }
.skipped { margin-top: 14px; display: grid; gap: 6px; }
.skip { display: flex; gap: 8px; align-items: flex-start; font-size: 0.84rem; color: var(--ink-2); }
.skip .i { color: var(--muted); margin-top: 2px; }
.empty { padding: 22px; text-align: center; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; border: 1px dashed var(--border-strong); font-size: 0.9rem; }
.mini-bars { display: grid; gap: 10px; }
.mini { display: grid; grid-template-columns: 52px minmax(0, 1fr) 150px; gap: 12px; align-items: center; font-size: 0.84rem; }
.mini strong { font-weight: 640; }
.mini-track { position: relative; height: 20px; }
.mini-track::before { content: ''; position: absolute; left: 0; right: 0; top: 9px; height: 2px; background: var(--grid); }
.mini-track .b { position: absolute; left: 0; height: 6px; border-radius: 0 3px 3px 0; width: var(--w, 0%); transition: width .4s; }
.mini-track .b.before { top: 2px; background: var(--axis); }
.mini-track .b.after { top: 11px; height: 7px; background: var(--s1); }
.mini-track .tick { position: absolute; top: 0; height: 20px; width: 2px; left: var(--x, 0%); margin-left: -1px; background: var(--ink); border-radius: 1px; }
.mini-figs { text-align: right; color: var(--ink-2); white-space: nowrap; }
.mini-figs strong { color: var(--ink); }
.disclaimer { display: flex; gap: 8px; align-items: flex-start; margin-top: 18px; font-size: 0.78rem; color: var(--muted); }
.disclaimer .i { margin-top: 1px; }

/* ── Charts ──────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.s1 { stroke: var(--s1); }
.chart .ln.s2 { stroke: var(--s2); }
.chart .ln.muted-ln { stroke: var(--muted); stroke-width: 1.5; }
.chart .ln.dash { stroke-dasharray: 5 4; stroke-width: 1.75; }
.chart .area.s1 { fill: var(--s1); opacity: .10; }
.chart .band { fill: var(--s2); opacity: .13; }
.chart .cross { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .pt { stroke: var(--surface); stroke-width: 2; }
.chart .pt.s1 { fill: var(--s1); }
.chart .pt.s2 { fill: var(--s2); }
.chart .pt.muted-pt { fill: var(--muted); }
.chart .end-dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip {
  position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; min-width: 168px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow-pop); padding: 10px 12px; font-size: 0.8rem; line-height: 1.4;
  transform: translate(var(--tx, 0px), var(--ty, 0px)); opacity: 0; transition: opacity .12s;
}
.tip.on { opacity: 1; }
.tip-title { font-weight: 640; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tip-row strong { color: var(--ink); font-weight: 620; font-variant-numeric: tabular-nums; }
.tip-row .k { display: inline-flex; align-items: center; gap: 6px; }
.tip-row .sw { width: 9px; height: 9px; border-radius: 2px; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-size: 0.84rem; font-weight: 540; display: inline-flex; gap: 6px; align-items: center; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.stat-label { font-size: 0.76rem; color: var(--ink-2); }
.stat-value { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.015em; margin-top: 2px; white-space: nowrap; }
.stat-sub { font-size: 0.76rem; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; margin-bottom: 16px; }
.controls .field { min-width: 160px; }

/* ── Exposure ────────────────────────────────────────────────────────── */
.stackbars { display: grid; gap: 14px; }
.stackbar-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; font-size: 0.84rem; color: var(--ink-2); }
.stack { display: flex; height: 22px; gap: 2px; border-radius: 6px; overflow: hidden; }
.stack > span { flex: var(--f, 0) 1 0; min-width: 2px; background: var(--s1); cursor: default; }
.stack > span.s2 { background: var(--s2); }
.stack > span.s3 { background: var(--s3); }
.stack > span.s4 { background: var(--muted); }
.stack > span:hover { filter: brightness(1.08); }
.reg-table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 0.86rem; }
.reg-table th { text-align: right; font-weight: 560; color: var(--muted); font-size: 0.76rem; padding: 0 0 6px; }
.reg-table th:first-child { text-align: left; }
.reg-table td { padding: 7px 0; border-top: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.reg-table td:first-child { text-align: left; }
.reg-table .k { display: inline-flex; gap: 8px; align-items: center; color: var(--ink); }
.big-fig { font-size: 2rem; font-weight: 660; letter-spacing: -0.03em; line-height: 1.1; }
.big-fig small { font-size: 0.9rem; color: var(--ink-2); font-weight: 500; letter-spacing: 0; margin-left: 6px; }
.lt-list { display: grid; gap: 9px; margin-top: 16px; }
.lt { display: grid; grid-template-columns: 116px minmax(0, 1fr) 76px; gap: 10px; align-items: center; font-size: 0.84rem; }
.lt-name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-name strong { color: var(--ink); font-weight: 640; }
.lt-track { height: 12px; position: relative; }
.lt-track > span { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w, 0%); background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.lt-val { text-align: right; font-variant-numeric: tabular-nums; }
.lt-list + .note { margin-top: 16px; }
.legacy-list { display: grid; }
.legacy-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.legacy-item:first-child { border-top: 0; padding-top: 0; }
.legacy-item .nm { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.legacy-item .nm strong { font-weight: 660; }
.legacy-item .nm span { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legacy-item .val { text-align: right; font-weight: 620; font-variant-numeric: tabular-nums; }
.legacy-item .why { font-size: 0.8rem; color: var(--ink-2); }
.legacy-item .pl { text-align: right; font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.tbl-wrap { position: relative; overflow-x: auto; margin: 0 -24px; padding: 0 24px; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.tbl th { text-align: right; font-weight: 560; font-size: 0.74rem; letter-spacing: 0.02em; color: var(--muted); padding: 0 10px 8px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tbl td { text-align: right; padding: 11px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .l { text-align: left; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tbl .sym { font-weight: 650; }
.tbl .nm { color: var(--muted); font-size: 0.8rem; display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tbl .drop-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tbl tfoot td { border-top: 1px solid var(--border-strong); border-bottom: 0; font-weight: 640; }
.tbl.compact td { padding: 8px 10px; }

/* ── Costs ───────────────────────────────────────────────────────────── */
.cost-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.cost-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.cost-tile .tile-value { font-size: 1.45rem; }
.cost-tile.flag { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); }
.callout { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: color-mix(in srgb, var(--warning) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border)); font-size: 0.88rem; }
.callout .i { color: color-mix(in srgb, var(--warning) 70%, var(--ink)); margin-top: 1px; }
.callout + .card, .cost-grid + .card { margin-top: 16px; }
.tile-value .muted { font-size: 0.62em; font-weight: 500; letter-spacing: 0; }
.callout.good { background: color-mix(in srgb, var(--good) 6%, var(--surface)); border-color: color-mix(in srgb, var(--good) 30%, var(--border)); }
.callout.good .i { color: var(--good); }

/* ── Footer, toasts, skeletons ───────────────────────────────────────── */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: 0.78rem; color: var(--muted); padding: 4px 2px; }
.toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(440px, calc(100% - 32px)); }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--page); font-size: 0.88rem; box-shadow: var(--shadow-pop); animation: rise .25s ease-out; }
.toast.err .i { color: var(--serious); }
.toast.ok .i { color: var(--good); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-hero { height: 220px; }
.skeleton-block { height: 260px; }
.skeleton-chart { height: 340px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (min-width: 1101px) {
  #plan > .card { position: sticky; top: 84px; }
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  html { scroll-padding-top: 112px; }
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; row-gap: 6px; justify-content: space-between; }
  .nav { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px 8px; }
  .nav::-webkit-scrollbar { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cost-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 8px 16px 0; gap: 8px; }
  .status .label { display: none; }
  .page { padding: 18px 16px 40px; gap: 20px; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .hero { padding: 20px 16px 18px; }
  .hero-top { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
  .tile { padding: 12px 13px; }
  .tile-value { font-size: 1.12rem; }
  .grid-tight { grid-template-columns: minmax(0, 1fr); }
  .pl-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pl-top .seg-field { grid-column: 1 / -1; }
  .fund-row { grid-template-columns: auto minmax(0, 1fr) 112px; padding: 10px 12px; gap: 10px; }
  .adv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ticket { grid-template-columns: minmax(0, 1fr) auto; padding: 12px 14px; }
  .ticket-side { display: none; }
  .totals { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .total { padding: 10px 11px; }
  .total-value { font-size: 0.98rem; }
  .total-sub { font-size: 0.7rem; }
  .mf-target { display: none; }
  .banner-body { flex: 1 1 200px; }
  .banner .btn { margin-left: 30px; }
  .legacy-item { grid-template-columns: minmax(0, 1fr) auto; }
  .legacy-item .why { grid-column: 1 / -1; }
  .legacy-item .pl { grid-column: 1 / -1; text-align: left; }
  .tile-value .delta svg.i { width: 12px; height: 12px; }
  .mini { grid-template-columns: 46px minmax(0, 1fr) 118px; gap: 8px; font-size: 0.8rem; }
  .alloc-bar { grid-template-columns: minmax(0, 1fr) 96px; }
  .lt { grid-template-columns: 96px minmax(0, 1fr) 64px; }
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }
  .tbl .hide-sm { display: none; }
  .cost-grid { gap: 10px; }
  .cost-tile { padding: 14px; }
  .cost-tile .tile-value { font-size: 1.2rem; }
  .stats { gap: 10px; }
  .stat-value { font-size: 1.05rem; }
  .section-head { margin-bottom: 10px; }
  .card-head { margin-bottom: 16px; }
  .banner { flex-wrap: wrap; }
}
@media (max-width: 359px) {
  .tiles, .stats, .cost-grid, .totals { grid-template-columns: minmax(0, 1fr); }
  .pl-top { grid-template-columns: minmax(0, 1fr); }
}
/* ── Sectors (What you really own) ─────────────────────────────────────── */
.sector-list { display: grid; gap: 10px; }
.sector-row { display: grid; grid-template-columns: minmax(130px, 200px) minmax(0, 1fr) 118px 92px; gap: 12px; align-items: center; font-size: 0.86rem; }
.sector-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector-figs { text-align: right; color: var(--ink-2); white-space: nowrap; }
.sector-figs strong { color: var(--ink); font-weight: 650; }
.sector-val { text-align: right; color: var(--muted); white-space: nowrap; }

/* ── Plan screen (plan-editor.js) ──────────────────────────────────────── */
.dialog { width: min(880px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 48px); padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(0, 0, 0, .35); }
.dialog::backdrop { background: rgba(8, 8, 8, .55); }
.dialog-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 24px 14px; border-bottom: 1px solid var(--border); }
.dialog-head > div { display: grid; gap: 4px; }
.dialog-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 24px 24px; display: grid; gap: 22px; align-content: start; }
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.pe-status { display: grid; gap: 3px; flex: 1 1 260px; min-width: 0; font-size: 0.84rem; }
.pe-status .i { margin-right: 6px; vertical-align: -3px; }
.pe-ok { color: var(--good); }
.pe-bad { color: var(--down); }
.pe-section { display: grid; gap: 12px; }
.pe-h { font-size: 0.95rem; font-weight: 650; color: var(--ink); }
.pe-list { display: grid; gap: 10px; }
.pe-item { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.pe-item-top { display: grid; grid-template-columns: minmax(0, 1fr) 104px auto auto; gap: 10px; align-items: center; padding: 10px 12px; }
.pe-item-top-other { grid-template-columns: minmax(0, 1fr) 120px auto; }
.pe-id { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.pe-id strong { font-weight: 660; white-space: nowrap; }
.pe-id span { color: var(--muted); font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-details { display: grid; gap: 16px; padding: 14px 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
.pe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.pe-grid .field { align-content: start; }
.pe-wide { grid-column: span 2; }
.pe-split { min-width: 0; margin: 0; padding: 0; border: 0; }
.pe-split legend { padding: 0; margin-bottom: 8px; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.pe-sum { font-weight: 500; color: var(--muted); }
.pe-sum.warn { color: color-mix(in srgb, var(--warning) 75%, var(--ink)); }
.pe-split-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px 14px; }
.pe-split-field { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 8px; align-items: center; font-size: 0.82rem; color: var(--ink-2); }
.pe-split-field > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-split-field input, .pe-target input { height: 34px; }
.affix-r > span { left: auto; right: 10px; }
.affix-r > input { padding-left: 10px; padding-right: 26px; }
.pe-select { width: 100%; height: 34px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); }
.pe-add { justify-self: start; }
.pe-start { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 0.88rem; }
.pe-start-again > summary { cursor: pointer; font-size: 0.86rem; }
.pe-start-again[open] { display: grid; gap: 8px; }
.pe-share { font-size: 0.86rem; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.pe-share input:disabled { cursor: default; }
.pe-share input:disabled + span { color: var(--muted); }
.pe-others > summary { display: flex; gap: 6px; align-items: baseline; cursor: pointer; list-style: none; }
.pe-others > summary::-webkit-details-marker { display: none; }
.pe-others > summary::before { content: '›'; display: inline-block; width: 10px; color: var(--muted); transition: transform .15s; }
.pe-others[open] > summary::before { transform: rotate(90deg); }
.pe-mix-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.pe-mix { margin-top: 0; }
.pe-mix td small { margin-left: 4px; font-size: 0.74rem; color: var(--muted); }
.pe-moved { font-weight: 650; }
.pe-versions { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.pe-versions li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.88rem; }

@media (max-width: 760px) {
  .sector-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .sector-row .bullet { grid-column: 1 / -1; grid-row: 2; }
  .sector-val { display: none; }
  .dialog { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .dialog-inner { height: 100%; max-height: 100dvh; }
  .dialog-head, .dialog-body, .dialog-foot { padding-left: 16px; padding-right: 16px; }
  .pe-item-top { grid-template-columns: 100px minmax(0, 1fr) auto; }
  .pe-item-top-other { grid-template-columns: 120px minmax(0, 1fr); }
  .pe-item-top .pe-id { grid-column: 1 / -1; }
  .pe-item-top [data-act="toggle"] { justify-self: start; }
  .pe-mix-grid { grid-template-columns: 1fr; }
  .pe-wide { grid-column: auto; }
}

/* ── Accounts (account.js): link page, account window, IBKR guide, welcome ── */
/* #dash only groups the dashboard sections (to hide them before the first statement); the page grid lays them out. */
#dash { display: contents; }
.link-title { font-size: 1.3rem; font-weight: 650; letter-spacing: -0.01em; }
.acct-tabs { padding: 12px 24px 0; }
.acct-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 0.9rem; }
.acct-facts dt { color: var(--muted); }
.acct-facts dd { margin: 0; overflow-wrap: anywhere; }
.acct-form { display: grid; gap: 12px; max-width: 560px; }
.acct-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.acct-form .pe-select { height: 40px; }
.acct-status { font-size: 0.92rem; color: var(--ink); }
.acct-progress { font-size: 0.86rem; color: var(--ink-2); }
.acct-link { display: grid; gap: 8px; padding: 14px 16px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--good) 40%, var(--border)); background: color-mix(in srgb, var(--good) 7%, var(--surface)); }
.acct-link-row { display: flex; gap: 8px; }
.acct-link-row input { flex: 1; min-width: 0; font-size: 0.82rem; }
.acct-people td { vertical-align: middle; }
.acct-people .pe-select { width: auto; min-width: 150px; }
.acct-off td { opacity: .6; }
.guide { display: grid; gap: 18px; margin-top: 16px; }
.guide-step { display: grid; gap: 8px; }
.guide ol, .guide ul { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 0.9rem; line-height: 1.5; }
.guide ul { gap: 2px; margin-top: 4px; }
.guide code { font-size: 0.86rem; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.guide-options { display: grid; gap: 10px; }
.guide-option { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.guide-option[open] { display: grid; gap: 12px; }
.guide-option > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 0.95rem; }
.welcome { display: grid; gap: 6px; }
.welcome h2 { font-size: 1.4rem; }
.plan-empty { display: grid; gap: 12px; justify-items: center; text-align: center; }
.plan-empty p { max-width: 460px; }

@media (max-width: 760px) {
  .acct-tabs { padding: 10px 16px 0; }
  .acct-link-row { flex-direction: column; }
}

@media print {
  .topbar, .toasts, #refresh-btn, .ribbon { display: none !important; }
  body { background: #fff; }
  .card, .cost-tile { box-shadow: none; break-inside: avoid; }
}
