:root {
  --paper: #f4f2eb;
  --surface: #fffdf8;
  --surface-soft: #eceee6;
  --ink: #15231d;
  --ink-soft: #34443c;
  --muted: #707a73;
  --muted-light: #9aa19c;
  --line: #e1e3da;
  --line-strong: #cfd4ca;
  --green: #286d4b;
  --green-deep: #174b36;
  --green-bright: #4d996e;
  --mint: #dcebdd;
  --mint-light: #edf5ef;
  --coral: #d8684e;
  --coral-soft: #f6e2dc;
  --amber: #dca047;
  --amber-soft: #f5ead5;
  --nav-height: 82px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --shadow-phone: 0 34px 80px rgba(25, 39, 31, 0.18), 0 8px 24px rgba(25, 39, 31, 0.09);
  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-number: "Avenir Next", "SF Pro Display", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--ink);
  background: #e8ebe3;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea { color: inherit; font: inherit; }

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(40, 109, 75, 0.26);
  outline-offset: 2px;
}

button:disabled { cursor: not-allowed; opacity: 0.45; }
svg { display: block; }

.page-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(23, 75, 54, 0.035) 1px, transparent 1px);
  background-size: 100% 34px;
}

.device-wrap {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 100dvh;
  place-items: center;
  padding: 28px;
}

.phone-frame {
  position: relative;
  display: flex;
  width: min(390px, 100%);
  height: min(844px, calc(100dvh - 56px));
  min-height: 610px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(21, 35, 29, 0.11);
  border-radius: 46px;
  background: var(--paper);
  box-shadow: var(--shadow-phone);
}

.device-status {
  z-index: 20;
  display: flex;
  height: 34px;
  flex: 0 0 34px;
  align-items: center;
  justify-content: space-between;
  padding: 9px 25px 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-number);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.device-status-icons { display: flex; align-items: center; gap: 7px; }
.signal-bars { display: flex; height: 11px; align-items: flex-end; gap: 2px; }
.signal-bars i { display: block; width: 2px; border-radius: 2px; background: var(--ink); }
.signal-bars i:nth-child(1) { height: 4px; }
.signal-bars i:nth-child(2) { height: 6px; }
.signal-bars i:nth-child(3) { height: 8px; }
.signal-bars i:nth-child(4) { height: 10px; }
.wifi-mark { width: 12px; height: 8px; border-top: 2px solid var(--ink); border-radius: 50%; }
.battery-mark { position: relative; width: 18px; height: 9px; border: 1.5px solid var(--ink); border-radius: 3px; }
.battery-mark::before { position: absolute; inset: 2px; width: 10px; border-radius: 1px; background: var(--ink); content: ""; }
.battery-mark::after { position: absolute; top: 2px; right: -3px; width: 2px; height: 4px; border-radius: 0 2px 2px 0; background: var(--ink); content: ""; }

.app-shell {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
}

.app-view {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
}

.app-view::-webkit-scrollbar,
.sheet-body::-webkit-scrollbar { display: none; }

.screen { min-height: 100%; padding: 18px 20px 34px; }
.screen.with-nav { padding-bottom: 28px; }
.screen.enter { animation: page-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-kicker { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
h1,
h2,
h3,
p { margin-top: 0; }
h1,
h2,
h3 { letter-spacing: -0.025em; }
.screen-title { margin: 1px 0 0; font-size: 28px; font-weight: 750; line-height: 1.18; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 12px; }
.section-title { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: -0.02em; }
.text-button { display: inline-flex; align-items: center; gap: 3px; padding: 4px 0; color: var(--green); background: transparent; font-size: 13px; font-weight: 700; }
.text-button svg { width: 15px; height: 15px; }

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 17px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 750;
  transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.icon-button:active,
.nav-item:active,
.category-choice:active { transform: scale(0.975); }
.primary-button { color: #fff; background: var(--green); box-shadow: 0 8px 18px rgba(28, 92, 60, 0.18); }
.secondary-button { color: var(--ink); background: var(--surface-soft); }
.danger-button { color: #fff; background: var(--coral); }
.full-width { width: 100%; }

.icon-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 14px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.68);
  transition: transform 160ms ease, background-color 160ms ease;
}

.icon-button svg { width: 20px; height: 20px; }
.icon-button.ghost { background: transparent; }

/* Onboarding */
.onboarding {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  padding: 24px 24px max(28px, env(safe-area-inset-bottom));
  background: var(--paper);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  overflow: hidden;
  border-radius: 50% 50% 50% 38%;
  color: #fff;
  background: var(--green);
  font-size: 14px;
  font-weight: 850;
}

.brand-mark::after {
  position: absolute;
  right: -3px;
  bottom: -5px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mint);
  content: "";
}

.onboarding-copy { margin-top: clamp(54px, 11vh, 104px); }
.onboarding-copy h1 { max-width: 310px; margin: 0 0 18px; font-size: clamp(38px, 12vw, 49px); font-weight: 780; line-height: 1.12; letter-spacing: -0.06em; }
.onboarding-copy .lead { max-width: 290px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.75; }
.onboarding-art { position: relative; display: flex; min-height: 218px; flex: 1; align-items: center; justify-content: center; margin: 12px 0 8px; }

.receipt-slip {
  position: relative;
  width: 238px;
  padding: 23px 22px 26px;
  transform: rotate(-2.5deg);
  border-radius: 5px 5px 14px 14px;
  background: var(--surface);
  box-shadow: 0 18px 38px rgba(40, 67, 52, 0.12);
}

.receipt-slip::after {
  position: absolute;
  right: 0;
  bottom: -9px;
  left: 0;
  height: 10px;
  background-image: linear-gradient(135deg, transparent 6px, var(--surface) 0), linear-gradient(45deg, transparent 6px, var(--surface) 0);
  background-position: 0 0, 4px 0;
  background-size: 8px 10px;
  content: "";
}

.receipt-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; }
.receipt-amount { margin: 20px 0 8px; font-family: var(--font-number); font-size: 34px; font-weight: 760; letter-spacing: -0.05em; }
.receipt-line { height: 1px; margin: 17px 0; background: repeating-linear-gradient(90deg, var(--line-strong) 0 5px, transparent 5px 9px); }
.receipt-row { display: flex; align-items: center; justify-content: space-between; color: var(--ink-soft); font-size: 12px; }
.receipt-row + .receipt-row { margin-top: 9px; }
.receipt-row strong { color: var(--green); font-weight: 750; }
.onboarding-actions { display: grid; gap: 14px; }
.footnote { margin: 0; color: var(--muted-light); font-size: 12px; text-align: center; }

.budget-setup { display: flex; min-height: 100%; flex-direction: column; }
.setup-head { margin-top: 58px; }
.setup-head h1 { margin: 0 0 12px; font-size: 34px; font-weight: 780; line-height: 1.2; letter-spacing: -0.05em; }
.setup-head p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.budget-input-wrap { position: relative; display: flex; align-items: baseline; margin: 52px 0 20px; border-bottom: 2px solid var(--green); }
.budget-currency { color: var(--green); font-family: var(--font-number); font-size: 27px; font-weight: 750; }

.budget-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 4px 10px 8px;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-number);
  font-size: 48px;
  font-weight: 720;
  letter-spacing: -0.055em;
  line-height: 1;
}

.quick-budget { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-budget button { min-height: 42px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink-soft); background: var(--surface); font-family: var(--font-number); font-size: 13px; font-weight: 700; }
.quick-budget button.active { border-color: var(--green); color: var(--green-deep); background: var(--mint-light); }
.setup-note { display: flex; align-items: flex-start; gap: 10px; margin: 22px 0 0; padding: 14px 14px 13px; border-radius: 15px; color: var(--ink-soft); background: var(--surface-soft); font-size: 12px; line-height: 1.55; }
.setup-note svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; color: var(--green); }
.setup-spacer { flex: 1; }

/* Home */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; }
.home-date { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.home-greeting { margin: 4px 0 0; font-size: 25px; font-weight: 760; letter-spacing: -0.04em; }
.profile-dot { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(23, 75, 54, 0.13); border-radius: 50%; color: var(--green-deep); background: var(--mint); font-family: "Avenir Next", sans-serif; font-size: 16px; font-weight: 800; }

.budget-hero {
  position: relative;
  overflow: hidden;
  margin-top: 20px;
  padding: 22px 22px 20px;
  border-radius: var(--radius-lg);
  color: #f9fcf9;
  background: var(--green-deep);
  box-shadow: 0 16px 30px rgba(23, 75, 54, 0.18);
}

.budget-hero::before,
.budget-hero::after { position: absolute; top: 58px; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); content: ""; }
.budget-hero::before { left: -7px; }
.budget-hero::after { right: -7px; }
.hero-topline { display: flex; align-items: center; justify-content: space-between; color: rgba(255, 255, 255, 0.72); font-size: 12px; font-weight: 650; }
.hero-month-chip { padding: 4px 8px; border: 1px solid rgba(255, 255, 255, 0.17); border-radius: 999px; }
.hero-label { margin: 14px 0 4px; color: rgba(255, 255, 255, 0.72); font-size: 13px; }
.hero-amount { margin: 0; font-family: var(--font-number); font-size: clamp(37px, 10vw, 44px); font-variant-numeric: tabular-nums; font-weight: 730; letter-spacing: -0.055em; line-height: 1.12; }
.hero-amount.negative { color: #ffd8cd; }

.hero-progress { position: relative; height: 6px; overflow: hidden; margin: 22px 0 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); }
.hero-progress span { display: block; width: var(--progress, 0%); height: 100%; border-radius: inherit; background: #a8dfbd; transition: width 320ms ease; }
.hero-meta { display: flex; align-items: center; justify-content: space-between; color: rgba(255, 255, 255, 0.69); font-size: 11px; }
.hero-meta strong { color: #fff; font-weight: 700; }
.hero-link { position: absolute; right: 18px; bottom: 16px; display: grid; width: 29px; height: 29px; place-items: center; border-radius: 50%; color: var(--green-deep); background: var(--mint); }
.hero-link svg { width: 15px; height: 15px; }

.daily-note { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 12px; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255, 253, 248, 0.78); }
.daily-note-icon { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 12px; color: var(--green); background: var(--mint-light); }
.daily-note-icon svg { width: 17px; height: 17px; }
.daily-note-label { margin: 0; color: var(--muted); font-size: 11px; }
.daily-note-value { margin: 1px 0 0; font-family: var(--font-number); font-size: 17px; font-weight: 750; }
.daily-days { color: var(--muted); font-size: 11px; text-align: right; }
.daily-days strong { display: block; color: var(--ink-soft); font-family: var(--font-number); font-size: 15px; }

.record-list { overflow: hidden; border-top: 1px solid var(--line); }
.record-row { display: grid; min-height: 68px; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.category-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; color: var(--category-color, var(--green)); background: color-mix(in srgb, var(--category-color, var(--green)) 14%, white); }
.category-icon.small { width: 34px; height: 34px; border-radius: 11px; }
.category-icon svg { width: 20px; height: 20px; }
.category-icon.small svg { width: 16px; height: 16px; }
.record-main { min-width: 0; }
.record-title { overflow: hidden; margin: 0; font-size: 14px; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.record-subtitle { overflow: hidden; margin: 2px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.record-amount { font-family: var(--font-number); font-size: 14px; font-variant-numeric: tabular-nums; font-weight: 720; white-space: nowrap; }
.record-amount.income { color: var(--green-bright); }

.empty-state { display: flex; min-height: 210px; flex-direction: column; align-items: center; justify-content: center; padding: 36px 28px; color: var(--muted); text-align: center; }
.empty-state svg { width: 38px; height: 38px; margin-bottom: 12px; color: var(--green); opacity: 0.68; }
.empty-state strong { margin-bottom: 5px; color: var(--ink-soft); font-size: 15px; }
.empty-state p { max-width: 220px; margin: 0; font-size: 12px; line-height: 1.6; }

/* Bottom navigation */
.bottom-nav-host { z-index: 30; flex: 0 0 auto; padding: 0 13px max(8px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(244, 242, 235, 0), var(--paper) 26%); }
.bottom-nav { position: relative; display: grid; height: 66px; grid-template-columns: repeat(5, 1fr); align-items: center; border: 1px solid rgba(21, 35, 29, 0.08); border-radius: 24px; background: rgba(255, 253, 248, 0.96); box-shadow: 0 12px 28px rgba(35, 52, 43, 0.1); backdrop-filter: blur(14px); }
.nav-item { display: flex; min-width: 0; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted-light); background: transparent; font-size: 10px; font-weight: 650; transition: color 180ms ease, transform 160ms ease; }
.nav-item svg { width: 20px; height: 20px; }
.nav-item.active { color: var(--green); }
.nav-add-wrap { display: grid; place-items: center; }
.nav-add { display: grid; width: 52px; height: 52px; place-items: center; transform: translateY(-8px); border: 5px solid var(--surface); border-radius: 18px; color: #fff; background: var(--green); box-shadow: 0 9px 20px rgba(26, 94, 61, 0.28); transition: transform 160ms ease, background-color 160ms ease; }
.nav-add:active { transform: translateY(-8px) scale(0.95); }
.nav-add svg { width: 23px; height: 23px; }

/* Headers and utility */
.subpage-head { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 8px; margin-bottom: 24px; }
.subpage-head h1 { margin: 0; font-size: 19px; font-weight: 760; text-align: center; }
.subpage-head .icon-button { background: transparent; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.month-switcher { display: inline-flex; min-height: 38px; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 13px; padding: 0 5px; color: var(--ink-soft); background: rgba(255, 253, 248, 0.8); }
.month-switcher button { display: grid; width: 29px; height: 29px; place-items: center; border-radius: 9px; color: var(--ink-soft); background: transparent; }
.month-switcher button:disabled { opacity: 0.22; }
.month-switcher svg { width: 15px; height: 15px; }
.month-switcher strong { min-width: 74px; font-family: var(--font-number); font-size: 12px; font-weight: 720; text-align: center; }

.summary-pair { display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary-cell { padding: 17px 0 15px; }
.summary-cell + .summary-cell { border-left: 1px solid var(--line); padding-left: 18px; }
.summary-cell:first-child:not(:last-child) { padding-right: 18px; }
.summary-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.summary-value { display: block; font-family: var(--font-number); font-size: 21px; font-variant-numeric: tabular-nums; font-weight: 750; letter-spacing: -0.03em; }
.summary-value.income { color: var(--green); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-soft); }
.segmented button { min-height: 36px; border-radius: 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.segmented button.active { color: var(--ink); background: var(--surface); box-shadow: 0 2px 7px rgba(29, 45, 36, 0.08); }

/* Bills */
.bill-filter { margin: 14px 0 2px; }
.bill-groups { margin-top: 8px; }
.date-group + .date-group { margin-top: 19px; }
.date-heading { display: flex; align-items: center; justify-content: space-between; padding: 5px 1px 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.date-heading strong { color: var(--ink-soft); font-weight: 750; }
.bill-row { display: grid; width: 100%; min-height: 68px; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 0; color: inherit; background: transparent; text-align: left; }
.bill-row:first-of-type { border-top: 1px solid var(--line); }

/* Stats */
.stats-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.stat-block { padding: 17px 16px; border-radius: 18px; background: var(--surface); }
.stat-block:first-child { color: #fff; background: var(--green-deep); }
.stat-block .summary-label { color: inherit; opacity: 0.7; }
.stat-block .summary-value { color: inherit; }
.chart-card { margin-top: 20px; padding: 19px 18px 17px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255, 253, 248, 0.72); }
.chart-title { margin: 0; font-size: 15px; font-weight: 750; }
.chart-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.donut-wrap { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: center; gap: 18px; margin-top: 20px; }
.donut { position: relative; display: grid; width: 132px; height: 132px; place-items: center; border-radius: 50%; }
.donut::after { position: absolute; width: 78px; height: 78px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px rgba(21, 35, 29, 0.04); content: ""; }
.donut-center { z-index: 1; text-align: center; }
.donut-center span { display: block; color: var(--muted); font-size: 10px; }
.donut-center strong { display: block; margin-top: 1px; font-family: var(--font-number); font-size: 17px; font-weight: 760; }
.legend-list { display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 8px; font-size: 11px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--legend-color); }
.legend-name { overflow: hidden; color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.legend-value { color: var(--muted); font-family: var(--font-number); font-weight: 700; }

.category-bars { display: grid; gap: 13px; margin-top: 20px; }
.category-bar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 12px; }
.category-bar-head strong { font-weight: 690; }
.category-bar-head span { color: var(--muted); font-family: var(--font-number); font-size: 11px; }
.bar-track { height: 6px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.bar-track span { display: block; width: var(--bar-width); height: 100%; border-radius: inherit; background: var(--bar-color); }
.trend-chart { display: grid; height: 145px; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; margin-top: 18px; padding-top: 12px; border-bottom: 1px solid var(--line); }
.trend-column { display: flex; height: 100%; min-width: 0; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; }
.trend-value { height: 15px; color: var(--muted); font-family: var(--font-number); font-size: 9px; }
.trend-bar { width: 100%; max-width: 24px; height: var(--trend-height); min-height: 3px; border-radius: 7px 7px 3px 3px; background: var(--mint); }
.trend-column.today .trend-bar { background: var(--green); }
.trend-day { color: var(--muted); font-size: 9px; }
.trend-column.today .trend-day { color: var(--green); font-weight: 750; }

/* Budget detail */
.budget-detail-card { margin-top: 10px; padding: 24px 22px 22px; border-radius: var(--radius-lg); color: #fff; background: var(--green-deep); }
.budget-detail-card .summary-label,
.budget-detail-card .summary-value { color: inherit; }
.budget-detail-amount { margin: 0; font-family: var(--font-number); font-size: 42px; font-variant-numeric: tabular-nums; font-weight: 740; letter-spacing: -0.055em; }
.budget-detail-amount.negative { color: #ffd8cd; }
.budget-detail-progress { height: 7px; overflow: hidden; margin: 22px 0 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); }
.budget-detail-progress span { display: block; width: var(--progress); height: 100%; border-radius: inherit; background: #a8dfbd; }
.budget-detail-meta { display: flex; justify-content: space-between; color: rgba(255, 255, 255, 0.68); font-size: 11px; }
.budget-days-card { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding: 17px 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.budget-days-card span { color: var(--muted); font-size: 12px; }
.budget-days-card strong { font-family: var(--font-number); font-size: 19px; font-weight: 750; }
.form-section { margin-top: 27px; }
.form-label { display: block; margin-bottom: 9px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.budget-edit-row { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 16px; padding: 0 15px; background: var(--surface); }
.budget-edit-row span { color: var(--green); font-family: var(--font-number); font-weight: 750; }
.budget-edit-row input { width: 100%; min-width: 0; height: 54px; border: 0; outline: 0; background: transparent; font-family: var(--font-number); font-size: 22px; font-weight: 720; }
.form-help { margin: 8px 1px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }

/* Profile */
.profile-card { display: flex; align-items: center; gap: 14px; margin-top: 5px; padding: 18px 0 22px; border-bottom: 1px solid var(--line); }
.profile-avatar { display: grid; width: 55px; height: 55px; flex: 0 0 auto; place-items: center; border-radius: 19px; color: #fff; background: var(--green); font-family: "Avenir Next", sans-serif; font-size: 22px; font-weight: 800; }
.profile-card h2 { margin: 0; font-family: "Avenir Next", sans-serif; font-size: 20px; font-weight: 800; letter-spacing: -0.035em; }
.profile-card p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.settings-group { margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255, 253, 248, 0.72); }
.settings-row { display: grid; width: 100%; min-height: 65px; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); padding: 0 15px; color: inherit; background: transparent; text-align: left; }
.settings-row:last-child { border-bottom: 0; }
.settings-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; color: var(--green); background: var(--mint-light); }
.settings-icon.coral { color: var(--coral); background: var(--coral-soft); }
.settings-icon svg { width: 17px; height: 17px; }
.settings-title { margin: 0; font-size: 13px; font-weight: 720; }
.settings-subtitle { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.settings-value { display: flex; align-items: center; gap: 5px; color: var(--muted); font-family: var(--font-number); font-size: 12px; font-weight: 700; }
.settings-value svg { width: 15px; height: 15px; }
.privacy-note { display: grid; grid-template-columns: 34px 1fr; gap: 12px; margin-top: 20px; padding: 16px; border-radius: 17px; color: #fff; background: var(--green-deep); }
.privacy-note svg { width: 22px; height: 22px; margin-top: 3px; color: #a8dfbd; }
.privacy-note strong { display: block; margin-bottom: 3px; font-size: 13px; }
.privacy-note p { margin: 0; color: rgba(255, 255, 255, 0.7); font-size: 11px; line-height: 1.55; }
.version-note { margin-top: 18px; color: var(--muted-light); font-size: 10px; text-align: center; }

/* Category management */
.category-tabs { margin-bottom: 18px; }
.category-list { overflow: hidden; border-top: 1px solid var(--line); }
.category-manage-row { display: grid; min-height: 68px; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.category-manage-row.is-hidden { opacity: 0.54; }
.category-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.category-name strong { overflow: hidden; font-size: 14px; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.mini-badge { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 9px; font-weight: 700; }
.row-actions { display: flex; align-items: center; gap: 3px; }
.mini-action { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; color: var(--muted); background: transparent; }
.mini-action.danger { color: var(--coral); }
.mini-action svg { width: 16px; height: 16px; }
.add-category-button { margin-top: 20px; }

/* Sheet */
.sheet-backdrop { position: absolute; z-index: 60; inset: 0; background: rgba(17, 30, 23, 0.34); animation: fade-in 180ms ease both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.bottom-sheet { position: absolute; z-index: 61; right: 0; bottom: 0; left: 0; display: flex; max-height: 94%; flex-direction: column; overflow: hidden; border-radius: 30px 30px 0 0; background: var(--surface); box-shadow: 0 -18px 50px rgba(19, 34, 26, 0.18); animation: sheet-up 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 36px; height: 4px; flex: 0 0 auto; margin: 10px auto 4px; border-radius: 99px; background: var(--line-strong); }
.sheet-head { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; padding: 3px 16px 6px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 760; text-align: center; }
.sheet-head button { background: transparent; }
.sheet-body { min-height: 0; overflow-y: auto; padding: 8px 20px max(12px, env(safe-area-inset-bottom)); }
.entry-type { grid-template-columns: 1fr 1fr; margin-bottom: 13px; }
.amount-display { width: 100%; min-height: 78px; border: 0; padding: 4px 0 8px; color: var(--ink); background: transparent; font-family: var(--font-number); font-size: 47px; font-variant-numeric: tabular-nums; font-weight: 730; letter-spacing: -0.055em; text-align: right; }
.amount-display::placeholder { color: var(--line-strong); }
.entry-hint { margin: -2px 0 9px; color: var(--muted); font-size: 10px; text-align: right; }
.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px 7px; margin: 8px 0 17px; }
.category-choice { display: flex; min-width: 0; flex-direction: column; align-items: center; gap: 6px; padding: 0; color: var(--muted); background: transparent; font-size: 10px; font-weight: 650; transition: transform 160ms ease, color 160ms ease; }
.category-choice .category-icon { width: 46px; height: 46px; border: 2px solid transparent; border-radius: 16px; transition: border-color 160ms ease, box-shadow 160ms ease; }
.category-choice.active { color: var(--ink); }
.category-choice.active .category-icon { border-color: var(--category-color); box-shadow: 0 5px 14px color-mix(in srgb, var(--category-color) 16%, transparent); }
.entry-optional { display: grid; gap: 9px; margin-bottom: 15px; }
.compact-field { display: grid; grid-template-columns: 27px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 47px; border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; color: var(--muted); background: var(--paper); }
.compact-field svg { width: 17px; height: 17px; }
.compact-field input { width: 100%; min-width: 0; height: 45px; border: 0; outline: 0; background: transparent; font-size: 12px; }
.compact-field input[type="date"] { color: var(--ink-soft); font-family: var(--font-number); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key { display: grid; min-height: 49px; place-items: center; border-radius: 14px; color: var(--ink); background: var(--surface-soft); font-family: var(--font-number); font-size: 20px; font-weight: 680; transition: transform 100ms ease, background-color 100ms ease; }
.key:active { transform: scale(0.97); background: var(--mint); }
.key.function { color: var(--ink-soft); }
.key svg { width: 21px; height: 21px; }
.save-entry { margin-top: 13px; }
.sheet-note { margin: 9px 0 1px; color: var(--muted-light); font-size: 10px; text-align: center; }

/* Detail sheet */
.detail-hero { padding: 16px 0 23px; border-bottom: 1px solid var(--line); text-align: center; }
.detail-hero .category-icon { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 18px; }
.detail-hero .category-icon svg { width: 24px; height: 24px; }
.detail-category { margin: 0; color: var(--muted); font-size: 12px; }
.detail-amount { margin: 3px 0 0; font-family: var(--font-number); font-size: 37px; font-weight: 740; letter-spacing: -0.05em; }
.detail-list { margin: 12px 0 16px; }
.detail-row { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.detail-row strong { overflow: hidden; color: var(--ink-soft); font-weight: 650; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Category editor */
.color-options,
.icon-options { display: grid; gap: 9px; }
.icon-options,
.color-options { grid-template-columns: repeat(6, 1fr); }
.icon-option,
.color-option { display: grid; width: 100%; aspect-ratio: 1; place-items: center; border: 2px solid transparent; border-radius: 14px; background: var(--surface-soft); }
.icon-option svg { width: 20px; height: 20px; color: var(--ink-soft); }
.icon-option.active { border-color: var(--green); color: var(--green); background: var(--mint-light); }
.icon-option.active svg { color: var(--green); }
.color-option { position: relative; border-radius: 50%; background: var(--option-color); }
.color-option.active::after { position: absolute; inset: 5px; border: 2px solid #fff; border-radius: 50%; content: ""; }
.form-control { width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 15px; outline: 0; padding: 0 14px; background: var(--paper); font-size: 14px; }
.form-control:focus { border-color: var(--green); }

/* Dialogs */
.dialog-backdrop { position: absolute; z-index: 80; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(17, 30, 23, 0.36); animation: fade-in 160ms ease both; }
.dialog { width: 100%; max-width: 318px; border-radius: 24px; padding: 23px 21px 18px; background: var(--surface); box-shadow: 0 20px 55px rgba(16, 29, 22, 0.22); animation: dialog-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.96) translateY(5px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.dialog h2 { margin: 0 0 8px; font-size: 18px; font-weight: 760; text-align: center; }
.dialog p { margin: 0 0 20px; color: var(--muted); font-size: 12px; line-height: 1.65; text-align: center; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-actions.single { grid-template-columns: 1fr; }
.dialog-button { min-height: 46px; border-radius: 14px; font-size: 13px; font-weight: 740; }
.dialog-button.cancel { color: var(--ink-soft); background: var(--surface-soft); }
.dialog-button.confirm { color: #fff; background: var(--green); }
.dialog-button.confirm.danger { background: var(--coral); }
.toast-root { position: absolute; z-index: 100; right: 20px; bottom: 100px; left: 20px; display: flex; justify-content: center; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; padding: 11px 15px; border-radius: 14px; color: #fff; background: rgba(21, 35, 29, 0.94); box-shadow: 0 10px 24px rgba(20, 34, 27, 0.18); font-size: 12px; font-weight: 650; animation: toast-in 220ms ease both; }
.toast svg { width: 16px; height: 16px; color: #a8dfbd; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 560px) {
  body { background: var(--paper); }
  .page-texture,
  .device-status { display: none; }
  .device-wrap { display: block; min-height: 100dvh; padding: 0; }
  .phone-frame { width: 100%; height: 100dvh; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  .bottom-nav-host { padding-bottom: max(7px, env(safe-area-inset-bottom)); }
}

@media (max-width: 370px) {
  .screen { padding-right: 16px; padding-left: 16px; }
  .onboarding { padding-right: 20px; padding-left: 20px; }
  .budget-hero { padding-right: 18px; padding-left: 18px; }
  .donut-wrap { grid-template-columns: 116px minmax(0, 1fr); gap: 13px; }
  .donut { width: 116px; height: 116px; }
  .donut::after { width: 69px; height: 69px; }
  .icon-options,
  .color-options { grid-template-columns: repeat(5, 1fr); }
}

@media (max-height: 710px) {
  .onboarding-copy { margin-top: 34px; }
  .onboarding-copy h1 { font-size: 38px; }
  .onboarding-art { min-height: 150px; }
  .receipt-slip { width: 205px; padding: 17px 18px 22px; }
  .receipt-amount { margin-top: 13px; font-size: 29px; }
  .receipt-line { margin: 12px 0; }
  .setup-head { margin-top: 32px; }
  .budget-input-wrap { margin-top: 34px; }
  .bottom-sheet { max-height: 97%; }
  .amount-display { min-height: 62px; font-size: 40px; }
  .category-grid { gap: 7px; margin-bottom: 10px; }
  .category-choice .category-icon { width: 41px; height: 41px; }
  .key { min-height: 43px; }
}

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

.record-row {
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.form-help.error {
  color: var(--coral);
  font-weight: 650;
}

.onboarding {
  overflow: hidden;
}

.hero-meta {
  padding-right: 34px;
}

.settings-title,
.settings-subtitle {
  display: block;
}

/* Daily limit */
.setup-head.compact { margin-top: 42px; }
.budget-input-wrap.monthly { margin-top: 30px; margin-bottom: 16px; }
.daily-setup { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.daily-setup-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.daily-setup-head label { color: var(--ink-soft); font-size: 13px; font-weight: 750; }
.daily-setup-head span { color: var(--muted); font-size: 10px; }
.daily-input-shell { display: flex; align-items: baseline; border-bottom: 1.5px solid var(--line-strong); padding: 0 2px 8px; }
.daily-input-shell:focus-within { border-color: var(--green); }
.daily-input-shell > span { color: var(--green); font-family: var(--font-number); font-size: 20px; font-weight: 750; }
.daily-input-shell input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 0 6px; background: transparent; font-family: var(--font-number); font-size: 30px; font-weight: 730; letter-spacing: -0.04em; }
.daily-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.daily-quick button { min-height: 34px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: rgba(255, 253, 248, 0.78); font-family: var(--font-number); font-size: 10px; font-weight: 700; }
.daily-quick button.active { border-color: var(--green); color: var(--green-deep); background: var(--mint-light); }

.daily-note { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; transition: border-color 220ms ease, background-color 220ms ease, transform 220ms ease; }
.daily-note-main { min-width: 0; }
.daily-note-copy { display: flex; align-items: baseline; gap: 7px; }
.daily-note-progress { height: 4px; overflow: hidden; margin: 7px 0 5px; border-radius: 99px; background: var(--surface-soft); }
.daily-note-progress span { display: block; width: var(--daily-progress); height: 100%; border-radius: inherit; background: var(--green-bright); transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1); }
.daily-note-message { overflow: hidden; margin: 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.daily-days { min-width: 72px; white-space: nowrap; }
.daily-days strong { font-size: 13px; }
.daily-note.is-over { border-color: rgba(216, 104, 78, 0.35); background: var(--coral-soft); }
.daily-note.is-over .daily-note-icon { color: var(--coral); background: rgba(255, 255, 255, 0.66); }
.daily-note.is-over .daily-note-progress span { background: var(--coral); }
.daily-note.is-over .daily-note-message,
.daily-note.is-over .daily-days { color: #98513f; }

.daily-plan-card { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 13px; overflow: hidden; margin-top: 12px; padding: 17px 18px 19px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.daily-plan-copy span,
.daily-plan-status span,
.daily-plan-copy small { display: block; color: var(--muted); font-size: 10px; }
.daily-plan-copy strong { display: block; margin-top: 2px; font-family: var(--font-number); font-size: 24px; font-weight: 750; letter-spacing: -0.035em; }
.daily-plan-copy small { margin-top: 2px; }
.daily-plan-status { text-align: right; }
.daily-plan-status strong { display: block; margin-top: 2px; color: var(--green); font-family: var(--font-number); font-size: 17px; font-weight: 750; }
.daily-plan-progress { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.daily-plan-progress span { display: block; width: var(--daily-progress); height: 100%; border-radius: inherit; background: var(--green-bright); transition: width 520ms cubic-bezier(0.22, 1, 0.36, 1); }
.daily-plan-card.is-over { border-color: rgba(216, 104, 78, 0.36); background: var(--coral-soft); }
.daily-plan-card.is-over .daily-plan-status strong { color: var(--coral); }
.daily-plan-card.is-over .daily-plan-progress span { background: var(--coral); }

/* iPhone-like motion */
.screen.enter { animation: page-in-ios 380ms cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes page-in-ios {
  from { opacity: 0; transform: translateY(8px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.bottom-sheet { animation: sheet-up-ios 460ms cubic-bezier(0.18, 0.9, 0.18, 1) both; will-change: transform; }
@keyframes sheet-up-ios {
  0% { transform: translateY(104%); }
  76% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}
.sheet-backdrop,
.dialog-backdrop { background: rgba(17, 30, 23, 0.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.dialog { animation: dialog-spring 360ms cubic-bezier(0.18, 0.9, 0.2, 1.12) both; }
@keyframes dialog-spring {
  0% { opacity: 0; transform: scale(0.9) translateY(10px); }
  72% { opacity: 1; transform: scale(1.018) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.dialog.care { border: 1px solid rgba(40, 109, 75, 0.12); background: linear-gradient(180deg, #fffdf8 0%, #f2f7f1 100%); }
.dialog-care-icon { display: grid; width: 44px; height: 44px; place-items: center; margin: 0 auto 12px; border-radius: 15px; color: var(--green); background: var(--mint); }
.dialog-care-icon svg { width: 22px; height: 22px; }
.amount-display { animation: amount-pop 150ms cubic-bezier(0.2, 0.9, 0.2, 1.12); transform-origin: right center; }
@keyframes amount-pop {
  0% { transform: scale(0.985); }
  65% { transform: scale(1.018); }
  100% { transform: scale(1); }
}
.category-choice.active .category-icon { animation: category-pop 280ms cubic-bezier(0.18, 0.9, 0.2, 1.18); }
@keyframes category-pop {
  0% { transform: scale(0.82); }
  62% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.nav-add,
.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.category-choice,
.mini-action,
.key { touch-action: manipulation; }
.nav-item svg,
.nav-add svg,
.icon-button svg { transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1); }
.nav-item.active svg { animation: nav-active-pop 340ms cubic-bezier(0.18, 0.9, 0.2, 1.15); }
@keyframes nav-active-pop {
  0% { transform: translateY(1px) scale(0.86); }
  68% { transform: translateY(-1px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}

/* Wallet transaction flight */
.money-flight-layer { position: absolute; z-index: 75; inset: 0; overflow: hidden; pointer-events: none; }
.money-token { position: absolute; display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255, 255, 255, 0.72); border-radius: 50%; font-family: var(--font-number); font-size: 12px; font-weight: 800; box-shadow: 0 5px 12px rgba(21, 35, 29, 0.18); will-change: transform, opacity; }
.money-token.income { color: #fff; background: var(--green-bright); }
.money-token.expense { color: #fff; background: var(--coral); }
.money-change-label { position: absolute; transform: translate(-50%, 0); border-radius: 999px; padding: 5px 9px; font-family: var(--font-number); font-size: 11px; font-weight: 750; white-space: nowrap; will-change: transform, opacity; }
.money-change-label.income { color: var(--green-deep); background: #ccebd7; }
.money-change-label.expense { color: #8f3f31; background: #f7d8cf; }
.budget-hero.wallet-receive { animation: wallet-receive 720ms cubic-bezier(0.18, 0.9, 0.2, 1.14); }
.budget-hero.wallet-pay { animation: wallet-pay 660ms cubic-bezier(0.18, 0.9, 0.2, 1.08); }
@keyframes wallet-receive {
  0% { transform: scale(1); box-shadow: 0 16px 30px rgba(23, 75, 54, 0.18); }
  42% { transform: scale(1.018); box-shadow: 0 20px 38px rgba(40, 109, 75, 0.28), 0 0 0 7px rgba(168, 223, 189, 0.2); }
  100% { transform: scale(1); box-shadow: 0 16px 30px rgba(23, 75, 54, 0.18); }
}
@keyframes wallet-pay {
  0% { transform: scale(1); }
  38% { transform: scale(0.985); }
  100% { transform: scale(1); }
}
.nav-add.money-arrive { animation: plus-arrive 560ms cubic-bezier(0.18, 0.9, 0.2, 1.2); }
.nav-add.money-launch { animation: plus-launch 620ms cubic-bezier(0.18, 0.9, 0.2, 1.06); }
@keyframes plus-arrive {
  0% { transform: translateY(-8px) scale(0.78); }
  58% { transform: translateY(-10px) scale(1.12); }
  100% { transform: translateY(-8px) scale(1); }
}
@keyframes plus-launch {
  0% { transform: translateY(-8px) scale(1); }
  35% { transform: translateY(-7px) scale(0.88); }
  70% { transform: translateY(-10px) scale(1.09); }
  100% { transform: translateY(-8px) scale(1); }
}

/* Theme controls */
.theme-option-list { display: grid; gap: 9px; }
.theme-option { display: grid; min-height: 72px; grid-template-columns: 44px minmax(0, 1fr) 24px; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 17px; padding: 0 14px; color: inherit; background: var(--paper); text-align: left; transition: transform 160ms ease, border-color 220ms ease, background-color 220ms ease; }
.theme-option:active { transform: scale(.98); }
.theme-option-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 13px; color: var(--ink-soft); background: var(--surface-soft); }
.theme-option-copy strong,
.theme-option-copy small { display: block; }
.theme-option-copy strong { font-size: 14px; font-weight: 750; }
.theme-option-copy small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.theme-check { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; color: #fff; background: transparent; }
.theme-option.active { border-color: var(--green); background: var(--mint-light); }
.theme-option.active .theme-option-icon { color: var(--green); background: var(--mint); }
.theme-option.active .theme-check { background: var(--green); }
.theme-preview { margin-top: 18px; padding: 16px; border-radius: 17px; background: var(--surface-soft); }
.theme-preview-card { padding: 15px 16px 13px; border-radius: 16px; color: #fff; background: var(--green-deep); }
.theme-preview-card span { display: block; color: rgba(255, 255, 255, .68); font-size: 10px; }
.theme-preview-card strong { display: block; margin-top: 2px; font-family: var(--font-number); font-size: 25px; }
.theme-preview-card i { display: block; width: 58%; height: 4px; margin-top: 12px; border-radius: 99px; background: #a8dfbd; }
.theme-preview p { margin: 10px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

/* Dark theme */
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1512;
  --surface: #17201b;
  --surface-soft: #202a24;
  --ink: #edf3ef;
  --ink-soft: #c7d1ca;
  --muted: #94a098;
  --muted-light: #7d8981;
  --line: #29352e;
  --line-strong: #3a493f;
  --green: #75b68f;
  --green-deep: #1c4934;
  --green-bright: #70ba8d;
  --mint: #243c2f;
  --mint-light: #1b2c23;
  --coral: #e38a73;
  --coral-soft: #3b2621;
  --amber: #e0ad62;
  --amber-soft: #382f20;
  --shadow-phone: 0 34px 80px rgba(0, 0, 0, .42), 0 8px 24px rgba(0, 0, 0, .26);
}
html[data-theme="dark"] body { background: #090e0b; }
html[data-theme="dark"] .page-texture { background-image: linear-gradient(rgba(126, 192, 153, .045) 1px, transparent 1px); }
html[data-theme="dark"] .phone-frame { border-color: rgba(228, 240, 232, .1); }
html[data-theme="dark"] .bottom-nav-host { background: linear-gradient(180deg, rgba(15, 21, 18, 0), var(--paper) 26%); }
html[data-theme="dark"] .bottom-nav { border-color: rgba(228, 240, 232, .08); background: rgba(23, 32, 27, .96); box-shadow: 0 12px 28px rgba(0, 0, 0, .3); }
html[data-theme="dark"] .icon-button { background: rgba(255, 255, 255, .055); }
html[data-theme="dark"] .month-switcher { background: rgba(23, 32, 27, .84); }
html[data-theme="dark"] .category-icon { background: color-mix(in srgb, var(--category-color) 20%, var(--surface)); }
html[data-theme="dark"] .daily-note { background: rgba(23, 32, 27, .84); }
html[data-theme="dark"] .daily-note.is-over { background: #35241f; }
html[data-theme="dark"] .daily-note.is-over .daily-note-icon { background: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .daily-note.is-over .daily-note-message,
html[data-theme="dark"] .daily-note.is-over .daily-days { color: #efa18e; }
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .settings-group { background: rgba(23, 32, 27, .82); }
html[data-theme="dark"] .daily-quick button { background: rgba(23, 32, 27, .82); }
html[data-theme="dark"] .theme-option { background: #131b17; }
html[data-theme="dark"] .theme-preview { background: #131b17; }
html[data-theme="dark"] .setup-note { background: #1b2520; }
html[data-theme="dark"] .dialog.care { border-color: rgba(117, 182, 143, .2); background: linear-gradient(180deg, #17201b 0%, #16271e 100%); }
html[data-theme="dark"] .money-change-label.income { color: #c9f0d8; background: #24543b; }
html[data-theme="dark"] .money-change-label.expense { color: #ffd6cc; background: #683a30; }
html[data-theme="dark"] .toast { color: #15231d; background: rgba(237, 243, 239, .95); }
html[data-theme="dark"] .toast svg { color: #286d4b; }
html[data-theme="dark"] .bottom-sheet { box-shadow: 0 -18px 50px rgba(0, 0, 0, .34); }
html[data-theme="dark"] .dialog { box-shadow: 0 20px 55px rgba(0, 0, 0, .4); }
html[data-theme="dark"] .budget-hero,
html[data-theme="dark"] .budget-detail-card,
html[data-theme="dark"] .privacy-note,
html[data-theme="dark"] .stat-block:first-child,
html[data-theme="dark"] .theme-preview-card { border: 1px solid rgba(168, 223, 189, .1); }

body,
.phone-frame,
.app-shell,
.bottom-nav,
.bottom-sheet,
.dialog,
.settings-group,
.chart-card,
.daily-note,
.budget-hero,
.receipt-slip,
.theme-option,
.theme-preview { transition: background-color 320ms ease, color 320ms ease, border-color 320ms ease, box-shadow 320ms ease; }

html[data-theme="dark"] .primary-button,
html[data-theme="dark"] .nav-add,
html[data-theme="dark"] .profile-avatar,
html[data-theme="dark"] .dialog-button.confirm,
html[data-theme="dark"] .theme-option.active .theme-check {
  color: #fff;
  background: #347a53;
}

html[data-theme="dark"] .danger-button { background: #b85f49; }
html[data-theme="dark"] .money-token.income { background: #397f59; }
html[data-theme="dark"] .money-token.expense { background: #b85f49; }

.quick-budget button,
.daily-quick button {
  touch-action: manipulation;
  transition: transform 140ms ease, border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.quick-budget button:active,
.daily-quick button:active {
  transform: scale(.96);
}

.quick-budget button.active,
.daily-quick button.active {
  animation: amount-choice-pop 260ms cubic-bezier(0.18, 0.9, 0.2, 1.14);
}

@keyframes amount-choice-pop {
  0% { transform: scale(.92); }
  65% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Sheet dismissal and page swipe transitions */
.app-view {
  touch-action: pan-y;
}

.bottom-sheet.closing {
  animation: sheet-down-ios 360ms cubic-bezier(0.4, 0, 0.7, 0.2) both;
}

.sheet-backdrop.closing {
  animation: fade-out-ios 320ms ease both;
}

@keyframes sheet-down-ios {
  0% { transform: translateY(0); }
  18% { transform: translateY(-4px); }
  100% { transform: translateY(105%); }
}

@keyframes fade-out-ios {
  from { opacity: 1; }
  to { opacity: 0; }
}

.screen.slide-in-forward {
  animation: screen-slide-forward 420ms cubic-bezier(0.18, 0.9, 0.2, 1.04) both;
}

.screen.slide-in-backward {
  animation: screen-slide-backward 420ms cubic-bezier(0.18, 0.9, 0.2, 1.04) both;
}

@keyframes screen-slide-forward {
  0% { opacity: 0.58; transform: translateX(30px) scale(0.992); }
  72% { opacity: 1; transform: translateX(-2px) scale(1); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes screen-slide-backward {
  0% { opacity: 0.58; transform: translateX(-30px) scale(0.992); }
  72% { opacity: 1; transform: translateX(2px) scale(1); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* Animated launch screen */
.boot-splash {
  position: absolute;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  background: #0f1512;
}

.boot-logo {
  width: min(72%, 330px);
  height: auto;
  overflow: visible;
}

.boot-u-path {
  fill: none;
  stroke: #fff;
  stroke-width: 104;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: boot-u-draw 920ms cubic-bezier(0.4, 0, 0.2, 1) 100ms both;
}

.boot-dot {
  fill: #dcebdd;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: boot-dot-enter 380ms cubic-bezier(0.2, 0.9, 0.2, 1.18) 1000ms both;
}

.boot-splash.is-leaving {
  animation: boot-splash-out 340ms ease 0ms forwards;
}

@keyframes boot-u-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes boot-dot-enter {
  0% { opacity: 0; transform: scale(0); }
  42% { opacity: 1; transform: scale(1.24); }
  62% { transform: scale(0.82); }
  80% { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes boot-splash-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* iPhone PWA safe area and standalone layout */
@supports (padding: max(0px)) {
  @media (max-width: 560px) {
    .app-shell {
      padding-top: max(20px, env(safe-area-inset-top));
    }
  }
}

@media all and (display-mode: standalone) and (max-width: 560px) {
  body {
    background: var(--paper);
  }

  .phone-frame {
    height: 100dvh;
  }
}

/* Compact entry sheet for phones */
@media (max-width: 560px) and (max-height: 940px) {
  .bottom-sheet {
    max-height: 100%;
    border-radius: 26px 26px 0 0;
  }

  .sheet-handle {
    margin: 6px auto 2px;
  }

  .sheet-head {
    padding: 1px 13px 3px;
  }

  .sheet-head .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
  }

  .sheet-body {
    padding: 4px 17px max(8px, env(safe-area-inset-bottom));
  }

  .entry-type {
    margin-bottom: 5px;
  }

  .amount-display {
    min-height: 54px;
    padding: 2px 0 4px;
    font-size: 39px;
  }

  .entry-hint {
    margin: -1px 0 5px;
    font-size: 9px;
  }

  .category-grid {
    gap: 5px 6px;
    margin: 3px 0 8px;
  }

  .category-choice {
    gap: 3px;
    font-size: 10px;
  }

  .category-choice .category-icon {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }

  .category-choice .category-icon svg {
    width: 18px;
    height: 18px;
  }

  .entry-optional {
    gap: 6px;
    margin-bottom: 8px;
  }

  .compact-field {
    min-height: 40px;
    border-radius: 12px;
    padding: 0 11px;
  }

  .compact-field input {
    height: 38px;
  }

  .keypad {
    gap: 5px;
  }

  .key {
    min-height: 42px;
    border-radius: 12px;
    font-size: 18px;
  }

  .save-entry {
    min-height: 46px;
    margin-top: 8px;
  }

  .sheet-note {
    margin: 5px 0 0;
    font-size: 9px;
  }
}
