/* Expense Logger 1.9.1 — dark-first, iOS-style */

:root {
  --bg: #0B0C10;
  --card: #16181F;
  --raised: #1F222B;
  --sep: rgba(255,255,255,.08);
  --text: #F2F4F8;
  --text-dim: #8A91A3;
  --text-secondary: #A8B0C2;
  --accent: #5B8CFF;
  --accent-press: #4a7ae6;
  --accent-ink: #0B0C10;
  --link: #8CADFF;
  --success: #34C77B;
  --warn: #F5A524;
  --danger: #FF5A5F;
  --radius-card: 16px;
  --radius-input: 12px;
  --radius-pill: 999px;
  --radius-sheet: 24px;
  --gutter: 16px;
  --tab-bar-h: 49px;
  --shadow: 0 8px 32px rgba(0,0,0,.45);
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F2F3F7;
    --card: #FFFFFF;
    --raised: #FFFFFF;
    --sep: rgba(0,0,0,.08);
    --text: #0E1116;
    --text-dim: #5E6573;
    --text-secondary: #5E6573;
    --accent: #2558D4;
    --accent-press: #1E4BB8;
    --accent-ink: #FFFFFF;
    --link: #2558D4;
    --shadow: 0 8px 24px rgba(20,30,60,.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.29;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  overflow-x: clip;
}

@media (prefers-color-scheme: light) {
  :root {
    --raised: #E9EDF3;
  }
  .cat-btn {
    background: var(--raised);
    border: 1px solid rgba(14, 17, 22, 0.14);
  }
  .cat-btn.selected {
    border-width: 2px;
    background: color-mix(in srgb, var(--cat-ring, var(--accent)) 16%, var(--raised));
  }
  .add-cats .cat-btn {
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05);
  }
}

body {
  padding: 0;
  max-width: 640px;
  margin: 0 auto;
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Splash */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, #141824 0%, var(--bg) 65%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: opacity 0.35s ease;
}
.splash-screen.hide { opacity: 0; pointer-events: none; visibility: hidden; }
.splash-icon { display: block; margin-bottom: var(--sp-4); }
.splash-title { font-size: 22px; font-weight: 700; margin: 0 0 var(--sp-2); }
.splash-tag { color: var(--text-dim); font-size: 15px; margin: 0; }

.app-main {
  padding: var(--sp-2) var(--gutter)
    calc(env(safe-area-inset-bottom, 0px) + var(--tab-bar-h) + var(--sp-6));
  padding-left: calc(env(safe-area-inset-left, 0px) + var(--gutter));
  padding-right: calc(env(safe-area-inset-right, 0px) + var(--gutter));
}

.screen[hidden] { display: none !important; }

.screen-header-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--gutter));
  padding: calc(env(safe-area-inset-top, 0px) + var(--sp-2)) var(--gutter) var(--sp-3);
  isolation: isolate;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.screen-header-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: -1;
  pointer-events: none;
}
.screen-header-wrap.compact::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--sep);
  pointer-events: none;
}
.title-sentinel { height: 1px; margin-top: -1px; pointer-events: none; }
.screen-title {
  font-size: 28px;
  line-height: 34px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  transition: font-size 0.2s ease, line-height 0.2s ease;
}
.screen-header-wrap.compact .screen-title {
  font-size: 17px;
  line-height: 22px;
}
.screen-title-compact {
  display: none;
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  top: calc(env(safe-area-inset-top, 0px) + var(--sp-3));
  text-align: center;
  pointer-events: none;
}
.screen-header-wrap.compact .screen-title-compact { display: block; }
.screen-header-wrap.compact .screen-title { visibility: hidden; }

.month-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
#reportMonthSwitcher {
  position: relative;
  z-index: 22;
  isolation: isolate;
}
#reportMonthSwitcher::before {
  content: "";
  position: absolute;
  inset: -4px -8px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  z-index: -1;
}
.report-month-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: 0.96;
  z-index: 21;
  pointer-events: none;
}
.report-month-backdrop:not([hidden]) {
  pointer-events: auto;
}
.month-pill {
  background: var(--raised);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 15px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  position: relative;
}
.month-pill .visually-hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
}
.month-nav {
  background: var(--raised);
  border: none;
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  font-family: inherit;
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.card.flat-card { background: transparent; padding: 0; }
.caption-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin: 0 0 var(--sp-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hero-total {
  font-size: 44px;
  line-height: 48px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--sp-4);
  font-variant-numeric: tabular-nums;
}
.hero-budget-track {
  position: relative;
  height: 8px;
  background: var(--raised);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex: 1;
}
.hero-budget-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  width: 0;
  transition: width 0.35s ease;
}
.hero-budget-pace {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  background: var(--text-dim);
  border-radius: 1px;
}
.hero-budget-row { display: flex; align-items: center; gap: var(--sp-3); }
.hero-budget-pct { font-size: 15px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.hero-budget-meta { font-size: 15px; color: var(--text-dim); margin: var(--sp-2) 0 0; }

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 var(--sp-3);
  text-transform: none;
  letter-spacing: 0;
}

.insights-scroll {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-1);
}
.insights-scroll::-webkit-scrollbar { display: none; }
.insight-chip {
  flex: 0 0 min(280px, 85vw);
  scroll-snap-align: start;
  background: var(--card);
  border-radius: var(--radius-card);
  padding: var(--sp-4);
  min-height: 88px;
}
.insight-chip .insight-kicker { font-size: 13px; color: var(--accent); font-weight: 600; margin-bottom: var(--sp-1); margin-top: 0; }
.insight-chip .insight-text { font-size: 15px; line-height: 1.35; margin: 0; }

.recap-teaser {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.12), rgba(155, 107, 255, 0.08));
  border: 1px solid rgba(91, 140, 255, 0.25);
  border-radius: var(--radius-input);
  color: var(--text);
  font: inherit;
  padding: var(--sp-3) var(--sp-3);
  cursor: pointer;
  min-height: 48px;
  text-align: left;
}
.recap-teaser-icon { display: inline-flex; color: var(--accent); }
.insight-strip-card .recap-teaser { margin: 0; }

.backup-nudge-card { padding: var(--sp-3) var(--sp-4); }
.backup-nudge {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 15px;
  color: var(--text-dim);
}
.backup-nudge-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
}
.settings-nudge {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--sep);
  justify-content: space-between;
}
.backup-nudge-text { flex: 1; line-height: 1.35; }
.backup-nudge-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: var(--sp-2);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}
.data-meta-hint { padding: 0 var(--sp-4) var(--sp-2); margin: 0; }
.inset-card > .data-meta-hint:first-of-type { padding-top: var(--sp-3); }
.backup-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

label.field-label, .field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: var(--sp-2);
}

input[type="number"], input[type="text"], input[type="password"],
input[type="month"], input[type="date"], select {
  width: 100%;
  background: var(--raised);
  border: none;
  border-radius: var(--radius-input);
  padding: 14px;
  color: var(--text);
  font-size: 17px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }

.field { margin-bottom: var(--sp-4); }
.hint { font-size: 13px; color: var(--text-dim); margin: var(--sp-2) 0 0; line-height: 1.4; }
.version { font-size: 13px; color: var(--text-dim); text-align: center; margin: var(--sp-6) 0 var(--sp-2); }

.amount-wrap { position: relative; }
.amount-wrap .dollar {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-dim); pointer-events: none;
  z-index: 1;
}
.amount-wrap input[type="number"] {
  padding-left: 34px;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.cat-btn {
  background: var(--raised);
  border: 2px solid transparent;
  border-radius: var(--radius-input);
  padding: var(--sp-3) var(--sp-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  min-height: 64px;
}
.cat-btn.selected { border-color: var(--cat-ring, var(--accent)); background: color-mix(in srgb, var(--cat-ring, var(--accent)) 12%, var(--raised)); }

/* Category icon badges (inline SVG; motion in icon-animations.css) */
.cat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 10px;
  line-height: 0;
}
.cat-badge--xs { width: 22px; height: 22px; border-radius: 7px; }
.cat-badge--sm { width: 28px; height: 28px; border-radius: 8px; }
.cat-badge--md { width: 32px; height: 32px; }
.cat-badge--lg { width: 40px; height: 40px; border-radius: 11px; }
.cat-badge--picker { width: 36px; height: 36px; }
.cat-badge-icon {
  width: 62%;
  height: 62%;
  background: var(--badge-fg, currentColor);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.cat-badge-letter {
  font-size: 14px;
  font-weight: 700;
  color: var(--badge-fg, currentColor);
  line-height: 1;
}
.cat-badge--xs .cat-badge-letter { font-size: 11px; }
.cat-pill--icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cat-chip--badge { padding: 0; background: transparent !important; }
.donut-center-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  justify-content: center;
}
.donut-center-label-wrap--stacked {
  flex-direction: column;
  gap: 3px;
  align-items: center;
  width: 100%;
  max-width: 100%;
}
.donut-center-label-wrap .donut-center-cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 100%;
  text-align: center;
  font-weight: 600;
}
.insight-kicker-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.report-cat-cell .cat-badge { vertical-align: middle; margin-right: 4px; }

.ui-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.ui-icon--row { width: 22px; height: 22px; }
.ui-icon--xs { width: 14px; height: 14px; }
.ui-icon--sm { width: 18px; height: 18px; }
.ui-icon--md { width: 22px; height: 22px; }
.ui-icon-glyph {
  width: 100%;
  height: 100%;
  background: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.pill-btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
/* Category sheet — icon picker & name field (content-height, no inner scroll) */
#catModal.modal-overlay {
  align-items: flex-end;
}
.cat-name-input-wrap {
  height: 52px;
  border-radius: var(--radius-input);
  background: var(--raised);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 10px;
}
.cat-name-input-wrap input[type="text"] {
  flex: 1;
  min-width: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}
.cat-name-input-wrap input[type="text"]:focus {
  box-shadow: none;
}
.cat-name-preview-host {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-badge--name-preview {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}
.cat-badge--name-preview .icon-art {
  width: 26px;
  height: 26px;
  margin: auto;
}
.cat-badge--name-preview .cat-badge-letter {
  font-size: 18px;
}
.cat-name-count {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.cat-color-field {
  margin-bottom: 0;
}
#catModal .icon-picker {
  display: grid;
  grid-template-columns: repeat(5, 64px);
  justify-content: space-between;
  row-gap: 14px;
  --picker-fg: var(--text);
  --picker-ring: var(--accent);
}
#catModal .icon-picker-option {
  width: 64px;
  height: 64px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-card);
  background-color: var(--raised);
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 100ms ease-out, background-color 150ms ease, box-shadow 150ms ease;
}
#catModal .icon-picker-option:active {
  transform: scale(0.96);
}
#catModal .icon-picker-option.selected {
  background-color: color-mix(in srgb, var(--picker-ring) 20%, var(--raised));
  box-shadow: inset 0 0 0 2.5px var(--picker-ring);
}
@media (prefers-color-scheme: light) {
  #catModal .icon-picker-option.selected {
    background-color: color-mix(in srgb, var(--picker-ring) 16%, var(--raised));
  }
}
#catModal .icon-picker .cat-badge--picker-tile {
  width: 40px;
  height: 40px;
  border-radius: 0;
  background: transparent !important;
  overflow: visible;
  color: var(--picker-fg);
  transition: color 150ms ease;
}
#catModal .icon-picker .cat-badge--picker-tile .cat-badge-letter {
  font-size: 26px;
  font-weight: 700;
  color: var(--picker-fg);
  transition: color 150ms ease;
}
#catModal .icon-picker .cat-badge--picker-tile .icon-art {
  width: 40px;
  height: 40px;
  color: var(--picker-fg);
  transition: color 150ms ease;
}
#catModal .icon-picker .cat-badge--picker-tile .cat-badge-icon {
  background: var(--picker-fg);
  transition: background 150ms ease;
}
#catModal .cat-name-preview-host .cat-badge-icon {
  background: var(--picker-fg);
}
#catModal .icon-picker .icon-art path,
#catModal .icon-picker .icon-art circle {
  stroke-width: 5;
}
#catModal .cat-name-preview-host .icon-art path,
#catModal .cat-name-preview-host .icon-art circle {
  stroke-width: 5;
}
#catModal .color-swatches {
  display: grid;
  grid-template-columns: repeat(6, 44px);
  justify-content: space-between;
  row-gap: 12px;
}
#catModal .color-swatch {
  width: 44px;
  height: 44px;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
#catModal .color-swatch.selected {
  box-shadow: 0 0 0 3px var(--card), 0 0 0 5.5px var(--text);
}
@media (prefers-reduced-motion: reduce) {
  #catModal .icon-picker-option {
    transition: none;
  }
  #catModal .icon-picker-option:active {
    transform: none;
  }
  #catModal .icon-picker .cat-badge--picker-tile,
  #catModal .icon-picker .cat-badge--picker-tile .icon-art,
  #catModal .icon-picker .cat-badge--picker-tile .cat-badge-letter {
    transition: none;
  }
}

.save-btn {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-input);
  padding: var(--sp-4);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 52px;
}
.save-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.flex1 { flex: 1; }

.btn-secondary {
  width: 100%;
  background: var(--raised);
  border: none;
  color: var(--text);
  border-radius: var(--radius-input);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 52px;
  margin-bottom: var(--sp-3);
}
.btn-secondary.danger, .danger-text { color: var(--danger); }
.pill-btn { border-radius: var(--radius-pill); }

.link-btn {
  background: none; border: none;
  color: var(--accent);
  font-size: 15px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  padding: var(--sp-2) 0; min-height: 44px;
}
.legend-edit-budgets { margin-top: var(--sp-3); }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.section-header .card-title { margin: 0; }

.chart-canvas { width: 100%; height: auto; display: block; }
.chart-subtitle { margin: -4px 0 var(--sp-3); font-size: 15px; color: var(--text-dim); }

.donut-wrap {
  position: relative; width: min(100%, 200px); margin: 0 auto var(--sp-3);
  aspect-ratio: 1;
}
@keyframes donut-wrap-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.donut-wrap.donut-wrap--fade-in {
  opacity: 0;
  animation: donut-wrap-fade-in 200ms ease-out forwards;
}
@media (prefers-reduced-motion: reduce) {
  .donut-wrap.donut-wrap--fade-in {
    animation: none;
    opacity: 1;
  }
}
.chart-svg.donut-chart { width: 100%; height: 100%; display: block; }
.donut-seg { cursor: pointer; transition: opacity 0.15s ease; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: var(--donut-inner-box, 74px);
  max-width: var(--donut-inner-box, 74px);
  gap: 1px;
  overflow: hidden;
}
.donut-center-label {
  font-size: var(--donut-center-label-size, 13px);
  line-height: 1.15;
  color: var(--text-dim);
  max-width: 100%;
}
.donut-center-value {
  font-size: var(--donut-center-value-size, 22px);
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
}
.donut-center-sub {
  font-size: var(--donut-center-sub-size, 12px);
  line-height: 1.2;
  color: var(--text-secondary);
  max-width: 100%;
}

.cat-legend { font-size: 15px; }
.legend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--sep);
  align-items: center;
  min-height: 52px;
}
.legend-row:last-child { border-bottom: none; }
.legend-row .name { display: flex; align-items: center; gap: var(--sp-2); text-align: left; font-weight: 600; }
.legend-row .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-chip {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.legend-row .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend-budget-bar { grid-column: 1 / -1; height: 4px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.legend-budget-fill { height: 100%; border-radius: 2px; }
button.legend-row.legend-btn {
  width: 100%; background: none; border: none; font-family: inherit; font-size: 15px;
  cursor: pointer; color: inherit; text-align: left;
}
button.legend-row.legend-btn.active { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: var(--radius-input); }

.chart-legend-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); font-size: 12px; color: var(--text-dim); }
.mini-leg { display: inline-flex; align-items: center; gap: 6px; }
.mini-leg .swatch { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }
.mini-leg .swatch.bar { background: var(--accent); }
.mini-leg .swatch.line { background: var(--text); height: 2px; }
.mini-leg .swatch.green { border-top: 2px dashed var(--success); height: 0; }

.trend-pill { display: inline-block; font-weight: 700; font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.trend-pill.up { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.trend-pill.down { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.trend-pill.flat { background: var(--raised); color: var(--text-dim); }

/* Activity */
.activity-search-row {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.activity-search-row .search-wrap {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.search-wrap {
  position: relative;
  margin-bottom: var(--sp-3);
}
.activity-search-row .search-wrap input[type="search"] {
  padding-left: 42px;
  height: 36px;
  min-height: 36px;
  font-size: 17px;
  background: var(--raised);
  border-radius: 10px;
  width: 100%;
  border: none;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.activity-search-row .search-wrap input[type="search"]::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}
.activity-search-row .search-wrap input[type="search"]:focus {
  box-shadow: none;
}
.search-wrap input {
  padding-left: 40px;
  height: 36px;
  min-height: 36px;
  font-size: 17px;
  background: var(--raised);
  border-radius: 10px;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}
.search-icon .search-icon-svg {
  display: block;
  width: 20px;
  height: 20px;
}
.activity-filter-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--raised);
  border: none;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
}
.activity-filter-btn.is-active {
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent);
}
.activity-range-chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  margin-bottom: var(--sp-3);
  max-width: 100%;
}
.activity-range-chip {
  flex: 0 0 auto;
  background: var(--raised);
  border: 1px solid var(--sep);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  height: 32px;
  min-height: 32px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  box-sizing: border-box;
}
.activity-range-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
@media (prefers-color-scheme: light) {
  .activity-range-chip[aria-pressed="true"] {
    color: var(--accent-ink);
  }
}
.activity-summary-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  background: var(--card);
  border-radius: var(--radius-card);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.activity-summary-range {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: var(--sp-1);
}
.activity-summary-total {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.activity-summary-side {
  text-align: right;
  flex-shrink: 0;
}
.activity-summary-count {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: var(--sp-1);
}
.activity-summary-avg {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.activity-summary-avg .avg-amt {
  color: var(--text);
  font-weight: 600;
}

.activity-account-segments {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 0 var(--sp-3);
  padding-bottom: 2px;
}
.activity-account-segments::-webkit-scrollbar { display: none; }
.activity-account-segment {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--sep);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.activity-account-segment[aria-pressed="true"] {
  background: var(--raised);
  color: var(--text);
  border-color: rgba(255,255,255,.12);
}
.account-mini-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-mini-icon svg { width: 10px; height: 10px; display: block; }
.account-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  background: var(--raised);
  font-size: 12px;
  color: var(--text-dim);
  vertical-align: middle;
}
.account-tag .account-mini-icon { width: 14px; height: 14px; }
.account-tag .account-mini-icon svg { width: 9px; height: 9px; }

.activity-row.is-transfer-row .row-amt { color: var(--text-dim); }
.activity-row.is-transfer-row .row-linked {
  display: block;
  font-size: 12px;
  color: var(--accent);
  margin-top: 4px;
  font-weight: 600;
}
.activity-row.is-transfer-row .transfer-chip {
  background: var(--raised);
  color: var(--text-dim);
}
.activity-row.is-transfer-row .transfer-chip svg { opacity: .85; }

.import-account-modal { padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px)); }
.import-account-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 var(--sp-4) var(--sp-3);
  letter-spacing: -0.02em;
}
.import-account-file {
  margin: 0 var(--sp-4) var(--sp-4);
  font-size: 15px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.import-account-file .file-doc-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .7;
}
.import-account-list { margin: 0 var(--sp-4); display: flex; flex-direction: column; gap: 10px; }
.import-account-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: var(--radius-card);
  border: 1.5px solid transparent;
  background: var(--card);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}
.import-account-option[aria-checked="true"] {
  border-color: var(--accent);
}
.import-account-option-main { flex: 1; min-width: 0; }
.import-account-option-name {
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.import-account-option-sub { font-size: 14px; color: var(--text-dim); margin-top: 2px; }
.import-account-suggested {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(91, 140, 255, .18);
  color: var(--accent);
}
.import-account-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  flex-shrink: 0;
  position: relative;
}
.import-account-option[aria-checked="true"] .import-account-radio {
  border-color: var(--accent);
  background: var(--accent);
}
.import-account-option[aria-checked="true"] .import-account-radio::after {
  content: '';
  position: absolute;
  inset: 5px;
  background: var(--accent-ink);
  border-radius: 50%;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath fill='white' d='M1 5.2L4.2 8.4 11 1.6' stroke='white' stroke-width='2' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
}
.import-account-add {
  justify-content: flex-start;
  color: var(--text-secondary);
}
.import-account-add .account-mini-icon { background: var(--raised); color: var(--text-dim); }
.import-account-hint {
  margin: var(--sp-4) var(--sp-4) var(--sp-3);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.import-account-hint .hint-info-icon { flex-shrink: 0; opacity: .7; margin-top: 1px; }
#importAccountContinueBtn { margin: var(--sp-2) var(--sp-4) 0; width: calc(100% - var(--sp-4) * 2); }

.account-type-picker { display: flex; gap: 8px; }
.account-type-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-card);
  border: 1.5px solid var(--sep);
  background: var(--card);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
}
.account-type-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(91, 140, 255, .1);
}

.transfer-detail-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--bg);
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--sp-4) calc(env(safe-area-inset-bottom, 0px) + 24px);
}
.transfer-detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.transfer-detail-hero {
  text-align: center;
  margin-bottom: var(--sp-5);
}
.transfer-detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-3);
}
.transfer-detail-title { font-size: 17px; color: var(--text-secondary); margin-bottom: 4px; }
.transfer-detail-amount { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.transfer-detail-direction { font-size: 15px; color: var(--text-dim); margin-top: 6px; }
.transfer-not-spending {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--sp-3);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(52, 199, 123, .15);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
}
.transfer-section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: var(--sp-4) 0 var(--sp-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.transfer-pair-card {
  background: var(--card);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.transfer-pair-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--sep);
}
.transfer-pair-row:last-child { border-bottom: none; }
.transfer-pair-row-main { flex: 1; min-width: 0; }
.transfer-pair-row-title { font-weight: 600; font-size: 16px; }
.transfer-pair-row-sub { font-size: 14px; color: var(--text-dim); margin-top: 2px; }
.transfer-pair-row-amt {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.transfer-pair-row-date { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.transfer-auto-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: var(--sp-3);
  line-height: 1.45;
  display: flex;
  gap: 8px;
}
.transfer-details-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 4px 0;
}
.transfer-details-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 16px;
  border-bottom: 1px solid var(--sep);
}
.transfer-details-row:last-child { border-bottom: none; }
.transfer-details-row span:first-child { color: var(--text-dim); }
.transfer-unlink-btn {
  width: 100%;
  margin-top: var(--sp-5);
  padding: 16px;
  border-radius: var(--radius-card);
  border: none;
  background: var(--card);
  color: #ff6b6b;
  font-size: 17px;
  font-weight: 600;
}

.activity-month-block { margin-bottom: var(--sp-4); }
.activity-month-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) 0 var(--sp-3);
}
.activity-month-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.activity-month-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}
.activity-month-total {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.activity-filter-sheet {
  padding: 0 var(--sp-4) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.activity-filter-sheet .field-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: var(--sp-2);
}
.activity-filter-sheet .field-select {
  width: 100%;
  min-height: 44px;
}
.entries-meta { font-size: 13px; color: var(--text-dim); margin: 0 0 var(--sp-2); }

.activity-day-block {
  margin-bottom: var(--sp-4);
}
.activity-day-block .activity-group {
  margin-bottom: 0;
}
.activity-group {
  background: var(--card);
  border-radius: var(--radius-card);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}
.activity-group.activity-flat .activity-day-rows { border-radius: var(--radius-card); }
.activity-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0 var(--sp-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  position: sticky;
  top: var(--activity-day-sticky-top, calc(env(safe-area-inset-top, 0px) + 48px));
  z-index: 4;
  margin: 0 0 var(--sp-2);
}
.activity-day-rows {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--card);
}
.activity-day-header .day-total {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 52px;
  border-bottom: 1px solid var(--sep);
  cursor: pointer;
}
.activity-row:last-child { border-bottom: none; }
.activity-row .row-main { flex: 1; min-width: 0; }
.activity-row .row-title { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-row .row-sub {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.activity-row .row-sub-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-row .row-sub .account-tag {
  flex-shrink: 0;
  margin-left: 0;
}
.activity-row.is-transfer-row .row-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.activity-row .row-amt { font-weight: 600; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.entry {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--sep); gap: var(--sp-3); cursor: pointer;
}
.entry:last-child { border-bottom: none; }
.entry-info { min-width: 0; flex: 1; }
.entry-info .top { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.entry-info .note { font-size: 15px; color: var(--text-dim); }
.entry-info .date { font-size: 13px; color: var(--text-dim); }
.entry-right { display: flex; align-items: center; gap: var(--sp-2); }
.entry-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.cat-pill { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--raised); border: 1px solid var(--sep); }

.del-btn {
  background: transparent; border: 1px solid var(--sep);
  color: var(--danger); width: 44px; height: 44px;
  border-radius: var(--radius-input); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.empty { text-align: center; color: var(--text-dim); font-size: 15px; padding: var(--sp-6) var(--sp-2); }

/* Bottom tab bar */
.bottom-tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 640px;
  margin: 0 auto;
  box-sizing: border-box;
  min-height: calc(var(--tab-bar-h) + env(safe-area-inset-bottom, 0px));
  height: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--sep);
  z-index: 100;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.15;
  padding: 5px 2px 3px;
  min-height: var(--tab-bar-h);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.tab-btn:not(.tab-btn-add) {
  flex: 1 1 0;
  min-width: 0;
}
.tab-btn > span:not(.add-fab) {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}
.tab-btn .tab-icon { width: 24px; height: 24px; }
.tab-btn.active { color: var(--accent); }
.tab-btn-add { flex: 0 0 72px; margin-top: -18px; max-height: none; min-height: 0; }
.add-fab {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

/* Sheets / modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2000;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s cubic-bezier(.2,.8,.2,1);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
/* Sheet modals: fade backdrop only so the sheet panel stays fully opaque */
.modal-overlay.sheet {
  opacity: 1;
  background: transparent;
  transition: none;
}
.modal-overlay.sheet:not(.show) {
  visibility: hidden;
  pointer-events: none;
}
.modal-overlay.sheet.show {
  visibility: visible;
}
.modal-overlay.sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
}
.modal-overlay.sheet.modal-front::before {
  background: rgba(0, 0, 0, 0.72);
}
.modal-overlay.sheet.show::before {
  opacity: 1;
  pointer-events: auto;
}
.modal-overlay.sheet.show { pointer-events: auto; }
.modal-overlay.sheet .modal {
  position: relative;
  z-index: 1;
  background: var(--card);
}
.modal-overlay.modal-front {
  z-index: 5000;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.modal-overlay.sheet.modal-front {
  background: transparent;
}
#balanceSheet.modal-overlay.modal-front {
  z-index: 5200;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.modal-overlay.modal-front .modal {
  background: var(--card);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
}
.modal {
  background: var(--card);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: var(--sp-3) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + var(--sp-4));
  width: 100%;
  max-width: 640px;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  max-height: 92vh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}
.sheet-modal.add-sheet { overflow-x: hidden; }
.modal-overlay.show .modal { transform: translateY(0); }
#catModal .modal.cat-sheet-modal {
  height: auto;
  max-height: none;
  overflow: visible;
  padding-bottom: calc(34px + env(safe-area-inset-bottom, 0px));
}
.sheet-grabber {
  width: 36px; height: 5px;
  background: var(--sep);
  border-radius: 3px;
  margin: 0 auto var(--sp-3);
}
.sheet-header {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto minmax(64px, 1fr);
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.sheet-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  grid-column: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-header-action {
  min-height: 44px;
  padding: var(--sp-2) 0;
  justify-self: start;
}
.sheet-header-trailing { justify-self: end; }
.sheet-header > .sheet-cancel { justify-self: start; }
.sheet-header > .link-btn:not(.sheet-header-trailing) { justify-self: start; }
.sheet-header-spacer { width: 1px; justify-self: end; }
.sheet-cancel { width: auto; min-height: 36px; padding: 8px 12px; margin: 0; justify-self: start; }

.add-amount-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: var(--sp-4);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.add-amount-prefix { font-size: 44px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.add-amount-display input {
  flex: 1 1 auto;
  min-width: 0;
  width: 0;
  max-width: 100%;
  background: transparent;
  border: none;
  font-size: clamp(28px, 10vw, 44px);
  line-height: 48px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0;
  box-shadow: none;
}
.add-cats { max-width: 100%; }
.grouped-rows { padding: 0; overflow: hidden; max-width: 100%; }
.grouped-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) minmax(0, auto) 16px;
  gap: var(--sp-2);
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  min-height: 52px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--sep);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.add-note-field {
  padding: 0 var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--sep);
}
.add-note-field input {
  width: 100%;
  background: var(--raised);
  border: none;
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-size: 17px;
  box-shadow: none;
  pointer-events: auto;
}
.grouped-row:last-child { border-bottom: none; }
.row-value { color: var(--text-dim); font-size: 15px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 42vw; }
.chevron { color: var(--text-dim); }
.switch-row { cursor: default; grid-template-columns: 32px minmax(0, 1fr) auto; }
.ios-switch {
  width: 51px;
  height: 31px;
  max-width: 51px;
  accent-color: var(--accent);
  justify-self: end;
  grid-column: 3;
  flex-shrink: 0;
}
.toggle-switch {
  position: relative;
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border: none;
  border-radius: 16px;
  background: var(--sep);
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}
.toggle-switch.is-on {
  background: var(--accent);
}
.toggle-switch.is-on::after {
  transform: translateX(20px);
}

.inset-group { margin-bottom: var(--sp-6); }
.group-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 var(--sp-2) var(--sp-2);
}
.inset-card {
  background: var(--card);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.inset-card .entry,
.inset-card .settings-inset-entry {
  padding: var(--sp-3) var(--sp-4);
}
.inset-card .budget-settings-field {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--sep);
}
.inset-card .budget-settings-field:last-child {
  border-bottom: none;
}
.inset-card .entry .top {
  gap: var(--sp-3);
  align-items: center;
}
.inset-card .settings-cat-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.settings-row, .settings-row-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  min-height: 52px;
  border-bottom: 1px solid var(--sep);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.settings-row:last-child, .settings-row-btn:last-child { border-bottom: none; }
.inset-hint { padding: 0 var(--sp-4) var(--sp-3); margin: 0; }
.check-settings { gap: var(--sp-3); }
.group-action { margin-left: var(--sp-2); }
.full-destructive { margin-top: var(--sp-4); }

.collapsible summary {
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.collapsible summary::-webkit-details-marker { display: none; }
.inline-select { width: auto; font-size: 13px; padding: 6px 28px 6px 10px; }

/* Spending Wrapped — story slides (always dark) */
.wrapped-overlay {
  background: #000;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
.wrapped-overlay.show { align-items: stretch; }
.wrapped-overlay .modal { display: none; }
.wrapped-overlay.show .wrapped-stories { opacity: 1; }
.wrapped-stories {
  --wrapped-bg: #000;
  --wrapped-card: #1c1c1e;
  --wrapped-text: #f2f4f8;
  --wrapped-dim: #8e8e93;
  color: var(--wrapped-text);
  background: var(--wrapped-bg);
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) var(--sp-4) env(safe-area-inset-bottom);
  box-sizing: border-box;
  opacity: 0;
  transition: opacity 250ms ease;
}
.wrapped-progress {
  display: flex;
  gap: 4px;
  padding: var(--sp-2) 0 var(--sp-3);
}
.wrapped-progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
}
.wrapped-progress-seg.is-on { background: rgba(255, 255, 255, 0.55); }
.wrapped-progress-seg.is-current { background: #fff; }
.wrapped-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: 14px;
  font-weight: 600;
}
.wrapped-topbar-title { display: inline-flex; align-items: center; gap: 6px; color: var(--wrapped-text); }
.wrapped-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--wrapped-text);
  font-size: 16px;
  cursor: pointer;
}
.wrapped-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.wrapped-tap-zones {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
}
.wrapped-tap-back { flex: 0 0 38%; border: none; background: transparent; cursor: pointer; }
.wrapped-tap-next { flex: 1; border: none; background: transparent; cursor: pointer; }
.wrapped-slides {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--sp-1);
  display: flex;
  flex-direction: column;
}
.wrapped-slide {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: min(100%, 100%);
  justify-content: flex-start;
}
.wrapped-card {
  border-radius: 26px;
  padding: 22px 20px;
  position: relative;
  flex-shrink: 0;
}
.wrapped-slide > .wrapped-hero {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 24px 20px 20px;
}
.wrapped-slide > .wrapped-hero.wrapped-hero--fill {
  flex: 1 1 auto;
  min-height: 0;
}
.wrapped-slide > .wrapped-card--dim {
  flex: 1 1 auto;
  min-height: 0;
}
.wrapped-card--dim {
  background: var(--wrapped-card);
}
.wrapped-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.55);
  margin-bottom: var(--sp-2);
}
.wrapped-card--dim .wrapped-kicker { color: var(--wrapped-dim); }
.wrapped-hero-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.12;
  margin: 0 0 10px;
  color: #0a0a0a;
  max-width: 92%;
}
.wrapped-hero-lead { margin: 0 0 4px; font-size: 17px; font-weight: 600; color: rgba(0, 0, 0, 0.68); }
.wrapped-hero-num {
  font-size: 52px;
  font-weight: 800;
  margin: 0;
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #0a0a0a;
}
.wrapped-hero-num--text { font-size: 38px; }
.wrapped-hero-sub { margin: 10px 0 0; font-size: 15px; font-weight: 600; line-height: 1.35; color: rgba(0, 0, 0, 0.75); }
.wrapped-hero-detail { margin: var(--sp-1) 0 0; font-size: 14px; color: rgba(0, 0, 0, 0.62); }
.wrapped-hero-icon {
  position: absolute;
  top: 20px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.16);
}
.wrapped-hero-icon .ui-icon-glyph,
.wrapped-hero-icon .cat-badge-icon {
  background-color: rgba(0, 0, 0, 0.85) !important;
}
.wrapped-hero-icon .cat-badge {
  box-shadow: none;
  background: transparent !important;
}
.wrapped-hero--blue { background: #5b8cff; }
.wrapped-hero--orange { background: #ff9500; }
.wrapped-hero--gold { background: #ffb800; }
.wrapped-hero--pink { background: #ff6b9d; }
.wrapped-hero--purple { background: #b794f6; }
.wrapped-hero--green { background: #51cf66; }
.wrapped-hero--teal { background: #38d9a9; }
.wrapped-mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  min-height: 132px;
}
.wrapped-mini-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.65);
  font-weight: 600;
}
.wrapped-mini-bar-val { font-size: 9px; white-space: nowrap; }
.wrapped-mini-bar-fill {
  width: 100%;
  max-width: 42px;
  height: var(--h, 24px);
  border-radius: 8px 8px 5px 5px;
  background: rgba(0, 0, 0, 0.28);
}
.wrapped-mini-bar.wrapped-bar-current .wrapped-mini-bar-fill {
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.wrapped-split {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
}
.wrapped-split-stat { flex: 1; padding: var(--sp-4); }
.wrapped-split-divider { width: 1px; background: rgba(255, 255, 255, 0.08); }
.wrapped-stat-lg { display: block; font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wrapped-good { color: #51cf66; }
.wrapped-stat-sub { margin: 4px 0 0; font-size: 12px; color: var(--wrapped-dim); }
.wrapped-row-card {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}
.wrapped-row-icon {
  flex: 0 0 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(91, 140, 255, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wrapped-row-icon .ui-icon-glyph,
.wrapped-cat-icon .cat-badge-icon,
.wrapped-cat-icon .ui-icon-glyph {
  background-color: #f2f4f8 !important;
}
.wrapped-row-icon--ok { background: rgba(81, 207, 102, 0.2); }
.wrapped-stack-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: var(--sp-2) 0 var(--sp-3);
  gap: 2px;
}
.wrapped-stack-seg { display: block; height: 100%; border-radius: 3px; }
.wrapped-cat-row, .wrapped-purchase-row, .wrapped-budget-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.wrapped-purchase-row { grid-template-columns: auto 1fr auto; }
.wrapped-cat-name, .wrapped-purchase-row strong { font-weight: 700; font-size: 16px; }
.wrapped-steady-line { white-space: nowrap; font-size: 15px; display: block; }
.wrapped-cat-pct { color: var(--wrapped-dim); font-size: 13px; }
.wrapped-cat-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.wrapped-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: var(--sp-2) 0; }
.wrapped-chip {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
}
.wrapped-wday-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 72px;
  margin: var(--sp-2) 0;
}
.wrapped-wday-bar {
  flex: 1;
  height: var(--h-anim, var(--h, 12px));
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  align-self: flex-end;
}
.wrapped-wday-bar.wrapped-bar-current { background: #ff6b9d; }
.wrapped-wday-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--wrapped-dim);
  font-weight: 700;
}
.wrapped-wday-active { color: #ff6b9d; }
.wrapped-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  vertical-align: middle;
}
.wrapped-badge--new { background: #5b8cff; color: #fff; }
.wrapped-badge--up { background: #fcc419; color: #111; }
.wrapped-budget-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.wrapped-budget-fill { height: 100%; border-radius: 3px; }
.wrapped-budget-ok { color: #51cf66; }
.wrapped-budget-over { color: #ff6b6b; }
.wrapped-budget-fill.wrapped-budget-ok { background: #51cf66; }
.wrapped-budget-fill.wrapped-budget-over { background: #ff6b6b; }
.wrapped-budget-status { font-size: 12px; font-weight: 700; text-align: right; }
.wrapped-budget-ratio { font-size: 12px; color: var(--wrapped-dim); }
.wrapped-footer-hint {
  text-align: center;
  font-size: 13px;
  color: var(--wrapped-dim);
  margin: 6px 0 4px;
  flex-shrink: 0;
}
.wrapped-summary-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.wrapped-share-btn, .wrapped-done-btn {
  flex: 1;
  min-height: 48px;
  border-radius: 999px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.wrapped-share-btn {
  background: #5b8cff;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.wrapped-done-btn { background: #2c2c2e; color: #fff; }
.wrapped-share-note {
  text-align: center;
  font-size: 12px;
  color: var(--wrapped-dim);
  margin: var(--sp-2) 0 0;
}
.wrapped-summary-card {
  border-radius: 24px;
  padding: var(--sp-5) var(--sp-4);
  background: linear-gradient(180deg, #5b8cff 0%, #9b6bff 100%);
  color: #fff;
}
.wrapped-summary-head { font-weight: 700; margin: 0 0 var(--sp-2); display: flex; align-items: center; gap: 6px; }
.wrapped-summary-total { font-size: 48px; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; }
.wrapped-summary-cmp { font-size: 14px; opacity: 0.9; margin: var(--sp-1) 0 var(--sp-3); }
.wrapped-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1 1 auto;
  align-content: stretch;
}
.wrapped-summary-tile {
  background: rgba(0, 0, 0, 0.22);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 82px;
}
.wrapped-summary-card {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
.wrapped-summary-tile .wrapped-kicker { color: rgba(255, 255, 255, 0.65); margin-bottom: 4px; }
.wrapped-summary-tile strong { display: block; font-size: 15px; }
.wrapped-summary-foot {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-4);
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
}
.wrapped-empty {
  color: var(--text-dim);
  text-align: center;
  padding: var(--sp-6);
}

/* Import */
.import-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.import-stat {
  background: var(--raised);
  border-radius: var(--radius-input);
  padding: var(--sp-2) var(--sp-3);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.25;
  text-align: center;
}
.import-stat strong { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.import-stat span { color: var(--text-dim); }
.import-row-list {
  max-height: 50vh;
  overflow-y: auto;
  scrollbar-color: color-mix(in srgb, var(--text-dim) 35%, transparent) transparent;
  scrollbar-width: thin;
}
.import-row-list::-webkit-scrollbar { width: 8px; }
.import-row-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-dim) 40%, transparent);
  border-radius: 8px;
}
.import-row-list::-webkit-scrollbar-track { background: transparent; }
.import-row { background: var(--raised); border-radius: var(--radius-input); padding: var(--sp-3); margin-bottom: var(--sp-2); }
.import-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  font-weight: 600;
  font-size: 14px;
}
.import-row-date { flex: 1; min-width: 0; }
.import-row-amt { flex-shrink: 0; font-variant-numeric: tabular-nums; margin-left: var(--sp-2); }
.import-row-note { font-size: 14px; color: var(--text-secondary); margin: 4px 0 8px; line-height: 1.35; }
.import-row-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.import-row-actions .import-cat-select {
  width: 100%; border: none; border-radius: var(--radius-pill); background: var(--card);
  padding: 8px 12px; font-size: 14px; font-family: inherit; color: var(--text);
}
.import-row-actions .import-xfer-seg { width: 100%; justify-content: stretch; }
.import-row-actions .import-xfer-seg .seg-btn { flex: 1; text-align: center; font-size: 11px; padding: 6px 4px; }
.import-row-actions .import-xfer-seg--4 .seg-btn { font-size: 10px; padding: 6px 3px; }
.import-other-tag {
  align-self: flex-start; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: rgba(91, 140, 255, 0.15); color: var(--accent);
}
#importModal.modal-overlay {
  isolation: isolate;
}
#importModal .import-review-discard-scrim {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: rgba(0, 0, 0, 0.62);
  box-sizing: border-box;
}
@media (prefers-color-scheme: light) {
  #importModal .import-review-discard-scrim {
    background: rgba(0, 0, 0, 0.72);
  }
}
#importModal .import-review-discard-scrim.show {
  display: flex;
}
#importModal .import-discard-card {
  width: 100%;
  max-width: 340px;
  background-color: var(--card);
  color: var(--text);
  opacity: 1;
  border-radius: var(--radius-card);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
#importModal .import-discard-card h3 { margin: 0 0 var(--sp-2); font-size: 20px; }
#importModal .import-discard-card .hint { margin: 0; }
.import-discard-actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.import-discard-actions .save-btn,
.import-discard-actions .btn-secondary {
  width: 100%;
  margin-bottom: 0;
}

.color-swatches { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.color-swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.color-swatch.selected { border-color: var(--text); }
.emoji-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-option { width: 44px; height: 44px; border-radius: var(--radius-input); border: 1px solid var(--sep); background: var(--raised); font-size: 20px; cursor: pointer; }

.summary-row { display: flex; justify-content: space-between; padding: var(--sp-3) 0; border-bottom: 1px solid var(--sep); font-size: 15px; }
.summary-row:last-child { border-bottom: none; }
.summary-row .label { color: var(--text-dim); }
.summary-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }

.month-bar-row { display: flex; align-items: center; gap: var(--sp-3); padding: 6px 0; font-size: 13px; }
.month-bar-row .bar-wrap { flex: 1; height: 10px; background: var(--raised); border-radius: 5px; overflow: hidden; }
.month-bar-row .bar-fill { height: 100%; background: var(--accent); }

.recurring-badge { font-size: 10px; padding: 2px 7px; border-radius: 10px; background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); font-weight: 700; }

.report-header { text-align: center; padding: var(--sp-2) 0 var(--sp-4); border-bottom: 1px solid var(--sep); }
.report-total { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.report-section { margin-top: var(--sp-4); }
.report-section h3 { margin: 0 0 var(--sp-2); font-size: 15px; font-weight: 600; }
.report-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.report-section-head h3 { margin: 0; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th, .report-table td { padding: var(--sp-2); border-bottom: 1px solid var(--sep); text-align: left; vertical-align: middle; }
.report-table td:last-child, .report-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.report-tx-table { table-layout: fixed; }
.report-tx-table th:first-child, .report-tx-table td.report-tx-date { width: 54px; max-width: 54px; white-space: nowrap; padding-right: var(--sp-1); font-size: 12px; }
.report-tx-table th:nth-child(2), .report-tx-table .report-cat-cell { overflow: hidden; }
.report-tx-table th:last-child, .report-tx-table td.report-tx-amt { width: 72px; max-width: 72px; white-space: nowrap; }
.report-tx-label { display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.report-tx-label .cat-badge { flex-shrink: 0; }
.report-tx-label-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }

.seg-control {
  display: inline-flex;
  background: var(--raised);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  min-height: 32px;
  cursor: pointer;
  white-space: nowrap;
}
.seg-btn.is-active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.report-chart-card { margin-bottom: var(--sp-4); }
.report-chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.report-chart-head .card-title { margin: 0; flex: 1; }
.report-chart-compare { margin-top: var(--sp-1); min-height: 1.25em; }
.report-avg-chip { color: var(--text-dim); font-size: 13px; }
.report-chart-scroll {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  margin: var(--sp-2) calc(-1 * var(--sp-4)) 0;
  padding: 0 var(--sp-4) var(--sp-1);
  scrollbar-width: none;
}
#reportChartSvgWrap {
  will-change: transform, opacity;
}
#reportChartSvgWrap.report-chart-window-anim {
  transition: transform 180ms ease, opacity 180ms ease;
}
#reportChartSvgWrap.report-chart-window-left {
  transform: translateX(10px);
  opacity: 0.55;
}
#reportChartSvgWrap.report-chart-window-right {
  transform: translateX(-10px);
  opacity: 0.55;
}
.report-chart-scroll::-webkit-scrollbar { display: none; }
.report-chart-svg { display: block; height: 196px; width: auto; max-width: none; }
.report-chart-svg--fit { width: 100%; max-width: 100%; }
.report-bar-track { fill: var(--raised); }
.report-bar-outline { stroke: var(--accent); stroke-width: 2; pointer-events: none; }
.report-bar-label { fill: var(--text-dim); font-size: 10px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.report-bar-label.is-sel { fill: var(--accent); }
.report-avg-line { stroke: var(--text-dim); stroke-width: 1; opacity: 0.55; pointer-events: none; }
.report-avg-label { fill: var(--text-dim); font-size: 9px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, sans-serif; opacity: 0.8; pointer-events: none; }
.report-bar-hit { cursor: pointer; touch-action: manipulation; }
.report-bar-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.report-recur-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.report-recur-group {
  border: 1px solid var(--sep);
  border-radius: var(--radius-input);
  overflow: hidden;
  background: var(--raised);
}
.report-recur-group[open] { background: var(--card); }
.report-recur-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  cursor: pointer;
  list-style: none;
  font-size: 14px;
}
.report-recur-summary::-webkit-details-marker { display: none; }
.report-recur-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-recur-meta { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.report-recur-count { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.report-recur-total { font-weight: 700; }
.report-recur-table { margin: 0; }
.report-recur-table td { font-size: 12px; }
.report-recur-onetime {
  border: 1px dashed var(--sep);
  border-radius: var(--radius-input);
  background: transparent;
  margin-top: var(--sp-1);
}
.report-recur-onetime-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: var(--text-secondary);
}
.report-recur-onetime-summary::-webkit-details-marker { display: none; }
.report-recur-onetime-label { font-weight: 600; }
.report-recur-onetime-meta { font-weight: 500; font-size: 12px; }
.report-recur-onetime[open] { background: var(--raised); border-style: solid; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--tab-bar-h) + var(--sp-4));
  transform: translateX(-50%) translateY(20px);
  background: var(--raised);
  color: var(--text);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-pill);
  font-size: 15px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 6000;
  max-width: 85vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.undo-toast {
  position: fixed;
  left: var(--gutter); right: var(--gutter);
  bottom: var(--tab-bar-offset, calc(env(safe-area-inset-bottom, 0px) + var(--tab-bar-h) + 12px));
  background: var(--card);
  border-radius: var(--radius-card);
  padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: center; justify-content: space-between;
  z-index: 150;
  box-shadow: var(--shadow);
  max-width: 608px;
  margin: 0 auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(100% + var(--sp-4)));
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1), opacity 0.2s ease, visibility 0.2s ease;
}
.undo-toast.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  z-index: 1100;
}
.undo-toast button {
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: var(--radius-input);
  padding: 10px 18px; font-weight: 700; font-family: inherit; min-height: 44px;
}

.save-hint { font-size: 13px; color: var(--text-dim); text-align: center; min-height: 1.2em; }

.receipt-preview { width: 56px; height: 56px; border-radius: var(--radius-input); object-fit: cover; }
.receipt-modal-img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--radius-input); }

.btn-row { display: flex; gap: var(--sp-3); margin-top: var(--sp-4); }

/* —— Forecast & balance —— */
.forecast-home-card {
  display: block; width: 100%; text-align: left; position: relative;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border: none; font: inherit; color: inherit; cursor: pointer;
}
.forecast-home-kicker {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 6px;
}
.forecast-home-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.forecast-home-date { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; max-width: 100%; }
.forecast-home-date.is-long { font-size: 17px; line-height: 1.25; white-space: normal; }
.forecast-home-days { font-size: 14px; color: var(--text-dim); white-space: nowrap; }
.forecast-home-balance {
  margin-top: 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--text-dim);
}
.forecast-home-balance-val { font-size: 17px; font-weight: 700; color: var(--text); white-space: nowrap; }
.forecast-home-chevron { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }

.home-section-error {
  border: 1px solid rgba(255, 90, 95, 0.35);
  background: var(--card);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
}
.home-section-error-title { margin: 0 0 6px; font-size: 15px; font-weight: 600; color: var(--text); }
.home-section-error-text { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text-dim); }

.forecast-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  padding:
    0
    calc(env(safe-area-inset-right, 0px) + var(--gutter))
    calc(80px + env(safe-area-inset-bottom, 0px))
    calc(env(safe-area-inset-left, 0px) + var(--gutter));
}
.forecast-nav {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 calc(-1 * var(--gutter)) 0;
  padding: calc(env(safe-area-inset-top, 0px) + var(--sp-2)) var(--gutter) var(--sp-2);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
}
.forecast-nav.is-scrolled { border-bottom-color: var(--sep); }
.forecast-nav-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.forecast-nav-meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0 2px; font-size: 14px; font-weight: 600;
}
.forecast-nav-meta-label { color: var(--text-secondary); font-weight: 600; }
.forecast-nav-meta-val { font-weight: 700; }
.forecast-nav-meta-val.is-neg { color: #F87171; }
.forecast-nav-meta-val.is-pos { color: var(--success); }
.forecast-back-btn {
  justify-self: start;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-left: 0;
  padding-right: var(--sp-2);
}
.forecast-back-chev { flex-shrink: 0; display: block; }
.forecast-nav-title { font-size: 17px; font-weight: 600; text-align: center; margin: 0; }
.forecast-info-btn {
  justify-self: end;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--sep);
  background: transparent;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: -4px 0;
}
.forecast-info-btn svg { width: 22px; height: 22px; }
.forecast-kicker {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); margin: 0;
}
.forecast-summary-card { padding: var(--sp-4); margin-bottom: var(--sp-3); }
.forecast-summary-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.forecast-account-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; background: #20C99722; color: #20C997;
  white-space: nowrap;
}
.forecast-headline-row { margin-top: 8px; }
.forecast-headline-main { min-width: 0; }
.forecast-headline-prefix { font-size: 15px; color: var(--text-secondary); margin: 0 0 2px; }
.forecast-headline-date-row {
  display: flex; flex-wrap: nowrap; align-items: baseline; justify-content: space-between;
  gap: 8px; width: 100%;
}
.forecast-days-away { flex-shrink: 0; text-align: right; }
.forecast-headline-date { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin: 0; line-height: 1.05; white-space: nowrap; max-width: 100%; }
.forecast-headline-date.is-long { font-size: 22px; line-height: 1.2; white-space: normal; }
.forecast-headline-date.is-all-days { font-size: 28px; }
.forecast-days-away { font-size: 14px; color: var(--text-dim); margin: 0; white-space: nowrap; }
.forecast-cause-line, .forecast-positive-line {
  font-size: 13px; color: var(--text-secondary); margin: 10px 0 0; line-height: 1.35;
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.forecast-cause-when { white-space: nowrap; }
.forecast-cause-line strong, .forecast-positive-line strong { color: var(--text); font-weight: 700; }
.forecast-positive-line { color: var(--success); }
.forecast-positive-line svg { flex-shrink: 0; }
.forecast-up-row--summary {
  cursor: default;
  background: color-mix(in srgb, #ff922b 12%, var(--card));
}
.forecast-up-row--summary .forecast-up-title { color: var(--text); font-weight: 600; }
.forecast-up-row--past {
  cursor: default;
  opacity: 0.92;
}
.forecast-up-divider {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-dim);
  border-top: 1px dashed var(--sep); border-bottom: 1px dashed var(--sep);
  background: color-mix(in srgb, var(--raised) 50%, transparent);
}
.forecast-up-moved-chip {
  display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; color: var(--text-secondary); background: var(--raised);
}
.forecast-cushion-chip.is-critical { background: rgba(185, 28, 28, 0.14); color: #B91C1C; }
.forecast-show-more-btn {
  display: block; width: 100%; margin-top: var(--sp-3); padding: 12px;
  border: none; border-radius: var(--radius-input); background: rgba(91, 140, 255, 0.14);
  color: var(--accent); font-size: 16px; font-weight: 600; font-family: inherit;
}
.forecast-upcoming-foot {
  display: flex; gap: 8px; font-size: 12px; color: var(--text-dim); margin: var(--sp-3) 0 0; line-height: 1.45;
}
.forecast-detail-modal { max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.forecast-detail-body { flex: 1; overflow-y: auto; padding: 0 0 var(--sp-3); }
.forecast-detail-close {
  position: absolute; right: 16px; top: 12px; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--raised); color: var(--text-dim); font-size: 22px; line-height: 1;
}
.forecast-detail-hero {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: start;
  margin-bottom: var(--sp-4); padding-right: 40px;
}
.forecast-detail-hero-text { min-width: 0; }
.forecast-detail-hero h3 { margin: 0; font-size: 20px; font-weight: 700; }
.forecast-detail-hero p { margin: 4px 0 0; font-size: 14px; color: var(--text-dim); }
.forecast-detail-hero-amt { font-size: 22px; font-weight: 700; white-space: nowrap; }
.forecast-detail-section-label {
  display: flex; justify-content: space-between; font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim); margin: 12px 0 6px;
}
.forecast-detail-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 0;
  border-bottom: 1px solid var(--sep); align-items: start;
}
.forecast-detail-row:last-child { border-bottom: none; }
.forecast-detail-row-name { font-size: 16px; font-weight: 600; margin: 0; }
.forecast-detail-row-sub { font-size: 13px; color: var(--text-dim); margin: 2px 0 0; }
.forecast-detail-row-amt { font-size: 16px; font-weight: 600; text-align: right; white-space: nowrap; }
.forecast-detail-row-date { font-size: 13px; color: var(--text-dim); text-align: right; }
.forecast-oneoff-toggle { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.forecast-oneoff-toggle span { font-size: 12px; color: var(--text-dim); }
.forecast-detail-note { font-size: 12px; color: var(--text-dim); display: flex; gap: 8px; margin: 12px 0 0; line-height: 1.4; }
.forecast-up-sub.is-muted { font-style: italic; }
.forecast-balance-row {
  margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--sep);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.forecast-balance-label { font-size: 14px; color: var(--text-dim); margin: 0 0 4px; white-space: nowrap; }
.forecast-balance-val { font-size: 28px; font-weight: 700; margin: 0; letter-spacing: -0.02em; white-space: nowrap; }
.forecast-balance-card { padding: var(--sp-4); margin-bottom: var(--sp-3); }
.forecast-balance-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.forecast-balance-card-title { font-size: 15px; font-weight: 700; margin: 0; line-height: 1.2; }
.forecast-balance-card-header { align-items: center; }
.forecast-balance-card-range { font-size: 13px; color: var(--text-dim); margin: 2px 0 0; }
.forecast-flow-summary { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.forecast-flow-today { font-size: 14px; color: var(--text-secondary); margin: 0; }
.forecast-flow-net { font-size: 22px; font-weight: 700; margin: 0; white-space: nowrap; }
.forecast-flow-net.is-neg { color: #F87171; }
.forecast-flow-net.is-pos { color: var(--success); }
.forecast-flow-bars { margin-bottom: 14px; }
.forecast-bar-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.forecast-bar-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-dim); }
.forecast-bar-track {
  height: 8px; border-radius: 999px; background: var(--raised); overflow: hidden;
  display: flex;
}
.forecast-bar-track.is-in-empty {
  border: 1.5px dashed rgba(245, 165, 36, 0.55); background: transparent;
}
.forecast-bar-seg { height: 100%; }
.forecast-bar-seg--income { background: var(--success); }
.forecast-bar-seg--bills { background: #cc5de8; }
.forecast-bar-seg--card { background: #748FFC; }
.forecast-bar-seg--daily { background: #ff922b; }
.forecast-bar-amt { font-size: 12px; font-weight: 600; color: var(--text-dim); white-space: nowrap; }
.forecast-breakdown-list { border-top: 1px solid var(--sep); }
.forecast-bd-row {
  display: grid; grid-template-columns: 40px 1fr auto 16px; gap: 10px; align-items: center;
  width: 100%; border: none; background: transparent; text-align: left; padding: 12px 0;
  border-bottom: 1px solid var(--sep); color: inherit; font: inherit; cursor: pointer;
}
.forecast-bd-row:last-child { border-bottom: none; }
.forecast-bd-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.forecast-bd-title { font-size: 16px; font-weight: 600; margin: 0; }
.forecast-bd-text { min-width: 0; }
.forecast-bd-sub {
  font-size: 13px; color: var(--text-dim); margin: 2px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.forecast-bd-amt.is-zero { color: var(--text-secondary); font-weight: 600; }
.forecast-bd-amt.is-in.is-zero { color: var(--text-secondary); }
.forecast-bd-amt { font-size: 16px; font-weight: 600; text-align: right; white-space: nowrap; }
.forecast-bd-amt.is-in { color: var(--success); }
.forecast-bd-chev { color: var(--text-dim); font-size: 18px; line-height: 1; }
.forecast-breakdown-total {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 0 4px;
  border-top: 1px solid var(--sep); font-size: 15px; font-weight: 700;
}
.forecast-no-income-notice {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 12px;
  border-radius: var(--radius-input); background: rgba(245, 165, 36, 0.12); font-size: 13px; color: var(--text-secondary);
}
.forecast-no-income-notice strong { color: var(--text); }
.forecast-import-link { margin-left: auto; font-size: 14px; flex-shrink: 0; }
.forecast-update-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border-radius: 999px; border: none; background: rgba(91, 140, 255, 0.18); color: var(--accent);
  font-size: 15px; font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.forecast-chart-card { padding: var(--sp-4); margin-bottom: var(--sp-3); }
.forecast-chart-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.forecast-chart-title { font-size: 17px; font-weight: 700; margin: 0; }
.forecast-chart-sub { font-size: 13px; color: var(--text-dim); margin: 2px 0 0; white-space: nowrap; }
.forecast-range-toggle {
  display: flex; background: var(--raised); border-radius: 8px; padding: 2px; flex-shrink: 0;
}
.forecast-range-btn {
  border: none; background: transparent; color: var(--text-dim); font-size: 12px; font-weight: 600;
  padding: 5px 7px; border-radius: 6px; min-width: 34px;
}
.forecast-range-btn[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.forecast-chart-wrap { position: relative; margin: 0 -4px; opacity: 1; transition: opacity 0.2s ease; }
.forecast-chart-wrap.is-loading { opacity: 0.35; }
.forecast-chart-canvas { width: 100%; height: auto; display: block; }
.forecast-chart-note {
  display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--text-dim);
  margin: 10px 0 0; line-height: 1.35;
}
.forecast-note-icon { flex-shrink: 0; opacity: 0.75; margin-top: 1px; }
.forecast-upcoming { margin-bottom: var(--sp-4); }
.forecast-upcoming-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 var(--sp-1) var(--sp-2); gap: 8px;
}
.forecast-upcoming-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
  white-space: nowrap;
}
.forecast-upcoming-window { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.forecast-upcoming-list { padding: 0; overflow: hidden; }
.forecast-up-row {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: start;
  padding: 12px var(--sp-4); border-bottom: 1px solid var(--sep);
  width: 100%; text-align: left; border-left: none; border-right: none; border-top: none;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.forecast-up-row:last-child { border-bottom: none; }
.forecast-up-row--major {
  background: rgba(91, 140, 255, 0.06);
  padding-top: 14px; padding-bottom: 14px;
}
.forecast-up-row--major .forecast-up-title { font-size: 17px; }
.forecast-up-row--major .forecast-up-amt { font-size: 17px; }
.forecast-schedule-list { margin-top: 8px; }
.forecast-schedule-row { padding: 10px 0; border-bottom: 1px solid var(--sep); }
.forecast-schedule-row:last-child { border-bottom: none; }
.forecast-schedule-name { font-size: 15px; font-weight: 600; }
.forecast-schedule-detail { font-size: 13px; color: var(--text-dim); margin-top: 4px; line-height: 1.35; }
.forecast-up-icon {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.forecast-up-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.forecast-up-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.forecast-up-amt-col { text-align: right; min-width: 88px; }
.forecast-up-amt { font-size: 16px; font-weight: 600; white-space: nowrap; }
.forecast-up-amt.is-in { color: var(--success); }
.forecast-up-amt.is-xfer { color: var(--text-secondary); }
.forecast-up-run { font-size: 12px; color: var(--text-dim); margin-top: 2px; white-space: nowrap; }
.forecast-cushion-chip {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(245, 165, 36, 0.22); color: #9A4508;
  white-space: nowrap;
}
.forecast-empty { padding: var(--sp-5); text-align: center; margin: var(--sp-3) 0; }
.forecast-empty-title { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.forecast-empty-text { color: var(--text-dim); margin: 0 0 var(--sp-4); }

.balance-sheet-modal {
  display: flex;
  flex-direction: column;
  max-height: min(92dvh, 92vh);
  padding-bottom: 0;
  box-sizing: border-box;
}
.balance-sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.balance-sheet-actions {
  flex-shrink: 0;
  padding: var(--sp-3) 0 calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--sep);
}
.balance-input-error {
  margin: calc(-1 * var(--sp-2)) 0 var(--sp-3);
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}
.balance-sheet-header { display: flex; justify-content: space-between; align-items: center; padding: 0 0 var(--sp-3); }
.balance-sheet-header h3 { margin: 0; font-size: 20px; font-weight: 700; }
.balance-sheet-close {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--raised);
  color: var(--text); font-size: 16px;
}
.balance-sheet-account { display: flex; align-items: center; gap: 10px; padding: 0 0 var(--sp-3); }
.balance-input-wrap {
  display: block; margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--accent); border-radius: var(--radius-input);
}
.balance-input-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
#balanceAmountInput {
  width: 100%; border: none; background: transparent; font-size: 32px; font-weight: 700;
  color: var(--text); padding: 0; font-family: inherit; letter-spacing: -0.02em;
}
.balance-asof-row { margin: 0 0 var(--sp-3); width: 100%; box-sizing: border-box; }
.balance-info-callout {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 var(--sp-3);
  padding: var(--sp-3); border-radius: var(--radius-input); background: var(--raised); font-size: 14px; color: var(--text-secondary);
}
.balance-sheet-foot { font-size: 12px; color: var(--text-dim); padding: 0 0 var(--sp-3); margin: 0; }
#balanceSheet .save-btn {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}

.other-transfer-sheet { padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px)); }
.other-transfer-hero { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; padding: var(--sp-4); align-items: start; }
.other-transfer-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--raised);
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.other-transfer-title { font-size: 20px; font-weight: 700; margin: 0; }
.other-transfer-sub { font-size: 14px; color: var(--text-dim); margin-top: 4px; }
.other-transfer-amt { font-size: 22px; font-weight: 700; white-space: nowrap; }
.other-transfer-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 var(--sp-4) var(--sp-3);
  padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(52, 199, 123, 0.15); color: var(--success);
}
.other-transfer-toggle-card {
  margin: 0 var(--sp-4) var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-input); background: var(--raised);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.other-transfer-toggle-card p { margin: 0; font-size: 15px; font-weight: 600; }
.other-transfer-toggle-card span { display: block; font-size: 13px; color: var(--text-dim); font-weight: 400; margin-top: 2px; }
.other-transfer-foot {
  display: flex; gap: 8px; font-size: 12px; color: var(--text-dim); padding: 0 var(--sp-4) var(--sp-4); margin: 0;
}
.settings-account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--sp-4); border-bottom: 1px solid var(--sep);
}
.settings-account-row:last-child { border-bottom: none; }
.settings-account-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.settings-account-name { font-size: 16px; font-weight: 600; }
.settings-account-sub { font-size: 13px; color: var(--text-dim); }
.settings-account-action {
  font-size: 15px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  border: none;
  background: none;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  margin: -10px -12px -10px 0;
  cursor: pointer;
}
.settings-row .link-btn {
  min-width: 44px;
  padding-left: 12px;
  padding-right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.import-other-tag {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  padding: 2px 6px; border-radius: 4px; background: var(--raised); margin-left: 6px;
}

@media (prefers-color-scheme: dark) {
  .forecast-cushion-chip { color: #FCD34D; }
  .forecast-cushion-chip.is-critical { color: #FCA5A5; background: rgba(248, 113, 113, 0.22); }
}

@media (prefers-color-scheme: light) {
  .forecast-nav { background: color-mix(in srgb, var(--bg) 90%, transparent); }
  .forecast-range-btn[aria-pressed="true"] { background: #fff; }
  .forecast-cushion-chip { color: #9A4508; }
  .forecast-cushion-chip.is-critical { color: #B91C1C; background: rgba(185, 28, 28, 0.12); }
  .forecast-up-row--summary { background: color-mix(in srgb, #ff922b 10%, #fff); }
  .forecast-no-income-notice { background: rgba(245, 165, 36, 0.16); }
  .forecast-flow-net.is-neg { color: #dc2626; }
  .forecast-nav-meta-val.is-neg { color: #dc2626; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .modal { transition: opacity 0.1s ease; transform: none; }
  .modal-overlay.show .modal { transform: none; }
  .hero-budget-fill { transition: none; }
}

/* Chase card balance owed (1.8.0) */
.modal-overlay.sheet-fade.show .modal {
  transform: none;
  opacity: 1;
}
.modal-overlay.sheet-fade:not(.show) .modal {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}
.modal-overlay.sheet-fade {
  transition: none;
}
#chaseCardSheet.modal-overlay.modal-front,
#chaseBalanceSheet.modal-overlay.modal-front {
  z-index: 5300;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.settings-account-row-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 12px var(--sp-4);
  margin: 0;
  border-top: 1px solid var(--sep);
}
.settings-accounts-foot {
  margin: 0;
  padding: 10px var(--sp-4) 12px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  border-top: 1px solid var(--sep);
}
#chaseBalanceSheet {
  isolation: isolate;
}
#chaseBalanceSheet .import-review-discard-scrim {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: rgba(0, 0, 0, 0.62);
  box-sizing: border-box;
}
@media (prefers-color-scheme: light) {
  #chaseBalanceSheet .import-review-discard-scrim {
    background: rgba(0, 0, 0, 0.72);
  }
}
#chaseBalanceSheet .import-review-discard-scrim.show {
  display: flex;
}
#chaseBalanceSheet .import-discard-card {
  width: 100%;
  max-width: 340px;
  background-color: var(--card);
  color: var(--text);
  opacity: 1;
  border-radius: var(--radius-card);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.chase-balance-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: var(--sp-4);
  min-height: 44px;
}
.chase-balance-topbar-title {
  flex: 1 1 auto;
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  white-space: nowrap;
}
.chase-balance-topbar-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--link);
  font-size: 17px;
  line-height: 22px;
  cursor: pointer;
}
.chase-balance-topbar-save { font-weight: 600; }
#chaseBalanceAmountInput {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 34px;
  font-weight: 700;
  line-height: 41px;
  letter-spacing: 0.4px;
  color: var(--text);
  padding: 0;
  font-family: inherit;
}
.chase-balance-input-wrap {
  margin-top: var(--sp-2);
}
.settings-account-owed {
  text-align: right;
  flex-shrink: 0;
  min-width: 88px;
}
.settings-account-owed-amt {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  display: block;
}
.settings-account-owed-label {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  display: block;
}
.settings-account-row-btn .chevron {
  margin-left: 6px;
  color: var(--text-dim);
  font-size: 18px;
}
.chase-card-sheet-modal,
.chase-balance-sheet-modal {
  max-height: calc(100vh - 57px);
  display: flex;
  flex-direction: column;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--card);
}
.chase-card-sheet-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 44px var(--sp-3);
  flex-shrink: 0;
}
.chase-card-sheet-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
}
.sheet-icon-close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--raised);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chase-card-sheet-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 0 var(--sp-2);
}
.chase-card-hero {
  background: var(--raised);
  border-radius: 16px;
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  position: relative;
}
.chase-card-hero-label {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  margin: 0 0 4px;
}
.chase-card-hero-amt {
  font-size: 34px;
  font-weight: 700;
  line-height: 41px;
  letter-spacing: 0.4px;
  margin: 0 0 4px;
}
.chase-card-hero-asof {
  font-size: 15px;
  line-height: 20px;
  color: var(--text-dim);
  margin: 0;
}
.chase-card-set-btn {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  min-height: 44px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: var(--link);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.chase-card-math {
  display: grid;
  gap: 8px;
  margin-bottom: var(--sp-4);
  font-size: 15px;
  line-height: 20px;
}
.chase-card-math-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
}
.chase-card-math-row.is-credit span:last-child { color: var(--success); }
.chase-card-section-label {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--sp-3) 0 var(--sp-2);
}
.chase-card-row-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 0;
  border-bottom: 1px solid var(--sep);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  min-height: 44px;
}
.chase-card-row-btn:last-child { border-bottom: none; }
.chase-card-row-main { flex: 1; min-width: 0; }
.chase-card-row-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  margin: 0;
}
.chase-card-row-sub {
  font-size: 15px;
  line-height: 20px;
  color: var(--text-dim);
  margin: 2px 0 0;
}
.chase-card-row-amt {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  white-space: nowrap;
}
.chase-card-row-amt.is-credit { color: var(--success); }
.chase-card-row-amt.is-forecast { color: var(--text-dim); }
.chase-card-all-link {
  font-size: 17px;
  font-weight: 600;
  color: var(--link);
  background: none;
  border: none;
  padding: 10px 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  min-height: 44px;
}
.chase-neutral-tag {
  display: inline-block;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  background: var(--raised);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 4px;
}
.chase-card-sheet-foot {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  text-align: center;
  margin: var(--sp-3) 0 0;
  flex-shrink: 0;
}
.chase-balance-sheet-scroll { padding-bottom: var(--sp-2); }
.chase-balance-input-wrap { margin-top: var(--sp-2); }
.chase-balance-change-line {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  margin: var(--sp-2) 0 0;
}
.chase-balance-change-line strong {
  color: var(--text);
  font-weight: 600;
}
.chase-balance-callout {
  margin-top: var(--sp-4);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--raised);
  border-radius: 12px;
  padding: var(--sp-3);
}
.chase-balance-callout p {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
}
.balance-info-icon { flex-shrink: 0; color: var(--link); margin-top: 1px; }
.forecast-up-not-spending-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-dim);
  background: var(--raised);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 4px;
}
@media (prefers-color-scheme: light) {
  .chase-card-set-btn { color: #fff; }
}

/* —— 1.9.0 edit / import / forecast QoL —— */
.edit-cats.cats { margin: 0 0 var(--sp-2); }
.edit-category-meta { margin-top: 6px; }
.edit-type-info.callout-info {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  margin-top: 10px;
  border-radius: var(--radius-input);
  background: color-mix(in srgb, var(--link) 12%, var(--raised));
  font-size: 15px;
  line-height: 1.35;
}
.edit-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  min-height: 44px;
  padding: 8px 0;
}
.edit-remember-title { display: block; font-size: 17px; color: var(--text); }
.edit-remember-sub { display: block; font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.bulk-recat-prompt {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin: 8px var(--sp-3) 12px;
  padding: 14px;
  border-radius: var(--radius-card);
  border: 1px solid color-mix(in srgb, var(--link) 35%, var(--sep));
  background: var(--card);
}
.bulk-recat-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}
.bulk-recat-icon { color: var(--link); flex-shrink: 0; }
.bulk-recat-copy { flex: 1; min-width: 0; width: 100%; }
.bulk-recat-title { font-size: 17px; font-weight: 600; margin: 0 0 4px; line-height: 1.35; }
.bulk-recat-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
  margin-left: 0;
}
.bulk-recat-actions .btn-secondary,
.bulk-recat-actions .save-btn { min-height: 44px; min-width: 44px; padding: 10px 16px; }
.import-review-toolbar { padding: 0 var(--sp-3) var(--sp-2); }
.import-file-meta { font-size: 13px; color: var(--text-dim); margin: 0 0 8px; }
.import-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.import-filter-chip {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: var(--raised);
  color: var(--text-secondary);
  font-size: 15px;
}
.import-filter-chip.is-active { background: var(--text); color: var(--bg); }
.import-filter-count { font-variant-numeric: tabular-nums; margin-left: 4px; }
.import-row--compact { padding: 0; overflow: hidden; }
.import-row-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px var(--sp-3);
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
}
.import-row-merchant { display: block; font-weight: 600; font-size: 15px; line-height: 1.25; }
.import-row-meta { display: block; font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.import-row-chevron { color: var(--text-dim); font-size: 18px; flex-shrink: 0; }
.import-row-expanded { padding: 0 var(--sp-3) 12px; }
.import-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.import-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--sep);
  background: var(--card);
  font-size: 15px;
}
.import-cat-chip.is-selected { border-color: var(--link); box-shadow: 0 0 0 1px var(--link); }
.import-apply-prompt {
  margin: 0 var(--sp-3) 12px;
  padding: 12px;
  border-radius: var(--radius-input);
  background: color-mix(in srgb, var(--link) 10%, var(--raised));
}
.import-apply-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.import-apply-actions .btn-secondary,
.import-apply-actions .save-btn { min-height: 44px; }
.import-balance-offer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin: 0 var(--sp-3) 12px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--success) 10%, var(--raised));
}
.import-balance-offer-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
}
.import-balance-offer.is-on { outline: 1px solid color-mix(in srgb, var(--link) 40%, transparent); }
.import-balance-offer-main { flex: 1; min-width: 0; }
.import-balance-offer-title { margin: 0 0 4px; font-size: 15px; line-height: 1.35; }
.import-balance-foot { font-size: 11px; color: var(--text-dim); margin: 8px 0 0; }
.import-balance-use {
  min-height: 44px;
  height: 44px;
  padding: 0 20px;
  align-self: flex-end;
  flex-shrink: 0;
  width: auto;
  max-width: 120px;
}
.import-balance-offer.is-on .import-balance-use {
  font-weight: 600;
}
.forecast-edited-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--raised);
  border-radius: 6px;
  padding: 2px 6px;
  vertical-align: middle;
}
.forecast-edit-hero {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 var(--sp-3) 12px;
  padding: 12px;
  border-radius: var(--radius-input);
  background: color-mix(in srgb, var(--link) 10%, var(--raised));
}
.forecast-edit-hero-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.forecast-edit-hero-label { font-weight: 600; font-size: 17px; }
.forecast-reset-btn { min-height: 44px; flex-shrink: 0; }
.forecast-apply-seg { width: 100%; }
.forecast-skip-btn {
  width: calc(100% - var(--sp-3) * 2);
  margin: 8px var(--sp-3) 16px;
  min-height: 48px;
  color: var(--link);
  background: color-mix(in srgb, var(--link) 8%, var(--raised));
}
@media (prefers-color-scheme: light) {
  .import-filter-chip.is-active { background: #1c1c1e; color: #fff; }
  .edit-type-info.callout-info { background: #eef3fc; }
  .bulk-recat-prompt { border-color: #c8d8f5; }
  .import-balance-offer { background: #eef8f3; }
}

@media print {
  body { background: #fff; color: #000; }
  .bottom-tab-bar, .undo-toast, .toast, .modal-overlay, .splash-screen { display: none !important; }
  .app-main { padding: 0; }
  #tab-add, #tab-summary, #tab-history, #tab-settings { display: none !important; }
  #tab-report { display: block !important; }
  #reportMonthSwitcher, #reportExportPdfBtn, #openWrappedBtn, .no-print { display: none !important; }
  .card { border: 1px solid #ddd; break-inside: avoid; }
  .report-bar-track { fill: #eee; }
  .report-bar-outline { stroke: #333; }
  .report-avg-line { stroke: #666; }
  .report-bar-label, .report-avg-label { fill: #444; }
}
