/* ============================================================
   BFF — styles.css
   Faithful vanilla reproduction of the Lovable prototype.
   Colors and type mirror the prototype's design tokens.
   Edit the --variables below to recolor the whole app.
   ============================================================ */

/* Hide the app until auth decides what to show, so signed-out
   visitors don't see the home screen flash before the login
   redirect (and signed-in users don't see placeholder data). JS
   adds .ready to <html>; a safety timeout guarantees reveal. */
html:not(.ready) body { visibility: hidden; }

:root {
  --radius: 0.875rem;
  --background: oklch(0.985 0.008 95);
  --foreground: oklch(0.18 0.02 200);
  --surface: oklch(0.97 0.012 90);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.18 0.02 200);
  --primary: oklch(0.55 0.09 195);
  --primary-foreground: oklch(0.99 0 0);
  --primary-soft: oklch(0.93 0.03 195);
  --secondary: oklch(0.95 0.02 90);
  --muted: oklch(0.94 0.015 90);
  --muted-foreground: oklch(0.5 0.02 220);
  --accent: oklch(0.93 0.03 195);
  --destructive: oklch(0.6 0.2 25);
  --destructive-foreground: oklch(0.99 0 0);
  --success: oklch(0.65 0.15 155);
  --warning: oklch(0.85 0.14 90);
  --warning-foreground: oklch(0.35 0.08 80);
  --border: oklch(0.9 0.015 200);
  --input: oklch(0.92 0.012 200);
  --ring: oklch(0.55 0.09 195);

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --sidebar-w: 288px;
  --motion-scale: 1;
}

/* Dark mode — toggled from Profile (adds .dark to <html>) */
html.dark {
  --background: oklch(0.15 0.02 200);
  --foreground: oklch(0.98 0 0);
  --surface: oklch(0.2 0.025 200);
  --card: oklch(0.22 0.025 200);
  --card-foreground: oklch(0.98 0 0);
  --primary: oklch(0.65 0.11 195);
  --primary-foreground: oklch(0.12 0.02 200);
  --primary-soft: oklch(0.3 0.05 195);
  --muted: oklch(0.25 0.02 200);
  --muted-foreground: oklch(0.7 0.02 200);
  --border: oklch(0.3 0.02 200);
}

/* Large text — toggled from Profile (adds .large-text to <html>).
   The app sizes text in px, so we scale the whole UI up proportionally. */
html.large-text { zoom: 1.15; }

/* High-contrast — toggled from Profile (adds .hc to <html>) */
html.hc { --border: oklch(0.35 0.02 200); --muted-foreground: oklch(0.28 0.02 220); }
html.hc.dark { --border: oklch(0.75 0.02 200); --muted-foreground: oklch(0.85 0.02 200); }

/* ---------- Base ---------- */
* { box-sizing: border-box; border-color: var(--border); }
html, body {
  margin: 0; padding: 0;
  /* Stop iOS Safari from auto-inflating text (keeps sizes/alignment consistent
     between narrow-desktop and the real iPhone). */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  /* Remove the grey flash iOS paints over tapped buttons/links. */
  -webkit-tap-highlight-color: transparent;
}
/* Interactive elements: no 300ms tap delay, no double-tap zoom. */
button, a, .tile, .nav-link, .icon-btn, .chip, .pill-btn, .seg button,
input[type="button"], input[type="submit"], label, summary {
  touch-action: manipulation;
}
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---------- Layout shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; }

/* Desktop sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  width: var(--sidebar-w);
  display: none; flex-direction: column;
  border-right: 2px solid var(--border);
  background: color-mix(in oklab, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
}
.sidebar .brand { display: flex; align-items: center; gap: 8px; padding: 20px 24px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; flex: 1; }
.sidebar-foot { border-top: 2px solid var(--border); padding: 16px; }

.brand-logo {
  display: grid; place-items: center; height: 36px; width: 36px;
  border-radius: 12px; background: var(--primary); color: var(--primary-foreground);
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  overflow: hidden;
}
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.brand-logo svg { height: 20px; width: 20px; }
.brand-img { height: 26px; width: auto; display: block; }
button.nav-profile, button.nav-link { width: 100%; border: 0; background: transparent; cursor: pointer; font: inherit; text-align: left; }

.nav-link {
  display: flex; align-items: center; gap: 12px;
  border-radius: 12px; padding: 12px 16px;
  font-size: 16px; font-weight: 500; color: var(--foreground);
  transition: background .15s, color .15s;
}
.nav-link svg { height: 20px; width: 20px; }
.nav-link:hover { background: var(--muted); }
.nav-link.active { background: var(--primary); color: var(--primary-foreground); }

.nav-profile {
  display: flex; align-items: center; gap: 8px;
  border-radius: 12px; padding: 8px; color: var(--foreground);
  transition: background .15s;
}
.nav-profile:hover { background: var(--muted); }
.nav-profile.active { background: var(--primary); color: var(--primary-foreground); }
.nav-profile .np-icon {
  display: grid; place-items: center; height: 36px; width: 36px;
  border-radius: 12px; background: var(--muted); color: var(--foreground);
}
.nav-profile.active .np-icon { background: color-mix(in oklab, var(--primary-foreground) 20%, transparent); color: var(--primary-foreground); }
.nav-profile span.np-name { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
a.nav-profile, a.nav-link { text-decoration: none; }
.nav-profile .np-avatar { border-radius: 999px; overflow: hidden; }
.nav-profile .np-avatar svg { height: 20px; width: 20px; }
.np-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.np-text .np-name { font-size: 14px; line-height: 1.2; }
.np-sub { font-size: 12px; color: var(--muted-foreground); }
.nav-profile.active .np-sub { color: color-mix(in oklab, var(--primary-foreground) 80%, transparent); }

/* Home greeting profile chip */
.home-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.home-head > div { display: flex; flex-direction: column; gap: 2px; }
.home-head .page-eyebrow { margin: 0; line-height: 1.2; }
.home-head .page-title { margin: 0; line-height: 1.05; }
.home-avatar { height: 68px; width: 68px; text-decoration: none; }
.home-avatar svg { height: 32px; width: 32px; }

/* Mobile header */
.mobile-header {
  position: sticky; top: 0; z-index: 30;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  background: color-mix(in oklab, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
}
.mh-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.mh-left, .mh-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; height: 36px; width: 36px;
  border-radius: 999px; border: 0; background: transparent; color: var(--foreground);
  transition: background .15s;
}
.icon-btn:hover { background: var(--muted); }
.icon-btn svg { height: 18px; width: 18px; }
.icon-btn.muted { color: var(--muted-foreground); }
.icon-btn.avatar { background: var(--muted); }
.icon-btn.avatar.active { background: var(--primary); color: var(--primary-foreground); }
.mobile-header .brand { display: flex; align-items: center; gap: 8px; }

/* Mobile slide-out sheet */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.4); opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.sheet-overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  width: 288px; max-width: 85vw;
  background: var(--background); border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.sheet.open { transform: translateX(0); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  padding: 16px 20px;
}
.sheet-nav { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.sheet-nav .nav-link { padding: 12px; font-size: 14px; }
.sheet-nav .nav-link svg { height: 16px; width: 16px; }

/* Main content */
.main { padding: 24px 16px 40px; }
.container { margin: 0 auto; max-width: 80rem; }

@media (min-width: 768px) {
  .mobile-header { display: none; }
  .sidebar { display: flex; }
  .sheet, .sheet-overlay { display: none; }
  .main { margin-left: var(--sidebar-w); padding: 32px; }
}
@media (min-width: 640px) {
  .main { padding-left: 24px; padding-right: 24px; }
}

/* ---------- Page heading ---------- */
.page-eyebrow { font-size: 14px; color: var(--muted-foreground); }
.page-title { font-size: 30px; font-weight: 700; margin-top: 4px; }
@media (min-width: 640px) { .page-title { font-size: 36px; } }
.head-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.head-between { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 24px; }

/* ---------- Cards ---------- */
.card {
  border-radius: 24px; background: var(--card);
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px color-mix(in oklab, var(--border) 60%, transparent);
}
.card-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.card-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.card-icon { display: grid; place-items: center; height: 36px; width: 36px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.card-icon svg { height: 16px; width: 16px; }

/* Grids */
.grid { display: grid; gap: 20px; }
/* Grid items default to min-width:auto, so a wide child (like the History
   chart) can force the shared mobile column wider than the screen, pushing
   every card in that grid past the right edge. min-width:0 lets them shrink
   to the container. */
.grid > * { min-width: 0; }
.grid-3 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
.mt-5 { margin-top: 20px; }
.space-y > * + * { margin-top: 20px; }
@media (min-width: 1024px) {
  /* auto-fit + a 300px floor: cards drop to 2 (then 1) columns before they get
     narrow enough to cramp the History control or wrap the Quick-add title,
     instead of always forcing 3 columns into whatever width is available. */
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .lg-col-2 { grid-column: span 2; }

  /* Desktop balance hero: only the "CURRENT BALANCE" eyebrow gets a slightly
     larger font on wide screens. The layout stays stacked (eyebrow → toggle row →
     account label → amount → In/Out pair below), same as mobile — no horizontal
     split. .hero-money keeps display:contents so it's transparent to layout. */
  .hero-eyebrow { font-size: 15px; }
}
.sub-2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .sub-2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Hero balance card ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 24px;
  background: var(--primary); color: var(--primary-foreground); padding: 32px;
}
.hero .blob { position: absolute; border-radius: 999px; filter: blur(40px); }
.hero .blob1 { right: -64px; top: -64px; height: 256px; width: 256px; background: rgba(255,255,255,.10); }
.hero .blob2 { bottom: -80px; left: -40px; height: 224px; width: 224px; background: rgba(255,255,255,.05); }
.hero-inner { position: relative; }
.hero-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; opacity: .9; margin: 0 0 18px; }
.hero-label { font-size: 15px; font-weight: 600; opacity: .95; }
.hero-money { display: contents; }
.hero-amount-row { margin-top: 4px; display: flex; align-items: baseline; gap: 8px; }
.hero-amount { font-family: var(--font-display); font-weight: 700; font-size: 60px; line-height: 1; }
.hero-cents { font-size: 14px; opacity: .8; }
.hero-stats { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 28rem; }
.hero-stat { border-radius: 16px; background: rgba(255,255,255,.10); padding: 16px; backdrop-filter: blur(8px); }
.hero-stat .hs-label { display: flex; align-items: center; gap: 8px; font-size: 12px; opacity: .8; }
.hero-stat .hs-label svg { height: 14px; width: 14px; }
.hero-stat .hs-val { margin-top: 4px; font-family: var(--font-display); font-size: 24px; font-weight: 600; }

/* ---------- Warning / heads-up card ---------- */
.warn-card {
  display: flex; flex-direction: column; justify-content: space-between;
  border-radius: 24px; padding: 24px;
  background: color-mix(in oklab, var(--warning) 25%, transparent);
  border: 1px solid color-mix(in oklab, var(--warning) 40%, transparent);
}
.warn-eyebrow { display: flex; align-items: center; gap: 8px; color: var(--warning-foreground); }
.warn-eyebrow svg { height: 16px; width: 16px; }
.warn-eyebrow p { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.warn-title { margin-top: 12px; font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--warning-foreground); }
.warn-sub { margin-top: 4px; font-size: 14px; color: color-mix(in oklab, var(--warning-foreground) 80%, transparent); }
.warn-btn {
  margin-top: 20px; align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; background: var(--warning-foreground); color: var(--warning);
  padding: 8px 16px; font-size: 12px; font-weight: 500;
}
.warn-btn:hover { opacity: .9; }

/* ---------- Progress tiles ---------- */
.tile {
  display: block; border-radius: 16px; background: var(--surface); padding: 16px;
  transition: transform .15s, background .15s, box-shadow .15s;
}
.tile.link:hover { transform: translateY(-2px); background: var(--primary-soft); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-label { font-weight: 500; }
.pct { font-size: 12px; font-weight: 600; color: var(--muted-foreground); }
.pct.warn { color: var(--warning-foreground); }
.bar { margin-top: 12px; height: 8px; overflow: hidden; border-radius: 999px; background: var(--border); }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.bar > i.warn { background: var(--warning); }
.tile-sub { margin-top: 8px; font-size: 12px; color: var(--muted-foreground); }
.tile-name { font-weight: 500; }

.saving-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.saving-amt { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.saving-amt .of { font-size: 14px; font-weight: 400; color: var(--muted-foreground); }
.edit-controls { display: flex; align-items: center; gap: 12px; }

/* ---------- Over-budget states ---------- */
.bar > i.over { background: var(--destructive); }
.tile-over { background: color-mix(in oklab, var(--destructive) 8%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--destructive) 30%, transparent); }
.over-text { color: var(--destructive) !important; }
.over-nudge { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--border); }
.over-nudge-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.over-nudge-body { margin-top: 4px; font-size: 13px; color: var(--muted-foreground); line-height: 1.4; }
.over-nudge-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 999px; }
.warn-card.over { background: color-mix(in oklab, var(--destructive) 14%, transparent); border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }
.warn-card.over .warn-eyebrow, .warn-card.over .warn-title { color: var(--destructive); }
.warn-card.over .warn-sub { color: color-mix(in oklab, var(--destructive) 85%, transparent); }
.warn-card.over .warn-btn { background: var(--destructive); color: #fff; }

/* ---------- In / Out / Net summary (history) ---------- */
.io-summary { display: flex; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.io-item { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.io-label { font-size: 12px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.io-val { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.io-val.pos { color: var(--success); }
.io-val.neg { color: var(--destructive); }

/* ---------- Recent list ---------- */
.list { margin-top: 16px; list-style: none; padding: 0; margin-bottom: 0; }
.list.divide > li + li { border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.tx {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-radius: 16px; padding: 12px 8px; transition: transform .15s, background .15s;
}
.tx.hoverable:hover { transform: scale(1.02); background: var(--primary-soft); }
.tx-left { display: flex; min-width: 0; flex: 1; align-items: center; gap: 12px; }
.tx-ic { display: grid; height: 36px; width: 36px; flex-shrink: 0; place-items: center; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.tx-ic svg { height: 16px; width: 16px; }
.tx-ic.big { height: 40px; width: 40px; }
.tx-ic.uncat { background: color-mix(in oklab, var(--warning) 40%, transparent); color: var(--warning-foreground); }
.tx-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.tx-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted-foreground); }
.tx-right { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }
.tx-amt { font-size: 14px; font-weight: 600; }
.tx-amt.pos { color: var(--success); }
.divide li { padding: 12px 0; list-style: none; }
.divide .tx { padding: 0; border-radius: 0; }
.divide .tx:hover { transform: none; background: transparent; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 500; border: 0;
}
.badge.warn { background: color-mix(in oklab, var(--warning) 40%, transparent); color: var(--warning-foreground); }
.badge.warn:hover { background: color-mix(in oklab, var(--warning) 60%, transparent); }
.badge.soft { background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: color-mix(in oklab, var(--success, #16a34a) 18%, transparent); color: var(--success, #16a34a); }
.badge svg { height: 12px; width: 12px; }

.icon-edit {
  display: grid; height: 28px; width: 28px; place-items: center; border-radius: 999px;
  color: var(--muted-foreground); background: transparent; border: 0;
}
.icon-edit:hover { background: var(--background); color: var(--primary); }
.icon-edit.ring { border: 1px solid var(--border); }
.icon-edit.ring:hover { background: var(--primary-soft); }
.icon-edit svg { height: 14px; width: 14px; }
.small-edit { display: grid; height: 32px; width: 32px; place-items: center; border-radius: 999px; color: var(--muted-foreground); background: transparent; border: 0; }
.small-edit:hover { background: var(--muted); color: var(--foreground); }
.small-edit.danger:hover { background: color-mix(in oklab, var(--destructive, #dc2626) 14%, transparent); color: var(--destructive, #dc2626); }
.small-edit svg { height: 14px; width: 14px; }

/* ---------- Quick add ---------- */
.cat-grid { margin-top: 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cat-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border-radius: 16px; background: var(--surface); padding: 12px; text-align: center; border: 0; color: inherit;
  transition: background .15s;
}
.cat-tile:hover { background: var(--primary-soft); }
.cat-tile .ci { display: grid; height: 44px; width: 44px; place-items: center; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.cat-tile .ci svg { height: 20px; width: 20px; }
.cat-tile .cl { font-size: 12px; font-weight: 500; }
.cat-tile-add .ci { background: var(--surface); color: var(--muted-foreground); border: 1px dashed var(--border); }

/* Color dot shown for user-created categories (which have no line icon). */
.cat-dot { display: inline-block; width: 16px; height: 16px; border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.tx-ic .cat-dot { width: 18px; height: 18px; }

/* ---------- Category editor / manager ---------- */
.overlay.stacked { z-index: 80; } /* sits above the add-transaction dialog */
.dialog.cat-editor, .dialog.cat-manage { max-width: 420px; }
.input.input-error { border-color: var(--destructive); }
.swatch-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.cat-swatch {
  width: 30px; height: 30px; border-radius: 999px; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
  padding: 0; transition: transform .1s;
}
.cat-swatch:hover { transform: scale(1.08); }
.cat-swatch.active { border-color: var(--foreground); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--foreground); }
.cat-swatch-lg { display: inline-block; width: 22px; height: 22px; border-radius: 999px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
/* Keep the helper text clear of the color swatches above it */
.swatch-row + .field-hint { margin-top: 10px; }
/* Icon picker in the category editor */
.icon-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cat-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border: 1.5px solid var(--border, #e5e7eb); background: var(--card, #fff); color: var(--foreground, #111); padding: 0; transition: transform .1s, border-color .1s; }
.cat-icon svg { width: 20px; height: 20px; }
.cat-icon:hover { transform: scale(1.06); }
.cat-icon.active { border-color: var(--foreground, #111); box-shadow: 0 0 0 2px var(--card, #fff), 0 0 0 3px var(--foreground, #111); }
/* Colored category glyph in the manage-categories list */
.cmr-glyph { display: inline-flex; align-items: center; justify-content: center; width: 22px; flex: 0 0 auto; }
.cmr-glyph svg { width: 20px; height: 20px; }
.cmr-glyph .cat-dot { width: 16px; height: 16px; }
/* "See more" row at the bottom of the transaction list */
.see-more-row { list-style: none; display: flex; justify-content: center; padding: 12px 0 2px; }
.see-more-btn { min-width: 160px; }

/* Budget history dialog list */
.hist-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 8px; border-radius: 12px; }
.hist-row:hover { background: var(--surface); }
.hist-main { min-width: 0; }
.hist-range { font-size: 14px; font-weight: 600; margin: 0; }
.hist-amt { font-size: 13px; color: var(--muted-foreground); margin: 2px 0 0; }
.hist-amt .of { color: var(--muted-foreground); }

/* Goals header actions */
.head-actions { display: flex; align-items: center; gap: 8px; }

/* Unified Archive dialog */
.dialog-wide { max-width: 560px; }
.arch-body { max-height: 60vh; overflow-y: auto; }
.arch-head { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-foreground); margin: 18px 0 8px; }
.arch-head:first-child { margin-top: 4px; }
.arch-group { margin-bottom: 14px; }
.arch-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.arch-group-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.tile-archived { opacity: 0.78; }
.tile-archived .tile-name { display: flex; align-items: center; gap: 8px; }

.cat-manage-list { list-style: none; margin: 8px 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.cat-manage-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 12px; }
.cat-manage-row:hover { background: var(--surface); }
.cmr-name { flex: 1 1 auto; font-size: 14px; font-weight: 500; min-width: 0; }
.cmr-lock { font-size: 11px; font-weight: 500; color: var(--muted-foreground); }
.cmr-actions { display: flex; gap: 2px; flex: 0 0 auto; }

/* Pencil chip that opens the category manager on the History filters row. */
.chip.chip-acct { display: inline-flex; align-items: center; gap: 6px; }
.chip.chip-acct .cat-dot { width: 10px; height: 10px; }
.acct-tag { display: inline-flex; align-items: center; gap: 4px; }
.acct-tag .cat-dot { width: 9px; height: 9px; }
.chip.chip-edit { display: inline-flex; align-items: center; padding: 6px 10px; color: var(--muted-foreground); }
.chip.chip-edit svg { height: 14px; width: 14px; }
.chip.chip-edit:hover { color: var(--primary); border-color: color-mix(in oklab, var(--primary) 30%, transparent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; border: 0; font-weight: 600; font-size: 14px;
  padding: 10px 16px; transition: opacity .15s, background .15s; color: inherit;
}
.btn svg { height: 16px; width: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); font-weight: 500; }
.btn-outline:hover { background: var(--muted); }
.btn-lg { padding: 12px 16px; }
.link-inline { font-size: 12px; font-weight: 500; color: var(--primary); background: transparent; border: 0; }
.link-inline:hover { text-decoration: underline; }
.history-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.history-link:hover { color: var(--primary); }
.history-link svg { height: 12px; width: 12px; }

/* ---------- Period toggle / filters ---------- */
.seg { display: inline-flex; gap: 4px; border-radius: 999px; background: var(--surface); padding: 4px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 12px; font-weight: 500; color: var(--muted-foreground); transition: background .15s, color .15s; }
.seg button:hover { color: var(--foreground); }
.seg button.active { background: var(--primary); color: var(--primary-foreground); }
/* On phones the Day/Week/Month/Year control can't fit beside the title,
   so let the card header wrap and give the control its own full row. */
@media (max-width: 560px) {
  .hist-head { flex-wrap: wrap; }
  .hist-head .seg { width: 100%; justify-content: space-between; }
  .hist-head .seg button { flex: 1; padding: 6px 8px; text-align: center; }
}
/* Let the History card header wrap: when the title and the Day/Week/Month/Year
   control can't share a line (narrow card in the 3-col grid, or a small screen),
   the control drops to its own line instead of overflowing. Driven by real
   available width via flexbox — deliberately NOT a container query, because
   container-type gives the card an intrinsic min-width that defeats the
   `.grid > * { min-width: 0 }` rule above and blows out the 3-column row. */
.hist-head { flex-wrap: wrap; }
.hist-head > div:first-child { min-width: 0; }
/* Keep the control at its natural size and let it push right on a shared line;
   when it can't fit it wraps whole (never stretched or squished) on desktop. */
.hist-head .seg { flex: 0 0 auto; margin-left: auto; }
/* Home mini-history: always stack the period toggle directly under the
   "This week" heading, left-aligned, so it never floats off to the side. */
.hist-card .hist-head { flex-direction: column; align-items: flex-start; gap: 12px; }
.hist-card .hist-head .seg { margin-left: 0; }
.chip { border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground); }
.chip:hover { color: var(--foreground); }
.chip.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in oklab, var(--primary) 30%, transparent); }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; background: var(--card); padding: 6px 12px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); color: inherit; }
.pill-btn:hover { background: var(--surface); }
.pill-btn svg { height: 14px; width: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.controls { margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: 240px; }
.chart.short { height: 224px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.chart .axis-label { fill: var(--muted-foreground); font-size: 11px; font-family: var(--font-sans); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; }
.chart-head { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chart-nav { display: flex; align-items: center; gap: 8px; }
.round-btn { display: grid; height: 32px; width: 32px; place-items: center; border-radius: 999px; color: var(--muted-foreground); border: 1px solid var(--border); background: transparent; }
.round-btn:hover { background: var(--surface); color: var(--foreground); }
.round-btn:disabled { opacity: .4; cursor: not-allowed; }
.round-btn svg { height: 16px; width: 16px; }
.chart-heading { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.1; }
.chart-range { font-size: 12px; color: var(--muted-foreground); }

/* ---------- Coach chat ---------- */
.coach-welcome {
  /* Soft purple (not the teal --primary and not a yellow warning) so the banner
     reads as calm/informational — matches the portfolio testing finding. */
  margin-bottom: 20px; border-radius: 24px; padding: 20px;
  background: #F3F0FA;
  border: 1px solid #9B8EC4;
}
/* Dark mode: keep the calming purple but darken the fill so text stays readable. */
html.dark .coach-welcome { background: oklch(0.27 0.045 300); border-color: #9B8EC4; }
.coach-welcome .cw-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }

/* Weekly tip card on the home page — same calming purple as Welcome to Coach,
   deliberately not a warning color. */
/* Full-width tip: icon on the left, title and body stacked beside it. */
.tip-card {
  margin-top: 20px; border-radius: 24px; padding: 20px;
  display: flex; gap: 14px; align-items: flex-start;
  background: #F3F0FA;
  border: 1px solid #9B8EC4;
}
html.dark .tip-card { background: oklch(0.27 0.045 300); border-color: #9B8EC4; }
.tip-card .tip-ic { flex-shrink: 0; display: grid; place-items: center; height: 40px; width: 40px; border-radius: 999px; background: var(--card); color: oklch(0.5 0.14 300); }
html.dark .tip-card .tip-ic { color: oklch(0.74 0.12 300); }
.tip-card .tip-ic svg { width: 20px; height: 20px; }
.tip-card .tip-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.tip-card .tip-body { margin-top: 2px; font-size: 14px; line-height: 1.6; color: color-mix(in oklab, var(--foreground) 82%, transparent); }
/* Home: full-width balance hero, then the heads-up warning (when relevant) and
   the weekly tip stacked full-width beneath it — the tip reads as a slim
   secondary banner rather than competing with the balance. */
.hero-row { display: grid; gap: 20px; grid-template-columns: 1fr; }
.hero-row > * { min-width: 0; }
.home-right { display: flex; flex-direction: column; gap: 20px; }
.home-right .tip-card { margin-top: 0; }
.coach-welcome .cw-body { margin-top: 4px; font-size: 14px; line-height: 1.6; color: color-mix(in oklab, var(--foreground) 80%, transparent); }
.chat-card { display: flex; flex-direction: column; height: 60vh; border-radius: 24px; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px color-mix(in oklab, var(--border) 60%, transparent); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg-row { display: flex; }
.msg-row.you { justify-content: flex-end; }
.msg-row.coach { justify-content: flex-start; }
.bubble { max-width: 80%; border-radius: 16px; padding: 10px 16px; font-size: 14px; line-height: 1.6; }
.bubble.you { background: var(--primary); color: var(--primary-foreground); }
.bubble.coach { background: var(--surface); color: var(--foreground); }
.chat-form { display: flex; align-items: center; gap: 8px; border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent); padding: 12px; }
.chat-form input { flex: 1; border-radius: 999px; background: var(--surface); padding: 10px 16px; font-size: 14px; border: 1px solid transparent; outline: none; color: inherit; font-family: inherit; }
.chat-form input:focus { border-color: color-mix(in oklab, var(--primary) 40%, transparent); }
.send-btn { display: grid; height: 40px; width: 40px; place-items: center; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); border: 0; }
.send-btn:hover { opacity: .9; }
.send-btn svg { height: 16px; width: 16px; }

/* ---------- Journal ---------- */
.journal-head-ic { display: grid; height: 40px; width: 40px; place-items: center; border-radius: 16px; background: var(--primary); color: var(--primary-foreground); }
.journal-head-ic svg { height: 20px; width: 20px; }
.field-label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500; }
textarea.journal-area { width: 100%; resize: vertical; border-radius: 16px; background: var(--surface); padding: 16px; font-size: 14px; font-family: inherit; border: 1px solid transparent; outline: none; color: inherit; }
textarea.journal-area:focus { border-color: color-mix(in oklab, var(--primary) 40%, transparent); }
.entry { border-radius: 16px; background: var(--card); padding: 20px; box-shadow: 0 0 0 1px color-mix(in oklab, var(--border) 60%, transparent); }
.entry-top { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entry-date { font-size: 12px; color: var(--muted-foreground); }
.entry-text { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
.empty { border-radius: 16px; background: var(--surface); padding: 24px; font-size: 14px; color: var(--muted-foreground); }

/* ---------- Inputs / fields ---------- */
.field { display: block; font-size: 14px; }
.field > .lbl { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
.input {
  width: 100%; border-radius: 12px; background: var(--surface);
  padding: 10px 14px; font-size: 14px; outline: none; color: inherit;
  border: 1px solid var(--border); font-family: inherit;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary) 20%, transparent); }
/* iOS Safari gives date/time inputs an intrinsic width that ignores width:100%,
   so the field bulges past the dialog edge. Force it to size like every other
   field. Scoped to date/time so the Category/Account <select>s keep their
   native chevrons. */
.input[type="date"],
.input[type="time"],
.input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  text-align: left;
}
.input[type="date"]::-webkit-date-and-time-value,
.input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
}
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Toggle switch ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 16px; background: var(--surface); padding: 16px; }
.toggle-row .tr-label { font-size: 14px; font-weight: 500; }
.toggle-row .tr-desc { font-size: 12px; color: var(--muted-foreground); }
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; border-radius: 999px; background: var(--input); border: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; height: 20px; width: 20px; border-radius: 999px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }
.settings-btn { width: 100%; border-radius: 16px; background: var(--surface); padding: 12px 16px; text-align: left; font-size: 14px; font-weight: 500; border: 0; color: inherit; }
.settings-btn:hover { background: var(--primary-soft); }

/* ---------- Dialog / modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 16px; }
.overlay.open { display: flex; }
.dialog { width: 100%; max-width: 480px; border-radius: 20px; background: var(--card); color: var(--card-foreground); padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dialog h3 { font-size: 18px; font-weight: 600; }
.dialog .d-desc { margin-top: 4px; font-size: 14px; color: var(--muted-foreground); }
.dialog-body { padding: 12px 0; }
.dialog-body > * + * { margin-top: 12px; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dialog-foot.between { justify-content: space-between; }
.choose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 0; }
.choose-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border-radius: 16px; background: var(--surface); padding: 16px; text-align: left; border: 0; color: inherit; }
.choose-tile:hover { background: var(--primary-soft); }
.choose-tile svg { height: 20px; width: 20px; color: var(--primary); }
.choose-tile .ct-eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
.choose-tile .ct-body { font-size: 14px; }
.del-btn { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 8px 12px; font-size: 14px; font-weight: 500; color: var(--destructive); background: transparent; border: 0; }
.del-btn:hover { background: color-mix(in oklab, var(--destructive) 10%, transparent); }

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

/* focus ring for goal highlight */
.ring-focus { box-shadow: 0 0 0 2px var(--primary); }

/* ---------- Extras for inner pages ---------- */
.btn-danger { border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent); background: color-mix(in oklab, var(--destructive) 10%, transparent); color: var(--destructive); font-weight: 600; }
.btn-danger:hover { background: color-mix(in oklab, var(--destructive) 20%, transparent); }
.foot-right { display: flex; align-items: center; gap: 8px; }
.page-avatar { display: grid; place-items: center; height: 56px; width: 56px; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); flex-shrink: 0; overflow: hidden; }
.avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.page-avatar svg { height: 24px; width: 24px; }
.stack > * + * { margin-top: 12px; }
.send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   Auth screen (login / signup)
   ============================================================ */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--background); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: 0 12px 40px color-mix(in oklab, var(--foreground) 8%, transparent); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 24px; text-align: center; }
.auth-logo-img { height: 46px; width: auto; display: block; }
.auth-logo { display: grid; place-items: center; height: 48px; width: 48px; border-radius: 14px; background: var(--primary); color: var(--primary-foreground); flex-shrink: 0; }
.auth-logo svg { height: 24px; width: 24px; }
.auth-name { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.auth-tag { font-size: 13px; color: var(--muted-foreground); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--muted); border-radius: 12px; margin-bottom: 20px; }
.auth-tab { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted-foreground); cursor: pointer; }
.auth-tab.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px color-mix(in oklab, var(--foreground) 10%, transparent); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form[hidden] { display: none; }
.auth-error { min-height: 18px; margin: -4px 0 0; font-size: 13px; font-weight: 500; color: var(--destructive); }
.auth-foot { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted-foreground); }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 2px 0; color: var(--muted-foreground); font-size: 12px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-google { display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-link { border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--primary); text-align: center; padding: 2px; margin: -6px 0 0; }
.auth-link:hover { text-decoration: underline; }
.auth-hint { margin: 0 0 2px; font-size: 13px; color: var(--muted-foreground); line-height: 1.4; }

/* ============================================================
   Coach locked state (paid upgrade)
   ============================================================ */
.coach-lock { text-align: center; max-width: 460px; margin: 8px auto 0; padding: 32px 24px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; }
.lock-badge { display: inline-grid; place-items: center; height: 56px; width: 56px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); margin-bottom: 16px; }
.lock-badge svg { height: 26px; width: 26px; }
.lock-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.lock-body { margin: 8px auto 0; max-width: 380px; font-size: 14px; line-height: 1.6; color: color-mix(in oklab, var(--foreground) 80%, transparent); }
.lock-list { list-style: none; margin: 20px auto; padding: 0; max-width: 300px; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.lock-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.lock-list svg { height: 18px; width: 18px; color: var(--primary); flex-shrink: 0; }
.lock-note { margin-top: 12px; font-size: 12px; color: var(--muted-foreground); }

/* ============================================================
   Hero balance edit button
   ============================================================ */
.field-hint { margin: -4px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted-foreground); }
/* The balance-as-of hint is a standalone sibling under the date input, so the
   default negative top margin makes it collide with the field. Give it the same
   breathing room as the Color hint. */
#acc-bal-hint { margin-top: 10px; }
.hero-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero-edit {
  display: grid; place-items: center; height: 30px; width: 30px; border: 0; border-radius: 999px;
  background: color-mix(in oklab, var(--primary-foreground) 18%, transparent);
  color: var(--primary-foreground); cursor: pointer; flex-shrink: 0; transition: background .15s;
}
.hero-edit:hover { background: color-mix(in oklab, var(--primary-foreground) 30%, transparent); }
.hero-edit svg { height: 15px; width: 15px; }

/* ============================================================
   Expense / Income toggle inside the Add dialog
   ============================================================ */
.type-seg { width: 100%; margin-bottom: 4px; }
.type-seg button { flex: 1; }

/* ============================================================
   Profile photo row
   ============================================================ */
.photo-row { display: flex; align-items: center; gap: 16px; padding: 4px 0 8px; }
.photo-actions { min-width: 0; }
.photo-btns { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.photo-btns .btn { padding: 8px 14px; font-size: 13px; }
.danger-link { color: var(--destructive); }

/* ============================================================
   Photo cropper (drag to pan, slider to zoom)
   ============================================================ */
.crop-stage {
  position: relative; width: 100%; max-width: 300px; aspect-ratio: 1 / 1;
  margin: 4px auto 0; border-radius: 16px; overflow: hidden;
  background: var(--muted); touch-action: none; cursor: grab; user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage #crop-img { position: absolute; left: 0; top: 0; max-width: none; pointer-events: none; }
.crop-mask {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: 0 0 0 2000px color-mix(in oklab, var(--foreground) 45%, transparent);
  border-radius: 50%;
}
.crop-zoom { display: flex; align-items: center; gap: 10px; margin: 16px 2px 4px; }
.crop-zoom .crop-zi { height: 18px; width: 18px; color: var(--muted-foreground); flex-shrink: 0; }
.crop-zoom input[type="range"] { flex: 1; accent-color: var(--primary); }

/* ============================================================
   ACCOUNT TOGGLE (home hero) — switch Checking / Savings / more
   ============================================================ */
/* Segmented control that sits on the teal hero. The whole toggle is a
   flex row: a translucent "track" holding the account chips, plus a
   clearly-labelled Add button beside it. */
/* Hero header: account toggle on the left, Add + edit actions on the right. */
.hero-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.hero-actions { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.acct-toggle {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 0;
}
.acct-seg {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px; border-radius: 999px;
  background: color-mix(in oklch, white 18%, transparent);
}
.acct-chip {
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 600;
  padding: 7px 20px; border-radius: 999px;
  border: 0; background: transparent;
  color: color-mix(in oklch, white 82%, transparent);
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.acct-chip:hover { color: #fff; }
.acct-chip.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
/* Add-account: a visible pill ("+ Add"), not a faint icon. */
.acct-add {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid color-mix(in oklch, white 55%, transparent);
  background: color-mix(in oklch, white 12%, transparent);
  color: #fff;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  line-height: 1; cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.acct-add:hover { background: color-mix(in oklch, white 26%, transparent); }
.acct-add .acct-add-plus { font-size: 16px; line-height: 1; margin-top: -1px; }

/* ============================================================
   ACCOUNT DIALOG — edit / add account + transfer between accounts
   ============================================================ */
.acct-transfer {
  margin-top: 6px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.acct-transfer-head {
  font-size: 13px; font-weight: 700; color: var(--foreground);
  margin: 0 0 8px;
}
.acct-transfer .field { margin-bottom: 10px; }

.dialog-foot-split {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.foot-actions { display: flex; align-items: center; gap: 8px; }
.btn-ghost-danger {
  background: none; border: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 600;
  color: var(--destructive); padding: 8px 4px;
}
.btn-ghost-danger:hover { text-decoration: underline; }

/* ============================================================
   BANK IMPORT (Add transaction → Import from bank)
   ============================================================ */
.import-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.import-dropzone:hover, .import-dropzone.drag {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.import-dropzone svg { width: 34px; height: 34px; stroke: var(--primary); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }
.import-dropzone .idz-title { font-weight: 700; color: var(--foreground); }
.import-dropzone .idz-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 4px; }

.import-hint {
  font-size: 12.5px;
  color: var(--muted-foreground);
  margin-top: 12px;
  line-height: 1.5;
}

.dialog.import-dialog { max-width: 560px; width: 100%; }

.import-summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.import-pill {
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.import-pill.warn { background: var(--warning); color: var(--warning-foreground); }

.import-acct { margin: 0 0 12px; }

.import-list {
  max-height: 46vh; overflow-y: auto;
  margin: 0 -4px; padding: 0 4px; list-style: none;
}
.import-row {
  display: grid; grid-template-columns: 24px 1fr auto;
  align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.import-row:last-child { border-bottom: 0; }
.import-row.excluded { opacity: 0.4; }
.import-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.import-row .ir-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-row .ir-meta { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.import-row .ir-right { display: flex; align-items: center; gap: 8px; }
.import-row .ir-amt { font-weight: 700; font-size: 14px; white-space: nowrap; }
.import-row .ir-amt.pos { color: var(--success); }
.import-row select.ir-cat {
  font-family: var(--font-sans); font-size: 12px;
  padding: 4px 6px; border: 1px solid var(--input); border-radius: 8px;
  background: var(--card); color: var(--foreground);
}
.import-row .ir-cat[data-income="1"] { display: none; }

.import-error {
  background: color-mix(in oklch, var(--destructive) 12%, transparent);
  color: var(--destructive);
  border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; line-height: 1.5;
}

.import-launch {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 4px; padding: 12px;
  border: 1px solid var(--input); border-radius: var(--radius);
  background: var(--card); color: var(--primary);
  font-family: var(--font-sans); font-weight: 600; font-size: 14px; cursor: pointer;
}
.import-launch svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.import-launch:active { background: var(--surface); }

.import-or {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 10px; color: var(--muted-foreground); font-size: 12px;
}
.import-or::before, .import-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ============================================================
   COACH — typing indicator, privacy + consent gate
   ============================================================ */
.bubble.typing { display: inline-flex; gap: 4px; align-items: center; }
.bubble.typing .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .4;
  animation: bff-typing 1.2s infinite ease-in-out;
}
.bubble.typing .dot:nth-child(2) { animation-delay: .2s; }
.bubble.typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes bff-typing {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: .9; transform: translateY(-3px); }
}

.coach-privacy {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 16px; padding: 12px 14px;
  background: var(--muted); border: 1px solid var(--border); border-radius: 12px;
}
.coach-privacy .cp-icon { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; color: var(--primary); }
.coach-privacy .cp-icon svg { width: 18px; height: 18px; }
.coach-privacy p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted-foreground); }
.coach-privacy a { color: var(--primary); }

.privacy-note {
  padding: 12px 14px; margin-bottom: 4px;
  background: var(--muted); border: 1px solid var(--border); border-radius: 12px;
}
.privacy-note p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.55; color: var(--muted-foreground); }
.privacy-note p:last-child { margin-bottom: 0; }

.coach-consent {
  text-align: center; padding: 22px 18px 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 24px rgba(16, 96, 112, .08);
}
.coach-consent .cc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-bottom: 10px;
  border-radius: 50%; color: var(--primary); background: var(--muted);
}
.coach-consent .cc-icon svg { width: 22px; height: 22px; }
.coach-consent .cc-title { margin: 0 0 6px; font-size: 17px; }
.coach-consent .cc-body { margin: 0 auto 16px; max-width: 440px; font-size: 13px; line-height: 1.55; color: var(--muted-foreground); }
.coach-consent .cc-link {
  display: inline-block; margin-top: 10px; padding: 6px;
  background: none; border: 0; cursor: pointer;
  font-size: 12.5px; color: var(--primary); text-decoration: underline;
}

/* ---------- Import: PDF caveat, loading spinner, tappable amount ---------- */
.import-note {
  background: var(--warning); color: var(--warning-foreground);
  border-radius: 12px; padding: 10px 12px;
  font-size: 12.5px; line-height: 1.5; margin: 0 0 12px;
}
button.ir-amt {
  font-family: var(--font-sans);
  border: 0; background: transparent; cursor: pointer;
  color: var(--foreground);
  padding: 2px 6px; border-radius: 8px;
}
button.ir-amt:hover { background: var(--surface); }
.import-loading { text-align: center; padding: 22px 8px 8px; color: var(--muted-foreground); }
.import-loading p { margin: 12px 0 0; font-size: 13px; line-height: 1.5; }
.import-spin {
  display: inline-block; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: bff-spin 0.8s linear infinite;
}
@keyframes bff-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Touch / iOS Safari refinements
   These only apply on real touch devices (phones), so the
   narrow-desktop preview is unchanged.
   ============================================================ */

/* iOS zooms the page in whenever you focus a form control whose text is
   smaller than 16px. Force 16px on the actual input on coarse-pointer
   devices so tapping a field no longer yanks the layout around. The visual
   size barely changes; the jarring zoom disappears. */
@media (pointer: coarse) {
  input, select, textarea,
  .field input, .field select,
  .chat-form input, textarea.journal-area {
    font-size: 16px;
  }
}

/* On touch devices there's no real hover — but CSS :hover still fires on tap
   and then "sticks" until you tap elsewhere, which is what made buttons and
   tiles look wonky after a press. Neutralise the hover styles that move or
   recolor things so a tap looks clean. */
@media (hover: none) {
  .tile.link:hover { transform: none; background: var(--card); box-shadow: none; }
  .tx.hoverable:hover { transform: none; background: transparent; }
  .cat-swatch:hover,
  .cat-icon:hover { transform: none; }
  .nav-link:hover,
  .nav-profile:hover,
  .icon-btn:hover,
  .settings-btn:hover,
  .choose-tile:hover,
  .cat-tile:hover,
  .hist-row:hover,
  .cat-manage-row:hover,
  .pill-btn:hover,
  .chip:not(.active):hover,
  .seg button:not(.active):hover,
  .btn-primary:hover,
  .btn-outline:hover { background: inherit; color: inherit; transform: none; }
}

/* ============================================================
   History: search + Filter/Sort dropdowns
   Shown at every width (mobile and desktop); replaces the old
   chip rows, which are always hidden now.
   ============================================================ */
.hist-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
#hi-acct-filters, #hi-filters { display: none !important; }
.hist-search { position: relative; }
.hist-search .hs-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.hist-search input { padding-left: 38px; }
.hist-btn-row { display: flex; gap: 8px; }
.dropdown { position: relative; }
.hist-tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 128px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  font-family: inherit; font-size: 14px; font-weight: 600;
}
.hist-tool-btn svg { width: 16px; height: 16px; }
.hist-tool-btn.has-active { border-color: var(--primary); color: var(--primary); }
.hist-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--primary); color: var(--primary-foreground); font-size: 11px; font-weight: 700;
}
/* Filter/Sort menus are a slide-up bottom sheet at EVERY width (desktop too).
   On wide screens the sheet is centred with a max width so it reads as an
   intentional panel rather than a full-bleed bar. */
.dd-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.dd-backdrop.open { opacity: 1; pointer-events: auto; }

.dropdown-menu {
  position: fixed; z-index: 70;
  left: 0; right: 0; bottom: 0; top: auto;
  margin-left: auto; margin-right: auto; /* centre the sheet on wide screens */
  width: min(92vw, 720px); min-width: 0; max-width: 720px; max-height: 75vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.2);
  visibility: hidden; transform: translateY(100%); transition: transform .25s ease, visibility .25s ease;
}
.dropdown-menu.left, .dropdown-menu.right { left: 0; right: 0; }
.dropdown-menu.open { visibility: visible; transform: translateY(0); }

/* Drag-handle affordance at the top of the sheet */
.dropdown-menu::before {
  content: ""; display: block; width: 40px; height: 4px; margin: 4px auto 8px;
  border-radius: 999px; background: var(--border);
}
.dd-title {
  font-family: var(--font-display); font-size: 18px; font-weight: 600;
  padding: 2px 6px 8px;
}
.dd-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); padding: 12px 10px 4px; }
.dd-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 14px 10px; border: 0; background: transparent; border-radius: 9px;
  font-family: inherit; font-size: 15px; color: var(--foreground); text-align: left;
}
.dd-opt.active { background: var(--primary-soft); font-weight: 600; }
.dd-opt-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.dd-opt-label svg { width: 15px; height: 15px; flex-shrink: 0; }
.dd-check { color: var(--primary); flex-shrink: 0; }
.dd-opt-action { border-top: 1px solid var(--border); border-radius: 0; margin-top: 4px; color: var(--muted-foreground); }

/* On phones the two buttons stretch to fill the row for bigger tap targets. */
@media (max-width: 767px) {
  .hist-btn-row .dropdown { flex: 1; }
  .hist-tool-btn { width: 100%; min-width: 0; }
  /* Stack the hero header but keep everything left-aligned; the account toggle
     wraps to the next line instead of overflowing as accounts are added. */
  .hero-top { flex-direction: column; align-items: flex-start; }
  .acct-toggle {
    width: 100%; justify-content: flex-start;
    flex-wrap: wrap;
  }
  .acct-seg { max-width: 100%; overflow-x: auto; }
  .hero-actions { justify-content: flex-start; }
}

/* On desktop a bottom sheet looks stranded, so float it as a centered modal. */
@media (min-width: 768px) {
  .dropdown-menu {
    top: 50%; bottom: auto; left: 50%; right: auto;
    margin: 0;
    width: min(90vw, 460px); max-width: 460px; max-height: 80vh;
    border-radius: 20px;
    padding: 12px 16px 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.28);
    transform: translate(-50%, -48%) scale(.97);
    transition: transform .18s ease, opacity .18s ease, visibility .18s ease;
    opacity: 0;
  }
  .dropdown-menu.left, .dropdown-menu.right { left: 50%; right: auto; }
  .dropdown-menu.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  /* Hide the mobile drag-handle in modal mode. */
  .dropdown-menu::before { display: none; }
}
/* ============================================================
   Help & FAQ accordion (Profile page)
   ============================================================ */
.faq { display: flex; flex-direction: column; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:last-of-type { border-bottom: 0; }
.faq-item > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 4px; font-weight: 600; font-size: 15px; color: var(--foreground);
}
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-arrow { flex-shrink: 0; width: 18px; height: 18px; color: var(--muted-foreground); transition: transform .2s ease; }
.faq-item[open] > summary .faq-arrow { transform: rotate(180deg); }
.faq-body { padding: 0 4px 16px; }
.faq-body p { color: var(--muted-foreground); font-size: 14px; line-height: 1.55; }
.faq-contact { margin-top: 8px; padding: 14px 4px 2px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted-foreground); }
.faq-contact a { color: var(--primary); font-weight: 600; }

/* ============================================================
   Repeat / recurring controls (Add Transaction dialog)
   ============================================================ */
.recur-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--foreground); }
.recur-toggle input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.recur-opts { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
/* These carry the `hidden` attribute for their default state; a plain
   display rule would override it, so honor `hidden` explicitly. */
.recur-opts[hidden] { display: none; }
#add-recur-custom[hidden] { display: none; }
.recur-note { font-size: 13px; line-height: 1.5; color: var(--muted-foreground); margin: 0; }

/* ============================================================
   Recurring payments card (Profile page)
   ============================================================ */
.recur-list { display: flex; flex-direction: column; gap: 10px; }
.recur-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.recur-row-main { flex: 1; min-width: 0; }
.recur-row-name { font-weight: 600; font-size: 15px; color: var(--foreground); }
.recur-row-meta { font-size: 13px; color: var(--muted-foreground); margin-top: 2px; }
.recur-row-amt { font-weight: 700; font-size: 15px; white-space: nowrap; }
.recur-row-amt.income { color: #2f9e6f; }
.recur-row-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.recur-edit, .recur-stop { flex-shrink: 0; border: 1px solid var(--border); background: transparent; color: var(--muted-foreground); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.recur-edit:hover { color: var(--primary); border-color: var(--primary); }
.recur-stop:hover { color: #c0392b; border-color: #c0392b; }
