/* ============ Tokens ============ */
:root {
  --navy-900: #00072D;
  --navy-800: #001C55;
  --navy-700: #0A2472;
  --blue-500: #0E6BA8;
  --frost-200: #A6E1FA;

  --bg: #F2F8FD;
  --bg-accent: radial-gradient(1200px 600px at 100% -10%, rgba(166,225,250,.55), transparent 60%), radial-gradient(900px 500px at -10% 0%, rgba(14,107,168,.10), transparent 60%);
  --surface: #FFFFFF;
  --surface-2: #EAF3FB;
  --surface-3: #DCEBF7;
  --border: #DFE9F3;
  --text: #00072D;
  --text-2: #43557A;
  --text-3: #66758F;
  --primary: #0E6BA8;
  --primary-hover: #0A5A8F;
  --primary-soft: rgba(14,107,168,.10);
  --on-primary: #FFFFFF;
  --income: #12A36B;
  --income-soft: rgba(18,163,107,.12);
  --expense: #E5485F;
  --expense-soft: rgba(229,72,95,.11);
  --warn: #D98C00;
  --warn-soft: rgba(217,140,0,.12);
  --shadow-sm: 0 1px 2px rgba(0,7,45,.06), 0 1px 1px rgba(0,7,45,.04);
  --shadow: 0 10px 30px -12px rgba(0,28,85,.18), 0 2px 6px rgba(0,7,45,.05);
  --shadow-lg: 0 30px 60px -20px rgba(0,28,85,.35);
  --card-grad: linear-gradient(135deg, #001C55 0%, #0A2472 48%, #0E6BA8 100%);
  --tabbar-bg: rgba(255,255,255,.72);
  --backdrop: rgba(0,7,45,.42);
  --glass-bg: rgba(255,255,255,.6);
  --glass-border: rgba(255,255,255,.85);
  --glass-hi: rgba(255,255,255,.9);
  --glass-shadow: rgba(14,107,168,.45);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Poppins', 'Inter', system-ui, sans-serif;
  --font-num: 'Manrope', 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(.22,1,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #00072D;
    --bg-accent: radial-gradient(1100px 600px at 100% -10%, rgba(14,107,168,.30), transparent 60%), radial-gradient(900px 600px at -10% 10%, rgba(10,36,114,.55), transparent 60%);
    --surface: #04103E;
    --surface-2: #0A1A52;
    --surface-3: #102665;
    --border: rgba(166,225,250,.10);
    --text: #EAF6FD;
    --text-2: #A9BEDA;
    --text-3: #6F86AE;
    --primary: #A6E1FA;
    --primary-hover: #C4ECFC;
    --primary-soft: rgba(166,225,250,.12);
    --on-primary: #00072D;
    --income: #3DDC97;
    --income-soft: rgba(61,220,151,.14);
    --expense: #FF6B81;
    --expense-soft: rgba(255,107,129,.14);
    --warn: #FFC861;
    --warn-soft: rgba(255,200,97,.14);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow: 0 12px 30px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 30px 60px -20px rgba(0,0,0,.7);
    --tabbar-bg: rgba(4,16,62,.82);
    --backdrop: rgba(0,3,20,.6);
    --glass-bg: rgba(166,225,250,.13);
    --glass-border: rgba(166,225,250,.24);
    --glass-hi: rgba(255,255,255,.14);
    --glass-shadow: rgba(166,225,250,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #00072D;
  --bg-accent: radial-gradient(1100px 600px at 100% -10%, rgba(14,107,168,.30), transparent 60%), radial-gradient(900px 600px at -10% 10%, rgba(10,36,114,.55), transparent 60%);
  --surface: #04103E;
  --surface-2: #0A1A52;
  --surface-3: #102665;
  --border: rgba(166,225,250,.10);
  --text: #EAF6FD;
  --text-2: #A9BEDA;
  --text-3: #6F86AE;
  --primary: #A6E1FA;
  --primary-hover: #C4ECFC;
  --primary-soft: rgba(166,225,250,.12);
  --on-primary: #00072D;
  --income: #3DDC97;
  --income-soft: rgba(61,220,151,.14);
  --expense: #FF6B81;
  --expense-soft: rgba(255,107,129,.14);
  --warn: #FFC861;
  --warn-soft: rgba(255,200,97,.14);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 12px 30px -14px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 60px -20px rgba(0,0,0,.7);
  --tabbar-bg: rgba(4,16,62,.82);
  --backdrop: rgba(0,3,20,.6);
  --glass-bg: rgba(166,225,250,.13);
  --glass-border: rgba(166,225,250,.24);
  --glass-hi: rgba(255,255,255,.14);
  --glass-shadow: rgba(166,225,250,.35);
  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg); background-image: var(--bg-accent); background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { max-width: 100%; display: block; }
svg { flex-shrink: 0; }
:where(svg:not([width])) { width: 1.15em; height: 1.15em; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.income-c { color: var(--income); }
.expense-c { color: var(--expense); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: rgba(14,107,168,.25); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* ============ Splash ============ */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg); transition: opacity .45s var(--ease), visibility .45s;
}
.splash img { border-radius: 22px; animation: pulse 1.6s var(--ease) infinite; }
.splash-name { font-family: var(--font-head); font-weight: 600; font-size: 20px; color: var(--text); letter-spacing: .02em; }
.splash.out { opacity: 0; visibility: hidden; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ============ App shell ============ */
.shell { display: flex; min-height: 100dvh; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .sub { font-size: 12.5px; color: var(--text-3); }
.view-host { flex: 1; position: relative; padding: 4px 16px calc(110px + var(--safe-b)); width: 100%; max-width: 1180px; margin: 0 auto; }
.view { animation: viewIn .42s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-family: var(--font-head); font-weight: 600; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, var(--navy-700), var(--blue-500)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }

/* Tab bar (mobile): 4 pages + centre add button */
.tabbar {
  position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b));
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) 76px repeat(2, minmax(0, 1fr)); align-items: center;
  height: 68px; padding: 0 6px; border-radius: 26px;
  background: var(--tabbar-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg), inset 0 1px 0 var(--glass-hi);
  backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; min-width: 0;
  color: var(--text-3); font-size: 10.5px; font-weight: 500; letter-spacing: .01em; transition: color .25s; white-space: nowrap;
}
.tab > span:not(.tab-ico) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab .l-short { display: none; }
.tab-ico {
  position: relative; display: grid; place-items: center; width: 48px; height: 30px; border-radius: 999px;
  border: 1px solid transparent; transition: background .3s var(--ease), border-color .3s, box-shadow .3s, transform .35s var(--ease-spring);
}
.tab svg { width: 21px; height: 21px; }
.tab.active { color: var(--primary); font-weight: 600; }
.tab.active .tab-ico { background: var(--glass-bg); border-color: var(--glass-border); box-shadow: inset 0 1px 0 var(--glass-hi), 0 4px 14px -6px var(--glass-shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tab:active .tab-ico { transform: scale(.9); }
.fab-slot { display: grid; place-items: center; height: 100%; }
.fab {
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(140deg, var(--navy-700), var(--blue-500));
  box-shadow: 0 14px 26px -10px rgba(14,107,168,.85), inset 0 1px 0 rgba(255,255,255,.25), 0 0 0 5px var(--bg);
  transform: translateY(-18px); transition: transform .3s var(--ease-spring), box-shadow .3s;
}
.fab svg { width: 27px; height: 27px; }
.fab:active { transform: translateY(-18px) scale(.92); }

/* Menu button + left drawer (mobile) */
.menu-btn { position: relative; margin-left: -6px; color: var(--text); background: var(--glass-bg); border: 1px solid var(--glass-border); }
.menu-btn.has-active::after { content: ''; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px var(--bg); }
.drawer-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .35s var(--ease); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(318px, 84vw); display: flex; flex-direction: column; overflow-y: auto;
  padding: calc(16px + var(--safe-t)) 14px calc(20px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 88%, transparent); border-right: 1px solid var(--glass-border);
  backdrop-filter: saturate(170%) blur(24px); -webkit-backdrop-filter: saturate(170%) blur(24px);
  box-shadow: var(--shadow-lg); border-radius: 0 28px 28px 0;
  transform: translateX(-104%); transition: transform .42s var(--ease);
}
.drawer.dragging { transition: none; }
.drawer-root.open { pointer-events: auto; }
.drawer-root.open .drawer-backdrop { opacity: 1; }
.drawer-root.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 14px 6px; }
.brand-sm { display: flex; align-items: center; gap: 10px; }
.brand-sm img { width: 36px; height: 36px; border-radius: 11px; }
.brand-sm b { font-family: var(--font-head); font-weight: 600; font-size: 17px; }
.drawer-user {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; color: var(--text);
  background: var(--card-grad); color: #fff; box-shadow: 0 14px 30px -18px rgba(10,36,114,.9);
  margin: 4px 0 18px;
}
.drawer-user .meta { flex: 1; min-width: 0; }
.drawer-user b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-user span { font-size: 12px; opacity: .7; }
.drawer-user .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.25); background: rgba(255,255,255,.15); }
.drawer-user > svg { width: 18px; height: 18px; opacity: .7; }
.drawer-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; padding: 18px 8px 8px; }
.drawer-nav { display: grid; gap: 4px; }
.drawer-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px;
  color: var(--text-2); font-weight: 500; font-size: 14.5px;
  transition: background .2s, color .2s, transform .15s var(--ease); opacity: 0; transform: translateX(-12px);
}
.drawer-root.open .drawer-link { opacity: 1; transform: none; transition: background .2s, opacity .4s var(--ease), transform .45s var(--ease); }
.drawer-root.open .drawer-nav .drawer-link:nth-child(1) { transition-delay: .05s; }
.drawer-root.open .drawer-nav .drawer-link:nth-child(2) { transition-delay: .09s; }
.drawer-root.open .drawer-nav .drawer-link:nth-child(3) { transition-delay: .13s; }
.drawer-root.open .drawer-nav .drawer-link:nth-child(4) { transition-delay: .17s; }
.drawer-root.open .drawer-nav .drawer-link:nth-child(5) { transition-delay: .21s; }
.drawer-root.open .drawer-nav .drawer-link:nth-child(n+6) { transition-delay: .25s; }
.drawer-link:hover { background: var(--surface-2); color: var(--text); }
.drawer-link.active { background: var(--primary-soft); color: var(--primary); }
.drawer-link .dl-ico { display: grid; place-items: center; color: inherit; flex-shrink: 0; }
.drawer-link .dl-ico svg { width: 20px; height: 20px; }
.drawer-link .meta { flex: 1; min-width: 0; }
.drawer-link .meta { font-weight: inherit; }


@media (min-width: 960px) { .drawer-root { display: none; } }

/* Glass press effect (any tappable icon/control) */
.glass-host { overflow: hidden; isolation: isolate; }
.glass-press {
  position: absolute; z-index: 2; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), rgba(255,255,255,.14) 60%, rgba(255,255,255,.04));
  border: 1px solid rgba(255,255,255,.45); box-shadow: inset 0 1px 1px rgba(255,255,255,.6), 0 6px 18px -6px rgba(0,28,85,.35);
  backdrop-filter: blur(6px) saturate(160%); -webkit-backdrop-filter: blur(6px) saturate(160%);
  animation: glassPress .55s var(--ease) forwards;
}
.glass-press.release { animation: glassPress .55s var(--ease) forwards, glassOut .35s ease .2s forwards; }
@keyframes glassPress { to { transform: translate(-50%, -50%) scale(1); } }
@keyframes glassOut { to { opacity: 0; } }

/* Sidebar (desktop) */
@media (min-width: 960px) {
  .sidebar {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; width: 264px; flex-shrink: 0;
    padding: 22px 16px; border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(20px);
  }
  .brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 18px; }
  .brand img { width: 40px; height: 40px; border-radius: 12px; }
  .brand b { font-family: var(--font-head); font-size: 18px; font-weight: 600; }
  .side-add { margin: 2px 4px 14px; }
  .side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 14px 12px 6px; font-weight: 600; }
  .side-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--text-2); font-weight: 500; font-size: 14.5px; transition: background .2s, color .2s;
  }
  .side-link svg { width: 20px; height: 20px; }
  .side-link:hover { background: var(--surface-2); color: var(--text); }
  .side-link.active { background: var(--primary-soft); color: var(--primary); }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; background: var(--surface-2); }
  .side-user .meta { flex: 1; min-width: 0; }
  .side-user b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-user span { font-size: 12px; color: var(--text-3); }
  .tabbar { display: none; }
  .topbar { padding: 22px 32px 14px; }
  .topbar-title h1 { font-size: 26px; }
  .view-host { padding: 6px 32px 48px; }
  .mobile-only { display: none !important; }
}
@media (max-width: 959px) { .desktop-only { display: none !important; } }

/* ============ Components ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 15.5px; }
.link-btn { font-size: 13px; font-weight: 600; color: var(--primary); display: inline-flex; align-items: center; gap: 2px; }
.link-btn svg { width: 16px; height: 16px; }
.section { margin-top: 16px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h3 { font-size: 15.5px; }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) {
  .grid-desk-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-desk-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 760px) {
  .grid-home { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  background: var(--surface-2); color: var(--text); transition: transform .15s var(--ease), background .2s, opacity .2s, box-shadow .2s;
  white-space: nowrap; user-select: none;
}
.btn svg { width: 19px; height: 19px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 20px -10px var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-grad { color: #fff; background: linear-gradient(135deg, var(--navy-700), var(--blue-500)); box-shadow: 0 10px 22px -10px rgba(14,107,168,.8); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--expense-soft); color: var(--expense); }
.btn-income { background: var(--income-soft); color: var(--income); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 11px; font-size: 13px; }
.btn-sm svg { width: 16px; height: 16px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2);
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-btn.sm svg { width: 17px; height: 17px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge.income { background: var(--income-soft); color: var(--income); }
.badge.expense { background: var(--expense-soft); color: var(--expense); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }

/* Segmented control */
.segmented {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; border-radius: 14px; background: var(--surface-2); isolation: isolate;
}
.segmented button {
  position: relative; z-index: 1; height: 38px; border-radius: 11px; font-weight: 600; font-size: 13.5px; color: var(--text-2);
  transition: color .25s;
}
.segmented button.active { color: var(--text); }
.segmented .seg-thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 11px; background: var(--surface);
  box-shadow: var(--shadow-sm); transition: transform .35s var(--ease), width .35s var(--ease);
}
.segmented.type-income button.active { color: var(--income); }
.segmented.type-expense button.active { color: var(--expense); }

/* Form */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s;
  font-size: 15px;
}
.textarea { height: auto; min-height: 80px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 46px; }
.input-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-error { color: var(--expense); font-size: 13px; font-weight: 500; min-height: 18px; margin: -4px 0 10px; }
.check {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); cursor: pointer; margin-bottom: 14px;
}
.check input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .25s; flex-shrink: 0; cursor: pointer; }
.check input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .3s var(--ease-spring); }
.check input:checked { background: var(--blue-500); }
.check input:checked::after { transform: translateX(18px); }
.check .t { flex: 1; font-size: 14px; font-weight: 500; }
.check .t small { display: block; color: var(--text-3); font-weight: 400; font-size: 12px; }

.amount-field {
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px 10px 8px; margin-bottom: 8px;
}
.amount-field input {
  width: 2ch; max-width: 100%; min-width: 1.4ch; text-align: center; border: 0; outline: none; background: transparent;
  font-family: var(--font-num); font-weight: 800; font-size: 44px; letter-spacing: -.02em; color: var(--text);
}
.amount-field input::placeholder { color: var(--text-3); opacity: .6; }
.amount-field .cur { font-family: var(--font-num); font-weight: 700; font-size: 30px; color: var(--text-3); }
.amount-field.income input { color: var(--income); }
.amount-field.expense input { color: var(--expense); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border-radius: 12px;
  background: var(--surface-2); border: 1.5px solid transparent; font-size: 13.5px; font-weight: 500; color: var(--text-2);
  transition: background .2s, border-color .2s, color .2s, transform .15s var(--ease); white-space: nowrap; flex-shrink: 0;
}
.chip:active { transform: scale(.95); }
.chip .e { font-size: 16px; line-height: 1; }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }
.chip.on.income { background: var(--income-soft); border-color: var(--income); }
.chip.on.expense { background: var(--expense-soft); border-color: var(--expense); }
.chip.add { border: 1.5px dashed var(--border); background: transparent; color: var(--primary); }
.chip .x { width: 14px; height: 14px; }
.chip-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 10px; }

/* List items */
.list { display: grid; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-radius: 14px; transition: background .15s; cursor: pointer;
  width: 100%; text-align: left;
}
.item:hover { background: var(--surface-2); }
.item:active { background: var(--surface-3); }
.item + .item { border-top: 1px solid var(--border); border-top-color: color-mix(in srgb, var(--border) 60%, transparent); }
.item:hover + .item, .item:hover { border-top-color: transparent; }
.ico {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; font-size: 21px;
  background: color-mix(in srgb, var(--c, var(--blue-500)) 16%, transparent);
}
.ico.sm { width: 36px; height: 36px; border-radius: 11px; font-size: 17px; }
.ico.lg { width: 54px; height: 54px; border-radius: 17px; font-size: 26px; }
.item .meta { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.item .amt { font-family: var(--font-num); font-weight: 700; font-size: 15px; white-space: nowrap; text-align: right; }
.item .amt small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 11.5px; color: var(--text-3); }
.day-group { margin-top: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px 6px; font-size: 12.5px; font-weight: 600; color: var(--text-3); text-transform: none; }

/* Progress */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--blue-500)); width: 0; transition: width 1s var(--ease); }
.progress.thin { height: 6px; }

/* Empty state */
.empty { text-align: center; padding: 36px 18px; color: var(--text-2); }
.empty .em { font-size: 44px; margin-bottom: 10px; display: inline-block; animation: float 3s ease-in-out infinite; }
.empty h3 { margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 14px; margin-bottom: 16px; max-width: 320px; margin-inline: auto; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Skeleton */
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============ Balance card ============ */
.balance-card {
  position: relative; overflow: hidden; border-radius: var(--radius-xl); padding: 20px 20px 16px; color: #fff;
  background: linear-gradient(140deg, rgba(14,107,168,.96) 0%, rgba(10,36,114,.94) 100%);
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), inset 0 0 0 1px rgba(166,225,250,.12), 0 18px 40px -20px rgba(14,107,168,.7);
  backdrop-filter: blur(14px) saturate(150%); -webkit-backdrop-filter: blur(14px) saturate(150%);
  display: flex; flex-direction: column; isolation: isolate;
}
.balance-card::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background: linear-gradient(160deg, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 42%);
}
.balance-card::before {
  content: ''; position: absolute; z-index: -1; width: 240px; height: 240px; border-radius: 50%; right: -100px; top: -130px;
  background: radial-gradient(circle, rgba(166,225,250,.45), rgba(166,225,250,0) 70%);
}
.balance-card .bc-top { display: flex; align-items: center; justify-content: space-between; }
.balance-card .bc-label { font-family: var(--font-head); font-size: 15.5px; color: rgba(255,255,255,.92); font-weight: 600; }
.balance-card .bc-eye { color: rgba(255,255,255,.7); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; margin: -6px -6px -6px 0; }
.balance-card .bc-eye:hover { background: rgba(255,255,255,.1); color: #fff; }
.balance-card .bc-eye svg { width: 18px; height: 18px; }
.balance-card .bc-amount { font-family: var(--font-num); font-weight: 800; font-size: clamp(32px, 9vw, 40px); letter-spacing: -.025em; line-height: 1.1; margin-top: 6px; }
.balance-card .bc-amount .dec { font-size: .5em; color: rgba(255,255,255,.7); font-weight: 700; }
.bc-flows { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.18); }
.bc-flow { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bc-flow + .bc-flow { padding-left: 16px; border-left: 1px solid rgba(255,255,255,.18); }
.bc-flow span { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 14px; font-weight: 600; color: rgba(255,255,255,.9); }
.bc-flow span svg { width: 16px; height: 16px; stroke-width: 2.2; }
.bc-flow.in span svg { color: #86EFC4; }
.bc-flow.out span svg { color: #FDA4AF; }
.bc-flow b { font-family: var(--font-num); font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blurred { filter: blur(9px); user-select: none; transition: filter .3s; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  transition: transform .2s var(--ease), box-shadow .2s; cursor: pointer; text-align: left;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat .s-top { display: flex; align-items: center; justify-content: space-between; }
.stat .s-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); }
.stat .s-ico svg { width: 18px; height: 18px; }
.stat .s-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat .s-val { font-family: var(--font-num); font-weight: 800; font-size: 19px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s-sub { font-size: 12px; color: var(--text-3); }
.trend { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; }
.trend svg { width: 14px; height: 14px; }
.trend.up { color: var(--income); }
.trend.down { color: var(--expense); }

/* Hero summary (pages) */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-xl); padding: 20px; color: #fff; background: var(--card-grad);
  box-shadow: 0 20px 40px -22px rgba(10,36,114,.8); isolation: isolate;
}
.hero::before { content: ''; position: absolute; z-index: -1; width: 260px; height: 260px; border-radius: 50%; right: -90px; top: -120px; background: radial-gradient(circle, rgba(166,225,250,.45), transparent 65%); }
.hero .h-label { font-size: 13px; opacity: .75; }
.hero .h-val { font-family: var(--font-num); font-weight: 800; font-size: clamp(25px, 7.5vw, 32px); letter-spacing: -.02em; margin-top: 2px; }
.hero .h-row { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; }
.hero .h-row div { font-size: 12px; opacity: .8; }
.hero .h-row b { display: block; font-family: var(--font-num); font-size: 15px; opacity: 1; font-weight: 700; }

/* Period nav */
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0; }
.period-nav .p-label { text-align: center; flex: 1; }
.period-nav .p-label b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.period-nav .p-label span { font-size: 12px; color: var(--text-3); }
.period-nav .icon-btn { background: var(--surface); border: 1px solid var(--border); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow .8s var(--ease) both; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis-label { fill: var(--text-3); font-size: 10.5px; font-family: var(--font-body); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover { fill: var(--primary-soft); }
.chart .sel-bg { fill: var(--primary-soft); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; padding: 8px 10px; border-radius: 12px; font-size: 12px; white-space: nowrap;
  background: var(--navy-900); color: #EAF6FD; box-shadow: var(--shadow-lg); transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .15s;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-family: var(--font-num); }
.chart-tip .r { display: flex; align-items: center; gap: 6px; }
.chart-tip .dot { width: 8px; height: 8px; border-radius: 3px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle.seg { fill: none; stroke-linecap: butt; transition: stroke-dashoffset 1s var(--ease), opacity .2s; }
.donut .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .center small { font-size: 11.5px; color: var(--text-3); }
.donut .center b { font-family: var(--font-num); font-size: 17px; font-weight: 800; }
@keyframes donutIn { from { opacity: 0; transform: rotate(-70deg) scale(.85); } to { opacity: 1; transform: none; } }
.cat-legend { flex: 1; min-width: 0; display: grid; gap: 9px; }
.cat-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.cat-row .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.cat-row .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.cat-row .v { font-family: var(--font-num); font-weight: 700; }

.cat-bar-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 9px 0; }
.cat-bar-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; margin-bottom: 6px; }
.cat-bar-row .top b { font-family: var(--font-num); }
.cat-bar-row .top span { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ Sheets ============ */
.sheet-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .3s var(--ease); backdrop-filter: blur(2px); }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .42s var(--ease); padding-bottom: var(--safe-b);
  will-change: transform;
}
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet-root.open .sheet { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-handle { width: 42px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 10px auto 0; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 18px 6px 22px; touch-action: none; }
.sheet-head h3 { flex: 1; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 8px 22px 22px; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 22px 18px; border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 640px) {
  .sheet-root { align-items: center; padding: 24px; }
  .sheet { border-radius: 26px; transform: translateY(24px) scale(.97); opacity: 0; transition: transform .35s var(--ease), opacity .25s; max-height: 88dvh; }
  .sheet-root.open .sheet { transform: none; opacity: 1; }
  .sheet-handle { display: none; }
  .sheet-head { padding-top: 18px; }
}

/* Toast */
#toast-host { position: fixed; z-index: 80; left: 0; right: 0; top: calc(12px + var(--safe-t)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 16px; max-width: 420px;
  background: var(--navy-900); color: #EAF6FD; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); border: 1px solid rgba(166,225,250,.15);
  animation: toastIn .4s var(--ease-spring) both; pointer-events: auto;
}
.toast svg { width: 18px; height: 18px; }
.toast.ok svg { color: #3DDC97; }
.toast.err svg { color: #FF6B81; }
.toast.out { animation: toastOut .3s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px) scale(.96); } }

/* ============ Auth (minimal) ============ */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background: var(--bg);
}
.auth-box { width: 100%; max-width: 380px; animation: viewIn .45s var(--ease) both; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 30px; }
.auth-logo img { width: 56px; height: 56px; border-radius: 16px; }
.auth-logo b { font-family: var(--font-head); font-size: 20px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.auth-box h2 { font-size: 24px; font-weight: 600; text-align: center; color: var(--text); }
.auth-box .sub { color: var(--text-3); font-size: 14px; text-align: center; margin: 6px 0 26px; }
.auth-box .field label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.auth-box .input { height: 50px; border-radius: 14px; background: var(--surface); }
.auth-row { display: flex; justify-content: flex-end; margin: -4px 0 16px; }
.auth-link { color: var(--primary); font-weight: 600; font-size: 13.5px; background: none; border: 0; padding: 4px 0; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-2); margin-top: 22px; }
.auth-back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 14px; font-weight: 500; background: none; border: 0; padding: 4px 0; margin-bottom: 18px; cursor: pointer; }
.auth-back svg { width: 18px; height: 18px; }
.auth-btn { width: 100%; height: 52px; border-radius: 14px; font-size: 15px; }
.auth-hint { font-size: 12.5px; color: var(--text-3); text-align: center; margin-top: 14px; line-height: 1.5; }
.rc-card { border: 1.5px dashed var(--border); border-radius: 18px; padding: 22px 16px; text-align: center; background: var(--surface); margin-bottom: 14px; }
.rc-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 24px; font-weight: 700; letter-spacing: .08em; color: var(--text); user-select: all; word-break: break-all; }
.rc-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.rc-info { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); font-size: 13px; color: var(--text); margin-bottom: 16px; line-height: 1.5; }
.rc-info svg { width: 18px; height: 18px; color: var(--warn); flex-shrink: 0; margin-top: 1px; }

/* ============ Misc page bits ============ */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); }
.search .input { padding-left: 40px; height: 44px; }
.drawer-link .dl-ico { position: relative; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) { .tile-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
  text-align: left; transition: transform .2s var(--ease), box-shadow .2s; color: var(--text);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile:active { transform: scale(.98); }
.tile .ti { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.tile .ti svg { width: 22px; height: 22px; }
.tile b { font-family: var(--font-head); font-weight: 600; font-size: 15px; }
.tile span { font-size: 12.5px; color: var(--text-3); }

.entity { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.entity-top { display: flex; align-items: center; gap: 12px; }
.entity-top .meta { flex: 1; min-width: 0; }
.entity-top .t1 { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-top .t2 { font-size: 12.5px; color: var(--text-3); }
.entity-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.entity.done { opacity: .7; }
.kv { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.kv b { font-family: var(--font-num); color: var(--text); }
.ring { position: relative; width: 58px; height: 58px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 10px; font-size: 20px; display: grid; place-items: center; border: 1.5px solid transparent; }
.emoji-grid button.on { background: var(--primary-soft); border-color: var(--primary); }
.color-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.color-grid button { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); transition: transform .2s var(--ease-spring); }
.color-grid button.on { transform: scale(1.12); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }

.collapsible-head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 6px 2px; color: var(--text-2); font-weight: 600; font-size: 14px; }
.collapsible-head svg { width: 18px; height: 18px; transition: transform .3s var(--ease); }
.collapsible-head.open svg { transform: rotate(180deg); }

.settings-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.settings-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; width: 100%; text-align: left; transition: background .15s; }
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row:hover { background: var(--surface-2); }
.settings-row .si { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.settings-row .si svg { width: 19px; height: 19px; }
.settings-row .meta { flex: 1; font-weight: 500; font-size: 14.5px; }
.settings-row .meta small { display: block; color: var(--text-3); font-weight: 400; font-size: 12.5px; }
.settings-row > svg { width: 18px; height: 18px; color: var(--text-3); }

.profile-card { display: flex; align-items: center; gap: 14px; padding: 18px; }
.profile-card .avatar { width: 56px; height: 56px; font-size: 20px; }

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

/* ============ Responsive ============ */
.grid > *, .grid-2 > *, .grid-home > *, .tile-grid > * { min-width: 0; }
.date-row { flex-wrap: wrap; }
.date-row .input { flex: 1 1 150px; }
.section-title { gap: 10px; flex-wrap: wrap; }
.entity-actions .btn { flex: 0 1 auto; }

/* Small phones (≤ 380px) */
@media (max-width: 380px) {
  body { font-size: 14.5px; }
  .topbar { padding-left: 12px; padding-right: 12px; gap: 10px; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title .sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .view-host { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; border-radius: 18px; }
  .balance-card { padding: 18px 18px 14px; border-radius: 24px; }
  .grid-2 { gap: 10px; }
  .stat { padding: 12px; }
  .stat .s-val { font-size: 16.5px; }
  .stat .s-ico { width: 30px; height: 30px; }
  .hero { padding: 16px; border-radius: 22px; }
  .hero .h-row { gap: 12px; }
  .segmented button { font-size: 12.5px; padding: 0 4px; }
  .period-nav .p-label b { font-size: 15px; }
  .entity { padding: 14px; }
  .entity-top .ico.lg, .entity-top .avatar { width: 44px; height: 44px; font-size: 20px; border-radius: 14px; }
  .entity-top .avatar { border-radius: 50%; font-size: 15px; }
  .item { gap: 10px; }
  .ico { width: 40px; height: 40px; border-radius: 13px; font-size: 19px; }
  .item .amt { font-size: 14px; }
  .donut { width: 136px !important; height: 136px !important; }
  .tabbar { left: 8px; right: 8px; padding: 0 2px; grid-template-columns: repeat(2, minmax(0, 1fr)) 62px repeat(2, minmax(0, 1fr)); height: 64px; }
  .tab { font-size: 10px; }
  .tab .l-full { display: none; }
  .tab .l-short { display: inline; }
  .tab-ico { width: 40px; height: 28px; }
  .fab { width: 52px; height: 52px; border-radius: 18px; }
  .sheet-head { padding: 10px 12px 6px 16px; }
  .sheet-body { padding: 8px 16px 18px; }
  .sheet-foot { padding: 12px 16px 14px; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .amount-field input { font-size: 38px; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
  .drawer { width: 88vw; }
}

/* Tablets (640px – 959px): mobile navigation, roomier content */
@media (min-width: 640px) and (max-width: 959px) {
  .topbar { padding-left: 24px; padding-right: 24px; }
  .view-host { padding-left: 24px; padding-right: 24px; }
  .tabbar { left: 50%; right: auto; width: 520px; transform: translateX(-50%); }
}

/* Laptops (960px – 1199px): slimmer sidebar so two columns fit */
@media (min-width: 960px) and (max-width: 1199px) {
  .sidebar { width: 224px; padding: 20px 12px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .view-host { padding-left: 24px; padding-right: 24px; }
}

/* Wide screens */
@media (min-width: 1440px) {
  .view-host { max-width: 1280px; }
}

/* Short landscape phones */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 959px) {
  .tabbar { height: 56px; bottom: calc(6px + var(--safe-b)); }
  .tab > span:not(.tab-ico) { display: none !important; }
  .fab { width: 48px; height: 48px; transform: translateY(-10px); }
  .fab:active { transform: translateY(-10px) scale(.92); }
  .view-host { padding-bottom: calc(80px + var(--safe-b)); }
  .sheet { max-height: 96dvh; }
}
.list > *, .item .meta, .cat-legend > * { min-width: 0; }
@media (max-width: 380px) { .chips.scroll { margin: 0 -12px; padding: 2px 12px; } }
/* stack donut + legend whenever its card is narrow, whatever the screen size */
.card { container-type: inline-size; }
@container (max-width: 400px) {
  .donut-wrap { flex-direction: column; }
  .cat-legend { width: 100%; }
}

/* Limits (budgets) */
.chip.limited { height: auto; min-height: 38px; padding-top: 5px; padding-bottom: 5px; }
.lim-tag { font-family: var(--font-num); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--income-soft); color: var(--income); margin-left: 2px; }
.lim-tag.over { background: var(--expense-soft); color: var(--expense); }
.chip-group-label { flex-basis: 100%; display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.chip-group-label svg { width: 14px; height: 14px; }
.chip-break { flex-basis: 100%; height: 4px; border-bottom: 1px dashed var(--border); margin-bottom: 4px; }
.budget-card { cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s; }
.budget-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.toast.warn svg { color: #FFC861; }

/* ===================== accounts ===================== */
.acc-strip { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; scroll-snap-type: x proximity; }
.acc-strip::-webkit-scrollbar { display: none; }
.acc-pill { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text); scroll-snap-align: start; min-width: 0; transition: transform .2s var(--ease); }
.acc-pill:active { transform: scale(.97); }
.acc-pill .ap-ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: color-mix(in srgb, var(--c, var(--primary)) 14%, transparent); color: var(--c, var(--primary)); }
.acc-pill .ap-ico svg { width: 18px; height: 18px; }
.acc-pill .ap-meta { display: flex; flex-direction: column; line-height: 1.2; }
.acc-pill small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.acc-pill b { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.acc-pill.add { border-style: dashed; background: transparent; box-shadow: none; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.acc-card { position: relative; overflow: hidden; isolation: isolate; border-radius: var(--radius-lg); padding: 16px; color: #fff; background: linear-gradient(140deg, color-mix(in srgb, var(--c) 92%, #00072D) 0%, color-mix(in srgb, var(--c) 55%, #00072D) 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.acc-card::before { content: ''; position: absolute; z-index: -1; width: 200px; height: 200px; border-radius: 50%; right: -70px; top: -90px; background: radial-gradient(circle, rgba(255,255,255,.28), transparent 65%); }
.acc-head { display: flex; align-items: center; gap: 10px; }
.acc-head .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc-head b { font-family: var(--font-head); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-head small { font-size: 12px; opacity: .75; }
.acc-head .icon-btn { color: #fff; background: rgba(255,255,255,.14); }
.acc-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: rgba(255,255,255,.16); }
.acc-bal { font-family: var(--font-num); font-weight: 800; font-size: 26px; letter-spacing: -.02em; }
.acc-bal.neg { color: #FFC2CB; }
.acc-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acc-card .btn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.25); color: #fff; }
.acc-card .badge.primary { background: rgba(255,255,255,.2); color: #fff; }
.acc-tag { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 11px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.acc-picker .chip { gap: 6px; }
.hero.hero-income { background: linear-gradient(135deg, #064E3B 0%, #0A7D5A 55%, #12A36B 100%); }

/* ===================== notifications ===================== */
.bell-btn { position: relative; color: var(--text); background: var(--glass-bg); border: 1px solid var(--glass-border); flex: 0 0 auto; }
.bell-badge { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--primary); color: #fff; font: 700 10px/17px var(--font-num); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.bell-badge[hidden] { display: none; }
.bell-btn.has-urgent .bell-badge { background: var(--expense); }
.bell-btn:not(:has(.bell-badge[hidden])) svg { animation: bell-ring 2.4s var(--ease) 1; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20%, 40% { transform: rotate(-12deg); } }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); border: 1px solid transparent; position: relative; }
.notif.unseen { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.notif.unseen::before { content: ''; position: absolute; left: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--primary); }
.notif.danger { border-left: 3px solid var(--expense); }
.notif.warn { border-left: 3px solid var(--warn); }
.n-ico { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--surface-3); }
.n-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.n-meta b { font-size: 14px; font-weight: 600; }
.n-meta small { font-size: 12.5px; color: var(--text-2); }
.notif .badge { flex: 0 0 auto; }
.notif-cta { display: flex; gap: 10px; align-items: center; margin-top: 14px; padding: 12px; border-radius: var(--radius); background: var(--primary-soft); font-size: 13px; }
.notif-cta span svg { width: 20px; height: 20px; color: var(--primary); }
.reset-warn { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--expense-soft); color: var(--text); font-size: 13.5px; margin-bottom: 16px; }
.reset-warn svg { width: 22px; height: 22px; color: var(--expense); flex: 0 0 auto; }
@media (min-width: 960px) { .acc-strip { margin: 0; padding: 2px 0 4px; flex-wrap: wrap; } }
@media (max-width: 380px) { .acc-strip { margin: 0 -12px; padding: 2px 12px 4px; } }

/* category line icons (same look as the menu icons) */
.cat-line { display: grid; place-items: center; width: 30px; height: 30px; color: var(--c, var(--text-2)); flex-shrink: 0; }
.cat-line svg { width: 26px; height: 26px; }
.cat-line.lg { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-2); }
.cat-line.lg svg { width: 26px; height: 26px; }
.tile .cat-line { margin-bottom: 2px; }
.emoji-grid button svg { width: 21px; height: 21px; color: var(--text-2); }
.emoji-grid button.on svg { color: var(--primary); }

/* line icons inside tiles, chips and text */
svg.li { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex-shrink: 0; }
.ico svg.li { width: 52%; height: 52%; color: var(--c, var(--blue-500)); }
.chip .e svg.li { width: 17px; height: 17px; vertical-align: middle; color: var(--text-2); }
.chip.on .e svg.li { color: currentColor; }
.chip.on.expense .e svg.li { color: var(--expense); }
.chip.on.income .e svg.li { color: var(--income); }
.ap-ico svg.li { width: 19px; height: 19px; }
.acc-ico svg.li { width: 22px; height: 22px; }
.acc-tag svg.li { width: 12px; height: 12px; }

/* home header: avatar + full name only */
.topbar-title.home-head { display: flex; align-items: center; gap: 12px; }
.home-head .avatar { width: 42px; height: 42px; font-size: 15px; flex-shrink: 0; }
.home-head .hh-name { font-family: var(--font-head); font-size: 19px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* line icon pack: empty states, notifications, rings */
.empty .em svg.li { width: 46px; height: 46px; color: var(--primary); stroke-width: 1.5; }
.n-ico svg.li { width: 20px; height: 20px; color: var(--text-2); }
.notif.danger .n-ico svg.li { color: var(--expense); }
.notif.warn .n-ico svg.li { color: var(--warn); }
.ring span svg.li { transform: none; width: 22px; height: 22px; color: var(--c); }
.kv b svg.li { width: 14px; height: 14px; }
.rc-banner span { flex: 1; }
.sheet .rc-card { margin-top: 4px; }
.sheet #rc-host h2 { font-size: 20px; text-align: center; }
.sheet #rc-host .sub { color: var(--text-3); font-size: 13.5px; text-align: center; margin: 6px 0 16px; }

/* ============ UI polish v2 ============ */
/* skeletons */
.sk-wrap { animation: viewIn .3s var(--ease) both; }
.sk-list { padding: 6px 12px; }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.sk-row + .sk-row { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.sk-ico { width: 42px; height: 42px; border-radius: 14px; flex: none; }
.sk-lines { flex: 1; display: grid; gap: 7px; }

/* staggered entrance on first render only */
.view.fresh .list > *, .view.fresh .day-group, .view.fresh .quick-actions .qa { animation: itemIn .45s var(--ease) both; }
.view.fresh .list > *:nth-child(2), .view.fresh .quick-actions .qa:nth-child(2) { animation-delay: 40ms; }
.view.fresh .list > *:nth-child(3), .view.fresh .quick-actions .qa:nth-child(3) { animation-delay: 80ms; }
.view.fresh .list > *:nth-child(4) { animation-delay: 120ms; }
.view.fresh .list > *:nth-child(5) { animation-delay: 160ms; }
.view.fresh .list > *:nth-child(n+6) { animation-delay: 200ms; }
.view.fresh .day-group:nth-of-type(2) { animation-delay: 60ms; }
.view.fresh .day-group:nth-of-type(n+3) { animation-delay: 120ms; }
@keyframes itemIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qa {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 52px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); font-family: var(--font-head); font-weight: 600; font-size: 14.5px; color: var(--text);
  transition: transform .15s var(--ease), box-shadow .2s, background .2s;
}
.qa svg { width: 18px; height: 18px; padding: 6px; box-sizing: content-box; border-radius: 10px; stroke-width: 2.1; }
.qa.in svg { color: var(--income); background: color-mix(in srgb, var(--income) 14%, transparent); }
.qa.out svg { color: var(--expense); background: color-mix(in srgb, var(--expense) 14%, transparent); }
.qa.tr svg { color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.qa:hover { box-shadow: var(--shadow-md, 0 6px 18px -10px rgba(10,36,114,.35)); }
.qa:active { transform: scale(.96); }
@media (max-width: 380px) { .qa { flex-direction: column; gap: 2px; height: 66px; font-size: 13px; } }

/* onboarding */
.onboard .card-head { margin-bottom: 10px; }
.ob-steps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; }
.ob-step { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 12px; text-align: left; color: var(--text); }
.ob-step:not([disabled]):hover { background: var(--surface-2); }
.ob-step .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ob-step .meta b { font-size: 14px; font-weight: 600; }
.ob-step .meta small { font-size: 12.5px; color: var(--text-3); }
.ob-step > svg { width: 18px; height: 18px; color: var(--text-3); }
.ob-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--primary); }
.ob-ico svg { width: 18px; height: 18px; }
.ob-steps li.done .ob-ico { background: color-mix(in srgb, var(--income) 16%, transparent); color: var(--income); }
.ob-steps li.done .meta b { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--text-3) 60%, transparent); }
.ob-step[disabled] { cursor: default; }

/* swipe rows */
.swipe { position: relative; overflow: hidden; border-radius: 14px; transition: height .3s var(--ease), opacity .3s; }
.swipe > .item { position: relative; z-index: 1; width: 100%; background: var(--surface); transition: transform .28s var(--ease), background .2s; touch-action: pan-y; }
.swipe.dragging > .item { transition: none; }
.swipe + .swipe > .item { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font-weight: 600; font-size: 13.5px; color: #fff; opacity: 0; }
.swipe-bg span { display: flex; align-items: center; gap: 6px; opacity: .6; transition: opacity .15s, transform .15s; }
.swipe-bg svg { width: 18px; height: 18px; }
.swipe.swiped-l .swipe-bg { opacity: 1; background: #E5485F; }
.swipe.swiped-r .swipe-bg { opacity: 1; background: #0E6BA8; }
.swipe.swiped-l .sw-edit, .swipe.swiped-r .sw-del { visibility: hidden; }
.swipe.armed .swipe-bg span { opacity: 1; transform: scale(1.06); }
.swipe.removing { height: 0 !important; opacity: 0; }
.swipe.gone { display: none; }
.swipe-hint { font-size: 12px; text-align: center; margin-top: 12px; }
@media (pointer: fine) { .swipe-hint { display: none !important; } }

/* undo toast */
.toast-act { margin-left: 6px; padding: 6px 10px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: #A6E1FA; background: rgba(166,225,250,.12); white-space: nowrap; }
.toast-act:hover { background: rgba(166,225,250,.22); }

/* success pop */
.success-pop { position: fixed; z-index: 90; left: 50%; top: 42%; width: 84px; height: 84px; margin: -42px 0 0 -42px; border-radius: 28px; display: grid; place-items: center; pointer-events: none;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow-lg);
  animation: popIn .95s var(--ease) both; }
.success-pop svg { width: 52px; height: 52px; fill: none; stroke: var(--income); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.success-pop.expense svg { stroke: var(--primary); }
.success-pop circle { stroke-dasharray: 145; stroke-dashoffset: 145; animation: drawLine .5s var(--ease) .05s forwards; opacity: .35; }
.success-pop path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: drawLine .35s var(--ease) .3s forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.6); } 20% { opacity: 1; transform: scale(1.04); } 30% { transform: scale(1); } 78% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.92); } }

/* privacy mode */
.privacy .num, .privacy .amt, .privacy .s-val, .privacy .h-val, .privacy .lim-tag, .privacy .bc-amount, .privacy .bc-flow b,
.privacy .donut .center b, .privacy .cat-bar-row .top b, .privacy .chart .axis-label, .privacy .chart-tip b, .privacy .kv,
.privacy .h-row b, .privacy .dh-sums, .privacy .ap-meta b, .privacy .drill-head b {
  filter: blur(8px); user-select: none;
}
.num, .amt, .s-val, .h-val, .bc-amount, .lim-tag { transition: filter .25s; }

/* donut interaction */
.donut .seg { transition: opacity .2s; cursor: pointer; }
.donut.focus .seg { opacity: .3; }
.donut.focus .seg.on { opacity: 1; }
.donut .center small { max-width: 78%; margin-inline: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-row { transition: opacity .2s; }
.donut-wrap:has(.donut.focus) .cat-row:not(.on) { opacity: .4; }

/* analytics drill-down rows */
button.cat-bar-row { grid-template-columns: auto 1fr auto; text-align: left; color: inherit; border-radius: 12px; padding: 9px 6px; margin: 0 -6px; width: calc(100% + 12px); }
button.cat-bar-row:hover { background: var(--surface-2); }
button.cat-bar-row > svg { width: 16px; height: 16px; color: var(--text-3); }
.drill-head { display: flex; align-items: center; gap: 14px; padding: 4px 0 10px; }
.drill-head small { display: block; font-size: 12.5px; color: var(--text-3); }
.drill-head b { font-size: 22px; font-family: var(--font-num); font-weight: 800; }

/* transactions: filters + day headers */
.filter-btn { position: relative; width: 44px; height: 44px; flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; }
.filter-btn.on { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.f-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: var(--surface); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.active-filters { margin: -2px 0 12px; }
.active-filters .chip svg.x { width: 14px; height: 14px; margin-left: 2px; opacity: .7; }
.day-group.card { padding: 8px 10px; }
.day-head { padding: 6px; font-size: 13px; color: var(--text-2); gap: 10px; }
.day-head .dh-date { color: var(--text-3); font-weight: 500; }
.dh-sums { display: flex; gap: 10px; font-size: 12.5px; white-space: nowrap; }
.dh-sums b { font-weight: 700; }

/* accessibility */
.item:focus-visible, .qa:focus-visible, .chip:focus-visible, .ob-step:focus-visible, button.cat-bar-row:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.swipe:has(.item:focus-visible) { overflow: visible; }
.sheet:focus { outline: none; }
