/* TRING design tokens */
:root {
  --fx-light: oklch(0.2 0.01 260);
  --fx-edge: 0.25;
  --bg: oklch(0.965 0.002 260);
  --surface: oklch(0.995 0 0);
  --surface-2: oklch(0.955 0.003 260);
  --surface-3: oklch(0.925 0.004 260);
  --text: oklch(0.2 0.006 260);
  --muted: oklch(0.5 0.008 260);
  --border: oklch(0.9 0.004 260);
  --grid: oklch(0.2 0.006 260 / 0.06);
  --accent: oklch(0.56 0.16 248);
  --accent-ink: oklch(0.99 0 0);
  --accent-soft: oklch(0.94 0.03 248);
  --success: oklch(0.52 0.14 152);
  --danger: oklch(0.55 0.2 15);
  --warning: oklch(0.55 0.13 70);
  --highlight: inset 0 1px 0 oklch(1 0 0 / 0.7);
  --shadow: 0 1px 2px oklch(0.2 0 0 / 0.04), 0 6px 20px oklch(0.2 0 0 / 0.05);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.135 0.003 260);
    --surface: oklch(0.185 0.004 260);
    --surface-2: oklch(0.225 0.005 260);
    --surface-3: oklch(0.265 0.006 260);
    --text: oklch(0.95 0.003 260);
    --muted: oklch(0.68 0.008 260);
    --border: oklch(0.27 0.006 260);
    --grid: oklch(1 0 0 / 0.05);
    --accent: oklch(0.7 0.15 245);
    --accent-ink: oklch(0.15 0.02 250);
    --accent-soft: oklch(0.28 0.06 250);
    --success: oklch(0.78 0.16 152);
    --danger: oklch(0.7 0.19 5);
    --warning: oklch(0.8 0.13 80);
    --highlight: inset 0 1px 0 oklch(1 0 0 / 0.045);
    --shadow: 0 1px 0 oklch(0 0 0 / 0.3), 0 10px 30px oklch(0 0 0 / 0.25);
    --fx-light: oklch(1 0 0);
    --fx-edge: 0.35;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
@media (min-width: 900px) { .topbar h1 { font-size: 28px; } }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.up { color: var(--success); }
.down { color: var(--danger); }
.i { flex: none; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eyebrow { display: block; margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Shell: content plus a floating bottom tab bar on every screen size */
.app { min-height: 100dvh; }
.nav {
  position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 24px));
  display: flex; justify-content: space-around; gap: 2px; padding: 6px;
  border-radius: 22px; border: 1px solid var(--border);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 24px oklch(0 0 0 / 0.25);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; border-radius: 16px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
  transition: background-color 150ms ease-out, color 150ms ease-out;
}
.nav a[aria-current='page'] { color: var(--text); background: var(--surface-3); }
.nav a[aria-current='page'] .i { color: var(--accent); }
.main { min-width: 0; padding: 0 16px calc(104px + env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1200px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 0 14px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
#view { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) {
  .main { padding: 0 32px calc(112px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: 18px; }
}

/* ---------- Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 150ms ease-out, transform 150ms ease-out;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn.spinning .i { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { border: 0; padding: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.grow { flex: 1; }
.field.inline select { min-width: 0; }
label, .label { font-size: 14px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
}
textarea { resize: vertical; line-height: 1.4; }
/* One chevron for every select, the same in light and dark */
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b909a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 25%, transparent); }
.hint { font-size: 13px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .row-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.check:has(input:disabled) { color: var(--muted); cursor: default; }
.select-sm { width: auto; min-height: 36px; padding: 4px 30px 4px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; }

.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; max-width: 100%; }
.seg.wrap { flex-wrap: wrap; border-radius: 18px; }
.seg.full { display: flex; align-self: stretch; }
.seg.full label { flex: 1; min-width: 0; }
.seg.full span { justify-content: center; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .seg.full span { font-size: 13px; } }
.seg label { position: relative; display: block; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: var(--highlight); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg small { font-weight: 400; }

/* ---------- Surfaces: page → panel → inset box, like Trading 212 */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 20px; box-shadow: var(--highlight), var(--shadow); min-width: 0;
}
.box { display: flex; flex-direction: column; padding: 4px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); box-shadow: var(--highlight); }
.stat { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 500; text-align: right; }
.stat:last-child { border-bottom: 0; }
.stat .eyebrow { text-align: left; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar.end { justify-content: flex-end; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 360px) { .grid { grid-template-columns: 1fr; } }
.two-col { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: 3fr 2fr; } }
.footnote { font-size: 13px; color: var(--muted); max-width: 70ch; }
.banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px; border-radius: 20px; background: var(--accent-soft); border: 1px solid color-mix(in oklch, var(--accent) 30%, transparent); }
.banner > div { flex: 1; min-width: 200px; }
.banner p { font-size: 14px; color: var(--muted); }
.empty { text-align: left; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; padding: 32px 24px; }
.empty h2 { margin: 0; }
.empty .btn { margin-top: 8px; }
.skeleton { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; flex: none; vertical-align: middle; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip.buy { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.chip.sell { background: color-mix(in oklch, var(--danger) 15%, transparent); color: var(--danger); }
.chip.split { background: color-mix(in oklch, var(--accent) 15%, transparent); color: var(--accent); }

/* Asset monogram tile */
.avatar {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--c); background: color-mix(in oklch, var(--c) 18%, var(--surface-2));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--c) 30%, transparent);
}
.avatar.cash { --c: var(--muted); }
.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.avatar.sm { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }
.tx-main strong .chip { margin-left: 6px; vertical-align: 1px; }

/* ---------- Asset card (Markets) */
.asset { display: flex; flex-direction: column; gap: 14px; }
.asset-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.asset-id { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.asset-id h3 { overflow-wrap: anywhere; }
.price-block { text-align: right; flex: none; }
.price { font-size: 20px; font-weight: 600; }
.ath-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); }
.ath-row > div { display: flex; flex-direction: column; gap: 2px; }
.ath-row .right { text-align: right; align-items: flex-end; }
.big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; transition: width 250ms ease-out; }
.card-actions { display: flex; align-items: center; gap: 4px; margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.card-actions .icon-btn { margin-left: auto; }
.card-error { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r-md); background: color-mix(in oklch, var(--danger) 8%, transparent); color: var(--text); font-size: 14px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-list:empty { display: none; }
.pick { display: flex; justify-content: space-between; gap: 8px; align-items: center; min-height: 48px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }

/* ---------- KPIs, tables, lists */
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.card .kpis { margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi strong { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
.tx-list, .schedule, .legend-list, .hold-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tx-list li:last-child { border-bottom: 0; }
.tx-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tx-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule { max-height: 420px; overflow-y: auto; }
.schedule li { display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); }
.schedule li:last-child { border-bottom: 0; }
.schedule li.done > span:not(.chip) { color: var(--muted); }
.schedule .btn, .schedule .chip, .schedule li > span:last-child { justify-self: end; }

/* ---------- Line chart (Revolut style) */
.lc {
  position: relative; height: var(--lc-h, 220px); margin: 0 -20px;
  touch-action: pan-y; cursor: crosshair;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.lc svg { display: block; width: 100%; height: 100%; overflow: visible; }
.lc-grid line { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lc-end, .lc-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--lc-c); pointer-events: none; }
.lc-end { box-shadow: 0 0 0 4px color-mix(in oklch, var(--lc-c) 25%, transparent); animation: pulse 2.4s ease-out infinite; }
.lc-dot { width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--lc-c); }
.lc-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: 0.5; pointer-events: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--lc-c) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 10px transparent; } }
.lc-legend { display: flex; gap: 16px; margin-top: 8px; }
.sw { display: inline-block; width: 14px; height: 2px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.sw.dashed { background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px); }
.chart-empty { display: grid; place-items: center; min-height: 160px; }
.ranges { display: flex; justify-content: space-between; gap: 2px; margin-top: 12px; }
.ranges label { position: relative; flex: 1; display: block; }
.ranges input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.ranges span { display: grid; place-items: center; min-height: 36px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ranges input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: var(--highlight); }
.ranges input:focus-visible + span { outline: 2px solid var(--accent); }

.alloc { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.donut { flex: none; }
.donut-center { font: 600 14px Inter, system-ui, sans-serif; fill: var(--text); font-variant-numeric: tabular-nums; }
.legend-list { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.legend-list li { display: flex; align-items: center; gap: 8px; }
.legend-list li span:first-of-type { flex: 1; }
.legend-list i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-list.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 16px; }

/* ---------- Portfolio */
.port { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'perf' 'returns' 'hold' 'breakdown' 'expo' 'income' 'alloc' 'tx'; }
.perf { grid-area: perf; overflow: hidden; background: radial-gradient(120% 60% at 50% 100%, color-mix(in oklch, var(--surface-2) 70%, transparent), transparent 70%), var(--surface); }
.returns { grid-area: returns; }
.breakdown { grid-area: breakdown; padding: 12px; }
.holdings-panel { grid-area: hold; padding: 12px; }
.alloc-panel { grid-area: alloc; }
.tx-panel { grid-area: tx; }
.income-panel { grid-area: income; }
.expo-panel { grid-area: expo; }
.income-panel > .eyebrow, .expo-panel > .eyebrow { margin-bottom: 12px; }
.income-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.income-empty p { max-width: 60ch; }
.income-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .income-grid { grid-template-columns: 1fr 1fr; } }
.bar { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.div-years { display: grid; gap: 8px; margin-top: 16px; }
.div-year { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; }
.payers { margin-top: 12px; }
.income-panel .warn { margin-top: 12px; }
.expo-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.expo-kpis strong { display: block; font-size: 18px; font-weight: 600; }
.expo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.expo-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 15px; }
.expo-name { font-weight: 600; }
.expo-list p { margin-top: 6px; }
.expo-panel .expo-list + p { margin-top: 14px; }
/* Phones: the two column wrappers dissolve, so every panel follows the grid areas above */
.port-main, .port-side { display: contents; }
@media (min-width: 1000px) {
  /* Desktop: holdings stay in view beside the taller right column, so no empty gap opens below them */
  .port { grid-template-columns: 380px minmax(0, 1fr); grid-template-areas: 'side main' 'income income' 'alloc alloc' 'tx tx'; }
  .port-main { grid-area: main; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
  .port-side { grid-area: side; display: block; min-width: 0; }
  /* .port-side prefix: outranks the light-effect rule's position: relative (sticky still anchors the effect) */
  .port-side > .holdings-panel.panel { position: sticky; top: calc(88px + env(safe-area-inset-top)); max-height: calc(100dvh - 88px - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
  .holdings-panel .hold-list { overflow-y: auto; margin: 0 -12px; padding: 0 12px; overscroll-behavior: contain; }
}
.perf { position: relative; }
.perf-head { margin-bottom: 12px; }
.perf-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; user-select: none; -webkit-user-select: none; }
.perf-actions { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 2px; }
.hero { font-size: 40px; font-weight: 700; letter-spacing: -0.035em; line-height: 1.1; white-space: nowrap; }
.hero small { font-size: 0.6em; letter-spacing: -0.01em; color: var(--muted); }
.perf-sub { min-height: 21px; font-weight: 500; }
@media (max-width: 420px) { .hero { font-size: 34px; } }

.returns .eyebrow:first-child { margin-bottom: 12px; }
.pnl-grid { display: grid; gap: 1px; grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: var(--r-lg); overflow: hidden; background: var(--border); border: 1px solid var(--border); }
.returns { container-type: inline-size; }
@container (min-width: 420px) { .pnl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (min-width: 720px) { .pnl-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.pnl { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--surface-2); min-width: 0; }
.pnl strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pnl .small { font-size: 13px; }

.hold-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 6px 10px; }
.hold-total { display: block; font-size: 17px; font-weight: 600; }
.search { position: relative; margin-bottom: 6px; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 42px; border-radius: 999px; }
.hold { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px; border: 0; border-radius: var(--r-md); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; transition: background-color 120ms ease-out; }
.hold-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hold-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hold-sub { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hold-right { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.hold-val { font-weight: 600; font-size: 15px; }
.hold-right .small { font-size: 12px; font-weight: 500; }
.hold-empty { padding: 16px 10px; }

.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; min-height: 32px; white-space: nowrap; }
.tx-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tx-head h2 { margin: 0; }
.tx-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0 8px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }

/* Asset detail sheet */
.detail { display: flex; flex-direction: column; gap: 14px; }
.detail-id { display: flex; align-items: center; gap: 10px; }
.detail .lc { margin: 0 -20px; }
.detail .ranges { margin-top: 0; }
.detail h3.eyebrow { margin-top: 6px; }
.detail-actions { display: flex; gap: 8px; align-items: center; position: sticky; bottom: 0; padding-top: 4px; background: var(--surface); }

/* ---------- Plan */
.plan-layout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .plan-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.alloc-rows { flex: 1; min-width: min(100%, 320px); display: flex; flex-direction: column; gap: 8px; }
.alloc-row { display: flex; flex-direction: column; gap: 8px; padding: 8px 4px 10px 12px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.alloc-row input { background: var(--surface); }
.alloc-main { display: flex; align-items: center; gap: 8px; }
.alloc-main .dot { margin-right: 0; }
.alloc-main .pct-input { width: 80px; }
.alloc-main .icon-btn { width: 36px; }
.alloc-target { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding-left: 18px; }
.alloc-target label { font-size: 13px; }
.ccy-input { position: relative; width: 148px; flex: none; }
.ccy-input input { min-height: 36px; padding: 6px 46px 6px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.ccy-input span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 600; color: var(--muted); pointer-events: none; }
.alloc-out { margin-left: auto; padding-right: 10px; font-size: 15px; white-space: nowrap; }
.alloc-out strong { font-weight: 700; }
.alloc-note { margin: 0; padding: 0 10px 0 18px; }
.alloc-note .link-btn { color: var(--accent); text-decoration: none; min-height: 24px; }
.alloc-cols { display: flex; justify-content: space-between; padding: 0 48px 0 30px; font-weight: 500; }
.alloc-head .field.inline .label { font-size: 13px; }
/* One colour job each: the asset dot is identity, blue marks the active choice, green/red the outcome */
.alloc-head .seg input:checked + span, .seg.mini input:checked + span { background: var(--accent-soft); color: var(--accent); }
.alloc-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 12px; }
.alloc-head h2 { margin: 0; }
.seg.mini { padding: 2px; }
.seg.mini span { min-height: 32px; padding: 0 10px; font-size: 13px; }

/* Instrument search (combobox) */
.combo { position: relative; flex: 1; min-width: 0; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  margin: 0; padding: 6px; list-style: none; max-height: 344px; overflow-y: auto; min-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--highlight), 0 16px 40px oklch(0 0 0 / 0.28); animation: pop-in 150ms ease-out;
}
.combo-list.inline { position: static; min-width: 0; margin-top: 8px; max-height: 52dvh; box-shadow: none; animation: none; background: var(--surface-2); }
.combo-opt { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.combo-opt.active { background: var(--surface-3); }
.combo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.combo-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-opt .chip { flex: none; }
.combo-note { padding: 10px 8px; }
/* An open list must sit above the cards that follow */
.card:has(.combo-input[aria-expanded='true']) { z-index: 5; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.manual { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--border); }
.manual summary { display: flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.manual[open] summary { margin-bottom: 8px; }

/* Plan setup: three labelled groups; stays in view beside the allocation on tall desktop screens */
.setup-group { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-top: 16px; border-top: 1px solid var(--border); }
.setup .seg.full span { min-height: 40px; }
.setup-sum { margin: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 14px; }
.setup-sum strong { font-weight: 600; }
.affix { position: relative; }
.affix input { padding-right: 56px; }
.affix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 600; color: var(--muted); pointer-events: none; }
@media (min-width: 1100px) and (min-height: 820px) {
  .plan-layout > .card.setup { position: sticky; top: calc(88px + env(safe-area-inset-top)); align-self: start; }
}

/* Plan allocation treemap */
.plan-alloc { display: flex; flex-direction: column; gap: 14px; }
.tm { position: relative; }
.tm-cell { position: absolute; outline: none; }
.tm-in {
  position: absolute; inset: 2px; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px;
  padding: 10px 12px; overflow: hidden; border-radius: 10px; cursor: default;
  color: oklch(0.17 0.02 260);
  background: linear-gradient(155deg, color-mix(in oklch, var(--c) 78%, white), var(--c) 45%, color-mix(in oklch, var(--c) 82%, black));
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.3), inset 0 0 0 1px oklch(0 0 0 / 0.12);
}
.tm-cell.md .tm-in { padding: 6px 8px; }
.tm-cell.sm .tm-in { padding: 0; }
.tm-name { font-size: 14px; font-weight: 700; line-height: 1.2; }
.tm-val { font-size: 12px; font-weight: 600; opacity: 0.8; }
.tm-name, .tm-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-cell.md .tm-full, .tm-cell.lg .tm-short { display: none; }
.tm-cell.sm .tm-name, .tm-cell.sm .tm-val { display: none; }
.tm-more { display: none; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid oklch(0 0 0 / 0.15); font-size: 13px; }
.tm-more div { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.tm-more dt { opacity: 0.75; font-weight: 500; }
.tm-more dd { margin: 0; font-weight: 700; }
.tm-more .up, .tm-more .down { color: inherit; }
.tm-caption { margin-top: 6px; }
/* Pop-out: the tile lifts above its neighbours and grows (toward the middle) to show everything */
.tm-cell:is(:hover, :focus-visible) { z-index: 5; }
.tm-cell:is(:hover, :focus-visible) .tm-in {
  right: auto; bottom: auto; justify-content: flex-start;
  min-width: max(calc(100% - 4px), 220px); min-height: max(calc(100% - 4px), 64px); padding: 12px 14px;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.3), 0 0 0 2px color-mix(in oklch, var(--c) 60%, white), 0 14px 36px oklch(0 0 0 / 0.45);
  animation: tm-pop 160ms ease-out;
}
.tm-cell.ax-r:is(:hover, :focus-visible) .tm-in { left: auto; right: 2px; }
.tm-cell.ay-b:is(:hover, :focus-visible) .tm-in { top: auto; bottom: 2px; }
.tm-cell:is(:hover, :focus-visible) :is(.tm-name, .tm-val) { display: block; }
.tm-cell:is(:hover, :focus-visible) .tm-full { display: inline; }
.tm-cell:is(:hover, :focus-visible) .tm-short { display: none; }
.tm-cell:is(:hover, :focus-visible) .tm-more { display: block; }
@keyframes tm-pop { from { transform: scale(0.97); opacity: 0.7; } }

/* Plan result */
.plan-hero { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: center; margin-bottom: 20px; }
@media (min-width: 900px) { .plan-hero { grid-template-columns: minmax(280px, 2fr) 3fr; } }
.plan-gain { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--highlight); }
.plan-gain .hero { font-size: 36px; }
.card .plan-hero .kpis { margin-bottom: 0; }
#plan-results .footnote { margin-top: 14px; }
.pct-input { position: relative; width: 96px; flex: none; }
.pct-input input { padding-right: 28px; text-align: right; }
.pct-input span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#alloc-sum { display: flex; align-items: center; gap: 6px; }
#alloc-sum.ok { color: var(--success); }
#alloc-sum.warn { color: var(--warning); }

/* ---------- AI */
.ai-controls { display: flex; flex-direction: column; gap: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick .field.inline { min-width: 220px; }
.chat { display: flex; flex-direction: column; gap: 16px; min-height: 200px; }
.chat-empty { display: flex; flex-direction: column; gap: 6px; max-width: 60ch; }
.chat-empty h2 { margin: 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px 18px 4px 18px; background: var(--surface-3); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai { max-width: 100%; }
.msg.error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); color: var(--danger); background: color-mix(in oklch, var(--danger) 8%, transparent); font-size: 14px; }
.msg-meta { margin-bottom: 4px; }
.prose { overflow-wrap: anywhere; line-height: 1.6; }
.prose > * + * { margin-top: 10px; }
.prose h3, .prose h4 { font-size: 16px; margin-top: 18px; }
.prose ul, .prose ol { padding-left: 22px; margin-bottom: 0; }
.prose li + li { margin-top: 4px; }
.prose code { font-size: 14px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.prose table { font-size: 14px; }
.sources { margin-top: 10px; font-size: 14px; color: var(--muted); }
.sources summary { cursor: pointer; min-height: 32px; }
.sources ol { padding-left: 20px; margin: 4px 0 0; }
.chat-foot { display: flex; justify-content: flex-end; }
.composer { position: sticky; bottom: calc(92px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 6px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--highlight), var(--shadow); }
.composer textarea { border: 0; min-height: 44px; max-height: 200px; box-shadow: none; background: transparent; }
.composer .btn { width: 44px; padding: 0; flex: none; }

/* ---------- Toasts and sheet */
.toasts { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 8px 24px oklch(0 0 0 / 0.2); animation: toast-in 200ms ease-out; }
.toast.error { background: var(--danger); color: oklch(0.99 0 0); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 200ms ease-out, transform 200ms ease-out; }
.toast-btn { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; min-height: 32px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 1px solid var(--border); border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--text); box-shadow: var(--highlight), 0 -8px 40px oklch(0 0 0 / 0.3);
}
dialog.sheet[open] { animation: sheet-in 220ms ease-out; }
dialog.sheet::backdrop { background: oklch(0.05 0 0 / 0.55); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 24px; } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet-inner { display: flex; flex-direction: column; max-height: 92dvh; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 8px 20px; }
.sheet-head h2 { margin: 0; }
.sheet-body { overflow-y: auto; overflow-x: hidden; padding: 4px 20px calc(20px + env(safe-area-inset-bottom)); }

.sync-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); }
.sync-pill.ok { color: var(--success); }
.sync-pill.error { color: var(--danger); }
.sync-pill[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- Active AI, provider blocks */
.active-ai { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.active-ai strong { color: var(--text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.prov { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.prov-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; }

/* ---------- Sign-in gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.gate-brand { display: flex; align-items: center; gap: 14px; }
.gate-brand img { border-radius: 14px; }
.gate-brand h1 { letter-spacing: 0.08em; }
.btn.google { min-height: 48px; font-weight: 600; }

/* ---------- Import */
.imp-summary { display: flex; flex-direction: column; gap: 16px; }
.imp-summary:empty { display: none; }
.imp-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; box-shadow: none; background: var(--surface-2); }
p.warn { color: var(--warning); }

/* ---------- Hover only where a mouse exists; touch gets press feedback instead */
@media (hover: hover) and (pointer: fine) {
  .nav a:hover { color: var(--text); }
  .btn:hover { background: var(--surface-3); }
  .btn.primary:hover { background: color-mix(in oklch, var(--accent) 88%, var(--text)); }
  .btn.ghost:hover { background: var(--surface-2); }
  .icon-btn:hover { background: var(--surface-2); color: var(--text); }
  .asset-id:hover h3 { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
  .pick:hover { border-color: var(--accent); }
  .hold:hover { background: var(--surface-2); }
  .combo-opt:hover { background: var(--surface-3); }
  .cn-link:hover { opacity: 1; transform: translateX(2px); }
}
.hold:active, .icon-btn:active, .pick:active { background: var(--surface-2); }

/* ---------- Light effects (js/fx.js). --fx-x/--fx-y: light position in the element, --fx-o: strength */
.card:not(.no-fx), .panel:not(.no-fx) { position: relative; isolation: isolate; }
/* Spotlight Card: a brighter rim near the pointer (no fill inside the card) */
.card:not(.no-fx)::after, .panel:not(.no-fx)::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  opacity: var(--fx-o, 0);
}
.card:not(.no-fx)::after, .panel:not(.no-fx)::after {
  padding: 1px; z-index: 1;
  background: radial-gradient(180px circle at var(--fx-x, 50%) var(--fx-y, 50%), color-mix(in oklch, var(--fx-light) calc(var(--fx-edge) * 100%), transparent), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
/* Border Glow (after React Bits): with a mouse, a colored border and outer glow light up on the edge
   nearest the pointer. js/fx.js sets html.bglow, --edge-proximity (0-100) and --cursor-angle per card,
   and adds the .edge-light layer. Phones keep the tilt rim above. */
:root {
  --bg-glow: 214deg 95% 74%;
  --bg-c1: #5aa2ff; --bg-c2: #38bdf8; --bg-c3: #8ea2ff;
  --bg-blend: plus-lighter; --bg-fill-blend: soft-light; --bg-fill: 0.35;
}
@media (prefers-color-scheme: light) {
  :root { --bg-glow: 214deg 85% 52%; --bg-blend: normal; --bg-fill-blend: normal; --bg-fill: 0.12; }
}
.bglow :is(.card, .panel):not(.no-fx) {
  --edge-proximity: 0; --cursor-angle: 45deg;
  --edge-sensitivity: 30; --color-sensitivity: 50; --cone-spread: 25; --glow-padding: 40px; --fill-opacity: var(--bg-fill);
  --card-bg: var(--surface);
  --g1: radial-gradient(at 80% 55%, var(--bg-c1) 0px, transparent 50%);
  --g2: radial-gradient(at 69% 34%, var(--bg-c2) 0px, transparent 50%);
  --g3: radial-gradient(at 8% 6%, var(--bg-c3) 0px, transparent 50%);
  --g4: radial-gradient(at 41% 38%, var(--bg-c1) 0px, transparent 50%);
  --g5: radial-gradient(at 86% 85%, var(--bg-c2) 0px, transparent 50%);
  --g6: radial-gradient(at 82% 18%, var(--bg-c3) 0px, transparent 50%);
  --g7: radial-gradient(at 51% 4%, var(--bg-c2) 0px, transparent 50%);
  --gbase: linear-gradient(var(--bg-c1) 0 100%);
}
.bglow :is(.card, .panel):not(.no-fx)::before,
.bglow :is(.card, .panel):not(.no-fx)::after,
.bglow :is(.card, .panel):not(.no-fx) > .edge-light {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  padding: 0; -webkit-mask: none; mask: none;
  transition: opacity 250ms ease-out;
}
.bglow :is(.card, .panel):not(.no-fx):not(:hover)::before,
.bglow :is(.card, .panel):not(.no-fx):not(:hover)::after,
.bglow :is(.card, .panel):not(.no-fx):not(:hover) > .edge-light { opacity: 0; transition: opacity 750ms ease-in-out; }
/* Mesh-gradient border, shown in a cone toward the pointer */
.bglow :is(.card, .panel):not(.no-fx)::before {
  border: 1px solid transparent;
  background: linear-gradient(var(--card-bg) 0 100%) padding-box,
    var(--g1) border-box, var(--g2) border-box, var(--g3) border-box, var(--g4) border-box,
    var(--g5) border-box, var(--g6) border-box, var(--g7) border-box, var(--gbase) border-box;
  opacity: calc((var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)));
  -webkit-mask-image: conic-gradient(from var(--cursor-angle) at center, black calc(var(--cone-spread) * 1%), transparent calc((var(--cone-spread) + 15) * 1%), transparent calc((100 - var(--cone-spread) - 15) * 1%), black calc((100 - var(--cone-spread)) * 1%));
  mask-image: conic-gradient(from var(--cursor-angle) at center, black calc(var(--cone-spread) * 1%), transparent calc((var(--cone-spread) + 15) * 1%), transparent calc((100 - var(--cone-spread) - 15) * 1%), black calc((100 - var(--cone-spread)) * 1%));
}
/* Faint tint just inside the lit edge (the middle of the card stays clear) */
.bglow :is(.card, .panel):not(.no-fx)::after {
  border: 1px solid transparent;
  background: var(--g1) padding-box, var(--g2) padding-box, var(--g3) padding-box, var(--g4) padding-box,
    var(--g5) padding-box, var(--g6) padding-box, var(--g7) padding-box, var(--gbase) padding-box;
  mask-image: linear-gradient(to bottom, black, black),
    radial-gradient(ellipse at 50% 50%, black 40%, transparent 65%),
    radial-gradient(ellipse at 66% 66%, black 5%, transparent 40%),
    radial-gradient(ellipse at 33% 33%, black 5%, transparent 40%),
    radial-gradient(ellipse at 66% 33%, black 5%, transparent 40%),
    radial-gradient(ellipse at 33% 66%, black 5%, transparent 40%),
    conic-gradient(from var(--cursor-angle) at center, transparent 5%, black 15%, black 85%, transparent 95%);
  mask-composite: subtract, add, add, add, add, add;
  opacity: calc(var(--fill-opacity) * (var(--edge-proximity) - var(--color-sensitivity)) / (100 - var(--color-sensitivity)));
  mix-blend-mode: var(--bg-fill-blend);
}
/* Outer glow */
.bglow :is(.card, .panel):not(.no-fx) > .edge-light {
  inset: calc(var(--glow-padding) * -1); z-index: 1;
  -webkit-mask-image: conic-gradient(from var(--cursor-angle) at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%);
  mask-image: conic-gradient(from var(--cursor-angle) at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%);
  opacity: calc((var(--edge-proximity) - var(--edge-sensitivity)) / (100 - var(--edge-sensitivity)));
  mix-blend-mode: var(--bg-blend);
}
.bglow :is(.card, .panel):not(.no-fx) > .edge-light::before {
  content: ''; position: absolute; inset: var(--glow-padding); border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px hsl(var(--bg-glow) / 100%), inset 0 0 1px 0 hsl(var(--bg-glow) / 60%), inset 0 0 3px 0 hsl(var(--bg-glow) / 50%),
    inset 0 0 6px 0 hsl(var(--bg-glow) / 40%), inset 0 0 15px 0 hsl(var(--bg-glow) / 30%), inset 0 0 25px 2px hsl(var(--bg-glow) / 20%),
    inset 0 0 50px 2px hsl(var(--bg-glow) / 10%),
    0 0 1px 0 hsl(var(--bg-glow) / 60%), 0 0 3px 0 hsl(var(--bg-glow) / 50%), 0 0 6px 0 hsl(var(--bg-glow) / 40%),
    0 0 15px 0 hsl(var(--bg-glow) / 30%), 0 0 25px 2px hsl(var(--bg-glow) / 20%), 0 0 50px 2px hsl(var(--bg-glow) / 10%);
}
.edge-light { display: none; }
.bglow .edge-light { display: block; }

/* ---------- Card Nav (quick actions) */
.menu-btn { position: relative; width: 44px; height: 44px; flex: none; border: 0; border-radius: 999px; background: transparent; cursor: pointer; }
.menu-btn span { position: absolute; left: 13px; right: 13px; height: 2px; border-radius: 2px; background: var(--text); transition: transform 220ms ease-out, top 220ms ease-out; }
.menu-btn span:first-child { top: 18px; }
.menu-btn span:last-child { top: 24px; }
.menu-btn.open span:first-child { top: 21px; transform: rotate(45deg); }
.menu-btn.open span:last-child { top: 21px; transform: rotate(-45deg); }
.cardnav { max-width: 1200px; margin: 0 auto; display: grid; grid-template-rows: 0fr; transition: grid-template-rows 260ms ease-out; }
.cardnav.open { grid-template-rows: 1fr; }
.cardnav-inner { min-height: 0; overflow: hidden; display: grid; gap: 8px; grid-template-columns: 1fr; }
.cardnav.open .cardnav-inner { padding-bottom: 12px; }
@media (min-width: 700px) { .cardnav-inner { grid-template-columns: repeat(3, 1fr); } }
.cn-card {
  display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 18px; border: 1px solid var(--border);
  box-shadow: var(--highlight); opacity: 0; transform: translateY(16px);
  transition: opacity 240ms ease-out, transform 240ms ease-out; transition-delay: calc(var(--i) * 50ms);
}
.cardnav.open .cn-card { opacity: 1; transform: none; }
.cn-a { background: var(--surface); }
.cn-b { background: var(--surface-2); }
.cn-c { background: color-mix(in oklch, var(--accent) 12%, var(--surface)); }
.cn-label { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 8px; }
.cn-link { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px; text-align: left; cursor: pointer; opacity: 0.85; transition: opacity 150ms ease-out, transform 150ms ease-out; }
.cn-link .i { color: var(--muted); }
.cn-link:active { opacity: 1; }
@media (max-width: 699px) {
  .cn-card { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 16px; padding: 12px 16px; }
  .cn-label { width: 100%; font-size: 17px; margin-bottom: 0; }
}

/* Header split: investments and cash */
.perf-split { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--muted); font-weight: 500; }
.perf-split > * { display: inline-flex; align-items: center; gap: 6px; }
.perf-split .link-btn { text-decoration: none; color: inherit; min-height: 24px; }
.sw-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }

/* Sticky top bar: page background behind it once the page scrolls */
.topbar { position: sticky; top: 0; z-index: 15; }
/* Full-width backdrop as its own layer. (The old giant box-shadow + clip-path could lose its clip for a
   frame while scrolling, painting the page colour over everything: the blank-screen flash.) */
.topbar::before {
  content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%);
  background: var(--bg); border-bottom: 1px solid var(--border); opacity: 0; transition: opacity 150ms ease-out; pointer-events: none;
}
body { overflow-x: clip; }
/* Same size in both states: changing its padding here moved the page and toggled the state back, which flickered */
body.scrolled .topbar::before { opacity: 1; }
/* While the page scrolls, cards sliding under a still mouse don't trigger hover (tile pop-outs, edge glow) */
html.scrolling #view { pointer-events: none; }
.cardnav { position: sticky; top: calc(72px + env(safe-area-inset-top)); z-index: 14; }
@media (min-width: 900px) { .cardnav { top: calc(76px + env(safe-area-inset-top)); } }
