/* ==========================================================================
   RescueWallet — Budget Tracker
   Design tokens + layout. Light/dark aware.
   ========================================================================== */

:root {
  /* Surfaces — warmer, softer off-whites (less clinical) */
  --page:          #f3f4f2;
  --surface:       #ffffff;
  --surface-2:     #f7f8f6;
  --border:        rgba(30, 41, 38, 0.09);
  --border-strong: rgba(30, 41, 38, 0.15);

  /* Ink — slightly warmed, lower contrast than pure slate */
  --text:          #1f2a27;
  --text-2:        #52605b;
  --muted:         #8a9490;

  /* Brand — muted sage-green, less saturated than before */
  --brand:         #3a7d5f;
  --brand-2:       #2b6349;
  --brand-ink:     #ffffff;

  /* Semantics — softened, less alarming */
  --income:        #3f9c6d;
  --income-soft:   rgba(63, 156, 109, 0.12);
  --expense:       #c76b62;
  --expense-soft:  rgba(199, 107, 98, 0.12);

  /* Categorical — desaturated, harmonious dataviz palette (light mode) */
  --c1: #5b87c4; --c2: #4f9e7a; --c3: #d3a24e; --c4: #4a9d6f;
  --c5: #b08a5f; --c6: #cc7b74; --c7: #c98db0; --c8: #d1895f;

  --radius:   14px;
  --radius-s: 10px;
  --shadow:   0 1px 2px rgba(17,24,39,.06), 0 8px 24px rgba(17,24,39,.06);
  --ring:     0 0 0 3px rgba(28,92,67,.25);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page:          #14161a;
    --surface:       #1b1e23;
    --surface-2:     #22262c;
    --border:        rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.15);
    --text:          #eceef0;
    --text-2:        #b3bcbf;
    --muted:         #828d90;
    --brand:         #5aa985;
    --brand-2:       #6fbf9a;
    --brand-ink:     #12161a;
    --income:        #5cbf8c;
    --income-soft:   rgba(92,191,140,0.14);
    --expense:       #d98b83;
    --expense-soft:  rgba(217,139,131,0.14);
    --c1:#6d97cf; --c2:#5aad86; --c3:#cea560; --c4:#5aad7f;
    --c5:#bf9770; --c6:#d68981; --c7:#cf9bbb; --c8:#d89873;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 800; font-size: 20px; letter-spacing: -0.02em;
}
.brand .logo {
  width: 34px; height: 34px; display: block;
  filter: drop-shadow(0 3px 6px rgba(58,125,95,.3));
}
/* Wordmark: every letter of "Rescue" slanted; "Wallet" in brand green. */
.wm { display: inline-flex; align-items: baseline; letter-spacing: -0.02em; }
.wm-rescue { font-style: italic; font-weight: 800; }
.wm-wallet { color: var(--brand); font-weight: 800; font-style: normal; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  text-decoration: none;
  color: var(--text-2);
  font-weight: 600; font-size: 14.5px;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--brand); color: var(--brand-ink); }
.nav-link .ico { width: 20px; text-align: center; font-size: 16px; }
.nav-link .pro-tag {
  margin-left: auto; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 15%, transparent);
  padding: 2px 6px; border-radius: 6px;
}
.nav-link.active .pro-tag { color: var(--brand-ink); background: rgba(255,255,255,.22); }

.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }

/* ---------- Main ---------- */
.main { flex: 1; padding: 32px 40px 64px; max-width: 1200px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 27px; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: 14.5px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; letter-spacing: -0.01em; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }

.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.charts { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid.charts { grid-template-columns: 1fr; } }

/* ---------- Stat tiles ---------- */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.stat .value.income { color: var(--income); }
.stat .value.expense { color: var(--expense); }
.stat .chip { align-self: flex-start; font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 14px; font-weight: 700;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); padding: 9px 15px; border-radius: var(--radius-s);
  cursor: pointer; transition: background .12s, transform .04s, border-color .12s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); background: var(--brand); }
.btn.danger { color: var(--expense); border-color: transparent; background: transparent; padding: 6px 8px; }
.btn.danger:hover { background: var(--expense-soft); }
.btn.ghost { border-color: transparent; background: transparent; padding: 6px 8px; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
input, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-s); padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 14px; }

/* Segmented income/expense toggle */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-s); padding: 3px; gap: 3px; }
.segmented button {
  border: none; background: transparent; font-family: inherit; font-weight: 700; font-size: 13.5px;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; color: var(--text-2);
}
.segmented button.on-income { background: var(--income); color: #fff; }
.segmented button.on-expense { background: var(--expense); color: #fff; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.amount-income { color: var(--income); }
.amount-expense { color: var(--expense); }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.pill.income { background: var(--income-soft); color: var(--income); }
.pill.expense { background: var(--expense-soft); color: var(--expense); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .grow { flex: 1; }
.toolbar select, .toolbar input { width: auto; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Category chips grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 12px; }
.cat-item { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface-2); }
.cat-item .swatch { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; }
.cat-item .meta { flex: 1; min-width: 0; }
.cat-item .meta .name { font-weight: 700; font-size: 14.5px; }
.cat-item .meta .count { font-size: 12px; color: var(--muted); }
.cat-item .custom-badge { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); padding: 2px 7px; border-radius: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 460px; padding: 24px; border: 1px solid var(--border); }
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: 999px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile nav ---------- */
.topbar { display: none; }
@media (max-width: 720px) {
  /* Let the page itself own vertical scrolling — no nested scroll traps. */
  html, body { height: auto; min-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
  .app { flex-direction: column; min-height: 100vh; }
  /* Nav becomes a sticky top bar so it's always one tap away while you scroll. */
  .sidebar {
    position: sticky; top: 0; z-index: 40;
    height: auto; width: 100%; flex: none;
    flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 10px 12px; gap: 6px;
    border-right: none; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.1) blur(8px);
  }
  .sidebar::-webkit-scrollbar { height: 0; }
  .brand { padding: 0 10px 0 4px; font-size: 17px; flex: 0 0 auto; }
  .nav-bottom { flex-direction: row; margin-top: 0; gap: 6px; }
  .sidebar-foot { display: none; }
  .nav-link { padding: 8px 12px; white-space: nowrap; flex: 0 0 auto; scroll-snap-align: start; }
  .nav-link .label { display: none; }
  .nav-link .pro-tag { display: none; }
  .nav-link .ico { font-size: 18px; }
  .billing-link .plan-tag { display: none; }
  /* Main region flows naturally and takes the remaining height. */
  .main { padding: 20px 16px 80px; flex: 1 1 auto; width: 100%; max-width: 100%; }
}

canvas { max-width: 100%; }
.chart-box { position: relative; height: 300px; }

/* ==========================================================================
   Additions: loading screen, animated stats, brand icons, tracker, confetti
   ========================================================================== */

/* ---------- Splash / loading screen ---------- */
/* Dark intimate green, subtle spotlight, brown winged wallet fading in from
   zipped to open. No wordmark, tagline, or progress bar. */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background:
    radial-gradient(62% 55% at 50% 44%, #10402f 0%, #0a2c20 45%, #041610 100%);
  transition: opacity .6s ease, visibility .6s ease;
  overflow: hidden;
}
.splash.hide { opacity: 0; visibility: hidden; }
/* soft spotlight glow behind the wallet */
.splash .spotlight {
  position: absolute; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(150,240,200,.20), rgba(120,220,180,.07) 45%, transparent 70%);
  filter: blur(2px);
  animation: spotPulse 3.4s ease-in-out infinite;
}
.splash .splash-wallet {
  position: relative; width: 200px; height: auto;
  filter: drop-shadow(0 26px 50px rgba(0,0,0,.55));
  /* fade in, then a slow soaring drift */
  animation: walletIn 1s ease-out both, soar 4.2s ease-in-out 1.1s infinite;
}
/* leather flaps spread open once, hinged at the center-bottom fold */
.splash .flap { transform-box: fill-box; }
.splash .flap.l { transform-origin: 100% 100%; animation: openL 1s cubic-bezier(.2,.85,.3,1) .2s both; }
.splash .flap.r { transform-origin: 0% 100%; animation: openR 1s cubic-bezier(.2,.85,.3,1) .2s both; }

@keyframes walletIn { 0% { opacity: 0; transform: scale(.6); } 100% { opacity: 1; transform: scale(1); } }
@keyframes soar { 0%,100% { transform: translateY(0) rotate(-1.5deg) scale(1); } 50% { transform: translateY(-11px) rotate(1.5deg) scale(1); } }
@keyframes spotPulse { 0%,100% { opacity: .8; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes openL { 0% { transform: rotate(-44deg); opacity: .25; } 100% { transform: rotate(0); opacity: 1; } }
@keyframes openR { 0% { transform: rotate(44deg); opacity: .25; } 100% { transform: rotate(0); opacity: 1; } }

/* ---------- Animated dashboard stat values ---------- */
.stat .value.cycle { transition: opacity .42s ease, transform .42s ease; }
.stat .value.cycle.faded { opacity: 0; transform: translateY(6px); }
.scope-badge {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
  padding: 5px 11px; border-radius: 999px;
}
.scope-badge .live-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--brand); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }

/* ---------- Brand category icon tiles ---------- */
.cat-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex: 0 0 auto; }
.cat-icon svg { width: 26px; height: 26px; }
.chip-icon { width: 20px; height: 20px; display: inline-grid; place-items: center; }
.chip-icon svg { width: 18px; height: 18px; }

/* ---------- Transactions grey example tiles ---------- */
.stat.example .value { color: var(--muted) !important; }
.stat.example .example-tag {
  align-self: flex-start; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent);
  padding: 2px 8px; border-radius: 6px;
}

/* ---------- Tracker page ---------- */
.hero-goal {
  background: linear-gradient(135deg, #3a7d5f, #2f6a50 55%, #26533f);
  color: #fff; border: none; overflow: hidden; position: relative;
}
.hero-goal::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.hero-goal .quote { font-size: clamp(24px, 3.4vw, 36px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; line-height: 1.2; }
.hero-goal .quote .amt { color: #ffe58a; }
.hero-goal .sub { color: rgba(255,255,255,.85); font-size: 14.5px; margin: 0 0 18px; }
.goal-chips { display: flex; flex-wrap: wrap; gap: 10px; position: relative; z-index: 1; }
.goal-chip {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); color: #fff;
  font-family: inherit; font-weight: 700; font-size: 14px; padding: 9px 15px; border-radius: 999px;
  transition: transform .1s, background .15s;
}
.goal-chip:hover { background: rgba(255,255,255,.28); transform: translateY(-2px); }
.goal-chip:active { transform: translateY(0); }
.goal-chip .amt { color: #ffe58a; }
.goal-chip .tick { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 999px; background: #fff; color: #16a34a; font-size: 12px; font-weight: 900; }

.goal-card { display: flex; flex-direction: column; gap: 12px; }
.goal-card .top { display: flex; align-items: center; gap: 12px; }
.goal-card .top .meta { flex: 1; min-width: 0; }
.goal-card .top .name { font-weight: 800; font-size: 15.5px; }
.goal-card .top .note { font-size: 12.5px; color: var(--muted); }
.goal-card.done { border-color: color-mix(in srgb, var(--income) 45%, transparent); }
.progress { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .5s ease; }
.progress i.full { background: linear-gradient(90deg, #16a34a, #22c55e); }
.goal-card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.goal-card .saved { font-weight: 800; font-variant-numeric: tabular-nums; }
.goal-card .done-badge { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--income); background: var(--income-soft); padding: 3px 9px; border-radius: 999px; }
.goal-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Reward vibes ---------- */
/* Confetti (now opt-in, no longer the default). */
.confetti-piece { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 200; pointer-events: none; border-radius: 2px; will-change: transform, opacity; }
@keyframes confettiFall { to { transform: translateY(105vh) rotate(720deg); opacity: 0; } }

/* Shared full-screen overlay for the non-confetti celebrations. */
.reward-fx { position: fixed; inset: 0; z-index: 200; pointer-events: none; overflow: hidden; }

/* ⚡ Thunder — a white flash then a lightning bolt strikes down. */
.fx-thunder .thunder-flash { position: absolute; inset: 0; background: #fff; opacity: 0; animation: thunderFlash 1.5s ease-out forwards; }
.fx-thunder .bolt { position: absolute; top: -10vh; left: 50%; width: 90px; height: auto; transform: translateX(-50%); fill: #ffe58a; filter: drop-shadow(0 0 14px rgba(255,229,138,.9)); opacity: 0; animation: boltStrike 1.4s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes thunderFlash { 0%{opacity:0} 8%{opacity:.85} 16%{opacity:.1} 24%{opacity:.7} 32%{opacity:0} 100%{opacity:0} }
@keyframes boltStrike { 0%{opacity:0;transform:translateX(-50%) translateY(-30vh) scale(.9)} 18%{opacity:1;transform:translateX(-50%) translateY(18vh) scale(1)} 60%{opacity:1} 100%{opacity:0;transform:translateX(-50%) translateY(20vh) scale(1)} }

/* ☁️ Clouds parting — two cloud halves slide apart to reveal light. */
.fx-clouds .sun { position: absolute; top: 50%; left: 50%; width: 220px; height: 220px; border-radius: 50%; transform: translate(-50%,-50%) scale(.4); background: radial-gradient(circle, rgba(255,246,214,.95), rgba(255,224,150,.5) 55%, transparent 72%); opacity: 0; animation: sunRise 2s ease-out forwards; }
.fx-clouds .cloud { position: absolute; top: 0; width: 60vw; height: 100vh; background: radial-gradient(closest-side, rgba(226,232,236,.97), rgba(203,213,219,.9)); }
.fx-clouds .cloud.left { left: 0; border-radius: 0 50% 50% 0 / 0 50% 50% 0; animation: cloudLeft 2s cubic-bezier(.4,0,.2,1) forwards; }
.fx-clouds .cloud.right { right: 0; border-radius: 50% 0 0 50% / 50% 0 0 50%; animation: cloudRight 2s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes cloudLeft { 0%{transform:translateX(0)} 100%{transform:translateX(-75vw)} }
@keyframes cloudRight { 0%{transform:translateX(0)} 100%{transform:translateX(75vw)} }
@keyframes sunRise { 0%{opacity:0;transform:translate(-50%,-50%) scale(.4)} 55%{opacity:1} 100%{opacity:0;transform:translate(-50%,-50%) scale(1.15)} }

/* ⛓️ Chains unlinking — two links pull apart and snap. */
.fx-chains { display: grid; place-items: center; }
.fx-chains .link { position: absolute; width: 62px; height: 96px; border: 13px solid #b8c0c6; border-radius: 34px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.fx-chains .link.a { animation: linkLeft 1.5s cubic-bezier(.6,-0.3,.4,1) forwards; }
.fx-chains .link.b { animation: linkRight 1.5s cubic-bezier(.6,-0.3,.4,1) forwards; }
.fx-chains .snap { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #ffe58a; box-shadow: 0 0 24px 10px rgba(255,229,138,.8); opacity: 0; animation: snapFlash 1.5s ease-out forwards; }
@keyframes linkLeft { 0%,35%{transform:translateX(-24px) rotate(0)} 100%{transform:translateX(-46vw) rotate(-40deg);opacity:0} }
@keyframes linkRight { 0%,35%{transform:translateX(24px) rotate(0)} 100%{transform:translateX(46vw) rotate(40deg);opacity:0} }
@keyframes snapFlash { 0%,33%{opacity:0} 42%{opacity:1;transform:scale(1.4)} 60%{opacity:0} 100%{opacity:0} }

/* 💥 Ground shattering — screen shakes and a crack tears across it. */
body.quaking { animation: quake .8s cubic-bezier(.36,.07,.19,.97); }
@keyframes quake { 10%{transform:translate(-2px,-3px)} 20%{transform:translate(3px,2px)} 30%{transform:translate(-4px,3px)} 40%{transform:translate(4px,-2px)} 50%{transform:translate(-3px,3px)} 60%{transform:translate(3px,-3px)} 70%{transform:translate(-2px,2px)} 80%{transform:translate(2px,-2px)} 100%{transform:translate(0,0)} }
.fx-quake .crack { position: absolute; top: 0; left: 50%; width: 4px; height: 0; transform: translateX(-50%); background: linear-gradient(#1f2a27, #52605b); clip-path: polygon(0 0,100% 6%,20% 20%,90% 34%,10% 52%,100% 66%,30% 82%,80% 100%,0 92%); animation: crackGrow 1.3s ease-out forwards; }
@keyframes crackGrow { 0%{height:0;opacity:.9} 70%{height:100vh;opacity:.9} 100%{height:100vh;opacity:0} }

/* Reward vibe picker (Chart Goals settings). */
.vibe-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.vibe-opt { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font-family: inherit; font-weight: 700; font-size: 13px; padding: 8px 13px; border-radius: 999px; cursor: pointer; transition: background .12s, color .12s, border-color .12s; }
.vibe-opt:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.vibe-opt.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- Demo Intro ---------- */
.intro-modal .intro-note p { font-size: 14px; line-height: 1.6; color: var(--text-2); margin: 0 0 12px; }
.intro-modal .intro-note b { color: var(--text); }

/* ---------- AI Insights cards ---------- */
.insight-card { position: relative; }
.insight-top { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.insight-ico { font-size: 24px; line-height: 1; flex: 0 0 auto; }
.insight-card h2 { font-size: 16px; }
.insight-evidence, .insight-rec { font-size: 14px; line-height: 1.55; margin: 0 0 10px; color: var(--text-2); }
.insight-tag { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; margin-right: 8px; padding: 2px 8px; border-radius: 6px; color: var(--muted); background: color-mix(in srgb, var(--muted) 15%, transparent); vertical-align: 1px; }
.insight-tag.rec { color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.insight-rec { color: var(--text); font-weight: 500; }
.insight-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Demo-data banner (dashboard) ---------- */
.demo-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: var(--radius); padding: 13px 16px; margin-bottom: 20px;
  font-size: 13.5px; color: var(--text-2); line-height: 1.5;
}
.demo-banner b { color: var(--text); }
.demo-banner-ico { font-size: 18px; flex: 0 0 auto; }
.demo-banner span:nth-child(2) { flex: 1; min-width: 200px; }
.demo-banner-cta {
  flex: 0 0 auto; border: none; background: var(--brand); color: var(--brand-ink);
  font-family: inherit; font-weight: 800; font-size: 13px; padding: 8px 14px;
  border-radius: 999px; cursor: pointer;
}
.demo-banner-cta:hover { filter: brightness(1.06); }

/* ==========================================================================
   Billing, plans, AI widgets
   ========================================================================== */

/* Sidebar bottom + Billing link */
.nav-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.nav-bottom .sidebar-foot { margin-top: 8px; }
.billing-link { position: relative; }
.billing-link .plan-tag {
  margin-left: auto; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); padding: 2px 7px; border-radius: 6px;
}
.billing-link.active .plan-tag { color: var(--brand-ink); background: rgba(255,255,255,.25); }

/* Modal head + close */
.modal.wide { max-width: 940px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.icon-x { border: none; background: var(--surface-2); color: var(--text-2); width: 32px; height: 32px; border-radius: 9px; font-size: 15px; cursor: pointer; line-height: 1; flex: 0 0 auto; }
.icon-x:hover { background: var(--border); }

/* Pricing tiers */
.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 780px) { .tiers { grid-template-columns: 1fr; } }
.tier { position: relative; border: 1px solid var(--border); border-radius: 14px; padding: 22px 20px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.tier.popular { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; }
.badge-pop { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 800; padding: 4px 13px; border-radius: 999px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.tier-name { font-weight: 800; font-size: 15px; }
.tier .price { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.tier .price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.tier-tag { color: var(--muted); font-size: 13px; margin-top: -4px; }
.tier ul { list-style: none; padding: 0; margin: 6px 0 8px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.tier li { display: flex; gap: 8px; align-items: flex-start; }
.tier li::before { content: "✓"; color: var(--income); font-weight: 900; flex: 0 0 auto; }
.tier .btn { margin-top: auto; justify-content: center; width: 100%; }

/* Confirmation */
.modal.confirm { position: relative; text-align: center; max-width: 420px; padding: 34px 28px 28px; }
.confirm-check { width: 62px; height: 62px; border-radius: 999px; background: var(--income-soft); color: var(--income); font-size: 32px; font-weight: 900; display: grid; place-items: center; margin: 0 auto 16px; }
.confirm-title { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
.confirm-sub { font-size: 15px; color: var(--text-2); margin: 0; font-weight: 600; }

/* Billing page hero */
.billing-hero { text-align: center; max-width: 640px; margin: 0 auto 26px; }
.billing-hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.02em; }
.billing-hero p { color: var(--text-2); margin: 0; }

/* AI widget FABs */
.fab-stack { position: fixed; right: 22px; bottom: 22px; z-index: 80; display: flex; flex-direction: column; gap: 12px; align-items: flex-end; }
.fab { border: none; cursor: pointer; font-family: inherit; font-weight: 800; font-size: 14px; color: #fff; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 8px; position: relative; }
.fab:active { transform: translateY(1px); }
.fab.walter { background: linear-gradient(135deg, #2b6349, #3a7d5f); }
.fab.chat { background: linear-gradient(135deg, #327a5c, #4f9e7a); }
.fab .reddot { position: absolute; top: -4px; right: -4px; width: 15px; height: 15px; border-radius: 999px; background: #ef4444; border: 2.5px solid var(--surface); animation: pulse 1.3s ease-in-out infinite; }

/* Walter speech bubble */
.walter-bubble { max-width: 320px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.walter-bubble .wb-head { font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.walter-bubble .wb-live { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: #ef4444; padding: 1px 7px; border-radius: 999px; }
.walter-bubble p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }

/* ---- Alex avatar (young professional, broad smile) ---- */
.alex-face { display: block; border-radius: 50%; flex: 0 0 auto; }
.fab .alex-face { width: 24px; height: 24px; }
.walter-bubble .wb-head .alex-face { width: 22px; height: 22px; }
.chat-title { display: inline-flex; align-items: center; gap: 9px; }
.chat-title .alex-face { width: 28px; height: 28px; }
.walter-bubble .wb-head { display: flex; align-items: center; gap: 8px; }

/* Bot messages carry Alex's face beside the bubble; user messages stay plain. */
.chat-msg.bot { background: transparent; border: none; padding: 0; display: flex; align-items: flex-start; gap: 8px; max-width: 92%; }
.chat-msg.bot .msg-av .alex-face { width: 28px; height: 28px; margin-top: 2px; }
.chat-msg.bot .msg-txt { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; border-bottom-left-radius: 5px; padding: 10px 13px; }
/* thinking dots */
.chat-msg.bot.typing { display: inline-block; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; border-bottom-left-radius: 5px; padding: 10px 14px; color: var(--muted); font-size: 18px; letter-spacing: 3px; line-height: 1; animation: typingPulse 1.1s ease-in-out infinite; }
@keyframes typingPulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* Chat panel */
.chat-panel { width: 350px; max-width: 88vw; height: 470px; max-height: 72vh; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { background: linear-gradient(135deg, #327a5c, #4f9e7a); color: #fff; padding: 13px 16px; font-weight: 800; font-size: 14.5px; display: flex; align-items: center; justify-content: space-between; }
.walter-bubble .wb-mem { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.chat-x { border: none; background: rgba(255,255,255,.2); color: #fff; width: 26px; height: 26px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.chat-msg { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-line; }
.chat-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.chat-msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 5px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input input { flex: 1; }

/* Billing legal / subscription disclosure */
.billing-legal { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.billing-legal p { font-size: 11.5px; line-height: 1.55; color: var(--muted); max-width: 760px; margin: 10px auto 0; }
.billing-legal a { color: var(--brand); font-weight: 600; text-decoration: none; }
.billing-legal a:hover { text-decoration: underline; }

/* Legal prose pages */
.prose { max-width: 760px; }
.prose h2 { font-size: 17px; margin: 26px 0 8px; }
.prose p, .prose li { color: var(--text-2); font-size: 14px; line-height: 1.65; }
.prose ul { padding-left: 20px; }
.prose .updated { color: var(--muted); font-size: 12.5px; }

/* ==========================================================================
   Mobile refinements (phone / App Store 6.7") — prevent horizontal overflow
   ========================================================================== */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  .main { max-width: 100%; width: 100%; }
  .page-head { align-items: stretch; }
  .page-head select, .page-head .btn { width: 100%; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat .value { font-size: 21px; }
  .stat .label { font-size: 11px; }
  .card { padding: 16px; }
  .chart-box { height: 300px; }
  .fab { font-size: 13px; padding: 11px 15px; }
  .fab-stack { right: 14px; bottom: 14px; }
  .chat-panel { height: 60vh; }
}
@media (max-width: 420px) {
  .grid.stats { grid-template-columns: 1fr; }
}

/* ---------- Interactive dashboard bits ---------- */
.scope-seg { flex-wrap: wrap; }
.scope-seg button { transition: background .15s, color .15s, transform .05s; }
.scope-seg button.on { background: var(--brand); color: var(--brand-ink); }
.scope-seg button:not(.on):hover { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--text); }
.scope-seg button:active { transform: translateY(1px); }
.card.stat { transition: transform .16s ease, box-shadow .16s ease; }
.card.stat:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(17,24,39,.12); }
@media (prefers-color-scheme: dark) { .card.stat:hover { box-shadow: 0 12px 30px rgba(0,0,0,.5); } }

/* ---------- Chart Goals pie ---------- */
.goalpie-wrap { position: relative; height: 260px; }
.goalpie-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.goalpie-center .pct { font-size: 40px; font-weight: 800; letter-spacing: -.02em; color: var(--brand); }
.goalpie-center .lbl { font-size: 12.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* Suppress splash entirely once it has played this session (no flash on tab nav) */
html.no-splash .splash { display: none !important; }
