/* ============================================================
   Финансовый дневник — design system
   Ash-gray · tangelo · powder · Playfair Display / Jost / JetBrains Mono

   Note on the palette: the three brand hexes (#A3C1BF ash-gray,
   #EA4501 tangelo, #FFFFEB powder) are all LIGHT colours — none of
   them can serve as a literal dark background, so --bg-* below is a
   derived dark ramp, not the literal light hex.

   That ramp's hue moved from ash-gray's own ~176° (teal) to ~213°
   (navy-blue) in this pass — the earlier reference the card system is
   built from read as "тёмно-синеватая" (dark blue-ish), and the navy
   ramp turned out to be a strict accessibility win too, not just a
   mood match: tangelo-on-card-surface went 3.58:1 → 4.13:1, --text-3
   4.70:1 → 5.43:1, every other pair improved or held. Powder is still
   the primary light text colour; ash-gray/tangelo/powder themselves
   are unchanged literal tokens.
   ============================================================ */

:root {
  /* ---- surfaces: dark ramp, navy-blue hue (~213°) ---- */
  --bg-0: #0a0e12;        /* page canvas, darkest */
  --bg-1: #121921;        /* hero/panel base */
  --bg-2: #1b242f;        /* inputs, slightly raised */
  --bg-3: #243040;        /* most raised surface */
  --surface-card: rgba(25, 33, 44, 0.72);
  --surface-card-solid: #19212c;
  --border: rgba(255, 255, 235, 0.13);
  --border-strong: rgba(255, 255, 235, 0.26);

  --ash-gray: #a3c1bf;    /* literal brand hex — decorative use only */
  --ash-gray-dim: #8fadab; /* muted ash-gray for neutral card labels — checked: 5.84:1 on --card-bg */

  /* ---- text: powder ramp ---- */
  --text-0: #ffffeb;
  --text-1: #c9d9d8;
  --text-2: #96b6b3;
  /* lightened from the initial #587e7c — that read only 3.13:1 against
     --surface-card-solid (modal bg), under the 4.5:1 floor for small text;
     this hits 4.70:1 against that worst-case surface. */
  --text-3: #6e9e9b;

  --powder: #ffffeb;
  --powder-dim: #c9d9d8;

  /* ---- brand accent: tangelo (buttons, focus, glow, brand marks) ---- */
  --accent: #ea4501;
  --accent-bright: #ff6a2e;
  --accent-dim: rgba(234, 69, 1, 0.18);
  --accent-ink: #0a0e12;  /* dark text ON a tangelo fill — tangelo is too
                              bright for light text at small sizes (checked: 3.88:1);
                              this pairing re-checked at 4.79:1 with the navy ramp */
  --tangelo: #ea4501;

  /* ---- semantic accents (data meaning) — recoloured onto our 3-hex
     brand palette instead of the generic green/amber/blue a card-grid
     dashboard usually reaches for. income (profit) = tangelo, the
     "positive/accent" hue; life-spend = ash-gray; invest-spend = a
     deeper, more saturated shade of the same ash-gray family (kept
     distinct in lightness so the two spend categories don't collapse
     into the same colour). warn stays red — alerts only, not a
     category. All checked ≥3:1 against --surface-card-solid at the
     large/bold sizes card numbers use (tangelo: 3.58:1, large-text floor). */
  --income: #ea4501;
  --income-dim: rgba(234, 69, 1, 0.16);
  --life: #a3c1bf;
  --life-dim: rgba(163, 193, 191, 0.14);
  --invest: #6fa6a2;
  --invest-dim: rgba(111, 166, 162, 0.16);
  --warn: #ff7a6b;
  --warn-dim: rgba(255, 122, 107, 0.16);
  --neutral: #c9d9d8;
  --furniture: #e8c468; /* matches chart.js's C.furniture — profit-bar's second segment */

  /* ---- card system ---- */
  --card-bg: var(--surface-card-solid);
  --card-border: var(--border);
  --card-radius: 18px;
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 36px -22px rgba(0, 0, 0, 0.65);

  /* ---- type ---- */
  --font-display: "Playfair Display", "Iowan Old Style", Georgia, serif;
  --font-ui: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* ---- scale (8pt) ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px -18px rgba(0, 0, 0, 0.7);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 22px 48px -20px rgba(0, 0, 0, 0.8);

  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.5, 0, 0.2, 1);

  --page-max: 1080px;
}

/* ============================================================ reset ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Any class-level `display` (e.g. .btn's inline-flex) is author-origin and
   beats the user-agent's `[hidden] { display: none }` rule regardless of
   specificity — author-normal always outranks UA-normal in the cascade.
   Without this, a hidden .btn (or any element whose class sets display)
   stays visually visible even though the hidden IDL attribute reads true. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { color: var(--text-0); font-weight: 600; line-height: 1.2; }

button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-2);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--text-1);
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible {
  /* accent-bright fails 3:1 non-text contrast against the dark green base —
     cream clears it comfortably (8.96:1) and is the standard high-contrast
     choice for focus rings on a dark theme anyway. */
  outline: 2px solid var(--powder);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: rgba(168, 52, 46, 0.35); color: var(--powder); }

/* ============================================================ ambient ========== */
/* Fixed, viewport-covering — screen-space texture + a flat fallback tint
   only. The actual colour story lives in .scene-bg (below), which scrolls
   WITH the content, because a position:fixed layer can only ever show one
   viewport-height's worth of gradient — anything scrolled past that was a
   flat dead-end, which is exactly the seam this replaces. */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: var(--bg-0);
}

.ambient__grain {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* One continuous gradient spanning the FULL scrollable height (not the
   viewport) — lives inside [data-scroll-container] so it scrolls together
   with the content under Locomotive's transform, revealing different
   blooms at different scroll depths with no visible seam between them. */
[data-scroll-container] {
  position: relative;
  isolation: isolate; /* traps .scene-bg's z-index:-1 inside this layer */
}
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 82% 4%, rgba(234, 69, 1, 0.34), transparent 60%),
    radial-gradient(800px 550px at 8% 24%, rgba(163, 193, 191, 0.40), transparent 55%),
    radial-gradient(900px 650px at 85% 48%, rgba(234, 69, 1, 0.22), transparent 58%),
    radial-gradient(850px 600px at 6% 70%, rgba(163, 193, 191, 0.30), transparent 55%),
    radial-gradient(950px 650px at 80% 90%, rgba(234, 69, 1, 0.26), transparent 58%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 16%, var(--bg-0) 84%, var(--bg-3) 100%);
}

/* Reactive glow near the balance number — was page-fixed, now scoped to
   .hero so it scrolls away with it instead of floating over later sections. */
/* Resized for the compact hero card (was tuned for the old 72vh-tall
   borderless hero — 46vw would dwarf a ~340px card). */
.hero__glow {
  position: absolute;
  top: -15%;
  left: 4%;
  width: 55%;
  max-width: 340px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-color, rgba(255, 255, 235, 0.20)), transparent 68%);
  filter: blur(40px);
  opacity: 0.6;
  pointer-events: none;
  transition: background 1.2s var(--ease-in-out), opacity 1.2s var(--ease-in-out);
}

/* ============================================================ topbar ========== */
/* Fixed header, outside [data-scroll-container] entirely — Locomotive
   fakes scroll with a transform on that container, and a transform on
   an ancestor creates a new containing block that breaks true
   viewport-fixed (and position:sticky) positioning for anything inside
   it. Living outside means the brand + last-entry date stay visible
   through scroll, and can never be clipped by it. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(10, 14, 18, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.topbar__brand { display: flex; align-items: center; gap: var(--s-4); }

.topbar__titles { display: flex; flex-direction: column; gap: 8px; }

/* Brand wordmark: Podkova, bold, wide tracking, plain solid tangelo (no
   neon text-shadow stack — that read as a cheap sign-shop glow) with a
   thin accent rule underneath standing in for "structure" instead. Not
   Playfair/Prata by request — Podkova's warm, rounded slab-serif forms
   read with far more presence at this weight than either did, and it's
   deliberately NOT the site's --font-display (Playfair, still used for
   the hero number and panel titles) — a wordmark earns its own face. */
.topbar__glow-title {
  font-family: 'Podkova', var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.15; /* >1 on purpose: Podkova's bold ascenders/diacritic
    headroom sit slightly outside a line-height:1 box, and this element
    lives at the very top of a fixed header — no margin for a font
    metric to poke past its own line box here. */
  color: var(--tangelo);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
[data-glow-title="soft"] .topbar__glow-title {
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5), 0 0 18px var(--accent-dim);
}
.topbar__rule {
  width: 64px;
  height: 3px;
  background: var(--tangelo);
  border-radius: 2px;
}

.topbar__name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.topbar__meta { text-align: right; display: flex; flex-direction: column; gap: 1px; }
.topbar__meta-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-3);
}
.topbar__meta-value { font-family: var(--font-mono); font-size: 13px; color: var(--text-1); }

/* ============================================================ page layout ===== */
.page {
  max-width: var(--page-max);
  margin: 0 auto;
  /* top padding clears the fixed .topbar's own height + breathing room */
  padding: calc(var(--s-6) + 96px) var(--s-5) var(--s-9);
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
}

/* Card grid, not a continuous scene: each section holds one or more
   .card tiles against the shared page backdrop (.scene-bg). The tiles
   themselves carry the visual rhythm now, so no inter-section divider
   line is needed the way it was in the borderless "unified scene". */
main.page > section {
  position: relative;
}

/* ============================================================ card ========== */
/* Shared visual unit for every data block: hero, metric tiles, chart,
   ledger/modal. Explicit background + border + shadow — the opposite of
   the earlier "blend into the scene" approach, by request. */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

/* ============================================================ hero =========== */
/* Back to a real card — explicit border/background/shadow, not text
   floating on .scene-bg. The mascot moved from a half-screen bleeding
   portrait to a small badge in the corner: a status indicator for the
   balance's mood, not a competing focal point. */
.hero {
  position: relative;
  overflow: hidden; /* the internal glow stays inside the card's rounded corners */
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--s-7);
  min-height: 300px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(560px 380px at 16% 12%, rgba(234, 69, 1, 0.14), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

.hero__figure { position: relative; z-index: 2; max-width: 60%; }

/* ============================================================ mascot ========= */
/* Status badge, not a portrait — but big enough to actually read as a
   character, not an icon. Pinned to the vertical centre of the card's
   right edge rather than a corner, so it sits as a proper second focal
   point next to the balance instead of a small tucked-away detail.
   Every layer inside (.mascot__tilt/.stage/etc.) is untouched —
   mascot.js's breathing/blink/level-crossfade hooks don't know or care
   how big their container is. */
.hero__mascot {
  position: absolute;
  /* top:50% + margin-top (not transform:translateY(-50%)) — mascot.js's
     pulse() animates `transform: scale(...)` on this same element via
     GSAP, which would silently clobber a CSS translateY sharing that
     property. Margin-based centering has zero overlap with it. */
  top: 50%;
  margin-top: -108px;
  right: var(--s-7);
  width: 216px;
  height: 216px;
  z-index: 3;
  pointer-events: none;
  border-radius: 28%;
  overflow: hidden;
  border: 3px solid var(--mascot-ring-color, var(--border-strong));
  box-shadow: 0 14px 32px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.3);
  background: var(--bg-1);
  transition: border-color 0.6s var(--ease-in-out);
}

.mascot__glow {
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 45%,
    var(--mascot-glow-inner, #b8511e) 0%,
    var(--mascot-glow-outer, #6e3011) 45%,
    transparent 72%
  );
  filter: blur(2px);
  opacity: var(--mascot-glow-opacity, 0.5);
  will-change: transform;
}

.mascot__particles {
  position: absolute;
  inset: -10% -10% 10% -10%;
  overflow: visible;
  pointer-events: none;
}
.mascot__particle {
  position: absolute;
  border-radius: 50%;
  background: var(--mascot-particle-color, #a6927c);
  opacity: 0;
  animation: mascotParticleDrift var(--dur, 9s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes mascotParticleDrift {
  0%   { transform: translate(0, 0) scale(0.8); opacity: 0; }
  15%  { opacity: var(--peak, 0.55); }
  50%  { transform: translate(var(--dx, 8px), calc(var(--dy, -18px) * 1)) scale(1); }
  85%  { opacity: var(--peak, 0.55); }
  100% { transform: translate(calc(var(--dx, 8px) * 1.6), calc(var(--dy, -18px) * 1.8)) scale(0.8); opacity: 0; }
}

/* ============================================================ bg symbols ===== */
/* Floating $ / ₿ behind the content — atmospheric, not decorative confetti.
   Sits behind every section's own content but above .scene-bg (see the
   isolation:isolate on [data-scroll-container] that traps this z-index). */
.bg-symbols {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}
.bg-symbol {
  position: absolute;
  display: block;
  opacity: 0;
  transform: rotate(var(--rot, 0deg));
  animation: bgSymbolDrift var(--dur, 40s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  will-change: transform, opacity;
}
.bg-symbol img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}
@keyframes bgSymbolDrift {
  0%   { transform: translate(0, 0) rotate(var(--rot, 0deg)) scale(0.88); opacity: 0; }
  12%  { opacity: var(--peak, 0.12); }
  50%  { transform: translate(var(--dx, 14px), var(--dy, -30px)) rotate(calc(var(--rot, 0deg) * -1)) scale(1); opacity: calc(var(--peak, 0.12) * 0.72); }
  88%  { opacity: var(--peak, 0.12); }
  100% { transform: translate(calc(var(--dx, 14px) * 1.6), calc(var(--dy, -30px) * 1.8)) rotate(var(--rot, 0deg)) scale(0.88); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-symbol { animation: none !important; }
}

.mascot__shadow {
  position: absolute;
  left: 50%;
  bottom: 4%;
  width: 62%;
  height: 9%;
  transform: translate(-50%, 0);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 72%);
  filter: blur(4px);
  will-change: transform, opacity;
}

/* Two separate transform owners so they don't clobber each other:
   .mascot__tilt gets rotateX/rotateY from GSAP quickTo (cursor parallax),
   .mascot__stage gets translateY/scale from the rAF idle loop (breathe/float). */
.mascot__tilt {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 1200px;
  transform-style: preserve-3d;
  will-change: transform;
}

.mascot__stage {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}

.mascot__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: transform, opacity;
  transform-style: preserve-3d;
}
.mascot__layer.is-active { opacity: 1; }

.mascot__img, .mascot__placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%; /* chest-up portraits: ground them at the shadow, headroom goes up */
}
/* Closed-eyes layer sits stacked exactly on top of the open one, at
   opacity 0 until a blink (mascot.js) briefly raises it. */
.mascot__img--closed { opacity: 0; pointer-events: none; will-change: opacity; }
.mascot__placeholder { border-radius: 46% 46% 42% 42% / 52% 52% 40% 40%; }
.mascot__layer[data-mascot-layer="poor"] .mascot__placeholder {
  background: radial-gradient(circle at 35% 28%, #2a384a, #131921 55%, #0a0e12 100%);
}
.mascot__layer[data-mascot-layer="mid"] .mascot__placeholder {
  background: radial-gradient(circle at 35% 28%, #b8511e, #6e3011 55%, #3a1a09 100%);
}
.mascot__layer[data-mascot-layer="rich"] .mascot__placeholder {
  background: radial-gradient(circle at 35% 28%, #ff6a2e, #ea4501 55%, #a8320a 100%);
}

@media (max-width: 768px) {
  .hero { padding: var(--s-5); min-height: auto; }
  .hero__figure { max-width: calc(100% - 150px); }
  .hero__mascot { top: 50%; margin-top: -60px; right: var(--s-5); width: 120px; height: 120px; border-width: 2px; }
}

.hero__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-2);
  margin-bottom: var(--s-3);
}

/* Mono, not the display serif — financial figures read cleaner with
   tabular, unambiguous digits than in a display face, and it matches
   every other number on the page (.stat-row__value is already mono).
   Editorial-scale: this is the single dominant figure on the page now
   that there's no card holding it, so it can go much bigger than the
   old compact-card version. */
.hero__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(2.6rem, 5.6vw, 4.2rem);
  line-height: 1;
  color: var(--text-0);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Pill again — back inside a real card, the plain-text delta from the
   editorial pass read as under-weighted next to a bordered hero. */
.hero__delta {
  margin-top: var(--s-4);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3) 6px var(--s-2);
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.hero__delta-caption { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.1em; }
.hero__delta-value { font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.hero__delta-value[data-dir="up"]::before { content: "▲ "; font-size: 10px; }
.hero__delta-value[data-dir="down"]::before { content: "▼ "; font-size: 10px; }
.hero__delta-value[data-dir="up"] { color: var(--income); }
.hero__delta-value[data-dir="down"] { color: var(--warn); }
.hero__delta-value[data-dir="flat"] { color: var(--text-1); }

.hero__empty { margin-top: var(--s-4); color: var(--text-2); font-size: 14px; max-width: 32ch; }

/* ============================================================ panel ========== */
.panel {
  padding-block: var(--s-4);
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
}

/* Sits directly on .scene-bg, not inside a card — depending on scroll
   position that can be the lighter ash-gray blob, not the dark base,
   which dropped this to ~4.05:1 at weight 500 (checked by sampling the
   actual rendered pixel, not just the CSS token). Weight 700 both reads
   better as a section heading and clears the WCAG large-text bar (≥3:1)
   outright; the text-shadow is a small always-on safety margin for
   whatever the gradient happens to be doing underneath. */
.panel__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* text-shadow inherits to .panel__days-ago automatically — same
   legibility safety net as .panel__title (sits directly on .scene-bg). */
.panel__hint { font-size: 12.5px; color: var(--text-2); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.panel__days-ago { color: var(--text-3); }
.panel__meta { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }

/* ============================================================ metrics ======== */
/* Back to explicit cards — background, border, shadow, radius — per
   request. Each card keeps the meaningful composition bar from the
   editorial pass (data-bar wiring in app.js is markup-agnostic, it just
   needed a home again); app.js now animates the bar filling in with
   GSAP rather than snapping to its final width. */
.metrics { display: grid; gap: var(--s-5); }
.metrics--3 { grid-template-columns: repeat(3, 1fr); }
.metrics--4 { grid-template-columns: repeat(4, 1fr); }
.metrics--5 { grid-template-columns: repeat(4, 1fr); }
.metric--wide { grid-column: 1 / -1; }

.metric {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--s-5);
  overflow: hidden;
  will-change: transform;
}

.metric[data-accent="income"]  { --accent: var(--income); }
.metric[data-accent="life"]    { --accent: var(--life); }
.metric[data-accent="invest"]  { --accent: var(--invest); }
.metric[data-accent="neutral"] { --accent: var(--neutral); }

.metric__label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ash-gray-dim);
  margin-bottom: var(--s-3);
}

.metric__value {
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  font-weight: 700;
  color: var(--accent, var(--text-0));
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.metric__value-sub {
  font-size: 62%;
  font-weight: 600;
  color: var(--text-2);
  margin-left: var(--s-2);
}

.metric__sub { margin-top: var(--s-2); font-size: 11px; color: var(--text-3); }
.metric__sub .mono { color: var(--text-1); }

.metric--wide .metric__value { font-size: clamp(1.4rem, 3vw, 2rem); }

.metric__bar {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border);
  margin-top: var(--s-4);
}
.metric__bar i { display: block; height: 100%; transform-origin: left center; }

/* ============================================================ segmented ====== */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}

.segmented__btn {
  padding: var(--s-2) var(--s-4);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.segmented__btn:hover { color: var(--text-1); }
.segmented__btn.is-active { background: var(--bg-3); color: var(--text-0); box-shadow: var(--shadow-card); }

/* ============================================================ chart ========== */
/* No card — a hairline top rule, same language as .stat-row, so the
   chart reads as part of the statement flow rather than a boxed widget. */
.chart-wrap {
  position: relative;
  height: 368px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--s-5);
}
.chart-wrap canvas { width: 100% !important; }

/* ============================================================ ledger ======== */
.table-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--s-2)); padding: 0 var(--s-2); }

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 780px;
}

.ledger thead th {
  text-align: right;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 0 var(--s-3) var(--s-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ledger thead th.ledger__date,
.ledger thead th.ledger__check,
.ledger thead th.ledger__actions { text-align: left; }
.ledger th[data-accent-th="life"] { color: var(--life); }
.ledger th[data-accent-th="invest"] { color: var(--invest); }

.ledger td {
  padding: var(--s-3);
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  white-space: nowrap;
}
.ledger tbody tr { transition: background 0.15s var(--ease-out); }
.ledger tbody tr:hover { background: rgba(255, 255, 255, 0.022); }
.ledger tbody tr:last-child td { border-bottom: none; }

.ledger__date { text-align: left !important; font-family: var(--font-mono); color: var(--text-0); }
.ledger .col-total { color: var(--text-0); font-weight: 600; }
.ledger .col-diff[data-dir="up"] { color: var(--income); }
.ledger .col-diff[data-dir="down"] { color: var(--warn); }
.ledger .col-life { color: var(--life); }
.ledger .col-invest { color: var(--invest); }
.ledger .col-net[data-dir="up"] { color: var(--income); }
.ledger .col-net[data-dir="down"] { color: var(--warn); }

.ledger__cell-check { text-align: left !important; }

.check-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  padding: 2px var(--s-2);
  border-radius: 999px;
  white-space: nowrap;
}
.check-badge[data-state="ok"]   { background: var(--income-dim); color: var(--income); }
.check-badge[data-state="warn"] { background: var(--warn-dim); color: var(--warn); }
.check-badge[data-state="none"] { color: var(--text-3); }

.ledger__cell-actions { text-align: left !important; }
.row-action {
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--text-2);
  padding: 2px var(--s-2);
  border-radius: 6px;
  transition: color 0.12s var(--ease-out), background 0.12s var(--ease-out);
}
.row-action:hover { color: var(--text-0); background: var(--bg-3); }

/* ============================================================ empty state ==== */
.empty-state { text-align: center; padding: var(--s-6) var(--s-4); }
.empty-state__text { color: var(--text-2); margin-bottom: var(--s-4); }

/* ============================================================ record actions = */
.record-actions {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  justify-content: center;
  padding: var(--s-6) 0;
}

/* ============================================================ modal ========== */
/* Native <dialog> — top-layer rendering means it's unaffected by
   Locomotive Scroll's transform on [data-scroll-container], so it needs
   no special scroller wiring. */
/* .modal picks up `display: flex` only while [open] — otherwise it must
   stay `display: none` like the UA stylesheet's dialog:not([open]) rule,
   which this class would silently override (author styles beat UA styles
   at equal-or-lower specificity, regardless of the :not([open]) itself
   being more specific) and leave a "closed" dialog laid out inline at
   the bottom of the page. */
.modal {
  width: min(640px, calc(100vw - var(--s-6)));
  max-height: min(84vh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  background: var(--card-bg);
  color: var(--text-0);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.modal:not([open]) { display: none; }
.modal[open] { display: flex; flex-direction: column; }
.modal--wide { width: min(880px, calc(100vw - var(--s-6))); }

.modal::backdrop {
  background: rgba(4, 8, 8, 0.72);
  backdrop-filter: blur(3px);
}

.modal[open] {
  animation: modalIn 0.22s var(--ease-out);
}
.modal[open]::backdrop {
  animation: modalBackdropIn 0.22s var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalBackdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .modal[open], .modal[open]::backdrop { animation: none; }
}

.modal__form { display: flex; flex-direction: column; min-height: 0; }

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.modal__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-0);
}
.modal__close {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--text-2);
  transition: color 0.14s var(--ease-out), background 0.14s var(--ease-out);
}
.modal__close:hover { color: var(--text-0); background: var(--bg-3); }

.modal__body {
  padding: var(--s-5) var(--s-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.modal__hint { margin-bottom: var(--s-2); }

.modal__actions {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: center;
  padding: var(--s-5) var(--s-6);
  border-top: 1px solid var(--border);
  flex: none;
}

/* ---- row-based fields, spreadsheet-style: label left, input right ---- */
.row-group__label {
  margin-top: var(--s-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-2);
}
.row-group__note { text-transform: none; letter-spacing: 0; color: var(--text-3); font-size: 10.5px; }

.row-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.row-field--date { border-bottom: none; padding-top: 0; }
.row-field__label {
  font-size: 13.5px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.field__sign { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.row-field--income .field__sign { color: var(--income); }
.row-field--life .field__sign    { color: var(--life); }
.row-field--invest .field__sign  { color: var(--invest); }

.row-field__input {
  width: 160px;
  max-width: 44vw;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--text-0);
  font-size: 14px;
  text-align: right;
  font-family: var(--font-mono);
  transition: border-color 0.15s var(--ease-out), background 0.15s var(--ease-out);
}
.row-field--date .row-field__input { text-align: left; font-family: var(--font-ui); }
.row-field__input::placeholder { color: var(--text-3); }
.row-field__input:focus { outline: none; border-color: var(--border-strong); background: var(--bg-2); }
.row-field__input:focus-visible { outline: 2px solid var(--powder); outline-offset: 1px; }
.row-field--income .row-field__input:focus { border-color: var(--income); }
.row-field--life .row-field__input:focus   { border-color: var(--life); }
.row-field--invest .row-field__input:focus { border-color: var(--invest); }

.row-field__input[type="number"]::-webkit-outer-spin-button,
.row-field__input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row-field__input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

@media (max-width: 560px) {
  .row-field__input { width: 128px; }
}

/* ---- live preview ---- */
.preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-3);
  padding: var(--s-4);
  margin-top: var(--s-3);
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  background: var(--bg-1);
}
.preview__item { display: flex; flex-direction: column; gap: var(--s-1); }
.preview__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.preview__value { font-size: 15px; font-weight: 600; color: var(--text-0); }
.preview__value[data-dir="up"] { color: var(--income); }
.preview__value[data-dir="down"] { color: var(--warn); }

@media (max-width: 560px) {
  .preview { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================ buttons ======== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.14s var(--ease-out), background 0.14s var(--ease-out), border-color 0.14s var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn--sm { padding: var(--s-2) var(--s-3); font-size: 12px; }
.btn--lg { padding: var(--s-4) var(--s-6); font-size: 15px; border-radius: var(--radius); }

.btn--primary {
  background: var(--accent);
  /* tangelo is too bright for light (--powder) text at this weight/size —
     checked: powder-on-tangelo is 3.88:1, dark-on-tangelo is 4.79:1. */
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -12px var(--accent);
}
.btn--primary:hover { background: var(--accent-bright); }

.btn--ghost {
  background: var(--bg-2);
  color: var(--text-1);
  border-color: var(--border);
}
.btn--ghost:hover { color: var(--text-0); border-color: var(--border-strong); }

.btn--danger-ghost {
  background: transparent;
  color: var(--warn);
  border-color: var(--warn-dim);
}
.btn--danger-ghost:hover { background: var(--warn-dim); }

/* ============================================================ footer ======== */
.footer {
  margin-top: var(--s-4);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.footer p { font-size: 12px; color: var(--text-3); max-width: 64ch; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.footer__actions { display: flex; gap: var(--s-2); }

/* ============================================================ toast ========= */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%) translateY(12px);
  padding: var(--s-3) var(--s-5);
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  color: var(--text-0);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[data-tone="warn"] { border-color: var(--warn); }

/* ============================================================ reveal state == */
.reveal { opacity: 1; }
.js-motion .reveal { opacity: 0; }

/* ============================================================ responsive ==== */
@media (max-width: 900px) {
  .hero__delta { margin-inline: auto; }
  .metrics--3, .metrics--4, .metrics--5 { grid-template-columns: repeat(2, 1fr); }
  .preview { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .page { padding: calc(var(--s-5) + 76px) var(--s-4) var(--s-8); gap: var(--s-5); }
  .panel { padding: var(--s-5) var(--s-4); }
  .hero { padding: var(--s-6) var(--s-4); }
  /* Badge shrinks further here — at 120px (the 768px-breakpoint size) it
     was eating so much width that the delta pill had nowhere to go and
     wrapped across 3 cramped lines. */
  .hero__figure { max-width: calc(100% - 96px); }
  .hero__mascot { margin-top: -44px; right: var(--s-4); width: 88px; height: 88px; }
  .metrics--3, .metrics--4, .metrics--5 { grid-template-columns: 1fr; }
  .preview { grid-template-columns: 1fr 1fr; }
  .topbar__inner { padding: var(--s-3) var(--s-4); }
  .modal__head, .modal__body, .modal__actions { padding-left: var(--s-4); padding-right: var(--s-4); }
  .row-field { flex-wrap: wrap; }
}

/* ============================================================ reduced motion = */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js-motion .reveal { opacity: 1 !important; transform: none !important; }
  .ambient__glow { transition: none; }
}
