:root {
  --theme-accent: #7047eb;
  --theme-hover: #5932c3;
  --theme-soft: #eee8fc;
  --theme-canvas: #f6f5fa;
  --theme-light: #e2d7ff;
  --bg: var(--theme-canvas);
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #242132;
  --muted: #69717d;
  --line: #e3e7eb;
  --line-strong: #d5dbe1;
  --teal: var(--theme-accent);
  --coral: #ef6b58;
  --amber: #eeb44d;
  --blue: #3b82f6;
  --mint: #4fbf7f;
  --violet: #8a63d2;
  --rose: #df5d87;
  --shadow: 0 16px 44px rgba(28, 35, 45, 0.08);
}

/* Shared Fract refinement: quiet surfaces, clear type, useful color. */
html { color-scheme: light; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--theme-accent); outline-offset: 3px; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 2px 6px 10px;
}

.brand-mark {
  align-items: center;
  background: var(--text);
  border-radius: 8px;
  color: #fff;
  display: grid;
  font-weight: 800;
  height: 40px;
  place-items: center;
  width: 40px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-list,
.sidebar-footer {
  display: grid;
  gap: 6px;
}

.sidebar-footer {
  margin-top: auto;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #4d5662;
  display: flex;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
  width: 100%;
}

.nav-item svg {
  height: 19px;
  width: 19px;
}

.nav-item:hover,
.nav-item.active {
  background: var(--theme-soft);
  color: var(--theme-accent);
}

.nav-item.subtle:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.sync-card {
  align-items: center;
  background: #f3f6f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
}

.sync-card svg {
  color: var(--teal);
  height: 22px;
  width: 22px;
}

.sync-card strong,
.sync-card span {
  display: block;
}

.sync-card strong {
  font-size: 13px;
}

.sync-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
}

.eyebrow,
.section-label,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  margin-bottom: 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.quick-add { position: relative; }
.quick-add > button { min-width: 94px; }
.quick-add-menu { position: absolute; z-index: 30; top: calc(100% + 10px); right: 0; width: min(280px,calc(100vw - 36px)); padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 48px rgba(29,20,48,.16); }
.quick-add-menu[hidden] { display: none; }
.quick-add-menu button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text); text-align: left; }
.quick-add-menu button:hover,.quick-add-menu button:focus-visible { background: var(--theme-soft); }
.quick-add-menu button > svg { width: 20px; height: 20px; flex: none; color: var(--theme-accent); }
.quick-add-menu button svg { width:20px; height:20px; color:var(--theme-accent); }
.quick-add-menu strong,.quick-add-menu small { display: block; }
.quick-add-menu strong { font-size: 14px; }
.quick-add-menu small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.search {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  height: 42px;
  min-width: 270px;
  padding: 0 12px;
}

.search svg {
  color: var(--muted);
  height: 18px;
  width: 18px;
}

.search input,
.setting-row input,
.modal input,
.modal select {
  background: transparent;
  border: 0;
  color: var(--text);
  outline: 0;
  width: 100%;
}

select,
.icon-button,
.primary-button,
.secondary-button,
.text-button {
  border-radius: 8px;
  min-height: 42px;
}

select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0 34px 0 12px;
  min-height: 44px;
  border-radius: 10px;
  font-weight: 550;
}
select:hover { border-color: var(--line-strong); }
select option { background: var(--panel); color: var(--text); }

.icon-button {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-grid;
  height: 42px;
  place-items: center;
  width: 42px;
}
.icon-button svg { width:20px; height:20px; }

.primary-button,
.secondary-button,
.text-button {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
}

.primary-button {
  background: var(--text);
  border: 1px solid var(--text);
  color: #fff;
  padding: 0 16px;
}

.secondary-button {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0 14px;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--theme-accent);
  font-weight: 700;
  padding: 0 4px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1.35fr 1fr 1fr 1fr;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(28, 35, 45, 0.02);
}

.metric-card {
  min-height: 136px;
  padding: 18px;
}

.metric-card strong {
  display: block;
  font-size: 32px;
  line-height: 1.1;
  margin-top: 12px;
}

.metric-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

.hero-metric {
  background: var(--theme-accent);
  border-color: var(--theme-accent);
  color: #fff;
}

.hero-metric .metric-label,
.hero-metric p {
  color: rgba(255, 255, 255, 0.72);
}

.meter {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  height: 9px;
  margin-top: 16px;
  overflow: hidden;
}

.meter span {
  background: var(--teal);
  border-radius: inherit;
  display: block;
  height: 100%;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.category-panel,
.transactions-panel {
  min-height: 360px;
}

.chart-layout {
  align-items: center;
  display: grid;
  gap: 24px;
  grid-template-columns: 250px minmax(0, 1fr);
}

.donut-wrap {
  aspect-ratio: 1;
  display: grid;
  max-width: 260px;
  place-items: center;
  position: relative;
  width: 100%;
}

.donut-wrap.large {
  margin: 12px auto;
  max-width: 360px;
}

.donut {
  height: 100%;
  transform: rotate(-90deg);
  width: 100%;
}

.donut circle {
  fill: none;
  stroke-width: 7.5;
}

.donut-center {
  display: grid;
  left: 50%;
  place-items: center;
  position: absolute;
  text-align: center;
  top: 50%;
  transform: translate(-50%, -50%);
}

.donut-center strong {
  font-size: 25px;
}

.donut-center span {
  color: var(--muted);
  font-size: 13px;
}

.category-list,
.action-list,
.transaction-list,
.health-list {
  display: grid;
  gap: 10px;
}

.category-row,
.action-item,
.transaction-row,
.health-row,
.goal-card,
.insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.category-row {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.category-main,
.transaction-row,
.action-item,
.health-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.category-name,
.transaction-main,
.action-copy {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.swatch {
  border-radius: 6px;
  display: inline-block;
  height: 14px;
  flex: 0 0 auto;
  width: 14px;
}

.category-row strong,
.transaction-main strong,
.action-copy strong,
.health-row strong {
  display: block;
  font-size: 14px;
}

.category-row small,
.transaction-main small,
.action-copy small,
.health-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.progress {
  background: #eef1f3;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.progress span {
  border-radius: inherit;
  display: block;
  height: 100%;
}

.amount {
  font-weight: 800;
  white-space: nowrap;
}

.action-item {
  background: var(--panel-soft);
  padding: 12px;
}

.action-icon {
  align-items: center;
  border-radius: 8px;
  color: #fff;
  display: grid;
  flex: 0 0 auto;
  height: 36px;
  place-items: center;
  width: 36px;
}

.transaction-row {
  padding: 12px 0;
}

.transaction-row + .transaction-row {
  border-top: 1px solid var(--line);
}

.merchant-icon {
  align-items: center;
  background: #f0f4f4;
  border-radius: 8px;
  color: #33403f;
  display: grid;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  height: 36px;
  place-items: center;
  width: 36px;
}

.bar-chart {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(7, 1fr);
  min-height: 246px;
}

.bar {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.bar span {
  background: linear-gradient(180deg, var(--teal), #b49bea);
  border-radius: 8px 8px 4px 4px;
  display: block;
  min-height: 18px;
  width: 100%;
}

.bar small {
  color: var(--muted);
  font-size: 12px;
}

.tool-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.segmented {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  padding: 4px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 34px;
  padding: 0 14px;
}

.segmented button.active {
  background: var(--text);
  color: #fff;
}

.full-panel {
  min-height: 620px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.pill,
.status {
  background: #f0f4f4;
  border-radius: 999px;
  color: #4d5662;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 24px;
  padding: 4px 9px;
}

.budget-layout,
.category-page-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
}

.budget-line {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 132px;
  padding: 14px 0;
}

.budget-line input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 10px;
  width: 100%;
}

.large-number {
  font-size: 42px;
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.expanded {
  max-height: 620px;
  overflow: auto;
}

.insight-grid,
.goals-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.insight-card,
.goal-card {
  background: var(--panel);
  padding: 18px;
}

.insight-card strong,
.goal-card strong {
  display: block;
  font-size: 20px;
  margin-bottom: 8px;
}

.forecast {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
}

.forecast-item {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.forecast-item strong {
  display: block;
  font-size: 26px;
  margin-top: 6px;
}

.settings-panel {
  max-width: 760px;
}

.reset-panel {
  max-width: 760px;
  border-color: color-mix(in srgb, #b42332 28%, var(--line));
}
.reset-panel h2 { font-size: 18px; margin: 0; }
.reset-panel p { max-width: 65ch; margin: 9px 0 18px; }
.reset-open-button, .reset-danger-button {
  border-radius: 10px;
  font-weight: 650;
  min-height: 44px;
  padding: 10px 16px;
}
.reset-open-button {
  background: transparent;
  border: 1px solid #b42332;
  color: #a51d2c;
}
.reset-open-button:hover { background: color-mix(in srgb, #b42332 7%, var(--panel)); }
.reset-danger-button {
  background: #b42332;
  border: 1px solid #b42332;
  color: #fff;
}
.reset-danger-button:hover:not(:disabled) { background: #941b29; }
.reset-danger-button:disabled { cursor: not-allowed; opacity: .5; }
.reset-dialog { max-width: 520px; }
.reset-dialog h2 { font-size: 23px; line-height: 1.2; margin: 0; }
.reset-dialog #resetDescription { color: var(--muted); margin: 0; }
.reset-dialog .reset-backup-button { justify-self: start; min-height: 44px; }
.reset-dialog label { color: var(--text); font-size: 14px; margin-top: 4px; }
.reset-dialog input { min-height: 48px; font-size: 16px; }
.reset-dialog .reset-hint { color: var(--muted); font-size: 13px; margin: -4px 0 0; }
.reset-dialog .reset-error { color: #a51d2c; font-size: 13px; margin: 0; }
.reset-dialog .reset-error[hidden] { display: none; }
html[data-mode="dark"] .reset-open-button { color: #ffa4ae; border-color: #eb8290; }
html[data-mode="dark"] .reset-dialog .reset-error { color: #ffa4ae; }
@media(max-width:600px) {
  .reset-dialog .modal-actions { flex-direction: column-reverse; }
  .reset-dialog .modal-actions button { width: 100%; }
}

.setting-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 0;
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row small {
  color: var(--muted);
  margin-top: 4px;
}

.setting-row input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 180px;
  min-height: 42px;
  padding: 0 12px;
}

.setting-row input[type="checkbox"] {
  accent-color: var(--teal);
  height: 22px;
  width: 22px;
}

.modal {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 480px;
  padding: 0;
  width: calc(100vw - 32px);
}

.modal::backdrop {
  background: rgba(10, 14, 18, 0.32);
}

.modal-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.modal-card label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.modal-card input,
.modal-card select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.toast {
  background: var(--text);
  border-radius: 8px;
  bottom: 24px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.high-contrast {
  --bg: #eef2f3;
  --line: #cad2d9;
  --line-strong: #9ca9b3;
}

@media (max-width: 1180px) {
  .app-shell {
    display: block;
  }

  .brand div,
  .nav-item span:last-child,
  .sync-card div {
    display: none;
  }

  .sidebar {
    align-items: stretch;
    height: auto;
    padding: 12px;
    position: static;
  }

  .brand {
    justify-content: center;
    padding-bottom: 4px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 44px;
    justify-content: center;
    padding: 0;
  }

  .sidebar-footer {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 4px;
  }

  .sync-card {
    margin: 0;
  }

  .summary-grid,
  .dashboard-grid,
  .budget-layout,
  .category-page-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-metric,
  .category-panel,
  .transactions-panel,
  .full-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .setting-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .summary-grid,
  .dashboard-grid,
  .budget-layout,
  .category-page-grid,
  .insight-grid,
  .goals-grid,
  .forecast,
  .chart-layout {
    grid-template-columns: 1fr;
  }
}

/* Interface polish, shared with the iOS token palette. */
:root { --muted: #696477; --bg: var(--theme-canvas); --line: #e9e5f0; }
.main { padding: 40px; max-width: 1560px; width: 100%; margin-inline: auto; }
.sidebar { padding: 32px 20px; }
.brand-mark { background: var(--theme-accent); color: #fff !important; border-radius: 12px; font-size: 24px !important; }
.brand strong { font-size: 21px; letter-spacing: -.025em; }
.nav-item { border-radius: 10px; min-height: 48px; font-size: 14px; font-weight: 600; }
.nav-item.active { background: var(--theme-soft); color: var(--theme-hover); }
.topbar { margin-bottom: 30px; }
h1 { font-size: 34px; letter-spacing: -.03em; }
h2 { font-size: 18px; letter-spacing: -.02em; }
.panel-header .section-label, .goal-card > .section-label { display: none; }
.metric-label { text-transform: none; font-size: 14px; font-weight: 500; }
.metric-card, .panel, .goal-card, .insight-card { border-radius: 14px; box-shadow: none; }
.metric-card { padding: 24px; min-height: 166px; }
.metric-card strong { font-size: 36px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-metric { background: var(--theme-accent); border-color: transparent; }
.hero-metric p, .hero-metric .metric-label { color: #f1ebff; }
.hero-metric .meter { background: rgba(255,255,255,.22); }
.hero-metric .meter span { background: var(--theme-light); }
.primary-button { background: var(--theme-accent); border-color: var(--theme-accent); border-radius: 10px; min-height: 44px; font-weight: 650; }
.primary-button:hover { background: var(--theme-hover); }
.secondary-button:hover, .icon-button:hover { background: var(--theme-soft); }
.primary-button svg, .secondary-button svg { width: 18px; height: 18px; }
.panel { padding: 24px; }
.dashboard-grid { gap: 22px; }
.summary-grid { gap: 18px; margin-bottom: 24px; }
.category-row, .transaction-row, .health-row { border: none; border-radius: 0; padding: 14px 0; border-bottom: 1px solid var(--line); }
.category-row:last-child, .transaction-row:last-child, .health-row:last-child { border-bottom: 0; }
.category-row strong, .transaction-main strong, .action-copy strong, .health-row strong { font-size: 15px; font-weight: 600; }
.category-row small, .transaction-main small, .action-copy small, .health-row small { font-size: 13px; }
.transaction-main > span:last-child { min-width: 0; }
.transaction-main strong { overflow-wrap: anywhere; }
.amount, .amount-cell, .large-number { font-variant-numeric: tabular-nums; }
.action-item { border: none; border-radius: 12px; background: var(--theme-canvas); padding: 16px; }
.action-icon { display: none; }
.action-copy small { margin-top: 6px; }
.merchant-icon { background: var(--theme-soft); color: var(--theme-hover); border-radius: 12px; font-weight: 600; }
.donut { transform: none; }
.donut circle { stroke-width: 5; }
.chart-layout { grid-template-columns: minmax(160px, 220px) minmax(0,1fr); }
.bar-chart { align-items: end; }
.bar span { background: var(--theme-accent); border-radius: 5px 5px 0 0; }
.bar small { font-size: 12px; color: #696477; }
.empty-state { text-align: center; padding: 42px 18px; color: var(--muted); line-height: 1.8; }
.delete-entry { display: block; font-size: 12px; color: #a33b35; margin-left: auto; }
.modal { border: 0; border-radius: 16px; width: min(480px, calc(100vw - 28px)); padding: 0; max-height: 90dvh; }
.modal-card { padding: 26px; }
.modal input, .modal select { min-height: 44px; }
.modal::backdrop { background: rgba(36,33,50,.45); }
.setting-row input:focus-visible { outline: 3px solid var(--theme-accent); }
.toast { z-index: 20; max-width: calc(100vw - 32px); text-align: center; }
@media (min-width: 861px) and (max-width: 1180px) {
  .app-shell { display: grid; grid-template-columns: 82px minmax(0,1fr); }
  .sidebar { position: sticky; height: 100vh; padding: 20px 10px; }
  .nav-list { display: grid; }
  .sidebar-footer { display: grid; margin-top: auto; }
  .main { padding: 28px; }
  .summary-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 860px) {
  .main { padding: 24px 18px 112px; }
  .sidebar { display: contents; }
  .brand, .sidebar-footer .sync-card { display: none; }
  .nav-list { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: #fff; border-top: 1px solid var(--line); padding: 8px 6px max(8px, env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; }
  .nav-item { display: flex; flex-direction: column; flex: 1; gap: 3px; padding: 6px 2px; min-width: 0; font-size: 11px; }
  .nav-item span:last-child { display: block; }
  .nav-item[data-page="categories"] { display: none; }
  .sidebar-footer { position: absolute; top: 18px; right: 16px; margin: 0; }
  .sidebar-footer .nav-item { padding: 6px; font-size: 11px; }
  .topbar { gap: 22px; }
  .topbar-actions { display: grid; grid-template-columns: minmax(0,1fr) 44px; gap: 10px; }
  .search { grid-column: 1/-1; }
  #openTransactionModal { grid-column: 1/-1; }
  h1 { font-size: 30px; padding-right: 55px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .hero-metric { grid-column: 1/-1; }
  .metric-card { min-height: 128px; padding: 20px; }
  .metric-card:last-child { grid-column: 1/-1; min-height: auto; display: flex; align-items: center; gap: 12px; }
  .metric-card:last-child strong { font-size: 24px; margin: 0; }
  .metric-card:last-child p { margin: 0 0 0 auto; }
  .panel { padding: 20px; }
  .chart-layout { grid-template-columns: 1fr; gap: 12px; }
  .donut-wrap { max-width: 210px; margin-inline: auto; }
  .tool-row { flex-wrap: wrap; }
  .toast { bottom: 90px; }
  .table-wrap { overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Match the native iOS floating glass navigation on the compact web app. */
.appearance-panel, .bank-panel { margin-bottom: 24px; }
.appearance-panel > p, .bank-panel > p { margin: 12px 0 20px; }
.theme-picker { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 14px; border: 0; padding: 0; margin: 0; }
.theme-option { position: relative; cursor: pointer; min-width: 0; }
.theme-option input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--preview-canvas); border: 2px solid var(--line); border-radius: 12px; padding: 12px; }
.theme-preview > span { grid-column: 1/-1; height: 34px; background: var(--preview-accent); border-radius: 5px; }
.theme-preview > i { display: block; height: 20px; background: var(--preview-soft); border-radius: 4px; }
.theme-name { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 14px; font-weight: 600; }
.theme-check { visibility: hidden; color: var(--theme-accent); }
.theme-option input:checked + .theme-preview { border-color: var(--theme-accent); }
.theme-option input:checked ~ .theme-name .theme-check { visibility: visible; }
.theme-option input:focus-visible + .theme-preview { outline: 3px solid var(--theme-accent); outline-offset: 3px; }
#themeToggle[aria-pressed="true"] { background: var(--theme-soft); border-color: var(--theme-accent); color: var(--theme-accent); }
.bank-badge { display: inline-block; font-size: 12px; color: var(--theme-hover); background: var(--theme-soft); padding: 3px 8px; border-radius: 6px; vertical-align: middle; }
.bank-notice { background: var(--theme-soft); color: var(--theme-hover); padding: 12px 16px; border-radius: 10px; font-size: 14px; margin: 0 0 20px; }
.bank-notice[hidden] { display: none; }
.bank-connection { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 18px; font-size: 14px; }
button:disabled { cursor: wait; opacity: .55; }
@media(max-width:600px) { .theme-picker { grid-template-columns: repeat(2,minmax(0,1fr)); } .bank-connection { align-items: start; } }
@media (max-width: 860px) {
  .nav-list { --selected-tab: 0; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); padding: 5px; border: 1px solid rgba(255,255,255,.9); border-radius: 36px; background: rgba(250,248,255,.82); -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%); box-shadow: 0 8px 30px rgba(52,34,87,.12); overflow: hidden; isolation: isolate; }
  .nav-list::before { content: ""; position: absolute; left: 5px; top: 5px; bottom: 5px; width: calc((100% - 10px)/5); border-radius: 28px; background: color-mix(in srgb, var(--theme-soft) 80%, transparent); box-shadow: inset 0 1px 0 rgba(255,255,255,.9); transform: translateX(calc(var(--selected-tab)*100%)); transition: transform 280ms cubic-bezier(.16,1,.3,1); z-index: -1; }
  .nav-list.no-selection::before { opacity: 0; }
  .nav-list .nav-item.active, .nav-list .nav-item:hover { background: transparent; }
  .nav-list .nav-item { min-height: 50px; font-weight: 600; }
}

/* The selected accent stays familiar while the reading surfaces change. */
html[data-mode="dark"] { color-scheme: dark; --theme-canvas:#15111e; --theme-soft:#302640; --theme-light:#4b3c65; --panel:#211b2c; --panel-soft:#292235; --text:#f5f1fa; --muted:#c8bfd3; --line:#453a53; --line-strong:#685a79; --shadow:0 16px 44px rgba(0,0,0,.3); }
html[data-mode="dark"] .sidebar,html[data-mode="dark"] .search,html[data-mode="dark"] .segmented,html[data-mode="dark"] .modal,html[data-mode="dark"] .modal-card input,html[data-mode="dark"] .modal-card select { background:var(--panel); color:var(--text); }
html[data-mode="dark"] .sync-card,html[data-mode="dark"] .merchant-icon,html[data-mode="dark"] .pill,html[data-mode="dark"] .status { background:var(--panel-soft); color:var(--text); }
html[data-mode="dark"] .primary-button:not(.quick-add-menu button) { color:#fff; }
html[data-mode="dark"] .segmented button.active { background:var(--theme-accent); }
html[data-mode="dark"] .toast { background:#3b3150; color:#fff; }
html[data-mode="dark"] .text-button,html[data-mode="dark"] #themeToggle,html[data-mode="dark"] .quick-add-menu button svg { color:var(--theme-hover); }
html[data-mode="dark"] .hero-metric .metric-label,html[data-mode="dark"] .hero-metric p { color:#fff; }
html[data-mode="dark"] .theme-preview { border-color:var(--line-strong); }
html[data-mode="dark"] .nav-list { background:rgba(34,27,47,.88); border-color:rgba(191,174,216,.24); }
html[data-mode="dark"] .nav-list::before { box-shadow:inset 0 1px 0 rgba(255,255,255,.12); }
@media (max-width:860px) {
  .quick-add { position:absolute; right:0; top:0; }
  .quick-add > button { min-width:70px; min-height:40px; }
  .sidebar-footer { right:120px; z-index:12; }
  .sidebar-footer .nav-item span:last-child { display:none; }
  .topbar > div:first-child { min-height:42px; }
  .topbar-actions { padding-top:0; }
  #themeToggle { grid-column:2; grid-row:2; }
  #monthSelect { grid-column:1; grid-row:2; }
  .search { grid-row:1; }
}
