*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-background-primary: #f5f5f3;
  --color-background-secondary: #ffffff;
  --color-background-tertiary: #ececea;
  --color-text-primary: #1a1a18;
  --color-text-secondary: #5a5a57;
  --color-text-tertiary: #9a9995;
  --color-border-tertiary: #d8d8d5;
  /* Was referenced in budget.html, overview.html, index.html, settings.html,
     the tag-picker dropdown and the report modal but never defined, so every
     `border: Npx solid var(--color-border-secondary)` failed to parse and
     rendered as no border at all. One step stronger than tertiary. */
  --color-border-secondary: #c6c6c2;
  --color-accent: #2563eb;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --color-success: #16a34a;
  --radius-card: 12px;
  --radius-metric: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--color-background-primary);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding-left: 64px;
  padding-top: 48px;
}

/* ── TOP NAV (section page links) ── */
/* A file input hidden with display:none does not reliably receive a label tap
   on iOS Safari; take it out of layout without removing it from the a11y tree. */
/* The bug-report screenshot hint: a phone has no Cmd-V, so show a tap prompt
   there and the paste prompt on pointer devices. */
.hint-touch { display: none; }

.visually-hidden-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.top-nav {
  position: fixed;
  top: 0; left: 64px; right: 0;
  height: 48px;
  background: var(--color-background-secondary);
  border-bottom: 0.5px solid var(--color-border-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  z-index: 99;
}
.top-nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav-links::-webkit-scrollbar { display: none; }
.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding-left: 12px;
}
.top-nav-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  border: 0.5px solid var(--color-border-secondary);
  background: var(--color-background-primary);
  color: var(--color-text-secondary);
  font-family: inherit;
  transition: background .12s, color .12s;
}
.top-nav-action:hover { background: var(--color-background-tertiary); color: var(--color-text-primary); }
.top-nav-action-call { border-color: transparent; background: #25D366; color: #fff; }
.top-nav-action-call:hover { background: #1da851; color: #fff; }
.tna-icon { font-size: 13px; line-height: 1; }
.top-nav-link {
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.top-nav-link:hover { background: var(--color-background-tertiary); color: var(--color-text-primary); }
.top-nav-link.active { background: var(--color-background-tertiary); color: var(--color-text-primary); font-weight: 500; }

/* The WIMM wordmark in the middle of the top bar, only where there is room
   for it. nav.js marks the bar data-tabs="few" (one or two tabs) or "many"
   (Expenses' seven), and each gets its own width threshold. Once shown, the
   bar switches from flex to a three-column grid (tabs | wordmark | actions)
   whose side columns are equal, so the mark is centred, but never narrower
   than their content, so the tabs cannot slide under the mark even with a
   wider font: at worst it sits a little right of centre. The grid properties
   below are inert while the bar is flex. Below the thresholds (every phone)
   the mark is not rendered at all: no overlap, no wrap, no sideways scroll. */
.top-nav { grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr); }
.top-nav-actions { justify-self: end; }
.top-nav-brand {
  display: none;
  align-items: center;
  margin-inline: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--color-text-primary);
}
.top-nav-brand svg { display: block; width: 52px; height: 26px; }
.top-nav-brand:hover { background: var(--color-background-tertiary); }
.top-nav-brand:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
@media (min-width: 769px) {
  .top-nav[data-tabs="few"] { display: grid; }
  .top-nav[data-tabs="few"] .top-nav-brand { display: flex; }
}
/* Wide enough for every section, Expenses' seven tabs included. */
@media (min-width: 1280px) {
  .top-nav[data-tabs] { display: grid; }
  .top-nav[data-tabs] .top-nav-brand { display: flex; }
}

/* ── SIDEBAR NAV ── */
.nav {
  position: fixed;
  left: 0; top: 0;
  width: 64px; height: 100vh;
  background: var(--color-background-secondary);
  border-right: 0.5px solid var(--color-border-tertiary);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  flex-shrink: 0;
}
.sidebar-brand svg { display: block; width: 30px; height: 30px; }
.sidebar-items {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1;
}
.sidebar-divider {
  height: 0.5px;
  background: var(--color-border-tertiary);
  margin: 6px 10px;
}
.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--color-text-tertiary);
  border-radius: 8px;
  margin: 1px 6px;
  transition: background .12s, color .12s;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  background: none;
  width: calc(100% - 12px);
  position: relative;
}
.sidebar-item[data-importing] .sidebar-icon::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--color-background-primary, #fff);
  animation: import-pulse 1.2s ease-in-out infinite;
}
.sidebar-icon { position: relative; }
@keyframes import-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.sidebar-item:hover { background: var(--color-background-tertiary); color: var(--color-text-secondary); }
.sidebar-item.active { color: var(--color-text-primary); }
.sidebar-item.active .sidebar-icon {
  background: var(--color-text-primary);
  color: #fff;
}
.sidebar-icon {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
  background: var(--color-background-primary);
  flex-shrink: 0;
}
.sidebar-label {
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52px;
}
.sidebar-footer {
  border-top: 0.5px solid var(--color-border-tertiary);
  padding: 6px 0;
  flex-shrink: 0;
}

/* ── PAGE WRAPPER ── */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }

/* ── TOP BAR ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  padding: 6px 12px;
}
.month-nav button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.month-nav button:hover { color: var(--color-text-primary); }
.month-label { font-weight: 500; font-size: 14px; min-width: 100px; text-align: center; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  transition: background .12s;
  text-decoration: none;
}
.btn:hover { background: var(--color-background-tertiary); }
.btn-primary {
  background: var(--color-text-primary);
  color: #fff;
  border-color: var(--color-text-primary);
}
.btn-primary:hover { opacity: .88; background: var(--color-text-primary); }
.btn-danger { color: var(--color-danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── COMPACT ROW ACTIONS & INLINE INPUTS ──
   For actions that repeat on every row of a list (Edit, Deposit, Delete…)
   and for inputs that sit inside a row. The phone breakpoint below makes
   every .btn/.btn-sm a 40–44px box, which is right for a page's primary
   action ("+ Add …", Save, Submit) but turns a list into a stack of chunky
   buttons. Best practice (Apple HIG 44pt, Material 48dp) is a ≥44px *tap
   area*, not a 44px *visual* box — so these stay small to the eye and grow
   an invisible hit area with ::after.

     .btn-row   small outlined action: <button class="btn btn-row">Edit</button>
     .btn-link  text-only action, no box: <button class="btn-link">Delete</button>
                (add .btn-link-danger for a destructive one)
     .input-compact  inline input/select inside a row

   Rules for using them: never on a page's primary action; keep the boxes
   of two stacked actions at least (44 − button height)px apart — 14px for
   the 30px phone size — so their hit areas don't overlap (side by side,
   buttons ≥44px wide need only a normal gap); don't put them inside an
   overflow:hidden box (it clips the hit area). The hit area exists only
   where a finger can be the pointer (any-pointer: coarse); a mouse needs
   none. Works with or without .btn, on <button> and <a>. */
.btn-row, .btn-link {
  position: relative;          /* anchors the ::after hit area */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn.btn-row, .btn-row { min-height: 26px; padding: 3px 10px; border-radius: 6px; }
.btn-link {
  min-height: 26px;
  padding: 3px 6px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--color-text-secondary);
}
.btn-link:hover { background: var(--color-background-tertiary); color: var(--color-text-primary); }
.btn-link-danger { color: var(--color-danger); }
.btn-link-danger:hover { background: #fef2f2; color: var(--color-danger); }
/* Invisible hit area: at least 44×44, centred on the visual button. Each
   side reaches out by whatever the box is short of 44px (percentages of the
   button's own box) and never less than the 1px border. A tap on a
   pseudo-element hit-tests as the element itself, so handlers just work. */
@media (any-pointer: coarse) {
  .btn-row::after, .btn-link::after {
    content: "";
    position: absolute;
    top: min(-1px, calc(50% - 22px));
    bottom: min(-1px, calc(50% - 22px));
    left: min(-1px, calc(50% - 22px));
    right: min(-1px, calc(50% - 22px));
  }
}
.btn-row:focus-visible, .btn-link:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
/* Doubled class: must beat .field-input, which is declared further down. */
.input-compact.input-compact { padding: 4px 8px; min-height: 30px; font-size: 13px; }

/* ── CARDS ── */
.card {
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

/* ── METRIC CARDS ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--color-background-secondary);
  border-radius: var(--radius-metric);
  padding: 14px 16px;
  border: 0.5px solid var(--color-border-tertiary);
}
.metric-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 500; line-height: 1.2; overflow-wrap: break-word; }
.metric-sub { font-size: 12px; color: var(--color-text-secondary); margin-top: 3px; }
.metric-sub.up { color: var(--color-danger); }
.metric-sub.down { color: var(--color-success); }

/* ── BANNER ── */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.banner-warning {
  background: #fffbeb;
  border: 0.5px solid #fcd34d;
  color: #92400e;
}
.banner-danger {
  background: #fef2f2;
  border-left: 3px solid var(--color-danger);
  border-radius: 0 8px 8px 0;
  color: #7f1d1d;
}
.banner a { color: inherit; font-weight: 500; }

/* ── TWO-COL GRID ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }

/* ── CATEGORY LIST ── */
.category-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cat-name { flex: 1; font-size: 13px; color: var(--color-text-secondary); }
.cat-bar-wrap { width: 80px; height: 4px; background: var(--color-background-tertiary); border-radius: 2px; }
.cat-bar { height: 100%; border-radius: 2px; }
.cat-amount { font-size: 13px; font-weight: 500; min-width: 60px; text-align: right; }

/* ── TREND SPARKLINES ── */
.trend-list { display: flex; flex-direction: column; gap: 10px; }
.trend-row { display: flex; align-items: center; gap: 10px; }
.trend-name { flex: 1; font-size: 13px; color: var(--color-text-secondary); }
.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 28px; }
.trend-bar { width: 12px; border-radius: 2px 2px 0 0; background: var(--color-background-tertiary); }
.trend-badge { font-size: 12px; min-width: 20px; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.section-title { font-size: 13px; font-weight: 500; color: var(--color-text-secondary); }

/* ── FILTER CHIPS ── */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 0.5px solid var(--color-border-tertiary);
  background: var(--color-background-secondary);
  color: var(--color-text-secondary);
  transition: all .12s;
  white-space: nowrap;
}

.chip:hover { background: var(--color-background-tertiary); }
.chip.active { background: var(--color-text-primary); color: #fff; border-color: var(--color-text-primary); }

/* Inline tag pills on transaction/merchant rows. nowrap keeps a Hebrew tag
   from being split across lines in a narrow cell. */
.tag-pill {
  display: inline-block;
  background: var(--color-background-tertiary, #f3f4f6);
  color: var(--color-text-secondary);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  white-space: nowrap;
}

/* ── TRANSACTION ROWS ── */
.tx-list { display: flex; flex-direction: column; }
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  cursor: pointer;
  transition: background .1s;
  border-radius: 4px;
}
.tx-row:hover { background: var(--color-background-primary); padding-left: 6px; padding-right: 6px; }
.tx-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-merchant { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--color-text-tertiary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 14px; font-weight: 500; }
.tx-date { font-size: 12px; color: var(--color-text-tertiary); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;   /* keep "1/5" on one line — never wrap a badge */
}
.badge-foreign { background: #eff6ff; color: #1d4ed8; }
.badge-installment { background: #f5f3ff; color: #5b21b6; }
.badge-recurring { width: 6px; height: 6px; border-radius: 50%; background: var(--color-success); display: inline-block; }

/* ── INLINE EDIT PANEL ── */
.tx-expand {
  background: var(--color-background-primary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 8px;
  padding: 12px;
  margin: 4px 0 8px 44px;
  display: none;
}
.tx-expand.open { display: block; }
.expand-fields { display: flex; flex-direction: column; gap: 8px; }
.tx-edit-row td { padding: 10px 16px; background: var(--color-background-primary); }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-grid-4-wide { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 8px; align-items: end; margin-bottom: 8px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-grid-2fr1 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-bottom: 10px; }
.loan-progress-pad { padding: 0 44px 0 52px; }
.sf-field-amount { width: 120px; }
.sf-field-date { width: 130px; }
.field-label { font-size: 11px; color: var(--color-text-tertiary); }
.field-input, .field-select {
  padding: 5px 8px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 6px;
  font-size: 13px;
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  font-family: var(--font);
}
.field-input:focus, .field-select:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }

/* ── INSTALLMENTS TABLE ── */
/* The 5-column table overflows a narrow card (long Hebrew merchant names +
   shekel amounts), drifting off the box on mobile. Let it scroll inside the
   card instead: min-width keeps the columns readable, the wrapper scrolls. */
#inst-section { overflow-x: auto; }
.inst-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 13px; }
.inst-table th { color: var(--color-text-tertiary); font-weight: 500; text-align: left; padding: 6px 8px; border-bottom: 0.5px solid var(--color-border-tertiary); }
.inst-table td { padding: 8px; border-bottom: 0.5px solid var(--color-border-tertiary); }

/* ── COLLAPSIBLE ── */
.collapsible-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-family: var(--font);
}
.collapsible-btn:hover { color: var(--color-text-primary); }

/* ── FULL TABLE (transactions page) ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  color: var(--color-text-tertiary);
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.data-table th:hover { color: var(--color-text-primary); }
.data-table td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); vertical-align: middle; }
.data-table tr:hover td { background: var(--color-background-primary); }

/* ── SIDEBAR FILTERS ── */
.page-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 64px; }
.filter-section { margin-bottom: 16px; }
.filter-label { font-size: 11px; font-weight: 500; color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.filter-input {
  width: 100%;
  padding: 7px 10px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 7px;
  font-size: 13px;
  background: var(--color-background-secondary);
  color: var(--color-text-primary);
  font-family: var(--font);
}
.filter-input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.filter-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.filter-toggle input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; }

/* ── SETTINGS ── */
.settings-section { margin-bottom: 28px; }
.settings-title { font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.rule-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rule-table th, .rule-table td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border-tertiary); text-align: left; }
.rule-table th { color: var(--color-text-tertiary); font-weight: 500; }
.config-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 0.5px solid var(--color-border-tertiary); }
.config-label { flex: 1; font-size: 13px; }
.config-sub { font-size: 12px; color: var(--color-text-tertiary); }
.toggle-switch { position: relative; width: 36px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--color-border-tertiary);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-track { background: var(--color-text-primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; align-items: center; font-size: 13px; }
.page-info { color: var(--color-text-secondary); }

/* ── EMPTY STATE ── */
.empty { text-align: center; padding: 48px 20px; color: var(--color-text-tertiary); }
.empty p { margin-bottom: 12px; }

/* ── LOADING ── */
.loading { color: var(--color-text-tertiary); font-size: 13px; padding: 12px 0; }

/* ── OVERVIEW PAGE ── */
.ov-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.ov-hero-card {
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  padding: 20px 20px 16px;
  box-shadow: var(--shadow-card);
}
.ov-hero-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 6px; }
.ov-hero-value { font-size: 28px; font-weight: 500; line-height: 1.1; margin-bottom: 4px; overflow-wrap: break-word; }
.ov-hero-sub { font-size: 12px; color: var(--color-text-tertiary); }
.ov-flow-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ov-flow-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text-secondary); }
.ov-flow-icon { width: 26px; height: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.ov-flow-right { display: flex; align-items: center; gap: 8px; }
.ov-flow-amount { font-size: 14px; font-weight: 500; }
.ov-income { color: var(--color-success); }
.ov-expense { color: var(--color-danger); }
.ov-flow-bar-wrap { height: 5px; background: var(--color-background-tertiary); border-radius: 3px; margin-bottom: 4px; }
.ov-flow-bar { height: 100%; border-radius: 3px; }
.ov-bar-income { background: var(--color-success); }
.ov-bar-expense { background: var(--color-danger); }
.ov-flow-divider { height: 0.5px; background: var(--color-border-tertiary); margin: 12px 0; }
.ov-flow-result { font-size: 13px; font-weight: 500; color: var(--color-text-primary); }
.ov-coming-soon { font-size: 11px; color: var(--color-accent); text-decoration: none; cursor: pointer; }
.ov-coming-soon:hover { text-decoration: underline; }
.ov-link { font-size: 12px; color: var(--color-accent); text-decoration: none; margin-left: auto; }
.ov-link:hover { text-decoration: underline; }

/* ── Timeline ── */
.ov-timeline-card { margin-bottom: 16px; }
.ov-proj-legend { font-size: 11px; color: var(--color-text-tertiary); margin-left: auto; }
.ov-timeline {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.ov-tl-col {
  flex: 1;
  min-width: 100px;
  padding: 8px 10px;
  border-radius: 8px;
}
.ov-tl-col:hover { background: var(--color-background-primary); }
.ov-tl-future {
  background: var(--color-background-primary);
  border: 0.5px dashed var(--color-border-tertiary);
  opacity: 0.7;
}
.ov-tl-divider {
  width: 1px;
  background: var(--color-border-tertiary);
  margin: 0 4px;
  flex-shrink: 0;
  align-self: stretch;
}
.ov-tl-month {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.ov-tl-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--color-border-secondary);
  color: var(--color-text-tertiary);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
  font-size: 9px;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  cursor: help;
  position: relative;
  flex-shrink: 0;
}
.ov-tl-info-static { cursor: default; vertical-align: middle; }
/* The timeline scrolls on X, which clips overflow on both axes, so the tooltip
   drops down *into* the column (which has height to spare) and right-aligns to
   the icon — the estimated months sit at the right edge, where a centered tip
   would be clipped. */
.ov-tl-tip {
  position: absolute;
  top: calc(100% + 5px);
  right: -4px;
  width: 168px;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--color-text-primary);
  color: var(--color-background-primary);
  font-family: inherit;
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  line-height: 1.45;
  text-align: left;
  letter-spacing: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-3px);
  transition: opacity 0.13s ease, transform 0.13s ease;
  z-index: 30;
  pointer-events: none;
}
.ov-tl-info:hover .ov-tl-tip,
.ov-tl-info:focus .ov-tl-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.ov-tl-rows { display: flex; flex-direction: column; gap: 4px; }
.ov-tl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.ov-tl-label { font-size: 10px; color: var(--color-text-tertiary); white-space: nowrap; }
.ov-tl-val { font-size: 12px; font-weight: 500; white-space: nowrap; }
.ov-tl-income { color: var(--color-success); }
.ov-tl-expense { color: var(--color-text-primary); }
.ov-tl-bar-wrap { height: 3px; background: var(--color-background-tertiary); border-radius: 2px; margin: 3px 0; }
.ov-tl-bar { height: 100%; background: var(--color-danger); border-radius: 2px; opacity: 0.6; }
.ov-tl-net-row { border-top: 0.5px solid var(--color-border-tertiary); padding-top: 4px; margin-top: 2px; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--color-text-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--color-background-secondary);
  border-radius: var(--radius-card);
  padding: 20px;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
.modal h3 { font-size: 15px; font-weight: 500; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── SETTINGS TABS ── */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 0.5px solid var(--color-border-tertiary);
  padding-bottom: 0;
}
.settings-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--color-text-tertiary);
  padding: 8px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -0.5px;
  transition: color .15s, border-color .15s;
}
.settings-tab { flex: 0 0 auto; white-space: nowrap; }
.settings-tab:hover { color: var(--color-text-secondary); }
.settings-tab.active { color: var(--color-text-primary); border-bottom-color: var(--color-text-primary); }

/* ── TAG PICKER ── */
.tp-container { position: relative; }
.tp-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 28px; padding: 2px 0; }
.tp-chip { display: inline-flex; align-items: center; gap: 2px; background: #f3f4f6; border-radius: 4px; padding: 2px 6px 2px 8px; font-size: 12px; color: var(--color-text-secondary); }
.tp-chip-remove { background: none; border: none; cursor: pointer; color: var(--color-text-tertiary); padding: 0 2px; font-size: 15px; line-height: 1; display: flex; align-items: center; }
.tp-chip-remove:hover { color: var(--color-danger); }
.tp-add-btn { font-size: 11px; padding: 2px 8px; }
.tp-dropdown { min-width: 220px; background: var(--color-background-secondary); border: 0.5px solid var(--color-border-secondary); border-radius: var(--radius-card); box-shadow: 0 4px 16px rgba(0,0,0,.14); padding: 6px; }
.tp-list { max-height: 180px; overflow-y: auto; margin-top: 4px; }
.tp-item { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.tp-item:hover { background: var(--color-background-tertiary); }
.tp-item-selected { color: var(--color-accent); font-weight: 500; }
.tp-check { width: 14px; font-size: 11px; color: var(--color-success); flex-shrink: 0; }
.tp-create { color: var(--color-accent); font-style: italic; }
.tp-empty { padding: 8px 6px; color: var(--color-text-tertiary); font-size: 12px; }


/* ── DAILY CALENDAR ── */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-wday {
  text-align: center; font-size: 11px; color: var(--color-text-tertiary);
  padding: 4px 0; font-weight: 500;
}
.cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
  min-height: 56px; padding: 5px 4px 4px;
  border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .12s;
}
.cal-day:hover { background: var(--color-background-tertiary); }
.cal-day-empty { cursor: default; pointer-events: none; }
.cal-day-num {
  font-size: 12px; color: var(--color-text-tertiary); line-height: 1;
  font-weight: 400; align-self: flex-end; margin-right: 2px;
  width: 100%; text-align: right;
}
.cal-day-bubble {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-background-tertiary);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1px;
}
.cal-day-has-tx .cal-day-bubble {
  background: #fee2e2;
}
.cal-day-bubble-amt {
  font-size: 9px; font-weight: 600; color: var(--color-danger); line-height: 1;
}
.cal-day-bubble-count {
  font-size: 8px; color: var(--color-text-tertiary); line-height: 1;
}
.cal-day-today .cal-day-num { color: var(--color-accent); font-weight: 700; }
.cal-day-selected .cal-day-bubble {
  background: var(--color-text-primary) !important;
}
.cal-day-selected .cal-day-bubble-amt,
.cal-day-selected .cal-day-bubble-count {
  color: #fff !important;
}
.cal-day-selected .cal-day-num { color: var(--color-text-primary); font-weight: 600; }
.cal-day-selected { background: var(--color-background-tertiary); }

/* ── RESPONSIVE ── */
/* ══ Empty states (Phase 7, t7-9) ═══════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 20px;
  gap: 3px;
}
.es-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 6px;
  opacity: .75;
}
.es-title {
  font-size: 14px; font-weight: 600;
  color: var(--color-text-primary);
}
.es-sub {
  font-size: 12.5px; line-height: 1.55;
  color: var(--color-text-tertiary);
  max-width: 320px;
}
.es-action { margin-top: 12px; text-decoration: none; }

/* ══ Inline help (Phase 7, t7-7 / t7-8) ═════════════════════════════════ */

.help-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px;
  margin-left: 5px;
  padding: 0;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: 50%;
  background: none;
  color: var(--color-text-tertiary);
  font-size: 10px; font-weight: 600; line-height: 1;
  font-family: var(--font);
  cursor: pointer;
  vertical-align: middle;
  transition: color .12s, border-color .12s, background .12s;
}
.help-dot:hover {
  color: var(--color-text-primary);
  border-color: var(--color-text-secondary);
  background: var(--color-background-tertiary);
}
.help-pop {
  position: fixed;
  z-index: 1200;
  width: min(300px, calc(100vw - 16px));
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
  padding: 12px 14px;
}
.help-pop-title {
  font-size: 13px; font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 5px;
}
.help-pop-body {
  font-size: 12.5px; line-height: 1.55;
  color: var(--color-text-secondary);
}

/* ══ Onboarding, tour, and what's-next (Phase 7) ══════════════════════════ */

body.ob-open { overflow: hidden; }

.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .55);
  overflow-y: auto;
}
.ob-card {
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 460px;
  padding: 22px 24px 18px;
  margin: auto;
}
.ob-dots { display: flex; gap: 6px; margin-bottom: 16px; }
.ob-dot {
  height: 3px; flex: 1;
  border-radius: 2px;
  background: var(--color-border-tertiary);
  transition: background .2s;
}
.ob-dot.is-active { background: var(--color-text-primary); }
.ob-dot.is-done { background: var(--color-text-tertiary); }

.ob-icon { font-size: 26px; line-height: 1; margin-bottom: 10px; }
.ob-title {
  font-size: 17px; font-weight: 600; line-height: 1.3;
  margin: 0 0 10px; color: var(--color-text-primary);
  text-wrap: balance;
}
.ob-body { font-size: 13px; line-height: 1.6; color: var(--color-text-secondary); }
.ob-body p { margin: 0 0 10px; }
.ob-body p:last-child { margin-bottom: 0; }
.ob-muted { color: var(--color-text-tertiary); font-size: 12px; }
.ob-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--color-background-tertiary);
  padding: 1px 5px; border-radius: 4px;
}
.ob-list { margin: 0 0 10px; padding-left: 18px; }
.ob-list li { margin-bottom: 5px; }

.ob-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.ob-spacer { flex: 1; }
.ob-skip { color: var(--color-text-tertiary); }
.ob-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Upload step */
.ob-drop {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 1.5px dashed var(--color-border-secondary);
  border-radius: 10px;
  padding: 26px 16px;
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.ob-drop:hover, .ob-drop.is-over {
  border-color: var(--color-text-secondary);
  background: var(--color-background-tertiary);
}
.ob-drop-icon { font-size: 20px; }
.ob-drop-main { font-size: 13px; font-weight: 500; color: var(--color-text-primary); }
.ob-drop-sub { font-size: 12px; color: var(--color-text-tertiary); }

.ob-progress { padding: 8px 0; }
.ob-progress-bar {
  height: 5px; border-radius: 3px;
  background: var(--color-background-tertiary);
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%; width: 0;
  background: var(--color-text-primary);
  border-radius: 3px;
  transition: width .4s ease;
}
.ob-progress-text {
  font-size: 12px; color: var(--color-text-tertiary);
  margin-top: 8px; text-align: center;
}
.ob-error {
  font-size: 12px; color: var(--color-danger, #c00);
  margin-top: 10px; line-height: 1.5;
}

.ob-result { text-align: center; padding: 12px 0; }
.ob-result-icon { font-size: 26px; margin-bottom: 8px; }
.ob-result-main { font-size: 15px; font-weight: 600; color: var(--color-text-primary); }
.ob-result-sub {
  font-size: 12px; color: var(--color-text-tertiary);
  margin-top: 5px; line-height: 1.6;
}

/* Tour spotlight */
.ob-spotlit {
  position: relative;
  z-index: 1001;
  border-radius: 8px;
  /* The ring doubles as the dimmer for everything else on the page. */
  box-shadow: 0 0 0 4px var(--color-background-secondary),
              0 0 0 6px var(--color-text-primary),
              0 0 0 9999px rgba(0, 0, 0, .55);
}
.ob-tour { position: fixed; inset: 0; z-index: 1002; pointer-events: none; }
.ob-tour-card {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  pointer-events: auto;
  background: var(--color-background-secondary);
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 12px;
}
.ob-tour-step {
  font-size: 11px; color: var(--color-text-tertiary);
  margin-bottom: 4px; letter-spacing: .02em;
}
.ob-tour-title { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.ob-tour-body { font-size: 12.5px; line-height: 1.55; color: var(--color-text-secondary); }
.ob-tour-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

/* What's next card */
.wn-card { margin-bottom: 12px; }
.wn-head { display: flex; align-items: center; margin-bottom: 10px; }
.wn-head .section-title { flex: 1; }
.wn-close {
  background: none; border: 0; cursor: pointer;
  font-size: 18px; line-height: 1;
  color: var(--color-text-tertiary);
  padding: 2px 6px; border-radius: 4px;
  min-width: 32px; min-height: 32px;
}
.wn-close:hover { background: var(--color-background-tertiary); color: var(--color-text-primary); }
.wn-items { display: flex; flex-direction: column; gap: 2px; }
.wn-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 8px; border-radius: 8px;
  text-decoration: none; color: inherit;
  transition: background .12s;
}
.wn-item:hover { background: var(--color-background-tertiary); }
.wn-num {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--color-background-tertiary);
  color: var(--color-text-secondary);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
.wn-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.wn-sub { font-size: 12px; color: var(--color-text-tertiary); line-height: 1.5; }
.wn-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 12px; padding-top: 10px;
  border-top: 0.5px solid var(--color-border-tertiary);
  font-size: 12px;
}
.wn-foot a, .wn-link {
  color: var(--color-text-tertiary);
  text-decoration: none;
  background: none; border: 0; padding: 0;
  font: inherit; font-size: 12px; cursor: pointer;
}
.wn-foot a:hover, .wn-link:hover { color: var(--color-text-primary); text-decoration: underline; }
.wn-dot { color: var(--color-text-tertiary); }

/* ── Onboarding: the three-things plan, fields, how-to, summary ── */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.ob-eyebrow {
  font-size: 11px; font-weight: 500; letter-spacing: .03em;
  color: var(--color-text-tertiary); margin-bottom: 4px;
}
.ob-plan { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ob-plan-item { display: flex; gap: 10px; align-items: flex-start; }
.ob-plan-num, .setup-mark {
  flex: 0 0 auto;
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: var(--color-background-tertiary);
  color: var(--color-text-secondary);
}
.ob-plan-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ob-plan-text strong { color: var(--color-text-primary); font-weight: 600; }
.ob-plan-why { font-size: 12.5px; color: var(--color-text-tertiary); line-height: 1.45; }

.ob-fields { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.ob-field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 14px; color: var(--color-text-primary);
}
.ob-field-label { min-width: 0; }
.ob-field-input { display: flex; align-items: center; gap: 6px; flex: 0 1 170px; min-width: 0; }
.ob-field-input .field-input { width: 100%; text-align: right; font-size: 15px; padding: 7px 10px; }

.ob-how {
  margin-top: 14px;
  border-top: 0.5px solid var(--color-border-tertiary);
  padding-top: 10px;
}
.ob-how summary {
  cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--color-accent);
  min-height: 32px; display: flex; align-items: center;
}
.ob-how[open] summary { margin-bottom: 6px; }
.ob-files { list-style: none; margin: 0 0 10px; padding: 0; }
.ob-file-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 0; min-width: 0; }
.ob-file-tick { color: var(--color-success); font-weight: 600; }
.ob-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-primary); }
.ob-file-count { color: var(--color-text-tertiary); white-space: nowrap; }

.ob-sum { display: flex; flex-direction: column; border: 0.5px solid var(--color-border-tertiary); border-radius: 10px; }
.ob-sum-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 10px 12px; font-size: 13px;
}
.ob-sum-row + .ob-sum-row { border-top: 0.5px solid var(--color-border-tertiary); }
.ob-sum-row strong { font-size: 16px; color: var(--color-text-primary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ob-sum-row.is-missing > span:last-child { color: var(--color-text-tertiary); font-size: 12px; text-align: right; }
.ob-sum-row strong.ob-pos { color: var(--color-success); }
.ob-sum-row strong.ob-neg { color: var(--color-danger); }

/* ── Setup checklist card (Overview / Expenses / Income) ── */
.setup-card { margin-bottom: 12px; }
.setup-head { display: flex; align-items: flex-start; gap: 10px; }
.setup-head-text { flex: 1; min-width: 0; }
.setup-title { font-size: 15px; font-weight: 600; color: var(--color-text-primary); }
.setup-sub { font-size: 12px; color: var(--color-text-tertiary); margin-top: 2px; line-height: 1.45; }
.setup-hide { color: var(--color-text-tertiary); }
.setup-bar {
  height: 4px; border-radius: 2px; margin: 10px 0 6px;
  background: var(--color-background-tertiary); overflow: hidden;
}
.setup-bar > span { display: block; height: 100%; background: var(--color-success); border-radius: 2px; transition: width .3s; }
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; min-height: 48px;
}
.setup-item + .setup-item { border-top: 0.5px solid var(--color-border-tertiary); }
.setup-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.setup-item-title { font-size: 13.5px; font-weight: 500; color: var(--color-text-primary); }
.setup-why { font-size: 12px; color: var(--color-text-tertiary); line-height: 1.4; }
.setup-go { flex: 0 0 auto; min-width: 72px; }
.setup-done { flex: 0 0 auto; font-size: 12px; color: var(--color-success); font-weight: 500; min-width: 72px; text-align: center; }
.setup-item.is-done .setup-mark { background: var(--color-success); color: #fff; }
.setup-item.is-done .setup-item-title { color: var(--color-text-secondary); }

/* ── Overview "Today" card: how much you have + this month so far ── */
.ov-today { margin-bottom: 12px; }
.ov-today-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ov-today-date { font-size: 12px; color: var(--color-text-tertiary); }
.ov-today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.ov-today-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 2px; }
.ov-today-value { font-size: 28px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ov-today-sub { font-size: 12px; color: var(--color-text-tertiary); margin-top: 3px; line-height: 1.45; }
.ov-today-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.ov-today-stat { background: var(--color-background-primary); border-radius: var(--radius-metric); padding: 8px 10px; min-width: 0; }
.ov-today-stat span { display: block; font-size: 11px; color: var(--color-text-tertiary); }
.ov-today-stat strong { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ov-today-note { font-size: 12px; color: var(--color-text-tertiary); margin-top: 8px; line-height: 1.5; }
.ov-today-note:empty { display: none; }
/* Doubled class: must beat the phone .btn-link.btn-link sizing further down. */
.ov-today .btn-link.btn-link { color: var(--color-accent); padding: 0; min-height: 0; font-size: inherit; vertical-align: baseline; }
.ov-today-hint { padding: 4px 0; }

@media (max-width: 768px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  body { padding-left: 0; padding-top: 48px; padding-bottom: 64px; }
  .page { padding: 16px 12px 64px; }
  .nav {
    width: 100%; height: 64px;
    top: auto; bottom: 0; left: 0;
    flex-direction: row;
    border-right: none;
    border-top: 0.5px solid var(--color-border-tertiary);
    overflow-x: auto; overflow-y: hidden;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .top-nav { left: 0; padding: 0 12px; }
  .top-nav-links {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  /* Labels cost too much width on a phone; the icons carry the meaning. */
  .top-nav-action { padding: 7px 9px; }
  .top-nav-actions { gap: 6px; padding-left: 8px; }
  .tna-label { display: none; }
  .tna-icon { font-size: 15px; }

  .hint-pointer { display: none; }
  .hint-touch { display: inline; }

  /* Onboarding: the card is the whole screen's worth of content on a phone. */
  .ob-overlay { padding: 12px; align-items: flex-start; }
  .ob-card { padding: 18px 16px 14px; max-width: 100%; margin-top: 12px; }
  .ob-title { font-size: 16px; }
  .ob-actions { flex-wrap: wrap; row-gap: 8px; }
  .ob-actions .btn { min-height: 44px; }
  /* 16px stops iOS zooming into the field on focus. */
  .ob-field-input .field-input { font-size: 16px; }
  .ob-how summary { min-height: 44px; }
  .btn.setup-go { min-height: 44px; }
  .ov-today-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ov-today-value { font-size: 24px; }
  .ov-today-stat { padding: 7px 8px; }
  .ov-today-stat strong { font-size: 14px; }
  /* Full-width on its own line, but as a quiet text link — a bordered
     full-width button reads as the primary action, which it is not. */
  .ob-skip {
    order: 3; width: 100%;
    border: none; background: none;
    text-align: center;
    min-height: 36px;
  }
  .ob-skip:hover { background: none; text-decoration: underline; }
  .ob-drop { padding: 22px 12px; }
  .ob-tour-card { width: calc(100vw - 24px); padding: 12px 14px 10px; }
  .wn-item { padding: 10px 8px; }

  /* A 15px circle is too small to tap; grow the hit area without growing
     the visible dot by much. */
  .help-dot { width: 20px; height: 20px; font-size: 11px; margin-left: 6px; }
  .empty-state { padding: 24px 14px; }

  /* Seven tabs need ~620px in a 390px viewport, and iOS draws no scrollbar,
     so fade whichever edge still has tabs behind it. nav.js toggles these
     classes from scrollLeft. */
  .top-nav-links.scroll-end:not(.scroll-start) {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .top-nav-links.scroll-start:not(.scroll-end) {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px);
            mask-image: linear-gradient(to right, transparent, #000 28px);
  }
  .top-nav-links.scroll-start.scroll-end {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  }

  /* Six settings tabs never fit a phone; scroll the strip instead of letting
     it push the whole page wider than the viewport. */
  .settings-tabs {
    overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 14px;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab { padding: 8px 12px; }

  /* min-width:320px + the overlay's own padding overflows the narrowest
     phones (320px viewports). */
  .modal { min-width: 0; width: calc(100% - 32px); max-width: 480px; padding: 16px; }
  .form-grid-2fr1 { grid-template-columns: minmax(0, 1fr); }

  /* Calendar: the 36px bubble plus cell padding forced the 7 tracks wider
     than the card on narrow phones. Scale the bubble with the viewport. */
  .cal-days { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
  .cal-day { padding: 4px 1px 3px; min-height: 52px; }
  .cal-day-bubble { width: clamp(26px, 8.5vw, 36px); height: clamp(26px, 8.5vw, 36px); }
  .top-nav-link { padding: 12px 12px; font-size: 14px; }
  .sidebar-brand { display: none; }
  .sidebar-items { flex-direction: row; padding: 0; flex: 1; }
  .sidebar-divider { display: none; }
  .sidebar-footer { border-top: none; border-left: 0.5px solid var(--color-border-tertiary); padding: 0; display: flex; align-items: center; }
  /* Bottom bar: let the 7 sections share the width evenly so nothing truncates,
     with the settings gear keeping its own fixed slot in the footer. */
  .sidebar-item { flex: 1 1 0; min-width: 0; margin: 0; padding: 4px 1px; min-height: 44px; justify-content: center; }
  .sidebar-footer .sidebar-item { flex: 0 0 auto; width: 44px; }
  .sidebar-icon { width: 28px; height: 28px; font-size: 14px; }
  .sidebar-label { max-width: 100%; font-size: 8px; letter-spacing: 0; }

  /* Touch targets ≥44px */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  select, input[type="text"], input[type="date"], input[type="number"], input[type="color"] { min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; }
  /* …except the compact row actions/inputs (see "COMPACT ROW ACTIONS"):
     small to the eye, but their ::after keeps a ≥44px tap area. The doubled
     class outranks the .btn / .btn-sm / input rules above. */
  .btn.btn-row, .btn-row.btn-row { min-height: 30px; padding: 5px 12px; font-size: 12px; }
  .btn-link.btn-link { min-height: 30px; padding: 5px 8px; font-size: 12px; }
  /* 16px stops iOS Safari zooming the page when the field is focused.
     An input can't carry ::after, so it keeps a 36px box (the smallest
     that still takes a thumb comfortably inside a row). */
  .input-compact.input-compact { min-height: 36px; padding: 6px 8px; font-size: 16px; }

  /* Compactness: tighter card padding + grid gaps on mobile */
  .card { padding: 12px 14px; margin-bottom: 10px; }
  .metric-card { padding: 10px 12px; }
  .ov-hero-card { padding: 12px 14px 10px; }
  .metrics-grid, .ov-hero { gap: 8px; margin-bottom: 10px; }

  /* Month-by-month strip: narrower columns fit ~4 months per screen instead
     of 3, and it is already scrolled to the most recent month on load. */
  .ov-tl-col { min-width: 88px; padding: 8px 7px; }
  .ov-tl-label { font-size: 9px; }
  .ov-tl-val { font-size: 11px; }
  .ov-timeline-card { margin-bottom: 10px; }

  /* Big currency values must fit one line — at desktop sizes they wrap
     mid-number inside a 2-col mobile grid (₪-24,337.3 / 2). */
  .ov-hero-value { font-size: 20px; }
  .metric-value { font-size: 18px; }
  .ov-hero-label, .metric-label { font-size: 11px; }
  .ov-hero-sub, .metric-sub { font-size: 11px; }
  .section-title { font-size: 13px; }

  /* Generic form grids used by inline-styled pages (loans/assets add-forms) */
  .form-grid-4, .form-grid-4-wide, .form-grid-2 { grid-template-columns: minmax(0, 1fr); }
  /* Form fields must be allowed to shrink below their intrinsic width, or a
     grid/flex track floors at min-content and overflows a narrow screen. */
  .field-group { min-width: 0; }
  .field-input { min-width: 0; max-width: 100%; }

  /* Transaction-style list rows (income/loans/assets/dashboard) — wrap trailing
     content to its own line instead of squeezing tx-info to nothing */
  .tx-row { flex-wrap: wrap; row-gap: 4px; }
  .tx-info { min-width: 140px; }
  .tx-right { margin-left: auto; }

  /* Income top bar: month nav on its own full-width row, stats packed into a
     compact left-aligned row underneath instead of one stat per line. */
  .top-bar { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .month-nav { flex: 1 1 100%; justify-content: center; }
  .stat-row-wrap {
    margin-left: 0 !important;
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 14px !important;
    row-gap: 8px;
  }
  .stat-row-wrap .stat-item { align-items: flex-start !important; }
  .stat-divider { display: none !important; }
  .flex-row-wrap { flex-wrap: wrap; row-gap: 6px; }
  .flex-row-wrap > *:last-child { margin-left: auto; }

  /* Loan progress bar — fixed 96px of side padding doesn't fit mobile */
  .loan-progress-pad { padding: 0 clamp(8px, 3vw, 44px) 0 clamp(8px, 3vw, 52px); }
  .loan-progress-meta { flex-direction: column; gap: 1px; }

  /* Page header totals (Loans/Assets) — 20px pushes to the edge at 390px */
  .page-total-value { font-size: 17px !important; }

  /* Sinking-fund Deposit/Withdraw form — fixed-width fields don't fit mobile
     (budget page; the Assets page lays its copy out itself) */
  .sf-form-row { flex-wrap: wrap; row-gap: 8px; }
  .sf-field-amount, .sf-field-date { width: auto; flex: 1 1 45%; min-width: 100px; }

  /* Settings tables (rules/merchants/tags/categories/accounts) — scroll rather than clip */
  .rule-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Transaction table → stacked cards */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    margin-bottom: 10px;
    border: 0.5px solid var(--color-border-tertiary);
    border-radius: var(--radius-card);
    padding: 10px 12px;
    background: var(--color-background-secondary);
  }
  .data-table tr:hover td { background: none; }
  .data-table tr.tx-edit-row { border: none; padding: 0; background: none; margin-bottom: 0; }
  .data-table td {
    border-bottom: none;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--color-text-tertiary);
    flex-shrink: 0;
  }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Onboarding: the statements imported so far ── */
/* Onboarding asks for three months, so the list has to show which ones
   already landed rather than replacing the drop zone with a single result. */
.ob-files {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ob-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--color-background-secondary, #f5f5f3);
  font-size: 13px;
}
.ob-file-tick { color: var(--color-success, #009970); font-weight: 600; }
.ob-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ob-file-count {
  color: var(--color-text-tertiary, #999);
  font-size: 12px;
  white-space: nowrap;
}
