/* Vault — fintech SaaS dashboard */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0f172a;
  --text-muted: #667085;
  --text-subtle: #98a2b3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-tint: #eff4ff;
  --primary-tint-2: #dbe7ff;
  --income: #059669;
  --income-tint: #ecfdf5;
  --expense: #dc2626;
  --expense-tint: #fef2f2;
  --warning: #d97706;
  --warning-tint: #fffbeb;
  --purple: #7c3aed;
  --purple-tint: #f5f3ff;
  --shadow-sm: 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-lg: 0 4px 12px rgba(16,24,40,0.06), 0 2px 4px rgba(16,24,40,0.04);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1b2740;
  --border: #2a3a5c;
  --border-strong: #36476b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-tint: #1e3a8a33;
  --primary-tint-2: #1e40af55;
  --income: #10b981;
  --income-tint: #064e3b55;
  --expense: #ef4444;
  --expense-tint: #7f1d1d55;
  --warning: #f59e0b;
  --warning-tint: #78350f55;
  --purple: #a78bfa;
  --purple-tint: #4c1d9555;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Top nav ── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 24px;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #4f7dff);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(37,99,235,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
}
.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--primary); background: var(--primary-tint); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}
.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: default;
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd6a5, #fb923c);
  display: grid;
  place-items: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.nav-logout {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.nav-logout:hover { color: var(--expense); background: var(--expense-tint); }
.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}

/* ── Page layout ── */
.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}
.eyebrow {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 4px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(37,99,235,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover { background: var(--primary-hover); color: white; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(37,99,235,0.25); }
.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--expense-tint); color: var(--expense); border-color: transparent; }
.btn-danger:hover { background: var(--expense); color: white; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-full { width: 100%; justify-content: center; }
.link-danger {
  border: 0;
  background: none;
  color: var(--expense);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.link-danger:hover { text-decoration: underline; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}
.card-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 3px 0 0;
}
.card-body { padding: 4px 20px 20px; }
.card-body.flush { padding: 0; }

/* ── Metric cards ── */
.metrics-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.metric-meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.metric.hero {
  background: linear-gradient(135deg, var(--primary-tint), var(--primary-tint-2) 120%);
  border-color: #bfdbfe;
}
[data-theme="dark"] .metric.hero {
  background: linear-gradient(135deg, #1e3a8a55, #2563eb33);
  border-color: #3b82f655;
}
.metric.hero .metric-value { font-size: 34px; color: var(--text); }
.metric.hero .metric-label { color: var(--primary); font-weight: 700; }
.metric.hero::after {
  content: "";
  position: absolute;
  right: -30px; top: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,0.12), transparent 70%);
  pointer-events: none;
}
.metric.hero.negative {
  background: linear-gradient(135deg, var(--expense-tint), #fecdd3 120%);
  border-color: #fecaca;
}
[data-theme="dark"] .metric.hero.negative {
  background: linear-gradient(135deg, #4a1f2a, #7f1d1d33);
  border-color: #7f2d3b;
}

/* Color helpers */
.value-income, .amount-income { color: var(--income); }
.value-expense, .amount-expense { color: var(--expense); }
.delta-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.delta-pill.up { background: var(--income-tint); color: var(--income); }
.delta-pill.down { background: var(--expense-tint); color: var(--expense); }

/* ── Two-column dashboard grid ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  align-items: flex-start;
}
.col { display: flex; flex-direction: column; gap: 18px; }

/* ── Chart box ── */
.chart-box { position: relative; min-height: 280px; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap-tall { position: relative; height: 320px; }

/* ── Transaction rows ── */
.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  transition: background 0.15s ease;
  cursor: pointer;
}
.tx-row:hover { background: var(--bg); }
.tx-row:first-child { border-top: none; }
.tx-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.tx-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tx-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tx-amount {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-date {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

/* Category icon colors */
.tx-cat-Food { background: #fef3c7; color: #b45309; }
.tx-cat-Transportation { background: #dbeafe; color: #1d4ed8; }
.tx-cat-Transport { background: #dbeafe; color: #1d4ed8; }
.tx-cat-Housing { background: #ede9fe; color: #6d28d9; }
.tx-cat-Rent { background: #ede9fe; color: #6d28d9; }
.tx-cat-Utilities { background: #e0e7ff; color: #4338ca; }
.tx-cat-Entertainment { background: #f3e8ff; color: #7c3aed; }
.tx-cat-Shopping { background: #fce7f3; color: #be185d; }
.tx-cat-Healthcare { background: #d1fae5; color: #047857; }
.tx-cat-Health { background: #d1fae5; color: #047857; }
.tx-cat-Education { background: #ecfeff; color: #0891b2; }
.tx-cat-Salary { background: #ecfdf5; color: #059669; }
.tx-cat-Freelance { background: #cffafe; color: #0891b2; }
.tx-cat-Investment { background: #fef3c7; color: #b45309; }
.tx-cat-Gift { background: #fce7f3; color: #be185d; }
.tx-cat-Other { background: var(--bg); color: var(--text-muted); }

[data-theme="dark"] .tx-cat-Food { background: #78350f55; color: #fcd34d; }
[data-theme="dark"] .tx-cat-Transportation,
[data-theme="dark"] .tx-cat-Transport { background: #1e3a8a55; color: #93c5fd; }
[data-theme="dark"] .tx-cat-Housing,
[data-theme="dark"] .tx-cat-Rent { background: #4c1d9555; color: #c4b5fd; }
[data-theme="dark"] .tx-cat-Utilities { background: #312e8155; color: #a5b4fc; }
[data-theme="dark"] .tx-cat-Entertainment { background: #4c1d9555; color: #c4b5fd; }
[data-theme="dark"] .tx-cat-Shopping { background: #83184355; color: #f9a8d4; }
[data-theme="dark"] .tx-cat-Healthcare,
[data-theme="dark"] .tx-cat-Health { background: #064e3b55; color: #6ee7b7; }
[data-theme="dark"] .tx-cat-Education { background: #164e6355; color: #67e8f9; }
[data-theme="dark"] .tx-cat-Salary { background: #064e3b55; color: #6ee7b7; }
[data-theme="dark"] .tx-cat-Freelance { background: #164e6355; color: #67e8f9; }
[data-theme="dark"] .tx-cat-Investment { background: #78350f55; color: #fcd34d; }
[data-theme="dark"] .tx-cat-Gift { background: #83184355; color: #f9a8d4; }

/* ── Progress bars ── */
.bar {
  height: 9px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(.2,.8,.2,1);
}
.bar-fill.green { background: linear-gradient(90deg, #10b981, #059669); }
.bar-fill.yellow { background: linear-gradient(90deg, #f59e0b, #d97706); }
.bar-fill.red { background: linear-gradient(90deg, #ef4444, #dc2626); }
.bar-fill.purple { background: linear-gradient(90deg, #8b5cf6, #7c3aed); }
.bar-fill.blue { background: linear-gradient(90deg, #3b82f6, #2563eb); }

/* ── Budget list ── */
.budget-list { display: flex; flex-direction: column; gap: 16px; }
.budget-row { display: flex; flex-direction: column; gap: 6px; }
.budget-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.budget-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.budget-name .pct { color: var(--text-muted); font-weight: 500; font-size: 12px; }
.budget-vals { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.budget-vals .spent { color: var(--text); font-weight: 600; }

/* ── Bills ── */
.bill-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px dashed var(--border);
}
.bill-row:first-child { border-top: none; padding-top: 0; }
.bill-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.bill-name { font-size: 13px; font-weight: 600; }
.bill-due { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.bill-due.soon { color: var(--warning); font-weight: 600; }
.bill-amt { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bill-item-muted { opacity: 0.55; }

/* ── Goals ── */
.goal-list { display: flex; flex-direction: column; gap: 14px; }
.goal-row { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--border); }
.goal-row:first-child { border-top: none; padding-top: 0; }
.goal-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.goal-name { font-weight: 600; }
.goal-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.goal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.goal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.contribution-box {
  background: var(--purple-tint);
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
[data-theme="dark"] .contribution-box { border-color: #5b4b8a; }
.contribution-box span {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--purple);
  margin-bottom: 2px;
}
.contribution-box strong { display: block; color: var(--purple); font-size: 15px; }
.contribution-box small { display: block; color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.mini-contribution {
  background: var(--purple-tint);
  border: 1px solid #ddd6fe;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-top: 6px;
}
[data-theme="dark"] .mini-contribution { border-color: #5b4b8a; }
.mini-contribution span { display: block; font-size: 12px; font-weight: 600; color: var(--purple); }
.mini-contribution small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-income { background: var(--income-tint); color: var(--income); }
.badge-expense { background: var(--expense-tint); color: var(--expense); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.select {
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%23667085'%3E%3Cpath d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  font-weight: 500;
}
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

/* ── Table ── */
.tbl-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tbl thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.15s ease; }
.tbl tbody tr:hover { background: var(--bg); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tbl .actions { text-align: right; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.row-actions { display: flex; align-items: center; gap: 10px; }

/* ── Forms ── */
.form-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 24px;
}
.form-card .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.field .hint { font-size: 11.5px; color: var(--text-muted); font-weight: 400; }
.input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 13.5px;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.input::placeholder { color: var(--text-subtle); }
[data-theme="dark"] .input { background: #111827; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Segmented control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.seg {
  padding: 9px 12px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
}
.seg:hover { color: var(--text); }
.seg.active-income { background: var(--card); color: var(--income); box-shadow: var(--shadow-sm); }
.seg.active-expense { background: var(--card); color: var(--expense); box-shadow: var(--shadow-sm); }

/* Budget-specific forms */
.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}
.narrow-form { max-width: 760px; }
.metric-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: var(--card);
  font-weight: 700;
  font-size: 13.5px;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.toggle-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.budget-input-list { display: grid; gap: 10px; }
.budget-header-row,
.budget-input-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 160px 42px;
  align-items: center;
  gap: 12px;
}
.budget-header-row {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 12px 2px;
}
.budget-input-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.budget-name-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
}
.budget-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
[data-theme="dark"] .budget-name-input { background: #111827; }
.budget-add-row { border-style: dashed !important; }
.delete-check {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--expense);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.delete-check input { width: 15px; height: 15px; accent-color: var(--expense); }
.budget-total-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.budget-total-strip div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.budget-total-strip span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* ── Auth pages ── */
.auth-wrap {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 28px;
}
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 0 0 24px; }
.auth-form { display: grid; gap: 16px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }
.auth-switch a { font-weight: 600; }

/* ── Reports ── */
.reports-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.rtab {
  flex: 1;
  min-width: 100px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  padding: 9px 12px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.rtab:hover { color: var(--text); background: var(--card); }
.rtab.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.rtab-panel { display: none; }
.rtab-panel.active { display: block; }
.rcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.rcard-toolbar {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}
.rcard-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 18px;
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.stat-label { display: block; color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.stat-value { display: block; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.r-select {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 30px 8px 10px;
  background: var(--card);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='%23667085'%3E%3Cpath d='M6 8L2 4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
}
[data-theme="dark"] .r-select { background-color: var(--card); }

/* ── Settings ── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  max-width: 860px;
}
.settings-section { display: grid; gap: 16px; }
.theme-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.theme-option input:checked + .theme-option-card {
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.theme-preview { width: 100%; height: 52px; border-radius: 6px; border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; gap: 3px; padding: 6px; }
.theme-preview-light { background: #f6f7fb; }
.theme-preview-light .tp-bar { background: #fff; border-radius: 3px; height: 8px; border: 1px solid #e5e7eb; }
.theme-preview-light .tp-bar.accent { background: #2563eb; border-color: #2563eb; width: 60%; }
.theme-preview-dark { background: #0f172a; }
.theme-preview-dark .tp-bar { background: #1e293b; border-radius: 3px; height: 8px; border: 1px solid #334155; }
.theme-preview-dark .tp-bar.accent { background: #3b82f6; border-color: #3b82f6; width: 60%; }
.theme-label { font-weight: 700; font-size: 13px; color: var(--text); }
.currency-options { display: grid; gap: 8px; }
.currency-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.currency-option input { accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; }
.currency-option:has(input:checked) { border-color: var(--primary); background: var(--card); }
.currency-symbol {
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  flex-shrink: 0;
}
.currency-info strong { display: block; font-size: 14px; }
.currency-info small { color: var(--text-muted); font-size: 12px; }

/* ── Toast notifications ── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  min-width: 240px;
  max-width: 340px;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(.2,.8,.2,1);
}
.toast.success { border-left: 3px solid var(--income); }
.toast.error { border-left: 3px solid var(--expense); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Empty states ── */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-box {
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: grid;
  gap: 8px;
  justify-items: start;
}
.empty-box h3 { font-size: 15px; font-weight: 700; margin: 0; }
.empty-box p { font-size: 13.5px; color: var(--text-muted); margin: 0; }
.empty-mini { display: grid; justify-items: start; gap: 10px; }
.empty-state { color: var(--text-muted); font-style: italic; font-size: 13px; }

/* Spending pace alert */
.spending-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--warning-tint);
  border: 1px solid var(--warning);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
  color: var(--warning);
  font-size: 13.5px;
  margin-bottom: 16px;
}
[data-theme="dark"] .spending-alert { background: rgba(217,119,6,0.12); }
.spending-alert strong { font-weight: 700; }

/* Rollover banner */
.rollover-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--primary-tint);
  border: 1px solid var(--primary-tint-2);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.rollover-banner p { font-size: 13px; color: var(--text-muted); margin: 3px 0 0; }
.rollover-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* Bill due-soon badge */
.bill-days { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; background: var(--bg); color: var(--text-muted); }
.bill-days.soon { background: var(--warning-tint); color: var(--warning); }
.bill-days.overdue { background: var(--expense-tint); color: var(--expense); }

/* Show/hide password toggle */
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.password-toggle:hover { color: var(--text); background: var(--bg); }
.password-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.showing .icon-eye { display: none; }
.password-toggle.showing .icon-eye-off { display: inline-block; }

/* ── Misc ── */
.panel-subtext { color: var(--text-muted); font-size: 13px; }
.text-right { text-align: right !important; }

/* ── Mobile ── */
@media (max-width: 980px) {
  .metrics-row { grid-template-columns: 1fr 1fr; }
  .grid-2, .split-grid, .settings-grid { grid-template-columns: 1fr; }
  .form-card { grid-template-columns: 1fr; }
  .form-card .full { grid-column: span 1; }
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .topnav { padding: 0 16px; gap: 12px; }
  .page { padding: 16px 14px 50px; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .rcard-body { grid-template-columns: 1fr; }
  .budget-total-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .metrics-row { grid-template-columns: 1fr; }
  .metric.hero .metric-value { font-size: 28px; }
  .budget-input-row { grid-template-columns: 1fr; }
  .budget-header-row { display: none; }
  .budget-total-strip { grid-template-columns: 1fr; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }
  .tbl tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }
  .tbl td { display: flex; justify-content: space-between; gap: 12px; text-align: right !important; border-bottom: 1px solid var(--border); padding: 10px 14px; }
  .tbl td::before { content: attr(data-label); color: var(--text-muted); font-weight: 700; text-align: left; flex-shrink: 0; }
  .tbl td:last-child { border-bottom: none; }
  .stat-strip { grid-template-columns: 1fr; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px; left: 12px; right: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    z-index: 40;
  }
}
