:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --canvas: #f2f2f7;
  --paper: #ffffff;
  --elevated: #ffffff;
  --fill: #eeeef0;
  --ink: #1c1c1e;
  --muted: #6c6c70;
  --tertiary: #8e8e93;
  --line: #e5e5ea;
  --accent: #007aff;
  --accent-soft: #eaf3ff;
  --on-accent: #ffffff;
  --success: #248a3d;
  --warning: #b76800;
  --red: #c9342c;
  --bar: rgba(249, 249, 251, .9);
  --backdrop: rgba(0, 0, 0, .34);
  --shadow: 0 8px 24px rgba(0, 0, 0, .1);
  --green: var(--accent);
  --green-light: var(--accent-soft);
  --orange: var(--accent);
  --orange-pale: var(--accent-soft);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="dark"] {
  --canvas: #000000;
  --paper: #1c1c1e;
  --elevated: #2c2c2e;
  --fill: #2c2c2e;
  --ink: #f5f5f7;
  --muted: #a1a1a6;
  --tertiary: #8e8e93;
  --line: #38383a;
  --accent: #0a84ff;
  --accent-soft: #132c46;
  --success: #30d158;
  --warning: #ff9f0a;
  --red: #ff6961;
  --bar: rgba(22, 22, 24, .9);
  --backdrop: rgba(0, 0, 0, .64);
  --shadow: 0 8px 24px rgba(0, 0, 0, .32);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 15px; line-height: 1.4; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:active { opacity: .7; }
a { color: var(--accent); }
svg { pointer-events: none; }
.ui-icon { display: block; width: 22px; height: 22px; flex-shrink: 0; }
.app-shell { max-width: 480px; min-height: 100dvh; margin: auto; padding: env(safe-area-inset-top, 0px) 20px calc(170px + var(--safe-bottom)); }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand strong { font-size: 19px; letter-spacing: -.5px; font-weight: 650; }
.brand-mark { width: 30px; height: 30px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); display: grid; place-items: center; }
.brand-mark svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.header-actions { display: flex; gap: 2px; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: grid; place-items: center; }
.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { background: var(--fill); }
#main-view { outline: none; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 8px 0 22px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 400; letter-spacing: 0; }
.page-title { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -1px; margin: 5px 0 0; }
.month-picker { display: flex; align-items: center; gap: 0; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.month-picker button { display: grid; place-items: center; width: 32px; height: 44px; background: none; border: 0; color: var(--accent); }
.month-picker svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.card { border-radius: var(--radius); background: var(--paper); border: 0; box-shadow: none; }
.balance-card { padding: 24px 22px 20px; }
.balance-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.balance-label svg { display: none; }
.balance-value { font-size: clamp(30px, 9vw, 42px); font-weight: 650; letter-spacing: -1.6px; line-height: 1.15; margin: 10px 0 24px; overflow-wrap: anywhere; }
.balance-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.balance-stat { border-top: .5px solid var(--line); padding-top: 14px; min-width: 0; }
.balance-stat > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.balance-stat strong { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.balance-stat strong.income { color: var(--success); }
.balance-stat strong.income:before { content: "↗ "; }
.balance-stat strong.expense:before { content: "↘ "; color: var(--muted); }
.sensitive, .balance-value, .tx-amount, .budget-amount, .mini-stat strong { font-variant-numeric: tabular-nums; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 28px 2px 12px; }
.section-row h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.4px; }
.text-button { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 400; min-height: 36px; padding: 4px 0; white-space: nowrap; }
.allowance-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 20px; }
.allowance-copy h3 { margin: 5px 0; font-size: 26px; font-weight: 600; letter-spacing: -.7px; }
.allowance-copy p { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }
.ring { position: relative; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) var(--progress, 0%), var(--fill) 0); }
.ring:after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--paper); }
.ring span { z-index: 1; color: var(--ink); font-size: 12px; font-weight: 600; }
.budget-list { padding: 3px 16px; }
.budget-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) 44px; gap: 10px; align-items: center; border-bottom: .5px solid var(--line); padding: 14px 0; }
.budget-row:last-child, .transaction-row:last-child, .rank-row:last-child, .setting-row:last-child { border-bottom: 0; }
.category-icon, .tx-icon, .goal-emoji, .insight-icon, .empty-art { display: grid; place-items: center; background: var(--fill); color: var(--muted); border-radius: 11px; flex-shrink: 0; }
.category-icon { width: 34px; height: 34px; }
.category-icon .ui-icon { width: 20px; height: 20px; }
.budget-main { min-width: 0; }
.budget-topline { display: flex; justify-content: space-between; align-items: center; gap: 5px 8px; flex-wrap: wrap; }
.budget-topline strong { font-size: 13px; font-weight: 500; }
.budget-topline span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.progress-track { height: 4px; background: var(--fill); border-radius: 5px; overflow: hidden; margin-top: 9px; }
.progress-fill { height: 100%; border-radius: 5px; width: var(--width, 0%); background: var(--accent); }
.progress-fill.is-warm { background: var(--warning); }
.progress-fill.is-over { background: var(--red); }
.budget-amount { border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 400; padding: 0; min-height: 44px; text-align: right; }
.budget-amount span { display: none; }
.insight-card { display: flex; align-items: flex-start; gap: 12px; padding: 18px; }
.insight-icon { min-width: 32px; height: 32px; background: var(--accent-soft); color: var(--accent); }
.insight-icon .ui-icon { width: 19px; height: 19px; }
.insight-card p { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0; }
.insight-card strong { color: var(--ink); font-weight: 600; }
.goal-card { padding: 18px; }
.goal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.goal-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.goal-name > div { min-width: 0; }
.goal-emoji { width: 38px; height: 38px; }
.goal-name strong { display: block; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.goal-name span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.goal-edit { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 0; min-height: 44px; }
.goal-progress, .plan-summary { height: 5px; background: var(--fill); border-radius: 8px; overflow: hidden; margin: 16px 0 10px; }
.goal-progress i, .plan-summary i { height: 100%; display: block; border-radius: 8px; width: var(--width, 0%); background: var(--accent); }
.goal-foot { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.goal-foot strong { font-weight: 500; color: var(--ink); }
.transaction-list { background: var(--paper); border-radius: var(--radius); padding: 2px 16px; }
.day-label { font-size: 11px; color: var(--muted); padding: 18px 0 6px; }
.transaction-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 28px; gap: 9px; align-items: center; padding: 12px 0; border-bottom: .5px solid var(--line); }
.tx-icon { width: 36px; height: 36px; }
.tx-icon .ui-icon { width: 20px; height: 20px; }
.tx-info { min-width: 0; }
.tx-info strong { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-info span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; }
.tx-amount.income { color: var(--success); }
.tx-more { height: 44px; width: 44px; margin: 0 -8px; border: 0; background: none; color: var(--tertiary); font-size: 19px; letter-spacing: 1px; }
.empty-state { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty-art { margin: auto auto 14px; width: 48px; height: 48px; border-radius: 15px; }
.empty-state b { display: block; color: var(--ink); font-size: 16px; font-weight: 600; margin: 8px 0; }
.empty-state p { font-size: 13px; line-height: 1.6; margin: 0; }
.quick-add { position: fixed; z-index: 5; right: max(20px, calc((100vw - 480px) / 2 + 20px)); bottom: calc(88px + var(--safe-bottom)); display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.quick-add span { display: none; }
.quick-add svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bottom-nav { position: fixed; z-index: 4; bottom: 0; left: 50%; transform: translateX(-50%); width: min(480px, 100%); padding: 8px 10px calc(10px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); border-top: .5px solid var(--line); background: var(--bar); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 46px; padding: 4px; border: 0; background: none; color: var(--muted); font-size: 10px; font-weight: 500; }
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.is-active { color: var(--accent); }
.nav-item.is-active svg { stroke-width: 1.9; }
.chart-card { padding: 20px 18px 16px; }
.chart-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.chart-head strong { font-size: 14px; font-weight: 600; }
.chart-head span { font-size: 12px; color: var(--muted); }
.chart { position: relative; display: flex; align-items: end; justify-content: space-around; gap: 10px; height: 150px; margin-top: 20px; border-bottom: .5px solid var(--line); }
.chart:before, .chart:after { content: ""; position: absolute; left: 0; right: 0; border-top: .5px dashed var(--line); }
.chart:before { top: 33%; }
.chart:after { top: 66%; }
.chart-column { display: flex; align-items: end; gap: 4px; height: 100%; position: relative; }
.chart-bar { width: 14px; min-height: 3px; border-radius: 4px 4px 0 0; background: var(--fill); height: var(--height, 0%); z-index: 1; }
.chart-bar.expense { background: var(--accent); }
.chart-bar.income { background: var(--success); }
.chart-labels { display: flex; justify-content: space-around; font-size: 11px; color: var(--muted); padding-top: 8px; }
.legend { display: flex; gap: 18px; margin-top: 16px; color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; }
.legend .now { background: var(--accent); }
.legend .income-key { background: var(--success); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mini-stat { padding: 17px 15px; min-width: 0; }
.mini-stat span { color: var(--muted); font-size: 12px; }
.mini-stat strong { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.5px; margin: 8px 0 5px; }
.mini-stat em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.mini-stat em.negative { color: var(--red); }
.category-ranking { padding: 3px 16px; }
.rank-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: .5px solid var(--line); }
.rank-row .category-icon { width: 32px; height: 32px; }
.rank-copy strong { font-size: 13px; font-weight: 500; }
.rank-value { font-size: 13px; font-weight: 500; }
.plan-hero { padding: 20px; }
.plan-total { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.plan-total strong { display: block; font-size: 28px; font-weight: 600; letter-spacing: -.8px; margin-top: 5px; }
.plan-total span { color: var(--muted); font-size: 12px; }
.plan-total button { background: none; border: 0; color: var(--accent); padding: 0; min-height: 44px; font-size: 13px; }
.plan-summary-copy { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.settings-card { padding: 0 16px; }
.setting-row { width: 100%; padding: 13px 0; border: 0; border-bottom: .5px solid var(--line); background: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; min-height: 60px; }
.setting-label { display: flex; align-items: center; gap: 12px; }
.setting-label strong { font-size: 14px; font-weight: 400; }
.setting-row > span:last-child { color: var(--muted); font-size: 12px; }
.challenge-card { padding: 18px; display: flex; gap: 12px; }
.challenge-icon { color: var(--muted); }
.challenge-card strong { font-size: 14px; font-weight: 600; }
.challenge-card p { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.filter-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 11px; background: var(--fill); margin-bottom: 18px; }
.filter-pills button { background: none; border: 0; border-radius: 8px; color: var(--muted); min-height: 38px; font-size: 13px; font-weight: 500; }
.filter-pills button.active { color: var(--ink); background: var(--elevated); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: flex; align-items: flex-end; justify-content: center; background: var(--backdrop); }
.modal-sheet { width: min(480px, 100%); max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + var(--safe-bottom)); animation: slideup .2s ease-out; }
.modal-handle { width: 36px; height: 5px; border-radius: 4px; background: var(--line); margin: 0 auto 16px; }
.modal-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.modal-heading h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.4px; }
.modal-close { display: grid; place-items: center; border: 0; border-radius: 50%; width: 40px; height: 40px; background: var(--fill); color: var(--muted); font-size: 24px; flex-shrink: 0; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; background: var(--fill); padding: 3px; border-radius: 11px; margin-bottom: 20px; }
.type-switch button { border: 0; border-radius: 8px; background: none; color: var(--muted); min-height: 40px; font-size: 14px; font-weight: 500; }
.type-switch button.active { color: var(--ink); background: var(--elevated); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
.form-label { display: block; color: var(--muted); font-size: 13px; font-weight: 400; margin: 18px 0 8px; }
.amount-input-wrap { display: flex; align-items: baseline; gap: 8px; padding: 8px 0 14px; border-bottom: .5px solid var(--line); }
.amount-input-wrap input { min-width: 0; width: 100%; background: none; color: var(--ink); border: 0; outline: 0; font-size: 42px; font-weight: 600; letter-spacing: -1px; }
.amount-input-wrap:focus-within { border-color: var(--accent); }
.amount-input-wrap span { color: var(--muted); font-size: 26px; }
.form-input, .form-select { width: 100%; min-width: 0; min-height: 48px; padding: 12px; border: 1px solid transparent; border-radius: 12px; background: var(--fill); color: var(--ink); font-size: 16px; outline: none; }
.form-input:focus, .form-select:focus { border-color: var(--accent); }
input::placeholder { color: var(--tertiary); opacity: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid > div { min-width: 0; }
.primary-button { width: 100%; border: 0; border-radius: 14px; padding: 14px; margin-top: 22px; min-height: 50px; font-size: 16px; font-weight: 600; background: var(--accent); color: var(--on-accent); }
.primary-button.danger { background: var(--red); color: #fff; }
.secondary-button { width: 100%; min-height: 44px; border: 0; background: none; color: var(--muted); font-size: 14px; padding: 12px; margin-top: 6px; }
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.category-choice { min-width: 0; min-height: 68px; border: 1px solid transparent; border-radius: 13px; padding: 10px 2px; color: var(--muted); background: var(--fill); }
.category-choice > span { display: grid; place-items: center; }
.category-choice small { display: block; font-size: 10px; margin-top: 7px; }
.category-choice.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(160px + var(--safe-bottom)); transform: translate(-50%, 8px); width: max-content; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px; font-size: 13px; text-align: center; color: var(--ink); background: var(--elevated); box-shadow: var(--shadow); border: .5px solid var(--line); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.privacy .sensitive { filter: blur(7px); user-select: none; }
.install-banner { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; background: var(--paper); color: var(--muted); margin-top: 20px; }
.page-heading + .install-banner { margin-top: 0; margin-bottom: 16px; }
.install-banner p { flex: 1; margin: 0; font-size: 12px; line-height: 1.55; }
.install-banner strong { color: var(--ink); font-weight: 500; }
.install-banner button { border: 0; background: none; color: var(--accent); font-size: 12px; min-height: 44px; padding: 0; }
.notice { font-size: 12px; line-height: 1.55; color: var(--muted); margin: 14px 2px 0; }
.fade-in { animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideup { from { transform: translateY(24px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 700px) {
  .app-shell { padding-top: 16px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-sheet { border-radius: 24px; max-height: 88dvh; padding-bottom: 24px; }
  .bottom-nav { border-radius: 20px 20px 0 0; }
}
@media (max-width: 370px) {
  .app-shell { padding-left: 16px; padding-right: 16px; }
  .balance-card { padding: 20px 18px; }
  .transaction-list, .budget-list { padding-left: 12px; padding-right: 12px; }
  .transaction-row { grid-template-columns: 32px minmax(0, 1fr) auto 24px; gap: 7px; }
  .tx-icon { width: 32px; height: 32px; }
  .tx-amount { font-size: 12px; }
  .page-title { font-size: 30px; }
  .section-row h2 { font-size: 17px; }
  .balance-stat strong { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
