/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --navy:         #0d1b2a;
  --navy-light:   #16293d;
  --navy-mid:     #1e3a52;
  --cream:        #f7f3ed;
  --cream-dark:   #ece7de;
  --cream-deeper: #e2dbd0;
  --gold:         #c9a84c;
  --gold-light:   #f0e6c4;
  --gold-tint:    rgba(201,168,76,0.09);
  --gold-dark:    #a8872e;
  --coral:        #d4614e;
  --coral-light:  #fad8d3;
  --coral-tint:   rgba(212,97,78,0.08);
  --green:        #3d9e6a;
  --green-light:  #d0f0e0;
  --slate:        #475569;
  --slate-light:  #64748b;
  --slate-faint:  #94a3b8;
  --text:         #1a1f2e;
  --text-light:   #4a5568;
  --ink-strong:   #0d1b2a;   /* navy as text — flips light in dark mode */
  --border:       #d8d2c8;
  --border-light: #e8e3db;
  --surface:      #ffffff;
  --sidebar-w:    240px;
  --bottom-nav-h: 60px;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg:    0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --t:            180ms;
}

/* ── Dark mode — same tokens, night values ─────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --cream:        #10151f;
    --cream-dark:   #1a2130;
    --cream-deeper: #232c3e;
    --gold-light:   rgba(201, 168, 76, 0.22);
    --gold-tint:    rgba(201, 168, 76, 0.12);
    --coral-light:  rgba(212, 97, 78, 0.24);
    --coral-tint:   rgba(212, 97, 78, 0.12);
    --green-light:  rgba(61, 158, 106, 0.24);
    --slate:        #a9b4c6;
    --slate-light:  #8d99ad;
    --slate-faint:  #5f6d83;
    --text:         #e8e6e1;
    --text-light:   #a9b0bd;
    --ink-strong:   #eef0f4;
    --border:       #2d374a;
    --border-light: #222b3c;
    --surface:      #1a2230;
    --shadow-sm:    0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow:       0 4px 12px rgba(0,0,0,0.45), 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg:    0 12px 32px rgba(0,0,0,0.55), 0 4px 8px rgba(0,0,0,0.35);
  }
}

/* ── Korean language overrides ─────────────────────────────────────────── */
:lang(ko), .lang-ko {
  word-break: keep-all;
  line-height: 1.75;
  font-weight: 500;
}
html:lang(ko) h1, html:lang(ko) h2, html:lang(ko) h3,
html:lang(ko) .page-title, html:lang(ko) .section-title,
html:lang(ko) .sidebar-logo .logo-text { font-weight: 700; }

/* Korean font size boost — Noto Sans KR needs ~10% more size to feel equivalent */
html:lang(ko) table             { font-size: 15px; }
html:lang(ko) thead th          { font-size: 11px; }
html:lang(ko) .nav-link         { font-size: 15px; }
html:lang(ko) .bottom-nav-item span { font-size: 11.5px; }
html:lang(ko) .stat-label       { font-size: 12.5px; }
html:lang(ko) .stat-value       { font-size: 29px; }
html:lang(ko) .page-eyebrow     { font-size: 11px; }
html:lang(ko) .page-title       { font-size: 24px; }
html:lang(ko) .section-title    { font-size: 17px; }
html:lang(ko) .form-field label { font-size: 12px; }
html:lang(ko) input, html:lang(ko) select, html:lang(ko) .btn { font-size: 14px; }
html:lang(ko) .timeline-item-name { font-size: 15px; }
html:lang(ko) .upcoming-name   { font-size: 14px; }
html:lang(ko) .rta-label       { font-size: 12px; }
html:lang(ko) .rta-amount      { font-size: 29px; }
html:lang(ko) .budget-group-name { font-size: 11px; }

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--cream);
  /* Stop the whole page from rubber-banding / triggering a pull-to-refresh
     gesture — native apps don't bounce their outer chrome. Inner scroll
     containers (tables, the forecast list, the calendar agenda) keep their
     own natural scrolling; this only contains the page-level overscroll. */
  overscroll-behavior-y: none;
}
body {
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  background: var(--cream);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  /* Remove the default gray flash on tap — buttons/links get their own
     :active feedback below instead, closer to a native button press. */
  -webkit-tap-highlight-color: transparent;
}

/* Chrome (buttons, nav, bottom nav) shouldn't show a text-selection cursor
   or the long-press "copy/share" callout — actual content text (amounts,
   descriptions, notes) is left selectable as normal. */
.btn, .nav-link, .bottom-nav-item, .lang-toggle, .hamburger,
.sidebar-logout-btn, .month-nav-btn, .cal-add-btn, .csv-upload-btn,
.trend-chip, .insights-month-pill, .insights-housing-chip {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Native-style tap feedback — a quick scale-down instead of relying on
   :hover (which touch devices fake unreliably on first tap). .btn already
   has its own :active scale; these cover the rest of the tappable chrome. */
.nav-link:active, .bottom-nav-item:active, .cal-add-btn:active,
.csv-upload-btn:active, .month-nav-btn:active, .lang-toggle:active,
.bt-card:active, .claim-card:active, .trend-chip:active,
.insights-month-pill:active, .insights-housing-chip:active {
  transform: scale(0.96);
  transition: transform 100ms ease;
}

/* ── Mobile Header ─────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  /* min-height (not height) so the safe-area padding below adds on top of
     the 52px content row instead of eating into a fixed box — under
     box-sizing:border-box, `height:52px` + `padding-top` would squash the
     visible content into whatever's left after the notch inset. */
  min-height: calc(52px + env(safe-area-inset-top));
  background: var(--navy);
  z-index: 90;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
}

.mobile-header-title {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.02em;
}

/* ── Hamburger ─────────────────────────────────────────────────────────── */
.hamburger {
  width: 40px; height: 40px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background var(--t) var(--ease);
}
.hamburger:hover { background: rgba(255,255,255,0.08); }
.hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: rgba(255,255,255,0.75);
  border-radius: 2px;
  transition: var(--t) var(--ease);
}

/* ── Sidebar Overlay ───────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 98;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t) var(--ease);
}
.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 99;
  transition: transform var(--t) var(--ease);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.logo-mark {
  color: var(--gold);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
  border-left: 3px solid transparent;
  border-radius: 0;
  position: relative;
}

.nav-link:hover {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.05);
}

.nav-link.active {
  color: var(--gold);
  border-left-color: var(--gold);
  background: rgba(201,168,76,0.1);
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

.sidebar-footer-text {
  font-size: 11px;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.04em;
}

/* ── Offline indicator / sync ──────────────────────────────────────────── */
.offline-indicator {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #ef9a9a;
  margin-bottom: 8px;
}
.offline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef476f;
  flex-shrink: 0;
  animation: offline-pulse 2s ease-in-out infinite;
}
@keyframes offline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.offline-sync-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 10px;
  background: var(--gold-tint);
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: var(--radius-sm);
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--t);
}
.offline-sync-btn:hover { background: rgba(201,168,76,0.18); }
.offline-sync-btn:disabled { opacity: 0.6; cursor: default; }
.offline-sync-count {
  background: var(--gold);
  color: var(--ink-strong);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

/* ── Sidebar user chip ─────────────────────────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: rgba(255,255,255,0.07);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user-icon {
  font-size: 14px;
  color: var(--gold);
  flex-shrink: 0;
}
.sidebar-username {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout-btn {
  background: none;
  border: none;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  padding: 2px 0;
  flex-shrink: 0;
  transition: color var(--t);
}
.sidebar-logout-btn:hover { color: rgba(255,255,255,0.7); }

/* ── Auth overlay ──────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 32px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo .logo-mark {
  font-size: 22px;
  color: var(--gold);
}
.auth-logo .logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: -0.02em;
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
.auth-tab.active {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: var(--shadow-sm);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: -8px;
}
.auth-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  color: var(--slate-faint);
}
.auth-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t), box-shadow var(--t);
  box-sizing: border-box;
}
.auth-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
.auth-error {
  font-size: 13px;
  color: var(--coral);
  padding: 8px 10px;
  background: var(--coral-tint);
  border-radius: var(--radius-sm);
  border: 1px solid var(--coral-light);
}
.auth-submit {
  margin-top: 4px;
  padding: 11px 20px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), transform var(--t);
  font-family: inherit;
}
.auth-submit:hover { background: var(--navy-mid); }
.auth-submit:active { transform: scale(0.98); }

/* ── Lang Toggle ───────────────────────────────────────────────────────── */
.lang-toggle {
  display: block;
  margin: 4px 20px 12px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--t) var(--ease);
  text-align: center;
  width: calc(100% - 40px);
  letter-spacing: 0.02em;
}
.lang-toggle:hover {
  background: rgba(255,255,255,0.1);
  color: var(--gold);
  border-color: rgba(201,168,76,0.5);
}

/* ── Bottom Nav (mobile) ───────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  /* min-height (not height) — same box-sizing:border-box issue as
     .mobile-header: a fixed height would let the home-indicator inset
     padding squash the actual nav items instead of adding below them. */
  min-height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--navy);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 80;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  font-size: 10px;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: color var(--t) var(--ease);
  flex: 1;
  justify-content: center;
}
.bottom-nav-item svg { width: 20px; height: 20px; stroke: currentColor; }
.bottom-nav-item.active { color: var(--gold); }
.bottom-nav-item:active { color: rgba(255,255,255,0.7); }

/* ── Main Content ──────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 48px 56px 64px;
  min-height: 100vh;
  max-width: calc(var(--sidebar-w) + 900px);
}

/* ── Page Header ───────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 36px;
  animation: fadeIn 220ms var(--ease) both;
}

.page-eyebrow {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--slate-faint);
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-weight: 500;
  margin-bottom: 6px;
}

.page-title {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--ink-strong);
  line-height: 1.25;
}

/* ── Stat Blocks ───────────────────────────────────────────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 40px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeIn 220ms 40ms var(--ease) both;
}

.stat-block {
  padding: 24px 28px;
  border-right: 1px solid var(--border-light);
  transition: background var(--t) var(--ease);
}
.stat-block:last-child { border-right: none; }
.stat-block:hover { background: var(--cream); }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--slate-faint);
  margin-bottom: 10px;
  font-weight: 500;
}

.stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
}

.stat-value.positive { color: var(--gold-dark); }
.stat-value.negative { color: var(--coral); }
.stat-value.neutral  { color: var(--slate); }

/* ── Section titles ────────────────────────────────────────────────────── */
.section-title {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 16px;
}

/* ── Chart container ───────────────────────────────────────────────────── */
.chart-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  margin-bottom: 40px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 220ms 80ms var(--ease) both;
  overflow: hidden;
}
.chart-wrap canvas { max-height: 200px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
  animation: fadeIn 220ms 120ms var(--ease) both;
}

/* Mobile scroll container for tables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--slate-faint);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--t) var(--ease);
  cursor: pointer;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:not(.cat-sep-row):hover { background: var(--gold-tint); }

thead th:first-child,
tbody tr td:first-child {
  padding-left: 14px;
  border-left: 3px solid transparent;
}

tbody tr:not(.cat-sep-row):hover td:first-child {
  border-left-color: var(--gold);
}

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.mono {
  font-family: 'DM Mono', monospace;
  font-size: 12.5px;
  letter-spacing: -0.01em;
}

.positive { color: var(--gold-dark); }
.negative { color: var(--coral); }
.neutral  { color: var(--slate); }

/* ── Table footer ──────────────────────────────────────────────────────── */
.table-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 11px 16px;
  background: var(--cream);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--slate);
  gap: 12px;
}
.table-footer .footer-total {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  color: var(--coral);
}

/* ── Free Cash Flow strip ──────────────────────────────────────────────── */
.fcf-strip {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 18px 20px;
  background: var(--navy);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: -1px;
}
.fcf-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.fcf-item.fcf-result {
  flex: 1.2;
}
.fcf-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.45);
}
.fcf-value {
  font-family: 'DM Mono', monospace;
  font-size: 17px;
  font-weight: 500;
}
.fcf-value.positive { color: #d4a84b; }
.fcf-value.negative { color: #e07060; }
.fcf-result .fcf-label { color: rgba(255,255,255,0.7); }
.fcf-result .fcf-value { font-size: 20px; }
.fcf-divider {
  font-size: 18px;
  color: rgba(255,255,255,0.25);
  padding: 0 14px;
  align-self: flex-end;
  padding-bottom: 2px;
}

/* ── Inline form row ───────────────────────────────────────────────────── */
.inline-form-row {
  display: none;
  padding: 16px 18px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  animation: slideDown 160ms var(--ease) both;
}
.inline-form-row.visible { display: block; }
.inline-form-row form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-field label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  font-weight: 600;
}
.form-field input,
.form-field select {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 7px 10px;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-size: 13px;
  min-width: 110px;
  transition: border-color var(--t) var(--ease);
  -webkit-appearance: none;
}
.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(255,255,255,0.1);
}
.form-field select option { background: var(--navy); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t) var(--ease);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-gold {
  background: var(--gold);
  color: var(--ink-strong);
}
.btn-gold:hover { background: #d4b358; }

.btn-ghost {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.65);
}
.btn-ghost:hover { background: rgba(255,255,255,0.12); }

.btn-coral { background: var(--coral); color: #fff; }
.btn-coral:hover { background: #c0553f; }

/* ── Add row button ────────────────────────────────────────────────────── */
.add-row-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border-light);
  color: var(--gold);
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background var(--t) var(--ease);
  letter-spacing: 0.01em;
}
.add-row-btn:hover { background: var(--gold-tint); }

/* ── Toggle switch ─────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 34px; height: 19px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--t) var(--ease);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 13px; width: 13px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t) var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(15px); }

/* ── Category separator rows ───────────────────────────────────────────── */
.cat-sep-row td {
  padding: 7px 16px 7px 14px;
  background: linear-gradient(to right, var(--slate-light) 3px, var(--cream) 3px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.cat-sep-chevron {
  display: inline-block;
  margin-right: 6px;
  font-size: 10px;
  color: var(--slate-light);
  transition: transform 0.18s ease;
  transform-origin: center;
}
.cat-sep-row.collapsed .cat-sep-chevron {
  transform: rotate(-90deg);
}
.cat-sep-row td:first-child { border-left: none; }
.cat-sep-row:hover td {
  background: linear-gradient(to right, var(--slate-light) 3px, var(--cream) 3px);
}
.cat-sep-name {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: capitalize;
  color: var(--slate-light);
}
.cat-sep-amt {
  float: right;
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--slate-light);
}
.cat-sep-toggle {
  float: right;
  margin-right: 14px;
  margin-top: -1px;
  vertical-align: middle;
}

.cat-sep-row[data-cat="housing"] td       { background: linear-gradient(to right, #4299e1 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="utilities"] td     { background: linear-gradient(to right, #ecc94b 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="subscriptions"] td { background: linear-gradient(to right, #9f7aea 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="debt"] td          { background: linear-gradient(to right, var(--coral) 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="insurance"] td     { background: linear-gradient(to right, #48bb78 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="bills"] td         { background: linear-gradient(to right, #4299e1 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="giving"] td        { background: linear-gradient(to right, #48bb78 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="flex"] td          { background: linear-gradient(to right, var(--gold) 3px, var(--cream) 3px); }
.cat-sep-row[data-cat="savings"] td       { background: linear-gradient(to right, #9f7aea 3px, var(--cream) 3px); }
.cat-sep-row:hover td { filter: none; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.budget-link-badge {
  display: inline-block;
  padding: 1px 6px;
  background: var(--gold-tint);
  color: var(--gold-dark);
  border: 1px solid rgba(201,168,76,0.25);
  font-size: 10px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  font-family: 'DM Sans', sans-serif;
}
.expired-badge {
  display: inline-block;
  padding: 1px 6px;
  background: var(--coral-light);
  color: var(--coral);
  font-size: 10px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.spent-detail {
  font-size: 10px;
  color: var(--slate-faint);
  margin-top: 2px;
}
.expired-row td { opacity: 0.5; }
.end-date-cell { font-size: 12px; color: var(--slate-faint); }

/* ── Details / collapsible ─────────────────────────────────────────────── */
details {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
details summary {
  padding: 13px 16px;
  cursor: pointer;
  background: var(--cream);
  font-size: 13px; font-weight: 500;
  color: var(--ink-strong);
  list-style: none;
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '›';
  color: var(--slate-faint);
  font-size: 18px;
  transition: transform var(--t) var(--ease);
}
details[open] summary::after { transform: rotate(90deg); }

/* ── Timeline (Upcoming) ───────────────────────────────────────────────── */
.timeline-month {
  margin-bottom: 28px;
  animation: fadeIn 220ms var(--ease) both;
}
.timeline-month-label {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 15px; font-weight: 600;
  color: var(--ink-strong);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.timeline-item {
  display: flex; align-items: center;
  gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}
.timeline-item:last-child { border-bottom: none; }
.date-badge {
  flex-shrink: 0;
  width: 46px; text-align: center;
  background: var(--navy);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
}
.date-badge-day {
  font-family: 'DM Mono', monospace;
  font-size: 17px; font-weight: 500;
  color: var(--gold); line-height: 1;
}
.date-badge-month {
  font-size: 9px; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4); margin-top: 3px;
}
.timeline-item-body { flex: 1; min-width: 0; }
.timeline-item-name {
  font-size: 14px; font-weight: 500;
  color: var(--text); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.timeline-item-meta { font-size: 12px; color: var(--slate-faint); }
.timeline-item-amount {
  font-family: 'DM Mono', monospace;
  font-size: 14px; font-weight: 500;
  color: var(--coral); flex-shrink: 0;
}
.timeline-item.paid .timeline-item-name { text-decoration: line-through; color: var(--slate-faint); }
.timeline-item.paid .timeline-item-amount { color: var(--slate-faint); }

.btn-mark-paid {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px; color: var(--slate);
  cursor: pointer;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  transition: all var(--t) var(--ease);
  flex-shrink: 0;
}
.btn-mark-paid:hover { border-color: var(--gold); color: var(--gold-dark); }
.timeline-item.paid .btn-mark-paid { opacity: 0.4; cursor: default; }

.timeline-item.editing {
  flex-wrap: wrap;
  align-items: flex-start;
}
.timeline-edit-wrap {
  width: 100%;
  background: var(--navy);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 4px 0;
}
.timeline-edit-wrap form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}

/* ── Projection ────────────────────────────────────────────────────────── */
.projection-table td:last-child.positive-bal {
  background: rgba(201,168,76,0.07); color: var(--gold-dark);
  font-family: 'DM Mono', monospace; font-weight: 500;
}
.projection-table td:last-child.negative-bal {
  background: var(--coral-tint); color: var(--coral);
  font-family: 'DM Mono', monospace; font-weight: 500;
}
.projection-table tr.highlighted > td { background: var(--gold-tint) !important; }

.projection-controls {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 12px; margin-bottom: 20px;
  font-size: 13px; color: var(--slate);
}
.months-selector { display: flex; gap: 5px; }
.months-btn {
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; color: var(--slate);
  cursor: pointer;
  transition: all var(--t) var(--ease);
}
.months-btn.active, .months-btn:hover {
  border-color: var(--gold); color: var(--gold-dark);
  background: var(--gold-tint);
}

/* ── Balance strip ─────────────────────────────────────────────────────── */
.balance-strip {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.balance-strip-month {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 20px; color: var(--ink-strong); font-weight: 600;
}
.balance-edit-wrap {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; font-size: 13px; color: var(--slate-faint);
}
.balance-display {
  font-family: 'DM Mono', monospace;
  font-size: 14px; color: var(--gold-dark);
  cursor: pointer;
  border-bottom: 1px dashed var(--gold);
  padding-bottom: 1px;
  transition: color var(--t) var(--ease);
}
.balance-display:hover { color: var(--gold); }
.balance-input {
  font-family: 'DM Mono', monospace;
  font-size: 14px; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none; padding: 4px 8px;
  transition: border-color var(--t) var(--ease);
}
.balance-input:focus { border-color: var(--gold); }

/* ── Upcoming on dashboard ─────────────────────────────────────────────── */
.upcoming-list { margin-bottom: 0; }
.upcoming-row {
  display: flex; align-items: center;
  gap: 14px; padding: 11px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.upcoming-row:last-child { border-bottom: none; }
.upcoming-date {
  font-family: 'DM Mono', monospace;
  color: var(--slate-faint); flex-shrink: 0; width: 72px; font-size: 12px;
}
.upcoming-name { flex: 1; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-amount { font-family: 'DM Mono', monospace; color: var(--coral); flex-shrink: 0; font-size: 13px; }

/* ── Action buttons ────────────────────────────────────────────────────── */
.action-btns { display: flex; gap: 5px; opacity: 0; transition: opacity var(--t) var(--ease); }
tr:hover .action-btns { opacity: 1; }
.action-btn {
  padding: 3px 9px; border-radius: 4px;
  font-size: 11px; border: 1px solid var(--border);
  background: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all var(--t) var(--ease); color: var(--slate);
}
.action-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
.action-btn.delete:hover { border-color: var(--coral); color: var(--coral); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 52px 32px;
  color: var(--slate-faint);
  animation: fadeIn 220ms var(--ease) both;
}
.empty-state-icon { font-size: 28px; margin-bottom: 14px; color: var(--border); }
.empty-state-title {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 17px; color: var(--slate);
  margin-bottom: 7px;
}
.empty-state-desc {
  font-size: 13px; line-height: 1.65;
  max-width: 280px; margin: 0 auto;
  color: var(--slate-faint);
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex;
  flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-weight: 500;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn 200ms var(--ease) both;
  pointer-events: auto;
  max-width: 300px;
}
.toast.success { border-left: 3px solid var(--gold); }
.toast.error   { border-left: 3px solid var(--coral); }
.toast.fade-out { animation: toastOut 200ms var(--ease) both; }

/* ── Loading ───────────────────────────────────────────────────────────── */
.loading-state {
  padding: 80px 32px; text-align: center;
  color: var(--slate-faint); font-size: 13px;
  font-family: 'DM Mono', monospace; letter-spacing: 0.05em;
}

/* ── Editing row ───────────────────────────────────────────────────────── */
.editing-row td { padding: 8px 6px; background: var(--gold-tint); }
.editing-row td input, .editing-row td select {
  background: var(--surface); border: 1px solid var(--gold);
  border-radius: 4px; padding: 4px 8px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; color: var(--text); width: 100%;
}

/* ── Budgets ───────────────────────────────────────────────────────────── */
.ready-to-assign-strip {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
  gap: 16px; margin-bottom: 28px;
  padding: 24px 28px;
  background: var(--navy);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeIn 220ms var(--ease) both;
}
.rta-label {
  font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255,255,255,0.38);
  margin-bottom: 6px; font-weight: 500;
}
.rta-amount {
  font-family: 'DM Mono', monospace;
  font-size: 32px; font-weight: 500; line-height: 1;
  letter-spacing: -0.02em;
}
.rta-amount.positive { color: var(--gold); }
.rta-amount.negative { color: var(--coral); }
.rta-meta { display: flex; gap: 24px; flex-wrap: wrap; }
.rta-meta-item { text-align: right; }
.rta-meta-label {
  font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.28);
  margin-bottom: 4px;
}
.rta-meta-value {
  font-family: 'DM Mono', monospace;
  font-size: 14px; color: rgba(255,255,255,0.65);
}
.budget-month-nav {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.month-nav-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 5px 12px;
  font-size: 15px; color: var(--slate); cursor: pointer; line-height: 1;
  transition: all var(--t) var(--ease); box-shadow: var(--shadow-sm);
}
.month-nav-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
.cal-today-btn {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  color: var(--gold-dark);
  border-color: var(--gold);
  background: var(--gold-tint);
  margin-left: 2px;
}
.cal-today-btn:hover { background: var(--gold); color: #fff; }
.month-nav-label {
  font-family: 'Playfair Display', 'Noto Serif KR', serif;
  font-size: 17px; font-weight: 600; color: var(--ink-strong);
  min-width: 130px; text-align: center;
}
.budget-group { margin-bottom: 16px; }
.budget-group-header {
  padding: 10px 16px; background: var(--cream);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.budget-group-name {
  font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--slate-faint); font-weight: 700;
}
.budget-group-total { font-family: 'DM Mono', monospace; font-size: 12px; }
.budget-group[data-cat="bills"]   { border-left: 3px solid #4299e1; }
.budget-group[data-cat="giving"]  { border-left: 3px solid #48bb78; }
.budget-group[data-cat="flex"]    { border-left: 3px solid var(--gold); }
.budget-group[data-cat="savings"] { border-left: 3px solid #9f7aea; }
.budget-group[data-cat="other"]   { border-left: 3px solid var(--slate-faint); }
tr.inactive-budget td:not(:nth-last-child(1)):not(:nth-last-child(2)) { opacity: 0.35; }
tr.inactive-budget:hover { background: none; }
tr.inactive-budget:hover td:first-child { border-left-color: transparent; }
td.avail-positive { color: var(--gold-dark); font-family: 'DM Mono', monospace; font-weight: 500; }
td.avail-zero     { color: var(--slate-faint); font-family: 'DM Mono', monospace; }
td.avail-negative { color: var(--coral); font-family: 'DM Mono', monospace; font-weight: 500; background: var(--coral-tint); }
.budget-bar { height: 2px; background: var(--border); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.budget-bar-fill { height: 100%; border-radius: 2px; background: var(--gold); transition: width 500ms var(--ease); }
.budget-bar-fill.overspent { background: var(--coral); }

/* ── Calendar ───────────────────────────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 40px;
  overflow: hidden;
}
.cal-day-header {
  background: var(--cream);
  padding: 8px 4px;
  font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--slate-faint);
  text-align: center;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-weight: 600;
}
.cal-cell {
  background: var(--surface);
  min-height: 108px; padding: 7px 6px 20px;
  position: relative; cursor: default;
}
.cal-cell.empty   { background: var(--cream); pointer-events: none; }
.cal-cell.today   { background: rgba(201,168,76,0.04); box-shadow: inset 2px 0 0 var(--navy); }
.cal-cell:hover   { background: var(--gold-tint); }
.cal-day-num {
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--slate-faint);
  text-align: right; margin-bottom: 5px;
}
.cal-cell.today .cal-day-num { color: var(--ink-strong); font-weight: 700; }
.cal-event {
  display: block; padding: 2px 5px;
  border-radius: 4px; font-size: 10px;
  margin-bottom: 2px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  transition: opacity var(--t) var(--ease); position: relative;
}
.cal-event:hover { opacity: 0.8; }
.cal-event.income  { background: var(--gold-light); color: #7a5000; }
.cal-event.expense { background: var(--coral-light); color: #9b3a2e; }
.cal-event.upcoming {
  background: var(--cream-dark); color: var(--slate);
  border: 1px solid var(--border);
}
.cal-day-balance {
  position: absolute; bottom: 4px; right: 5px;
  font-family: 'DM Mono', monospace; font-size: 9px; line-height: 1;
}
.cal-add-btn {
  position: absolute; bottom: 3px; left: 4px;
  font-size: 11px; color: var(--slate-faint);
  background: none; border: none; cursor: pointer;
  opacity: 0; transition: opacity var(--t) var(--ease);
  line-height: 1; padding: 1px 3px;
}
.cal-cell:hover .cal-add-btn { opacity: 1; }

/* Mobile agenda view — swapped in for .calendar-grid under the mobile
   breakpoint, since a 7-column grid has no room to work with at phone
   widths (it was clipping Thu/Fri/Sat off-screen entirely). Reuses
   .cal-cell/.cal-event/.cal-add-btn so the existing click handlers and
   popover/add-form logic (which key off those classes) work unchanged. */
.cal-agenda {
  display: none;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 40px;
  background: var(--surface);
}
.cal-agenda-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  min-height: unset;
}
/* .cal-add-form is appended as a normal child of the row (see openAddForm in
   app.js) — force it onto its own full-width line instead of squeezing in
   as another flex item next to the date/pills/button. */
.cal-agenda-row .cal-add-form {
  flex: 1 0 100%;
  margin: 10px -14px -12px;
  width: auto;
}
.cal-agenda-row:last-child { border-bottom: none; }
.cal-agenda-row.today { background: rgba(201,168,76,0.06); box-shadow: inset 2px 0 0 var(--navy); }
.cal-agenda-date {
  flex: 0 0 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2px;
}
.cal-agenda-dow {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--slate-faint);
  font-weight: 600;
}
.cal-agenda-row.today .cal-agenda-dow { color: var(--gold-dark); }
.cal-agenda-date .cal-day-num {
  font-size: 17px;
  text-align: center;
  margin-bottom: 0;
}
.cal-agenda-row.today .cal-day-num { color: var(--ink-strong); font-weight: 700; }
.cal-agenda-body {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-width: 0;
  padding-top: 3px;
}
.cal-agenda-body .cal-event { white-space: normal; max-width: 100%; }
.cal-agenda-empty { color: var(--slate-faint); font-size: 12px; }
.cal-agenda-row .cal-day-balance {
  position: static;
  font-size: 11px;
  flex: 0 0 auto;
  align-self: center;
  padding-left: 4px;
  white-space: nowrap;
}
.cal-agenda-row .cal-add-btn {
  position: static;
  opacity: 1;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gold-tint);
  color: var(--gold-dark);
  font-size: 15px;
  margin-left: 4px;
}
.cal-agenda-row .cal-add-btn:hover { background: var(--gold); color: #fff; }

.cal-popover {
  position: absolute; z-index: 200;
  background: var(--navy);
  border-radius: var(--radius-sm);
  padding: 14px; min-width: 260px;
  box-shadow: var(--shadow-lg);
  animation: slideDown 120ms var(--ease) both;
  top: calc(100% + 4px); left: 0;
}
.cal-cell:nth-child(7n) .cal-popover,
.cal-cell:nth-child(7n-1) .cal-popover { left: auto; right: 0; }
.cal-add-form {
  background: var(--navy);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

/* ── 10-Day Forecast ───────────────────────────────────────────────────── */
.forecast-section { margin-top: 24px; margin-bottom: 32px; animation: fadeIn 220ms 160ms var(--ease) both; }
.forecast-rows {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 480px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  scroll-behavior: smooth;
}
.forecast-rows::-webkit-scrollbar { width: 4px; }
.forecast-rows::-webkit-scrollbar-track { background: transparent; }
.forecast-rows::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.forecast-row {
  display: grid;
  grid-template-columns: 88px 1fr 110px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  align-items: start; gap: 12px;
}
.forecast-row:last-child { border-bottom: none; }
.forecast-row.has-events { background: var(--surface); }
.forecast-row:not(.has-events) { background: var(--cream); opacity: 0.5; }
.forecast-date { display: flex; flex-direction: column; padding-top: 2px; }
.forecast-weekday {
  font-family: 'DM Mono', monospace; font-size: 9px;
  text-transform: uppercase; color: var(--slate-faint); letter-spacing: .08em;
}
.forecast-day { font-size: 12px; color: var(--slate); font-weight: 500; margin-top: 1px; }
.forecast-events { display: flex; flex-direction: column; gap: 3px; }
.forecast-pill { font-size: 11px; font-family: 'DM Sans', 'Nanum Gothic', sans-serif; }
.forecast-pill.income  { color: #7a5000; }
.forecast-pill.expense { color: #9b3a2e; }
.forecast-pill.upcoming { color: var(--slate); }
.forecast-empty { font-size: 11px; color: var(--border); }
.forecast-balance {
  font-family: 'DM Mono', monospace; font-size: 11px;
  text-align: right; align-self: center; font-weight: 500;
}
.forecast-balance.positive { color: var(--gold-dark); }
.forecast-balance.negative { color: var(--coral); }

/* ── Table-layout fixed (matching column widths) ───────────────────────── */
.table-income    { table-layout: fixed; width: 100%; }
.table-recurring { table-layout: fixed; width: 100%; }
.table-budgets   { table-layout: fixed; width: 100%; }
.table-projection { table-layout: fixed; width: 100%; }

.table-income th:nth-child(1), .table-income td:nth-child(1) { width: 28%; }
.table-income th:nth-child(2), .table-income td:nth-child(2) { width: 12%; }
.table-income th:nth-child(3), .table-income td:nth-child(3) { width: 15%; }
.table-income th:nth-child(4), .table-income td:nth-child(4) { width: 14%; }
.table-income th:nth-child(5), .table-income td:nth-child(5) { width: 9%; }
.table-income th:nth-child(6), .table-income td:nth-child(6) { width: 8%; }
.table-income th:last-child,   .table-income td:last-child   { width: 14%; }

/* Freelance / one-time income table */
#freelance-table th:nth-child(1), #freelance-table td:nth-child(1) { width: 26%; }
#freelance-table th:nth-child(2), #freelance-table td:nth-child(2) { width: 13%; }
#freelance-table th:nth-child(3), #freelance-table td:nth-child(3) { width: 12%; }
#freelance-table th:nth-child(4), #freelance-table td:nth-child(4) { width: 28%; }
#freelance-table th:nth-child(5), #freelance-table td:nth-child(5) { width: 10%; }
#freelance-table th:last-child,   #freelance-table td:last-child   { width: 11%; }
.freelance-row.received td { opacity: 0.45; text-decoration: line-through; }
.freelance-row.received td:nth-child(5) { text-decoration: none; opacity: 1; }
.freelance-pending-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gold-tint);
  color: var(--gold-dark);
  font-size: 11px;
  font-weight: 600;
}

.table-recurring th:nth-child(1), .table-recurring td:nth-child(1) { width: 22%; }
.table-recurring th:nth-child(2), .table-recurring td:nth-child(2) { width: 10%; }
.table-recurring th:nth-child(3), .table-recurring td:nth-child(3) { width: 13%; }
.table-recurring th:nth-child(4), .table-recurring td:nth-child(4) { width: 12%; }
.table-recurring th:nth-child(5), .table-recurring td:nth-child(5) { width: 9%; }
.table-recurring th:nth-child(6), .table-recurring td:nth-child(6) { width: 10%; }
.table-recurring th:nth-child(7), .table-recurring td:nth-child(7) { width: 8%; }
.table-recurring th:last-child,   .table-recurring td:last-child   { width: 16%; }

.table-budgets th:nth-child(1), .table-budgets td:nth-child(1) { width: 26%; }
.table-budgets th:nth-child(2), .table-budgets td:nth-child(2) { width: 10%; }
.table-budgets th:nth-child(3), .table-budgets td:nth-child(3) { width: 14%; }
.table-budgets th:nth-child(4), .table-budgets td:nth-child(4) { width: 14%; }
.table-budgets th:nth-child(5), .table-budgets td:nth-child(5) { width: 14%; }
.table-budgets th:nth-child(6), .table-budgets td:nth-child(6) { width: 8%; }
.table-budgets th:last-child,   .table-budgets td:last-child   { width: 14%; }

.table-projection th:nth-child(1), .table-projection td:nth-child(1) { width: 14%; }
.table-projection th:nth-child(2), .table-projection td:nth-child(2) { width: 17%; }
.table-projection th:nth-child(3), .table-projection td:nth-child(3) { width: 18%; }
.table-projection th:nth-child(4), .table-projection td:nth-child(4) { width: 15%; }
.table-projection th:nth-child(5), .table-projection td:nth-child(5) { width: 13%; }
.table-projection th:last-child,   .table-projection td:last-child   { width: 23%; }

.table-budget-proj { table-layout: fixed; width: 100%; }
.table-budget-proj th:nth-child(1), .table-budget-proj td:nth-child(1) { width: 18%; }
.table-budget-proj th:nth-child(2), .table-budget-proj td:nth-child(2) { width: 20%; }
.table-budget-proj th:nth-child(3), .table-budget-proj td:nth-child(3) { width: 20%; }
.table-budget-proj th:nth-child(4), .table-budget-proj td:nth-child(4) { width: 16%; }
.table-budget-proj th:last-child,   .table-budget-proj td:last-child   { width: 26%; }

/* ── Animations ────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main-content { padding: 40px 32px 64px; }
  .rta-meta { gap: 16px; }
}

@media (max-width: 768px) {
  /* Show mobile chrome */
  .mobile-header { display: flex; }
  .bottom-nav    { display: flex; }

  /* Hide desktop sidebar trigger */
  body > .hamburger { display: none; }

  /* Sidebar becomes drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 99;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }

  /* iOS Safari auto-zooms the page on focusing any form control whose
     effective font-size is under 16px — every input/select in this app is
     smaller than that. Force a 16px floor so focusing a field never
     triggers the zoom (the fields themselves keep their own layout/width;
     only the text size changes). */
  input, select, textarea { font-size: 16px !important; }

  /* Content area */
  .main-content {
    margin-left: 0;
    padding: 16px 16px calc(var(--bottom-nav-h) + 16px + env(safe-area-inset-bottom));
    padding-top: calc(52px + env(safe-area-inset-top) + 16px);
    max-width: 100%;
  }

  /* Toast above bottom nav */
  #toast-container { bottom: calc(var(--bottom-nav-h) + 12px + env(safe-area-inset-bottom)); right: 16px; }

  /* Page header */
  .page-title { font-size: 24px; }
  .page-header { margin-bottom: 24px; }

  /* Stat row: 2-col on mobile */
  .stat-row { grid-template-columns: 1fr 1fr; }
  .stat-block:nth-child(2) { border-right: none; }
  .stat-block:nth-child(3) { grid-column: 1 / -1; border-right: none; border-top: 1px solid var(--border-light); }
  .stat-value { font-size: 22px; }

  /* Chart */
  .chart-wrap { padding: 16px 12px; margin-bottom: 24px; }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
  table { min-width: 560px; }
  .table-income, .table-recurring, .table-budgets, .table-projection, .table-budget-proj {
    table-layout: auto;
  }

  /* Inline form: stacked on mobile */
  .inline-form-row form { flex-direction: column; gap: 8px; }
  .form-field { width: 100%; }
  .form-field input, .form-field select { width: 100% !important; min-width: unset; }

  /* Calendar — swap the 7-col grid (no room at phone widths) for a
     vertical agenda list; see .cal-agenda rules above. */
  .calendar-grid { display: none; }
  .cal-agenda { display: flex; }
  .cal-popover, .cal-add-form { min-width: unset; width: 100%; }

  /* Balance strip */
  .balance-strip { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Projection controls */
  .projection-controls { gap: 8px; }

  /* Budget strip */
  .ready-to-assign-strip { flex-direction: column; align-items: flex-start; gap: 12px; }
  .rta-amount { font-size: 28px; }
  .rta-meta { gap: 20px; }

  /* Timeline */
  .timeline-item { gap: 10px; }
  .timeline-item-name { font-size: 13px; }
  .timeline-item-amount { font-size: 13px; }

  /* Forecast */
  .forecast-row { grid-template-columns: 70px 1fr 90px; padding: 8px 12px; gap: 8px; }
  .forecast-rows { max-height: 360px; }

  /* Free cash flow strip */
  .fcf-strip { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .fcf-divider { display: none; }
  .fcf-item { flex: 0 0 calc(50% - 6px); }
  .fcf-item.fcf-result { flex: 0 0 100%; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px; }
  .fcf-result .fcf-value { font-size: 22px; }

  /* Section title */
  .section-title { font-size: 15px; }
}

@media (max-width: 400px) {
  .stat-row { grid-template-columns: 1fr; }
  .stat-block:nth-child(2) { border-top: 1px solid var(--border-light); border-right: none; }
  .stat-block:nth-child(3) { grid-column: auto; }
  .rta-meta { flex-direction: column; gap: 8px; }
  .rta-meta-item { text-align: left; }
}

/* ── Nav section labels ─────────────────────────────────────────────────── */
.nav-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  padding: 14px 18px 4px; margin-top: 4px;
}

/* ── Tasks page ─────────────────────────────────────────────────────────── */
.task-add-wrap { margin-bottom: 24px; }

.todo-quick-form {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.todo-input {
  flex: 1; min-width: 180px;
  border: none; border-bottom: 1px solid var(--border);
  background: transparent; font-family: 'DM Sans','Nanum Gothic',sans-serif;
  font-size: 14px; color: var(--text); padding: 4px 0; outline: none;
}
.todo-input:focus { border-bottom-color: var(--gold); }
.todo-date-input, .todo-priority-select, .todo-cat-input {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--cream); font-family: 'DM Sans','Nanum Gothic',sans-serif;
  font-size: 13px; color: var(--slate); padding: 5px 8px; outline: none;
}
.todo-date-input:focus, .todo-priority-select:focus, .todo-cat-input:focus {
  border-color: var(--gold);
}
.todo-cat-input { width: 120px; }

.task-group { margin-bottom: 20px; }
.task-group-header {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--slate-light);
  padding: 0 4px 8px; display: flex; align-items: center; gap: 8px;
}
.group-overdue .task-group-header { color: var(--coral); }
.group-today   .task-group-header { color: var(--gold-dark); }
.task-group-count {
  background: var(--border); color: var(--slate);
  border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 600;
}
.group-overdue .task-group-count { background: #fde8e4; color: var(--coral); }
.group-today   .task-group-count { background: #fdf3d8; color: var(--gold-dark); }

.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); border-left-width: 3px;
  padding: 12px 14px; margin-bottom: 6px;
  transition: box-shadow var(--t) var(--ease);
}
.task-item:hover { box-shadow: var(--shadow); }
.priority-high   { border-left-color: var(--coral); }
.priority-medium { border-left-color: var(--gold); }
.priority-low    { border-left-color: var(--border); }

.task-item.task-done { opacity: 0.45; }
.task-item.task-done .task-title { text-decoration: line-through; }
.task-item.task-overdue { background: #fff8f7; }

.task-check {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 50%;
  background: transparent; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  font-size: 11px; color: var(--gold-dark); font-weight: 700;
  transition: all var(--t) var(--ease);
}
.task-check:hover { border-color: var(--gold); background: var(--gold-tint); }
.task-done .task-check { background: var(--gold-tint); border-color: var(--gold); }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.4; }
.task-desc  { font-size: 12px; color: var(--slate-light); margin-top: 2px; }
.task-meta  { display: flex; gap: 8px; margin-top: 5px; flex-wrap: wrap; align-items: center; }
.task-cat   {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  background: var(--cream); color: var(--slate); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 6px; text-transform: uppercase;
}
.task-due   { font-family: 'DM Mono',monospace; font-size: 11px; color: var(--slate-light); }
.task-due.overdue { color: var(--coral); font-weight: 600; }

.task-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.task-priority {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 3px;
}
.task-priority.priority-high   { background: #fde8e4; color: var(--coral); }
.task-priority.priority-medium { background: #fdf3d8; color: var(--gold-dark); }
.task-priority.priority-low    { background: var(--cream); color: var(--slate-light); }
.task-delete {
  width: 20px; height: 20px; border: none; background: transparent;
  color: var(--border); cursor: pointer; font-size: 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t) var(--ease);
}
.task-delete:hover { background: #fde8e4; color: var(--coral); }

.task-done-section { margin-top: 32px; }
.task-done-section summary {
  font-size: 12px; color: var(--slate-light); cursor: pointer; padding: 8px 0;
}

/* ── Grocery page ───────────────────────────────────────────────────────── */
.grocery-group { margin-bottom: 20px; }
.grocery-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--slate-light);
  padding: 0 4px 8px;
}
.grocery-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 5px;
  transition: opacity var(--t);
}
.grocery-item.grocery-checked { opacity: 0.4; }
.grocery-item.grocery-checked .grocery-name { text-decoration: line-through; }
.grocery-name { flex: 1; font-size: 14px; color: var(--text); }
.grocery-qty  { font-size: 12px; color: var(--slate-light); font-family: 'DM Mono',monospace; flex-shrink: 0; }
.grocery-checked-section { margin-top: 24px; }
.grocery-checked-section summary {
  font-size: 12px; color: var(--slate-light); cursor: pointer; padding: 8px 0;
  display: flex; align-items: center;
}

/* ── Calendar appointment pill ──────────────────────────────────────────── */
.cal-event.appointment { color: #5a4fcf; }

/* ── Tasks/Grocery mobile ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .todo-quick-form { gap: 6px; padding: 10px 12px; }
  .todo-input { font-size: 15px; min-width: 100%; }
  .todo-date-input, .todo-priority-select, .todo-cat-input { font-size: 13px; }
  .task-item { padding: 10px 12px; gap: 10px; }
  .task-title { font-size: 14px; }
}

/* ── Budget Tracker ─────────────────────────────────────────────────────── */
.bt-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.bt-summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.bt-over  { border-color: rgba(239,71,111,.35); }
.bt-under { border-color: rgba(6,214,160,.3); }
.bt-summary-val {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.bt-over .bt-summary-val  { color: #ef476f; }
.bt-under .bt-summary-val { color: #06d6a0; }
.bt-summary-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-light);
  margin-top: 4px;
}
.bt-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate);
  margin: 24px 0 10px;
  font-weight: 600;
}
.bt-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}
.bt-grid-fixed { grid-template-columns: repeat(3, 1fr); }

.bt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  user-select: none;
}
.bt-card:hover  { border-color: var(--gold); transform: translateY(-1px); }
.bt-card-over   { border-color: rgba(239,71,111,.4); }
.bt-card-over:hover { border-color: #ef476f; }

.bt-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.bt-cat-icon  { font-size: 16px; flex-shrink: 0; }
.bt-cat-name  { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.bt-txn-count { font-size: 10px; color: var(--slate); background: var(--border); border-radius: 10px; padding: 2px 7px; flex-shrink: 0; }

.bt-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.bt-bar { height: 100%; border-radius: 3px; transition: width .4s ease; min-width: 2px; }

.bt-card-amounts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  margin-bottom: 4px;
}
.bt-actual {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.bt-over-text  { color: #ef476f !important; }
.bt-under-text { color: #06d6a0 !important; }
.bt-budget-label { font-size: 11px; color: var(--slate); white-space: nowrap; }
.bt-delta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.bt-delta-over   { color: #ef476f; }
.bt-delta-under  { color: #06d6a0; }

/* Modal */
.bt-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
}
.bt-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.bt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bt-modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.bt-modal-meta  { font-size: 13px; color: var(--slate-light); }
.bt-modal-close {
  background: none;
  border: none;
  color: var(--slate);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.bt-modal-close:hover { background: var(--border); color: var(--text); }

.bt-modal-sort {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.bt-sort-label { font-size: 12px; color: var(--slate); margin-right: 4px; }
.bt-sort-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  transition: all .15s;
}
.bt-sort-btn:hover { border-color: var(--gold); color: var(--text); }
.bt-sort-btn.active { background: var(--gold); border-color: var(--gold); color: #fff; }
.bt-sort-dir-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--slate-light);
  cursor: pointer;
  margin-left: auto;
}
.bt-sort-dir-btn:hover { border-color: var(--gold); color: var(--text); }

.bt-modal-body { overflow-y: auto; flex: 1; padding: 0 4px; }
.bt-modal-empty { padding: 40px 20px; text-align: center; color: var(--slate); font-size: 14px; }

.bt-txn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bt-txn-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}
.bt-txn-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.bt-txn-table tbody tr:hover { background: var(--bg); }
.bt-txn-table tbody tr:last-child { border-bottom: none; }
.bt-txn-table td { padding: 10px 16px; }
.bt-txn-date     { color: var(--slate-light); font-family: 'DM Mono', monospace; font-size: 12px; white-space: nowrap; }
.bt-txn-merchant { color: var(--text); }
.bt-txn-amount   { font-family: 'DM Mono', monospace; font-weight: 600; color: var(--text); white-space: nowrap; }
.ta-right        { text-align: right; }

.bt-modal-footer {
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  flex-shrink: 0;
}
.bt-modal-totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--slate);
}
.bt-modal-total-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bt-modal-total-label { color: var(--slate); }
.bt-modal-total-val {
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.bt-modal-budget-label { color: var(--slate); font-size: 11px; }
.bt-modal-delta {
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 768px) {
  .bt-summary-strip   { grid-template-columns: 1fr 1fr; }
  .bt-grid            { grid-template-columns: 1fr 1fr; }
  .bt-grid-fixed      { grid-template-columns: 1fr 1fr; }
  .bt-modal-overlay   { padding: 12px; align-items: flex-end; }
  .bt-modal           { max-height: 85vh; border-radius: 16px 16px 0 0; }
}

/* ── Medical Claims ─────────────────────────────────────────────────────── */
.claims-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.claims-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.claims-stat-outstanding { border-color: rgba(239,71,111,.35); }
.claims-stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.claims-stat-outstanding .claims-stat-value { color: #ef476f; }
.claims-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-light);
  margin-top: 4px;
}
.claims-add-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.claims-list { display: flex; flex-direction: column; gap: 12px; }

.claim-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}
.claim-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 12px;
}
.claim-provider-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.claim-provider { font-size: 15px; font-weight: 600; color: var(--text); }
.claim-amount-wrap { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.claim-amount {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.claim-reimbursed-amt {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  color: #06d6a0;
}

.claim-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
}
.claim-pending    { background: rgba(255,209,102,.15); color: #ffd166; }
.claim-submitted  { background: rgba(69,123,157,.2);   color: #6db8e0; }
.claim-approved   { background: rgba(6,214,160,.15);   color: #06d6a0; }
.claim-reimbursed { background: rgba(6,214,160,.25);   color: #06d6a0; border: 1px solid rgba(6,214,160,.4); }
.claim-denied     { background: rgba(239,71,111,.15);  color: #ef476f; }

.claim-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 12px;
}
.claim-meta-item { font-size: 12px; color: var(--slate-light); }
.claim-notes { font-style: italic; }

.claim-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
/* .btn-ghost is designed for dark surfaces (translucent white on navy) —
   on .claim-card's light background it renders near-invisible (white text
   on a 7%-white tint). Override for legibility in this light context. */
.claim-card-actions .btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--slate);
}
.claim-card-actions .btn-ghost:hover {
  background: var(--cream);
  border-color: var(--gold);
  color: var(--gold-dark);
}
.claim-status-select {
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

.reimburse-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(6,214,160,.06);
  border: 1px solid rgba(6,214,160,.2);
  border-radius: 8px;
}
.reimburse-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  width: 160px;
}

.claim-form-card {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.claim-form-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
}
.claim-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-bottom: 16px;
}
.claim-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate-light);
}
.claim-form-actions { display: flex; gap: 10px; }
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--text);
  font-family: 'DM Sans', 'Nanum Gothic', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color var(--t) var(--ease);
}
.input:focus { border-color: var(--gold); background: var(--surface); }

.btn-sm { font-size: 12px; padding: 4px 12px; }
.btn-danger {
  background: rgba(239,71,111,.15);
  color: #ef476f;
  border: 1px solid rgba(239,71,111,.3);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(239,71,111,.25); }

@media (max-width: 768px) {
  .claims-summary-strip { grid-template-columns: 1fr 1fr; }
  .claim-form-grid { grid-template-columns: 1fr; }
}

/* ── Insights ───────────────────────────────────────────────────────────── */
.insights-housing-callout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(67,97,238,.08);
  border: 1px solid rgba(67,97,238,.25);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-light);
}
.insights-housing-icon { font-size: 14px; flex-shrink: 0; }
.insights-housing-callout > span:nth-child(2) { flex: 1; }
.insights-housing-amt {
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  color: #4361ee;
  font-size: 13px;
}
.insights-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}
.insights-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.insights-stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  line-height: 1.1;
}
.insights-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-light);
  margin-top: 4px;
}
.insights-stat-sub {
  font-size: 11px;
  color: var(--slate);
  margin-top: 2px;
}
.insights-charts-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  margin-bottom: 32px;
}
.insights-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.insights-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.insights-housing-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .03em;
  text-transform: none;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-light);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.insights-housing-chip:hover { border-color: var(--border-focus); color: var(--text); }
.insights-housing-chip.active { background: var(--gold-tint); border-color: var(--gold); color: var(--gold-dark); }
.insights-donut-wrap {
  width: 180px;
  height: 180px;
  margin: 0 auto 16px;
}
.insights-bar-wrap {
  height: 200px;
  margin-bottom: 12px;
}
.insights-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.insights-bar-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}
.insights-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
}
.insights-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.insights-legend-name { flex: 1; }
.insights-legend-amt  { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--slate-light); }
.insights-legend-note {
  font-size: 10px;
  color: var(--slate);
  margin-top: 6px;
  font-style: italic;
}

.insights-legend-item--clickable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: 0 -4px;
  transition: background .12s;
}
.insights-legend-item--clickable:hover { background: rgba(128,128,128,.1); }
.insights-legend-item--clickable:hover .insights-legend-hide { opacity: 1; }
.insights-legend-hide {
  font-size: 9px;
  opacity: 0;
  color: var(--slate);
  margin-left: 2px;
  transition: opacity .12s;
  flex-shrink: 0;
}

/* Excluded categories panel */
.insights-excluded-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.insights-excl-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.insights-excl-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  border-radius: 20px;
  border: 1.5px solid var(--chip-color, #888);
  background: transparent;
  color: var(--chip-color, #888);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  opacity: .75;
  transition: opacity .12s;
}
.insights-excl-chip:hover { opacity: 1; }
.insights-excl-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.insights-excl-restore { font-size: 11px; margin-left: 1px; }

.insights-section { margin-bottom: 36px; }

.insights-trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.insights-trend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.insights-trend-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  border: 1.5px solid;
  background: transparent;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s, transform .1s;
}
.trend-chip:hover { filter: brightness(1.1); transform: translateY(-1px); }
.trend-chip:active { transform: translateY(0); }
.trend-chip.on { font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.trend-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.insights-trend-wrap {
  position: relative;
  height: 260px;
  margin-bottom: 16px;
}
.insights-trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.insights-trend-legend-item {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 12px;
}
.insights-trend-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.insights-trend-legend-name {
  font-weight: 600;
  color: var(--text);
}
.insights-trend-legend-total {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-light);
}
.insights-trend-legend-avg {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--slate-light);
}
@media (max-width: 640px) {
  .insights-trend-card { padding: 16px; }
  .insights-trend-wrap { height: 220px; }
}
.insights-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.insights-recs-note {
  font-size: 12px;
  color: var(--slate-light);
  margin: -8px 0 16px;
}
.insights-merchants { display: flex; flex-direction: column; gap: 8px; }
.insights-merchant-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.insights-merchant-rank {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--slate);
  text-align: right;
}
.insights-merchant-name { color: var(--text); }
.insights-merchant-bar-wrap {
  width: 120px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.insights-merchant-bar {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width .4s ease;
}
.insights-merchant-amt {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--slate-light);
  min-width: 80px;
  text-align: right;
}
.insights-cat-list { display: flex; flex-direction: column; gap: 4px; }
.insights-cat-row {
  display: grid;
  grid-template-columns: 10px 160px 1fr auto auto 16px;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border-light);
  transition: background .12s, border-color .12s;
}
.insights-cat-row:hover { background: var(--cream-dark); border-color: var(--border); }
.insights-cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.insights-cat-row-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.insights-cat-row-bar-wrap {
  height: 6px;
  background: var(--cream-dark);
  border-radius: 3px;
  overflow: hidden;
}
.insights-cat-row-bar { height: 100%; border-radius: 3px; opacity: .55; }
.insights-cat-row-amt {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-align: right;
}
.insights-cat-row-count {
  font-size: 11.5px;
  color: var(--slate-faint);
  white-space: nowrap;
  text-align: right;
  min-width: 50px;
}
.insights-cat-row-chev { color: var(--slate-faint); font-size: 15px; }

.insights-recs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.insights-rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.insights-rec-cat {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 11px;
}
.insights-rec-amounts {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.insights-rec-amounts > div { flex: 1; }
.insights-rec-arrow { color: var(--slate); font-size: 16px; flex-shrink: 0; }
.insights-rec-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate);
  margin-bottom: 2px;
}
.insights-rec-num {
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  font-weight: 600;
}
.insights-rec-num.actual { color: var(--text-light); }
.insights-rec-num.rec    { color: var(--gold); }
.per-mo { font-size: 11px; font-weight: 400; color: var(--slate); }
.insights-rec-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.insights-rec-tag.over   { background: rgba(239,71,111,.15); color: #ef476f; }
.insights-rec-tag.buffer { background: rgba(6,214,160,.12);  color: #06d6a0; }
.insights-rec-tag.match  { background: rgba(134,153,186,.12); color: var(--slate-light); }
.insights-rec-note {
  font-size: 11px;
  color: var(--slate);
  line-height: 1.4;
}
/* month nav */
.insights-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
}
.insights-nav-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 6px;
  transition: background .15s;
}
.insights-nav-btn:hover:not(:disabled) { background: var(--border); }
.insights-nav-btn:disabled { color: var(--slate); cursor: default; }
.insights-nav-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 80px;
  text-align: center;
}
.insights-month-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.insights-month-pill {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--slate-light);
  cursor: pointer;
  transition: all .15s;
}
.insights-month-pill:hover { border-color: var(--gold); color: var(--text); }
.insights-month-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.insights-stat-sub.positive { color: #06d6a0; }
.insights-stat-sub.negative { color: #ef476f; }
@media (max-width: 768px) {
  .insights-stat-strip { grid-template-columns: repeat(2, 1fr); }
  .insights-charts-row { grid-template-columns: 1fr; }
  .insights-recs-grid  { grid-template-columns: 1fr 1fr; }
  .insights-merchant-bar-wrap { width: 60px; }
  .insights-cat-row { grid-template-columns: 10px 1fr auto auto 16px; }
  .insights-cat-row-bar-wrap { display: none; }
}
@media (max-width: 480px) {
  .insights-recs-grid { grid-template-columns: 1fr; }
  .insights-cat-row-count { display: none; }
  .insights-cat-row { grid-template-columns: 10px 1fr auto 16px; }
}

/* ── Category reclassification ───────────────────────────────────────────── */
.bt-txn-cat-cell { width: 120px; }
.bt-cat-select {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--ink-strong);
  cursor: pointer;
  max-width: 115px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7588' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 20px;
}
.bt-cat-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(215,163,66,.15);
}
.bt-override-badge {
  font-size: 10px;
  color: var(--gold);
  margin-left: 3px;
  vertical-align: super;
  line-height: 1;
}

/* ── Category Rules panel ────────────────────────────────────────────────── */
.bt-rules-section { margin-top: 28px; }
.bt-rules-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  background: var(--gold);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  padding: 0 5px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}
.bt-rules-empty {
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
  margin-top: 8px;
}
.bt-rules-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.bt-rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.bt-rule-merchant {
  flex: 1;
  font-weight: 500;
  color: var(--ink-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bt-rule-arrow { color: var(--text-light); flex-shrink: 0; }
.bt-rule-cat {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink-strong);
  white-space: nowrap;
  flex-shrink: 0;
}
.bt-rule-del {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.bt-rule-del:hover {
  color: var(--coral);
  background: rgba(239,71,111,.08);
}
.bt-edit-budget-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-light);
  padding: 0 3px;
  line-height: 1;
  vertical-align: middle;
  opacity: 0.5;
  transition: opacity .15s, color .15s;
}
.bt-edit-budget-btn:hover { color: var(--gold-dark); opacity: 1 !important; }
.bt-budget-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--text-light);
}
.bt-budget-input {
  width: 62px;
  font-size: 13px;
  font-family: inherit;
  padding: 2px 5px;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  background: var(--cream);
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.bt-budget-input::-webkit-inner-spin-button,
.bt-budget-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── CSV Import Banner ──────────────────────────────────────────────────────── */
.csv-import-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.csv-import-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.csv-import-icon { font-size: 16px; }
.csv-import-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.csv-manage-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
}
.csv-manage-btn:hover { background: var(--cream); }
.csv-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ink);
  color: var(--white);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
  user-select: none;
}
.csv-upload-btn:hover { opacity: .85; }

.account-export-btn { text-decoration: none; }
.account-desc {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
  max-width: 640px;
  margin: 0 0 16px;
}
.account-warning {
  background: rgba(214, 69, 69, .08);
  border: 1px solid rgba(214, 69, 69, .35);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  max-width: 640px;
  margin: 0 0 16px;
}
.account-warning strong { color: #c0392b; }

@keyframes csv-spin { to { transform: rotate(360deg); } }
.csv-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: csv-spin .7s linear infinite;
  vertical-align: middle;
}

.import-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}
.import-toast-links {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.import-toast-links a {
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.45);
  padding-bottom: 1px;
  white-space: nowrap;
}
.import-toast-links a:hover { border-color: #fff; }

.csv-import-list {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.csv-import-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.csv-import-row:last-child { border-bottom: none; }
.csv-import-filename {
  flex: 1;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.csv-import-meta {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}
.csv-import-del {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.csv-import-del:hover { color: var(--coral); background: rgba(239,71,111,.08); }
.csv-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-secondary);
}
.csv-empty-icon { font-size: 48px; margin-bottom: 16px; }
.csv-empty-state h2 { margin: 0 0 8px; color: var(--ink); font-size: 18px; }
.csv-empty-state p  { margin: 4px 0; font-size: 14px; max-width: 400px; }

/* ── Onboarding Overlay ─────────────────────────────────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(13, 27, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ob-card {
  background: var(--cream);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 28px 28px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  transition: opacity .16s ease, transform .16s ease;
}
.ob-card.ob-slide {
  opacity: 0;
  transform: translateY(8px);
}
.ob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.ob-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.ob-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background .25s, width .25s;
}
.ob-dot-active {
  background: var(--gold);
  width: 20px;
  border-radius: 4px;
}
.ob-skip {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--slate-light);
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ob-skip:hover { color: var(--text); }
.ob-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ob-icon svg { width: 68px; height: 68px; }
.ob-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-strong);
  letter-spacing: -.01em;
  margin-bottom: 10px;
  text-wrap: balance;
}
.ob-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-light);
  margin-bottom: 16px;
}
.ob-body strong { color: var(--text); font-weight: 600; }
.ob-features {
  list-style: none;
  margin-bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ob-feature-item {
  font-size: 13px;
  color: var(--text-light);
  padding-left: 18px;
  position: relative;
  line-height: 1.45;
}
.ob-feature-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: .7;
}
.ob-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ob-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.ob-back:hover { background: var(--cream-dark); }
.ob-next {
  flex: 1;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .01em;
  transition: background .15s;
}
.ob-next:hover { background: var(--navy-mid); }

/* ── Pull-to-refresh indicator (mobile) ────────────────────────────────── */
#ptr-indicator {
  position: fixed;
  top: calc(52px + env(safe-area-inset-top) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--slate-light);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease);
}
#ptr-indicator.ready { color: var(--gold-dark); border-color: var(--gold); }
#ptr-indicator.refreshing span {
  display: inline-block;
  animation: ptr-rotate 800ms linear infinite;
}
@keyframes ptr-rotate { to { transform: rotate(360deg); } }
