/* Budget — product styles. Built on the shared SuperCala tokens
   (supercala-app-tokens.css) + topbar (supercala-topbar.css), both
   loaded first. We never set a body background — the classic SuperCala
   --bg-fade (html,body in app-tokens) shows through. Colours come from
   the shared tokens so dark/light themes work for free. */

* { box-sizing: border-box; }

/* The `hidden` attribute must always win. Author `display` rules (e.g.
   .signed-out { display: grid }) otherwise override the UA's
   [hidden]{display:none}, which left the signed-out gate visible even after
   showApp() set gate.hidden = true. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Brand (left of the shared topbar) — matches the other products. */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { border-radius: 7px; display: block; }
.brand-stack { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-studio { font-size: 0.7rem; color: var(--fg-dim); }

/* Buttons (the shared topbar styles .btn.icon-only; these are the
   in-page buttons). */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.5rem 0.9rem; background: var(--bg-elev-2); color: var(--fg);
  transition: filter 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--fg-dim); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elev-2); border-color: var(--border); }
.btn-lg { padding: 0.7rem 1.3rem; font-size: 1.05rem; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.85rem; border-radius: 8px; }
.icon-sq { width: 2.25rem; padding: 0.4rem 0; text-align: center; }

.settings-value { color: var(--fg-dim); font-weight: 600; }
.settings-select {
  font: inherit; background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.2rem 0.4rem;
}

/* Signed-out empty state — a focused hero CTA. */
.signed-out { display: grid; place-items: center; min-height: 60vh; padding: 1.5rem; }
.gate-hero {
  text-align: center;
  max-width: 30rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.85rem;
  animation: gate-rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes gate-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.gate-badge {
  width: 64px; height: 64px; border-radius: 18px;
  display: grid; place-items: center; color: var(--accent-fg);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 30px -10px var(--accent), 0 4px 12px rgba(0, 0, 0, 0.25);
}
.gate-badge svg { width: 32px; height: 32px; }
.gate-title { margin: 0.3rem 0 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.gate-sub { margin: 0; color: var(--fg-dim); font-size: 1rem; line-height: 1.5; max-width: 26rem; }
.gate-cta {
  margin-top: 0.6rem;
  display: inline-flex; align-items: center; gap: 0.55rem;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  color: var(--accent-fg); cursor: pointer;
  border: 0; border-radius: 12px; padding: 0.85rem 1.6rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 12px 28px -10px var(--accent), 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}
.gate-cta:hover {
  transform: translateY(-2px); filter: brightness(1.04);
  box-shadow: 0 18px 36px -12px var(--accent), 0 4px 10px rgba(0, 0, 0, 0.25);
}
.gate-cta:active { transform: translateY(0); }
.gate-cta:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.gate-cta-arrow { width: 18px; height: 18px; transition: transform 0.14s ease; }
.gate-cta:hover .gate-cta-arrow { transform: translateX(3px); }
.gate-alt { margin: 0.4rem 0 0; color: var(--fg-dim); font-size: 0.9rem; }
.gate-alt a { color: var(--accent); text-decoration: none; font-weight: 600; }
.gate-alt a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .gate-hero { animation: none; }
  .gate-cta:hover, .gate-cta:active { transform: none; }
  .gate-cta:hover .gate-cta-arrow { transform: none; }
}

/* Boot loading state — shown while the signed-in data loads, instead of a
   partially-painted dashboard. */
.app-loading { display: grid; place-items: center; min-height: 60vh; padding: 1.5rem; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.loader-ring {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid var(--bg-elev-3); border-top-color: var(--accent);
  animation: loader-spin 0.8s linear infinite;
}
.loader-text { margin: 0; color: var(--fg-dim); font-size: 0.95rem; }
@keyframes loader-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  /* Still a progress indicator — just becalmed. */
  .loader-ring { animation-duration: 2s; }
}

/* App layout */
.app { max-width: 56rem; margin: 1.5rem auto; padding: 0 1.25rem 4rem; }
.monthbar { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1.25rem; }
.monthbar h2 { margin: 0; font-size: 1.25rem; min-width: 10rem; text-align: center; }
.spacer { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1.5rem; }
.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.card-label { font-size: 0.75rem; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 1.35rem; font-weight: 700; }
.card-value.neg { color: var(--red); }

/* Panels */
.panel {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.75rem; }
.panel-head h3 { margin: 0; font-size: 1.05rem; }
.panel-head-left { display: flex; align-items: center; gap: 0.65rem; }
/* Square "+" add buttons (Category / Bill / Goal). Same height as a regular
   .btn (and the AI "Organize" button beside Category): identical 0.5rem
   vertical padding + inherited font metrics → identical height; aspect-ratio:1
   makes them square. (Don't override font-size/line-height — that would change
   the line box and break the height match.) */
.btn-add {
  padding: 0.5rem;
  aspect-ratio: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Collapsible panels (data-collapse) — Bills & This month start collapsed;
   the chevron + title toggle, everything but the head hides. */
.panel.collapsed > :not(.panel-head) { display: none; }
.panel.collapsed .panel-head { margin-bottom: 0; }
.panel-title-toggle { cursor: pointer; user-select: none; }
.panel-title-toggle:hover { color: var(--accent); }
.panel-chevron {
  flex: none; width: 1.2rem; height: 1.35rem; padding: 0;
  display: inline-grid; place-items: center;
  font: inherit; font-size: 0.85rem; line-height: 1; cursor: pointer;
  color: var(--fg-dim); background: transparent; border: 0; border-radius: 6px;
  transition: transform 0.15s ease, color 0.12s ease;
}
.panel-chevron.open { transform: rotate(90deg); }
.panel-chevron:hover { color: var(--accent); }
.panel-chevron:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--fg-dim); font-size: 0.9rem; }

/* Panel header actions + the AI "Organize" button */
.panel-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn-ai {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-fg); border: 1px solid transparent;
}
.btn-ai:hover { filter: brightness(1.05); border-color: transparent; }
.btn-ai:disabled { opacity: 0.7; cursor: default; filter: none; }

/* AI categorize preview (rendered inside the shared modal). The shared modal
   is capped at 26rem, so everything here must FIT that width — never force it
   wider (a min-width > the modal's max-width overflows the panel). Long raw
   bank descriptors are unbreakable tokens, so wrap them hard. */
.ai-preview { display: flex; flex-direction: column; gap: 0.85rem; min-width: 0; }
.ai-intro { margin: 0; }
.ai-cat-list {
  display: flex; flex-direction: column;
  max-height: 46vh; overflow-y: auto; overflow-x: hidden;
  border: 1px solid var(--border); border-radius: 10px;
}
.ai-cat { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); min-width: 0; }
.ai-cat:last-child { border-bottom: 0; }
.ai-cat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
/* Name can shrink + wrap; budget is fixed-width and never clipped. */
.ai-cat-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ai-cat-budget { flex: none; font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; white-space: nowrap; }
/* Sample-merchant line is the long raw-descriptor offender — clamp to 2 lines. */
.ai-cat-meta {
  font-size: 0.8rem; margin-top: 0.15rem; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ai-opts { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.25rem; }
.ai-opt { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; cursor: pointer; }

/* Categories */
.categories { display: flex; flex-direction: column; gap: 0.85rem; }
.cat-row { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; align-items: center; }
/* min-width:0 + overflow-wrap:anywhere let a long single-word category name
   break (and hyphenate) onto the next line instead of overflowing into the
   right-aligned spent/budget figures. overflow-wrap:anywhere (not break-word)
   also shrinks the min-content so the grid's 1fr name column can narrow. */
.cat-name { font-weight: 600; display: flex; align-items: center; gap: 0.5rem; min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.cat-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; background: var(--fg-dim); }
.cat-figures { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-figures .spent { font-weight: 600; }
.cat-figures .of { color: var(--fg-dim); }
.cat-bar { grid-column: 1 / -1; height: 7px; background: var(--bg-elev-3); border-radius: 999px; overflow: hidden; }
.cat-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.cat-bar.over > span { background: var(--red); }
.budget-input {
  width: 6.5rem; text-align: right; font: inherit; padding: 0.3rem 0.5rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev-2); color: var(--fg);
}
.cat-row.income .cat-figures .spent { color: var(--green); }
/* Name cell — the drill-down button plus the "+" add-subcategory affordance
   on top-level rows. Hidden until the row is hovered (or reached by
   keyboard) so the list stays calm; on touch devices — no hover to reveal
   it — it stays faintly visible instead. */
.cat-name-wrap { display: flex; align-items: center; gap: 0.45rem; min-width: 0; }
/* Expand/collapse chevron on parents that have subcategories — rotates open
   like MyNetWorth's section chevrons. */
.cat-chevron {
  flex: none; width: 1.1rem; height: 1.35rem; padding: 0;
  display: inline-grid; place-items: center;
  font: inherit; font-size: 0.8rem; line-height: 1; cursor: pointer;
  color: var(--fg-dim); background: transparent; border: 0; border-radius: 6px;
  transition: transform 0.15s ease, color 0.12s ease;
}
.cat-chevron.open { transform: rotate(90deg); }
.cat-chevron:hover { color: var(--accent); }
.cat-chevron:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-addsub {
  flex: none; width: 1.35rem; height: 1.35rem; padding: 0; line-height: 1;
  display: inline-grid; place-items: center;
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  color: var(--fg-dim); background: transparent;
  border: 1px solid var(--border); border-radius: 6px;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.cat-row:hover .cat-addsub,
.cat-row:focus-within .cat-addsub,
.cat-addsub:focus-visible { opacity: 1; }
.cat-addsub:hover { color: var(--accent); border-color: var(--accent); }
/* Touch screens have no hover to reveal it — keep it faintly visible. */
@media (hover: none) {
  .cat-addsub { opacity: 0.55; }
}
/* Subcategory rows — indented under their parent, slightly de-emphasised so
   the parent's rolled-up figures stay the headline. The connecting border
   makes the nesting read at a glance. */
.cat-row.sub {
  margin: -0.35rem 0 0 0.95rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--bg-elev-3);
}
/* Inline transactions of an expanded category — same indent language as
   subcategory rows; `deep` nests one level further (a subcategory's list). */
.cat-txns {
  margin: -0.35rem 0 0.25rem 0.95rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--bg-elev-3);
}
.cat-txns.deep { margin-left: 2.6rem; }
.cat-txns .empty { padding: 0.25rem 0; }
.cat-txns .txn { padding: 0.3rem 0; }
.cat-txns-label {
  font-size: 0.7rem; font-weight: 600; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 0.3rem 0 0.1rem;
}
.cat-row.sub .cat-name { font-weight: 500; font-size: 0.92em; }
.cat-row.sub .cat-dot { width: 0.55rem; height: 0.55rem; }
.cat-row.sub .cat-figures { font-size: 0.92em; }
.cat-row.sub .cat-bar { height: 5px; }
/* Transfers / payments — excluded from spending; rendered muted. */
.cat-row.transfer .cat-name { color: var(--fg-dim); }
.cat-row.transfer .cat-figures .moved { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.cat-tag {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--fg-dim); background: var(--bg-elev-3);
  padding: 0.05rem 0.4rem; border-radius: 999px; margin-left: 0.4rem;
}
/* Category name is a button (click to drill into its transactions). Reset the
   native chrome and add a subtle clickable affordance. */
.cat-name.cat-open {
  font: inherit; font-weight: 600; color: inherit; text-align: left;
  background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  border-radius: 6px;
}
.cat-name.cat-open:hover { color: var(--accent); }
.cat-name.cat-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted.small { font-size: 0.82rem; margin: 0.1rem 0 0.6rem; }

/* Transaction form */
.txn-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem 0.75rem; align-items: center; }
.txn-form input, .txn-form select {
  font: inherit; min-width: 0; width: 100%; padding: 0.5rem 0.6rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg-elev-2); color: var(--fg);
}
.txn-form .btn { width: 100%; }

/* Transactions list */
.txns { display: flex; flex-direction: column; }
.txn {
  display: grid; grid-template-columns: 5.5rem 1fr auto auto; gap: 0.75rem; align-items: center;
  padding: 0.55rem 0; border-top: 1px solid var(--border);
}
.txn:first-child { border-top: none; }
.txn .date { color: var(--fg-dim); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
/* Description is a button (click to recategorize + teach the AI). */
.txn .desc {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  font: inherit; text-align: left; color: inherit;
  background: none; border: 0; padding: 0.1rem 0.25rem; margin: -0.1rem -0.25rem;
  cursor: pointer; border-radius: 6px; min-width: 0;
}
.txn .desc.desc-edit:hover { background: var(--bg-elev-2); }
.txn .desc.desc-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.txn .desc .merchant { font-weight: 600; overflow-wrap: anywhere; }
.txn .desc .cat { font-size: 0.8rem; color: var(--fg-dim); overflow-wrap: anywhere; }
.txn .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.txn .amt.income { color: var(--green); }
.txn .del { color: var(--fg-dim); background: none; border: none; cursor: pointer; font-size: 1rem; }
.txn .del:hover { color: var(--red); }
.txn.synced { opacity: 0.95; }
.del-spacer { display: inline-block; width: 1rem; }
.empty { color: var(--fg-dim); padding: 1rem 0; text-align: center; }

/* Sync button states */
.btn.synced { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); cursor: default; }

/* Modal styling lives in the shared /shared/css/supercala-modal.css. */

/* Toast */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--bg-elev-3); color: var(--fg); border: 1px solid var(--border);
  padding: 0.6rem 1rem; border-radius: 10px; z-index: 1200; font-size: 0.9rem;
}

@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .txn-form { grid-template-columns: 1fr 1fr; }
  .txn-form .btn { grid-column: 1 / -1; }
  .brand-studio { display: none; }
  /* Month controls stay on row 1; the action buttons (Household / Alerts /
     Sync) wrap to a full second row instead of running off the right edge.
     The spacer becomes a full-width line break; the buttons share the row. */
  .monthbar { flex-wrap: wrap; }
  .monthbar h2 { min-width: 0; flex: 1; }
  .monthbar .spacer { flex-basis: 100%; height: 0; }
  /* Equal width AND height across the wrapped row: the parent is
     align-items:center, so without align-self:stretch a 1-line button (Alerts)
     ends up shorter than a button whose text wraps to two lines (Sync with
     MyNetWorth / Household). Stretch them all to the tallest and center the
     label since .btn is padding-only. */
  .monthbar .btn-secondary {
    flex: 1;
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
}

/* ---- Phase 1: safe-to-spend hero ---- */
.hero-safe {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
}
.hero-label { font-size: 0.78rem; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.hero-value { font-size: 2.1rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-value.neg { color: var(--red); }
.hero-sub { font-size: 0.9rem; color: var(--fg-dim); }
.good { color: var(--green); }
.bad { color: var(--red); }

/* per-category vs-last-month chip */
.cat-delta { font-size: 0.78rem; font-variant-numeric: tabular-nums; margin-left: 0.4rem; }

/* ---- Phase 1: goals ---- */
.goals { display: flex; flex-direction: column; gap: 0.9rem; }
.goal-row { display: flex; flex-direction: column; gap: 0.4rem; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.goal-name {
  background: transparent; border: none; padding: 0; color: var(--fg); font: inherit;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 0.45rem;
}
.goal-name:hover { color: var(--accent); }
.goal-figs { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.goal-figs .of { color: var(--fg-dim); font-weight: 400; }
.goal-bar { height: 9px; background: var(--bg-elev-3); border-radius: 999px; overflow: hidden; }
.goal-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }
.goal-bar.done > span { background: var(--green); }
.goal-foot { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.goal-foot .small { margin: 0; }

/* ---- Bills & subscriptions (Phase 2) ---- */
.bills { display: flex; flex-direction: column; }
.bill-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0; border-bottom: 1px solid var(--bg-elev-3);
}
.bill-row:last-child { border-bottom: none; }
.bill-row.inactive { opacity: 0.55; }
.bill-main { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; min-width: 0; }
.bill-name {
  background: transparent; border: none; padding: 0; color: var(--fg); font: inherit;
  font-weight: 600; cursor: pointer; text-align: left;
}
.bill-name:hover { color: var(--accent); }
.bill-figs { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.bill-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.bill-chip {
  font-size: 0.72rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--bg-elev-3); color: var(--fg-dim); white-space: nowrap;
}
.bill-chip.soon { background: color-mix(in srgb, var(--amber, #d97706) 16%, transparent); color: var(--amber, #d97706); }
.bill-chip.overdue { background: color-mix(in srgb, var(--red, #dc2626) 14%, transparent); color: var(--red, #dc2626); }
.bill-chip.price-up { background: color-mix(in srgb, var(--red, #dc2626) 12%, transparent); color: var(--red, #dc2626); }
.bill-chip.nudge { background: color-mix(in srgb, var(--amber, #d97706) 14%, transparent); color: var(--amber, #d97706); }
.bill-chip.lapsed { background: var(--bg-elev-3); color: var(--fg-dim); font-style: italic; }

/* ---- Rollover / envelope budgeting (Phase 3) ---- */
.cat-carry {
  font-size: 0.74rem; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--bg-elev-3); white-space: nowrap;
}
/* Lives in the name cell right after the add-subcategory "+", sized to
   match it, and likewise hidden until the row is hovered/focused. */
.cat-rollover {
  flex: none; width: 1.35rem; height: 1.35rem; padding: 0; line-height: 1;
  display: inline-grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg-dim); cursor: pointer; font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.15s, border-color 0.15s;
}
.cat-row:hover .cat-rollover,
.cat-row:focus-within .cat-rollover,
.cat-rollover:focus-visible { opacity: 1; }
.cat-rollover:hover { color: var(--accent); border-color: var(--accent); }
/* Active envelopes reveal in the on-state look (accent + tinted fill) but
   follow the same hide rules — the carry chip in the figures is the always-
   visible signal that a rollover is running. */
.cat-rollover.on {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
/* Touch screens have no hover to reveal it. */
@media (hover: none) {
  .cat-rollover { opacity: 0.55; }
  .cat-rollover.on { opacity: 1; }
}

/* ---- View charts link + /charts page ---- */
.charts-link {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; padding: 0.65rem 1rem; margin: 0 0 1rem;
  background: var(--bg-elev-1); border: 1px solid var(--bg-elev-3); border-radius: 12px;
  color: var(--fg); font-weight: 600; text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.charts-link svg { width: 18px; height: 18px; }
.charts-link:hover { border-color: var(--accent); color: var(--accent); }

.charts-page { max-width: 860px; }
.charts-controls {
  display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between;
  margin-bottom: 1rem;
}
.seg { display: inline-flex; background: var(--bg-elev-1); border: 1px solid var(--bg-elev-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  background: transparent; border: none; border-radius: 8px; color: var(--fg-dim);
  cursor: pointer; font: inherit; font-size: 0.88rem; font-weight: 600; padding: 0.35rem 0.85rem;
}
.seg-btn:hover { color: var(--fg); }
.seg-btn.active { background: var(--accent); color: #fff; }

.chart-area { padding: 0.5rem 0; }

/* Vertical column chart — amount on top, bar grows up, label + share below.
   Scrolls horizontally when there are more categories than fit. */
.bar-chart {
  display: flex; align-items: stretch; gap: 0.6rem;
  overflow-x: auto; padding: 0.25rem 0.25rem 0.5rem;
}
.bar-col {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  flex: 1 1 0; min-width: 64px; max-width: 120px;
}
.bar-value { font-size: 0.78rem; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar-track {
  display: flex; flex-direction: column; justify-content: flex-end;
  height: 220px; width: 100%; max-width: 56px;
  background: var(--bg-elev-2); border-radius: 8px; overflow: hidden;
}
.bar-fill { display: block; width: 100%; border-radius: 8px 8px 0 0; transition: height 0.3s ease; }
.bar-label {
  font-size: 0.78rem; font-weight: 600; text-align: center; line-height: 1.25;
  max-width: 100%; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.bar-pct { font-size: 0.72rem; }

.pie-chart { display: flex; flex-wrap: wrap; align-items: center; gap: 1.75rem; justify-content: center; padding: 0.5rem 0; }
.pie { width: 220px; height: 220px; border-radius: 50%; flex-shrink: 0; }
.pie-legend { display: flex; flex-direction: column; gap: 0.45rem; min-width: 230px; max-width: 100%; }
.legend-row { display: flex; align-items: center; gap: 0.5rem; }
.legend-name { font-size: 0.9rem; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-figs { font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 560px) {
  .bar-col { min-width: 56px; }
  .bar-track { height: 170px; max-width: 44px; }
  .pie { width: 180px; height: 180px; }
}

/* ---- Email alerts modal (Phase 4) ---- */
.alert-prefs { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.5rem 0 1rem; }
.alert-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; cursor: pointer; }
.alert-row input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
.alert-row.locked { opacity: 0.55; cursor: default; }
.alert-days { width: 3.2em; padding: 0.1rem 0.3rem; border: 1px solid var(--bg-elev-3); border-radius: 6px; background: var(--bg-elev-1); color: var(--fg); font: inherit; }
.alert-pro-chip {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem; border-radius: 999px; margin-left: auto;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
}
.alert-sep { border: none; border-top: 1px solid var(--bg-elev-3); margin: 0.2rem 0; }

/* ---- Transaction splits (Phase 5) ---- */
.txn-split {
  background: transparent; border: none; color: var(--fg-dim); cursor: pointer;
  font-size: 0.95rem; padding: 0.15rem 0.35rem; border-radius: 6px;
}
.txn-split:hover { color: var(--accent); background: var(--bg-elev-2); }
.split-chip {
  font-size: 0.68rem; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 0.05rem 0.4rem; border-radius: 999px; vertical-align: 1px;
}
.split-parts { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.6rem 0 0.4rem; }
.split-part { display: grid; grid-template-columns: 1fr 6.5em auto; gap: 0.4rem; align-items: center; }
.split-part select, .split-part input {
  font: inherit; background: var(--bg-elev-1); color: var(--fg);
  border: 1px solid var(--bg-elev-3); border-radius: 8px; padding: 0.3rem 0.45rem; min-width: 0;
}
.split-remainder { margin: 0.4rem 0 0; }
.split-remainder.bad { color: var(--red); }

/* ---- Budget period selector (Phase 5) ---- */
.period-select {
  font: inherit; font-size: 0.85rem; font-weight: 600;
  background: var(--bg-elev-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.3rem 0.5rem;
  cursor: pointer;
}
.period-select:hover { border-color: var(--accent); }

/* ---- Saving spinner ---- */
/* Applied to any button mid-save: dims it and spins a ring on the right.
   position:relative + padding keeps the label visible next to the ring. */
.btn-loading {
  position: relative;
  opacity: 0.75;
  pointer-events: none;
  padding-right: 2.1em !important;
}
.btn-loading::after {
  content: "";
  position: absolute;
  right: 0.65em; top: 50%;
  width: 0.9em; height: 0.9em;
  margin-top: -0.45em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.65s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-loading::after { animation-duration: 1.6s; }
}

/* ---- Category drill-down page ---- */
.cat-head { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cat-head h2 { margin: 0; font-size: 1.4rem; }
.bar-col.clickable, .legend-row.clickable, .pie.clickable { cursor: pointer; }
.bar-col.clickable:hover .bar-label { color: var(--accent); }
.legend-row.clickable:hover .legend-name { color: var(--accent); }
.chart-hint { text-align: center; margin: 0.6rem 0 0; }

/* ---- Budget Coach voice widget (Phase 6) ---- */
/* The widget injects .vc-pill into <body>. Hidden until the app says the
   user is signed in; locked (greyed) until they're on Money Pro — clicks in
   that state are routed to the upgrade modal by a capture-phase gate. */
.vc-pill { display: none !important; }
.vc-toast { display: none !important; }
body.bdg-voice-visible .vc-pill { display: flex !important; }
body.bdg-voice-visible .vc-toast { display: block !important; }
body.bdg-voice-locked #supercala-voice-btn { filter: grayscale(0.6) brightness(0.9); }

/* ---- Household modal (Phase 7) ---- */
.household-members { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.6rem 0; }
.household-member { display: flex; align-items: center; gap: 0.6rem; }
.hm-email { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* ---- Phase 8: savings / net-worth strip + reconciliation ---- */
.insight-strip {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.8rem 1.1rem; margin-bottom: 1.25rem;
}
.insight { display: flex; flex-direction: column; gap: 0.1rem; }
.insight-label { font-size: 0.72rem; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.insight-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.insight-value.neg { color: var(--red); }
.insight-sub { font-size: 0.78rem; color: var(--fg-dim); }
.insight-sub.good { color: var(--green); }
.insight-sub.bad { color: var(--red); }
.insight-spark { width: 120px; height: 36px; margin-left: auto; }

.reconcile-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: color-mix(in srgb, var(--amber, #d97706) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #d97706) 35%, transparent);
  border-radius: 10px; padding: 0.55rem 0.8rem; margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.reconcile-list { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.6rem 0; max-height: 50vh; overflow-y: auto; }
.reconcile-pair { display: flex; flex-direction: column; gap: 0.4rem; border-bottom: 1px solid var(--border); padding-bottom: 0.6rem; }
.reconcile-pair:last-child { border-bottom: none; }
.rp-info { display: flex; flex-direction: column; gap: 0.15rem; }
.rp-actions { display: flex; gap: 0.4rem; }

/* Month label doubles as "jump to today"; empty-state jump button. */
.monthbar h2 { cursor: pointer; }
.monthbar h2:hover { color: var(--accent); }
.jump-today { margin-top: 0.6rem; }

/* ---- Pro plan chooser ---- */
.upgrade-chooser { display: flex; flex-direction: column; gap: 0.5rem; }
.upgrade-option {
  display: flex !important; justify-content: space-between; align-items: baseline;
  gap: 0.75rem; width: 100%; text-align: left;
}
.upgrade-option .uo-title { font-weight: 700; }
.upgrade-option .uo-price { font-size: 0.82rem; opacity: 0.85; white-space: nowrap; }
