/* =====================================================================
   WellF · Smoked Glass design system
   Tokens → base → environment → glass material → layout (dock, top bar,
   bento) → components → effects. Dark is the default theme; light is optional.
   ===================================================================== */

@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations"), url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"), url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */
:root {
  /* accent palette (functional colours) */
  --emerald: #10B981; --sapphire: #3B82F6; --amber: #F59E0B; --amethyst: #8B5CF6; --crimson: #BE123C;
  --emerald-rgb: 16, 185, 129; --sapphire-rgb: 59, 130, 246; --amber-rgb: 245, 158, 11; --amethyst-rgb: 139, 92, 246; --crimson-rgb: 190, 18, 60;

  --font: "Inter Variable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-lg: 24px; --r-md: 20px; --r-sm: 16px; --r-xs: 12px;
  --blur: blur(24px) saturate(140%);
  --blur-heavy: blur(32px) saturate(150%);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: 150ms; --t-med: 250ms; --t-slow: 350ms;
}

/* Light theme */
:root, html[data-theme="light"] {
  --bg: #EDF0F3; --bg-2: #E3E7EC;
  --ink: #0B0D10; --muted: #52525B; --faint: #71717A;
  --glass: rgba(255, 255, 255, .62); --glass-strong: rgba(250, 251, 252, .86); --glass-soft: rgba(11, 13, 16, .04);
  --line: rgba(255, 255, 255, .85); --hairline: rgba(11, 13, 16, .08); --hi: rgba(255, 255, 255, .9);
  --field: rgba(255, 255, 255, .7);
  --shadow: 0 1px 2px rgba(11, 13, 16, .04), 0 12px 32px -16px rgba(11, 13, 16, .22);
  --shadow-lift: 0 2px 6px rgba(11, 13, 16, .06), 0 22px 44px -18px rgba(11, 13, 16, .3);
  --brand: #047857; --brand-ink: #fff; --brand-soft: rgba(var(--emerald-rgb), .13);
  --pos: #047857; --neg: #BE123C; --danger: #BE123C; --warn: #B45309;
  --shared: #B45309; --shared-soft: rgba(var(--amber-rgb), .16);
  --in-line: #059669; --out-line: #E11D48;
  --ambient: .22; --grain: .05;
  color-scheme: light;
}
/* Dark theme (default) */
html[data-theme="dark"] {
  --bg: #0B0D10; --bg-2: #14171C;
  --ink: #F5F5F7; --muted: #A1A1AA; --faint: #8B8B94;
  --glass: rgba(255, 255, 255, .07); --glass-strong: rgba(22, 25, 31, .86); --glass-soft: rgba(255, 255, 255, .05);
  --line: rgba(255, 255, 255, .12); --hairline: rgba(255, 255, 255, .07); --hi: rgba(255, 255, 255, .10);
  --field: rgba(255, 255, 255, .06);
  --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 18px 40px -20px rgba(0, 0, 0, .8);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 28px 56px -22px rgba(0, 0, 0, .9);
  --brand: #34D399; --brand-ink: #04140E; --brand-soft: rgba(var(--emerald-rgb), .14);
  --pos: #34D399; --neg: #FB7185; --danger: #FB7185; --warn: #FBBF24;
  --shared: #FBBF24; --shared-soft: rgba(var(--amber-rgb), .14);
  --in-line: #34D399; --out-line: #FB7185;
  --ambient: .16; --grain: .06;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); scroll-padding-top: 110px; }
body { margin: 0; color: var(--ink); font: 400 14.5px/1.55 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; min-height: 100vh; min-height: 100dvh; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: clamp(1.45rem, 1.15rem + 1vw, 1.9rem); font-weight: 600; }
h2 { font-size: 1rem; font-weight: 550; letter-spacing: -.01em; }
h3 { font-size: .92rem; font-weight: 550; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
b, strong { font-weight: 600; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.hidden { display: none !important; }
.only-phone { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; padding: .6rem 1rem; border-radius: 12px; background: var(--brand); color: var(--brand-ink); font-weight: 600; transition: top var(--t-med); }
.skip:focus { top: 12px; }
svg { flex: none; }

/* ---------- Environment: ambient light pools + glass grain ---------- */
body::before, body::after { content: ""; position: fixed; pointer-events: none; }
body::before {
  inset: -10vmax; z-index: -2;
  background:
    radial-gradient(42vmax 36vmax at 8% 4%, rgba(var(--emerald-rgb), var(--ambient)), transparent 60%),
    radial-gradient(38vmax 34vmax at 96% 8%, rgba(var(--sapphire-rgb), calc(var(--ambient) * .9)), transparent 60%),
    radial-gradient(40vmax 36vmax at 82% 98%, rgba(var(--amethyst-rgb), calc(var(--ambient) * .85)), transparent 62%),
    radial-gradient(34vmax 30vmax at 4% 96%, rgba(var(--amber-rgb), calc(var(--ambient) * .55)), transparent 62%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  animation: drift 50s ease-in-out infinite alternate;
}
body::after {
  inset: 0; z-index: 70; opacity: var(--grain); mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift { to { transform: translate3d(2vmax, -1.5vmax, 0) scale(1.04); } }

/* ---------- Glass material ---------- */
.glass, .card, .kpi, .insight, .tile, .dock, .topnav, .tabbar, .month, .banner, .formula, .dropzone, .bulkbar, .seg {
  background: linear-gradient(180deg, var(--hi), transparent 42%), var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--hi), var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html[data-theme="dark"] { --glass: rgba(24, 27, 33, .96); }
  html[data-theme="light"] { --glass: rgba(255, 255, 255, .95); }
}
/* lower-powered devices: lighter blur */
@media (max-width: 699px), (prefers-reduced-transparency: reduce) {
  :root { --blur: blur(16px) saturate(130%); --blur-heavy: blur(22px) saturate(140%); }
}
@media (prefers-reduced-transparency: reduce) {
  html[data-theme="dark"] { --glass: rgba(24, 27, 33, .96); }
  html[data-theme="light"] { --glass: rgba(255, 255, 255, .96); }
}

/* =====================================================================
   Layout
   ===================================================================== */
.shell { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: 100vh; }
.shell > * { min-width: 0; }

/* Floating navigation dock */
.dock {
  position: sticky; top: 16px; margin: 16px 0 16px 16px; height: calc(100vh - 32px); width: 72px; border-radius: var(--r-lg);
  padding: 14px 0; display: flex; flex-direction: column; align-items: center; gap: 14px;
  -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); z-index: 30;
}
.dock .logo img { width: 38px; height: 38px; border-radius: 12px; display: block; box-shadow: 0 8px 18px -8px rgba(var(--emerald-rgb), .8); }
.dock .logo { margin-bottom: 6px; }
.nav { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.nav a {
  position: relative; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--muted);
  transition: color var(--t-fast), background var(--t-med) var(--ease), transform var(--t-fast) var(--ease);
}
.nav a:hover { color: var(--ink); background: var(--glass-soft); }
.nav a:active { transform: scale(.94); }
.nav a[aria-current="page"] { color: var(--ink); background: linear-gradient(180deg, rgba(var(--emerald-rgb), .26), rgba(var(--emerald-rgb), .1)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 0 0 1px rgba(var(--emerald-rgb), .3), 0 8px 22px -10px rgba(var(--emerald-rgb), .7); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -13px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--emerald); box-shadow: 0 0 10px rgba(var(--emerald-rgb), .9); animation: grow var(--t-slow) var(--spring); }
@keyframes grow { from { transform: scaleY(0); } }
.nav svg { width: 21px; height: 21px; transition: transform var(--t-med) var(--spring); }
.nav a:hover svg { transform: scale(1.08); }
.nav .sr-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dock .foot { margin-top: auto; }

/* Tooltips (pointer devices) */
[data-tip] { position: relative; }
@media (hover: hover) and (pointer: fine) {
  [data-tip]::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 14px); top: 50%; translate: -4px -50%; z-index: 60; pointer-events: none;
    padding: .38rem .65rem; border-radius: 10px; font-size: .78rem; font-weight: 500; white-space: nowrap; color: var(--ink);
    background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy);
    opacity: 0; transition: opacity var(--t-fast), translate var(--t-med) var(--ease);
  }
  [data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; translate: 0 -50%; }
  [data-tip][data-tip-pos="below"]::after { left: 50%; top: calc(100% + 10px); translate: -50% -4px; }
  [data-tip][data-tip-pos="below"]:hover::after, [data-tip][data-tip-pos="below"]:focus-visible::after { translate: -50% 0; }
}

.main { padding: 16px clamp(1rem, 2.6vw, 2.25rem) 4rem; max-width: 1360px; width: 100%; margin: 0 auto; }

/* Floating top navigation bar */
.topnav {
  position: sticky; top: 16px; z-index: 28; display: flex; align-items: center; gap: .6rem; padding: 7px 8px 7px 8px; border-radius: var(--r-md);
  margin-bottom: 1.6rem; transition: padding var(--t-slow) var(--ease), background var(--t-slow), box-shadow var(--t-slow), top var(--t-slow) var(--ease);
}
html.fx-scrolled .topnav { padding-top: 4px; padding-bottom: 4px; top: 10px; background: linear-gradient(180deg, var(--hi), transparent 42%), var(--glass-strong); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); }
.topnav .brand-mini { display: none; align-items: center; gap: .55rem; font-weight: 650; letter-spacing: -.02em; }
.topnav .brand-mini img { width: 28px; height: 28px; border-radius: 9px; transition: width var(--t-slow), height var(--t-slow); }
.topnav .spacer { flex: 1; }

/* view tabs with sliding pill */
.view-tabs { position: relative; display: inline-flex; padding: 3px; border-radius: 14px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.view-tabs a { position: relative; z-index: 1; padding: .42rem .9rem; border-radius: 11px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .86rem; transition: color var(--t-med); white-space: nowrap; }
.view-tabs a:hover { color: var(--ink); }
.view-tabs a[aria-current="page"] { color: var(--ink); }
.view-tabs .pill { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 11px; transition: transform var(--t-slow) var(--spring), width var(--t-slow) var(--spring);
  background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .05)); border: 1px solid rgba(var(--emerald-rgb), .35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 18px -4px rgba(var(--emerald-rgb), .55); }
html[data-theme="light"] .view-tabs .pill { background: #fff; box-shadow: 0 2px 8px -2px rgba(11, 13, 16, .2), 0 0 14px -4px rgba(var(--emerald-rgb), .5); }

/* global search */
.search { position: relative; flex: 0 1 340px; min-width: 160px; }
.search input { width: 100%; min-height: 38px; padding: .45rem .8rem .45rem 2.25rem; border-radius: 12px; background: var(--field); border: 1px solid var(--hairline); }
.search > svg { position: absolute; left: .75rem; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search kbd { position: absolute; right: .6rem; top: 50%; translate: 0 -50%; font: 500 .7rem var(--font); color: var(--faint); border: 1px solid var(--hairline); border-radius: 6px; padding: 1px 6px; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 320px; max-height: 60vh; overflow: auto; z-index: 50; padding: 6px; border-radius: var(--r-sm);
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); }
.search-results [role=option] { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .75rem; padding: .55rem .7rem; border-radius: 10px; cursor: pointer; }
.search-results [role=option][aria-selected="true"], .search-results [role=option]:hover { background: var(--brand-soft); }
.search-results .r-desc { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .r-meta { grid-column: 1; font-size: .76rem; color: var(--muted); }
.search-results .r-amt { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 550; }
.search-results .r-empty { padding: .9rem; color: var(--muted); font-size: .86rem; text-align: center; }

.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease); }
.icon-btn:hover { background: var(--glass-soft); color: var(--ink); border-color: var(--hairline); }
.icon-btn:active { transform: scale(.93); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot-badge { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center; color: #fff; background: var(--crimson); box-shadow: 0 0 0 2px var(--bg), 0 0 10px rgba(var(--crimson-rgb), .8); }
.ws-btn { display: inline-flex; align-items: center; gap: .55rem; padding: 3px 10px 3px 3px; border-radius: 14px; border: 1px solid var(--hairline); background: var(--glass-soft); cursor: pointer; color: var(--ink); transition: background var(--t-fast); }
.ws-btn:hover { background: var(--glass); }
.ws-btn .ws-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.ws-btn .ws-text b { font-size: .8rem; font-weight: 600; }
.ws-btn .ws-text span { font-size: .7rem; color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.3rem; }
.page-head .eyebrow { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.top-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.month { display: inline-flex; align-items: center; border-radius: 14px; padding: 3px; }
.month button { border: 0; background: none; width: 34px; height: 34px; cursor: pointer; border-radius: 11px; font-size: 1.1rem; display: grid; place-items: center; color: var(--muted); transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.month button:hover { background: var(--glass-soft); color: var(--ink); }
.month button:active { transform: scale(.9); }
.month span { min-width: 8.8rem; text-align: center; font-weight: 550; font-size: .88rem; }

/* phone: tab bar */
.tabbar { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 1099px) {
  .ws-btn .ws-text { display: none; }
  .search { flex-basis: 220px; }
  .search kbd { display: none; }
}
@media (max-width: 860px) and (min-width: 700px) {
  .view-tabs a { padding: .4rem .65rem; }
}

/* ---------- Phone ---------- */
@media (max-width: 699px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .dock { display: none; }
  .only-phone { display: revert; }
  .hide-phone { display: none !important; }
  .main { padding: 0 .85rem calc(env(safe-area-inset-bottom) + 7rem); }
  .topnav { top: 0; margin: 0 -.85rem 1.1rem; border-radius: 0 0 22px 22px; border-top: 0; padding: calc(env(safe-area-inset-top) + 8px) .85rem 8px; }
  html.fx-scrolled .topnav { top: 0; }
  .topnav .brand-mini { display: inline-flex; }
  .topnav .view-tabs, .topnav .search { display: none; }
  html.fx-scrolled .topnav .brand-mini img { width: 22px; height: 22px; }
  .page-head { flex-direction: column; align-items: stretch; margin-bottom: 1rem; }
  .top-actions { width: 100%; }
  .top-actions .month { flex: 1; justify-content: space-between; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px);
    padding: 6px; border-radius: 24px; background: linear-gradient(180deg, var(--hi), transparent 45%), var(--glass-strong);
    -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem .1rem .4rem; border-radius: 18px; color: var(--muted); text-decoration: none; font-size: .64rem; font-weight: 550; border: 0; background: none; cursor: pointer; transition: background var(--t-med), color var(--t-fast), transform var(--t-fast); position: relative; overflow: hidden; }
  .tabbar a:active, .tabbar button:active { transform: scale(.93); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar [aria-current="page"] { color: var(--ink); background: rgba(var(--emerald-rgb), .16); box-shadow: inset 0 0 0 1px rgba(var(--emerald-rgb), .3); }
  .tabbar [aria-current="page"] svg { color: var(--brand); }
}

/* =====================================================================
   Bento grid
   ===================================================================== */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.bento > * { min-width: 0; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.stack-col { display: grid; gap: 16px; align-content: start; }
@media (max-width: 1099px) {
  .span-3, .span-4 { grid-column: span 6; }
  .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .stack-col.span-4 { grid-column: span 12; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 699px) {
  .bento { gap: 12px; }
  .span-4, .span-5, .span-6, .span-7, .span-8, .span-12, .stack-col.span-4 { grid-column: span 12; }
  .stack-col.span-4 { grid-template-columns: 1fr; }
  .span-3 { grid-column: span 6; }
}
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 899px) { .grid.two { grid-template-columns: 1fr; } .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 699px) { .grid.three { grid-template-columns: 1fr; } }

/* =====================================================================
   Components
   ===================================================================== */
.card { position: relative; border-radius: var(--r-lg); padding: 1.2rem 1.3rem; transition: box-shadow var(--t-med), border-color var(--t-med); }
.card > h2 + * { margin-top: .85rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head .sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
@media (max-width: 699px) { .card { padding: 1rem 1rem; border-radius: var(--r-md); } }

/* KPI stat cards */
.kpi { position: relative; overflow: hidden; border-radius: var(--r-md); padding: 1rem 1.1rem .9rem; display: flex; flex-direction: column; gap: .55rem; isolation: isolate;
  transition: transform var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), border-color var(--t-med); transform: translateY(var(--lift, 0)); }
.kpi::after { content: ""; position: absolute; z-index: -1; width: 220px; height: 220px; right: -90px; top: -110px; border-radius: 50%; background: radial-gradient(circle, rgba(var(--tone-rgb), .32), transparent 66%); pointer-events: none; }
.kpi:hover, .insight:hover { --lift: -4px; box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); border-color: rgba(var(--tone-rgb), .35); }
.kpi-top { display: flex; align-items: center; gap: .6rem; }
.kpi-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: rgb(var(--tone-rgb)); background: rgba(var(--tone-rgb), .14); box-shadow: inset 0 0 0 1px rgba(var(--tone-rgb), .25); }
html[data-theme="dark"] .kpi-icon { color: color-mix(in srgb, rgb(var(--tone-rgb)) 70%, white); }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value { font-size: clamp(1.35rem, 1.05rem + .9vw, 1.8rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; min-height: 28px; }
.kpi-hint { font-size: .76rem; color: var(--muted); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: .74rem; font-weight: 600; padding: 2px 7px 2px 5px; border-radius: 99px; white-space: nowrap; }
.delta svg { width: 13px; height: 13px; }
.delta.good { color: var(--pos); background: rgba(var(--emerald-rgb), .13); }
.delta.bad { color: var(--neg); background: rgba(var(--crimson-rgb), .13); }
.delta.flat { color: var(--muted); background: var(--glass-soft); }
.spark { width: 92px; height: 28px; overflow: visible; }
.spark path.line { fill: none; stroke: rgb(var(--tone-rgb)); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark path.area { fill: rgba(var(--tone-rgb), .16); }
.spark circle { fill: rgb(var(--tone-rgb)); }
@media (max-width: 699px) { .kpi { padding: .85rem .9rem .8rem; } .spark { width: 64px; } .kpi-value { font-size: 1.2rem; } .kpi-icon { width: 28px; height: 28px; } }

.tone-emerald { --tone-rgb: var(--emerald-rgb); }
.tone-sapphire { --tone-rgb: var(--sapphire-rgb); }
.tone-amber { --tone-rgb: var(--amber-rgb); }
.tone-amethyst { --tone-rgb: var(--amethyst-rgb); }
.tone-crimson { --tone-rgb: 244, 63, 94; }

/* Analytics panel */
.analytics { overflow: hidden; isolation: isolate; }
.analytics::before { content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(70% 90% at 15% 0%, rgba(var(--emerald-rgb), .14), transparent 60%), radial-gradient(60% 80% at 100% 100%, rgba(var(--sapphire-rgb), .10), transparent 60%); }
html[data-theme="dark"] .analytics { background: linear-gradient(180deg, var(--hi), transparent 30%), rgba(10, 12, 15, .45); }
.chart-summary { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.chart-summary div { display: flex; flex-direction: column; }
.chart-summary span { font-size: .74rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; }
.chart-summary span i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-summary b { font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; }
.chart { position: relative; height: 240px; outline: none; border-radius: 12px; touch-action: pan-y; }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--brand); }
.chart svg.plot { position: absolute; inset: 0 0 24px 0; width: 100%; height: calc(100% - 24px); overflow: visible; }
.chart .grid-line { stroke: var(--hairline); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .l-in, .chart .l-out { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart .l-in { stroke: var(--in-line); filter: drop-shadow(0 4px 8px rgba(var(--emerald-rgb), .45)); }
.chart .l-out { stroke: var(--out-line); filter: drop-shadow(0 4px 8px rgba(244, 63, 94, .35)); }
.chart .a-in { fill: url(#gIn); } .chart .a-out { fill: url(#gOut); }
html.fx-on .chart .l-in, html.fx-on .chart .l-out { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .9s var(--ease) forwards; }
html.fx-on .chart .l-out { animation-delay: .12s; }
html.fx-on .chart .a-in, html.fx-on .chart .a-out { opacity: 0; animation: fadein .6s .35s var(--ease) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }
.chart .x-labels { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; display: flex; justify-content: space-between; font-size: .7rem; color: var(--faint); }
.chart .x-labels span { width: 0; display: flex; justify-content: center; white-space: nowrap; }
.chart .y-labels { position: absolute; left: 0; top: 0; bottom: 24px; display: flex; flex-direction: column; justify-content: space-between; font-size: .68rem; color: var(--faint); pointer-events: none; }
.chart .y-labels span { translate: 0 -50%; background: none; }
.chart .y-labels span:last-child { translate: 0 0; visibility: hidden; }
.chart .cursor-line { position: absolute; top: 0; bottom: 24px; width: 1px; background: linear-gradient(180deg, transparent, var(--line) 15%, var(--line) 85%, transparent); opacity: 0; pointer-events: none; transition: opacity var(--t-fast); }
.chart .pt { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; opacity: 0; pointer-events: none; transition: opacity var(--t-fast), left var(--t-fast) var(--ease), top var(--t-fast) var(--ease); border: 2px solid var(--bg); }
.chart .pt.in { background: var(--in-line); box-shadow: 0 0 10px rgba(var(--emerald-rgb), .9); }
.chart .pt.out { background: var(--out-line); box-shadow: 0 0 10px rgba(244, 63, 94, .8); }
.chart .tip { position: absolute; top: 4px; min-width: 150px; padding: .55rem .7rem; border-radius: 12px; font-size: .78rem; pointer-events: none; opacity: 0; z-index: 3;
  background: var(--glass-strong); border: 1px solid var(--line); box-shadow: var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); transition: opacity var(--t-fast), left var(--t-fast) var(--ease); }
.chart .tip b { display: block; margin-bottom: .25rem; font-size: .8rem; }
.chart .tip div { display: flex; justify-content: space-between; gap: 1rem; }
.chart .tip i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .35rem; }
.chart.active .cursor-line, .chart.active .pt, .chart.active .tip { opacity: 1; }
@media (max-width: 699px) { .chart { height: 200px; } }

/* Insight cards (coloured) */
.insight { position: relative; overflow: hidden; isolation: isolate; border-radius: var(--r-md); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center;
  background: linear-gradient(145deg, rgba(var(--tone-rgb), .22), rgba(var(--tone-rgb), .05) 60%), var(--glass); border-color: rgba(var(--tone-rgb), .22);
  transition: transform var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), border-color var(--t-med); transform: translateY(var(--lift, 0)); }
.insight .i-body { min-width: 0; flex: 1; }
.insight .i-label { font-size: .76rem; color: var(--muted); font-weight: 500; }
.insight .i-value { font-size: 1.15rem; font-weight: 600; letter-spacing: -.02em; margin-top: .1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insight .i-hint { font-size: .74rem; color: var(--muted); margin-top: .15rem; }
.ring { width: 58px; height: 58px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; rotate: -90deg; }
.ring .track { fill: none; stroke: rgba(var(--tone-rgb), .18); stroke-width: 6; }
.ring .val { fill: none; stroke: rgb(var(--tone-rgb)); stroke-width: 6; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(var(--tone-rgb), .6)); transition: stroke-dashoffset .9s var(--ease); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .78rem; font-weight: 650; }
.mini-bar { height: 6px; border-radius: 99px; background: rgba(var(--tone-rgb), .16); margin-top: .5rem; overflow: hidden; }
.mini-bar i { display: block; height: 100%; border-radius: 99px; background: rgb(var(--tone-rgb)); box-shadow: 0 0 10px rgba(var(--tone-rgb), .6); }
.insight .i-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; color: rgb(var(--tone-rgb)); background: rgba(var(--tone-rgb), .16); }
html[data-theme="dark"] .insight .i-icon, html[data-theme="dark"] .ring span { color: color-mix(in srgb, rgb(var(--tone-rgb)) 65%, white); }
@media (max-width: 699px) { .insight { flex-direction: column; align-items: flex-start; gap: .6rem; padding: .9rem; } .ring { width: 48px; height: 48px; } .insight .i-value { font-size: 1rem; } }

/* Activity & alerts lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .35rem; border-radius: 12px; text-decoration: none; color: inherit; transition: background var(--t-fast); }
.list-item + .list-item { border-top: 1px solid var(--hairline); }
a.list-item:hover, button.list-item:hover { background: var(--glass-soft); }
button.list-item { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.li-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; color: rgb(var(--tone-rgb, 161, 161, 170)); background: rgba(var(--tone-rgb, 161, 161, 170), .14); }
html[data-theme="dark"] .li-icon { color: color-mix(in srgb, rgb(var(--tone-rgb, 161, 161, 170)) 70%, white); }
.li-icon svg { width: 16px; height: 16px; }
.li-body { flex: 1; min-width: 0; }
.li-title { font-weight: 500; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-amt { font-weight: 550; font-size: .88rem; }

/* Legacy tiles (kept for compatibility) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.tile { position: relative; overflow: hidden; border-radius: var(--r-md); padding: 1rem 1.1rem; }
.tile .label { font-size: .8rem; color: var(--muted); } .tile .value { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; } .tile .hint { font-size: .76rem; color: var(--muted); }

.banner { border-radius: var(--r-md); padding: .85rem 1.1rem; background: linear-gradient(180deg, var(--hi), transparent 42%), var(--shared-soft), var(--glass); border-color: rgba(var(--amber-rgb), .25); }
.banner.info { background: linear-gradient(180deg, var(--hi), transparent 42%), var(--brand-soft), var(--glass); border-color: rgba(var(--emerald-rgb), .25); }
.formula { font-size: .88rem; color: var(--muted); border-radius: var(--r-md); padding: .85rem 1.1rem; }
.formula b { color: var(--ink); }

/* Category bars */
.bars { display: flex; flex-direction: column; gap: .9rem; }
.bar-row .top { display: flex; justify-content: space-between; gap: .5rem; font-size: .86rem; }
.bar { height: 6px; background: var(--glass-soft); border-radius: 99px; overflow: hidden; margin-top: .4rem; box-shadow: inset 0 0 0 1px var(--hairline); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, rgba(var(--emerald-rgb), .7), var(--emerald)); box-shadow: 0 0 10px rgba(var(--emerald-rgb), .5); transition: width .7s var(--ease); }
.bar.over > i { background: linear-gradient(90deg, rgba(244, 63, 94, .7), #F43F5E); box-shadow: 0 0 10px rgba(244, 63, 94, .5); }
.bar.shared > i { background: linear-gradient(90deg, rgba(var(--amber-rgb), .7), var(--amber)); box-shadow: 0 0 10px rgba(var(--amber-rgb), .5); }
.legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); padding: .5rem 1rem; border-radius: 12px; cursor: pointer; font-weight: 550; font-size: .86rem;
  text-decoration: none; color: var(--ink); min-height: 38px; white-space: nowrap; background: linear-gradient(180deg, var(--hi), transparent), var(--glass-soft);
  box-shadow: inset 0 1px 0 var(--hi), 0 1px 2px rgba(0, 0, 0, .08);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease), background var(--t-med), border-color var(--t-med), translate var(--t-med) var(--ease);
}
.btn:hover { background: linear-gradient(180deg, var(--hi), transparent), var(--glass); border-color: rgba(var(--emerald-rgb), .3); translate: 0 -1px; }
.btn:active { transform: scale(.97); }
.btn.primary { color: #fff; border-color: rgba(255, 255, 255, .18);
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 55%), linear-gradient(135deg, #10B981, #059669);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 22px -10px rgba(var(--emerald-rgb), .9); }
.btn.primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 12px 28px -10px rgba(var(--emerald-rgb), 1); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: rgba(var(--crimson-rgb), .4); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--glass-soft); }
.btn.sm { padding: .28rem .7rem; min-height: 30px; font-size: .8rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; translate: none; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label, .label-text { font-size: .82rem; font-weight: 550; }
.field .help { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: .55rem .8rem; border: 1px solid var(--hairline); border-radius: 12px; background: var(--field); min-height: 42px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(var(--emerald-rgb), .6); box-shadow: 0 0 0 4px rgba(var(--emerald-rgb), .14); }
.btn:focus-visible, .nav a:focus-visible, .tabbar a:focus-visible, .icon-btn:focus-visible, .ws-btn:focus-visible, .view-tabs a:focus-visible,
.switch input:focus-visible + span, .seg button:focus-visible, .month button:focus-visible, .list-item:focus-visible, .foot-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
select { appearance: none; -webkit-appearance: none; padding-right: 2.1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B8B94' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; }
select option, select optgroup { background: var(--bg-2); color: var(--ink); }
select.compact { min-height: 32px; padding: .2rem 1.8rem .2rem .65rem; font-size: .8rem; max-width: 200px; border-radius: 10px; background-position: right .6rem center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--emerald); cursor: pointer; }
input[type=date]::-webkit-calendar-picker-indicator { filter: var(--date-filter, none); }
html[data-theme="dark"] { --date-filter: invert(.8); }

.seg { display: inline-flex; border-radius: 13px; padding: 3px; gap: 2px; box-shadow: none; }
.seg button { border: 0; background: none; padding: .38rem .85rem; cursor: pointer; font-weight: 500; font-size: .84rem; border-radius: 10px; color: var(--muted); transition: background var(--t-med) var(--ease), color var(--t-fast), box-shadow var(--t-med); position: relative; overflow: hidden; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { color: var(--ink); background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .04)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 0 0 1px rgba(var(--emerald-rgb), .32), 0 0 14px -4px rgba(var(--emerald-rgb), .6); }
html[data-theme="light"] .seg button[aria-pressed="true"] { background: #fff; box-shadow: 0 2px 8px -2px rgba(11, 13, 16, .2), 0 0 0 1px rgba(var(--emerald-rgb), .25); }
.error { color: var(--danger); font-size: .86rem; }
.error:empty { display: none; }

/* Switch (amber = shared with household) */
.switch { position: relative; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .8rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 24px; border-radius: 99px; background: var(--glass-soft); position: relative; transition: background var(--t-med) var(--ease), box-shadow var(--t-med); flex: none; box-shadow: inset 0 0 0 1px var(--line); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform var(--t-slow) var(--spring), width var(--t-fast); box-shadow: 0 2px 5px rgba(0, 0, 0, .3); }
.switch:hover span { box-shadow: inset 0 0 0 1px var(--line), 0 0 0 4px var(--brand-soft); }
.switch:active span::after { width: 22px; }
.switch input:checked + span { background: linear-gradient(135deg, #FBBF24, var(--amber)); box-shadow: 0 0 12px -2px rgba(var(--amber-rgb), .7); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch:active input:checked + span::after { transform: translateX(12px); }
.switch input:disabled + span { opacity: .4; }

/* ---------- Data tables (become cards on phones) ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.3rem; padding: 0 1.3rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 550; padding: .5rem .55rem; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
td { padding: .6rem .55rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--glass-soft); }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
tr.dup td { opacity: .45; }
.desc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.badge { display: inline-block; font-size: .7rem; font-weight: 550; padding: .12rem .5rem; border-radius: 99px; background: var(--glass-soft); color: var(--muted); white-space: nowrap; border: 1px solid var(--hairline); }
.badge.shared { background: var(--shared-soft); color: var(--shared); border-color: rgba(var(--amber-rgb), .25); }
.badge.warn { background: rgba(var(--amber-rgb), .16); color: var(--warn); border-color: rgba(var(--amber-rgb), .3); }
td .row { flex-wrap: nowrap; }
@media (max-width: 699px) {
  .table-wrap { margin: 0; padding: 0; }
  table:not(.resp) { font-size: .8rem; }
  table:not(.resp) th, table:not(.resp) td { padding-left: .3rem; padding-right: .3rem; }
  table:not(.resp) th { font-size: .62rem; letter-spacing: .03em; }
  table:not(.resp) .avatar { display: none; }
  table.resp, table.resp tbody { display: block; }
  table.resp thead { display: none; }
  table.resp tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: .7rem; row-gap: .35rem; align-items: center; grid-template-areas: "chk desc amt" "chk date act" "chk cat share"; padding: .8rem .15rem; border-bottom: 1px solid var(--hairline); }
  table.resp.mini tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "desc amt" "date share" "cat cat"; }
  table.resp tr:last-child { border-bottom: 0; }
  table.resp tbody tr:hover { background: none; }
  table.resp td { padding: 0; border: 0; }
  table.resp .c-chk { grid-area: chk; align-self: start; padding-top: .15rem; }
  table.resp .c-desc { grid-area: desc; }
  table.resp .c-date { grid-area: date; font-size: .78rem; color: var(--muted); }
  table.resp .c-amt { grid-area: amt; text-align: right; font-weight: 600; }
  table.resp .c-act { grid-area: act; justify-self: end; }
  table.resp .c-cat { grid-area: cat; min-width: 0; }
  table.resp .c-share { grid-area: share; justify-self: end; }
  table.resp .desc { max-width: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  table.resp select.compact { max-width: 100%; width: 100%; }
}

/* ---------- States: empty, error, loading ---------- */
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: .35rem; font-size: 1rem; }
.empty .btn { margin-top: 1rem; }
.empty .row { justify-content: center; }
.empty .e-icon { width: 48px; height: 48px; margin: 0 auto .8rem; border-radius: 15px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px rgba(var(--emerald-rgb), .25); }
.skel { position: relative; overflow: hidden; border-radius: var(--r-md); background: var(--glass); border: 1px solid var(--line); }
.skel::after { content: ""; position: absolute; inset: 0; translate: -100% 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent); animation: shimmer 1.3s infinite; }
html[data-theme="light"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); }
@keyframes shimmer { to { translate: 100% 0; } }
.skel.k { height: 128px; } .skel.big { height: 330px; } .skel.mid { height: 200px; }

/* ---------- Misc components ---------- */
.bulkbar { position: sticky; bottom: 1rem; z-index: 35; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .55rem .75rem; border-radius: var(--r-sm); margin-top: 1rem; background: linear-gradient(180deg, var(--hi), transparent), var(--glass-strong); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); }
.bulkbar select { max-width: 200px; min-height: 32px; padding: .2rem 1.8rem .2rem .7rem; }
@media (max-width: 699px) { .bulkbar { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 92px); margin: 0; } }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar input[type=search] { max-width: 280px; padding-left: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238B8B94' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: .8rem center; }
@media (max-width: 699px) { .toolbar input[type=search] { max-width: none; flex: 1 1 100%; } .toolbar .seg { overflow-x: auto; max-width: 100%; scrollbar-width: none; } .toolbar .seg button { white-space: nowrap; } }
.member-list { display: flex; flex-direction: column; }
.member-list > div { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--hairline); }
.member-list > div:last-child { border-bottom: 0; }
.avatar { width: 32px; height: 32px; border-radius: 11px; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: .76rem; flex: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .25), transparent 60%), linear-gradient(135deg, var(--emerald), var(--sapphire)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 12px -4px rgba(var(--emerald-rgb), .6); }
button.avatar { border: 0; cursor: pointer; padding: 0; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.25rem; letter-spacing: .2em; font-weight: 600; padding: .45rem .9rem; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.goal { padding: .9rem 0; border-bottom: 1px solid var(--hairline); }
.goal:last-child { border-bottom: 0; }
.goal .bar { margin-top: .6rem; }
.budget-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 130px; gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--hairline); }
.budget-row:last-child { border-bottom: 0; }
.budget-row input { min-height: 34px; padding: .3rem .7rem; text-align: right; }
@media (max-width: 560px) { .budget-row { grid-template-columns: minmax(0, 1fr) 110px; } .budget-row .spent { display: none; } }

/* Import */
.dropzone { position: relative; border: 1.5px dashed rgba(var(--emerald-rgb), .45); border-radius: var(--r-md); padding: 2rem 1.2rem; text-align: center; cursor: pointer; display: block; transition: transform var(--t-med) var(--ease), border-color var(--t-med), background var(--t-med); }
.dropzone:hover, .dropzone.drag { border-color: var(--emerald); background: linear-gradient(180deg, var(--hi), transparent 42%), var(--brand-soft), var(--glass); transform: translateY(-2px); }
.dropzone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dropzone .dz-icon { width: 48px; height: 48px; margin: 0 auto .6rem; border-radius: 15px; display: grid; place-items: center; color: #fff; background: linear-gradient(180deg, rgba(255, 255, 255, .25), transparent 60%), linear-gradient(135deg, #10B981, #059669); box-shadow: 0 8px 20px -8px rgba(var(--emerald-rgb), .9); }
.dropzone .dz-icon svg { width: 23px; height: 23px; }
details.card summary { cursor: pointer; }
.mapping { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.amount-cell { display: inline-flex; align-items: center; gap: .35rem; }
.flip { border: 1px solid var(--line); background: var(--field); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; font-size: .85rem; line-height: 1; display: inline-grid; place-items: center; color: var(--ink); transition: background var(--t-fast), border-color var(--t-fast); }
.flip:hover { background: var(--brand-soft); border-color: var(--brand); }
.steps { display: flex; gap: .5rem; font-size: .8rem; color: var(--muted); margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.steps span { padding: .22rem .7rem; border-radius: 99px; }
.steps b { color: var(--brand); font-weight: 600; }
.steps span:has(b) { background: var(--glass); border: 1px solid var(--line); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth .panel { width: 100%; max-width: 420px; }
.auth .brand { display: flex; align-items: center; justify-content: center; gap: .7rem; font-size: 1.6rem; font-weight: 650; letter-spacing: -.03em; margin-bottom: .4rem; }
.auth .brand img { width: 46px; height: 46px; border-radius: 14px; box-shadow: 0 10px 26px -10px rgba(var(--emerald-rgb), .9); }
.auth .card { padding: 1.5rem; }
.auth .seg { width: 100%; }
.auth .seg button { flex: 1; }
.promise { display: flex; flex-direction: column; gap: .45rem; margin-top: 1.25rem; font-size: .84rem; color: var(--muted); padding: 0 .5rem; }
.promise div { display: flex; gap: .55rem; }
.promise div::before { content: "✓"; color: var(--brand); font-weight: 700; }

/* ---------- Modal / sheet & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(5, 6, 8, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 1rem; animation: fadein var(--t-med) ease both; }
html[data-theme="light"] .modal-back { background: rgba(11, 13, 16, .22); }
.modal { border-radius: var(--r-lg); width: 100%; max-width: 540px; max-height: 92vh; overflow: auto; padding: 1.4rem; background: linear-gradient(180deg, var(--hi), transparent 30%), var(--glass-strong); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); animation: pop var(--t-slow) var(--spring); }
.modal h2 { margin-bottom: 1rem; font-size: 1.12rem; }
.modal .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes rise { from { transform: translateY(100%); } }
@media (max-width: 699px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal { max-width: none; border-radius: 26px 26px 0 0; padding: .6rem 1.1rem calc(env(safe-area-inset-bottom) + 1.2rem); max-height: 90vh; animation: rise var(--t-slow) var(--ease); }
  .modal::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto .9rem; }
  .modal .actions .btn { flex: 1; }
}
.sheet-links { display: flex; flex-direction: column; gap: .4rem; }
.sheet-links a, .sheet-links button { display: flex; align-items: center; gap: .8rem; padding: .85rem 1rem; border-radius: 16px; text-decoration: none; color: var(--ink); font-weight: 500; background: var(--glass-soft); border: 1px solid var(--hairline); cursor: pointer; text-align: left; width: 100%; }
.sheet-links svg { width: 20px; height: 20px; color: var(--brand); }
.sheet-links [aria-current="page"] { border-color: rgba(var(--emerald-rgb), .4); }
.sheet-search input { margin-bottom: .6rem; }
.sheet-search .search-results { position: static; box-shadow: none; max-height: 55vh; }

#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(160%); padding: .65rem 1.1rem; border-radius: 14px; font-weight: 500; font-size: .88rem; z-index: 60;
  transition: transform var(--t-slow) var(--spring), visibility var(--t-slow); max-width: 90vw; visibility: hidden; color: var(--ink);
  background: var(--glass-strong); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift); }
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.err { background: rgba(var(--crimson-rgb), .92); color: #fff; border-color: rgba(255, 255, 255, .2); }
@media (max-width: 699px) { #toast { bottom: calc(env(safe-area-inset-bottom) + 96px); } }

/* ---------- Dropdown menus ---------- */
.dd { position: relative; display: inline-flex; }
.dd-menu { position: absolute; top: calc(100% + 8px); right: 0; min-width: 230px; z-index: 45; padding: 6px; border-radius: var(--r-sm);
  background: linear-gradient(180deg, var(--hi), transparent 30%), var(--glass-strong); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.97); transform-origin: top right; transition: opacity var(--t-fast) var(--ease), transform var(--t-med) var(--spring), visibility var(--t-med); }
.dd.up .dd-menu { top: auto; bottom: calc(100% + 8px); }
.dd.side .dd-menu { top: auto; bottom: 0; left: calc(100% + 14px); right: auto; transform-origin: bottom left; transform: translateX(-6px) scale(.97); }
.dd.open .dd-menu { opacity: 1; visibility: visible; transform: none; }
.dd-menu [role=menuitem], .dd-menu [role=menuitemradio] { display: flex; align-items: center; gap: .65rem; width: 100%; padding: .55rem .75rem; border-radius: 10px; border: 0; background: none; cursor: pointer; color: var(--ink); text-decoration: none; font-weight: 500; font-size: .86rem; text-align: left; white-space: nowrap; transition: background var(--t-fast), transform var(--t-fast) var(--ease); }
.dd-menu [role=menuitem]:hover, .dd-menu [role=menuitem]:focus-visible, .dd-menu [role=menuitemradio]:hover, .dd-menu [role=menuitemradio]:focus-visible { background: var(--brand-soft); outline: none; transform: translateX(2px); }
.dd-menu [role=menuitemradio][aria-checked="true"] { color: var(--brand); }
.dd-menu [role=menuitemradio][aria-checked="true"]::after { content: "✓"; margin-left: auto; font-weight: 700; }
.dd-menu svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.dd-menu [role=menuitem]:hover svg { color: var(--brand); }
.dd-menu .danger, .dd-menu .danger svg { color: var(--danger) !important; }
.dd-menu hr { border: 0; border-top: 1px solid var(--hairline); margin: 4px 6px; }
.dd-head { padding: .45rem .75rem .4rem; font-size: .76rem; color: var(--muted); }
.dd-head b { display: block; color: var(--ink); font-size: .88rem; }
.dd-menu.wide { width: 340px; }
@media (max-width: 699px) { .dd-menu.wide { width: min(340px, calc(100vw - 24px)); right: -48px; } }
.chev { width: 14px; height: 14px; transition: transform var(--t-med) var(--ease); }
.dd.open .chev { transform: rotate(180deg); }
.foot-toggle { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 12px; }

/* =====================================================================
   Interaction effects (assets/fx.js) — understated, 150–350ms
   ===================================================================== */
html.fx-on { scroll-behavior: smooth; }

/* cursor light behind the glass + border illumination */
#fx-spot { position: fixed; left: 0; top: 0; width: 640px; height: 640px; margin: -320px 0 0 -320px; z-index: -1; pointer-events: none; border-radius: 50%; opacity: 0; transition: opacity .5s;
  background: radial-gradient(circle, rgba(var(--emerald-rgb), .13) 0%, rgba(var(--sapphire-rgb), .06) 38%, transparent 66%); will-change: transform; }
html.fx-pointer.fx-cursor-in #fx-spot { opacity: 1; }
html.fx-pointer :is(.card, .kpi, .insight, .banner, .formula, .dropzone) { isolation: isolate; }
html.fx-pointer :is(.banner, .formula) { position: relative; }
html.fx-pointer :is(.card, .kpi, .insight, .banner, .formula, .month, .dropzone, .topnav)::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 2;
  background: radial-gradient(200px circle at var(--mx, -999px) var(--my, -999px), rgba(110, 231, 183, .75), rgba(96, 165, 250, .35) 45%, transparent 75%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  opacity: var(--spot-o, 0); transition: opacity var(--t-slow);
}
html.fx-pointer .analytics::before { all: unset; content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(70% 90% at 15% 0%, rgba(var(--emerald-rgb), .14), transparent 60%), radial-gradient(60% 80% at 100% 100%, rgba(var(--sapphire-rgb), .10), transparent 60%); }
html.fx-pointer .card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: radial-gradient(380px circle at var(--mx, -999px) var(--my, -999px), rgba(var(--emerald-rgb), .07), transparent 60%); opacity: var(--spot-o, 0); transition: opacity var(--t-slow); }
.month, .topnav { position: relative; }
.topnav { position: sticky; }

/* gentle tilt */
html.fx-pointer .fx-tilt { transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0)); transition: transform var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), border-color var(--t-med); }
html.fx-pointer .fx-tilt.fx-tilting { transition: transform 120ms linear, box-shadow var(--t-slow) var(--ease), border-color var(--t-med); }

/* magnetic primary buttons */
html.fx-pointer :is(.btn.primary, [data-magnetic]) { transition: translate .5s var(--spring), transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease); }
html.fx-pointer .fx-pulled { transition: translate 120ms ease-out, transform var(--t-fast) var(--ease), box-shadow var(--t-med) var(--ease) !important; }

/* reveal once, staggered */
html.fx-on .fx-reveal { opacity: 0; translate: 0 14px; transition: opacity var(--t-slow) var(--ease), translate var(--t-slow) var(--ease), transform var(--t-slow) var(--ease), box-shadow var(--t-slow) var(--ease), border-color var(--t-med); }
html.fx-on .fx-reveal.fx-in { opacity: 1; translate: 0 0; }
html:not(.fx-on) .fx-reveal { opacity: 1; translate: none; }

/* press ripple */
.fx-ripple { position: absolute; border-radius: 50%; pointer-events: none; z-index: -1; transform: scale(0); opacity: .35; background: radial-gradient(circle, rgba(255, 255, 255, .8), rgba(255, 255, 255, 0) 70%); animation: ripple 450ms var(--ease) forwards; }
.btn:not(.primary) .fx-ripple, .seg .fx-ripple, .tabbar .fx-ripple { background: radial-gradient(circle, rgba(var(--emerald-rgb), .45), transparent 70%); }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
.main a:not(.btn):not(.list-item):not([role]) { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size var(--t-med) var(--ease); }
.main a:not(.btn):not(.list-item):not([role]):hover { background-size: 100% 1px; }

/* custom cursor (laptop/PC) */
#fx-dot, #fx-ring { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 9999; border-radius: 50%; opacity: 0; will-change: transform; }
#fx-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--emerald); box-shadow: 0 0 8px rgba(var(--emerald-rgb), .9); transition: opacity var(--t-fast), width var(--t-fast), height var(--t-fast), margin var(--t-fast); }
#fx-ring { width: 32px; height: 32px; margin: -16px 0 0 -16px; border: 1px solid rgba(var(--emerald-rgb), .5); background: rgba(255, 255, 255, .03);
  -webkit-backdrop-filter: blur(1px) saturate(160%); backdrop-filter: blur(1px) saturate(160%); transition: opacity var(--t-med), width var(--t-med) var(--ease), height var(--t-med) var(--ease), margin var(--t-med) var(--ease), background var(--t-med), border-color var(--t-med); }
html.fx-cursor.fx-cursor-in #fx-dot, html.fx-cursor.fx-cursor-in #fx-ring { opacity: 1; }
html.fx-cursor.fx-cursor-hover #fx-ring { width: 46px; height: 46px; margin: -23px 0 0 -23px; background: rgba(var(--emerald-rgb), .08); border-color: rgba(var(--emerald-rgb), .75); }
html.fx-cursor.fx-cursor-hover #fx-dot { width: 4px; height: 4px; margin: -2px 0 0 -2px; }
html.fx-cursor.fx-cursor-down #fx-ring { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
html.fx-cursor.fx-cursor-text #fx-dot, html.fx-cursor.fx-cursor-text #fx-ring { opacity: 0; }
html.fx-cursor, html.fx-cursor * { cursor: none !important; }
html.fx-cursor :is(input:not([type=checkbox]):not([type=file]), textarea, [contenteditable]) { cursor: text !important; }

/* back to top */
#fx-top { position: fixed; right: 22px; bottom: 22px; z-index: 38; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; cursor: pointer; color: var(--ink);
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--hi), transparent 45%), var(--glass-strong); -webkit-backdrop-filter: var(--blur-heavy); backdrop-filter: var(--blur-heavy); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-lift);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(.9); transition: opacity var(--t-med), visibility var(--t-med), transform var(--t-slow) var(--spring), border-color var(--t-fast); }
#fx-top svg { width: 19px; height: 19px; transition: transform var(--t-med) var(--ease); }
#fx-top.show { opacity: 1; visibility: visible; transform: none; }
#fx-top:hover { border-color: rgba(var(--emerald-rgb), .45); }
#fx-top:hover svg { transform: translateY(-2px); }
#fx-top:active { transform: scale(.93); }
@media (max-width: 699px) { #fx-top { right: 16px; bottom: calc(env(safe-area-inset-bottom) + 96px); } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #fx-spot, #fx-dot, #fx-ring { display: none; }
  html.fx-on { scroll-behavior: auto; }
  .chart .l-in, .chart .l-out { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
  .chart .a-in, .chart .a-out { opacity: 1 !important; }
}

/* ---------- refinements ---------- */
.search input[type=search] { padding-left: 2.3rem; background-image: none; }
.analytics { display: flex; flex-direction: column; }
.analytics .chart { flex: 1 1 auto; min-height: 240px; }
button.list-item { border: 0; }
.list-item + .list-item { border-top: 1px solid var(--hairline); }
.insight .i-icon svg { width: 21px; height: 21px; }
@media (max-width: 699px) {
  .kpi-top { flex-wrap: wrap; row-gap: .4rem; }
  .kpi-label { flex: 1 1 calc(100% - 40px); white-space: normal; }
  .kpi-top .delta { order: 3; }
  .kpi-hint { display: none; }
  .kpi-foot { min-height: 0; justify-content: flex-end; }
  .analytics .chart { min-height: 200px; }
}
