:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --hover: rgba(11, 11, 11, 0.04);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e8e7e1;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --up: #0a7d0a;
  --down: #c62f2f;
  --up-bg: rgba(12, 163, 12, 0.10);
  --down-bg: rgba(208, 59, 59, 0.10);
  --up-mark: #0ca30c;
  --down-mark: #d03b3b;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --other: #b9b8b0;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --hover: rgba(255,255,255,0.05);
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255,255,255,0.09);
    --up: #2fc12f; --down: #ef6b6b; --up-bg: rgba(12,163,12,.16); --down-bg: rgba(230,103,103,.16);
    --up-mark: #0ca30c; --down-mark: #e66767;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --other: #5c5b56;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321; --hover: rgba(255,255,255,0.05);
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255,255,255,0.09);
  --up: #2fc12f; --down: #ef6b6b; --up-bg: rgba(12,163,12,.16); --down-bg: rgba(230,103,103,.16);
  --up-mark: #0ca30c; --down-mark: #e66767;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --other: #5c5b56;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.num, td, .kv b { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Accounts bar */
.acct-bar { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.acct-bar::-webkit-scrollbar { display: none; }
.acct { flex: none; display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; font-weight: 600; white-space: nowrap; }
.acct:hover { color: var(--ink); background: var(--surface-2); }
.acct.on { color: var(--ink); border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.acct-v { color: var(--muted); font-weight: 550; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.acct.add { border-style: dashed; color: var(--muted); }
.acct.editing { padding: 4px 6px 4px 4px; gap: 4px; cursor: default; }
.acct-name-in { border: 0; outline: none; background: var(--surface-2); border-radius: 7px; padding: 5px 9px; font-weight: 600; width: 160px; }
.acct-mini { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.acct-mini:hover { background: var(--hover); color: var(--ink); }
.acct-mini.danger:hover { background: var(--down-bg); color: var(--down); }
.grid select.acct-sel { border: 0; background: transparent; padding: 9px 6px; border-radius: 6px; cursor: pointer; color: var(--ink-2); max-width: 150px; }
.grid select.acct-sel:hover { background: var(--hover); }
.grid select.acct-sel:focus { outline: 2px solid var(--series-1); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.tabs { display: flex; gap: 4px; }
.tab { white-space: nowrap; background: none; border: 0; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); cursor: pointer; font-weight: 550; }
.tab:hover { background: var(--hover); color: var(--ink); }
.tab.active { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.updated { color: var(--muted); font-size: 12px; margin-right: 6px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding-top: 22px; padding-bottom: 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin-bottom: 18px; }

.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 550; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--series-1); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { padding: 4px 8px; font-size: 12px; }

/* Delta pills */
.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.pill { display: inline-block; padding: 2px 7px; border-radius: 6px; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.pill.up { color: var(--up); background: var(--up-bg); }
.pill.down { color: var(--down); background: var(--down-bg); }
.pill.flat { color: var(--ink-2); background: var(--surface-2); }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 28px; align-items: center; }
.label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hero-value { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 4px 0 8px; }
.hero-deltas { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; }
.hero-deltas .sep { width: 1px; height: 14px; background: var(--border); margin: 0 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.stat { background: var(--surface); padding: 12px 14px; min-width: 0; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 17px; font-weight: 650; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; margin-top: 1px; }

/* Charts */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: color-mix(in srgb, var(--surface) 70%, transparent); font-size: 13px; }
.legend { display: flex; gap: 16px; margin: -4px 0 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px) !important; }

.alloc { display: grid; grid-template-columns: 200px minmax(0,1fr); gap: 20px; align-items: center; }
.donut-box { position: relative; height: 220px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.donut-center span { color: var(--muted); font-size: 12px; }
.alloc-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.alloc-legend li { display: grid; grid-template-columns: 10px minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 5px 6px; border-radius: 6px; font-size: 13px; cursor: default; }
.alloc-legend li:hover, .alloc-legend li.hl { background: var(--hover); }
.alloc-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.alloc-legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-legend .pc { font-weight: 650; font-variant-numeric: tabular-nums; }
.alloc-legend .vl { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.alloc-legend .pc { min-width: 46px; text-align: right; }

/* Markets widget */
.mkt-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.mkt-tile { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 11px 13px; cursor: pointer; min-width: 0; display: grid; gap: 3px; color: var(--ink); }
.mkt-tile:hover { background: var(--surface-2); }
.mkt-tile.on { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.mkt-tile .mk { font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkt-tile .mv { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mkt-tile .mc { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mkt-tile .mc.up { color: var(--up); } .mkt-tile .mc.down { color: var(--down); } .mkt-tile .mc.flat { color: var(--muted); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
@media (max-width: 760px) { .mkt-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Insights / news / calendar card */
.grid-2.wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: start; }
.side-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); width: 100%; }
.side-card .card-head { margin-bottom: 12px; }
.side-card .card-head > .side-tabs { flex: 1; }
.side-tabs button { border: 0; background: none; padding: 0 0 10px; margin-bottom: -1px; font-size: 15px; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.side-tabs button:hover { color: var(--ink); }
.side-tabs button.on { color: var(--ink); border-bottom-color: var(--series-1); }
.scroll { max-height: 560px; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
.pad { padding: 14px 2px; }
.mt { margin-top: 22px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip:hover { color: var(--ink); background: var(--surface-2); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li.news { border-top: 1px solid var(--border); }
.news-list li.news:first-child { border-top: 0; }
.news-list a { display: block; padding: 11px 6px; color: inherit; text-decoration: none; border-radius: 8px; }
.news-list a:hover { background: var(--hover); }
.news-list a:hover .nt { color: var(--series-1); }
.nt { font-weight: 600; line-height: 1.35; }
.ns { color: var(--ink-2); font-size: 13px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nmeta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 5px; }
.nmeta .src { color: var(--ink-2); font-weight: 600; }
.tkr { background: var(--surface-2); color: var(--ink-2); border-radius: 5px; padding: 0 6px; font-weight: 700; font-size: 11.5px; }
.cal-day { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.cal-day:first-child { border-top: 0; }
.cal-date { text-align: center; border: 1px solid var(--border); border-radius: 10px; padding: 5px 0 6px; height: fit-content; background: var(--surface); }
.cal-date .dw { font-size: 11px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.cal-date .dd { font-size: 20px; font-weight: 700; line-height: 1.1; }
.cal-date .dm { font-size: 11px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; }
.cal-date.today { border-color: var(--series-1); box-shadow: inset 0 0 0 1px var(--series-1); }
.cal-ev { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; cursor: pointer; border-radius: 8px; }
.cal-ev:hover { background: var(--hover); }
.cal-ev .logo-wrap, .cal-ev .logo, .cal-ev .logo-img { width: 28px; height: 28px; font-size: 10px; }
.cal-ev .ev-t { font-weight: 650; }
.cal-ev .ev-d { color: var(--ink-2); font-size: 12.5px; }
.ev-pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; margin-left: 6px; vertical-align: 1px; }
.ev-pill.earn { background: color-mix(in srgb, var(--series-1) 14%, transparent); color: var(--series-1); }
.ev-pill.exdiv { background: var(--up-bg); color: var(--up); }
.ev-pill.pay { background: color-mix(in srgb, var(--series-7) 14%, transparent); color: var(--series-7); }
.ev-pill.est { background: var(--surface-2); color: var(--muted); }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cal-head h3 { margin: 0; }
.mc-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 10px; }
.mc-nav b { font-size: 15px; }
.mc-nav .icon-btn { font-size: 18px; }
.mc-nav .icon-btn:disabled { opacity: .3; cursor: default; }
.mc-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; gap: 1px; background: var(--border); }
.mc-h { background: var(--surface-2); text-align: center; font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 6px 0; }
.mc-cell { background: var(--surface); min-height: 78px; padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mc-cell.out { background: var(--surface-2); }
.mc-cell.out .mc-n { color: var(--muted); opacity: .6; }
.mc-n { font-size: 12px; font-weight: 600; color: var(--ink-2); padding: 1px 3px; align-self: flex-start; border-radius: 6px; }
.mc-cell.today .mc-n { background: var(--series-1); color: #fff; }
.mc-ev { display: block; width: 100%; text-align: left; border: 0; border-radius: 4px; padding: 2px 5px; font-size: 11px; line-height: 1.3; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-ev span { opacity: .85; }
.mc-ev.earn { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }
.mc-ev.exdiv { background: var(--up-bg); color: var(--up); }
.mc-ev.pay { background: color-mix(in srgb, var(--series-7) 16%, transparent); color: var(--series-7); }
.mc-ev.est { background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, currentColor 12%, transparent) 4px 6px); }
.mc-ev:hover { filter: brightness(1.15); }
.mc-more { font-size: 11px; color: var(--muted); padding: 0 5px; }
.mc-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.mc-legend span { display: inline-flex; align-items: center; gap: 5px; }
.mc-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.mc-legend i.earn { background: var(--series-1); } .mc-legend i.exdiv { background: var(--up-mark); } .mc-legend i.pay { background: var(--series-7); }
.mc-legend i.est { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 4px); }
@media (max-width: 640px) { .mc-cell { min-height: 60px; } .mc-ev span { display: none; } }
.moved { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: color-mix(in srgb, var(--series-1) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--series-1) 35%, transparent); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; }

/* AI insights */
.ai-label { font-size: 11.5px; font-weight: 650; color: var(--series-7); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 2px; padding-top: 12px; border-top: 1px dashed var(--border); }
#aiInsights .ic { background: color-mix(in srgb, var(--series-7) 14%, transparent); color: var(--series-7); }
#aiInsights li.fresh { animation: flash 1.4s ease-out; }
.ai-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.ai-btn { color: var(--series-7); border-color: color-mix(in srgb, var(--series-7) 40%, transparent); }
.ai-btn:disabled { opacity: .6; cursor: progress; }
.ai-note { color: var(--muted); font-size: 12px; flex: 1; min-width: 200px; }

/* Movers & insights */
.movers, .insights { list-style: none; margin: 0; padding: 0; }
.movers li { display: grid; grid-template-columns: minmax(0,1fr) 90px 84px 80px; align-items: center; gap: 12px; padding: 9px 6px; border-top: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.movers li:first-child { border-top: 0; }
.movers li:hover { background: var(--hover); }
.sym { font-weight: 700; }
.nm-sm { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
.insights li { display: flex; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); align-items: flex-start; }
.insights li:first-child { border-top: 0; }
.insights .ic { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); font-size: 14px; }
.insights b { font-weight: 650; }
.insights .t { color: var(--ink-2); font-size: 13px; }

/* Tables */
.table-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { border-collapse: collapse; width: 100%; }
.positions th, .grid th { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
.positions th[data-sort] { cursor: pointer; }
.positions th[data-sort]:hover { color: var(--ink); }
.positions th.sorted::after { content: " ↓"; }
.positions th.sorted.asc::after { content: " ↑"; }
th.l, td.l, .positions th.l, .positions td.l, .grid th.l, .grid td.l, .grid td.ro.l { text-align: left; }
.positions td { padding: 11px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.positions tbody tr { cursor: pointer; }
.positions tbody tr:hover td { background: var(--hover); }
.positions tfoot td { font-weight: 700; border-bottom: 0; padding-top: 14px; }
.logo-wrap { position: relative; width: 32px; height: 32px; flex: none; }
.logo-img { position: absolute; inset: 0; width: 32px; height: 32px; border-radius: 9px; object-fit: contain; background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.d-sym { display: flex; align-items: center; gap: 10px; }
.d-sym .logo-wrap, .d-sym .logo-img, .d-sym .logo { width: 36px; height: 36px; }
.sym-cell { display: flex; align-items: center; gap: 10px; }
.logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px; flex: none; letter-spacing: -.02em; }
.sym-cell .nm-sm { max-width: 170px; }
.weight { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.weight .bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.weight .bar i { display: block; height: 100%; border-radius: 3px; }
.weight span { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
svg.spark { display: block; }

/* Editable grid */
.grid td { border-bottom: 1px solid var(--border); padding: 0; text-align: right; white-space: nowrap; }
.grid td.ro { padding: 0 10px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.grid td.ro.l { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.grid input { width: 100%; border: 0; background: transparent; padding: 10px; text-align: inherit; outline: none; border-radius: 6px; font-variant-numeric: tabular-nums; min-width: 90px; }
.grid input.sym-in { text-transform: uppercase; font-weight: 700; min-width: 90px; }
.grid input.notes { min-width: 160px; }
.grid input[type=date] { min-width: 140px; }
.grid input:hover { background: var(--hover); }
.grid input:focus { background: var(--surface); box-shadow: inset 0 0 0 2px var(--series-1); }
.grid input.bad { box-shadow: inset 0 0 0 2px var(--down-mark); }
.grid tr.new td { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--series-1) 14%, transparent); } }
.del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px 10px; border-radius: 6px; font-size: 16px; }
.del:hover { color: var(--down); background: var(--down-bg); }
.grid .empty-row td { padding: 28px; text-align: center; color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }

/* Autocomplete */
.ac { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); width: min(400px, calc(100vw - 16px)); overflow: hidden; }
.ac div { padding: 8px 12px; display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; cursor: pointer; font-size: 13px; align-items: center; }
.ac div.on, .ac div:hover { background: var(--hover); }
.ac b { font-weight: 700; }
.ac span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ac em { white-space: nowrap; font-style: normal; color: var(--muted); font-size: 11.5px; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 50; overflow-y: auto; padding: 22px; box-shadow: -10px 0 40px rgba(0,0,0,.2); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; }
.d-sym { font-size: 22px; font-weight: 750; }
.d-name { color: var(--muted); }
.d-price { font-size: 30px; font-weight: 700; margin: 12px 0 10px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.d-price .delta { font-size: 15px; margin-left: 6px; }
.drawer .chart-box { height: 230px; margin-top: 12px; }
.d-section { margin-top: 22px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.kv div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv span { color: var(--ink-2); }
.range52 { margin-top: 14px; }
.r-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.r-bar { position: relative; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--down-mark), var(--axis), var(--up-mark)); opacity: .9; }
.r-dot { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface); transform: translate(-50%, -50%); }
.r-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.mini { font-size: 13px; }
.mini th { text-align: right; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.mini td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.mini th:first-child, .mini td:first-child { text-align: left; }

/* Empty */
.empty { text-align: center; padding: 56px 20px; }
.empty h1 { font-size: 26px; margin: 18px 0 8px; }
.empty p { color: var(--ink-2); max-width: 460px; margin: 0 auto 22px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Dialog */
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 22px; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog textarea { width: 100%; margin: 14px 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 10px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; resize: vertical; }
dialog code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.dlg-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; z-index: 70; font-weight: 550; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 12px 0 0; }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--series-1); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--ink); }

/* Responsive */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .grid-2.wide-right { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .topbar-inner { gap: 10px; }
  .brand span, .updated { display: none; }
  .tab { padding: 6px 7px; font-size: 13px; }
  .tabs { gap: 0; }
  .icon-btn { width: 32px; height: 32px; }
  .hero-value { font-size: 34px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .card { padding: 16px; }
  .table-scroll { margin: 0 -16px; padding: 0 16px; }
  .alloc { grid-template-columns: 1fr; }
  .donut-box { height: 200px; }
  .chart-box.tall { height: 260px; }
  .movers li { grid-template-columns: minmax(0,1fr) 80px 80px; }
  .movers li .spk { display: none; }
  .seg button { padding: 5px 7px; }
  .kv { grid-template-columns: 1fr; }
}
.grid input[data-f="shares"] { min-width: 115px; }
.mc-ev b { display: block; overflow: hidden; text-overflow: ellipsis; }
.mc-ev span { display: block; font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
