:root {
  color-scheme: light dark;
  --canvas: #f2f2f7;
  --surface: rgba(255, 255, 255, .92);
  --surface-solid: #ffffff;
  --secondary: #f8f8fb;
  --raised: #e5e5ea;
  --ink: #17171a;
  --muted: #6f6f78;
  --subtle: #9a9aa2;
  --accent: #6f63e9;
  --accent-strong: #5a4ed7;
  --accent-soft: #ebe9ff;
  --positive: #208e67;
  --positive-soft: #e4f5ee;
  --warning: #c97a20;
  --warning-soft: #fff1df;
  --danger: #e24b53;
  --line: rgba(60, 60, 67, .12);
  --shadow: 0 10px 28px rgba(37, 37, 46, .055);
  --nav-height: 76px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000000;
    --surface: rgba(28, 28, 30, .94);
    --surface-solid: #1c1c1e;
    --secondary: #242426;
    --raised: #3a3a3c;
    --ink: #f5f5f7;
    --muted: #a2a2aa;
    --subtle: #74747c;
    --accent: #958cff;
    --accent-strong: #8076f4;
    --accent-soft: rgba(112, 99, 233, .2);
    --positive: #54d39d;
    --positive-soft: rgba(32, 142, 103, .22);
    --warning: #f1ad58;
    --warning-soft: rgba(201, 122, 32, .2);
    --danger: #ff7077;
    --line: rgba(84, 84, 88, .55);
    --shadow: 0 12px 34px rgba(0, 0, 0, .22);
  }
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-width: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { touch-action: manipulation; }
.ui-icon { display: block; width: 1em; height: 1em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 24px; text-align: center; }
.splash img { border-radius: 22px; box-shadow: var(--shadow); }
.splash h1 { margin: 10px 0 0; font-size: 32px; letter-spacing: -.8px; }
.splash p { max-width: 340px; margin: 0; color: var(--muted); line-height: 1.45; }
.spinner { width: 24px; height: 24px; margin-top: 18px; border: 3px solid var(--raised); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); background: radial-gradient(circle at 82% 7%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 34%), var(--canvas); }
.auth-card { width: min(100%, 430px); background: var(--surface-solid); padding: 26px; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.brand-lockup { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-lockup img { width: 60px; height: 60px; border-radius: 17px; }
.brand-lockup h1 { margin: 0; font-size: 29px; letter-spacing: -.7px; }
.brand-lockup p { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.auth-card h2 { margin: 0 0 8px; font-size: 22px; }
.auth-card > p { margin: 0 0 20px; color: var(--muted); line-height: 1.5; }
.auth-eyebrow { display: block; margin-bottom: 9px; color: var(--accent); font-size: 10px; letter-spacing: 1.5px; font-weight: 750; }
.auth-links { display: grid; gap: 12px; margin-top: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-link { border: 0; background: transparent; color: var(--accent); padding: 8px; min-height: 44px; font-size: 14px; cursor: pointer; }
.auth-link.subtle { color: var(--muted); font-size: 12px; }
.auth-divider { height: 1px; background: var(--line); margin: 1px 0 4px; }
.auth-card .field-hint { margin: -7px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.auth-note { margin: 17px 0; border-radius: 14px; padding: 13px 14px; background: color-mix(in srgb, var(--accent) 9%, var(--surface-solid)); color: var(--muted); font-size: 13px; line-height: 1.55; }
.recovery-codes { min-height: 218px; font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.9; white-space: pre; overflow: auto; }
.recovery-confirm { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink); font-size: 13px; line-height: 1.4; }
.recovery-confirm input { width: 20px; height: 20px; min-height: 20px; flex: 0 0 20px; accent-color: var(--accent); }
@media (max-width: 420px) { .auth-shell { padding-left: 16px; padding-right: 16px; } .auth-card { padding: 22px 20px; border-radius: 24px; } .brand-lockup { margin-bottom: 24px; } .recovery-codes { font-size: 11px; padding: 12px 10px; } }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span, .form-label { color: var(--muted); font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 50px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink); border-radius: 14px; padding: 13px 14px; outline: none; font-size: 16px; }
select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px); background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent); }
[hidden] { display: none !important; }
textarea { resize: vertical; min-height: 92px; }
.input-money { display: flex; align-items: center; gap: 8px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 14px; padding-left: 14px; }
.input-money:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 17%, transparent); }
.input-money strong { color: var(--accent); font-size: 20px; }
.input-money input { min-height: 50px; border: 0; background: transparent; box-shadow: none; }
.primary, .secondary, .danger-button, .icon-button, .chip, .text-button { border: 0; cursor: pointer; }
.primary { width: 100%; min-height: 52px; padding: 0 18px; border-radius: 15px; background: var(--accent); color: white; font-weight: 750; }
.primary:active, .secondary:active, .settings-button:active, .row-action:active { opacity: .72; }
.primary[disabled] { opacity: .55; cursor: wait; }
.secondary { min-height: 44px; padding: 0 16px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.add-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.add-button .ui-icon { width: 18px; height: 18px; }
.danger-button { min-height: 44px; padding: 0 16px; border-radius: 13px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 700; }
.text-button { background: transparent; color: var(--accent); font-weight: 680; padding: 8px 4px; }
.form-error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 14px; }

.app-shell { min-height: 100dvh; padding-bottom: calc(var(--nav-height) + 24px + env(safe-area-inset-bottom)); }
.page { width: min(100%, 820px); margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 18px 38px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 7px 0 22px; }
.page-title { margin: 0; font-size: clamp(32px, 8.2vw, 40px); line-height: 1.04; letter-spacing: -1.2px; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.app-mark { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.app-mark .ui-icon { width: 23px; height: 23px; }
.header-action { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(91, 79, 216, .28); cursor: pointer; }
.header-action .ui-icon { width: 23px; height: 23px; stroke-width: 2; }
.header-action:active { transform: scale(.94); }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.month-control { min-width: 0; display: grid; grid-template-columns: 40px minmax(130px, 1fr) 40px; align-items: center; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.month-control strong { min-width: 0; text-align: center; text-transform: capitalize; font-size: 14px; white-space: nowrap; }
.month-control button { width: 40px; height: 42px; display: grid; place-items: center; border: 0; background: transparent; color: var(--accent); cursor: pointer; }
.month-control .ui-icon { width: 18px; height: 18px; }
.today-button { min-height: 38px; flex: 0 0 auto; padding: 0 12px; border: 0; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; cursor: pointer; }
.today-button:disabled { opacity: 0; pointer-events: none; }

.budget-hero { position: relative; overflow: hidden; padding: 22px; border-radius: 28px; color: #fff; background: linear-gradient(145deg, #292447 0%, #5047b8 52%, #7368e8 100%); box-shadow: 0 18px 42px rgba(80, 71, 184, .22); }
.budget-hero::before { content: ""; position: absolute; width: 240px; height: 240px; right: -92px; top: -140px; border-radius: 50%; background: rgba(255, 255, 255, .11); }
.budget-hero::after { content: ""; position: absolute; width: 130px; height: 130px; left: -75px; bottom: -80px; border-radius: 50%; background: rgba(255, 255, 255, .06); }
.hero-top { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hero-label { font-size: 11px; font-weight: 780; letter-spacing: .9px; color: rgba(255, 255, 255, .73); }
.status-pill { padding: 6px 9px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; background: rgba(255, 255, 255, .13); font-size: 11px; font-weight: 720; }
.hero-amount { position: relative; z-index: 1; margin: 22px 0 3px; font-size: clamp(34px, 9.6vw, 48px); font-weight: 790; letter-spacing: -1.8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.hero-caption { position: relative; z-index: 1; color: rgba(255, 255, 255, .66); font-size: 13px; }
.progress-track { position: relative; z-index: 1; height: 7px; margin: 21px 0 8px; border-radius: 99px; background: rgba(255, 255, 255, .17); overflow: hidden; }
.progress-value { height: 100%; border-radius: inherit; background: #fff; }
.progress-meta { position: relative; z-index: 1; display: flex; justify-content: space-between; font-size: 11px; font-weight: 640; color: rgba(255, 255, 255, .72); }
.hero-metrics { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 21px; }
.hero-metric { min-width: 0; padding: 0 10px; border-left: 1px solid rgba(255, 255, 255, .15); }
.hero-metric:first-child { padding-left: 0; border-left: 0; }
.hero-metric span { display: block; color: rgba(255, 255, 255, .58); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-metric strong { display: block; margin-top: 4px; font-size: 13px; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.card { background: var(--surface-solid); border: 1px solid var(--line); border-radius: 22px; padding: 17px; box-shadow: var(--shadow); }
.card.full { grid-column: 1 / -1; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-header h2 { margin: 0; font-size: 19px; letter-spacing: -.38px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.metric-card { position: relative; min-height: 132px; overflow: hidden; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; }
.metric-label { min-width: 0; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; font-weight: 700; }
.metric-card > strong { display: block; margin-top: 12px; font-size: clamp(18px, 4.7vw, 24px); letter-spacing: -.65px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-card .page-subtitle { margin-top: 5px; font-size: 11px; }
.metric-icon { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border-radius: 11px; }
.metric-icon .ui-icon { width: 18px; height: 18px; }
.metric-card.positive .metric-icon { background: var(--positive-soft); color: var(--positive); }
.metric-card.warning .metric-icon { background: var(--warning-soft); color: var(--warning); }
.metric-card.positive > strong { color: var(--positive); }
.metric-card.warning > strong { color: var(--warning); }

.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut { width: 128px; height: 128px; flex: 0 0 auto; border-radius: 50%; position: relative; background: var(--raised); }
.donut::after { content: ""; position: absolute; inset: 21px; border-radius: 50%; background: var(--surface-solid); }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center span { color: var(--muted); font-size: 9px; font-weight: 760; letter-spacing: .6px; }
.donut-center strong { max-width: 84px; margin-top: 2px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.legend { flex: 1; min-width: 0; display: grid; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row strong { font-size: 12px; }
.category-chart-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.chart-recurring-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; border: 1px solid var(--line); border-radius: 12px; padding: 7px 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 650; cursor: pointer; }
.chart-recurring-toggle.excluded { background: var(--secondary); color: var(--muted); }
.chart-check { width: 20px; height: 20px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; flex: 0 0 20px; font-size: 12px; font-weight: 800; }
.category-chart-summary { display: flex; align-items: center; gap: 18px; margin: 8px 0 18px; }
.category-chart-caption { min-width: 0; display: grid; gap: 5px; }
.category-chart-caption > strong { font-size: 14px; }
.category-chart-caption > span { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.category-chart-caption > small { color: var(--muted); line-height: 1.5; font-size: 11px; }
.category-chart-legend { display: grid; }
.category-chart-item { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; min-height: 52px; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.category-chart-name { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.category-chart-value { flex: 0 0 auto; max-width: 48%; text-align: right; font-variant-numeric: tabular-nums; }
.category-chart-value strong { display: block; font-size: 12px; overflow-wrap: anywhere; }
.category-chart-value small { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); }
.category-chart-item.is-hidden { color: var(--muted); }
.category-chart-item.is-hidden .category-chart-name { text-decoration: line-through; }
.category-chart-item:focus-visible, .chart-recurring-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.category-chart-note, .chart-empty-note { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.chart-empty-note { margin-bottom: 12px; }

.rows { display: grid; min-width: 0; }
.row { width: 100%; min-width: 0; display: flex; align-items: center; gap: 11px; padding: 13px 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: inherit; text-align: left; }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row-action { width: 100%; display: flex; align-items: center; color: inherit; text-decoration: none; text-align: left; cursor: pointer; appearance: none; }
.row-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 13px; font-size: 18px; }
.ui-row-icon { background: var(--accent-soft); color: var(--accent); }
.ui-row-icon .ui-icon { width: 21px; height: 21px; }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; font-size: 14px; font-weight: 680; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.planned-chip { display: inline-flex; align-items: center; min-height: 18px; margin-left: 7px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-style: normal; font-weight: 720; vertical-align: 1px; }
.planned-expense-row .row-amount { color: var(--muted); }
.row-amount { flex: 0 0 auto; max-width: 40%; font-size: 14px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.row-chevron, .chevron { flex: 0 0 auto; color: var(--subtle); }
.row-chevron .ui-icon, .chevron .ui-icon { width: 15px; height: 15px; stroke-width: 2.2; }
.empty { text-align: center; padding: 25px 12px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-size: 24px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 390px; margin: 0 auto 15px; line-height: 1.45; font-size: 13px; }

.search { min-height: 48px; display: flex; align-items: center; gap: 9px; margin-bottom: 14px; padding: 0 14px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }
.search > span { color: var(--muted); }
.search .ui-icon { width: 19px; height: 19px; }
.search input { min-height: 46px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.summary-strip { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 14px; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.summary-strip > div { min-width: 0; }
.summary-strip small { display: block; color: var(--muted); font-size: 11px; }
.summary-strip strong { display: block; margin-top: 2px; font-size: 20px; letter-spacing: -.35px; white-space: nowrap; }
.summary-count { margin-left: auto; padding: 5px 8px; border-radius: 999px; background: var(--secondary); color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.savings-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 7px 0 16px; padding: 3px; border-radius: 13px; background: var(--raised); }
.savings-option { position: relative; cursor: pointer; }
.savings-option input { position: absolute; width: 1px; min-height: 1px; opacity: 0; pointer-events: none; }
.savings-option span { min-height: 38px; display: grid; place-items: center; padding: 0 12px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 680; transition: background .16s ease, color .16s ease, box-shadow .16s ease; }
.savings-option input:checked + span { background: var(--surface-solid); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.savings-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.forecast-note { display: flex; align-items: flex-start; gap: 8px; margin: -2px 4px 14px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.forecast-note .ui-icon { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; color: var(--accent); }
.day-section { margin-bottom: 12px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.day-head strong { min-width: 0; font-size: 14px; text-transform: capitalize; }
.day-head span { flex: 0 0 auto; color: var(--muted); font-size: 13px; font-weight: 680; }

.commitment { position: relative; overflow: hidden; display: flex; align-items: center; gap: 15px; padding: 20px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 24px; background: linear-gradient(145deg, var(--accent-soft), color-mix(in srgb, var(--surface-solid) 78%, var(--accent-soft))); }
.commitment::after { content: ""; position: absolute; width: 130px; height: 130px; right: -60px; top: -70px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.commitment-icon { width: 52px; height: 52px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 17px; background: var(--accent); color: #fff; }
.commitment-icon .ui-icon { width: 25px; height: 25px; }
.commitment span { color: var(--muted); font-size: 11px; }
.commitment strong { display: block; margin: 4px 0; font-size: 27px; letter-spacing: -.7px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin: 24px 4px 11px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.4px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-heading > span { min-width: 27px; height: 27px; display: grid; place-items: center; border-radius: 999px; background: var(--raised); color: var(--muted); font-size: 12px; font-weight: 700; }
.planned-list { padding-top: 2px; padding-bottom: 2px; }
.planned-item { border-top: 1px solid var(--line); }
.planned-item:first-child { border-top: 0; }
.planned-item .row { padding: 15px 0 10px; border-top: 0; }
.planned-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-left: 53px; padding: 0 0 12px; }
.tag { display: inline-flex; align-items: center; min-height: 25px; padding: 0 8px; border-radius: 999px; background: var(--secondary); color: var(--muted); font-size: 10px; font-weight: 680; }
.toggle { position: relative; width: 48px; height: 29px; flex: 0 0 auto; border: 0; border-radius: 999px; background: var(--raised); cursor: pointer; }
.toggle::after { content: ""; position: absolute; width: 23px; height: 23px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); transition: transform .18s ease; }
.toggle.on { background: var(--positive); }
.toggle.on::after { transform: translateX(19px); }

.settings-section { margin-bottom: 20px; }
.settings-section > h2 { margin: 0 0 8px 4px; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .45px; }
.settings-group { overflow: hidden; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.settings-button { width: 100%; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.settings-button:first-child { border-top: 0; }
.settings-button .row-main span { white-space: normal; line-height: 1.3; }
.settings-button .row-icon { width: 38px; height: 38px; border-radius: 12px; }
.logout-button { margin-top: 6px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-solid); box-shadow: var(--shadow); }
.logout-button .row-icon, .logout-button strong { color: var(--danger); }
.management-list { margin-top: 15px; }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(100%, 820px); transform: translateX(-50%); display: grid; grid-template-columns: repeat(5, 1fr); min-height: calc(var(--nav-height) + env(safe-area-inset-bottom)); padding: 7px 10px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-solid) 86%, transparent); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%); }
.nav-item { min-height: 56px; display: grid; align-content: center; justify-items: center; gap: 4px; border: 0; border-radius: 13px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10px; font-weight: 590; }
.nav-icon { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; }
.nav-icon .ui-icon { width: 22px; height: 22px; stroke-width: 1.8; }
.nav-item.active { color: var(--accent); font-weight: 700; }
.nav-item.active .nav-icon { background: var(--accent-soft); }
.fab { position: fixed; z-index: 22; right: max(18px, calc((100vw - 820px) / 2 + 18px)); bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom)); width: 56px; height: 56px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 13px 28px rgba(91, 79, 216, .38); cursor: pointer; }
.fab .ui-icon { width: 25px; height: 25px; stroke-width: 2.1; }
.fab:active { transform: scale(.94); }

.modal { width: min(calc(100% - 24px), 590px); max-height: min(90dvh, 840px); padding: 0; border: 0; border-radius: 28px; background: var(--canvas); color: var(--ink); box-shadow: 0 30px 90px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(7, 7, 9, .46); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-form { display: grid; max-height: inherit; }
.modal-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; min-height: 64px; padding: 12px 18px 8px; background: color-mix(in srgb, var(--canvas) 90%, transparent); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.modal-head h2 { grid-column: 2; margin: 0; text-align: center; font-size: 17px; letter-spacing: -.2px; }
.sheet-grabber { position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; transform: translateX(-50%); border-radius: 999px; background: var(--raised); }
.close-button { grid-column: 3; width: 34px; height: 34px; justify-self: end; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--raised); color: var(--muted); cursor: pointer; }
.close-button .ui-icon { width: 17px; height: 17px; stroke-width: 2.2; }
.modal-body { overflow-y: auto; padding: 9px 18px 24px; -webkit-overflow-scrolling: touch; }
.modal-body > p { color: var(--muted); line-height: 1.48; }
.modal-actions { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 10px; padding: 12px 18px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-solid) 88%, transparent); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); }
.modal-actions .primary { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 12px 0; border-top: 1px solid var(--line); }
.check-row span { line-height: 1.32; }
.check-row small { color: var(--muted); }
.check-row input[type="checkbox"] { appearance: none; width: 48px; min-width: 48px; height: 29px; min-height: 29px; padding: 0; border: 0; border-radius: 999px; background-color: var(--raised); background-image: radial-gradient(circle, #fff 0 11px, transparent 12px); background-position: 3px 3px; background-size: 23px 23px; background-repeat: no-repeat; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .03), 0 1px 2px rgba(0, 0, 0, .06); transition: background-position .18s ease, background-color .18s ease; }
.check-row input[type="checkbox"]:checked { background-color: var(--positive); background-position: 22px 3px; }
.color-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 7px 0 18px; }
.color-radio { width: 34px; height: 34px; border: 3px solid var(--canvas); border-radius: 50%; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.color-radio.selected { box-shadow: 0 0 0 3px var(--accent); }

.toast { position: fixed; z-index: 100; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(calc(100% - 32px), 460px); padding: 13px 16px; border-radius: 15px; background: #27272c; color: #fff; box-shadow: 0 12px 35px rgba(0, 0, 0, .25); text-align: center; font-size: 13px; font-weight: 650; }
.offline-banner { position: fixed; z-index: 101; top: 0; left: 0; right: 0; padding: max(7px, env(safe-area-inset-top)) 14px 7px; background: var(--warning); color: #1a1308; text-align: center; font-size: 12px; font-weight: 720; }
.offline-banner:not([hidden]) + #app .page { padding-top: calc(42px + env(safe-area-inset-top)); }
.offline-banner:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: max(9px, env(safe-area-inset-top)) 14px 9px; }
.offline-banner > span { min-width: 0; }
.offline-banner strong { display: block; font-size: 12px; }
.offline-banner small { display: block; margin-top: 3px; font-size: 10px; line-height: 1.4; }
.offline-banner button { flex: 0 0 auto; border: 0; border-radius: 10px; background: #1a130819; color: inherit; min-height: 36px; padding: 0 10px; font-size: 11px; font-weight: 700; cursor: pointer; }
.offline-banner:not([hidden]) + #app .page { padding-top: calc(86px + env(safe-area-inset-top)); }
.offline-banner:not([hidden]) ~ .toast { top: calc(78px + env(safe-area-inset-top)); }

@media (max-width: 610px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid > .card:not(.metric-card) { grid-column: 1 / -1; }
  .hero-metrics { margin-left: -3px; margin-right: -3px; }
  .hero-metric { padding: 0 7px; }
  .donut-wrap { align-items: center; gap: 16px; }
  .donut { width: 116px; height: 116px; }
  .donut::after { inset: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .row-amount { max-width: 34%; }
}

@media (max-width: 640px) {
  .modal { width: 100%; max-width: none; max-height: calc(100dvh - max(10px, env(safe-area-inset-top))); margin: auto 0 0; border-radius: 30px 30px 0 0; }
  .modal[open] { animation: sheet-up .22s ease-out; }
  .modal-form { max-height: calc(100dvh - max(10px, env(safe-area-inset-top))); }
  @keyframes sheet-up { from { transform: translateY(18px); opacity: .7; } }
}

@media (max-width: 374px) {
  .page { padding-left: 13px; padding-right: 13px; }
  .page-title { font-size: 30px; }
  .budget-hero { padding: 19px; }
  .hero-amount { font-size: 32px; }
  .month-control { grid-template-columns: 36px minmax(118px, 1fr) 36px; }
  .month-control button { width: 36px; }
  .today-button { padding: 0 9px; }
  .donut-wrap { align-items: flex-start; }
  .donut { width: 104px; height: 104px; }
  .row-icon { width: 39px; height: 39px; }
}

@media (display-mode: standalone) {
  body { user-select: none; }
  input, textarea { user-select: text; }
}

.view-segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px; background: var(--raised); border-radius: 13px; margin-bottom: 18px; }
.view-segmented button { min-height: 39px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 650; cursor: pointer; }
.view-segmented button.selected { background: var(--surface-solid); color: var(--ink); box-shadow: 0 1px 4px #0002; }
.period-presets { display: flex; gap: 7px; margin: 0 0 16px; }
.period-presets button { flex: 1; min-height: 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-solid); color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; }
.period-presets button.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.insight-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 14px; margin-bottom: 16px; }
.insight-controls .field { min-width: 0; margin: 0; }
.insight-controls input, .insight-controls select { display: block; width: 100%; min-width: 0; max-width: 100%; height: 52px; min-height: 52px; margin: 0; }
.insight-controls input[type="month"] { appearance: none; -webkit-appearance: none; min-inline-size: 0; padding: 13px 14px; text-align: left; overflow: hidden; }
.insight-controls input::-webkit-date-and-time-value { min-width: 0; min-height: 24px; text-align: left; }
.insight-controls input::-webkit-datetime-edit { min-width: 0; padding: 0; }
.insight-period { color: var(--muted); font-size: 13px; margin: 0 0 12px; text-transform: capitalize; }
.insight-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.insight-metric { min-width: 0; padding: 16px; }
.insight-metric:last-child { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; background: var(--accent-soft); border-color: transparent; }
.insight-metric span { display: block; color: var(--muted); font-size: 12px; }
.insight-metric strong { display: block; font-size: clamp(17px, 4.7vw, 26px); font-variant-numeric: tabular-nums; letter-spacing: -.6px; margin-top: 7px; overflow-wrap: anywhere; }
.insight-metric:last-child strong { margin: 0; }
.insight-metric.positive strong, .income-text { color: var(--positive); }
.insight-metric.negative strong, .negative-text { color: var(--danger); }
.insight-note { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 12px 0; }
.scope-note { margin: 14px 2px; }
.insight-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 14px 0 16px; }
.insight-actions .secondary { font-size: 13px; }
.insight-alert { display: flex; align-items: flex-start; gap: 10px; padding: 14px; margin: 14px 0; border-radius: 16px; background: var(--warning-soft); color: var(--warning); font-size: 12px; line-height: 1.5; }
.insight-alert strong { display: block; }
.insight-alert .ui-icon { width: 20px; height: 20px; flex: 0 0 auto; }
.insight-alert.neutral { background: var(--accent-soft); color: var(--accent); }
.insight-section { margin-top: 16px; }
.insight-section h2 { font-size: 18px; }
.trend-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: 11px; color: var(--muted); }
.trend-legend > span { display: flex; align-items: center; gap: 5px; }
.trend-legend i { width: 8px; height: 8px; display: inline-block; border-radius: 3px; }
.income-dot, .income-bar { background: var(--positive); }
.expense-dot, .expense-bar { background: var(--accent); }
.trend-legend small { margin-left: auto; font-size: 10px; }
.trend-scroll { min-width: 0; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; padding: 16px 0 0; }
.trend-chart { display: grid; grid-template-columns: repeat(var(--month-count), minmax(44px, 1fr)); gap: 9px; min-width: calc(var(--month-count) * 53px); }
.trend-month { border: 0; padding: 0; background: transparent; color: var(--muted); cursor: pointer; min-width: 0; }
.trend-month:focus-visible, .breakdown-row:focus-visible, .month-budget-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.trend-bars { height: 150px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%); }
.trend-bars i { width: 12px; border-radius: 4px 4px 0 0; }
.trend-month-label { display: block; font-size: 10px; margin-top: 9px; white-space: nowrap; }
.breakdown-list { display: grid; gap: 17px; }
.breakdown-row { display: block; width: 100%; border: 0; padding: 0; background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
.breakdown-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 7px; font-size: 12px; }
.breakdown-title strong { font-weight: 650; }
.breakdown-title > span { font-variant-numeric: tabular-nums; }
.breakdown-title small { color: var(--muted); font-size: 11px; }
.breakdown-track { display: block; height: 6px; border-radius: 6px; background: var(--secondary); overflow: hidden; }
.breakdown-track i { display: block; height: 100%; background: var(--positive); border-radius: inherit; }
.savings-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 17px 0 4px; }
.savings-summary > div { min-width: 0; }
.savings-summary span { display: block; color: var(--muted); font-size: 11px; }
.savings-summary strong { display: block; margin-top: 6px; font-size: 19px; letter-spacing: -.5px; overflow-wrap: anywhere; }
.month-budget-row { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; color: var(--ink); text-align: left; border: 0; border-top: 1px solid var(--line); padding: 14px 0; cursor: pointer; }
.month-budget-row:first-child { padding-top: 0; border-top: 0; }
.month-budget-row:last-child { padding-bottom: 0; }
.month-budget-row > span { min-width: 0; flex: 1; }
.month-budget-row > span:nth-child(2) { text-align: right; }
.month-budget-row strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.month-budget-row small { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.month-budget-row .ui-icon { width: 14px; height: 14px; flex: 0 0 auto; color: var(--subtle); }
.detail-facts p { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: 13px; }
.detail-facts span { color: var(--muted); }
.income-plan-item { border-top: 1px solid var(--line); padding: 14px 0; }
.income-plan-item:first-child { border-top: 0; }
.income-plan-action { text-align: right; min-height: 30px; font-size: 12px; margin-top: 5px; }
@media (max-width: 480px) {
  .insight-controls { grid-template-columns: minmax(0, 1fr); }
  .page-insights .insight-section { min-width: 0; }
  .page-insights .month-budget-row { align-items: flex-start; }
  .page-insights .month-budget-row > span:first-child { flex: 1.2; }
}
@media (max-width: 374px) {
  .insight-metrics { grid-template-columns: minmax(0, 1fr); }
  .page-overview .grid > .metric-card { grid-column: 1 / -1; min-height: auto; }
  .insight-metric { padding: 15px; }
  .insight-metric strong { font-size: 22px; }
  .savings-summary { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .month-budget-row { flex-wrap: wrap; }
  .month-budget-row > span:first-child { flex-basis: calc(100% - 24px); }
  .month-budget-row > span:nth-child(2) { flex-basis: 100%; text-align: left; }
  .month-budget-row > .ui-icon { display: none; }
}
@media (min-width: 640px) {
  .insight-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-metric:last-child { grid-column: auto; display: block; }
  .insight-metric:last-child strong { margin-top: 7px; }
  .insight-breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
