/* ======================================================
   Excelergy Budget - Base Styles
   VERSION: v2026-BUDGET-INIT-1
   Default theme: B (light + electric blue).
   Dark theme A activates when <html data-theme="dark">.
   ====================================================== */

:root {
  /* Theme B: light + electric blue (default) */
  --bg: #ffffff;
  --bg-soft: #f5f8fb;
  --card: rgba(255, 255, 255, 0.92);
  --card-solid: #ffffff;
  --border: #dee7ef;
  --border-strong: #b9c8d6;
  --text: #010E26;
  --muted: #5a6378;
  --primary: #014BC1;
  --primary-dark: #013592;
  --primary-soft: #e0ecfb;
  --accent: #00C4F0;
  --accent-soft: #d4f3fb;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --topbar-border: rgba(184, 200, 218, 0.85);
  --nav-pill-bg: #eef4fa;
  --table-head-bg: #f5f8fb;
  --table-head-text: #5a6378;
  --table-row-hover: #f5f8fb;
  --hero-glow: rgba(0, 196, 240, 0.10);
  --tile-glow: rgba(0, 196, 240, 0.10);
  --focus-ring: rgba(1, 75, 193, 0.18);
  --primary-shadow: 0 8px 18px rgba(1, 75, 193, 0.30);
  --shadow: 0 16px 36px rgba(1, 14, 38, 0.10);
  --shadow-soft: 0 4px 14px rgba(1, 14, 38, 0.06);
  --radius: 22px;
  --tag-text: var(--primary-dark);
}

/* Theme A: dark mode (logo-native) */
:root[data-theme="dark"] {
  --bg: #000713;
  --bg-soft: #011330;
  --card: rgba(1, 19, 48, 0.92);
  --card-solid: #011330;
  --border: #013592;
  --border-strong: #014BC1;
  --text: #ecf1f8;
  --muted: #7b8aa8;
  --primary: #017FEE;
  --primary-dark: #014BC1;
  --primary-soft: rgba(1, 127, 238, 0.20);
  --accent: #00C4F0;
  --accent-soft: rgba(0, 196, 240, 0.18);
  --topbar-bg: rgba(0, 7, 19, 0.85);
  --topbar-border: rgba(1, 53, 146, 0.55);
  --nav-pill-bg: rgba(1, 19, 48, 0.7);
  --table-head-bg: rgba(1, 53, 146, 0.30);
  --table-head-text: #7b8aa8;
  --table-row-hover: rgba(1, 127, 238, 0.10);
  --hero-glow: rgba(0, 196, 240, 0.10);
  --tile-glow: rgba(0, 196, 240, 0.12);
  --focus-ring: rgba(1, 127, 238, 0.40);
  --primary-shadow: 0 8px 18px rgba(0, 196, 240, 0.30);
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.40);
  --tag-text: var(--accent);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top right, var(--hero-glow), transparent 28rem), var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .18s ease, color .18s ease;
}
button, input, select { font: inherit; }

/* Topbar - identical pattern to Excelergy main site */
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 68px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(18px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; color: var(--text); }
.brand-mark { display: block; width: 34px; height: 34px; flex-shrink: 0; border-radius: 12px; box-shadow: var(--shadow-soft); }
.brand-suffix { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-left: 2px; }
.topbar-nav { display: flex; gap: 8px; background: var(--nav-pill-bg); padding: 5px; border-radius: 999px; border: 1px solid var(--border); }
.topbar-nav a { font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; padding: 9px 14px; border-radius: 999px; }
.topbar-nav a.active, .topbar-nav a:hover { color: var(--text); background: var(--card-solid); box-shadow: var(--shadow-soft); }

.topbar-actions {
  display: inline-flex; align-items: center; gap: 8px;
}
.theme-toggle, .feedback-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  padding: 0; flex-shrink: 0;
  text-decoration: none;
}
/* Preserve the original 10px gap when theme toggle is alone (no wrapper). */
.topbar > .theme-toggle { margin-left: 10px; }
.topbar > .feedback-toggle { margin-left: 10px; }
.theme-toggle:hover, .feedback-toggle:hover {
  background: var(--bg-soft); border-color: var(--border-strong); color: var(--primary);
}
.theme-toggle:focus, .feedback-toggle:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-toggle .icon-dark { display: none; } .theme-toggle .icon-light { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }

/* Hero */
.hero { max-width: 1520px; margin: 22px auto 0; padding: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { max-width: 860px; margin: 0; font-size: clamp(30px, 4vw, 54px); line-height: 1.02; letter-spacing: -.055em; }
.hero-copy { max-width: 660px; color: var(--muted); font-size: 16px; margin: 14px 0 0; }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.secondary-link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 0 14px; border-radius: 12px; background: var(--card-solid);
  border: 1px solid var(--border); color: var(--text); font-weight: 700; font-size: 13px;
  text-decoration: none; box-shadow: var(--shadow-soft);
}

/* Buttons */
button, .primary {
  min-height: 40px; padding: 0 16px; font-size: 13px; font-weight: 800;
  border-radius: 12px; border: none; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: var(--primary-shadow); }
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.secondary-button {
  min-height: 40px; padding: 0 16px; font-size: 13px; font-weight: 700;
  border-radius: 12px; border: 1px solid var(--border-strong); background: var(--card-solid);
  color: var(--text); cursor: pointer;
}
.secondary-button:hover { background: var(--bg-soft); }
.danger-button:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

/* Containers */
main { display: flex; flex-direction: column; gap: 20px; min-width: 0; max-width: 1520px; margin: 0 auto; padding: 0 28px 28px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-soft); backdrop-filter: blur(16px); }
.panel h3 { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; text-transform: uppercase; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-title h3 { margin: 0; color: var(--text); font-size: 18px; letter-spacing: -.02em; text-transform: none; }

/* Disclaimer strip (re-used pattern) */
.disclaimer-strip {
  max-width: 1520px; margin: 14px auto 18px; padding: 12px 28px;
  font-size: 12px; color: #7c2d12; background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 12px; line-height: 1.5;
}
.disclaimer-strip strong { color: #7c2d12; }

/* Pre-launch placeholder card */
.placeholder-card {
  text-align: center; padding: 60px 28px;
  background: linear-gradient(135deg, var(--primary-soft), var(--card-solid));
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.placeholder-card h2 { margin: 12px 0 8px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
.placeholder-card p { max-width: 540px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.55; }
.placeholder-card .placeholder-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff;
  box-shadow: var(--primary-shadow); margin-bottom: 4px;
}

/* ==========================================================
   TRACKER UI (/tracker.html)
   ========================================================== */

/* Drop zone --------------------------------------------------------- */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
  background: var(--bg-soft); border: 2px dashed var(--border-strong);
  border-radius: var(--radius); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.drop-zone:hover, .drop-zone.dragging {
  background: var(--primary-soft); border-color: var(--primary);
}
.drop-zone-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: var(--primary); color: #fff; box-shadow: var(--primary-shadow);
  margin-bottom: 8px;
}
.drop-zone-title { margin: 4px 0 6px; font-size: 16px; font-weight: 700; color: var(--text); }
.drop-zone-help { margin: 0; font-size: 13px; color: var(--muted); max-width: 480px; line-height: 1.45; }

/* Column-mapper ----------------------------------------------------- */
.mapper-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.mapper-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.mapper-grid input, .mapper-grid select {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-solid); color: var(--text); font-size: 13px;
  text-transform: none; font-weight: 500; letter-spacing: 0;
}
.mapper-grid input:focus, .mapper-grid select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.mapper-preview { margin-bottom: 18px; }
.mapper-preview-label {
  margin: 0 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.mapper-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Rules ------------------------------------------------------------- */
.rule-row {
  display: grid; align-items: center; gap: 8px;
  /* contains | pattern | → | category | type | account | tags | × */
  grid-template-columns: auto minmax(0, 1.8fr) auto minmax(0, 1.1fr) minmax(0, 0.9fr) minmax(0, 1.1fr) minmax(110px, 1.3fr) auto;
  padding: 4px 2px; margin-bottom: 6px;
}
.rule-row select { min-width: 0; }
.rule-prefix {
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 0 4px;
  display: inline-flex; align-items: center; gap: 6px;
}
.rule-default-badge {
  display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 4px;
  background: var(--border); color: var(--muted); line-height: 1;
}
.rule-row input, .rule-row select {
  width: 100%; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  font-size: 13px;
}
.rule-row input:focus, .rule-row select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.rule-delete {
  width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.rule-delete:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

/* Transaction filters ---------------------------------------------- */
.txn-filters {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.txn-filters label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.txn-filters select,
.txn-filters input[type="search"] {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--card-solid); color: var(--text); font-size: 13px;
}
.txn-filters input[type="search"] { width: 200px; }
.txn-filters input[type="search"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.txn-filters .inline-toggle { font-size: 12px; }

.txn-cycle-config {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 8px 0 10px;
  font-size: 12px; color: var(--muted); font-weight: 700;
}
.txn-cycle-config label { display: inline-flex; align-items: center; gap: 6px; }
.txn-cycle-config input[type="number"] {
  width: 60px; padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--card);
  color: var(--text); font-size: 13px; font-weight: 700; text-align: center;
}
.txn-cycle-config input[type="number"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.txn-cycle-config .muted { font-weight: 600; color: var(--muted); }

/* Transaction bulk-action bar (appears when ≥1 row is selected) */
.txn-bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 10px;
  margin: 0 0 10px;
  font-size: 13px;
}
.txn-bulk-count { font-weight: 800; color: var(--primary); flex-shrink: 0; }
.txn-bulk-bar select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--card-solid); color: var(--text);
  font-size: 13px; font-weight: 600;
}
.txn-bulk-bar button { width: auto; min-height: 0; padding: 6px 12px; font-size: 12px; font-weight: 700; }

.txn-select-col { width: 28px; text-align: center; }
.data-table .txn-select-col input,
.data-table td.txn-select-col input { cursor: pointer; }

/* Sortable header columns + sticky thead on long transaction lists */
.txn-table-scroll { max-height: 70vh; overflow-y: auto; }
.txn-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--card-solid);
  box-shadow: 0 1px 0 0 var(--border);
}
.txn-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.txn-sortable:hover { color: var(--primary); }
.txn-sortable .sort-arrow {
  display: inline-block; width: 0; height: 0; margin-left: 6px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0;
}
.txn-sortable.is-sorted { color: var(--primary); }
.txn-sortable.is-sorted .sort-arrow { opacity: 1; }
.txn-sortable.sort-asc  .sort-arrow { border-bottom: 5px solid currentColor; }
.txn-sortable.sort-desc .sort-arrow { border-top:    5px solid currentColor; }

/* Spending trends chart */
.trends-svg { width: 100%; height: auto; max-height: 320px; display: block; }
.trends-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.trends-legend .legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.trends-legend .legend-swatch {
  width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0;
}

/* Spending insights */
.insights-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.insights-list li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px;
  background: var(--card-solid); border: 1px solid var(--border);
  font-size: 14px; color: var(--text);
}
.insights-list li.insight-warning { border-color: #fde68a; background: #fffbeb; }
.insights-list li.insight-good    { border-color: #bbf7d0; background: #f0fdf4; }
.insights-list .insight-icon {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}
.insights-list li.insight-warning .insight-icon { background: #fef3c7; color: #92400e; }
.insights-list li.insight-good    .insight-icon { background: #dcfce7; color: #15803d; }
.insights-list .insight-text { flex: 1; min-width: 0; line-height: 1.45; }
.insights-list .insight-text strong { color: var(--text); }
.insights-list .insight-text .insight-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }

/* Cycle summary banner at the top of the recurring panel */
.recur-cycle-summary {
  padding: 14px 16px; margin-bottom: 14px;
  background: var(--primary-soft); border-radius: 12px;
  border: 1px solid var(--primary);
}
.recur-cycle-line { font-size: 14px; color: var(--text); line-height: 1.5; }
.recur-cycle-line strong { color: var(--primary); }
.recur-cycle-progress {
  margin-top: 10px; height: 6px; border-radius: 3px;
  background: var(--card); overflow: hidden;
}
.recur-cycle-progress > span {
  display: block; height: 100%; background: var(--primary);
  transition: width .3s ease-out;
}
.recur-cycle-progress-label {
  margin-top: 4px; font-size: 11px; color: var(--muted); font-weight: 600;
}

/* Recurring & upcoming panel */
.recur-list { display: flex; flex-direction: column; gap: 8px; }
.recur-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.recur-row.recur-overdue { border-color: #fca5a5; background: #fef2f2; }
.recur-row.recur-paid    { border-color: #86efac; }
.recur-label { font-weight: 700; color: var(--text); min-width: 0; }
.recur-meta  { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.recur-amount { text-align: right; font-weight: 700; font-feature-settings: 'tnum'; }
.recur-status {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.recur-status.overdue { background: #fee2e2; color: #b91c1c; }
.recur-status.paid    { background: #dcfce7; color: #15803d; }
.recur-status.upcoming { background: #fef3c7; color: #92400e; }
@media (max-width: 540px) {
  .recur-row { grid-template-columns: 1fr auto; }
  .recur-amount { grid-column: 1 / -1; text-align: left; padding-top: 4px; border-top: 1px solid var(--border); }
}

/* Net worth dashboard */
.tile-value.gain { color: #059669; }
.nw-total-row td { background: var(--primary-soft); }
.nw-total-row td:first-child { color: var(--text); }
.nw-trend-svg { width: 100%; height: auto; max-height: 280px; display: block; }
.snapshot-list-details summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted);
  padding: 6px 0; list-style: none;
}
.snapshot-list-details summary::-webkit-details-marker { display: none; }
.snapshot-list-details summary::before { content: "▸ "; display: inline-block; transition: transform .15s; }
.snapshot-list-details[open] summary::before { content: "▾ "; }
.snapshot-list-host { margin-top: 8px; max-height: 320px; overflow-y: auto; }
.snapshot-table { font-size: 13px; }
.snapshot-table .row-delete { width: 24px; height: 24px; font-size: 14px; }

/* Manage Categories */
.cat-list { display: flex; flex-direction: column; gap: 6px; }
.cat-row-mgr {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--card-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}
.cat-row-mgr .cat-name { flex: 1; min-width: 0; font-weight: 600; color: var(--text); }
.cat-row-mgr .cat-name input {
  width: 100%; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--primary); background: var(--card);
  color: var(--text); font-size: 14px; font-weight: 600;
}
.cat-row-mgr .cat-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.cat-row-mgr .cat-badge.custom { background: #fef3c7; color: #92400e; }
.cat-row-mgr .cat-usage { font-size: 12px; color: var(--muted); font-weight: 600; }
.cat-row-mgr .cat-actions { display: flex; gap: 6px; }
.cat-row-mgr .cat-actions button {
  width: auto; min-height: 0; padding: 4px 10px; font-size: 12px; font-weight: 700;
  border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text);
}
.cat-row-mgr .cat-actions button:hover { border-color: var(--primary); color: var(--primary); }
.cat-row-mgr .cat-actions .cat-delete:hover { border-color: #fca5a5; background: #fee2e2; color: #b91c1c; }

/* Planned vs actual */
.pva-good { color: #059669; font-weight: 700; }
.pva-bad  { color: #b91c1c; font-weight: 700; }
.pva-income-row td { border-top: 2px solid var(--border); padding-top: 10px; }
.pva-total-row td { background: var(--card-solid); }
.pva-income-row td:first-child,
.pva-total-row td:first-child { color: var(--text); }

/* Payment-type input (editable, datalist autocomplete) -------------- */
.txn-type-input {
  width: 70px; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  font-family: ui-monospace, Consolas, "SF Mono", monospace;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
}
.txn-type-input:hover { border-color: var(--border-strong); }
.txn-type-input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.txn-type-input::placeholder { font-weight: 400; color: var(--muted); opacity: 0.6; }

/* Transaction-row inline edits ------------------------------------- */
.data-table .txn-category, .data-table .txn-account {
  width: 100%; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  font-size: 12px;
}
.data-table .txn-delete {
  width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 6px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.data-table .txn-delete:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.data-table .txn-actions { white-space: nowrap; display: flex; gap: 4px; }
.data-table .txn-make-rule {
  height: 28px; padding: 0 8px; min-height: 0; border-radius: 6px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; font-weight: 700; line-height: 1; cursor: pointer;
}
.data-table .txn-make-rule:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Mobile rules layout ---------------------------------------------- */
@media (max-width: 760px) {
  /* On phones, stack: pattern full-width on row 1, then the three dropdowns
     share row 2, with the delete pinned to the corner. */
  .rule-row { grid-template-columns: 1fr 1fr 1fr auto; }
  .rule-prefix, .row-arrow { display: none; }
  .rule-pattern { grid-column: 1 / -1; }
  .rule-delete  { justify-self: end; }
  .mapper-actions { justify-content: stretch; }
  .mapper-actions button { flex: 1; }
}

/* Footer */
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px; }
.footer .build-stamp {
  margin: 6px 0 0; font-size: 10px; opacity: 0.55;
  font-family: ui-monospace, Consolas, "SF Mono", monospace;
  letter-spacing: .02em;
}

/* Help icon (re-used pattern, in case content needs tooltips) */
.help {
  width: 16px; height: 16px; min-width: 16px; min-height: 16px; border-radius: 50%;
  background: var(--accent-soft); color: var(--primary-dark); border: none;
  font-family: Georgia, serif; font-size: 11px; font-weight: 700; font-style: italic;
  line-height: 1; cursor: help; padding: 0; display: inline-flex; align-items: center;
  justify-content: center; vertical-align: middle; position: relative; flex-shrink: 0;
  box-sizing: border-box; transition: background .12s, color .12s;
}
.help:hover, .help:focus { background: var(--primary); color: #fff; outline: none; }

/* ==========================================================
   BUDGET TOOL UI
   ========================================================== */

/* Headline tile -------------------------------------------------------- */
.headline-tile {
  text-align: center;
  background: linear-gradient(135deg, var(--primary-soft), var(--card-solid));
  padding: 28px 24px;
}
.headline-label {
  margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--primary);
}
.headline-value {
  margin: 8px 0 4px; font-size: clamp(40px, 6vw, 64px);
  font-weight: 800; letter-spacing: -.04em; color: var(--primary-dark);
}
.headline-value.negative { color: #b42318; }
.headline-sub { margin: 0; color: var(--muted); font-size: 14px; }

/* Tile grid ------------------------------------------------------------ */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.tile { padding: 16px 18px; }
.tile-label {
  margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.tile-value {
  margin: 6px 0 0; font-size: 26px; font-weight: 800;
  letter-spacing: -.03em; color: var(--text);
}
.tile-value.negative { color: #b42318; }
.tile-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* Warnings panel ------------------------------------------------------- */
.warnings-panel {
  border-color: #fcd34d;
  background: linear-gradient(135deg, #fff8e1, var(--card-solid));
}
.warnings-panel h3 { color: #7c2d12; }
.warnings-panel ul { margin: 0; padding-left: 18px; color: #7c2d12; font-size: 13px; }
.warnings-panel li { margin: 4px 0; }

/* Scenario bar --------------------------------------------------------- */
.scenario-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; padding: 14px 18px;
}
.scenario-bar-left { display: flex; align-items: center; gap: 10px; }
.scenario-bar-left label {
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.scenario-bar-left input {
  min-width: 220px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--card-solid); color: var(--text);
}
.scenario-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scenario-bar-right select {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--card-solid); color: var(--text);
}

/* Sample-scenario chips ------------------------------------------------ */
.sample-strip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 18px;
}
.sample-label {
  margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.sample-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 32px; padding: 0 12px; font-size: 12px; font-weight: 700;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card-solid); color: var(--text); cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.chip:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-soft);
}
.chip:focus { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Section help text ---------------------------------------------------- */
.section-help { margin: -4px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }

/* Section tag (e.g. annual total chip) --------------------------------- */
.section-tag {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--tag-text);
}

/* Inline toggle (e.g. goal-enabled checkbox) --------------------------- */
.inline-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.inline-toggle input { accent-color: var(--primary); }

/* Repeating row form layout ------------------------------------------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: 1.6fr 0.7fr 0.7fr 1fr auto;
  padding: 4px 2px;
}
.row[data-kind="accounts"] {
  grid-template-columns: 1fr auto;
}
.row[data-kind="outgoings"] {
  grid-template-columns: 1.4fr 0.6fr 0.7fr 1fr 1fr auto auto;
}
.row[data-kind="sinkingFunds"] {
  grid-template-columns: 1.6fr 0.7fr 1fr auto;
}
.row[data-kind="transfers"] {
  grid-template-columns: 1.4fr 0.6fr 0.7fr 1fr auto 1fr auto;
}
.row-arrow {
  font-size: 16px; color: var(--muted); text-align: center; font-weight: 700;
}
.row input[type="text"], .row input[type="number"], .row select {
  width: 100%; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  font-size: 13px;
}
.row input:focus, .row select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}
.row-sub-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); font-weight: 700;
}
.row-sub-toggle input { accent-color: var(--primary); }
.row-delete {
  width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 18px; line-height: 1;
}
.row-delete:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

/* Goal grid ------------------------------------------------------------ */
.goal-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-top: 8px;
}
.goal-grid label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.goal-grid input {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card-solid); color: var(--text); font-size: 13px;
}
.goal-grid input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Data tables ---------------------------------------------------------- */
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  text-align: left; font-weight: 700; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--table-head-text);
  background: var(--table-head-bg); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:hover td { background: var(--table-row-hover); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.num.negative { color: #b42318; font-weight: 700; }

/* ── Tag chip editor (transactions + rules) ─────────────────────────── */
.tag-cell {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  min-width: 120px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 8px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 999px; font-size: 11px; font-weight: 700;
  line-height: 1.4; max-width: 100%;
}
.tag-chip > span {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px;
}
.tag-chip-x {
  width: 14px; height: 14px; min-height: 0; padding: 0;
  border: 0; background: transparent; color: var(--primary);
  border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.tag-chip-x:hover { background: var(--primary); color: #fff; }
.tag-chip.tag-chip-readonly { cursor: default; padding: 2px 9px; }
.tag-add {
  width: 20px; height: 20px; min-height: 0; padding: 0;
  border: 1px dashed var(--border-strong); background: transparent;
  color: var(--muted); border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.tag-add:hover { color: var(--primary); border-color: var(--primary); }
.tag-input {
  padding: 3px 8px; border: 1px solid var(--primary); border-radius: 999px;
  font-size: 11px; font-weight: 600; width: 100px;
  background: var(--card-solid); color: var(--text);
}
.tag-input:focus { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

/* Rule-row tag cell sits between the account dropdown and the delete
   button - leave it a slim narrow area; the chip editor wraps within. */
.rule-tags-cell {
  min-width: 110px; display: inline-flex; align-items: center;
  flex-wrap: wrap; gap: 4px;
}

/* ── 50/30/20 balance check panel ─────────────────────────────────────── */
#ratio503020Panel .ratio-bar-compact { margin: 0 0 4px; }
.ratio-bar {
  display: flex; height: 30px; border-radius: 8px; overflow: hidden;
  margin-bottom: 6px; border: 1px solid var(--border);
}
.ratio-bar > div {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  transition: flex 0.3s ease;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.ratio-bar .seg-needs   { background: #1d4ed8; }
.ratio-bar .seg-wants   { background: #7c3aed; }
.ratio-bar .seg-savings { background: #15803d; }
.bar-mini-legend {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.bar-mini-legend .dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  vertical-align: middle; margin-right: 4px;
}
.bar-mini-legend .dot-needs   { background: #1d4ed8; }
.bar-mini-legend .dot-wants   { background: #7c3aed; }
.bar-mini-legend .dot-savings { background: #15803d; }
.verdict-pill {
  margin-left: auto;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap;
}
.verdict-pill.on    { background: #dcfce7; color: #15803d; }
.verdict-pill.over  { background: #fee2e2; color: #b91c1c; }
.verdict-pill.under { background: #fef3c7; color: #b45309; }
:root[data-theme="dark"] .verdict-pill.on    { background: rgba(21,128,61,.35); color: #86efac; }
:root[data-theme="dark"] .verdict-pill.over  { background: rgba(153,27,27,.35); color: #fca5a5; }
:root[data-theme="dark"] .verdict-pill.under { background: rgba(180,83,9,.35);  color: #fcd34d; }

.ratio-rows {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px;
  margin: 16px 0;
}
@media (max-width: 760px) {
  .ratio-rows { grid-template-columns: 1fr; }
}
.ratio-row {
  padding: 12px 14px; border-radius: 10px; background: var(--bg-soft);
}
.ratio-row .label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.ratio-row .actual {
  font-size: 22px; font-weight: 800; margin-top: 2px; color: var(--text);
}
.ratio-row .target { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ratio-row.on    { background: #dcfce7; }
.ratio-row.over  { background: #fee2e2; }
.ratio-row.under { background: #fef3c7; }
.ratio-row.on    .actual { color: #15803d; }
.ratio-row.over  .actual { color: #b91c1c; }
.ratio-row.under .actual { color: #b45309; }
:root[data-theme="dark"] .ratio-row.on    { background: rgba(21,128,61,.25); }
:root[data-theme="dark"] .ratio-row.over  { background: rgba(153,27,27,.25); }
:root[data-theme="dark"] .ratio-row.under { background: rgba(180,83,9,.25); }
:root[data-theme="dark"] .ratio-row.on    .actual { color: #86efac; }
:root[data-theme="dark"] .ratio-row.over  .actual { color: #fca5a5; }
:root[data-theme="dark"] .ratio-row.under .actual { color: #fcd34d; }

.ratio-verdict {
  padding: 10px 14px; border-radius: 8px; background: var(--primary-soft);
  color: var(--primary); font-size: 13px; line-height: 1.45;
  margin: 0 0 10px;
}
.ratio-verdict strong { font-weight: 800; }
#ratio503020Panel .drill-row {
  font-size: 12px; color: var(--muted); margin: 0;
}
#ratio503020Panel .drill-row a {
  color: var(--primary); font-weight: 600; cursor: pointer; text-decoration: none;
}
#ratio503020Panel .drill-row a:hover { text-decoration: underline; }

/* Customise modal */
.ratio503020-modal-card { max-width: 560px; }
.ratio503020-modal-card .preset-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px;
}
.ratio503020-modal-card .preset-chip {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card-solid); cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text);
  text-align: left;
}
.ratio503020-modal-card .preset-chip:hover {
  border-color: var(--primary); color: var(--primary);
}
.ratio503020-modal-card .preset-chip.active {
  border-color: var(--primary); background: var(--primary-soft); color: var(--primary);
}
.ratio503020-modal-card .preset-chip small {
  display: block; font-weight: 400; color: var(--muted); margin-top: 2px;
}
.ratio503020-modal-card .sliders {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 6px;
}
.ratio503020-modal-card .sliders label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.ratio503020-modal-card .sliders input[type="number"] {
  width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-weight: 700; background: var(--card-solid); color: var(--text);
}
.ratio503020-modal-card .modal-total { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.ratio503020-modal-card .modal-total.bad { color: #b91c1c; font-weight: 700; }
.ratio503020-modal-card h4 { margin: 18px 0 6px; font-size: 13px; color: var(--text); }
.ratio503020-modal-card .bucket-list {
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); max-height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.ratio503020-modal-card .bucket-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.ratio503020-modal-card .bucket-row label { font-size: 13px; color: var(--text); }
.ratio503020-modal-card .bucket-row select {
  padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card-solid); color: var(--text);
  font-size: 12px; font-weight: 600;
}

/* Category bars -------------------------------------------------------- */
.spend-category-grid {
  display: grid; gap: 24px;
  grid-template-columns: 280px 1fr;
  align-items: center;
}
@media (max-width: 720px) {
  .spend-category-grid { grid-template-columns: 1fr; }
  .category-donut { max-width: 240px; margin: 0 auto; }
}
.category-donut svg.donut-svg { width: 100%; height: auto; max-width: 280px; display: block; }
.category-bars { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cat-row {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 160px 1fr 100px;
}
.cat-label { font-size: 13px; color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.cat-label .cat-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.cat-bar {
  display: block; height: 10px; border-radius: 999px;
  background: var(--bg-soft); overflow: hidden;
}
.cat-bar-fill {
  display: block; height: 100%;
  background: var(--primary);
}
.cat-value { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }

/* ── Profile bar ─────────────────────────────────────────────────────────── */
.profile-bar {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 6px 24px;
  position: sticky;
  top: 68px;
  z-index: 19;
}
.profile-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.profile-icon { flex-shrink: 0; opacity: 0.5; color: var(--muted); }
.profile-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.profile-name-input {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-solid);
  color: var(--text);
  width: 160px;
  min-width: 80px;
}
.profile-name-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring); }
.profile-select {
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-solid);
  color: var(--text);
  cursor: pointer;
  max-width: 200px;
}
.profile-action-btn {
  font-size: 12px !important;
  padding: 4px 10px !important;
  min-height: 0 !important;
  height: 28px !important;
  line-height: 1 !important;
}
.profile-import-label { cursor: pointer; display: inline-flex; align-items: center; }
.profile-bar-sep {
  display: inline-block; width: 1px; height: 20px;
  background: var(--border); margin: 0 4px; flex-shrink: 0;
}

/* Toast */
.profile-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
}
.profile-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Undo toast (window.excelergyToast.showUndo) */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 14px;
  min-width: 280px;
  max-width: 460px;
  background: var(--text);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  animation: toast-in .18s ease-out;
}
.toast--leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
.toast-msg { flex: 1; min-width: 0; }
.toast-undo {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.toast-undo:hover { background: rgba(255,255,255,0.12); border-color: #fff; }
.toast-close {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.toast-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.toast-progress {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--primary);
  transform-origin: left center;
  animation: toast-progress 5s linear forwards;
}
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
@media (max-width: 600px) {
  .toast-host { left: 12px; right: 12px; bottom: 12px; transform: none; }
  .toast { min-width: 0; max-width: none; width: 100%; }
}

/* Section collapse toggle */
.section-collapse-btn {
  width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color .15s, border-color .15s, transform .2s;
}
.section-collapse-btn:hover { color: var(--text); border-color: var(--border-strong); }
.section-collapse-btn[aria-expanded="false"] { transform: rotate(-90deg); }

/* When pin and chevron are both direct children of the section title (which
   uses justify-content: space-between), we wrap them in this flex group so
   they stay anchored together on the right of the title bar. */
.section-actions-group {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
}

/* Pin: marks a panel as "always start collapsed on load". Sits next to
   the chevron in the section title bar. */
.section-pin-btn {
  width: 28px; height: 28px; min-height: 0; padding: 0; border-radius: 8px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color .15s, border-color .15s, background .15s;
}
.section-pin-btn:hover { color: var(--text); border-color: var(--border-strong); }
.section-pin-btn.is-active {
  background: var(--primary-soft); color: var(--primary); border-color: var(--primary);
}

/* Add-row button at bottom of a section */
.rows-footer { margin-top: 10px; display: flex; }

/* Responsive */
@media (max-width: 760px) {
  .profile-bar { padding: 6px 16px; top: auto; position: static; }
  .profile-bar-inner { gap: 6px; }
  .profile-name-input { width: 120px; }
  .profile-select { max-width: 130px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-nav { width: 100%; }
  .topbar-nav a { flex: 1; text-align: center; }
  .hero { padding: 22px 16px; flex-direction: column; align-items: stretch; }
  main { padding: 0 16px 20px; }

  .row,
  .row[data-kind="incomes"],
  .row[data-kind="outgoings"],
  .row[data-kind="sinkingFunds"],
  .row[data-kind="transfers"] {
    grid-template-columns: 1fr 1fr; gap: 6px;
  }
  /* Label always gets a full row at the top - it's the most important field
     and benefits from the extra width on phones. */
  .row > .row-label { grid-column: 1 / -1; }
  /* Sub-toggle, delete, and the from/to account selects on transfers each
     get their own full or anchored cell so the row never overflows. */
  .row-sub-toggle { grid-column: 1 / -1; }
  .row-delete { grid-column: 2; justify-self: end; }
  .row[data-kind="transfers"] > .row-from-account,
  .row[data-kind="transfers"] > .row-to-account { grid-column: 1 / -1; }
  .row[data-kind="transfers"] > .row-arrow { display: none; }
  /* Inputs benefit from being a touch larger on a phone keyboard. */
  .row input[type="text"], .row input[type="number"], .row select { padding: 10px 12px; font-size: 14px; }

  .cat-row { grid-template-columns: 110px 1fr 80px; gap: 8px; }
  .scenario-bar-left input { min-width: 0; width: 100%; }
  .scenario-bar-left { width: 100%; }
}

/* ── Print ────────────────────────────────────────────────────────────────
   Goal: a clean single-column snapshot of whatever's on screen - the
   numbers and tables - without any chrome (nav, profile bar, toggles,
   add/delete buttons, drop zones). Used for "save plan as PDF" and
   "show this to my partner". */
@media print {
  /* Force a light theme regardless of the user's setting so the print
     output is consistent. */
  :root, [data-theme="dark"] {
    --bg-from: #ffffff;
    --bg-to:   #ffffff;
    --card:    #ffffff;
    --card-solid: #ffffff;
    --text:    #000000;
    --muted:   #555555;
    --border:  #cccccc;
    --border-strong: #999999;
    --primary: #014BC1;
    --primary-soft: #f0f4ff;
    --shadow-soft: none;
  }
  body { background: #ffffff !important; }

  /* Hide all interactive chrome */
  .topbar,
  .profile-bar,
  .theme-toggle,
  .toast-host,
  .hero-actions,
  .disclaimer-strip,
  .rows-footer,
  .row-delete,
  .row-sub-toggle,
  .section-collapse-btn,
  .secondary-button,
  .danger-button,
  .scenario-bar,
  button[data-add],
  #budgetSuggestPanel,
  .drop-zone,
  #mapperPanel,
  #rulesPanel,
  #addInvBtn,
  #addDebtBtn,
  .debt-promo-toggle,
  .debt-promo-row,
  .impact-custom-row,
  #scheduleToggleBtn,
  #scheduleShowMoreRow,
  .txn-actions,
  .txn-filters,
  .toc {
    display: none !important;
  }

  /* Show inputs as plain text - no boxes, no borders */
  .row input[type="text"],
  .row input[type="number"],
  .row select,
  .goal-grid input,
  .goal-grid select {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    font-weight: 600;
    -webkit-appearance: none;
    appearance: none;
  }
  .row select { padding-right: 0 !important; }

  /* Compact the page */
  main { padding: 0 !important; max-width: none !important; }
  .panel {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    page-break-inside: avoid;
    margin-bottom: 12px !important;
    padding: 12px !important;
  }
  .headline-tile { background: #f0f4ff !important; }
  .tile-grid { display: grid !important; grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .data-table { font-size: 11px; }
  .data-table th, .data-table td { padding: 4px 6px !important; }
  .footer { border-top: 1px solid #ccc; margin-top: 16px; padding-top: 8px; font-size: 10px; color: #666; }
  .footer .build-stamp { color: #999; }
  /* Add a clear print header */
  body::before {
    content: "Excelergy Budget - printed snapshot";
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: #014BC1;
    padding: 0 0 12px;
    border-bottom: 2px solid #014BC1;
    margin-bottom: 16px;
  }
}

/* ── Blog post layout ──────────────────────────────────────────────────── */
main.blog-post {
  max-width: 720px; margin: 24px auto; padding: 0 24px 48px;
  font-size: 16px; line-height: 1.65; color: var(--text);
}
.blog-post .eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 8px; }
.blog-post h1 { font-size: clamp(28px, 3.5vw, 38px); letter-spacing: -.03em; line-height: 1.2; margin: 6px 0 12px; }
.blog-post .post-meta { color: var(--muted); font-size: 13px; font-weight: 600; margin: 0 0 28px; }
.blog-post h2 { font-size: 22px; letter-spacing: -.02em; margin: 32px 0 12px; color: var(--text); }
.blog-post h3 { font-size: 17px; margin: 24px 0 10px; color: var(--text); }
.blog-post p, .blog-post li { color: var(--text); }
.blog-post p { margin: 0 0 16px; }
.blog-post ul, .blog-post ol { margin: 0 0 16px; padding-left: 22px; }
.blog-post li { margin: 4px 0; }
.blog-post a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.blog-post a:hover { text-decoration: none; }
.blog-post hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.blog-post blockquote {
  margin: 18px 0; padding: 12px 18px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  color: var(--text); border-radius: 0 8px 8px 0;
}
.blog-post code {
  background: var(--card-solid); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border); font-size: 14px;
}
.blog-post .callout {
  margin: 22px 0; padding: 16px 18px;
  background: var(--card-solid); border: 1px solid var(--border);
  border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0;
  font-size: 14px;
}
.blog-post .callout strong { color: var(--primary); }
.blog-post .post-cta {
  margin: 36px 0 0; padding: 22px 24px;
  background: var(--primary-soft); border-radius: 12px;
  text-align: center;
}
.blog-post .post-cta h3 { margin: 0 0 8px; color: var(--primary); font-size: 18px; }
.blog-post .post-cta p { margin: 0 0 14px; font-size: 14px; color: var(--text); }
.blog-post .post-cta a {
  display: inline-block; padding: 10px 22px; border-radius: 999px;
  background: var(--primary); color: #fff !important; text-decoration: none;
  font-weight: 700;
}
.blog-post .back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-size: 13px; }

/* ── Everyday spending review panel ───────────────────────────────────── */
.everyday-summary {
  display: flex; flex-wrap: wrap; gap: 24px;
  padding: 14px 16px; border-radius: 10px;
  background: var(--bg-soft); margin-bottom: 12px;
}
.everyday-summary-label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
.everyday-summary-value {
  font-size: 22px; font-weight: 800; color: var(--text);
}
.everyday-summary-cats {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.everyday-cat-chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 700;
}
.everyday-pills {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin: 14px 0 4px;
}
.everyday-pill {
  padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card-solid);
  text-align: center;
}
.everyday-pill.current {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft);
}
.everyday-pill-label {
  font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 4px;
}
.everyday-pill-total {
  font-size: 16px; font-weight: 800; color: var(--text);
}
.everyday-pill-count {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

/* ── Build budget suggestion sections ─────────────────────────────────── */
.suggest-section {
  margin: 0 0 22px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-solid);
}
.suggest-section:last-child { margin-bottom: 0; }
.suggest-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 6px;
}
.suggest-section h4 {
  margin: 0; font-size: 15px; font-weight: 800; color: var(--text);
  letter-spacing: -0.01em;
}
.suggest-section-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  white-space: nowrap;
}
.suggest-table { font-size: 13px; margin-top: 8px; }
.suggest-table th { font-size: 11px; }
.suggest-table tr.suggest-in-plan {
  opacity: 0.55;
}
.suggest-table tr.suggest-in-plan input[type="text"],
.suggest-table tr.suggest-in-plan input[type="number"],
.suggest-table tr.suggest-in-plan select {
  background: var(--bg-soft);
}
.suggest-status {
  display: inline-block;
  font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
}
.suggest-status.new {
  background: #dcfce7; color: #15803d;
}
.suggest-status.in-plan {
  background: var(--bg-soft); color: var(--muted);
}
.suggest-type {
  display: inline-block;
  font-size: 10px; font-weight: 800; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary);
}
:root[data-theme="dark"] .suggest-status.new {
  background: rgba(21, 128, 61, .35); color: #86efac;
}
/* Merchant header rows are the "label/category/type" row; variant rows are
   one-per-distinct-amount underneath. Variant rows share borders with their
   merchant so the group reads as one block. */
.suggest-table tr.suggest-merchant-head td {
  border-top: 2px solid var(--border-strong);
}
.suggest-table tr.suggest-merchant-head:first-child td {
  border-top: none;
}
.suggest-table tr.suggest-variant td {
  border-top: 1px dashed var(--border);
  padding-top: 4px; padding-bottom: 4px;
}
/* Synthetic "Total / month" row on variable merchants - slightly tinted so
   the user can tell at a glance this is the aggregate, not one of the
   individual amount variants. */
.suggest-table tr.suggest-variant-total td {
  background: var(--primary-soft);
  border-top: 1px solid var(--primary);
}
:root[data-theme="dark"] .suggest-table tr.suggest-variant-total td {
  background: rgba(1, 75, 193, 0.18);
}

/* ── Export profile picker modal ─────────────────────────────────────── */
.export-overlay {
  position: fixed; inset: 0; z-index: 11000;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: export-fade-in 0.18s ease-out;
}
@keyframes export-fade-in { from { opacity: 0; } to { opacity: 1; } }
.export-card {
  background: var(--card-solid);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px;
}
.export-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.export-card p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.export-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 0;
}
.export-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.export-item:hover { border-color: var(--primary); }
.export-item input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary);
  flex-shrink: 0; cursor: pointer;
}
.export-item .export-name { flex: 1; min-width: 0; }
.export-item .export-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
  flex-shrink: 0;
}
.export-bulk-actions {
  display: flex; gap: 14px;
  margin: 10px 2px 0;
}
.export-link {
  background: none; border: 0; padding: 0; min-height: 0;
  font-size: 12px; font-weight: 700; color: var(--primary);
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.export-link:hover { text-decoration: none; }
.export-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
}
.export-actions button { min-width: 100px; }
.export-actions button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 540px) {
  .export-card { padding: 22px 18px; }
  .export-card h2 { font-size: 18px; }
  .export-actions { flex-direction: column-reverse; }
  .export-actions button { width: 100%; }
}

/* ── Inline help tooltips ──────────────────────────────────────────────
   Tiny "?" buttons next to confusing settings. Click toggles a popover;
   hover (on desktop) shows it transiently. Markup pattern is:
     <button class="help-tip" data-help="Explanation text...">?</button>
   The popover is built on-demand by app.js. */
.help-tip {
  /* Override the global button rule (min-height 40px + padding 0 16px)
     so this stays a perfect circle, not stretched to button height. */
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; min-height: 0; min-width: 0;
  padding: 0; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  border: 1px solid var(--primary-soft);
  font-size: 11px; font-weight: 800; font-family: inherit;
  cursor: pointer; vertical-align: middle; margin-left: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1;
  box-sizing: border-box;
}
.help-tip:hover, .help-tip.is-active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.help-tip-popover {
  position: absolute; z-index: 9500;
  max-width: 280px;
  padding: 12px 14px;
  background: var(--text); color: #fff;
  border-radius: 10px;
  font-size: 13px; line-height: 1.5; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  animation: help-tip-in 0.12s ease-out;
}
.help-tip-popover::before {
  content: ''; position: absolute; top: -6px; left: 18px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 6px solid var(--text);
}
@keyframes help-tip-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Friendly empty states ─────────────────────────────────────────────
   Used wherever a panel has no data yet. Replaces bare "no data" lines
   with a more inviting block + an action arrow back to the relevant input. */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 18px; text-align: center;
  color: var(--muted);
}
.empty-state .empty-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.empty-state h4 {
  font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 6px;
}
.empty-state p {
  font-size: 13px; line-height: 1.5; color: var(--muted); max-width: 380px; margin: 0 0 12px;
}
.empty-state .empty-cta {
  font-size: 13px; font-weight: 600; color: var(--primary);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.empty-state .empty-cta:hover { text-decoration: underline; }

/* ── PWA install banner (mobile only) ─────────────────────────────────── */
.pwa-install-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  z-index: 10500;
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px;
  background: var(--card-solid);
  border: 1px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  animation: pwa-install-in 0.22s ease-out;
}
@keyframes pwa-install-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pwa-install-leaving { animation: pwa-install-out 0.18s ease-in forwards; }
@keyframes pwa-install-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(12px); }
}
.pwa-install-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 10px;
}
.pwa-install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-install-text strong { font-size: 14px; color: var(--text); }
.pwa-install-text span   { font-size: 12px; color: var(--muted); line-height: 1.4; }
.pwa-install-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pwa-install-actions button {
  font-size: 12px; padding: 6px 12px; min-height: 0; width: auto;
  white-space: nowrap; font-weight: 700;
}
@media (max-width: 420px) {
  .pwa-install-banner { flex-wrap: wrap; }
  .pwa-install-actions { width: 100%; justify-content: flex-end; }
}

/* ── First-run onboarding overlay ──────────────────────────────────────── */
.onboard-overlay {
  position: fixed; inset: 0; z-index: 11000;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: onboard-fade-in 0.2s ease-out;
}
@keyframes onboard-fade-in { from { opacity: 0; } to { opacity: 1; } }
.onboard-card {
  background: var(--card-solid);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}
.onboard-card h2 {
  margin: 8px 0 12px;
  font-size: 24px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.onboard-card p {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}
.onboard-card p.muted { color: var(--muted); font-size: 13px; }
.onboard-progress {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 18px;
}
.onboard-dot {
  width: 24px; height: 6px; border-radius: 3px;
  background: var(--border); transition: background .2s;
}
.onboard-dot.is-active { background: var(--primary); }
.onboard-dot.is-done   { background: #86efac; }
.onboard-tabs {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border-radius: 10px;
  background: var(--primary-soft); margin: 14px 0;
  font-size: 13px; color: var(--text);
}
.onboard-tabs strong { color: var(--primary); font-weight: 800; }
.onboard-actions {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 22px;
}
.onboard-actions button { min-width: 100px; }
.onboard-cycle-label {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 14px; font-weight: 700; color: var(--text);
  padding: 14px; background: var(--primary-soft); border-radius: 10px;
  margin: 12px 0;
}
.onboard-cycle-label input {
  width: 68px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--card);
  color: var(--text); font-size: 16px; font-weight: 700; text-align: center;
}
.onboard-sample-grid {
  display: grid; gap: 10px; margin: 14px 0 0;
}
.onboard-sample-card {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); background: var(--card);
  color: var(--text); transition: border-color .15s, background .15s;
  width: 100%;
}
.onboard-sample-card:hover {
  border-color: var(--primary); background: var(--primary-soft);
}
.onboard-sample-card strong {
  display: block; font-size: 15px; margin-bottom: 4px; color: var(--text);
}
.onboard-sample-card span {
  font-size: 12px; color: var(--muted); font-weight: 500;
}
@media (max-width: 540px) {
  .onboard-card { padding: 22px 18px; }
  .onboard-card h2 { font-size: 20px; }
  .onboard-actions { flex-direction: column-reverse; }
  .onboard-actions button { width: 100%; }
}

/* "More from Excelergy" links in the footer */
.footer-suite { margin-top: 8px; font-size: 13px; line-height: 1.8; }
.footer-suite a { color: var(--primary); font-weight: 700; text-decoration: none; white-space: nowrap; }
