/* ==========================================================================
   Dreamora design system
   Plain CSS (no build step) so it can be used as-is by the Next.js app
   (import in app/globals.css; Tailwind can read the same tokens).

   Layout idea: a dawn sky (baby blue → lavender → pink → cream) is the
   ambient layer; ivory/cream "porcelain" cards float on it and carry every
   number. Decoration lives in the sky and on at most one hero card per page,
   never inside tables or forms.

   Themes: "Fajar" (light, default) and "Senja" (twilight). System setting
   picks automatically; data-theme="light|dark" on <html> forces one.
   ========================================================================== */

:root {
  /* — Sky (ambient background only) — */
  --sky-1: #d2ecfb;            /* baby blue */
  --sky-2: #dcd6f7;            /* lavender */
  --sky-3: #fde3eb;            /* pink */
  --sky-4: #faf5ec;            /* cream */
  --bg: #fbf4f1;

  /* — Surfaces — */
  --surface: rgb(255 253 249 / 0.86);   /* porcelain glass */
  --surface-solid: #fffdf9;
  --surface-2: #faf5ec;                 /* cream inset (inputs, table head) */
  --surface-3: #feeff3;                 /* soft white-pink (hover, selected) */
  --line: #f2d9e1;
  --line-strong: #e7bccb;

  /* — Ink (all pass WCAG AA on surfaces) — */
  --ink: #4e3a49;
  --ink-2: #745c6d;
  --ink-3: #a08a99;            /* decorative/placeholder only, never data */

  /* — Brand pinks — */
  --rose: #f7a0b8;
  --rose-deep: #f195bc;
  --blush: #fbb6c4;
  --pink: #fde3eb;
  --rose-ink: #a33a66;         /* accent text / links */
  --on-rose: #45293b;          /* text on rose fills */
  --nav-active-bg: #fcd5e1;
  --nav-active-fg: #45293b;

  /* — Secondary accents — */
  --blue: #d2ecfb;
  --blue-ink: #2f6688;
  --lavender: #dcd6f7;
  --lav-ink: #5b4e9a;
  --cream: #fae9d7;
  --ivory: #f7f9ea;
  --honeydew: #ddecd9;
  --gold: #c9a35a;             /* hairlines on the hero card only */

  /* — Semantic (separate from brand) — */
  --pos: #2a7350;  --pos-bg: #e3f1e0;
  --neg: #b23a5e;  --neg-bg: #fce4ea;
  --warn: #8f5c0c; --warn-bg: #fbefd6;
  --info: #2f6688; --info-bg: #e2f2fc;

  /* — Charts (categorical, ordered) — */
  --c1: #ee8fae; --c2: #8fc3e8; --c3: #a99ae6; --c4: #e9b979; --c5: #8ccaa3; --c6: #f2b6c9;
  --grid: #f0e2e7;

  /* — Shape & depth — */
  --r-s: 10px; --r-m: 16px; --r-l: 22px; --r-xl: 28px; --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(181 112 142 / 0.10), 0 2px 8px rgb(181 112 142 / 0.06);
  --shadow:    0 2px 6px rgb(181 112 142 / 0.10), 0 12px 32px rgb(181 112 142 / 0.12);
  --shadow-lg: 0 10px 30px rgb(140 90 140 / 0.18), 0 30px 80px rgb(140 90 140 / 0.16);
  --focus: 0 0 0 3px var(--surface-solid), 0 0 0 5px var(--rose-deep);

  /* — Type — */
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-num: "Nunito", "Segoe UI", system-ui, sans-serif;
  --fs-xs: 0.75rem; --fs-s: 0.8125rem; --fs-m: 0.9375rem; --fs-l: 1.0625rem;
  --fs-xl: 1.375rem; --fs-2xl: 1.75rem; --fs-3xl: 2.25rem;

  /* — Motion — */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 140ms; --t: 220ms; --t-slow: 420ms;

  --sidebar-w: 268px;
  color-scheme: light;
}

/* ——— Senja (twilight) ——— */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky-1: #1c1934; --sky-2: #2b2350; --sky-3: #3d2953; --sky-4: #251e3a; --bg: #221b36;
    --surface: rgb(50 40 72 / 0.84); --surface-solid: #322848; --surface-2: #2a2240; --surface-3: #3c2f55;
    --line: #463a60; --line-strong: #5d4c7b;
    --ink: #f8ecf3; --ink-2: #d4c0d8; --ink-3: #9f8bad;
    --rose: #f7a0b8; --rose-deep: #f195bc; --blush: #fbb6c4; --pink: #4a3150;
    --rose-ink: #ffb4cc; --on-rose: #3a2133; --nav-active-bg: #4f3358; --nav-active-fg: #fbeef5;
    --blue: #263b58; --blue-ink: #ace0fb; --lavender: #393268; --lav-ink: #cec6ff;
    --cream: #3a2f42; --ivory: #2e2a3c; --honeydew: #263a31; --gold: #e3c57f;
    --pos: #93dcb2; --pos-bg: #233a2e; --neg: #ff9fb8; --neg-bg: #46263a;
    --warn: #f3c77c; --warn-bg: #42341f; --info: #ace0fb; --info-bg: #23354f;
    --c1: #f59ab8; --c2: #8ccff5; --c3: #b9adff; --c4: #f0c486; --c5: #93dcb2; --c6: #e7a6c4;
    --grid: #43375c;
    --shadow-sm: 0 1px 2px rgb(10 5 25 / 0.35);
    --shadow: 0 2px 8px rgb(10 5 25 / 0.35), 0 14px 34px rgb(10 5 25 / 0.35);
    --shadow-lg: 0 14px 40px rgb(10 5 25 / 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --sky-1: #1c1934; --sky-2: #2b2350; --sky-3: #3d2953; --sky-4: #251e3a; --bg: #221b36;
  --surface: rgb(50 40 72 / 0.84); --surface-solid: #322848; --surface-2: #2a2240; --surface-3: #3c2f55;
  --line: #463a60; --line-strong: #5d4c7b;
  --ink: #f8ecf3; --ink-2: #d4c0d8; --ink-3: #9f8bad;
  --rose: #f7a0b8; --rose-deep: #f195bc; --blush: #fbb6c4; --pink: #4a3150;
  --rose-ink: #ffb4cc; --on-rose: #3a2133; --nav-active-bg: #4f3358; --nav-active-fg: #fbeef5;
  --blue: #263b58; --blue-ink: #ace0fb; --lavender: #393268; --lav-ink: #cec6ff;
  --cream: #3a2f42; --ivory: #2e2a3c; --honeydew: #263a31; --gold: #e3c57f;
  --pos: #93dcb2; --pos-bg: #233a2e; --neg: #ff9fb8; --neg-bg: #46263a;
  --warn: #f3c77c; --warn-bg: #42341f; --info: #ace0fb; --info-bg: #23354f;
  --c1: #f59ab8; --c2: #8ccff5; --c3: #b9adff; --c4: #f0c486; --c5: #93dcb2; --c6: #e7a6c4;
  --grid: #43375c;
  --shadow-sm: 0 1px 2px rgb(10 5 25 / 0.35);
  --shadow: 0 2px 8px rgb(10 5 25 / 0.35), 0 14px 34px rgb(10 5 25 / 0.35);
  --shadow-lg: 0 14px 40px rgb(10 5 25 / 0.5);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
/* `hidden` must always win over component display rules (e.g. .field is flex). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-m);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -0.01em; font-variation-settings: "SOFT" 100, "WONK" 1; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-l); }
p { margin: 0; }
a { color: var(--rose-ink); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-s); }
.num, .amount, td.num { font-family: var(--font-num); font-variant-numeric: tabular-nums lining-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.muted { color: var(--ink-2); }

/* ==========================================================================
   Sky decoration layer
   ========================================================================== */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(60% 45% at 85% 0%, var(--sky-1) 0%, transparent 70%),
    radial-gradient(55% 50% at 5% 20%, var(--sky-2) 0%, transparent 70%),
    radial-gradient(70% 60% at 70% 85%, var(--sky-3) 0%, transparent 75%),
    linear-gradient(180deg, var(--sky-4), var(--bg));
}
.sky canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.cloud {
  position: absolute; width: 340px; height: 120px; border-radius: 999px; opacity: 0.55;
  background:
    radial-gradient(closest-side at 30% 60%, rgb(255 255 255 / 0.95), transparent),
    radial-gradient(closest-side at 55% 40%, rgb(255 240 246 / 0.95), transparent),
    radial-gradient(closest-side at 78% 62%, rgb(255 255 255 / 0.9), transparent);
  filter: blur(6px);
  animation: drift 90s linear infinite;
}
:root[data-theme="dark"] .cloud { opacity: 0.14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cloud { opacity: 0.14; } }
.cloud--a { top: 6%; left: -360px; animation-duration: 110s; }
.cloud--b { top: 58%; left: -360px; width: 420px; animation-duration: 140s; animation-delay: -60s; transform: scale(1.2); }
.cloud--c { top: 28%; left: -360px; width: 260px; animation-duration: 95s; animation-delay: -30s; opacity: 0.4; }
@keyframes drift { to { translate: calc(100vw + 720px) 0; } }

/* Four-point sparkle, used as an inline glyph (svg.sparkle) */
.sparkle { width: 1em; height: 1em; fill: currentColor; flex: none; }
.sparkle--twinkle { animation: twinkle 3.2s var(--ease) infinite; transform-origin: center; }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(0.72) rotate(20deg); opacity: 0.6; } }

/* ==========================================================================
   App shell
   ========================================================================== */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: max(20px, env(safe-area-inset-top, 0px)) 14px 18px max(14px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 6px; text-decoration: none; color: var(--ink); }
.brand__mark { width: 40px; height: 40px; flex: none; }
.brand__name { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; font-variation-settings: "SOFT" 100, "WONK" 1; }
.brand__tag { display: block; font-size: var(--fs-xs); color: var(--ink-2); font-family: var(--font-body); font-weight: 600; letter-spacing: 0.02em; margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 14px; }
.nav__group { display: flex; flex-direction: column; gap: 2px; }
.nav__title { font-size: 0.6875rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); padding: 0 12px 4px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 14px;
  color: var(--ink-2); font-weight: 700; font-size: var(--fs-m); text-decoration: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.nav__link svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav__link:hover { background: var(--surface-3); color: var(--ink); }
.nav__link:active { transform: scale(0.98); }
.nav__link[aria-current="page"] {
  color: var(--nav-active-fg);
  background: var(--nav-active-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rose) 55%, transparent), var(--shadow-sm);
}
.nav__link[aria-current="page"]::after {
  content: ""; position: absolute; right: 12px; width: 8px; height: 8px;
  background: var(--rose-deep); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
.nav__count { margin-left: auto; font-size: var(--fs-xs); font-weight: 800; color: var(--neg); background: var(--neg-bg); border-radius: var(--r-pill); padding: 1px 8px; }

.sidebar__foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--on-rose); background: linear-gradient(135deg, var(--blush), var(--lavender)); flex: none; }
.sidebar__foot .who { min-width: 0; line-height: 1.25; }
.sidebar__foot .who b { display: block; font-size: var(--fs-s); }
.sidebar__foot .who span { font-size: var(--fs-xs); color: var(--ink-2); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px;
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar__title { font-family: var(--font-display); font-size: var(--fs-l); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__menu { display: none; }
.page {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding-block: 26px 120px;
  padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 22px;
}

/* Greeting */
.greeting { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.greeting h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem); display: flex; align-items: center; gap: 10px; }
.greeting h1 .sparkle { color: var(--rose-deep); width: 0.7em; height: 0.7em; }
.greeting p { color: var(--ink-2); margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   Buttons, chips, badges
   ========================================================================== */
.btn {
  --btn-bg: var(--surface-solid); --btn-fg: var(--ink); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--r-pill);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font: 800 var(--fs-m)/1 var(--font-body); letter-spacing: 0.01em; cursor: pointer; text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease), filter var(--t) var(--ease);
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; stroke: currentColor; flex: none; }
.btn:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--primary {
  --btn-fg: var(--on-rose); --btn-bd: transparent;
  background: linear-gradient(135deg, var(--rose-deep), var(--rose) 55%, var(--blush));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--rose-deep) 35%, transparent), inset 0 1px 0 rgb(255 255 255 / 0.5);
}
.btn--primary:hover { filter: saturate(1.08) brightness(1.02); box-shadow: 0 10px 24px color-mix(in srgb, var(--rose-deep) 40%, transparent), inset 0 1px 0 rgb(255 255 255 / 0.5); }
.btn--soft { --btn-bg: var(--surface-3); --btn-bd: transparent; --btn-fg: var(--rose-ink); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover { --btn-bg: var(--surface-3); box-shadow: none; }
.btn--danger { --btn-bg: var(--neg); --btn-fg: #fff; --btn-bd: transparent; }
:root[data-theme="dark"] .btn--danger { --btn-fg: #3a1626; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--danger { --btn-fg: #3a1626; } }
.btn--icon { min-height: 40px; width: 40px; padding: 0; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-s); }
.btn .spinner { display: none; }
.btn[aria-busy="true"] .spinner { display: inline-block; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface-solid);
  color: var(--ink-2); font: 700 var(--fs-s)/1 var(--font-body); cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--lavender); color: var(--lav-ink); border-color: transparent; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--income { color: var(--pos); background: var(--pos-bg); }
.badge--expense { color: var(--neg); background: var(--neg-bg); }
.badge--transfer { color: var(--lav-ink); background: var(--lavender); }
.badge--info { color: var(--info); background: var(--info-bg); }
.badge--warn { color: var(--warn); background: var(--warn-bg); }

/* ==========================================================================
   Cards & stats
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-sm); padding: 20px;
  backdrop-filter: blur(10px);
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__head h2 { font-size: var(--fs-l); }
.card__sub { font-size: var(--fs-s); color: var(--ink-2); }

.stats { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 16px 18px; border-radius: var(--r-l);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat__label { display: flex; align-items: center; gap: 8px; font-size: var(--fs-s); font-weight: 700; color: var(--ink-2); }
.stat__icon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.stat__icon svg { width: 16px; height: 16px; stroke: currentColor; }
.stat__icon--pink { background: var(--pink); color: var(--rose-ink); }
.stat__icon--blue { background: var(--blue); color: var(--blue-ink); }
.stat__icon--lav { background: var(--lavender); color: var(--lav-ink); }
.stat__icon--green { background: var(--honeydew); color: var(--pos); }
.stat__icon--cream { background: var(--cream); color: var(--warn); }
.stat__value { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: clamp(1.15rem, 0.95rem + 0.6vw, 1.45rem); font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.stat__meta { font-size: var(--fs-xs); color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { font-weight: 800; }
.delta--up { color: var(--pos); }
.delta--down { color: var(--neg); }

/* The one decorated card per page: net worth, with gold hairline + planet */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: center;
  padding: 24px 26px; border-radius: var(--r-xl);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--lavender) 90%, transparent), transparent 60%),
    radial-gradient(90% 120% at 0% 100%, color-mix(in srgb, var(--blue) 80%, transparent), transparent 60%),
    linear-gradient(135deg, var(--pink), var(--surface-solid));
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--line));
  box-shadow: var(--shadow), inset 0 0 0 4px color-mix(in srgb, var(--surface-solid) 60%, transparent), inset 0 0 0 5px color-mix(in srgb, var(--gold) 35%, transparent);
}
.hero__label { display: flex; align-items: center; gap: 8px; }
.hero__label .sparkle { color: var(--gold); }
.hero__value { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 800; font-size: clamp(1.9rem, 1.3rem + 2vw, 2.9rem); letter-spacing: -0.02em; line-height: 1.1; margin-top: 6px; overflow-wrap: anywhere; }
.hero__split { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.hero__split div { display: flex; flex-direction: column; }
.hero__split span { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); }
.hero__split b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-l); }
.hero__art { position: absolute; right: -30px; top: -40px; width: 300px; height: 300px; z-index: -1; opacity: 0.95; pointer-events: none; }
.hero__art .bubble { animation: bob 7s ease-in-out infinite; }
.hero__art .bubble:nth-child(2) { animation-delay: -2.5s; animation-duration: 9s; }
.hero__art .ring { animation: ring-glint 6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes ring-glint { 50% { opacity: 0.6; } }
.hero__note { font-size: var(--fs-xs); color: var(--ink-2); margin-top: 10px; }

/* ==========================================================================
   Dashboard grid & charts
   ========================================================================== */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.grid-2 > * { min-width: 0; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-2); font: 600 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--line-strong); }
.chart .bar { transition: opacity var(--t) var(--ease); }
.chart .bar:hover { opacity: 0.8; }
.chart .line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s var(--ease) 0.2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .grow { transform-box: fill-box; transform-origin: bottom; animation: grow 0.7s var(--ease) both; }
@keyframes grow { from { transform: scaleY(0); } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-s); color: var(--ink-2); font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; padding: 8px 12px; border-radius: 12px;
  background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: var(--fs-s); font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.donut-wrap { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; }
.donut-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--fs-s); }
.donut-list li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.donut-list i { width: 10px; height: 10px; border-radius: 3px; }
.donut-list b { font-variant-numeric: tabular-nums; }

/* Budget progress */
.progress { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--c2), var(--c3)); transition: width var(--t-slow) var(--ease); }
.progress--warn > span { background: linear-gradient(90deg, var(--c4), #e9a35f); }
.progress--over > span { background: linear-gradient(90deg, var(--rose-deep), var(--neg)); }
.budget-list { display: flex; flex-direction: column; gap: 14px; list-style: none; margin: 0; padding: 0; }
.budget-list li { display: flex; flex-direction: column; gap: 6px; }
.budget-list .row { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-s); }
.budget-list .row b { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--surface-solid); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-m); }
.table th {
  position: sticky; top: 0; text-align: left; font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-2); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-3); }
.table .num { text-align: right; white-space: nowrap; }
.table .desc { font-weight: 700; }
.table .desc small { display: block; font-weight: 600; color: var(--ink-2); font-size: var(--fs-xs); }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.amount { font-weight: 800; }
.amount--pos { color: var(--pos); }
.amount--neg { color: var(--neg); }
.amount--neutral { color: var(--lav-ink); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 0; flex-wrap: wrap; font-size: var(--fs-s); color: var(--ink-2); }
.pager { display: flex; gap: 6px; align-items: center; }

/* Compact variant for narrow cards (dashboard): date · description · amount */
.table--compact th[data-col="cat"], .table--compact td[data-col="cat"],
.table--compact th[data-col="acct"], .table--compact td[data-col="acct"],
.table--compact th[data-col="type"], .table--compact td[data-col="type"] { display: none; }
.table--compact td, .table--compact th { padding-inline: 12px; }

.spark { width: 100%; max-width: 240px; height: 64px; display: block; overflow: visible; }

/* Phone: rows become cards */
@media (max-width: 720px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { padding: 0; border: 0; }
  .table--stack td[data-col="date"] { grid-column: 1; grid-row: 2; font-size: var(--fs-xs); color: var(--ink-2); }
  .table--stack td[data-col="desc"] { grid-column: 1; grid-row: 1; }
  .table--stack td[data-col="amount"] { grid-column: 2; grid-row: 1; }
  .table--stack td[data-col="type"] { grid-column: 2; grid-row: 2; text-align: right; }
  .table--stack td[data-col="cat"], .table--stack td[data-col="acct"] { display: none; }
  .table--stack td.actions { grid-column: 1 / -1; grid-row: 3; text-align: left; padding-top: 6px; }
  .table--stack td.actions .btn { min-height: 32px; }
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-s); font-weight: 800; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.label .opt { font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border-radius: 14px; border: 1.5px solid var(--line-strong); background: var(--surface-2);
  color: var(--ink); font: 600 var(--fs-m)/1.3 var(--font-body);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
.textarea { min-height: 84px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); font-weight: 600; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--rose-deep); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--rose-deep); background: var(--surface-solid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--rose) 30%, transparent); }
.select { appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a33a66' 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 12px center; background-size: 16px; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group__prefix { position: absolute; left: 14px; font-weight: 800; color: var(--ink-2); pointer-events: none; }
.input-group .input { padding-left: 44px; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--fs-l); font-weight: 800; }
.hint { font-size: var(--fs-xs); color: var(--ink-2); }
.error-text { font-size: var(--fs-s); font-weight: 700; color: var(--neg); display: flex; align-items: center; gap: 6px; }
.error-text:empty { display: none; }
.field[data-invalid="true"] .input, .field[data-invalid="true"] .select { border-color: var(--neg); background: var(--neg-bg); }
.form-alert { padding: 10px 14px; border-radius: 12px; background: var(--neg-bg); color: var(--neg); font-weight: 700; font-size: var(--fs-s); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; border-radius: var(--r-pill); font-weight: 800; font-size: var(--fs-s); color: var(--ink-2); cursor: pointer; transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.segmented input:focus-visible + label { box-shadow: var(--focus); }
.segmented input:checked + label { background: var(--surface-solid); color: var(--ink); box-shadow: var(--shadow-sm); }
.segmented input[value="INCOME"]:checked + label { color: var(--pos); }
.segmented input[value="EXPENSE"]:checked + label { color: var(--neg); }
.segmented input[value="TRANSFER"]:checked + label { color: var(--lav-ink); }

.search { position: relative; flex: 1 1 220px; max-width: 340px; }
.search svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; stroke: var(--ink-2); }
.search .input { padding-left: 40px; min-height: 40px; border-radius: var(--r-pill); background: var(--surface-solid); }

/* ==========================================================================
   Dialogs (native <dialog>: focus trap, Esc, inert background for free)
   ========================================================================== */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface-solid); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; animation: dialog-in var(--t-slow) var(--ease); }
/* Head and foot stay put; only the body scrolls (long forms on short phones). */
.dialog > form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; gap: 0; }
.dialog__head, .dialog__foot { flex: none; }
.dialog__body { flex: 1 1 auto; min-height: 0; }
.dialog::backdrop { background: color-mix(in srgb, var(--lav-ink) 28%, transparent); backdrop-filter: blur(4px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 6px; }
.dialog__head p { color: var(--ink-2); font-size: var(--fs-s); margin-top: 4px; }
.dialog__body { padding: 12px 22px 6px; overflow-y: auto; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; border-top: 1px solid var(--line); background: var(--surface-solid); }
.dialog--confirm .dialog__foot { border-top: 0; }
.dialog--confirm { width: min(420px, calc(100vw - 32px)); text-align: center; }
.dialog--confirm .dialog__head { flex-direction: column; align-items: center; padding-top: 26px; }
.dialog--confirm .dialog__foot { justify-content: center; }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--neg-bg); color: var(--neg); margin-bottom: 6px; }
.confirm-icon svg { width: 26px; height: 26px; stroke: currentColor; }
.confirm-detail { margin: 6px auto 0; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: var(--fs-s); display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-region {
  position: fixed; z-index: 80; top: calc(74px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 12px 12px 12px 14px; border-radius: 18px; background: var(--surface-solid); border: 1px solid var(--line);
  box-shadow: var(--shadow); animation: toast-in var(--t-slow) var(--ease);
  position: relative; overflow: hidden;
}
.toast.is-leaving { animation: toast-out var(--t) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast__icon { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; }
.toast__icon svg { width: 18px; height: 18px; stroke: currentColor; }
.toast--success .toast__icon { background: var(--pos-bg); color: var(--pos); }
.toast--error .toast__icon { background: var(--neg-bg); color: var(--neg); }
.toast--info .toast__icon { background: var(--info-bg); color: var(--info); }
.toast b { display: block; font-size: var(--fs-m); }
.toast p { font-size: var(--fs-s); color: var(--ink-2); }
.toast__timer { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--rose), var(--c3)); animation: timer linear forwards; }
.toast:hover .toast__timer { animation-play-state: paused; }
@keyframes timer { from { width: 100%; } to { width: 0; } }

/* ==========================================================================
   Empty & loading states
   ========================================================================== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 38px 20px; }
.empty__art { width: 150px; height: 120px; }
.empty__art .float { animation: bob 6s ease-in-out infinite; }
.empty h3 { font-size: var(--fs-xl); }
.empty p { color: var(--ink-2); max-width: 42ch; }
.empty .btn { margin-top: 6px; }

.skeleton { position: relative; overflow: hidden; border-radius: 10px; background: var(--surface-2); }
.skeleton::after { content: ""; position: absolute; inset: 0; translate: -100% 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--pink) 70%, transparent), transparent); animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { to { translate: 100% 0; } }
.sk-line { height: 12px; }
.sk-value { height: 26px; width: 70%; }
.sk-chart { height: 220px; border-radius: var(--r-m); }
.loader { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); font-weight: 700; }
.loader .sparkle { color: var(--rose-deep); animation: spin-twinkle 1.2s var(--ease) infinite; }
@keyframes spin-twinkle { 50% { transform: rotate(45deg) scale(0.7); opacity: 0.6; } 100% { transform: rotate(90deg) scale(1); } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Mini music player
   ========================================================================== */
.music {
  position: fixed; z-index: 40;
  right: calc(18px + env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 6px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--surface-solid) 88%, transparent); backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  max-width: calc(100vw - 36px);
  transition: border-radius var(--t) var(--ease), padding var(--t) var(--ease);
}
.music__disc {
  position: relative; isolation: isolate; overflow: hidden;
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 0; cursor: pointer;
  background: transparent; color: var(--on-rose);
}
.music__disc::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--c1), var(--c3), var(--c2), var(--c5), var(--c4), var(--c1));
}
.music__disc svg { width: 18px; height: 18px; fill: currentColor; stroke: none; background: var(--surface-solid); border-radius: 50%; padding: 6px; box-sizing: content-box; }
.music.is-playing .music__disc::before { animation: spin 6s linear infinite; }
.music__info { min-width: 0; display: none; flex-direction: column; line-height: 1.2; }
.music__info b { font-size: var(--fs-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.music__info span { font-size: var(--fs-xs); color: var(--ink-2); }
.music__eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.music__eq i { width: 3px; background: var(--rose-deep); border-radius: 2px; height: 30%; }
.music.is-playing .music__eq i { animation: eq 0.9s ease-in-out infinite; }
.music.is-playing .music__eq i:nth-child(2) { animation-delay: -0.3s; }
.music.is-playing .music__eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 50% { height: 100%; } }
.music__controls { display: none; align-items: center; gap: 6px; }
.music__vol { width: 96px; accent-color: var(--rose-deep); }
.music.is-open .music__info, .music.is-open .music__controls { display: flex; }
.music.is-open { padding-right: 10px; }
.music__empty { font-size: var(--fs-xs); color: var(--ink-2); max-width: 210px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 70; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh;
    translate: -105% 0; transition: translate var(--t-slow) var(--ease); box-shadow: var(--shadow-lg);
    background: var(--surface-solid);
  }
  .sidebar.is-open { translate: 0 0; }
  .scrim { position: fixed; inset: 0; z-index: 65; background: color-mix(in srgb, var(--lav-ink) 30%, transparent); backdrop-filter: blur(2px); }
  .topbar__menu { display: inline-flex; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .page { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 18px 110px; gap: 18px; }
}
@media (max-width: 560px) {
  .stats { gap: 10px; }
  .stat { padding: 13px 14px; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .hero__art { width: 170px; height: 170px; right: -62px; top: -58px; opacity: 0.55; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .donut-list { width: 100%; }
  .dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .dialog[open] { animation: sheet-in var(--t-slow) var(--ease); }
  .dialog--confirm { margin: auto; border-radius: var(--r-xl); width: calc(100vw - 32px); }
  .toast-region { left: max(14px, env(safe-area-inset-left, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); width: auto; }
  .btn-label-sm { display: none; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

/* ==========================================================================
   Reduced motion: decoration stops, feedback stays instant
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .cloud { display: none; }
  .chart .draw { stroke-dashoffset: 0; }
  .skeleton::after { display: none; }
}
