/* Investment Tracker — clean banking-app style: soft background, white cards, big numbers, little text. */

:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e9edf2;
  --text: #0e1526;
  --text-2: #3b4458;
  --muted: #6f7889;
  --border: #e6eaf0;
  --accent: #0d6b5c;
  --accent-hover: #0b5c4f;
  --accent-text: #ffffff;
  --accent-soft: #e3f3ef;
  --hero-a: #0f1b33;
  --hero-b: #114a5c;
  --hero-text: #ffffff;
  --good: #128a4a;
  --good-soft: #e3f5ea;
  --warn: #9a5b00;
  --warn-soft: #fcefd6;
  --bad: #c62f2f;
  --bad-soft: #fde8e8;
  --info: #2d5aa8;
  --info-soft: #e7eefb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --grid: #eceef2;
  --axis: #8a8f9b;
  --tooltip-bg: #1d2129;
  --tooltip-text: #f4f5f7;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.04);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sidebar-w: 236px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0e14;
    --surface: #151a23;
    --surface-2: #1c222d;
    --surface-3: #262d3a;
    --text: #eef1f5;
    --text-2: #c3c9d4;
    --muted: #8f97a6;
    --border: #262c38;
    --accent: #3fb59a;
    --accent-hover: #5cc6ad;
    --accent-text: #06201a;
    --accent-soft: #143a32;
    --hero-a: #16233d;
    --hero-b: #13505f;
    --good: #4cc77a;
    --good-soft: #15301f;
    --warn: #e2b04e;
    --warn-soft: #3a2f17;
    --bad: #f07f7f;
    --bad-soft: #3b1d1d;
    --info: #8fb4ef;
    --info-soft: #1d2a40;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #2fa12f;
    --series-7: #9085e9;
    --grid: #252a34;
    --tooltip-bg: #eef0f4;
    --tooltip-text: #12151b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6rem; letter-spacing: -0.01em; }
h1 { font-size: 1.35rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0 0 0.6rem; }
small, .muted { color: var(--muted); }
small { font-size: 0.82rem; }
.mono { font-family: var(--mono); font-size: 0.88rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.hidden, [hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }

/* ---------- app layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { display: flex; align-items: center; gap: 0.65rem; font-weight: 700; font-size: 1.05rem; padding: 0 8px 22px; white-space: nowrap; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.logo .icon { width: 20px; height: 20px; stroke-width: 2.2; }
.menu-label { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; color: var(--muted); padding: 14px 12px 8px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; border: 0; background: none; color: var(--text-2);
  font: inherit; text-align: left; padding: 0.7rem 0.8rem; border-radius: 12px; cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .count { margin-left: auto; }
.nav-item .label-short { display: none; }
.sidebar .grow { flex: 1; min-height: 16px; }
.count { display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 99px; background: var(--bad); color: #fff; font-size: 0.72rem; font-weight: 600; text-align: center; line-height: 1.5; }
.tabbar { display: none; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.75rem;
  padding: 12px 28px; background: var(--bg);
}
.search { position: relative; flex: 0 1 320px; min-width: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem; border-radius: 14px; background: var(--surface); border-color: transparent; box-shadow: var(--shadow); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface);
  color: var(--text-2); display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: var(--shadow);
}
.icon-btn:hover { color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; display: grid; place-items: center; border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--accent-soft); }
.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 30; padding: 6px;
  background: var(--surface); border-radius: 16px; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.14);
}
.user-menu-head { padding: 10px 12px 8px; display: grid; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 6px; word-break: break-all; }
.user-menu-head strong { font-size: 0.9rem; }
.user-menu-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item .icon { color: var(--muted); }
.user-menu-item.danger { color: var(--bad); }
.user-menu-item.danger .icon { color: var(--bad); }
.user-menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

main { width: 100%; max-width: 1180px; padding: 8px 28px 48px; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
.dash-masonry { columns: 3 300px; column-gap: 1rem; margin-top: 1rem; }
.dash-masonry > .card { break-inside: avoid; margin-bottom: 1rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.spacer-y { height: 0.9rem; }
.panel-inner { margin-top: 0.9rem; }
.page-title { display: flex; align-items: center; gap: 0.6rem; margin: 6px 0 14px; }
.page-title h1 { margin: 0; }

.panel, .card { background: var(--surface); border: 0; border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.panel + .panel { margin-top: 1rem; }
.card-head { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.card-head h2 { margin: 0; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 0.8rem 0.9rem; }
.stat .label { color: var(--muted); font-size: 0.78rem; }
.stat .value { font-size: 1.1rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- home: balance card & quick actions ---------- */
.dash { display: grid; gap: 1rem; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); align-items: start; }
.dash > .grid { align-content: start; }
.dash-bottom { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 360px; margin-top: 1rem; }
.hero-card {
  position: relative; overflow: hidden; color: var(--hero-text); border-radius: var(--radius); padding: 1.3rem 1.4rem 1.2rem;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); box-shadow: 0 12px 30px rgba(15, 27, 51, 0.22);
}
.hero-card::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, 0.06); }
.hero-top { display: flex; align-items: center; gap: 0.5rem; position: relative; z-index: 1; }
.hero-label { font-size: 0.82rem; opacity: 0.8; }
.hero-eye { margin-left: auto; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: inherit; display: grid; place-items: center; cursor: pointer; }
.hero-amount { position: relative; z-index: 1; font-size: 2.35rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; margin: 0.35rem 0 0.25rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-sub { position: relative; z-index: 1; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.86rem; opacity: 0.92; }
.hero-sub .delta { background: rgba(255, 255, 255, 0.14); padding: 0.15rem 0.5rem; border-radius: 99px; }
.hero-sub .delta.up { color: #8ff0c3; }
.hero-sub .delta.down { color: #ffb4b4; }
.hero-cur { position: relative; z-index: 1; display: inline-flex; gap: 2px; background: rgba(255, 255, 255, 0.12); border-radius: 99px; padding: 2px; margin-top: 0.9rem; }
.hero-cur button { border: 0; background: transparent; color: inherit; opacity: 0.75; font: inherit; font-size: 0.78rem; font-weight: 600; padding: 0.25rem 0.7rem; border-radius: 99px; cursor: pointer; }
.hero-cur button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: var(--hero-a); opacity: 1; }
.hero-cur button:disabled { opacity: 0.35; cursor: default; }
.returns-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.returns-strip .rs-cell:first-child { grid-column: span 2; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.returns-strip .rs-cell:first-child .rs-value { font-size: 1.05rem; }
.rs-cell { background: var(--surface); border-radius: 14px; padding: 0.65rem 0.75rem; box-shadow: var(--shadow); min-width: 0; }
.rs-label { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-value { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.98rem; margin-top: 0.1rem; white-space: nowrap; }
.rs-sub { font-size: 0.7rem; color: var(--muted); margin-top: 0.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.3rem 0 0; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; }
.type-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.85rem 0.4rem; border: 2px solid transparent; border-radius: 16px; background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 0.84rem; font-weight: 500; cursor: pointer; }
.type-tile:hover { background: var(--surface-3); }
.type-tile .type-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--accent); box-shadow: var(--shadow); }
.type-tile[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.type-tile[aria-pressed="true"] .type-icon { background: var(--accent); color: var(--accent-text); }
.record .page-title { margin-bottom: 0.8rem; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 0.76rem; cursor: pointer; padding: 0.2rem 0; }
.qa .qa-icon { width: 50px; height: 50px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--accent); }
.qa:hover .qa-icon { background: var(--accent-soft); }
.alloc-bar { display: flex; gap: 2px; height: 12px; margin: 0.4rem 0 0.6rem; border-radius: 99px; overflow: hidden; }
.alloc-bar span { min-width: 4px; }
.alloc-list { list-style: none; margin: 0; padding: 0; }
.alloc-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.alloc-list li:last-child { border-bottom: 0; }
.alloc-list .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.alloc-list .pct { color: var(--muted); font-size: 0.82rem; }
.alloc-list .amt { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.alloc-list.compact li { padding: 0.4rem 0; font-size: 0.88rem; }
.alloc-list.compact strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.grid.cols-2.tight { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.btn.block { width: 100%; justify-content: center; }
.review-headline { font-size: 1.02rem; font-weight: 650; line-height: 1.35; margin: 0 0 0.5rem; }
h2.review-headline { font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.6rem; }
.chip { background: var(--surface-2); border-radius: 99px; padding: 0.3rem 0.7rem; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 0.8rem; }
.mover { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.lrow.mine .avatar-sm { background: var(--accent-soft); color: var(--accent); }
.lrow .title .badge { margin-left: 0.4rem; vertical-align: middle; }

/* ---------- list rows (holdings, activity, accounts, menus) ---------- */
.list { display: flex; flex-direction: column; }
.lrow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.8rem;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border); text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
  color: inherit; font: inherit; width: 100%; cursor: default;
}
.lrow:last-child { border-bottom: 0; }
button.lrow, .lrow.tap { cursor: pointer; }
button.lrow:hover, .lrow.tap:hover { background: var(--surface-2); margin: 0 -0.6rem; padding-left: 0.6rem; padding-right: 0.6rem; border-radius: 12px; }
.lrow .avatar-sm { width: 40px; height: 40px; border-radius: 14px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; flex: none; }
.lrow .avatar-sm.in { background: var(--good-soft); color: var(--good); }
.lrow .avatar-sm.out { background: var(--bad-soft); color: var(--bad); }
.lrow .avatar-sm.neutral { background: var(--info-soft); color: var(--info); }
.lrow .main { min-width: 0; display: grid; gap: 0.1rem; }
.lrow .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .sub { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .right { text-align: right; display: grid; gap: 0.1rem; justify-items: end; }
.lrow .value { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lrow .change { font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lrow .chev { color: var(--muted); }
.group-label { font-size: 0.76rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0.9rem 0 0.3rem; }
.group-label:first-child { padding-top: 0; }
.tx-detail { background: var(--surface-2); border-radius: 14px; padding: 0.8rem 0.9rem; margin: 0.2rem 0 0.8rem; display: grid; gap: 0.5rem; }
.tx-detail .kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.5rem; }
.tx-detail .kv div { display: grid; gap: 0.05rem; }
.tx-detail .k { font-size: 0.74rem; color: var(--muted); }
.tx-detail .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.more-list .lrow { padding: 0.9rem 0; }
.more-list .avatar-sm { background: var(--accent-soft); color: var(--accent); }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; }
.chart-wrap .gridline { stroke: var(--grid); stroke-width: 1; }
.chart-wrap .baseline { stroke: var(--axis); stroke-width: 1; opacity: 0.6; }
.chart-wrap .tick-label { fill: var(--axis); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-wrap .end-label { font-size: 12px; font-weight: 600; fill: var(--text-2); }
.chart-wrap .crosshair { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-wrap .hit { fill: transparent; cursor: crosshair; }
.chart-tooltip {
  position: absolute; top: 0; pointer-events: none; background: var(--tooltip-bg); color: var(--tooltip-text);
  border-radius: 12px; padding: 0.65rem 0.8rem; font-size: 0.86rem; min-width: 200px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); z-index: 2;
}
.chart-tooltip .t-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.12rem 0; }
.chart-tooltip .t-row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.chart-tooltip .key { width: 14px; height: 2px; border-radius: 2px; flex: none; }
.chart-tooltip .t-date { opacity: 0.7; font-size: 0.78rem; text-align: center; margin-top: 0.25rem; }
.legend { display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--text-2); margin-bottom: 0.4rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend .key { width: 14px; height: 2px; border-radius: 2px; }
.chart-empty { display: grid; place-items: center; min-height: 200px; color: var(--muted); text-align: center; padding: 1rem; }

.ticker {
  display: flex; align-items: center; gap: 1.4rem; overflow-x: auto; padding: 4px 28px 10px; white-space: nowrap; scrollbar-width: none;
}
.ticker::-webkit-scrollbar { display: none; }
.ticker-label { font-size: 0.74rem; color: var(--muted); }
.tick { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.88rem; background: var(--surface); border-radius: 99px; padding: 0.3rem 0.7rem 0.3rem 0.35rem; box-shadow: var(--shadow); }
.tick strong { font-weight: 650; }
.tick .price { color: var(--text-2); font-variant-numeric: tabular-nums; }
.delta { display: inline-flex; align-items: center; gap: 0.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.sep { display: none; }

.tabs-line { display: flex; gap: 0.3rem; margin-bottom: 0.6rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs-line::-webkit-scrollbar { display: none; }
.tabs-line button { border: 0; background: var(--surface-2); color: var(--text-2); font: inherit; font-size: 0.86rem; font-weight: 500; padding: 0.45rem 0.9rem; cursor: pointer; border-radius: 99px; white-space: nowrap; }
.tabs-line button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent); font-weight: 600; }
.sort-select { width: auto; padding: 0.35rem 1.8rem 0.35rem 0.7rem; font-size: 0.82rem; border-radius: 99px; }
.grow-input { flex: 1 1 200px; }
.asset-cell { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.asset-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; flex: none; }
.asset-name { font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; }

.ai-card { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%); }
.ai-title { display: flex; align-items: center; gap: 0.45rem; font-weight: 600; color: var(--text-2); margin-bottom: 0.5rem; }
.ai-title .icon { color: var(--accent); }
.ai-count { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 0.2rem; }
.ai-list { list-style: none; padding: 0; margin: 0.6rem 0 0.8rem; }
.ai-list li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.ai-list li:last-child { border-bottom: 0; }
.ai-list .amt { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-card textarea { min-height: 4.5rem; background: var(--surface); }

.goal-tile { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.goal-tile:last-child { border-bottom: 0; padding-bottom: 0; }
.goal-tile-top { display: flex; align-items: flex-start; gap: 0.6rem; }
.goal-tile .goal-name { flex: 1; min-width: 0; white-space: normal; }
.goal-tile .goal-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-pct { font-size: 1.3rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1; }
.goal-pct .icon { width: 22px; height: 22px; stroke-width: 2.4; }
.goal-tile .progress { height: 10px; margin: 0.55rem 0 0.4rem; }
.goal-meta { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; font-size: 0.82rem; }
.goal-meta b { font-variant-numeric: tabular-nums; }
.goal { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.goal:last-child { border-bottom: 0; }
.goal-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 0.45rem 0 0.3rem; }
.progress span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.progress.met span { background: var(--good); }
#goals-grid { margin: 1rem 0; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 0.55rem; color: var(--text); font-size: 0.95rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 0.68rem 0.8rem; min-width: 0; width: 100%;
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { min-height: 6.5rem; resize: vertical; font-family: var(--mono); font-size: 0.9rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem; margin: 0; }
legend { padding: 0 0.3rem; color: var(--muted); font-size: 0.85rem; }

button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; border: 0; background: var(--surface-2); color: var(--text);
  padding: 0.65rem 1.1rem; border-radius: 14px; cursor: pointer; white-space: nowrap;
}
button.btn:hover { background: var(--surface-3); }
button.btn.primary { background: var(--accent); color: var(--accent-text); }
button.btn.primary:hover { background: var(--accent-hover); }
button.btn.soft { background: var(--accent-soft); color: var(--accent); }
button.btn.danger { color: var(--bad); background: var(--bad-soft); }
button.btn.small { padding: 0.4rem 0.8rem; font-size: 0.84rem; border-radius: 10px; }
button.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.86rem; font-weight: 500; padding: 0.45rem 0.85rem; cursor: pointer; border-radius: 11px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1); }

/* ---------- tables (desktop) ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
thead th { color: var(--muted); font-weight: 500; font-size: 0.76rem; white-space: nowrap; border-bottom: 0; }
tr:last-child td { border-bottom: 0; }

/* ---------- badges & notes ---------- */
.badge { display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 0.18rem 0.6rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.note { border-radius: var(--radius-sm); padding: 0.65rem 0.85rem; font-size: 0.9rem; margin: 0.5rem 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--info-soft); color: var(--info); }
.note.good { background: var(--good-soft); color: var(--good); }
.note ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
details.help-more > summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; list-style: none; }
details.help-more > summary::-webkit-details-marker { display: none; }
details.help-more > summary::before { content: "ⓘ "; }
details.help-more[open] > summary { margin-bottom: 0.3rem; }
details.help-more p, details.help-more ul { font-size: 0.86rem; color: var(--text-2); }

/* ---------- inbox ---------- */
.inbox-item { border: 0; border-radius: 16px; background: var(--surface-2); margin-bottom: 0.6rem; }
.inbox-item > summary { list-style: none; cursor: pointer; padding: 0.8rem 0.9rem; display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.inbox-item > summary::-webkit-details-marker { display: none; }
.inbox-item[open] > summary { border-bottom: 1px solid var(--border); }
.inbox-item .body { padding: 0.9rem; }
.sms { font-family: var(--mono); font-size: 0.86rem; white-space: pre-wrap; word-break: break-word; background: var(--surface); border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; }
.summary-text { flex: 1 1 260px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 0.86rem; }
.field-src { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; }
.field-src.message { color: var(--good); }
.field-src.derived { color: var(--info); }
.field-src.account, .field-src.metadata { color: var(--warn); }
.field-src.user { color: var(--accent); }
.field-src.missing { color: var(--bad); }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.5rem; }
.preview-grid div { background: var(--surface); border-radius: var(--radius-sm); padding: 0.55rem 0.65rem; }
.preview-grid .k { font-size: 0.74rem; color: var(--muted); }
.preview-grid .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.token { word-break: break-all; font-family: var(--mono); background: var(--surface-2); padding: 0.5rem; border-radius: var(--radius-sm); }
.help h2 { margin-top: 1.2rem; }
.help ul { padding-left: 1.2rem; }

/* ---------- list rows & inline editors ---------- */
.list-item { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem 0.8rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-of-type { border-bottom: 0; }
.list-main { flex: 1 1 240px; min-width: 0; display: grid; gap: 0.15rem; }
.list-main small { overflow-wrap: anywhere; }
.inline-edit { flex-basis: 100%; display: grid; gap: 0.6rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.8rem; }
.inline-edit input { background: var(--surface); }
.settings { display: grid; gap: 1rem; max-width: 820px; }
.settings .tabs-line { margin-bottom: 0; }

/* ---------- auth ---------- */
.auth { max-width: 400px; margin: 10vh auto; padding: 0 16px; }
.auth .panel { padding: 1.8rem; }
.auth .brand { padding: 0 0 1.2rem; }
.auth .logo { width: 48px; height: 48px; border-radius: 14px; }
.auth .logo .icon { width: 26px; height: 26px; }

#toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 14px;
  max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .dash-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 76px; }
  .sidebar { padding: 22px 12px; align-items: center; }
  .sidebar .brand span, .menu-label, .nav-item .label { display: none; }
  .sidebar .brand { padding: 0 0 18px; }
  .nav-item { justify-content: center; padding: 0.75rem; }
  .nav-item .count { position: absolute; top: 4px; right: 4px; margin: 0; }
}
@media (max-width: 720px) {
  :root { font-size: 15px; --radius: 18px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }

  /* Bottom tab bar: 5 items, raised centre "Record" button, safe-area aware. */
  .tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; align-items: flex-end;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); box-shadow: 0 -6px 20px rgba(16, 24, 40, 0.07);
  }
  .tabbar .nav-item { flex: 1; flex-direction: column; gap: 0.2rem; padding: 0.35rem 0.1rem; font-size: 0.66rem; border-radius: 10px; min-width: 0; min-height: 50px; justify-content: center; color: var(--muted); }
  .tabbar .nav-item[aria-current="page"] { background: transparent; color: var(--accent); }
  .tabbar .nav-item .label { display: none; }
  .tabbar .nav-item .label-short { display: block; white-space: nowrap; }
  .tabbar .nav-item .icon { width: 23px; height: 23px; }
  .tabbar .nav-item .count { position: absolute; top: 0; right: 50%; transform: translateX(16px); margin: 0; }
  .tabbar .nav-item.fab { color: var(--accent-text); }
  .tabbar .nav-item.fab .icon { width: 26px; height: 26px; stroke-width: 2.4; background: var(--accent); border-radius: 50%; padding: 15px; box-sizing: content-box; margin-top: -26px; box-shadow: 0 8px 20px rgba(13, 107, 92, 0.35); }
  .tabbar .nav-item.fab .label-short { color: var(--muted); }
  .tabbar .nav-item.fab[aria-current="page"] .label-short { color: var(--accent); }

  .topbar { padding: 8px 14px; gap: 0.5rem; }
  .search { flex: 1 1 auto; }
  .icon-btn, .avatar { width: 38px; height: 38px; }
  .ticker { padding: 2px 14px 8px; gap: 0.6rem; }
  main { padding: 6px 14px calc(96px + env(safe-area-inset-bottom)); }
  .grid { gap: 0.8rem; }
  .panel, .card { padding: 1rem 0.95rem; }
  .panel + .panel { margin-top: 0.8rem; }
  .hero-card { padding: 1.15rem 1.2rem 1.1rem; }
  .hero-amount { font-size: 2rem; }
  h1 { font-size: 1.2rem; }
  .page-title { margin: 4px 0 10px; }

  input, select, textarea { font-size: 16px; padding: 0.75rem 0.8rem; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .form-grid .wide { grid-column: 1 / -1; }
  button.btn { min-height: 46px; }
  button.btn.small { min-height: 38px; }
  form > .row.end { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; }
  .seg button { flex: 1 1 auto; min-height: 38px; text-align: center; }
  .tabs-line { margin-left: -0.95rem; margin-right: -0.95rem; padding: 0 0.95rem 2px; }
  .settings .tabs-line { margin-left: 0; margin-right: 0; padding: 0 0 2px; }
  .user-menu { position: fixed; left: 12px; right: 12px; top: 58px; min-width: 0; }
  .lrow .avatar-sm { width: 42px; height: 42px; }
  .returns-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .type-grid { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .type-tile { padding: 0.7rem 0.2rem; font-size: 0.74rem; border-radius: 14px; }
  .type-tile .type-icon { width: 36px; height: 36px; }

  /* Remaining tables become stacked cards with "heading: value" cells. */
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { border-radius: 14px; padding: 0.35rem 0.8rem; margin-bottom: 0.6rem; background: var(--surface-2); }
  tr:last-child { margin-bottom: 0; }
  td { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); text-align: right; }
  td:last-child, tr:last-child td { border-bottom: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 0.76rem; text-align: left; flex: 0 0 auto; }
  td:not([data-label])::before, td[data-label=""]::before { display: none; }
  td:empty { display: none; }
  td.num { text-align: right; white-space: normal; }
  td > .row, td > .btn, td > button { margin-left: auto; }
  .hide-sm { display: none; }
}
@media (max-width: 400px) {
  .form-grid { grid-template-columns: 1fr; }
  .quick-actions { gap: 0.3rem; }
}
