/* ============ Themes ============ */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --r-lg: 24px; --r-md: 18px; --r-sm: 12px;
  --ease: cubic-bezier(.22, .9, .3, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --income: #12A26B; --expense: #E5484D; --transfer: #3B7BF2;
}

/* Emerald (default) */
html[data-theme="emerald"] { --accent: #0B8F63; --accent-2: #1FBF8A; --accent-deep: #065F46; --accent-soft: #E3F4EC; --on-accent: #fff;
  --bg: #F3F5F2; --card: #FFFFFF; --card-2: #F0F3EF; --text: #0D1A15; --text-2: #4F5E57; --text-3: #8A968F; --line: #E3E8E4; --track: #E9EEEA; }
html[data-theme="emerald"][data-scheme="dark"] { --accent: #2FCB92; --accent-2: #1C9E70; --accent-deep: #0B3D2C; --accent-soft: #11291F; --on-accent: #04130D;
  --bg: #080C0A; --card: #121916; --card-2: #19221E; --text: #EDF4F0; --text-2: #A9B7B0; --text-3: #6E7C75; --line: #1F2A25; --track: #1C2621; }

/* Lagoon */
html[data-theme="lagoon"] { --accent: #0A7EA4; --accent-2: #2BB5D6; --accent-deep: #0B4A63; --accent-soft: #E1F1F7; --on-accent: #fff;
  --bg: #F2F5F7; --card: #FFFFFF; --card-2: #EEF3F6; --text: #0B1A22; --text-2: #4B5E69; --text-3: #8696A0; --line: #E1E8ED; --track: #E7EEF2; }
html[data-theme="lagoon"][data-scheme="dark"] { --accent: #4CC9E8; --accent-2: #1B8DB0; --accent-deep: #0A3445; --accent-soft: #0F2630; --on-accent: #031218;
  --bg: #070B0E; --card: #10171C; --card-2: #172027; --text: #EAF3F7; --text-2: #A3B4BE; --text-3: #6A7C87; --line: #1D2A32; --track: #1A252C; }

/* Apricot */
html[data-theme="apricot"] { --accent: #D9583B; --accent-2: #F29A54; --accent-deep: #8A2E1A; --accent-soft: #FBEAE2; --on-accent: #fff;
  --bg: #F8F4F0; --card: #FFFFFF; --card-2: #F5EFEA; --text: #23140F; --text-2: #6A5850; --text-3: #A29188; --line: #EEE5DF; --track: #F1E9E3; }
html[data-theme="apricot"][data-scheme="dark"] { --accent: #FF8A62; --accent-2: #C9542F; --accent-deep: #4A1E10; --accent-soft: #2A1710; --on-accent: #1E0A04;
  --bg: #0E0A08; --card: #1A1310; --card-2: #231A16; --text: #F8EEE9; --text-2: #C2AEA5; --text-3: #85736B; --line: #2C211C; --track: #281E19; }

/* Iris */
html[data-theme="iris"] { --accent: #5B4BDB; --accent-2: #9A7CF4; --accent-deep: #2E2385; --accent-soft: #ECE9FB; --on-accent: #fff;
  --bg: #F4F3F8; --card: #FFFFFF; --card-2: #F0EFF6; --text: #15132A; --text-2: #575470; --text-3: #918EA7; --line: #E5E3EE; --track: #EAE8F2; }
html[data-theme="iris"][data-scheme="dark"] { --accent: #A694FF; --accent-2: #6B55E0; --accent-deep: #231B5E; --accent-soft: #1B1834; --on-accent: #0D0A22;
  --bg: #09080F; --card: #13121D; --card-2: #1B1A28; --text: #EEEDF7; --text-2: #AEABC4; --text-3: #737089; --line: #23222F; --track: #201F2C; }

html[data-scheme="dark"] { --income: #3DD68C; --expense: #FF6B6B; --transfer: #6EA2FF; color-scheme: dark; }
html { --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 8px 24px -12px rgba(16, 24, 20, .12); --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .35); }
html[data-scheme="dark"] { --shadow: 0 0 0 1px rgba(255, 255, 255, .03); }

/* ============ Base ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; transition: background-color .3s var(--ease), color .3s var(--ease); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea, select { font-size: 16px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; letter-spacing: -0.01em; }
.hidden { display: none !important; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pos { color: var(--income); } .neg { color: var(--expense); } .tr { color: var(--transfer); }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; position: relative; }
.screen { padding: calc(var(--safe-t) + 10px) 18px calc(var(--safe-b) + 110px); }
.screen.enter > * { animation: rise .45s var(--ease) both; }
.screen.enter > *:nth-child(2) { animation-delay: 40ms; } .screen.enter > *:nth-child(3) { animation-delay: 80ms; }
.screen.enter > *:nth-child(4) { animation-delay: 120ms; } .screen.enter > *:nth-child(5) { animation-delay: 160ms; }
.screen.enter > *:nth-child(n+6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ Top bar ============ */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 52px; margin-bottom: 6px; }
.topbar h1 { font-family: var(--font-display); font-size: 30px; font-weight: 750; letter-spacing: -0.025em; margin: 0; }
.topbar .sub { font-size: 13px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--text);
  box-shadow: var(--shadow); transition: transform .15s var(--ease), background .2s; }
.icon-btn:active { transform: scale(.92); }
.back-row { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.back-row .title { font-weight: 650; font-size: 17px; flex: 1; text-align: center; margin-right: 42px; }

/* Month switcher */
.month { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 14px; }
.month .lbl { font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -0.015em; padding: 6px 12px; border-radius: 12px; display: inline-flex; gap: 6px; align-items: center; }
.month .lbl:active { background: var(--card-2); }
.month .lbl small { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 99px; }
.month .arrow { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); background: var(--card); box-shadow: var(--shadow); }
.month .arrow:active { transform: scale(.9); }
.month .arrow:disabled { opacity: .3; }
.slide-l { animation: slideL .32s var(--ease); } .slide-r { animation: slideR .32s var(--ease); }
@keyframes slideL { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes slideR { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

/* ============ Cards ============ */
.card { background: var(--card); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-h h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card-h .link { color: var(--accent); font-weight: 600; font-size: 14px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 10px; }
.press { transition: transform .18s var(--ease); }
.press:active { transform: scale(.975); }

/* Hero */
.hero { position: relative; overflow: hidden; border-radius: 28px; padding: 22px 20px 18px; color: #fff; margin-bottom: 14px;
  background: radial-gradient(120% 140% at 100% 0%, var(--accent-2) 0%, transparent 55%), linear-gradient(150deg, var(--accent) 0%, var(--accent-deep) 100%);
  box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--accent) 70%, transparent); }
html[data-scheme="dark"] .hero { color: #fff; background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 55%, transparent) 0%, transparent 60%), linear-gradient(150deg, var(--accent-2) 0%, var(--accent-deep) 100%); }
.hero::after { content: ""; position: absolute; width: 220px; height: 220px; right: -70px; bottom: -110px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 0 0 28px rgba(255, 255, 255, .04); }
.hero .k { font-size: 14px; opacity: .85; font-weight: 550; }
.hero .big { font-family: var(--font-display); font-size: 44px; font-weight: 760; letter-spacing: -0.035em; line-height: 1.08; margin: 4px 0 18px; }
.hero .split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; z-index: 1; }
.hero .pill { background: rgba(255, 255, 255, .14); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-radius: 18px; padding: 12px 14px; }
.hero .pill .t { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 6px; font-weight: 550; }
.hero .pill .v { font-size: 20px; font-weight: 700; margin-top: 2px; letter-spacing: -0.02em; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.hero .ratio { height: 6px; border-radius: 9px; background: rgba(255, 255, 255, .18); margin-top: 16px; overflow: hidden; position: relative; z-index: 1; }
.hero .ratio i { display: block; height: 100%; border-radius: 9px; background: #fff; transform-origin: left; animation: grow .9s var(--ease) .15s both; }
.hero .ratio-l { font-size: 12.5px; opacity: .85; margin-top: 8px; position: relative; z-index: 1; }
@keyframes grow { from { transform: scaleX(0); } }

/* Total card */
.total-card { display: flex; align-items: center; gap: 14px; }
.total-card .ic { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 22px; }
.total-card .t { font-size: 14px; color: var(--text-2); }
.total-card .v { font-size: 21px; font-weight: 720; letter-spacing: -0.02em; }
.total-card .chev { margin-left: auto; color: var(--text-3); }

/* Categories breakdown */
.stack-bar { display: flex; gap: 3px; height: 12px; border-radius: 8px; overflow: hidden; margin: 2px 0 12px; }
.stack-bar i { display: block; height: 100%; min-width: 4px; border-radius: 3px; transform-origin: left; animation: grow .8s var(--ease) both; }
.breakdown { display: flex; gap: 18px; align-items: center; }
.donut { position: relative; flex: none; }
.donut-seg { animation: donutIn .9s var(--ease) both; }
@keyframes donutIn { from { stroke-dasharray: 0 var(--c); } }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center .s { font-size: 12px; color: var(--text-3); font-weight: 600; }
.donut-center .v { font-size: 17px; font-weight: 750; letter-spacing: -0.02em; }
.cat-rows { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cat-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 12px; text-align: left; width: 100%; }
.cat-row:active { background: var(--card-2); }
.cat-row .e { font-size: 18px; width: 26px; text-align: center; }
.cat-row .n { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-row .v { font-size: 14.5px; font-weight: 650; }
.cat-row .bar-wrap { height: 4px; background: var(--track); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.cat-row .bar-wrap i { display: block; height: 100%; border-radius: 4px; transform-origin: left; animation: grow .8s var(--ease) both; }
.cat-row .mid { flex: 1; min-width: 0; }
.cat-row .top-line { display: flex; gap: 8px; align-items: baseline; }
@media (max-width: 380px) { .breakdown { flex-direction: column; } .cat-rows { width: 100%; } }

/* ============ Transactions ============ */
.tx-list { display: flex; flex-direction: column; }
.tx { display: flex; align-items: center; gap: 13px; padding: 10px 4px; border-radius: 16px; width: 100%; text-align: left; transition: background .15s; }
.tx:active { background: var(--card-2); }
.tx .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; flex: none; background: var(--card-2); }
.ic.transfer { background: color-mix(in srgb, var(--transfer) 13%, transparent); color: var(--transfer); }
.ic.income { background: color-mix(in srgb, var(--income) 13%, transparent); }
.tx .mid { flex: 1; min-width: 0; }
.tx .t { font-weight: 620; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .s { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.tx .a { font-weight: 700; font-size: 15.5px; white-space: nowrap; }
.tx.fresh { animation: fresh 1.4s var(--ease); }
@keyframes fresh { 0% { background: var(--accent-soft); transform: scale(.97); } 30% { transform: none; } 100% { background: transparent; } }
.day-h { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; color: var(--text-3); padding: 16px 6px 4px; text-transform: none; }
.day-h:first-child { padding-top: 2px; }
.day-group { background: var(--card); border-radius: var(--r-lg); padding: 6px 10px; box-shadow: var(--shadow); }
.more-link { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 12px; margin-top: 4px; color: var(--accent); font-weight: 650; font-size: 15px; width: 100%; border-radius: 14px; }
.more-link:active { background: var(--accent-soft); }

/* Empty */
.empty { text-align: center; padding: 34px 20px; color: var(--text-3); }
.empty .e { font-size: 42px; margin-bottom: 8px; }
.empty .t { color: var(--text); font-weight: 650; font-size: 17px; margin-bottom: 4px; }
.empty p { margin: 0 0 16px; font-size: 14.5px; }

/* ============ Accounts ============ */
.acc-total { text-align: center; padding: 10px 0 18px; }
.acc-total .k { color: var(--text-2); font-size: 14.5px; font-weight: 550; }
.acc-total .v { font-family: var(--font-display); font-size: 42px; font-weight: 760; letter-spacing: -0.035em; }
.acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acc-card { background: var(--card); border-radius: 22px; padding: 16px; text-align: left; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; min-height: 132px; position: relative; overflow: hidden; }
.acc-card .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 23px; background: var(--card-2); }
.acc-card .n { font-weight: 640; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-card .ty { font-size: 12.5px; color: var(--text-3); }
.acc-card .v { font-size: 19px; font-weight: 730; letter-spacing: -0.02em; margin-top: auto; }
.acc-card.add { align-items: center; justify-content: center; color: var(--accent); border: 1.5px dashed color-mix(in srgb, var(--accent) 40%, transparent); background: transparent; box-shadow: none; font-weight: 650; gap: 8px; }
.acc-card.add .plus { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; }
.archived-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; }
.archived-row .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; font-size: 19px; opacity: .7; }
.archived-row .n { flex: 1; font-weight: 600; color: var(--text-2); }

.acc-hero { text-align: center; padding: 4px 0 18px; }
.acc-hero .ic { width: 68px; height: 68px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 34px; margin: 0 auto 10px; }
.acc-hero .n { font-weight: 650; font-size: 17px; }
.acc-hero .ty { font-size: 13px; color: var(--text-3); }
.acc-hero .v { font-family: var(--font-display); font-size: 40px; font-weight: 760; letter-spacing: -0.03em; margin-top: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--card-2); color: var(--text-2); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border-radius: 18px; padding: 13px 14px; box-shadow: var(--shadow); }
.tile .t { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.tile .v { font-size: 18px; font-weight: 720; margin-top: 3px; letter-spacing: -0.02em; }

/* ============ Controls ============ */
.seg { display: flex; background: var(--card-2); border-radius: 14px; padding: 3px; gap: 2px; position: relative; }
.seg button { flex: 1; padding: 9px 6px; border-radius: 11px; font-size: 14.5px; font-weight: 600; color: var(--text-2); transition: background .2s, color .2s, box-shadow .2s; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
html[data-scheme="dark"] .seg button.on { background: #ffffff1c; }
.seg.kind button.on[data-v="income"] { color: var(--income); } .seg.kind button.on[data-v="expense"] { color: var(--expense); } .seg.kind button.on[data-v="transfer"] { color: var(--transfer); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 9px 13px; border-radius: 99px; background: var(--card-2); font-weight: 600; font-size: 14px; white-space: nowrap; color: var(--text-2); transition: background .15s, color .15s, transform .15s; flex: none; }
.chip:active { transform: scale(.95); }
.chip.on { background: var(--accent); color: var(--on-accent); }
.chip .x { opacity: .7; margin-left: 2px; }
.grid-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gchip { background: var(--card-2); border-radius: 16px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: center; line-height: 1.2; border: 2px solid transparent; transition: border-color .15s, background .15s, transform .15s; min-height: 72px; justify-content: center; }
.gchip .e { font-size: 22px; }
.gchip:active { transform: scale(.95); }
.gchip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.gchip small { font-size: 11.5px; color: var(--text-3); font-weight: 600; }

.field { margin-bottom: 14px; }
.field > label, .lbl-s { display: block; font-size: 13px; font-weight: 650; color: var(--text-2); margin: 0 4px 7px; }
.input { width: 100%; background: var(--card-2); border: 1.5px solid transparent; border-radius: 14px; padding: 13px 14px; outline: none; transition: border-color .2s, background .2s; -webkit-appearance: none; appearance: none; }
.input:focus { border-color: var(--accent); background: var(--card); }
textarea.input { resize: none; min-height: 70px; }
.amount-box { text-align: center; padding: 8px 0 14px; }
.amount-box .wrap { display: inline-flex; align-items: baseline; justify-content: center; gap: 6px; max-width: 100%; }
.amount-box input { font-family: var(--font-display); font-size: 52px; font-weight: 760; letter-spacing: -0.035em; text-align: center; border: 0; outline: 0; background: none; min-width: .8em; max-width: 78vw; padding: 0; caret-color: var(--accent); font-variant-numeric: tabular-nums; }
.amount-box input::placeholder { color: var(--text-3); opacity: .5; }
.amount-box .cur { font-size: 26px; font-weight: 700; color: var(--text-3); }
.amount-box.income input { color: var(--income); } .amount-box.expense input { color: var(--expense); } .amount-box.transfer input { color: var(--transfer); }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.suggest button { font-size: 13px; padding: 6px 11px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swap { display: flex; justify-content: center; margin: -4px 0 6px; color: var(--transfer); }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px 18px; border-radius: 16px; font-weight: 680; font-size: 16.5px; background: var(--accent); color: var(--on-accent); transition: transform .15s var(--ease), opacity .2s, filter .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--expense) 12%, transparent); color: var(--expense); }
.btn.danger-solid { background: var(--expense); color: #fff; }
.btn.small { padding: 10px 14px; font-size: 14.5px; border-radius: 13px; width: auto; display: inline-flex; }
.btn .spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-direction: column; gap: 10px; }
.err { color: var(--expense); font-size: 14px; margin: 0 4px 12px; font-weight: 550; }

/* List (settings) */
.list { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.li { display: flex; align-items: center; gap: 13px; padding: 13px 16px; width: 100%; text-align: left; min-height: 54px; position: relative; }
.li + .li::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--line); }
.li:active { background: var(--card-2); }
.li .ic { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; background: var(--card-2); flex: none; }
.li .ic svg { width: 18px; height: 18px; }
.li .n { flex: 1; font-weight: 560; }
.li .n small { display: block; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.li .v { color: var(--text-3); font-size: 15px; }
.li .chev { color: var(--text-3); width: 18px; height: 18px; }
.li.muted .n { color: var(--text-3); }
.switch { width: 51px; height: 31px; border-radius: 99px; background: var(--track); position: relative; transition: background .25s; flex: none; }
.switch::after { content: ""; position: absolute; width: 27px; height: 27px; border-radius: 50%; background: #fff; top: 2px; left: 2px; box-shadow: 0 2px 5px rgba(0, 0, 0, .2); transition: transform .3s var(--spring); }
.switch.on { background: var(--income); }
.switch.on::after { transform: translateX(20px); }

/* Themes picker */
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme { border-radius: 18px; padding: 12px; background: var(--card); box-shadow: var(--shadow); text-align: left; border: 2px solid transparent; transition: border-color .2s, transform .15s; }
.theme:active { transform: scale(.97); }
.theme.on { border-color: var(--accent); }
.theme .sw { height: 54px; border-radius: 12px; margin-bottom: 9px; position: relative; overflow: hidden; }
.theme .sw i { position: absolute; right: 8px; bottom: 8px; width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, .85); }
.theme .n { font-weight: 650; font-size: 14.5px; }
.theme .d { font-size: 12px; color: var(--text-3); }

/* ============ Bottom nav ============ */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 0 12px calc(var(--safe-b) + 8px); pointer-events: none; }
.nav-in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; pointer-events: auto;
  background: color-mix(in srgb, var(--card) 82%, transparent); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-radius: 26px; padding: 6px 4px; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .22), 0 0 0 1px color-mix(in srgb, var(--text) 6%, transparent); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 5px; color: var(--text-3); text-decoration: none; font-size: 11px; font-weight: 620; transition: color .2s; border-radius: 16px; }
.nav a.on { color: var(--accent); }
.nav a:active svg { transform: scale(.88); }
.nav a svg { transition: transform .15s; width: 24px; height: 24px; }
.nav .add { position: relative; }
.nav .add span.b { width: 58px; height: 58px; border-radius: 20px; margin-top: -30px; display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(145deg, var(--accent-2), var(--accent)); box-shadow: 0 10px 22px -6px color-mix(in srgb, var(--accent) 75%, transparent), 0 0 0 5px var(--bg); transition: transform .2s var(--spring); }
.nav .add:active span.b { transform: scale(.9) rotate(90deg); }
.nav .add svg { width: 28px; height: 28px; stroke-width: 2.4; }
.nav .add { color: var(--text-2); }

/* ============ Sheets & dialogs ============ */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .38); z-index: 50; animation: fade .25s var(--ease); }
.backdrop.out { opacity: 0; transition: opacity .25s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 560px; margin: 0 auto; background: var(--bg); border-radius: 28px 28px 0 0;
  max-height: calc(100% - var(--safe-t) - 18px); display: flex; flex-direction: column; animation: sheetIn .42s var(--ease); box-shadow: var(--shadow-lg); }
html[data-scheme="dark"] .sheet { background: var(--card); }
.sheet.out { transform: translateY(105%); transition: transform .28s var(--ease); }
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet .grab { padding: 9px 0 3px; display: flex; justify-content: center; flex: none; touch-action: none; }
.sheet .grab i { width: 38px; height: 5px; border-radius: 9px; background: var(--text-3); opacity: .35; }
.sheet .sh { display: flex; align-items: center; justify-content: space-between; padding: 2px 18px 10px; flex: none; touch-action: none; }
.sheet .sh h2 { margin: 0; font-size: 19px; font-weight: 720; letter-spacing: -0.015em; }
.sheet .sb { overflow-y: auto; padding: 4px 18px calc(var(--safe-b) + 20px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet .close { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; color: var(--text-2); }
.sheet .close svg { width: 17px; height: 17px; }
.sheet .foot { padding: 10px 18px calc(var(--safe-b) + 14px); flex: none; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; left: 50%; right: auto; width: 520px; border-radius: 28px; transform: translate(-50%, -50%); animation: popIn .32s var(--ease); max-height: 88vh; }
  .sheet.out { transform: translate(-50%, -46%); opacity: 0; transition: all .22s var(--ease); }
  .sheet .grab { display: none; } .sheet .sh { padding-top: 18px; }
  @keyframes popIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.98); } }
}

.confirm { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.confirm .box { background: var(--card); border-radius: 26px; padding: 22px 20px 16px; width: 100%; max-width: 360px; box-shadow: var(--shadow-lg); animation: popC .3s var(--spring); text-align: center; }
@keyframes popC { from { opacity: 0; transform: scale(.9); } }
.confirm .ico { font-size: 38px; margin-bottom: 6px; }
.confirm h3 { margin: 0 0 6px; font-size: 18px; font-weight: 720; }
.confirm p { margin: 0 0 18px; color: var(--text-2); font-size: 14.5px; }

.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%); z-index: 80; background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 99px; font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow-lg); animation: toastIn .4s var(--spring); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.toast.out { opacity: 0; transform: translate(-50%, -10px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -16px) scale(.95); } }

/* Detail */
.detail-top { text-align: center; padding: 6px 0 18px; }
.detail-top .ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 30px; margin: 0 auto 10px; background: var(--card-2); }
html:not([data-scheme="dark"]) .sheet .detail-top .ic { background: var(--card); box-shadow: var(--shadow); }
.detail-top .a { font-family: var(--font-display); font-size: 40px; font-weight: 760; letter-spacing: -0.03em; }
.detail-top .t { font-weight: 650; font-size: 17px; margin-top: 2px; }
.kv { background: var(--card); border-radius: 20px; padding: 4px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
html[data-scheme="dark"] .sheet .kv, html[data-scheme="dark"] .sheet .list { background: var(--card-2); }
.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; font-size: 15px; }
.kv div + div { border-top: 1px solid var(--line); }
.kv span:first-child { color: var(--text-3); }
.kv span:last-child { font-weight: 600; text-align: right; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 12px; font-size: 22px; display: grid; place-items: center; background: var(--card-2); border: 2px solid transparent; }
.emoji-grid button.on { border-color: var(--accent); background: var(--accent-soft); }
html[data-scheme="dark"] .sheet .input, html[data-scheme="dark"] .sheet .chip, html[data-scheme="dark"] .sheet .gchip, html[data-scheme="dark"] .sheet .emoji-grid button, html[data-scheme="dark"] .sheet .seg { background: #ffffff0d; }
html[data-scheme="dark"] .sheet .gchip.on, html[data-scheme="dark"] .sheet .emoji-grid button.on { background: var(--accent-soft); }
html[data-scheme="dark"] .sheet .chip.on { background: var(--accent); }

.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.month-grid button { padding: 14px 4px; border-radius: 14px; background: var(--card-2); font-weight: 620; font-size: 15px; }
.month-grid button.on { background: var(--accent); color: var(--on-accent); }
.month-grid button:disabled { opacity: .35; }
.year-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 720; font-size: 18px; }

/* Search */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 0 12px; box-shadow: var(--shadow); flex: 1; }
.search svg { color: var(--text-3); width: 19px; height: 19px; }
.search input { border: 0; outline: 0; background: none; flex: 1; padding: 12px 0; min-width: 0; }
.tools { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-btn { position: relative; width: 46px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; }
.filter-btn b { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--card); }
.hint { font-size: 13px; color: var(--text-3); margin: 0 4px 10px; }
.sum-bar { display: flex; gap: 14px; font-size: 13.5px; color: var(--text-2); margin: 0 4px 12px; flex-wrap: wrap; }
.sum-bar b { font-weight: 700; }

/* Stats */
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.chart .grid.base { stroke-dasharray: none; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-weight: 600; font-family: var(--font); }
.chart .axis-active { fill: var(--text); font-weight: 750; }
.chart .bar { transform-box: fill-box; transform-origin: bottom; animation: barIn .7s var(--ease) both; }
@keyframes barIn { from { transform: scaleY(0); } }
.chart .area-line { stroke-dasharray: 1; animation: draw 1.2s var(--ease) both; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.chart .area-fill { animation: fade 1s var(--ease) .3s both; }
.chart .area-dot { animation: fade .4s 1s both; }
.insights { display: grid; gap: 10px; }
.insight { display: flex; gap: 13px; align-items: center; background: var(--card); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow); text-align: left; width: 100%; }
.insight .e { font-size: 24px; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--card-2); flex: none; }
.insight .k { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.insight .t { font-weight: 640; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight .mid { flex: 1; min-width: 0; }
.insight .v { font-weight: 720; white-space: nowrap; }
.big-num { font-size: 26px; font-weight: 750; letter-spacing: -0.025em; margin: -4px 0 10px; }
.big-num small { font-size: 13.5px; color: var(--text-3); font-weight: 600; letter-spacing: 0; margin-left: 4px; }

/* ============ Auth & lock ============ */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(var(--safe-t) + 30px) 24px calc(var(--safe-b) + 30px); max-width: 420px; margin: 0 auto; animation: rise .5s var(--ease); }
.logo { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; margin: 0 auto 18px; color: #fff;
  background: radial-gradient(100% 100% at 100% 0%, var(--accent-2), transparent 60%), linear-gradient(150deg, var(--accent), var(--accent-deep));
  box-shadow: 0 16px 34px -14px color-mix(in srgb, var(--accent) 80%, transparent); }
.logo svg { width: 38px; height: 38px; stroke-width: 2.1; }
.auth h1 { text-align: center; margin: 0 0 6px; font-family: var(--font-display); font-size: 30px; letter-spacing: -0.025em; }
.auth .lead { text-align: center; color: var(--text-2); margin: 0 0 28px; }
.auth .switch-mode { text-align: center; margin-top: 16px; color: var(--text-2); font-size: 15px; }
.auth .switch-mode button { color: var(--accent); font-weight: 650; }
.auth .input { background: var(--card); box-shadow: var(--shadow); }

.lock { position: fixed; inset: 0; z-index: 90; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 20px) 24px calc(var(--safe-b) + 20px); animation: fade .2s; }
.lock .logo { margin-bottom: 14px; width: 64px; height: 64px; border-radius: 20px; }
.lock h2 { margin: 0 0 4px; font-size: 21px; font-weight: 720; }
.lock .msg { color: var(--text-2); font-size: 15px; min-height: 22px; margin-bottom: 22px; text-align: center; }
.lock .msg.bad { color: var(--expense); }
.pin-dots { display: flex; gap: 16px; margin-bottom: 34px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-3); transition: background .15s, border-color .15s, transform .15s; }
.pin-dots i.f { background: var(--accent); border-color: var(--accent); transform: scale(1.1); }
.pin-dots.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 30px; font-weight: 500; display: grid; place-items: center; transition: transform .1s, background .15s; }
.keypad button:active { transform: scale(.9); background: var(--accent-soft); }
.keypad button.plain { background: none; box-shadow: none; font-size: 15px; font-weight: 600; color: var(--text-2); }
.keypad button.plain svg { width: 30px; height: 30px; }
.lock .alt { margin-top: 26px; color: var(--accent); font-weight: 600; font-size: 15px; }

.splash { min-height: 100vh; display: grid; place-items: center; }
.splash .logo { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .8; } }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--income); display: inline-block; }
.sync-dot.off { background: var(--text-3); }
.sync-dot.busy { background: var(--accent); animation: pulse 1s infinite; }

@media (min-width: 900px) {
  .screen { padding-top: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
