:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --surface-muted: #eef2f0;
  --text: #151b18;
  --muted: #737b77;
  --border: #e4e9e6;
  --primary: #2f8a68;
  --primary-strong: #247356;
  --primary-soft: #e9f5ef;
  --green: #4ba57f;
  --green-soft: #eaf7f1;
  --red: #d45859;
  --red-soft: #fbecec;
  --blue: #3976d8;
  --blue-soft: #ebf2fd;
  --navy: #213c83;
  --navy-soft: #edf0fb;
  --amber: #c58b2d;
  --amber-soft: #fff5df;
  --shadow: 0 14px 34px rgba(31, 52, 42, 0.07), 0 2px 7px rgba(31, 52, 42, 0.04);
  --shadow-soft: 0 7px 22px rgba(31, 52, 42, 0.06);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

body.dark {
  color-scheme: dark;
  --bg: #111613;
  --surface: #1a211d;
  --surface-soft: #202923;
  --surface-muted: #273229;
  --text: #f4f7f5;
  --muted: #a7b0aa;
  --border: #303b34;
  --primary: #65c79d;
  --primary-strong: #7dd8b3;
  --primary-soft: #1e3a2e;
  --green: #70d1aa;
  --green-soft: #1e3a2e;
  --red: #ff8384;
  --red-soft: #422526;
  --blue: #72a9ff;
  --blue-soft: #21344e;
  --navy: #9fb8ff;
  --navy-soft: #26304b;
  --amber: #f0bc61;
  --amber-soft: #40341f;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
  --shadow-soft: 0 7px 22px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.hidden { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.ui-icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 17px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 5px 8px 25px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border-radius: 15px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: -0.02em; }
.brand > div > span { margin-top: 3px; color: var(--muted); font-size: 11px; }

.nav-list { display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  min-height: 49px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 750;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item:hover { transform: translateX(2px); color: var(--text); background: var(--surface-soft); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
.nav-icon { width: 25px; text-align: center; font-size: 21px; line-height: 1; }
.nav-label { white-space: nowrap; }
.sidebar-footer { margin-top: auto; display: grid; gap: 11px; }
.privacy-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px;
  border-radius: 13px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 11px;
  line-height: 1.4;
  font-weight: 750;
}

.main-content {
  min-width: 0;
  padding: 0 34px 56px;
}
.main-content > * { max-width: 1480px; margin-left: auto; margin-right: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  max-width: none;
  margin: 0 -34px 35px;
  padding: 18px 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.page-heading .eyebrow { margin-bottom: 3px; }
.topbar h1, .section-title-row h2, .section-toolbar h2, .panel h3 { margin: 0; }
.topbar h1 { font-size: 24px; letter-spacing: -0.035em; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.sync-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-status[data-state="syncing"] .sync-status-dot { background: #d89a1d; animation: sync-pulse 1s ease-in-out infinite; }
.sync-status[data-state="synced"] .sync-status-dot { background: var(--primary); }
.sync-status[data-state="offline"], .sync-status[data-state="error"] { color: var(--red); }
.sync-status[data-state="offline"] .sync-status-dot, .sync-status[data-state="error"] .sync-status-dot { background: var(--red); }
@keyframes sync-pulse { 50% { opacity: .35; transform: scale(.8); } }
.profile-button {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border));
  border-radius: 16px;
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--shadow-soft);
}
.profile-button:hover { transform: translateY(-1px); border-color: var(--primary); }
.profile-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.profile-button > span { position: absolute; right: 4px; bottom: 4px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--muted); }
.profile-button.authenticated > span { background: var(--primary); }
.month-navigation {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.month-arrow {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: transparent;
  font-size: 27px;
  line-height: 1;
}
.month-arrow:hover { color: var(--primary); background: var(--primary-soft); }
.month-picker {
  position: relative;
  min-width: 174px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  cursor: pointer;
}
.month-picker strong { font-size: 15px; }
.month-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.section-title-row, .section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 25px;
}
.section-title-row h2, .section-toolbar h2 {
  font-size: clamp(29px, 3vw, 42px);
  letter-spacing: -0.045em;
}

.primary-button, .secondary-button, .ghost-button, .danger-button, .soft-action-button, .link-button, .icon-button {
  border: 0;
  font-weight: 750;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.primary-button, .secondary-button, .ghost-button, .danger-button, .soft-action-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 14px;
}
.primary-button { color: #fff; background: var(--primary); box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 24%, transparent); }
.primary-button:hover { background: var(--primary-strong); transform: translateY(-1px); }
.secondary-button { color: var(--primary); background: var(--primary-soft); }
.ghost-button { color: var(--text); background: var(--surface-soft); border: 1px solid var(--border); }
.danger-button { color: var(--red); background: var(--red-soft); }
.soft-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}
.soft-action-button:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); transform: translateY(-1px); }
.link-button { padding: 4px; color: var(--primary); background: transparent; }
.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 20px;
}
.icon-button:hover { color: var(--primary); }
.icon-button .ui-icon, .nav-icon .ui-icon { width: 22px; height: 22px; }
.full-width { width: 100%; }

.app-section { display: none; }
.app-section.active { display: block; }

/* Dashboard inspired by the supplied mobile references */
.overview-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.7fr);
  gap: 20px;
  margin-bottom: 20px;
}
.wealth-card {
  --mask-color: #fff;
  position: relative;
  min-height: 260px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 31px 34px 27px;
  border-radius: var(--radius-xl);
  color: #fff;
  background:
    radial-gradient(circle at 75% 10%, rgba(255,255,255,0.12), transparent 22%),
    linear-gradient(120deg, #55b58a 0%, #2e815f 48%, #205f46 100%);
  box-shadow: 0 22px 45px rgba(35, 104, 77, 0.2);
}
.wealth-card.negative {
  background:
    radial-gradient(circle at 75% 10%, rgba(255,255,255,0.12), transparent 22%),
    linear-gradient(120deg, #d76565 0%, #b63e47 48%, #842d37 100%);
  box-shadow: 0 22px 45px rgba(146, 45, 54, 0.24);
}
.wealth-card::before, .wealth-card::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 50%;
  right: -85px;
  top: -100px;
}
.wealth-card::after { width: 230px; height: 230px; right: 5px; top: -50px; }
.wealth-card > * { position: relative; z-index: 1; }
.wealth-card-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.wealth-card-head span { display: block; font-size: 13px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,0.78); }
.wealth-card-head small { display: block; margin-top: 6px; color: rgba(255,255,255,0.67); font-size: 12px; }
.wealth-badge {
  flex: 0 0 auto;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff !important;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 11px !important;
  letter-spacing: 0.08em !important;
}
.wealth-card > strong { margin: 15px 0; font-size: clamp(37px, 5vw, 62px); letter-spacing: -0.055em; }
.wealth-card-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wealth-card-footer > div {
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.1);
}
.wealth-card-footer span { display: block; color: rgba(255,255,255,0.66); font-size: 11px; }
.wealth-card-footer strong { display: block; margin-top: 5px; font-size: 17px; }

.score-summary-card {
  min-height: 260px;
  display: grid;
  grid-template-columns: 124px 1fr;
  align-items: center;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.score-mini-ring {
  --score: 0;
  width: 120px;
  height: 120px;
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 39px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--score) * 1%), var(--surface-muted) 0);
}
.score-mini-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.score-mini-ring strong, .score-mini-ring span { position: relative; z-index: 1; }
.score-mini-ring strong { font-size: 31px; letter-spacing: -0.05em; }
.score-mini-ring span { color: var(--muted); font-size: 12px; }
.score-summary-card h3 { margin: 7px 0 8px; font-size: 23px; letter-spacing: -0.035em; }
.score-summary-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.summary-card {
  min-height: 154px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 23px 25px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.summary-card-top { display: flex; align-items: center; gap: 11px; }
.summary-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 18px;
}
.summary-icon .ui-icon, .portfolio-icon .ui-icon, .empty-state-icon .ui-icon { width: 21px; height: 21px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; }
.summary-card > strong { display: block; margin-top: 14px; font-size: clamp(24px, 2.4vw, 34px); letter-spacing: -0.045em; }
.summary-card > small { margin-top: 7px; color: var(--muted); line-height: 1.4; }
.summary-card.income > strong { color: var(--green); }
.summary-card.income .summary-icon { color: var(--green); background: var(--green-soft); }
.summary-card.investment > strong { color: var(--blue); }
.summary-card.investment .summary-icon { color: var(--blue); background: var(--blue-soft); }
.summary-card.expense > strong { color: var(--red); }
.summary-card.expense .summary-icon { color: var(--red); background: var(--red-soft); }
.summary-card.balance > strong { color: var(--text); }
.summary-card.balance .summary-icon { color: var(--text); background: var(--surface-muted); }

.dashboard-view-toggle {
  width: max-content;
  display: flex;
  gap: 8px;
  margin: 0 auto 26px;
  padding: 5px;
  border-radius: 17px;
  background: var(--surface-muted);
}
.dashboard-view-button {
  min-height: 45px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-weight: 760;
}
.dashboard-view-button.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-soft); }
.dashboard-view { display: none; }
.dashboard-view.active { display: block; }
.transaction-tabs {
  max-width: 680px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 auto 24px;
}
.transaction-tab {
  min-height: 49px;
  border: 0;
  border-radius: 16px;
  color: var(--muted);
  background: transparent;
  font-size: 16px;
}
.transaction-tab.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-soft); }

.panel, .portfolio-stat-card, .investment-month-strip {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel h3 { font-size: 18px; letter-spacing: -0.025em; }
.panel-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.dashboard-table-panel { overflow: hidden; padding: 0; }
.dashboard-table-heading { align-items: center; padding: 22px 24px 17px; margin: 0; }
.dashboard-table-wrap { border-top: 1px solid var(--border); }
.dashboard-quick-table td:first-child { color: var(--muted); }
.dashboard-quick-table td:nth-child(2) strong, .dashboard-quick-table td:nth-child(2) small { display: block; }
.dashboard-quick-table td:nth-child(2) small { margin-top: 3px; color: var(--muted); }
.icon-only { min-width: 37px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.85fr); gap: 20px; }
.lower-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 20px; }
.reference-lower-grid { align-items: stretch; }
.charts-reference-grid .wide { grid-row: span 2; }
.legend-note, .muted { color: var(--muted); font-size: 12px; }

.chart-wrap { position: relative; min-height: 300px; }
.chart-wrap canvas { width: 100%; height: 300px; }
.donut-wrap { min-height: 220px; }
.donut-wrap canvas { height: 220px; }
.donut-center { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; text-align: center; pointer-events: none; }
.donut-center small { color: var(--muted); }
.donut-center strong { font-size: 18px; }
.category-legend { display: grid; gap: 8px; margin-top: 14px; }
.category-legend-item { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.category-legend-item span:first-child { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

.analysis-content { display: grid; gap: 10px; }
.analysis-item { display: flex; gap: 11px; align-items: flex-start; padding: 12px; border-radius: 14px; background: var(--surface-soft); }
.analysis-icon { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 11px; font-weight: 900; }
.analysis-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.progress-group, .progress-row { display: grid; gap: 14px; }
.progress-row > div:first-child { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.progress-row strong { color: var(--text); }
.progress-track { height: 10px; overflow: hidden; border-radius: 99px; background: var(--surface-muted); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--red), #ef9696); transition: width 0.4s ease; }
.progress-fill.alt { background: linear-gradient(90deg, var(--blue), #72a8ff); }
.compact-list { display: grid; gap: 10px; }
.compact-item { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.compact-item:last-child { padding-bottom: 0; border-bottom: 0; }
.compact-item strong, .compact-item small { display: block; }
.compact-item small { margin-top: 3px; color: var(--muted); }
.amount-positive { color: var(--green) !important; }
.amount-negative { color: var(--red) !important; }

/* Budget / movement page */
.page-summary-grid { margin-bottom: 24px; }
.movement-summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.movement-summary-grid .summary-card { min-height: 150px; padding: 19px; }
.movement-summary-grid .summary-card > strong { font-size: clamp(21px, 2vw, 29px); }
.pending-summary > strong, .pending-summary .summary-icon { color: var(--amber); }
.pending-summary .summary-icon { background: var(--amber-soft); }
.forecast-summary > strong, .forecast-summary .summary-icon { color: var(--blue); }
.forecast-summary .summary-icon { background: var(--blue-soft); }
.budget-toolbar { align-items: flex-end; margin-bottom: 18px; }
.filter-row, .button-stack { display: flex; gap: 11px; align-items: flex-end; flex-wrap: wrap; }
.filter-row label, .form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.filter-row label { min-width: 160px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface-soft);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.table-panel { overflow: hidden; padding: 0; }
.reference-table-panel { border-radius: var(--radius-lg); }
.table-card-heading { align-items: center; margin: 0; padding: 21px 23px; }
.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; contain: inline-size; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
th { color: var(--muted); background: var(--surface-soft); font-size: 10px; letter-spacing: 0.07em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 32%, transparent); }
.align-right { text-align: right; }
.status-badge, .class-badge { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-badge.paid { color: var(--green); background: var(--green-soft); }
.status-badge.pending { color: var(--amber); background: var(--amber-soft); }
.class-badge { color: var(--primary); background: var(--primary-soft); }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-action { border: 0; border-radius: 10px; padding: 8px 10px; color: var(--muted); background: var(--surface-soft); }
.row-action:hover { color: var(--primary); background: var(--primary-soft); }
.empty-state { margin: 0; padding: 30px; color: var(--muted); text-align: center; }
.empty-state-action { display: grid; justify-items: center; gap: 9px; }
.empty-state-action.hidden { display: none; }
.empty-state-action strong { color: var(--text); font-size: 15px; }
.empty-state-action > span:not(.empty-state-icon) { max-width: 480px; font-size: 12px; line-height: 1.55; }
.empty-state-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; color: var(--primary); background: var(--primary-soft); font-size: 22px; }
.empty-state-action .secondary-button { margin-top: 5px; }
.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.transactions-mobile-list { display: none; }
.transaction-mobile-card { display: grid; gap: 13px; padding: 16px; border-bottom: 1px solid var(--border); }
.transaction-mobile-card:last-child { border-bottom: 0; }
.transaction-mobile-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.transaction-mobile-head > div { min-width: 0; }
.transaction-mobile-head strong, .transaction-mobile-head small { display: block; }
.transaction-mobile-head > div strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transaction-mobile-head small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.transaction-mobile-head > .money-value { flex: 0 0 auto; }
.transaction-mobile-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.transaction-mobile-card .row-actions { justify-content: flex-start; }

/* Portfolio page */
.portfolio-hero-card {
  --mask-color: #fff;
  position: relative;
  min-height: 205px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 31px 35px;
  margin-bottom: 22px;
  border-radius: var(--radius-xl);
  color: #fff;
  background: linear-gradient(120deg, #58b88c, #2b7d5d 55%, #205d45);
  box-shadow: 0 22px 45px rgba(35, 104, 77, 0.2);
}
.portfolio-hero-card::after { content: ""; position: absolute; width: 360px; height: 360px; right: -80px; top: -140px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); }
.portfolio-hero-card > * { position: relative; z-index: 1; }
.portfolio-hero-card > div span { display: block; color: rgba(255,255,255,0.79); font-size: 13px; font-weight: 850; letter-spacing: 0.11em; text-transform: uppercase; }
.portfolio-hero-card small { display: block; margin-top: 6px; color: rgba(255,255,255,0.65); }
.portfolio-hero-card > strong { margin-top: 17px; font-size: clamp(36px, 5vw, 58px); letter-spacing: -0.055em; }
.portfolio-hero-card .wealth-badge { position: absolute; right: 31px; top: 31px; }
.portfolio-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.portfolio-stat-card { min-height: 155px; padding: 23px; }
.portfolio-stat-title { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.portfolio-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; font-size: 17px; }
.portfolio-stat-card strong { display: block; margin-top: 15px; font-size: clamp(23px, 2.4vw, 32px); letter-spacing: -0.045em; }
.portfolio-stat-card small { display: block; margin-top: 7px; color: var(--muted); }
.portfolio-stat-card.liquidity strong, .portfolio-stat-card.liquidity .portfolio-icon { color: var(--green); }
.portfolio-stat-card.liquidity .portfolio-icon { background: var(--green-soft); }
.portfolio-stat-card.contributed strong, .portfolio-stat-card.contributed .portfolio-icon { color: var(--blue); }
.portfolio-stat-card.contributed .portfolio-icon { background: var(--blue-soft); }
.portfolio-stat-card.investments strong, .portfolio-stat-card.investments .portfolio-icon { color: var(--navy); }
.portfolio-stat-card.investments .portfolio-icon { background: var(--navy-soft); }
.portfolio-stat-card.result strong, .portfolio-stat-card.result .portfolio-icon { color: var(--red); }
.portfolio-stat-card.result .portfolio-icon { background: var(--red-soft); }
.investment-month-strip { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 21px; margin-bottom: 18px; color: var(--muted); }
.investment-month-strip strong { color: var(--blue); font-size: 20px; }
.investment-goal-panel { margin: 18px 0; }
.investment-goal-panel .progress-row { margin-top: 16px; }
.investment-header-actions { display: grid; justify-items: end; gap: 7px; }
.investment-header-actions > small { max-width: 420px; color: var(--muted); font-size: 11px; text-align: right; }
.investment-valuation-alert { display: grid; gap: 4px; margin: 0 0 18px; padding: 14px 17px; border: 1px solid #e6b65c; border-radius: 15px; color: #6b4c11; background: #fff6df; }
.investment-valuation-alert strong { font-size: 13px; }
.investment-valuation-alert span { font-size: 12px; line-height: 1.45; }
.valuation-status { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.valuation-status.stale { color: var(--red); }
.valuation-status.estimated { color: #a16a09; }
.investment-event-help { margin: -3px 0 2px; padding: 12px 14px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.45; }
.soft-action-button:disabled { cursor: not-allowed; opacity: .48; }
.embedded-section-title { margin-top: 30px; padding-top: 26px; border-top: 1px solid var(--border); }
.credit-purchase-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.credit-purchase-fields small { grid-column: 1 / -1; }
.forecast-disclosure, .secondary-section-disclosure { margin: 16px 0 24px; }
.forecast-disclosure > summary, .secondary-section-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: 17px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  list-style: none;
}
.forecast-disclosure > summary::-webkit-details-marker, .secondary-section-disclosure > summary::-webkit-details-marker { display: none; }
.forecast-disclosure > summary::after, .secondary-section-disclosure > summary::after { content: "⌄"; color: var(--muted); font-size: 18px; transition: transform .2s ease; }
.forecast-disclosure[open] > summary::after, .secondary-section-disclosure[open] > summary::after { transform: rotate(180deg); }
.forecast-disclosure > summary span, .secondary-section-disclosure > summary h3 { font-weight: 800; }
.forecast-disclosure > summary small, .secondary-section-disclosure > summary > span { margin-left: auto; color: var(--muted); font-size: 12px; }
.forecast-disclosure .forecast-grid { margin-bottom: 0; }
.secondary-section-disclosure { margin-top: 18px; }
.secondary-section-disclosure > summary h3, .secondary-section-disclosure > summary p { margin: 0; }
.secondary-section-disclosure > summary p { margin-bottom: 4px; }
.disclosure-panel { margin-top: 10px; }
.credit-disclosure { margin-bottom: 0; }

/* Goals and achievements */
.goals-layout, .settings-grid { display: grid; gap: 20px; }
.goals-layout { grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr); }
.settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.score-panel { display: grid; grid-template-columns: 170px 1fr; align-items: center; gap: 24px; }
.score-ring { --score: 0; width: 155px; height: 155px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--score) * 1%), var(--surface-muted) 0); position: relative; }
.score-ring::after { content: ""; position: absolute; width: 116px; height: 116px; border-radius: 50%; background: var(--surface); }
.score-ring > div { position: relative; z-index: 1; display: grid; text-align: center; }
.score-ring strong { font-size: 38px; letter-spacing: -0.05em; }
.score-ring span { color: var(--muted); font-size: 12px; }
.challenge-list { display: grid; gap: 10px; }
.challenge-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border-radius: 13px; background: var(--surface-soft); }
.challenge-item div { display: flex; align-items: center; gap: 10px; }
.challenge-check { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: var(--surface-muted); font-size: 12px; }
.challenge-item.completed .challenge-check { color: var(--green); background: var(--green-soft); }
.challenge-points { color: var(--primary); font-weight: 900; }
.achievement-panel { margin-top: 20px; }
.achievement-preview, .achievement-grid { display: grid; gap: 12px; }
.achievement-preview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.achievement-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.achievement-card { min-height: 116px; padding: 14px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-soft); }
.achievement-card.locked { opacity: 0.48; filter: grayscale(0.85); }
.achievement-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-bottom: 9px; border-radius: 11px; color: var(--amber); background: var(--amber-soft); }
.achievement-card strong, .achievement-card small { display: block; }
.achievement-card strong, .achievement-card small { overflow-wrap: anywhere; }
.achievement-card small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.danger-panel { border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Modals */
.modal { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 24px; color: var(--text); background: transparent; }
.modal::backdrop { background: rgba(8, 14, 10, 0.58); backdrop-filter: blur(5px); }
.modal-card { max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.small-modal { max-width: 480px; margin: auto; }
.modal-header, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.modal-header { margin-bottom: 22px; }
.modal-header h2 { margin: 0; }
.modal-actions { margin-top: 22px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.one-column { grid-template-columns: 1fr; }
.form-grid .full-span { grid-column: 1 / -1; }
.form-grid small { color: var(--muted); font-weight: 500; line-height: 1.45; }
.close-month-modal { width: min(540px, calc(100vw - 32px)); }
.close-month-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.close-month-summary > div, .close-month-details { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.close-month-summary span, .close-month-details span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.close-month-summary strong { display: block; font-size: 20px; }
.close-month-summary .close-month-balance { grid-column: 1 / -1; padding: 19px; background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); }
.close-month-balance strong { font-size: 28px; color: var(--primary); }
.close-month-balance.negative { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 28%, var(--border)); }
.close-month-balance.negative strong { color: var(--red); }
.close-month-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.close-month-details strong { font-size: 14px; }
.close-month-note { display: flex; gap: 11px; align-items: flex-start; margin-top: 14px; padding: 13px 15px; border-radius: 14px; color: var(--primary); background: var(--primary-soft); }
.close-month-note > span { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 900; }
.close-month-note p { margin: 2px 0 0; color: var(--text); font-size: 12px; line-height: 1.5; }
.auth-modal { width: min(530px, calc(100vw - 32px)); }
.auth-card { padding: 28px; }
.auth-modal-header { margin-bottom: 16px; }
.auth-brand-lockup { min-width: 0; display: flex; align-items: center; gap: 13px; }
.auth-brand-lockup img { width: 44px; height: 44px; border-radius: 14px; }
.auth-brand-lockup .eyebrow { margin-bottom: 2px; }
.auth-brand-lockup h2 { font-size: 22px; }
.auth-demo-notice { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 20px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--border)); border-radius: 14px; background: var(--amber-soft); }
.auth-demo-notice > span { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--amber); font-size: 12px; font-weight: 900; }
.auth-demo-notice p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-demo-notice strong { display: block; color: var(--text); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 22px; padding: 5px; border-radius: 15px; background: var(--surface-soft); }
.auth-tabs button { min-height: 42px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 800; }
.auth-tabs button.active { color: var(--primary); background: var(--surface); box-shadow: var(--shadow-soft); }
.auth-form { display: grid; gap: 15px; }
.auth-form label > span:first-child { display: block; margin-bottom: 7px; }
.password-field { position: relative; display: block !important; margin: 0 !important; }
.password-field input { padding-right: 50px; }
.password-field button { position: absolute; top: 50%; right: 6px; width: 38px; height: 38px; transform: translateY(-50%); border: 0; border-radius: 10px; color: var(--muted); background: transparent; }
.password-field button:hover { color: var(--primary); background: var(--primary-soft); }
.auth-form-options { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.check-label { display: flex !important; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.45; font-weight: 650; }
.check-label input { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--primary); }
.text-button { padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; font-weight: 800; }
.text-button:hover { text-decoration: underline; }
.auth-submit { width: 100%; min-height: 48px; }
.auth-error { min-height: 18px; margin: -5px 0 0; color: var(--red); font-size: 12px; font-weight: 750; }
.terms-check { padding: 2px 0; }
.password-requirements { display: grid; gap: 5px; margin: -7px 0 0; padding: 0 2px; list-style: none; }
.password-requirements li { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; line-height: 1.3; font-weight: 650; transition: color .2s ease; }
.password-requirements span { width: 14px; height: 14px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--muted) 48%, var(--border)); border-radius: 50%; color: transparent; font-size: 8px; font-weight: 900; transition: border-color .2s ease, color .2s ease, background .2s ease; }
.password-requirements li.met { color: var(--primary); }
.password-requirements li.met span { border-color: var(--primary); color: #fff; background: var(--primary); }
.auth-submit:disabled { cursor: not-allowed; opacity: .46; box-shadow: none; transform: none; }
.auth-centered { text-align: center; }
.auth-centered h2 { margin: 4px 0 9px; }
.auth-centered > .muted { max-width: 390px; margin: 0 auto 18px; line-height: 1.55; }
.auth-state-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 2px auto 14px; border-radius: 19px; color: var(--primary); background: var(--primary-soft); font-size: 24px; font-weight: 900; }
.auth-state-icon.success { color: #fff; background: var(--primary); }
.auth-demo-code, .auth-security-note { margin: 0 0 18px; padding: 11px 14px; border-radius: 13px; color: var(--muted); background: var(--surface-soft); font-size: 12px; line-height: 1.5; }
.auth-demo-code strong { color: var(--primary); letter-spacing: .08em; }
.otp-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp-fields input { min-width: 0; height: 54px; padding: 0; text-align: center; font-size: 22px; font-weight: 900; }
.auth-resend { min-height: 20px; margin: 17px 0 10px; color: var(--muted); font-size: 12px; }
.auth-spam-note { display: block; margin-top: 15px; color: var(--muted); }
.auth-form-left { margin-bottom: 18px; text-align: left; }
.profile-avatar-large { width: 76px; height: 76px; display: grid; place-items: center; margin: 2px auto 15px; border: 4px solid var(--primary-soft); border-radius: 24px; color: #fff; background: linear-gradient(145deg, var(--primary), #176b4b); font-size: 24px; font-weight: 900; }
.auth-profile-status { display: flex; align-items: center; gap: 12px; margin: 20px 0; padding: 14px; border-radius: 15px; text-align: left; background: var(--primary-soft); }
.auth-profile-status > span { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 900; }
.auth-profile-status strong, .auth-profile-status small { display: block; }
.auth-profile-status small { margin-top: 3px; color: var(--muted); }
.profile-menu, .legal-menu { display: grid; gap: 9px; margin-top: 16px; text-align: left; }
.profile-menu > button, .legal-menu > button {
  width: 100%; min-height: 64px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 14px; color: var(--text); background: var(--surface-soft); text-align: left;
}
.profile-menu > button:hover, .legal-menu > button:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--primary-soft); }
.profile-menu > button > .ui-icon { width: 22px; height: 22px; justify-self: center; color: var(--primary); }
.profile-menu > button span, .legal-menu > button span { min-width: 0; }
.profile-menu strong, .profile-menu small, .legal-menu strong, .legal-menu small { display: block; }
.profile-menu small, .legal-menu small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.profile-menu b, .legal-menu b { color: var(--muted); font-size: 20px; }
.profile-menu > .profile-menu-danger { color: var(--red); }
.profile-menu > .profile-menu-danger .ui-icon { color: var(--red); }
.auth-back-button { margin: -2px 0 18px; padding: 4px 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; font-weight: 800; }
.auth-section-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.auth-section-heading > span { width: 46px; height: 46px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; color: var(--primary); background: var(--primary-soft); }
.auth-section-heading h2, .auth-section-heading p { margin: 0; }
.account-note { margin: -5px 0 0; line-height: 1.5; }
.security-status-card { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 11px; margin-bottom: 12px; padding: 13px 14px; border-radius: 14px; background: var(--primary-soft); }
.security-status-card > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 900; }
.security-status-card strong, .security-status-card small { display: block; }
.security-status-card small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.security-control { margin-top: 10px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-soft); }
.security-control > summary, .security-control-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; cursor: pointer; list-style: none; }
.security-control > summary::-webkit-details-marker { display: none; }
.security-control > summary > span, .security-control-title > span { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; }
.security-control > summary small, .security-control-title small { color: var(--muted); font-size: 10px; }
.security-control > summary::after { content: "⌄"; color: var(--muted); }
.security-control[open] > summary::after { transform: rotate(180deg); }
.security-form { padding: 0 14px 14px; }
.sessions-card { padding-bottom: 14px; }
.session-item { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 0 14px 13px; padding: 12px; border-radius: 12px; background: var(--surface); }
.session-device { color: var(--primary); }
.session-item strong, .session-item small { display: block; }
.session-item small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.session-item em { color: var(--primary); font-size: 10px; font-style: normal; font-weight: 800; }
.sessions-card > button { width: calc(100% - 28px); margin: 0 14px; }
.legal-menu > button { grid-template-columns: minmax(0, 1fr) auto; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 13px 16px; border-radius: 13px; color: #fff; background: #162019; box-shadow: var(--shadow); transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

/* Privacy mask */
.hide-values .money-value { font-size: 0 !important; color: transparent !important; }
.hide-values .money-value::after {
  content: "••••••";
  font-size: 20px;
  letter-spacing: 0.09em;
  color: var(--mask-color, var(--text));
}
.hide-values td.money-value::after { font-size: 13px; }
.hide-values .wealth-card .money-value::after, .hide-values .portfolio-hero-card .money-value::after { font-size: clamp(30px, 4vw, 50px); }

@media (max-width: 1220px) {
  .budget-summary-grid, .portfolio-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lower-grid, .settings-grid { grid-template-columns: 1fr; }
  .achievement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 96px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 20px 12px; }
  .brand { padding: 0 0 24px; }
  .brand > div, .nav-label, .privacy-badge { display: none; }
  .brand-mark { width: 50px; height: 50px; }
  .nav-list { width: 100%; }
  .nav-item { justify-content: center; padding: 12px 6px; }
  .nav-icon { width: auto; }
  .sidebar-footer { width: 100%; }
  .overview-hero-grid { grid-template-columns: 1fr; }
  .score-summary-card { min-height: 190px; }
  .dashboard-grid, .goals-layout { grid-template-columns: 1fr; }
  .charts-reference-grid .wide { grid-row: auto; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    width: 100%;
    height: 78px;
    padding: 7px 8px env(safe-area-inset-bottom, 7px);
    display: block;
    border: 0;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(15px);
  }
  .brand, .sidebar-footer { display: none; }
  .nav-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; }
  .nav-item { min-height: 62px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 5px 3px; border-radius: 12px; font-size: 10px; }
  .nav-item:hover { transform: none; }
  .nav-icon { font-size: 21px; }
  .nav-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .main-content { padding: 0 16px 110px; }
  .topbar { margin: 0 -16px 27px; padding: 13px 16px; gap: 10px; }
  .page-heading { display: none; }
  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px 48px;
    gap: 10px;
  }
  .sync-status { display: none; }
  .month-navigation { grid-column: 1; }
  .privacy-toggle { grid-column: 2; }
  .profile-button { grid-column: 3; }
  .month-navigation { min-width: 0; }
  .month-picker { min-width: 0; flex: 1; }
  .month-picker strong { font-size: 14px; }
  .top-add-button {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-height: 48px;
    padding: 0 18px;
    font-size: 14px;
  }
  .privacy-toggle { flex: 0 0 auto; }
  .section-title-row { align-items: center; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .investment-header-actions { width: 100%; justify-items: stretch; }
  .investment-header-actions .panel-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .investment-header-actions > small { max-width: none; text-align: left; }
  .section-title-row h2 { font-size: 32px; }
  .dashboard-title-row { align-items: stretch; flex-direction: column; }
  .dashboard-title-row .panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .dashboard-title-row .soft-action-button {
    width: 100%;
    min-height: 48px;
    padding: 0 12px;
    font-size: 13px;
  }
  .dashboard-title-row .soft-action-button span { margin: 0 5px 0 0; font-size: 16px; }
  .wealth-card { min-height: 250px; padding: 26px 25px 23px; }
  .wealth-card > strong { font-size: clamp(34px, 10vw, 48px); }
  .score-summary-card { grid-template-columns: 105px 1fr; padding: 22px; }
  .score-mini-ring { width: 101px; height: 101px; padding-top: 32px; }
  .score-mini-ring strong { font-size: 27px; }
  .budget-summary-grid, .portfolio-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
  .summary-card, .portfolio-stat-card { min-height: 145px; padding: 19px; }
  .summary-card > strong, .portfolio-stat-card strong { font-size: clamp(22px, 6vw, 29px); }
  .summary-card > small, .portfolio-stat-card small { font-size: 10px; }
  .dashboard-table-heading { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; }
  .panel-actions > * { flex: 1; }
  .close-month-summary, .close-month-details { grid-template-columns: 1fr; }
  .close-month-summary .close-month-balance { grid-column: auto; }
  .filter-row { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .filter-row label:first-child { grid-column: 1 / -1; }
  .filter-row label { min-width: 0; }
  .budget-toolbar { align-items: stretch; flex-direction: column; }
  .budget-toolbar > .soft-action-button { width: 100%; }
  .portfolio-hero-card { min-height: 190px; padding: 27px 25px; }
  .portfolio-hero-card .wealth-badge { right: 22px; top: 22px; }
  .table-card-heading .legend-note { display: none; }
  .settings-grid, .goals-layout { grid-template-columns: 1fr; }
  .achievement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toast { right: 16px; bottom: 94px; }
  .auth-card { padding: 22px; }
}

@media (max-width: 520px) {
  .month-arrow { width: 36px; }
  .icon-button { width: 44px; height: 44px; }
  .profile-button { width: 44px; height: 44px; }
  .month-navigation { min-height: 50px; }
  .section-title-row { gap: 10px; }
  .overview-hero-grid { gap: 14px; }
  .wealth-card-head small { display: none; }
  .wealth-card-footer { grid-template-columns: 1fr; }
  .wealth-card-footer > div:last-child { display: none; }
  .score-summary-card { min-height: 165px; grid-template-columns: 88px 1fr; gap: 16px; }
  .score-mini-ring { width: 85px; height: 85px; padding-top: 26px; }
  .score-mini-ring::after { inset: 8px; }
  .score-mini-ring strong { font-size: 23px; }
  .score-summary-card h3 { font-size: 19px; }
  .budget-summary-grid, .portfolio-card-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .summary-card, .portfolio-stat-card { min-height: 132px; padding: 16px; border-radius: 20px; }
  .auth-brand-lockup img { width: 40px; height: 40px; }
  .auth-brand-lockup h2 { font-size: 19px; }
  .auth-form-options { align-items: flex-start; flex-direction: column; }
  .otp-fields { gap: 5px; }
  .otp-fields input { height: 48px; font-size: 19px; }
  .summary-icon, .portfolio-icon { width: 36px; height: 36px; }
  .metric-label, .portfolio-stat-title { font-size: 10px; }
  .summary-card > strong, .portfolio-stat-card strong { margin-top: 11px; font-size: 22px; }
  .summary-card > small, .portfolio-stat-card small { display: none; }
  .dashboard-view-toggle { width: 100%; }
  .dashboard-view-button { flex: 1; justify-content: center; }
  .transaction-tabs { gap: 5px; }
  .transaction-tab { font-size: 14px; }
  .panel { padding: 18px; }
  .dashboard-table-panel { padding: 0; }
  th, td { padding: 13px 14px; }
  .dashboard-quick-table th:nth-child(1), .dashboard-quick-table td:nth-child(1) { width: 72px; }
  .portfolio-hero-card > strong { font-size: 34px; }
  .investment-month-strip { align-items: flex-start; flex-direction: column; }
  .investment-header-actions { justify-items: stretch; width: 100%; }
  .investment-header-actions > small { text-align: left; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-span { grid-column: auto; }
  .credit-purchase-fields { grid-template-columns: 1fr; }
  .credit-purchase-fields small { grid-column: auto; }
  .score-panel { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .achievement-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Finance planning extensions */
.forecast-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 16px 0 24px; }
.forecast-card { padding: 18px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-sm); }
.forecast-card span, .forecast-card small { display: block; color: var(--muted); }
.forecast-card strong { display: block; margin: 10px 0 6px; font-size: 23px; letter-spacing: -.03em; }
.category-budget-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.field-title { display: block; margin-bottom: 8px; font-weight: 700; }
.category-budget-list { display: grid; gap: 12px; }
.category-budget-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(160px, 2fr) 56px; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.category-budget-row:last-child { border-bottom: 0; }
.category-budget-row small { display: block; margin-top: 4px; color: var(--muted); }
.category-budget-row.attention .progress-fill { background: #d89a24; }
.category-budget-row.warning .progress-fill, .category-budget-row.danger .progress-fill { background: var(--red); }
.credit-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 22px; }
.credit-card { min-height: 210px; padding: 22px; border-radius: 24px; color: #fff; background: linear-gradient(145deg, #202735, #44526d); box-shadow: var(--shadow-md); display: grid; gap: 16px; }
.credit-card.limit-warning { background: linear-gradient(145deg, #672b35, #b54b5d); }
.credit-card span, .credit-card small { color: rgba(255,255,255,.76); }
.credit-card strong { display: block; margin-top: 4px; font-size: 22px; }
.credit-card .progress-track { background: rgba(255,255,255,.22); }
.credit-card .progress-fill { background: #fff; }
.credit-card .row-action { color: #fff; border-color: rgba(255,255,255,.34); justify-self: start; }
.management-list { display: grid; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.management-item, .closure-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px; border-radius: 14px; background: var(--surface-muted); }
.management-item small, .closure-item small { display: block; margin-top: 4px; color: var(--muted); }
.closure-list { display: grid; gap: 10px; margin-top: 14px; }
.onboarding-modal::backdrop { background: rgba(13, 20, 31, .72); backdrop-filter: blur(8px); }
.onboarding-followup { margin: 14px 0 0; padding: 11px 13px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 11px; line-height: 1.5; }

@media (max-width: 980px) {
  .forecast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .movement-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .movement-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .movement-summary-grid .summary-card { min-height: 132px; padding: 16px; }
  .movement-summary-grid .summary-card > small { display: block; }
  #movementsSection .transactions-panel > .table-wrap { display: none; }
  #movementsSection .transactions-mobile-list { display: block; }
  .category-budget-fields { grid-template-columns: 1fr; }
  .category-budget-row { grid-template-columns: 1fr 52px; }
  .category-budget-row .progress-track { grid-column: 1 / -1; grid-row: 2; }
  .management-item, .closure-item { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .forecast-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .forecast-card { padding: 14px; border-radius: 17px; }
  .forecast-card strong { font-size: 19px; }
  .forecast-card small { font-size: 10px; }
  .forecast-disclosure > summary { align-items: flex-start; flex-direction: column; gap: 4px; }
  .forecast-disclosure > summary small { margin-left: 0; }
  .forecast-disclosure > summary::after { position: absolute; right: 20px; }
  .secondary-section-disclosure > summary > span { max-width: 130px; text-align: right; }
  .transaction-tabs { gap: 5px; }
  .transaction-tab { min-height: 44px; padding: 8px 5px; font-size: 13px; }
}
.cloud-auth-required #authModal .close-modal {
  display: none;
}

.cloud-auth-required > :not(#authModal):not(.toast) {
  pointer-events: none;
  user-select: none;
}



/* Legal documents */
.terms-check { align-items: flex-start; }
.terms-check > span { line-height: 1.5; }
.legal-inline-link {
  display: inline; padding: 0; border: 0; color: var(--primary); background: transparent;
  font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.legal-draft-notice, .legal-draft-banner {
  display: grid; gap: 4px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--amber) 34%, var(--border));
  border-radius: 14px; color: var(--muted); background: var(--amber-soft); font-size: 12px; line-height: 1.45;
}
.legal-draft-notice strong, .legal-draft-banner strong { color: var(--text); }
.legal-draft-notice { margin: 4px 0 16px; }
.legal-modal { width: min(760px, calc(100vw - 28px)); max-height: min(860px, calc(100dvh - 28px)); padding: 0; overflow: hidden; }
.legal-card { max-height: min(860px, calc(100dvh - 28px)); padding: 0 28px 30px; overflow-y: auto; background: var(--surface); }
.legal-header {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; margin: 0 -28px; padding: 22px 28px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.legal-header h2 { margin: 0; font-size: clamp(21px, 3vw, 28px); }
.legal-header .eyebrow { margin-bottom: 3px; }
.legal-draft-banner { margin: 20px 0; }
.legal-content { color: var(--muted); font-size: 14px; line-height: 1.7; }
.legal-content .legal-updated { margin: 0 0 22px; color: var(--primary); font-size: 12px; font-weight: 800; }
.legal-content h3 { margin: 26px 0 8px; color: var(--text); font-size: 16px; }
.legal-content p { margin: 0 0 12px; }
.legal-content ul { margin: 8px 0 14px; padding-left: 21px; }
.legal-content li { margin: 5px 0; }
.legal-content strong { color: var(--text); }

@media (max-width: 640px) {
  .legal-modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .legal-card { max-height: calc(100dvh - 16px); padding: 0 18px 24px; }
  .legal-header { margin: 0 -18px; padding: 18px; }
  .legal-content { font-size: 13px; }
}


/* Investment identity spacing */
#investmentsTableBody td:first-child > strong,
#investmentsTableBody td:first-child > small { display: block; }
#investmentsTableBody td:first-child > small { margin-top: 8px; line-height: 1.35; }
