/* ── Fonts ─────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist[wght].woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/static/fonts/GeistMono[wght].woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:          oklch(96.5% 0.005 250);
  --bg-2:        oklch(93%   0.008 250);
  --surface:     oklch(100%  0     0);
  --surface-2:   oklch(97%   0.005 250);
  --border:      oklch(89%   0.008 250);
  --border-2:    oklch(84%   0.01  250);
  --text-1:      oklch(18%   0.01  250);
  --text-2:      oklch(44%   0.01  250);
  --text-3:      oklch(64%   0.01  250);

  --in:          oklch(50%   0.15  145);
  --in-bg:       oklch(96%   0.04  145);
  --in-border:   oklch(88%   0.07  145);
  --out:         oklch(52%   0.18   25);
  --out-bg:      oklch(97%   0.04   25);
  --out-border:  oklch(88%   0.08   25);
  --over:        oklch(48%   0.2    25);

  --accent:      oklch(52%   0.16  250);
  --accent-2:    oklch(64%   0.12  250);
  --accent-bg:   oklch(95%   0.04  250);

  --sidebar-bg:        oklch(13%  0.012 250);
  --sidebar-border:    oklch(22%  0.012 250);
  --sidebar-text:      oklch(82%  0.012 250);
  --sidebar-text-2:    oklch(52%  0.012 250);
  --sidebar-active-bg: oklch(24%  0.015 250);
  --sidebar-hover-bg:  oklch(19%  0.012 250);

  --shadow-sm: 0 1px 3px oklch(0% 0 0 / 0.06), 0 1px 2px oklch(0% 0 0 / 0.04);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / 0.08), 0 2px 4px oklch(0% 0 0 / 0.05);
  --shadow-lg: 0 8px 24px oklch(0% 0 0 / 0.12), 0 4px 8px oklch(0% 0 0 / 0.06);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-w: 240px;
  --topbar-h:  56px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
}

body.dark {
  --bg:          oklch(14%   0.01  250);
  --bg-2:        oklch(18%   0.01  250);
  --surface:     oklch(20%   0.012 250);
  --surface-2:   oklch(24%   0.012 250);
  --border:      oklch(28%   0.012 250);
  --border-2:    oklch(34%   0.012 250);
  --text-1:      oklch(92%   0.008 250);
  --text-2:      oklch(60%   0.008 250);
  --text-3:      oklch(38%   0.008 250);

  --in:          oklch(66%   0.16  145);
  --in-bg:       oklch(22%   0.05  145);
  --in-border:   oklch(32%   0.08  145);
  --out:         oklch(68%   0.17   25);
  --out-bg:      oklch(22%   0.05   25);
  --out-border:  oklch(32%   0.08   25);
  --over:        oklch(68%   0.2    25);

  --accent:      oklch(65%   0.14  250);
  --accent-2:    oklch(52%   0.1   250);
  --accent-bg:   oklch(22%   0.05  250);

  --shadow-sm: 0 1px 3px oklch(0% 0 0 / 0.3);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / 0.4);
  --shadow-lg: 0 8px 24px oklch(0% 0 0 / 0.5);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }
ul, ol { list-style: none; }

/* ── App shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar-brand svg { opacity: 0.9; flex-shrink: 0; }
.sidebar-section-label {
  padding: var(--sp-3) var(--sp-5) var(--sp-1);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text-2);
}
.sidebar-nav {
  padding: 0 var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 7px var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text);
}
.nav-item.active svg { opacity: 1; }
.sidebar-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sidebar-active-bg);
  border: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--sidebar-text);
  flex-shrink: 0;
  text-transform: uppercase;
}
.sidebar-username {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-toggle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text-2);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text); }

/* ── Main area ─────────────────────────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
}
.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-1);
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-3); }

/* ── Content scroll area ───────────────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
}
.content-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* ── Card ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.card-header-spacer { flex: 1; }
.card-body { padding: var(--sp-5); }
.card-body.no-pad { padding: 0; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--text-1);
  background: var(--surface-2);
  border-color: var(--border);
}
.btn:hover { background: var(--bg-2); }
.btn:active { opacity: 0.8; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.in {
  background: var(--in-bg);
  border-color: var(--in-border);
  color: var(--in);
}
.btn.out {
  background: var(--out-bg);
  border-color: var(--out-border);
  color: var(--out);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn.icon {
  width: 32px;
  height: 32px;
  padding: 0;
}
.btn.sm { height: 26px; padding: 0 var(--sp-2); font-size: 12px; }
.btn.sm.icon { width: 26px; }
.btn svg { flex-shrink: 0; }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
.input {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.15);
}
.input::placeholder { color: var(--text-3); }
.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-prefix {
  position: absolute;
  left: var(--sp-3);
  color: var(--text-2);
  font-size: 13px;
  pointer-events: none;
  font-family: 'Geist Mono', monospace;
}
.input-prefix-wrap .input { padding-left: 22px; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* ── Segmented control ─────────────────────────────────────────────────────── */
.seg {
  display: inline-flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-item {
  height: 26px;
  padding: 0 var(--sp-3);
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  transition: background 0.1s, color 0.1s;
  user-select: none;
  white-space: nowrap;
}
.seg-item:hover { color: var(--text-1); }
.seg-item.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: var(--shadow-sm);
}
.seg-item[data-type="out"].active { color: var(--out); }
.seg-item[data-type="in"].active { color: var(--in); }

/* ── Pills ─────────────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.in { background: var(--in-bg); color: var(--in); border-color: var(--in-border); }
.pill.out { background: var(--out-bg); color: var(--out); border-color: var(--out-border); }
.pill.outline { background: transparent; }

/* ── Color dot ─────────────────────────────────────────────────────────────── */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.bar {
  height: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  position: relative;
  overflow: visible;
  min-width: 80px;
}
.bar .fill {
  height: 100%;
  border-radius: 999px;
  background: var(--text-3);
  max-width: 100%;
  transition: width 0.3s;
}
.bar .fill.in { background: var(--in); }
.bar .fill.out { background: var(--accent); }
.bar .fill.over { background: var(--out); }
.bar .mark {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 10px;
  background: var(--text-2);
  border-radius: 1px;
  transform: translateX(-50%);
}

/* ── Typography helpers ────────────────────────────────────────────────────── */
.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}
.kicker {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}
.mono {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.num-xl {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.num-lg {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.num-sm {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
}
.color-in { color: var(--in); }
.color-out { color: var(--out); }
.color-muted { color: var(--text-2); }
.color-dim { color: var(--text-3); }

/* ── Layout helpers ────────────────────────────────────────────────────────── */
.row { display: flex; flex-direction: row; align-items: center; }
.col { display: flex; flex-direction: column; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { align-items: center; justify-content: center; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Summary stats row ─────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.stat-cell {
  background: var(--surface);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.stat-delta {
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  color: var(--text-3);
}

/* ── Quick-add bar ─────────────────────────────────────────────────────────── */
.quick-add-form {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.quick-add-form .input { height: 36px; }
.quick-add-hint {
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  color: var(--text-3);
  margin-top: var(--sp-2);
}
kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--text-2);
}

/* ── Quick-add card (needs visible overflow for category dropdown) ─────────── */
.quick-add-card { overflow: visible; }

/* ── Custom category dropdown ──────────────────────────────────────────────── */
.cat-picker-wrap { position: relative; }
.cat-picker-btn {
  height: 36px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-1);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 140px;
  cursor: pointer;
  transition: border-color 0.12s;
  white-space: nowrap;
}
.cat-picker-btn:focus-visible, .cat-picker-btn.open {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.15);
  outline: none;
}
.cat-picker-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cat-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
  padding: var(--sp-1);
}
.cat-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-1);
  transition: background 0.1s;
}
.cat-dropdown-item:hover { background: var(--bg-2); }
.cat-dropdown-item.create-new { color: var(--accent); font-weight: 500; }
.cat-dropdown-empty { padding: var(--sp-3); color: var(--text-3); font-size: 12px; text-align: center; }

/* ── Transaction list ──────────────────────────────────────────────────────── */
.tx-date-group { display: flex; flex-direction: column; gap: 2px; }
.tx-date-header {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-1);
  letter-spacing: 0.02em;
}
.tx-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-5);
  cursor: default;
  transition: background 0.1s;
  position: relative;
}
.tx-row:hover { background: var(--bg-2); }
.tx-row:hover .tx-actions { opacity: 1; }
.tx-name { flex: 1; font-size: 13.5px; min-width: 0; }
.tx-note { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 500;
  flex-shrink: 0;
}
.tx-amount.in { color: var(--in); }
.tx-amount.out { color: var(--out); }
.tx-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.1s;
  flex-shrink: 0;
}

/* ── Forecast table ────────────────────────────────────────────────────────── */
.forecast-table { width: 100%; border-collapse: collapse; }
.forecast-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.forecast-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.forecast-table tr:last-child td { border-bottom: none; }
.forecast-table tr:hover td { background: var(--bg-2); }
.forecast-planned-cell { cursor: pointer; }
.forecast-planned-input {
  height: 28px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-1);
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  outline: none;
  width: 100px;
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.15);
}
.diff-positive { color: var(--in); }
.diff-negative { color: var(--out); }

/* ── Investment shared ─────────────────────────────────────────────────────── */
.stale-icon { position: relative; display: inline-flex; cursor: default; }
.stale-icon svg { color: var(--out); }
.tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px var(--sp-2);
  font-size: 11px;
  white-space: nowrap;
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  z-index: 100;
  pointer-events: none;
  display: none;
}
.stale-icon:hover .tooltip { display: block; }
.return-pos { color: var(--in); }
.return-neg { color: var(--out); }

/* ── Sidebar accounts section ──────────────────────────────────────────────── */
.sidebar-section-header {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--sp-3) var(--sp-1) var(--sp-5);
}
.sidebar-accounts-label {
  flex: 1;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text-2);
}
.sidebar-accounts {
  padding: 0 var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sidebar-account-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
}
.sidebar-account-row:hover { background: var(--sidebar-hover-bg); }
.sidebar-account-name {
  flex: 1;
  font-size: 13px;
  color: var(--sidebar-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-account-balance {
  font-size: 11px;
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--sidebar-text-2);
  flex-shrink: 0;
}
.sidebar-account-empty {
  padding: var(--sp-2) var(--sp-3);
  font-size: 12px;
  color: var(--sidebar-text-2);
}
.sidebar-account-balance-rub {
  font-size: 11px;
  color: var(--sidebar-text-2);
  margin-top: 1px;
}
.sidebar-assets-group {
  border-top: 1px solid var(--sidebar-border);
  margin-top: var(--sp-1);
  padding-top: var(--sp-1);
}
.sidebar-assets-header .sidebar-account-name {
  color: var(--sidebar-text);
  font-weight: 500;
}
.sidebar-assets-class-row {
  padding-left: calc(var(--sp-3) + 14px);
}
.sidebar-subtotal-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  border-radius: var(--radius-sm);
  user-select: none;
}
.sidebar-subtotal-header .sidebar-account-name {
  color: var(--sidebar-text);
  font-weight: 500;
}
/* assets totals — green numbers; debt stays red (untouched) */
.sidebar-subtotal-header:not(.sidebar-subtotal-header--debt) .sidebar-account-balance {
  color: var(--in);
}
.sidebar-assets-header .sidebar-account-balance { color: var(--in); }
.sidebar-subtotal-header--debt .sidebar-account-name,
.sidebar-subtotal-header--debt .sidebar-account-balance {
  color: var(--out);
}

/* ── Field helper text ─────────────────────────────────────────────────────── */
.field-helper {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Color picker input ────────────────────────────────────────────────────── */
.color-input {
  width: 64px;
  height: 36px;
  padding: 3px 4px;
  cursor: pointer;
}

/* ── Inline notice (delete error in edit modal) ────────────────────────────── */
.inline-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--out-bg);
  border: 1px solid var(--out-border);
  color: var(--out);
  font-size: 12px;
}

/* ── Modal overlay ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-body { padding: var(--sp-5) var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
}
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }

/* ── Month picker ──────────────────────────────────────────────────────────── */
.month-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.month-picker-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px var(--sp-3);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  user-select: none;
  color: var(--text-1);
}
.month-picker-label:hover { background: var(--bg-2); }
.month-picker-label svg { color: var(--text-2); flex-shrink: 0; }
.month-not-current { font-size: 10px; color: var(--accent); font-weight: 600; margin-left: 2px; }
.month-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
}
.month-nav-btn:hover { background: var(--bg-2); color: var(--text-1); }

/* ── Login screen ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--sp-5);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.login-brand span {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.login-error {
  font-size: 13px;
  color: var(--out);
  background: var(--out-bg);
  border: 1px solid var(--out-border);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
}

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-5);
  color: var(--text-3);
  font-size: 13px;
}

/* ── Spinner ───────────────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tab fade transition ───────────────────────────────────────────────────── */
.tab-panel { animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Responsive / mobile ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .content-area { padding: var(--sp-4); }
  .quick-add-form { flex-direction: column; align-items: stretch; }
  .stats-row { grid-template-columns: 1fr; }
  .inv-stat-row { flex-direction: column; }
  .inv-stat-row .stat-divider { width: 100%; height: 1px; }
  .inv-stat-col { padding: var(--sp-4) !important; }
  .inv-row-col { width: 56px; }
  .inv-col-hdr { display: none; }
  .proj-slider-label { width: 110px; }
  .proj-slider-val { width: 70px; }
  .proj-chart-wrap { height: 180px; }
  .topbar { padding: 0 var(--sp-4); }
}

/* ── Forecast redesign ─────────────────────────────────────────────────────── */
.forecast-top-card {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6);
}
.forecast-donut-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.forecast-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}
.forecast-stat-cols {
  display: flex;
  align-items: stretch;
  flex: 1;
  min-width: 0;
}
.stat-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.forecast-stat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: 0 var(--sp-5);
  min-width: 0;
}
.forecast-stat-col:first-child { padding-left: 0; }
.forecast-cat-cell {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.forecast-cat-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}
.forecast-cat-sub {
  font-size: 11px;
  color: var(--text-3);
}
.forecast-bar-cell { min-width: 120px; }
.forecast-pace-bar { width: 100%; }
.forecast-amt-cell { white-space: nowrap; }
.forecast-plan-editable {
  cursor: pointer;
  border-bottom: 1px dashed var(--border-2);
}
.forecast-plan-editable:hover { color: var(--accent); }
.forecast-add-cell { padding: var(--sp-3) var(--sp-4) !important; }

/* ── User menu dropdown ────────────────────────────────────────────────────── */
.avatar-btn {
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.avatar-btn:hover { opacity: 0.75; }
.user-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 400;
  overflow: hidden;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  color: var(--text-1);
  transition: background 0.1s;
  text-align: left;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--bg-2); }
.user-menu-item svg { flex-shrink: 0; }
.user-menu-item-danger { color: var(--out); }
.user-menu-item-danger:hover { background: var(--out-bg); }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--sp-3) var(--sp-5);
  font-size: 13px;
  color: var(--text-2);
  z-index: 600;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Investments redesign ──────────────────────────────────────────────────── */

/* Range slider — cross-browser, theme-aware */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  flex: 1;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.15);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.15);
  cursor: pointer;
  border: 2px solid var(--accent);
}
input[type=range]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.2);
}
input[type=range]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.2);
}

/* Top stat card 3-col layout */
.inv-stat-row {
  display: flex;
  align-items: stretch;
}
.inv-stat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  min-width: 0;
}
.inv-goal-btn { align-self: flex-start; margin-top: var(--sp-2); }
.inv-goal-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--text-3);
}
.inv-goal-edit:hover { color: var(--text-2); }

/* Holdings list */
.inv-list { display: flex; flex-direction: column; }
.inv-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.inv-row:last-child { border-bottom: none; }
.inv-row:hover { background: var(--bg-2); }
.inv-row:hover .inv-row-actions { opacity: 1; }
.inv-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  flex-shrink: 0;
  text-transform: uppercase;
  position: relative;
  letter-spacing: 0.02em;
}
.inv-badge-stale {
  position: absolute;
  bottom: -3px;
  right: -3px;
  color: var(--out);
  display: flex;
  cursor: default;
}
.inv-badge-stale .tooltip {
  bottom: unset;
  top: calc(100% + 4px);
  right: 0;
}
.inv-badge-stale:hover .tooltip { display: block; }
.inv-row-name { flex: 1; min-width: 0; }
.inv-row-name-primary {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-row-name-sub {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 2px;
  flex-wrap: wrap;
}
.inv-row-col {
  text-align: right;
  flex-shrink: 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}
.inv-row-col-val {
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-1);
}
.inv-row-col-sub { font-size: 11px; color: var(--text-3); }
.inv-row-actions {
  display: flex;
  gap: var(--sp-1);
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
  width: 60px;
  justify-content: flex-end;
}
.inv-col-hdr {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.inv-col-hdr-cell {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  flex-shrink: 0;
  text-align: right;
}

/* Projection chart */
.proj-chart-wrap { width: 100%; height: 220px; position: relative; overflow: hidden; }
.proj-chart-wrap svg { width: 100%; height: 100%; display: block; }

/* Projection controls */
.proj-controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border-top: 1px solid var(--border);
}
.proj-slider-row { display: flex; align-items: center; gap: var(--sp-3); }
.proj-slider-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  flex-shrink: 0;
  width: 160px;
}
.proj-slider-val {
  font-size: 12px;
  font-family: 'Geist Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  text-align: right;
  flex-shrink: 0;
  width: 80px;
}
