/* ===== CSS Variables & Reset ===== */
:root {
  --bg: #f3f0f5;
  --bg-card: #ffffff;
  --bg-secondary: #f9f7fb;
  --bg-sidebar: #1F1238;
  --bg-sidebar-hover: #2a1845;
  --bg-sidebar-active: #3d2560;
  --text: #1F1238;
  --text-secondary: #6b5b7b;
  --text-sidebar: #b8a5cf;
  --text-sidebar-active: #ffffff;
  --border: #e2dce8;
  /* v229: brand palette per Opes Ledger Brand Guidelines page 5
     Aubergine #2D1B4E (primary) · Brass #C9A961 (accent) · Parchment #F5F1E8 (surface) */
  --primary: #2D1B4E;
  --primary-hover: #1F1238;
  --primary-light: #FAF7F0;
  --accent: #C9A961;
  --accent-light: #FAF3DC;
  --income: #059669;
  --income-light: #ecfdf5;
  --expense: #dc2626;
  --expense-light: #fef2f2;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --info: #7c3aed;
  --info-light: #f3edf9;
  --shadow-sm: 0 1px 2px rgba(26,14,46,0.04);
  --shadow: 0 1px 3px rgba(26,14,46,0.06), 0 1px 2px rgba(26,14,46,0.04);
  --shadow-md: 0 4px 12px rgba(26,14,46,0.08), 0 2px 4px rgba(26,14,46,0.04);
  --shadow-lg: 0 12px 24px rgba(26,14,46,0.12), 0 4px 8px rgba(26,14,46,0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-width: 260px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0d0818;
  --bg-card: #150e24;
  --bg-secondary: #1e1433;
  --border: #2a1d42;
  --text: #f1f0f5;
  --text-secondary: #b8a5cf;
  /* v229: dark-theme variants of the brand palette — keep aubergine deeper for
     contrast against #0d0818 bg, brass stays consistent */
  --primary: #6B5B8A;
  --primary-hover: #8e7ba8;
  --primary-light: #2a1545;
  --accent: #C9A961;
  --accent-light: #1a1505;
  --income-light: #052e16;
  --expense-light: #2d0a0a;
  --warning-light: #2d1a04;
  --info-light: #2a1545;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 24px rgba(0,0,0,0.5);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1F1238 0%, #120828 100%);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  /* v111: top offset driven by --banner-height so the subscription banner
     doesn't cover the sidebar logo. Falls back to 0 when banner is hidden. */
  top: var(--banner-height, 0);
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header {
  padding: 1.75rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.logo-text {
  font-family: 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', Times, serif;
  font-size: 1.05rem;
  font-weight: 500;
  font-style: normal;
  text-transform: uppercase;
  color: white;
  letter-spacing: 0.18em;
}

.nav-links {
  list-style: none;
  padding: 1.25rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #e2e8f0;
}

.nav-link:hover svg { opacity: 1; }

.nav-link.active {
  /* v229: active sidebar item gets a brass left-rule + brass-tinted gradient,
     matching the brand spec. Aubergine + brass appearing together. */
  background: linear-gradient(135deg, var(--bg-sidebar-active), rgba(201, 169, 97, 0.15));
  color: var(--text-sidebar-active);
  border-left: 3px solid #C9A961;
  font-weight: 600;
}

.nav-link.active svg { opacity: 1; color: #C9A961; }

/* Sub-navigation */
.nav-parent { position: relative; }

.nav-links .nav-parent ul.nav-sub {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-links .nav-parent.expanded ul.nav-sub {
  max-height: 200px;
}

.nav-sub-link {
  padding-left: 2.75rem !important;
  font-size: 0.85rem !important;
  opacity: 0.85;
}

.nav-sub-link svg {
  width: 16px !important;
  height: 16px !important;
}

.nav-sub-link.active {
  opacity: 1;
}

/* Nested sub-navigation (3rd level) */
.nav-sub-nested {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-sub-nested.expanded {
  max-height: 200px;
}

.nav-sub-nested-link {
  padding-left: 3.75rem !important;
  font-size: 0.8rem !important;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Mobile header */
.mobile-header {
  display: none;
  position: fixed;
  /* v111: top offset driven by --banner-height so the subscription banner
     doesn't cover the hamburger button and logo. Falls back to 0. */
  top: var(--banner-height, 0);
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(135deg, #1F1238, #120828);
  color: white;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.menu-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
}

.menu-btn svg { width: 24px; height: 24px; }

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2.25rem 2.5rem;
  /* v123: No max-width cap so the app fills the viewport on wide/fullscreen
     monitors. v124: width must subtract the sidebar width (sidebar is
     position:fixed, removed from flex flow, so width:100% = full viewport
     and the margin-left:var(--sidebar-width) pushes content past the right
     edge, causing horizontal scroll on narrow windows). calc() below makes
     main-content shrink to fit whatever space remains beside the sidebar. */
  width: calc(100% - var(--sidebar-width));
  box-sizing: border-box;
  min-width: 0;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header h2 {
  font-family: 'Times New Roman MT', 'Times New Roman', Times, serif;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.view-subtitle {
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-size: 0.925rem;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.view h2, .view h3, .card h3 {
  font-family: 'Times New Roman MT', 'Times New Roman', Times, serif;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header-row h3 { margin-bottom: 0; }

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.summary-card:hover {
  border-color: rgba(184,134,11,0.25);
  box-shadow: 0 4px 16px rgba(184,134,11,0.08);
}

/* v113: Clickable dashboard cards, stronger affordance, proper focus ring, */
/* and a press state so mobile taps feel responsive. */
.dashboard-card-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(59,26,94,0.12);
  transform: translateY(-1px);
}
.dashboard-card-link:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.dashboard-card-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Nested buttons (e.g. rollover "Roll over $X →"), info tips, and anchor
   links ("See all" on bottom-row cards) keep their own hover state separate
   from the parent card, prevents a confusing double-affordance and lets
   their own onclicks run without the parent card hijacking them. */
.dashboard-card-link button,
.dashboard-card-link .info-tip,
.dashboard-card-link a {
  position: relative;
  z-index: 1;
}

/* v133: Budget cards are clickable, drilling down to a pre-filtered
   Transactions view. Uses the same hover/focus affordance pattern as the
   dashboard cards for consistency. */
.budget-card-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.budget-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(59,26,94,0.12);
  transform: translateY(-1px);
}
.budget-card-link:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.budget-card-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.budget-card-link button {
  position: relative;
  z-index: 1;
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon svg { width: 24px; height: 24px; }

.income-icon { background: var(--income-light); color: var(--income); }
.expense-icon { background: var(--expense-light); color: var(--expense); }
.balance-icon { background: var(--primary-light); color: var(--primary); }
.savings-icon { background: var(--accent-light); color: var(--accent); }

.card-info { display: flex; flex-direction: column; }

.card-label {
  font-family: 'Times New Roman MT', 'Times New Roman', Times, serif;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 0.2rem;
}

/* ===== Charts ===== */
.charts-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card { min-height: 320px; }
.chart-container { position: relative; height: 260px; }
.chart-container-doughnut { height: 240px; display: flex; align-items: center; justify-content: center; }

/* ===== Dashboard Bottom ===== */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ===== Budget Progress Bars ===== */
.budget-item {
  margin-bottom: 1rem;
}

.budget-item:last-child { margin-bottom: 0; }

.budget-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.budget-item-label {
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.budget-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.budget-item-values {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}

[data-theme="dark"] .progress-bar {
  background: rgba(255,255,255,0.08);
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #1F1238);
  color: white;
  box-shadow: 0 2px 6px rgba(91,45,142,0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1F1238, #3a1a5e);
  box-shadow: 0 4px 12px rgba(91,45,142,0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--expense-light);
  color: var(--expense);
  border: 1px solid transparent;
}

.btn-danger:hover { background: var(--expense); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 0.4rem 0.75rem;
}

.btn-ghost:hover { background: var(--primary-light); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover { background: var(--bg); color: var(--text); }
[data-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,0.08); }

.btn-icon svg { width: 16px; height: 16px; }

.btn-toggle {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.btn-toggle.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.toggle-group { display: flex; gap: 0.5rem; }

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.link:hover { text-decoration: underline; }

.muted { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 0.75rem; }

/* ===== Filters ===== */
.filters-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  flex: 1;
  min-width: 200px;
  transition: border-color var(--transition);
}

.search-box:focus-within { border-color: var(--primary); }

[data-theme="dark"] .search-box { background: rgba(255,255,255,0.04); }

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.search-box input {
  border: none;
  background: transparent;
  padding: 0.6rem 0.5rem;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  width: 100%;
}

select {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

select:focus { border-color: var(--primary); }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }

.txn-table {
  width: 100%;
  border-collapse: collapse;
}

.txn-table th {
  text-align: left;
  padding: 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
}

.txn-table td {
  padding: 0.85rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.txn-table tr:hover td { background: var(--primary-light); }
.txn-row-selected td { background: rgba(99,102,241,0.08) !important; }
.txn-select-cb { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* Reviewed/processed transactions, compact display */
.txn-reviewed td {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
  opacity: 0.65;
  background: rgba(16,185,129,0.04);
}
.txn-reviewed:hover td { opacity: 1; }
.txn-reviewed td:nth-child(3)::before {
  content: '✓ ';
  color: var(--income);
  font-weight: 700;
}
.txn-reviewed .txn-category-badge { font-size: 0.7rem; padding: 0.15rem 0.5rem; }
.txn-reviewed .btn-icon { width: 22px; height: 22px; }
[data-theme="dark"] .txn-reviewed td { background: rgba(16,185,129,0.06); }

/* Auto-reviewed (rule-matched) transactions, needs verification */
.txn-auto-reviewed td {
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  background: rgba(234,179,8,0.06);
  border-left: 3px solid var(--warning);
}
.txn-auto-reviewed .txn-category-badge { font-size: 0.72rem; padding: 0.15rem 0.5rem; }
.txn-auto-reviewed .btn-icon { width: 24px; height: 24px; }
[data-theme="dark"] .txn-auto-reviewed td { background: rgba(234,179,8,0.08); }

/* Duplicate transfer detection */
.txn-dupe-row td { background: rgba(239,68,68,0.06); }
[data-theme="dark"] .txn-dupe-row td { background: rgba(239,68,68,0.1); }
.txn-dupe-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--expense);
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  margin-top: 0.25rem;
  cursor: pointer;
  transition: background 0.15s;
}
.txn-dupe-badge:hover { background: rgba(239,68,68,0.2); }
.dupe-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.text-right { text-align: right; }

.txn-amount-income { color: var(--income); font-weight: 700; }
.txn-amount-expense { color: var(--expense); font-weight: 700; }
.txn-amount-transfer { color: var(--info); font-weight: 700; }

.txn-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  font-size: 0.775rem;
  font-weight: 600;
  background: var(--bg);
  letter-spacing: 0.01em;
}

[data-theme="dark"] .txn-category-badge { background: rgba(255,255,255,0.06); }

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Budgets Grid ===== */
.budget-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.budget-month-nav h3 { margin: 0; }

/* v128: Budget page container. Groups (Fixed / Needs / Wants / Other) stack
   vertically, each spans the full content width. Inside each group,
   .budget-grid-inner has its own responsive auto-fill grid so cards flow
   into as many columns as the viewport allows (1 on mobile, 2-3 on tablet,
   4-6 on wide desktop). Previously this was a grid that forced groups to
   sit as side-by-side columns, wasting horizontal space on wide screens. */
.budgets-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.budget-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.budget-card-header h3 {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.budget-spent {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.budget-limit-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.budget-progress-lg {
  height: 12px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

[data-theme="dark"] .budget-progress-lg { background: rgba(255,255,255,0.08); }

.budget-progress-lg .progress-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }

.budget-remaining {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Accounts Grid ===== */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.account-card {
  position: relative;
  overflow: hidden;
}

.account-card-stripe {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.account-type-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.account-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.account-balance {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.account-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ===== Settings ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.settings-grid select {
  width: 100%;
}

.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 0.2rem;
  background: var(--bg);
}

[data-theme="dark"] .category-tag { background: rgba(255,255,255,0.06); }

.category-tag .remove-cat {
  cursor: pointer;
  margin-left: 0.2rem;
  opacity: 0.5;
  font-size: 1rem;
  line-height: 1;
}

.category-tag .remove-cat:hover { opacity: 1; }

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-form input[type="text"] {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition);
}

.inline-form input[type="text"]:focus { border-color: var(--primary); }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,14,46,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition);
  border: 1px solid var(--border);
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

/* ===== Forms ===== */
.form-group {
  margin-bottom: 1rem;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="color"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,45,142,0.15);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus {
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}

.empty-state p {
  margin-bottom: 0.5rem;
  font-size: 0.925rem;
}

/* ===== Goals ===== */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.goal-card {
  padding: 1.5rem;
}

.goal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.goal-card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.goal-amount {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.goal-target-text {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.goal-progress-lg {
  height: 10px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

[data-theme="dark"] .goal-progress-lg {
  background: rgba(255,255,255,0.08);
}

.goal-progress-lg .progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.goal-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.goal-contribute-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.goal-contribute-row input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
}

.goal-contribute-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,45,142,0.15);
}

.goal-linked-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  font-weight: 500;
}

.form-hint {
  display: block;
  font-size: 0.775rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ===== Bank Connections ===== */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.connection-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
}

.connection-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.connection-info {
  flex: 1;
  min-width: 0;
}

.connection-name {
  font-weight: 600;
  font-size: 0.925rem;
  margin-bottom: 0.15rem;
}

.connection-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ===== Categories ===== */
.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.category-row:last-child {
  border-bottom: none;
}

.category-row:hover {
  background: rgba(91,45,142,0.03);
}

[data-theme="dark"] .category-row:hover {
  background: rgba(255,255,255,0.03);
}

.category-row-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.category-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.category-row-name {
  font-weight: 500;
  font-size: 0.925rem;
}

.category-row-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0.4;
  transition: opacity var(--transition);
}

.category-row:hover .category-row-actions {
  opacity: 1;
}

.category-group-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-need {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.badge-want {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}

.badge-income {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

/* ===== Investments ===== */
.inv-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.positive { color: var(--income) !important; }
.negative { color: var(--expense) !important; }
.bold { font-weight: 700; }

/* ===== Auto-suggest ===== */
.suggest-dropdown {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 180px;
  overflow-y: auto;
  z-index: 300;
  font-size: 0.85rem;
}

.suggest-item {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background var(--transition);
}

.suggest-item:hover { background: var(--primary-light); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    /* v124: Reset width for mobile, sidebar slides off-screen here so the
       main content should span the full viewport. */
    width: 100%;
    padding: 1.25rem;
    /* v111: top padding = banner height + mobile header height + gap */
    padding-top: calc(var(--banner-height, 0px) + 60px + 1.25rem);
  }

  .charts-row { grid-template-columns: 1fr; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .view-header h2 { font-size: 1.5rem; }
}

/* ===== Auth Screen ===== */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #1F1238 0%, #2D1B4E 50%, #1F1238 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo img {
  /* v230: ceremonial mark sized 128px — brand book page 4 puts ceremonial
     marks at 120+px so the motto (LIVE · SAVE · COMPOUND) and est. year
     stay legible. Below that they get cramped. */
  width: 128px;
  height: 128px;
  margin-bottom: 1rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.auth-logo h2 {
  color: #ffffff;
  font-family: 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', serif;
  font-size: 1.5rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.auth-logo p {
  color: #b8a5cf;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.auth-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-card h2 {
  font-size: 1.25rem;
  color: #1F1238;
  margin-bottom: 0.25rem;
}

.auth-card .auth-subtitle {
  color: #6b5b7b;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.auth-card .form-group {
  margin-bottom: 1rem;
}

.auth-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #1F1238;
  margin-bottom: 0.35rem;
}

.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid #e2dce8;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #f9f7fb;
  color: #1F1238;
  transition: border-color 0.2s;
}

.auth-card input:focus {
  outline: none;
  border-color: #2D1B4E;
  box-shadow: 0 0 0 3px rgba(91,45,142,0.1);
}

.auth-btn {
  width: 100%;
  padding: 0.75rem;
  background: #2D1B4E;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 0.5rem;
}

.auth-btn:hover {
  background: #1F1238;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-toggle {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: #6b5b7b;
}

.auth-toggle a {
  color: #2D1B4E;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

.auth-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

.auth-success {
  background: #ecfdf5;
  color: #059669;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: none;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: #b8a5cf;
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2dce8;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: #b8a5cf;
}

.auth-footer a {
  color: #b8a5cf;
  text-decoration: underline;
}

/* ===== Landing Page ===== */
#landing-page {
  position: fixed;
  inset: 0;
  z-index: 9998;
  overflow-y: auto;
  background: #ffffff;
}

/* Nav */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(31, 18, 56, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(184, 165, 207, 0.15);
}

.landing-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #ffffff;
  font-family: 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', serif;
  font-size: 1.05rem;
  font-weight: 500;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.landing-nav-brand img {
  border-radius: 8px;
}

.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.landing-nav-links a {
  color: #b8a5cf;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.landing-nav-links a:hover {
  color: #ffffff;
}

.landing-nav-signin {
  cursor: pointer;
}

.landing-nav-cta {
  background: var(--accent, #b8860b);
  color: #ffffff;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.landing-nav-cta:hover {
  background: #9a7209;
}

/* Hero */
.landing-hero {
  background: linear-gradient(135deg, #1F1238 0%, #2D1B4E 50%, #1F1238 100%);
  padding: 5rem 1.5rem 4rem;
  text-align: center;
}

.landing-hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.landing-hero h1 {
  /* Brand spec page 6 lists Playfair Display as an acceptable alternative to
     Bodoni Moda for display headlines. Used here because Bodoni's high
     thin-stroke contrast breaks down against dark hero backgrounds — Playfair
     keeps the classical serif voice while staying legible at large sizes. */
  font-family: 'Playfair Display', 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', serif;
  font-size: 3rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.25px;
}

.landing-hero-sub {
  color: #b8a5cf;
  font-size: 1.15rem;
  line-height: 1.65;
  margin-bottom: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.landing-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.landing-btn-primary {
  /* v229: brand brass fallback aligned to #C9A961 spec value */
  background: var(--accent, #C9A961);
  color: #1F1238;
  border: none;
  padding: 0.85rem 2rem;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.landing-btn-primary:hover {
  background: #A88840; /* Brass Deep per brand book page 5 */
  transform: translateY(-1px);
}

.landing-btn-ghost {
  color: #b8a5cf;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.85rem 1.5rem;
  border: 1.5px solid rgba(184, 165, 207, 0.3);
  border-radius: 10px;
  transition: border-color 0.2s, color 0.2s;
}

.landing-btn-ghost:hover {
  border-color: #b8a5cf;
  color: #ffffff;
}

.landing-hero-note {
  color: rgba(184, 165, 207, 0.6);
  font-size: 0.8rem;
}

/* Hero Screenshot */
.landing-hero-screenshot {
  max-width: 960px;
  margin: 3rem auto 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(184, 165, 207, 0.15);
}

.landing-hero-screenshot img {
  width: 100%;
  display: block;
}

/* Sections */
.landing-section {
  padding: 4rem 1.5rem;
}

.landing-section-light {
  background: #ffffff;
}

.landing-section-dark {
  background: linear-gradient(135deg, #1F1238 0%, #2a1845 100%);
}

.landing-container {
  max-width: 1100px;
  margin: 0 auto;
}

.landing-section-title {
  /* Playfair Display (brand-approved alternative to Bodoni Moda) — holds up
     equally well on light and dark section backgrounds.
     v229: brass underline below the title to tie landing typography into the
     PDF section-header pattern. "Aubergine + brass must always appear
     together" — brand book page 5. */
  font-family: 'Playfair Display', 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', serif;
  font-size: 2rem;
  font-weight: 600;
  color: #1F1238;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: -0.25px;
  position: relative;
  padding-bottom: 0.65rem;
}

.landing-section-title::after {
  content: '';
  display: block;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 2px;
  background: #C9A961;
}

/* Same brass underline on dark sections, but the rule reads softer against
   the dark aubergine bg so we keep it visible. */
.landing-section-dark .landing-section-title::after {
  background: #C9A961;
  opacity: 0.85;
}

.landing-section-sub {
  text-align: center;
  color: #6b5b7b;
  font-size: 1.05rem;
  margin-bottom: 2.5rem;
}

/* Features Grid */
.landing-features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.landing-feature-card {
  background: #ffffff;
  border: 1px solid #e2dce8;
  border-radius: 14px;
  padding: 1.5rem;
  transition: box-shadow 0.25s, transform 0.2s;
}

.landing-feature-card:hover {
  box-shadow: 0 8px 24px rgba(31, 18, 56, 0.1);
  transform: translateY(-2px);
}

.landing-feature-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.landing-feature-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #1F1238;
  margin-bottom: 0.4rem;
}

.landing-feature-card p {
  font-size: 0.85rem;
  color: #6b5b7b;
  line-height: 1.55;
}

/* Showcase Grid */
.landing-showcase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.landing-showcase-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(184, 165, 207, 0.12);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
}

.landing-showcase-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.landing-showcase-item img {
  width: 100%;
  display: block;
  border-bottom: 1px solid rgba(184, 165, 207, 0.1);
}

.landing-showcase-item h4 {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  margin: 1rem 1.25rem 0.25rem;
}

.landing-showcase-item p {
  color: #b8a5cf;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 1.25rem 1.25rem;
}

/* How It Works */
.landing-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.landing-step {
  text-align: center;
  flex: 1;
  max-width: 240px;
}

.landing-step-num {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent, #C9A961);
  color: #1F1238;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.landing-step h3 {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.landing-step p {
  color: #b8a5cf;
  font-size: 0.9rem;
  line-height: 1.55;
}

.landing-step-arrow {
  flex-shrink: 0;
}

/* Pricing Grid */
.landing-pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.landing-price-card {
  background: #ffffff;
  border: 2px solid #e2dce8;
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  position: relative;
  transition: box-shadow 0.25s, transform 0.2s;
}

.landing-price-card:hover {
  box-shadow: 0 12px 32px rgba(31, 18, 56, 0.12);
  transform: translateY(-3px);
}

/* v229: "Most Popular" pricing card — brass border + badge instead of
   aubergine. Brass signals premium without competing visually with the
   aubergine primary CTAs. "Aubergine + brass must always appear together,
   brass is finish, not foreground" — brand book page 5. */
.landing-price-featured {
  border-color: #C9A961;
  box-shadow: 0 8px 24px rgba(201, 169, 97, 0.18);
}

.landing-price-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: #C9A961;
  color: #1F1238;
  padding: 2px 16px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.landing-price-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1F1238;
  margin-bottom: 0.5rem;
}

.landing-price {
  font-size: 2.25rem;
  font-weight: 800;
  color: #2D1B4E;
  margin-bottom: 0.25rem;
}

.landing-price span {
  font-size: 0.9rem;
  font-weight: 400;
  color: #6b5b7b;
}

.landing-price-desc {
  color: #6b5b7b;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.landing-price-features {
  list-style: none;
  padding: 0;
  text-align: left;
  margin-bottom: 1.5rem;
}

.landing-price-features li {
  padding: 0.35rem 0;
  font-size: 0.9rem;
  color: #1F1238;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.landing-price-features li::before {
  content: '\2713';
  color: #059669;
  font-weight: 700;
  flex-shrink: 0;
}

.landing-price-btn {
  width: 100%;
  padding: 0.75rem;
  border: 1.5px solid #e2dce8;
  border-radius: 10px;
  background: #f9f7fb;
  color: #1F1238;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.landing-price-btn:hover {
  background: #f3edf9;
  border-color: #2D1B4E;
}

.landing-price-btn-primary {
  background: #2D1B4E;
  color: #ffffff;
  border-color: #2D1B4E;
}

.landing-price-btn-primary:hover {
  background: #1F1238;
}

.landing-pricing-note {
  text-align: center;
  color: #6b5b7b;
  font-size: 0.8rem;
  margin-top: 1.5rem;
}

/* Trust */
.landing-trust-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  text-align: center;
  padding: 2rem 0;
  border-top: 1px solid #e2dce8;
}

.landing-trust-item h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #1F1238;
  margin: 0.75rem 0 0.25rem;
}

.landing-trust-item p {
  color: #6b5b7b;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Final CTA */
.landing-final-cta {
  padding: 4rem 1.5rem;
}

/* Footer */
/* v191: Trust strip beneath the hero */
.landing-trust-strip {
  background: #1F1238;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(184, 165, 207, 0.1);
  border-bottom: 1px solid rgba(184, 165, 207, 0.1);
}

.landing-trust-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
}

.landing-trust-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #d4c5e8;
  font-size: 0.9rem;
  font-weight: 500;
}

.landing-trust-icon {
  font-size: 1.1rem;
  display: inline-block;
}

/* v191: FAQ section */
.landing-faq-list {
  max-width: 720px;
  margin: 2rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.landing-faq-item {
  background: #ffffff;
  border: 1px solid rgba(60, 26, 94, 0.1);
  border-radius: 12px;
  padding: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.landing-faq-item[open] {
  border-color: rgba(60, 26, 94, 0.25);
  box-shadow: 0 4px 14px rgba(60, 26, 94, 0.06);
}

.landing-faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  color: #1F1238;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.landing-faq-item summary::-webkit-details-marker { display: none; }

.landing-faq-item summary::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 400;
  color: #6b5b7b;
  transition: transform 0.2s;
}

.landing-faq-item[open] summary::after {
  content: '−';
}

.landing-faq-item p {
  margin: 0;
  padding: 0 1.25rem 1.1rem;
  color: #4b3960;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Brand interlude — full-bleed ceremonial banner between Showcase and How It Works (v222) */
.landing-brand-interlude {
  background: #2D1B4E;
  padding: 0;
  width: 100%;
  display: block;
  overflow: hidden;
}

.landing-brand-banner {
  display: block;
  width: 100%;
  max-width: 1500px;
  height: auto;
  margin: 0 auto;
}

@media (max-width: 600px) {
  /* At narrow widths the wordmark in the banner gets small; add some breathing
     room so it doesn't look cramped against the next section. */
  .landing-brand-interlude {
    padding: 1rem 0;
  }
}

/* Footer */
.landing-footer {
  background: #1F1238;
  padding: 3rem 1.5rem 0;
  /* v229: brass hairline divides footer from page body — subtle finish,
     not a focal point. */
  border-top: 1px solid rgba(201, 169, 97, 0.25);
}

.landing-footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
  padding-bottom: 2rem;
}

.landing-footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.landing-footer-about {
  max-width: 320px;
}

.landing-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ffffff;
  font-family: 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', serif;
  font-weight: 500;
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.landing-footer-brand img {
  border-radius: 6px;
}

.landing-footer-blurb {
  color: #8e7ba8;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

.landing-footer-heading {
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem 0;
}

.landing-footer-col a {
  color: #b8a5cf;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.15rem 0;
  transition: color 0.15s;
}

.landing-footer-col a:hover {
  color: #ffffff;
}

.landing-footer-bottom {
  border-top: 1px solid rgba(184, 165, 207, 0.1);
  padding: 1rem 0;
}

.landing-footer-bottom-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.landing-footer-copy {
  color: #6b5b7b;
  font-size: 0.75rem;
}

.landing-footer-disclaimer {
  color: #6b5b7b;
  font-size: 0.75rem;
  font-style: italic;
}

/* Landing Responsive */
@media (max-width: 768px) {
  .landing-hero h1 {
    font-size: 2rem;
  }

  .landing-hero-sub {
    font-size: 1rem;
  }

  .landing-hero-actions {
    flex-direction: column;
  }

  .landing-features-grid {
    grid-template-columns: 1fr;
  }

  .landing-showcase-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero-screenshot {
    margin: 2rem -0.5rem 0;
    border-radius: 8px;
  }

  .landing-steps {
    flex-direction: column;
  }

  .landing-step-arrow {
    transform: rotate(90deg);
  }

  .landing-pricing-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .landing-trust-grid {
    grid-template-columns: 1fr;
  }

  .landing-nav-links a:not(.landing-nav-signin):not(.landing-nav-cta) {
    display: none;
  }

  .landing-footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .landing-footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .landing-footer-bottom-inner {
    flex-direction: column;
    text-align: center;
  }

  .landing-trust-list {
    gap: 1rem;
    flex-direction: column;
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .landing-features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .landing-showcase-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Subscription Banner ===== */
.subscription-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.subscription-banner .btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-weight: 600;
}

.banner-warning {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 2px solid #f59e0b;
}

.banner-warning .btn-sm {
  background: #f59e0b;
  color: #fff;
}

.banner-error {
  background: #fee2e2;
  color: #991b1b;
  border-bottom: 2px solid #ef4444;
}

.banner-error .btn-sm {
  background: #ef4444;
  color: #fff;
}

/* ===== Tier Selection ===== */
.tier-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  overflow-y: auto;
  padding: 2rem 1rem;
  display: none;
}

.tier-header {
  text-align: center;
  margin-bottom: 2rem;
}

.tier-header h2 {
  font-size: 1.75rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.tier-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.tier-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.tier-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.tier-card.recommended {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.tier-card.recommended::before {
  content: 'Most Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  padding: 2px 16px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tier-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.tier-price {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.tier-price span {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.tier-features {
  list-style: none;
  text-align: left;
  margin: 1.25rem 0;
  padding: 0;
}

.tier-features li {
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.tier-features li::before {
  content: '✓';
  color: var(--income);
  font-weight: 700;
  flex-shrink: 0;
}

.tier-features li.locked::before {
  content: ',';
  color: var(--text-secondary);
}

.tier-features li.locked {
  color: var(--text-secondary);
}

.tier-btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.tier-btn-primary {
  background: var(--primary);
  color: white;
}

.tier-btn-primary:hover {
  background: var(--primary-hover);
}

.tier-btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.tier-btn-secondary:hover {
  border-color: var(--primary);
}

/* Tier badge in sidebar */
.tier-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.tier-badge-pro {
  background: linear-gradient(135deg, #d4a017, #f5c842);
  color: #1F1238;
}

.tier-badge-plus {
  background: linear-gradient(135deg, #2D1B4E, #7c3aed);
  color: white;
}

/* Locked feature overlay */
.feature-locked {
  position: relative;
}

.feature-locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(var(--bg), 0.7);
  backdrop-filter: blur(2px);
  border-radius: var(--radius);
  z-index: 10;
}

.upgrade-prompt {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  border: 1.5px solid var(--primary);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.upgrade-prompt h3 {
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.upgrade-prompt p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.upgrade-prompt .btn {
  background: var(--primary);
  color: white;
}

@media (max-width: 768px) {
  /* v128: Budget page tweaks for narrow viewports. Group header (label +
     subtotal) wraps to two lines when there isn't enough room, cards
     drop to a single column within each group, group padding trimmed. */
  .budget-group-section {
    padding: 0.5rem !important;
  }
  .budget-group-section > div:first-child {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .budget-grid-inner {
    grid-template-columns: 1fr !important;
  }

  .tier-grid {
    grid-template-columns: 1fr;
  }
  .auth-container {
    max-width: 100%;
  }
}

/* ===== Investments: grouped-by-account layout ===== */
.inv-account-group { margin-bottom: 1rem; padding: 1rem 1.25rem; }
.inv-account-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 0.75rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border); margin-bottom: 0.85rem;
}
.inv-account-title { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.inv-account-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.inv-account-type-badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
.inv-account-totals { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-size: 0.85rem; }
.inv-totals-row { white-space: nowrap; }
.inv-holdings-list { display: flex; flex-direction: column; gap: 0.55rem; }
.inv-holding-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
.inv-holding-main { min-width: 0; }
.inv-holding-name { font-weight: 600; font-size: 0.95rem; line-height: 1.25; word-break: break-word; }
.inv-holding-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.15rem; }
.inv-holding-values { text-align: right; display: flex; flex-direction: column; gap: 0.15rem; min-width: 110px; }
.inv-holding-current { font-size: 1rem; font-weight: 700; }
.inv-holding-book { font-size: 0.72rem; }
.inv-holding-gain { font-size: 0.8rem; font-weight: 600; }
.inv-holding-actions { display: flex; gap: 0.35rem; align-items: center; flex-shrink: 0; }
.inv-empty-holdings {
  padding: 0.75rem 0.25rem; text-align: left; color: var(--text-secondary);
  font-size: 0.88rem;
}

/* Mobile: stack holding card vertically */
@media (max-width: 640px) {
  .inv-account-group { padding: 0.85rem 0.9rem; }
  .inv-account-header { flex-direction: column; align-items: stretch; }
  .inv-account-totals { justify-content: flex-start; font-size: 0.8rem; }
  .inv-holding-card {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main   vals"
      "actions actions";
    row-gap: 0.5rem;
  }
  .inv-holding-main { grid-area: main; }
  .inv-holding-values { grid-area: vals; min-width: 0; }
  .inv-holding-actions { grid-area: actions; justify-content: flex-end; padding-top: 0.35rem; border-top: 1px dashed var(--border); }
}

/* ===== Mobile Card Views (≤640px) =====
   Converts horizontally-scrolling tables into stacked cards so each row fits
   on one screen without side-scrolling. Scoped per-view because each table
   has different columns. */
@media (max-width: 640px) {
  /* --- Transactions table (columns: checkbox, date, desc, cat, acct, amount, actions) --- */
  #view-transactions .table-container { overflow-x: visible; }
  #view-transactions .txn-table { border-collapse: separate; border-spacing: 0; }
  #view-transactions .txn-table thead { display: none; }
  #view-transactions .txn-table,
  #view-transactions .txn-table tbody { display: block; width: 100%; }
  #view-transactions .txn-table tr {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    grid-template-areas:
      "cb   desc    amt"
      "cb   date    amt"
      "cb   cat     cat"
      "cb   acct    acct"
      ".    actions actions";
    column-gap: 0.6rem;
    row-gap: 0.2rem;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    align-items: start;
  }
  #view-transactions .txn-table tr:hover td { background: transparent; }
  #view-transactions .txn-table td {
    display: block; border: none !important; padding: 0;
    font-size: 0.85rem; min-width: 0; word-break: break-word;
  }
  #view-transactions .txn-table td:nth-child(1) { grid-area: cb; align-self: center; }
  #view-transactions .txn-table td:nth-child(2) { grid-area: date; font-size: 0.72rem; color: var(--text-secondary); }
  #view-transactions .txn-table td:nth-child(3) { grid-area: desc; font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
  #view-transactions .txn-table td:nth-child(4) { grid-area: cat; font-size: 0.75rem; }
  #view-transactions .txn-table td:nth-child(5) { grid-area: acct; font-size: 0.72rem; color: var(--text-secondary); }
  #view-transactions .txn-table td:nth-child(6) { grid-area: amt; font-size: 1rem; font-weight: 700; text-align: right; white-space: nowrap; align-self: start; }
  #view-transactions .txn-table td:nth-child(7) { grid-area: actions; text-align: right; padding-top: 0.25rem; border-top: 1px dashed var(--border) !important; margin-top: 0.25rem; }
  #view-transactions .txn-table td:nth-child(2)::before { content: "📅 "; }
  #view-transactions .txn-table td:nth-child(5)::before { content: "🏦 "; }
  #view-transactions .txn-reviewed td { padding: 0; }
  #view-transactions .table-footer { flex-wrap: wrap; gap: 0.4rem; font-size: 0.8rem; }

  /* v114.1: Projected-group header rows must opt OUT of the grid-card mobile
     treatment, colspan is ignored once each <tr> is display:grid, so the
     single <td> gets squeezed into the 28px "cb" column and text wraps one
     character per line. Restore sensible block layout for these rows only. */
  #view-transactions .txn-table tr.projected-group-header {
    display: block;
    padding: 0.75rem 0.9rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left-width: 3px;
    border-left-style: dashed;
    border-left-color: #3b82f6;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    column-gap: 0;
    row-gap: 0;
  }
  #view-transactions .txn-table tr.projected-group-header td {
    display: block;
    padding: 0;
    border: none !important;
    grid-area: unset;
    font-size: 0.9rem;
    word-break: normal;
    white-space: normal;
    color: var(--text);
  }
  #view-transactions .txn-table tr.projected-group-header td::before { content: "" !important; }
  /* Subtle visual differentiation for expanded upcoming-body rows so users can
     see which cards belong to the upcoming group. Applied via [data-upcoming]. */
  #view-transactions .txn-table tr[data-upcoming]:not(.projected-group-header) {
    border-left-width: 3px;
    border-left-style: dashed;
    border-left-color: #93c5fd;
    margin-left: 0.5rem;
  }
  /* Month sub-pills: lighter background + slight indent to show nesting under the master row. */
  #view-transactions .txn-table tr.upcoming-month-pill {
    background: #f0f9ff;
    border-left-color: #60a5fa;
    margin-left: 0.5rem;
  }
  #view-transactions .txn-table .btn-icon { padding: 0.5rem; }
  #view-transactions .filters-row { flex-direction: column; align-items: stretch; }
  #view-transactions .filters-row input,
  #view-transactions .filters-row select { width: 100%; }

  /* --- Dashboard Recent Transactions (columns: date, desc, cat, acct, amount) --- */
  #view-dashboard #dashboard-transactions { overflow-x: visible; }
  #view-dashboard .txn-table { border-collapse: separate; border-spacing: 0; }
  #view-dashboard .txn-table thead { display: none; }
  #view-dashboard .txn-table,
  #view-dashboard .txn-table tbody { display: block; width: 100%; }
  #view-dashboard .txn-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "desc amt"
      "date amt"
      "cat  cat"
      "acct acct";
    column-gap: 0.6rem;
    row-gap: 0.2rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    align-items: start;
  }
  #view-dashboard .txn-table tr:hover td { background: transparent; }
  #view-dashboard .txn-table td {
    display: block; border: none !important; padding: 0;
    font-size: 0.8rem; min-width: 0; word-break: break-word;
  }
  #view-dashboard .txn-table td:nth-child(1) { grid-area: date; font-size: 0.72rem; color: var(--text-secondary); }
  #view-dashboard .txn-table td:nth-child(1)::before { content: "📅 "; }
  #view-dashboard .txn-table td:nth-child(2) { grid-area: desc; font-size: 0.92rem; font-weight: 600; line-height: 1.25; }
  #view-dashboard .txn-table td:nth-child(3) { grid-area: cat; font-size: 0.75rem; }
  #view-dashboard .txn-table td:nth-child(4) { grid-area: acct; font-size: 0.72rem; color: var(--text-secondary); }
  #view-dashboard .txn-table td:nth-child(4)::before { content: "🏦 "; }
  #view-dashboard .txn-table td:nth-child(5) { grid-area: amt; font-size: 1rem; font-weight: 700; text-align: right; white-space: nowrap; align-self: start; }

  /* Investments uses its own account-grouped card layout (see .inv-* classes above) ,
     no table-based mobile override needed. */
}

/* ===== v103: Mobile (≤640px) Borrowed Investing & Investments, prevent side-scroll ===== */
@media (max-width: 640px) {
  /* ---- Borrowed Investing: prevent tables from horizontal-scrolling ----
     Convert ledger, borrow txn log, prepayment, and reborrow tables to stacked cards */
  #view-borrowed .table-container { overflow-x: visible; }
  #view-borrowed table.txn-table { border-collapse: separate; border-spacing: 0; width: 100%; }
  #view-borrowed table.txn-table thead { display: none; }
  #view-borrowed table.txn-table,
  #view-borrowed table.txn-table tbody { display: block; width: 100%; }
  #view-borrowed table.txn-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.3rem 0.75rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg, #fff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    align-items: start;
  }
  #view-borrowed table.txn-table tr:hover td { background: transparent; }
  #view-borrowed table.txn-table td {
    display: block; border: none !important; padding: 0;
    font-size: 0.82rem; min-width: 0; word-break: break-word; white-space: normal;
  }
  /* Make any amount/right-aligned cell stick to the right column */
  #view-borrowed table.txn-table td.text-right { text-align: right; grid-column: 2; }

  /* Card headers & content wrap properly */
  #view-borrowed .view-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  #view-borrowed .card { padding: 1rem; }
  #view-borrowed .card-header-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  #view-borrowed .summary-cards { grid-template-columns: 1fr; }
  #view-borrowed .card-value { word-break: break-word; }
  #view-borrowed .summary-card { min-width: 0; }

  /* Prevent any overflow from the cycle visual or scenario cards */
  #view-borrowed #recycling-cycle-visual,
  #view-borrowed #rental-recycling-cycle-visual,
  #view-borrowed #debt-conv-recycling-cycle-visual {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Shrink the visual blocks on mobile */
  #view-borrowed #recycling-cycle-visual > div:first-child,
  #view-borrowed #rental-recycling-cycle-visual > div:first-child,
  #view-borrowed #debt-conv-recycling-cycle-visual > div:first-child {
    flex-wrap: wrap; justify-content: flex-start;
  }

  /* Info banner icon shouldn't lock layout */
  #view-borrowed .card > div[style*="display:flex"] { flex-wrap: wrap; }

  /* Scenario calculator grid single column */
  #view-borrowed #scenario-cards { grid-template-columns: 1fr; }

  /* Filters row in ledger */
  #view-borrowed .form-group { min-width: 0 !important; width: 100%; }

  /* ---- Investments page: ensure summary cards stack + no overflow ---- */
  #view-investments .summary-cards { grid-template-columns: 1fr; }
  #view-investments .view-header { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  #view-investments .view-header > div[style*="display:flex"] { flex-wrap: wrap; }
  #view-investments .charts-row { grid-template-columns: 1fr; }
  #view-investments .card-value { word-break: break-word; }
  #view-investments .inv-account-group { padding: 0.85rem 0.9rem; }
  #view-investments table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ===== v104: Mortgage form tabs, lifecycle table, HELOC inputs, borrowed chips, tip banner ===== */
  /* Mortgage modal, two-tab form */
  #modal-mortgage .mtg-tab-btn {
    padding: 0.55rem 0.65rem !important;
    font-size: 0.85rem !important;
    flex: 1 1 auto;
    text-align: center;
  }
  #modal-mortgage .mtg-tab-btn + .mtg-tab-btn { border-left: none; }
  #modal-mortgage #mtg-tip-banner {
    font-size: 0.78rem !important;
    padding: 0.6rem 0.75rem !important;
  }
  #modal-mortgage .modal-body > div[role="tablist"],
  #modal-mortgage div[style*="role:tablist"] {
    flex-wrap: wrap;
  }
  /* Ensure readvanceable inputs stack on mobile */
  #mtg-readvanceable-fields > div,
  #mtg-readvanceable-fields .form-group {
    min-width: 0 !important;
    width: 100%;
  }

  /* Mortgage lifecycle table */
  .mtg-lifecycle-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mtg-lifecycle-table {
    min-width: 320px;
    font-size: 0.75rem !important;
  }
  .mtg-lifecycle-table th,
  .mtg-lifecycle-table td {
    padding: 0.4rem 0.5rem !important;
  }

  /* Borrowed purpose chips */
  .borrowed-chips-row {
    gap: 0.4rem !important;
  }
  .borrowed-chip {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.72rem !important;
  }
  .borrowed-chip span:last-child {
    padding: 0.1rem 0.4rem !important;
    font-size: 0.65rem !important;
  }

  /* Legacy BI panel table on mobile, also follow the stack-to-cards pattern */
  #borrowed-legacy-panel .txn-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.3rem 0.75rem;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg, #fff);
  }
  #borrowed-legacy-panel .txn-table thead { display: none; }
  #borrowed-legacy-panel .txn-table td {
    display: block;
    border: none !important;
    padding: 0 !important;
    font-size: 0.8rem;
  }
  #borrowed-legacy-panel .txn-table td:nth-child(3),
  #borrowed-legacy-panel .txn-table td:nth-child(4),
  #borrowed-legacy-panel .txn-table td:nth-child(5) {
    text-align: right;
    grid-column: 2;
  }

  /* View-header with two buttons should wrap on narrow screens */
  #view-borrowed .view-header > div[style*="display:flex"] { flex-wrap: wrap; width: 100%; }
  #view-borrowed .view-header button { flex: 1 1 auto; }

  /* Tip-banner variants */
  .record-new-borrow-tip,
  .convert-legacy-tip {
    font-size: 0.75rem !important;
    padding: 0.55rem 0.7rem !important;
  }

  /* ===== v105: Mortgage-payment auto-split + rent/mortgage migration ===== */
  /* Mortgage picker row stacks full-width */
  #txn-mortgage-group {
    width: 100%;
  }
  #txn-mortgage-group select {
    width: 100%;
  }
  #txn-mortgage-split-preview {
    line-height: 1.35;
    word-break: break-word;
  }

  /* v105 rent/mortgage migration banner */
  #v105-rent-mortgage-banner > div {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  #v105-rent-mortgage-banner button {
    flex: 1 1 auto;
  }

  /* v105 rent/mortgage migration modal, convert rows to cards */
  #modal-rent-mortgage-migrate .rm-migrate-tablewrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #modal-rent-mortgage-migrate .txn-table {
    min-width: 0;
  }
  #modal-rent-mortgage-migrate .txn-table thead {
    display: none;
  }
  #modal-rent-mortgage-migrate .txn-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.25rem 0.75rem;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg, #fff);
  }
  #modal-rent-mortgage-migrate .txn-table td {
    display: block;
    border: none !important;
    padding: 0 !important;
    font-size: 0.82rem;
  }
  #modal-rent-mortgage-migrate .txn-table td:nth-child(3) {
    text-align: right;
    grid-column: 2;
  }
  #modal-rent-mortgage-migrate .txn-table td:nth-child(5) {
    grid-column: 1 / -1;
  }
  #modal-rent-mortgage-migrate .txn-table select {
    width: 100%;
  }

  /* v105 split-transaction badge should wrap cleanly */
  .txn-table .txn-category-badge {
    white-space: normal;
  }

  /* ===== v106: Editable split editor, radio link-mode toggle, linked-HELOC LOC cards ===== */
  /* Stack interest/principal inputs vertically on narrow screens */
  #txn-mortgage-split-editor .form-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  #txn-mortgage-split-editor .form-group {
    width: 100%;
    min-width: 0;
  }
  /* iOS: input font-size >= 16px prevents auto-zoom on focus */
  #txn-mortgage-split-editor input {
    font-size: 16px;
  }
  /* Radio link-mode toggle stays single-column inside readvanceable section */
  #mtg-readvanceable-fields label[style*="flex"] {
    width: 100%;
  }
  #mtg-heloc-existing-picker select,
  #mtg-heloc-existing-picker {
    width: 100%;
  }
  /* LOC card linked-mortgage subtitle wraps cleanly on narrow screens */
  .acct-linked-mtg-subtitle,
  .acct-linked-mtg-helper {
    word-break: break-word;
    white-space: normal;
    line-height: 1.3;
  }
}

/* ===== Print Styles ===== */
@media print {
  /* Hide all app UI */
  .sidebar,
  .mobile-header,
  .no-print,
  .modal-overlay,
  .modal,
  .filters-row {
    display: none !important;
  }

  /* Reset layout */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: #fff !important;
    font-family: 'Times New Roman MT', 'Times New Roman', Times, serif;
    color: #1F1238 !important;
    font-size: 11pt;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* Show only the reports view */
  .view { display: none !important; }
  .view#view-reports { display: block !important; }

  /* Hide the normal view header, we use the branded cover instead */
  #view-reports > .view-header {
    display: none !important;
  }

  /* ===== Branded Report Cover Header (v223: tightened + brand-correct) ===== */
  .print-cover {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.75rem 1rem 0.85rem;
    border-bottom: 2px solid #2D1B4E;
    margin-bottom: 1rem;
    page-break-after: avoid;
  }

  .print-cover-logo {
    display: flex !important;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
  }

  /* v223: real brand mark image, replaces the old CSS-drawn "$" placeholder.
     v224: kept for backward-compat but the live cover now uses inline SVG
     (.print-cover-svg below) so the mark renders crisp at any print DPI. */
  .print-cover-img {
    width: 38px;
    height: 38px;
    display: block;
  }

  /* v224: inline SVG brand mark on PDF cover — vector, no load race */
  .print-cover-svg {
    width: 48px;
    height: 48px;
    display: block;
  }

  .print-cover-name {
    font-family: 'Bodoni Moda', 'Times New Roman MT', 'Times New Roman', Times, serif;
    font-size: 20pt;
    font-weight: 500;
    color: #2D1B4E;
    letter-spacing: 0.15em;
    text-transform: uppercase;
  }

  .print-cover-title {
    font-family: 'Playfair Display', 'Bodoni Moda', 'Times New Roman MT', serif;
    font-size: 13pt;
    color: #2D1B4E;
    font-weight: 600;
    margin-top: 0.1rem;
    margin-bottom: 0.3rem;
  }

  .print-cover-meta {
    font-size: 9pt;
    color: #6b5b7b;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }

  .print-cover-divider {
    width: 48px;
    height: 2px;
    background: linear-gradient(90deg, #2D1B4E, #C9A961);
    margin: 0.5rem auto 0;
    border: none;
  }

  /* ===== Section Headers ===== */
  .print-section-header {
    display: block !important;
    font-family: 'Playfair Display', 'Bodoni Moda', 'Times New Roman MT', serif;
    font-size: 12pt;
    font-weight: 600;
    color: #2D1B4E;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 2px solid #C9A961;
    padding-bottom: 0.3rem;
    margin: 1rem 0 0.5rem;
    page-break-after: avoid;
    break-after: avoid;
  }

  /* ===== Cards (v223: tighter spacing so more fits per page) ===== */
  .card {
    box-shadow: none !important;
    border: 1px solid #d8d0e3 !important;
    border-radius: 6px !important;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 0.5rem !important;
    padding: 0.6rem 0.75rem !important;
  }

  .card h3 {
    font-family: 'Playfair Display', 'Bodoni Moda', 'Times New Roman MT', serif;
    font-size: 11pt !important;
    font-weight: 600;
    color: #2D1B4E !important;
    margin-bottom: 0.4rem;
  }

  .card-header-row h3 {
    margin-bottom: 0;
  }

  /* ===== Summary Cards ===== */
  .summary-cards {
    display: flex !important;
    gap: 0.6rem;
    flex-wrap: wrap;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 0.75rem !important;
  }

  .summary-card {
    box-shadow: none !important;
    border: 1px solid #d8d0e3 !important;
    border-radius: 6px !important;
    padding: 0.75rem !important;
  }

  .card-label {
    font-size: 8pt !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b5b7b !important;
  }

  .card-value {
    font-size: 13pt !important;
    font-weight: 700;
  }

  .card-icon {
    width: 36px !important;
    height: 36px !important;
  }

  /* ===== Charts ===== */
  canvas {
    max-width: 100% !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .chart-container,
  [style*="height:400px"],
  [style*="height:420px"] {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* ===== Expand "Other" for print ===== */
  #other-cat-breakdown {
    max-height: none !important;
    overflow: visible !important;
  }
  #other-chevron {
    display: none !important;
  }
  #other-cat-row {
    cursor: default !important;
  }

  /* ===== Budget color dots ===== */
  .budget-color-dot {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ===== Page Footer ===== */
  .print-footer {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    font-size: 8pt;
    color: #9ca3af;
    margin-top: 2rem;
    padding-top: 0.75rem;
    border-top: 1px solid #d8d0e3;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }

  .print-footer-left {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .print-footer-icon {
    width: 16px;
    height: 16px;
    background: #2D1B4E;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #C9A961;
    font-size: 7pt;
    font-weight: 700;
    font-family: Arial, sans-serif;
  }

  /* v223: actual brand mark in footer instead of "$" placeholder */
  .print-footer-img {
    width: 16px;
    height: 16px;
    display: block;
  }

  /* v224: inline SVG version of footer mark */
  .print-footer-svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  /* ===== Page Settings (v223: slightly tighter margins) ===== */
  @page {
    margin: 0.5in 0.65in;
    size: letter;
  }

  @page :first {
    margin-top: 0.3in;
  }
}
