/* Shared components (design handoff 2026-10-05). Each component is defined once, here; style.css keeps only
   page- and feature-specific layout. Loaded after style.css, so a component wins over an older page rule of the
   same weight. The legacy class names that JS builds (.dup-btn, .table-section, .card, .owner-filter …) are
   listed next to the new ones, so no script had to change to get the new look.
   Colours, fonts, radii and shadows: tokens.css only. Motion: 150ms on background / border, nothing else. */

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  /* Numbers line up in every table and KPI (the Money rule). */
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { font-family: var(--font); color: var(--heading); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-tint); }
kbd {
  font: inherit;
  font-size: 11px;
  line-height: 1.5;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-body);
  white-space: nowrap;
}
.icon { flex: none; vertical-align: middle; }
.muted { color: var(--text-muted); }
/* Amounts, dates, counts: left-to-right, aligned to the left edge of their column (RTL page). */
.num, td.num, th.num { direction: ltr; text-align: left; white-space: nowrap; }
main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

/* ---------- Header (sticky) ---------- */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: block;
  padding: 0;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header-in {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: inherit; text-decoration: none; min-width: 0; }
.app-header .brand:focus-visible { border-radius: var(--radius); }
/* The logo (logo.svg: its own indigo tile, so no background here). */
.brand-mark {
  flex: none;
  display: block;
  width: 32px;
  height: 32px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name { font-weight: 600; font-size: 16px; color: var(--text); white-space: nowrap; }
.app-header .brand-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
.app-header .page-nav { display: flex; flex-wrap: wrap; gap: 4px; overflow: visible; }
.app-header .page-nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-body);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast);
}
.app-header .page-nav a:hover { background: var(--surface-sub); color: var(--text); }
.app-header .page-nav a.active { background: var(--surface-sub); color: var(--text); font-weight: 500; }
.app-header .header-actions { margin-inline-start: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.search-trigger {
  height: 36px;
  min-width: 230px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast);
}
.search-trigger:hover { background: var(--surface-sub); }
.search-trigger-label { flex: 1; text-align: right; }
.save-status {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-strong-body);
  white-space: nowrap;
}
.save-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--income); box-shadow: 0 0 0 3px var(--income-tint); flex: none; }
.save-status-demo .save-status-dot { background: var(--text-faint); box-shadow: 0 0 0 3px var(--surface-sub); }
/* Square icon buttons in the header (eye, decisions, report, settings, menu). */
.settings-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-strong-body);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.settings-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
.settings-btn:hover { background: var(--surface-sub); color: var(--text); border-color: var(--border); }
.settings-btn.active,
.settings-btn[aria-pressed="true"],
body.privacy-on #privacy-btn { background: var(--row-selected); color: var(--accent); border-color: var(--border-strong); }
/* Pending decisions = needs attention: amber, never red. */
.decisions-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--attention);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
/* Desktop: the top navigation. Below 1000px the pages move to the side drawer (sidemenu.js, three-dots button). */
.menu-btn { display: none; }
@media (max-width: 999px) {
  .app-header .page-nav { display: none; }
  .menu-btn { display: inline-grid; }
  .search-trigger { min-width: 0; }
  .search-trigger-label { display: none; }
  .save-status-text { display: none; }
  .save-status { padding: 0 11px; }
}
@media (max-width: 640px) {
  .app-header-in { padding: 8px 12px; gap: 8px; }
  .app-header .brand-sub { display: none; }
  /* A phone has no Ctrl key, and at 320px the hint pushed the header 21px past the screen (UX round 11, R11-04). */
  .search-trigger kbd { display: none; }
  .search-trigger { justify-content: center; padding: 0; }
  .app-header .header-actions { gap: 4px; }
  main { padding: 16px 12px 48px; }
  .save-status { display: none; }
}
@media (pointer: coarse), (max-width: 640px) {
  .settings-btn, .search-trigger { min-width: 44px; height: 44px; }
  .settings-btn { width: 44px; }
}

/* ---------- PageHeader ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 0 24px;
  padding: 16px 20px;
  background: var(--surface-head);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.page-head h1 { margin: 0; font-size: var(--fs-h1); font-weight: 600; letter-spacing: -0.01em; color: var(--heading); line-height: 1.3; }
.page-head p { margin: 2px 0 0; color: var(--text-body); } /* muted is under 4.5:1 on this band */
.page-head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.page-head-meta { font-size: 13px; color: var(--text-body); white-space: nowrap; }
.page-head-meta strong { color: var(--text); font-weight: 500; }

/* ---------- Card ---------- */
.table-section,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 24px;
  box-shadow: none;
  overflow-x: auto;
  overflow-y: hidden;
}
.table-section:hover { box-shadow: none; }
/* The card header is a full-width band on top of the card. */
.table-section > h2,
.panel > h2,
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: -16px -20px 16px;
  padding: 12px 20px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border);
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--heading);
  line-height: 1.4;
}
/* On the grey band --text-muted is 4.3:1, under the 4.5:1 floor: secondary text there is --text-body (7:1). */
.table-section > h2 .section-note,
.panel > h2 .section-note,
.card-head .section-note { font-size: 12px; font-weight: 400; color: var(--text-body); }
.card-head-end { margin-inline-start: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* A card's own table runs edge to edge, like the design (rows 11px 20px). */
.table-section > table,
.table-section > .table-wrap,
.panel > table,
.panel > .table-wrap { width: calc(100% + 40px); max-width: none; margin-inline: -20px; }
.table-section > table th:first-child, .table-section > table td:first-child,
.table-section > .table-wrap th:first-child, .table-section > .table-wrap td:first-child,
.panel > table th:first-child, .panel > table td:first-child { padding-inline-start: 20px; }
.table-section > table th:last-child, .table-section > table td:last-child,
.table-section > .table-wrap th:last-child, .table-section > .table-wrap td:last-child,
.panel > table th:last-child, .panel > table td:last-child { padding-inline-end: 20px; }
.section-note { font-size: 12px; font-weight: 400; color: var(--text-muted); }
/* A table that ends the card ends it: no empty strip under the last row. */
.table-section > table:last-child, .panel > table:last-child { margin-bottom: -16px; }
.table-section > table:last-child tbody tr:last-child td, .panel > table:last-child tbody tr:last-child td { border-bottom: 0; }
/* No colour chips in card headers: the icon spans of the old design stay hidden until each page drops them. */
.table-section > h2 > .section-icon { display: none; }

/* A note inside a card: neutral; .note-attention when it really needs attention. */
.note {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-sub);
  color: var(--text-strong-body);
  font-size: 13px;
}
.note-attention { background: var(--attention-bg); border: 1px solid var(--attention-border); color: var(--attention-text); }

/* ---------- KpiCard ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  gap: 16px;
  margin: 0 0 24px;
}
.card {
  position: relative;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius);
  box-shadow: var(--shadow-kpi);
  transition: border-color var(--t-fast);
}
.card::before { content: none; }
.card:hover { box-shadow: var(--shadow-kpi); transform: none; }
.card-label { order: 0; margin: 0; padding-inline-end: 24px; font-size: 13px; font-weight: 400; color: var(--text-muted); }
/* The icon sits at the end of the label row (top left in RTL), muted, 16px. */
.card-icon {
  position: absolute;
  top: 20px;
  inset-inline-end: 20px;
  width: 16px;
  height: 16px;
  margin: 0;
  display: grid;
  place-items: center;
  background: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 0;
}
.card-icon svg { width: 16px; height: 16px; }
.card-icon.income { color: var(--income); }
.card-icon.expense { color: var(--expense); }
.card-value {
  font-size: var(--fs-kpi);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
  overflow-wrap: anywhere;
}
.card-value.positive { color: var(--income); }
.card-value.negative { color: var(--expense); }
.card-value.attention { color: var(--attention); }
.card-sub { margin: 0; font-size: 12px; color: var(--text-muted); }
.card-sub.card-warning { color: var(--attention-text); font-weight: 500; }
.card-sub.card-warning.freshness-old { color: var(--expense); } /* a figure past the red threshold (M3) */
.card-subs { display: flex; flex-direction: column; gap: 2px; }
.card-sub-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 8px; font-size: 12px; color: var(--text-muted); }
/* KPI cards that are links (overview tiles). */
.card-link { color: inherit; text-decoration: none; cursor: pointer; }
.card-link:hover { color: inherit; border-color: var(--border); }
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-link-arrow { display: none; }
@media (max-width: 999px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Money ---------- */
.money { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.money-cur, .money-dec { font-size: 0.62em; font-weight: 500; color: var(--text-muted); }
.money-cur { margin-inline-end: 1px; }
body.privacy-on .amount-income,
body.privacy-on td.positive { color: var(--text-muted); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; border-spacing: 0; font-size: var(--fs-table); }
th, td {
  padding: 11px 12px;
  text-align: right;
  border-bottom: 1px solid var(--row-line);
  white-space: nowrap;
  vertical-align: middle;
}
th {
  padding-block: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--border);
}
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: 1px solid var(--row-line); }
th.sortable-th { cursor: pointer; user-select: none; }
th.sortable-th:hover, th.sortable-th-active { color: var(--text); }
/* Income is green in a row; an expense is plain text (red is for KPIs, totals and errors only). */
td.positive, .amount-income { color: var(--income); font-weight: 500; }
td.negative, .amount-expense { color: var(--text); font-weight: 500; }
/* A negative total or summary may be red (red = expense in KPIs, totals and errors only). */
.amount-total-negative { color: var(--expense); font-weight: 600; }
/* Internal transfers and card charges already counted elsewhere: muted, not in the totals. */
td.amount-muted, .amount-muted { color: var(--text-muted); font-weight: 400; }
tr.group-row > td {
  background: var(--group-row);
  color: var(--heading);
  font-size: var(--fs-table);
  font-weight: 600;
  cursor: pointer;
}
tr.group-row:hover > td { background: var(--group-row-hover); }
tr.group-gap > td { height: 8px; padding: 0; border: 0; background: var(--surface); }
tr.row-selected > td { background: var(--row-selected); }
tr.row-pending > td { background: var(--attention-row); }
.table-foot,
tfoot td {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface-foot);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
tfoot td { display: table-cell; }
.table-foot strong, tfoot strong { color: var(--text); font-weight: 600; }
.table-wrap { overflow-x: auto; overflow-y: hidden; }
/* Loading skeleton for a table that is still being read. */
.skeleton { display: block; height: 12px; border-radius: 4px; background: var(--surface-sub); }

/* ---------- Chip (filter) ---------- */
.chip,
.owner-filter button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-strong-body);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.chip:hover,
.owner-filter button:hover { background: var(--surface-sub); border-color: var(--border); }
.chip.active,
.chip[aria-pressed="true"],
.owner-filter button.active { background: var(--chip-on); border-color: var(--chip-on); color: var(--on-accent); }
.chip-count { font-size: 11px; opacity: 0.75; }
.owner-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }

/* ---------- Segmented ---------- */
.seg,
.view-toggle,
.chart-range-row,
.dc-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  width: auto;
  max-width: 100%;
  padding: 3px;
  margin: 0 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* no lenses yet: an empty row drew a small empty pill (UX round 4) */
.chart-range-row:empty { display: none; }
.seg button,
.view-toggle button,
.chart-range-row button,
.dc-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-body);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--t-fast);
}
.seg button:hover,
.view-toggle button:hover,
.chart-range-row button:hover,
.dc-tab:hover { background: var(--surface-sub); color: var(--text); border-color: transparent; }
.seg button.active,
.seg button[aria-pressed="true"],
.view-toggle button.active,
.view-toggle button[aria-pressed="true"],
.chart-range-row button.active,
.dc-tab.active { background: var(--chip-on); color: var(--on-accent); font-weight: 500; box-shadow: none; }
@media (pointer: coarse), (max-width: 640px) {
  .seg button, .view-toggle button, .chart-range-row button, .dc-tab, .chip, .owner-filter button { min-height: 44px; }
}

/* ---------- Tag ---------- */
.tag,
.type-pill,
.st-badge,
.st-chip,
.dc-badge,
.dc-chip,
.import-card-badge,
.setup-chip,
.setup-count,
.dup-confidence {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-sub);
  color: var(--text-strong-body);
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}
/* "Needs attention" (pending, to check, renewal soon): the small amber tag. */
.tag-attention,
.type-pill-amber,
.st-badge-warn,
.dc-badge-possible,
.setup-dup-flag,
.import-card-badge-unknown,
.dc-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 20px;
  padding: 0 7px;
  border: 1px solid var(--attention-border);
  border-radius: var(--radius-sm);
  background: var(--attention-bg);
  color: var(--attention-text);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.dc-count-zero { border-color: var(--border); background: var(--surface-sub); color: var(--text-muted); }
/* An error state is the one place a tag may be red. */
.tag-error,
.st-badge-bad { background: var(--expense-tint); color: var(--expense); }
.type-pill-blue, .type-pill-green, .type-pill-red, .type-pill-purple, .type-pill-teal,
.st-badge-ok, .dc-badge-exact, .import-card-badge-ok, .st-chip-muted { background: var(--surface-sub); color: var(--text-strong-body); }

/* ---------- Button ---------- */
.btn,
.dup-btn,
.mu-btn,
.pwa-lock-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn:hover,
.dup-btn:hover,
.mu-btn:hover,
.pwa-lock-secondary:hover { background: var(--surface-sub); border-color: var(--border); color: var(--text); transform: none; box-shadow: none; }
.btn-primary,
.dup-btn-primary,
.mu-btn-primary,
.pwa-lock-primary,
a.dup-btn-primary,
#add-asset-btn,
#add-liability-btn,
#add-insurance-btn,
#open-import-form-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  box-shadow: none;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.btn-primary:hover,
.dup-btn-primary:hover,
.mu-btn-primary:hover,
.pwa-lock-primary:hover,
a.dup-btn-primary:hover,
#add-asset-btn:hover,
#add-liability-btn:hover,
#add-insurance-btn:hover,
#open-import-form-btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); transform: none; box-shadow: none; filter: none; }
.btn-danger,
.dup-btn-danger { color: var(--expense); border-color: var(--border); }
.btn-danger:hover,
.dup-btn-danger:hover { background: var(--expense-tint); border-color: var(--expense-tint); color: var(--expense); }
.dup-btn-primary.ui-dialog-danger { background: var(--expense); border-color: var(--expense); }
.dup-btn-primary.ui-dialog-danger:hover { background: var(--expense); filter: brightness(0.92); }
.btn:disabled, .dup-btn:disabled, .mu-btn:disabled, .mu-btn-primary:disabled, .pwa-lock-primary:disabled,
.btn-primary:disabled, .dup-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg, .dup-btn svg, .btn-primary svg, .dup-btn-primary svg, .mu-btn svg, .view-toggle svg, .seg svg { width: 16px; height: 16px; stroke-width: 1.6; flex: none; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.link-btn,
.mu-link {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.link-btn:hover, .mu-link:hover { background: none; color: var(--accent-hover); }
/* Row actions: quiet square icon buttons. */
.icon-btn,
.modal-close-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t-fast);
}
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.6; }
.modal-close-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
.icon-btn:hover,
.modal-close-btn:hover,
.modal-close-btn:focus-visible { background: var(--surface-sub); color: var(--text); }
.icon-btn.icon-btn-danger:hover { background: var(--expense-tint); color: var(--expense); }
@media (pointer: coarse), (max-width: 640px) {
  .btn, .dup-btn, .mu-btn, .btn-primary, .dup-btn-primary, .mu-btn-primary, .pwa-lock-primary, .pwa-lock-secondary,
  #add-asset-btn, #add-liability-btn, #add-insurance-btn, #open-import-form-btn, a.dup-btn, a.dup-btn-primary { min-height: 44px; }
  .icon-btn, .modal-close-btn { width: 44px; height: 44px; }
}

/* ---------- Input / Select ---------- */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]), select, textarea) {
  height: 34px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color var(--t-fast);
}
:where(textarea) { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
:where(select) { cursor: pointer; }
:where(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
:where(input, select, textarea):focus-visible { outline: none; }
:where(input, select, textarea):disabled { background: var(--surface-sub); color: var(--text-muted); }
:where(input)::placeholder, :where(textarea)::placeholder { color: var(--text-muted); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- Switch (2026-10-07: every on/off setting is a small switch, not a check box) ---------- */
/* Still an <input type="checkbox" role="switch" class="switch">: the keyboard, the label, `checked` and the change
   event are the browser's own. Consent and confirmation boxes ("I read the terms", "I saved the key") stay check
   boxes on purpose: a switch says "a setting that is on or off", a check box says "I confirm". Off is the thumb at
   the start of the line, on is the thumb at the end, so it flips with the page direction. */
input[type="checkbox"].switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  box-sizing: border-box;
  inline-size: 32px;
  block-size: 18px;
  margin: 0;
  border-radius: 999px;
  background: var(--switch-off);
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--t-fast);
}
input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 14px;
  block-size: 14px;
  border-radius: 50%;
  background: var(--on-accent);
  transition: inset-inline-start var(--t-fast);
}
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::before { inset-inline-start: 16px; }
input[type="checkbox"].switch:disabled { opacity: 0.5; cursor: not-allowed; }
input[type="checkbox"].switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { input[type="checkbox"].switch, input[type="checkbox"].switch::before { transition: none; } }
:where(input[type="file"])::file-selector-button {
  height: 30px;
  margin-inline-end: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
/* A label over a field. */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.input-search { position: relative; display: inline-flex; }
.input-search input { padding-inline-start: 32px; }
.input-search .icon { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
@media (pointer: coarse) {
  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select) { min-height: 44px; font-size: 16px; }
  :where(textarea) { font-size: 16px; }
}

/* ---------- Dropzone ---------- */
.import-drop,
.dropzone {
  position: relative;
  width: 100%;
  font: inherit;
  color: var(--text);
  text-decoration: none;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 24px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-foot);
  text-align: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.import-drop:hover,
.import-drop:focus-within,
.dropzone:hover { border-color: var(--accent); background: var(--surface-foot); color: var(--text); }
.import-drop-over,
.dropzone-over { border-color: var(--accent); background: var(--row-selected); }
.import-drop-icon,
.dropzone-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-size: 0;
}
.import-drop-icon svg, .dropzone-icon svg { width: 20px; height: 20px; }
.import-drop-text { font-weight: 500; font-size: 15px; }
.import-drop-sub { max-width: 340px; color: var(--text-muted); font-size: 12px; }
.import-card-warn { margin: 0; color: var(--attention-text); font-weight: 500; }
/* File reading progress: a 4px bar, track surface-sub, fill data-3. */
.progress { height: 4px; border-radius: 2px; background: var(--surface-sub); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 2px; background: var(--data-3); }
.progress-indeterminate > i { width: 40%; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { transform: translateX(150%); } to { transform: translateX(-250%); } }
@media (prefers-reduced-motion: reduce) { .progress-indeterminate > i { animation: none; width: 100%; opacity: 0.6; } }

/* ---------- CommandPalette (Ctrl/⌘+K) ---------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
  background: var(--overlay);
}
.palette {
  width: min(560px, 100%);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.palette .palette-input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  box-shadow: none;
}
.palette .palette-input:focus { box-shadow: none; border-color: var(--border); }
.palette-results { flex: 1; min-height: 0; max-height: 360px; overflow-y: auto; padding: 6px; }
.palette-foot { padding: 8px 14px; border-top: 1px solid var(--border); background: var(--surface-foot); color: var(--text-muted); font-size: 12px; }
.search-result-group-label {
  padding: 8px 12px 4px;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.search-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.search-result-row:hover,
.search-result-row.search-result-active { background: var(--surface-sub); outline: none; }
.search-result-row .label { font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-row .detail { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; color: var(--text-muted); font-size: 12px; }
.search-empty { padding: 16px 12px; color: var(--text-muted); font-size: 14px; }
@media (max-width: 640px) {
  .palette-overlay { padding: 8px; }
  .search-result-row { flex-direction: column; gap: 2px; }
  .search-result-row .detail { max-width: 100%; }
}

/* ---------- EmptyState ---------- */
.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 24px;
  margin: 0 0 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.empty-hero h2 { margin: 0; font-size: 22px; font-weight: 600; color: var(--heading); }
.empty-hero > p { margin: 0; max-width: 520px; color: var(--text-body); }
.empty-steps {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: right;
}
.empty-steps li { display: flex; flex-direction: column; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.empty-steps small:first-child { font-size: 12px; font-weight: 600; color: var(--accent); }
.empty-steps b { font-weight: 500; }
.empty-steps span { font-size: 13px; color: var(--text-muted); }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.empty-actions .btn, .empty-actions .btn-primary { padding: 0 20px; }
@media (pointer: fine) and (min-width: 641px) { .empty-actions .btn, .empty-actions .btn-primary { min-height: 40px; } }
/* A list or table with nothing to show: one muted line, and a way out of the filter. */
.empty-state,
.decisions-empty { padding: 32px 20px; color: var(--text-muted); font-size: 14px; font-weight: 400; text-align: center; }
tbody tr.empty-row,
tbody tr.empty-row:hover { background: transparent; }
tbody tr.empty-row td { padding: 32px 20px; text-align: center; color: var(--text-muted); font-size: 14px; white-space: normal; }

/* ---------- Dialogs ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.modal-box {
  width: min(600px, 100%);
  max-height: 86vh;
  padding: 16px 20px 20px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.modal-box-wide { width: min(640px, 100%); max-width: none; }
.modal-header {
  position: sticky;
  top: -16px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: -16px -20px 16px;
  padding: 10px 12px 10px 20px;
  background: var(--surface-head);
  border-bottom: 1px solid var(--border);
  color: var(--heading);
  font-size: var(--fs-h2);
  font-weight: 600;
}
.modal-body label { color: var(--text-muted); font-size: 12px; }
.modal-body .form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.modal-body .form-actions .dup-btn-primary { min-width: 0; padding: 0 20px; font-size: 14px; }
/* a row whose only button is hidden (no rent yet: no "מחיקת הכנסה משכירות") drew a second line next to the divider */
.modal-body .form-actions:not(:has(> :not(.hidden))) { display: none; }
.ui-dialog-box { width: min(420px, 100%); padding: 20px; }
.ui-dialog-message { font-size: 15px; line-height: 1.6; margin: 0 0 16px; white-space: pre-line; }
.ui-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }
dialog { color: var(--text); }
dialog::backdrop { background: var(--overlay); }
@media (max-width: 640px) {
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal-box, .modal-box-wide { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; border: 0; padding: 16px; }
  .modal-header { margin: -16px -16px 16px; padding: 8px 8px 8px 16px; }
  .ui-dialog-overlay { padding: 16px; align-items: center; }
  .ui-dialog-box { height: auto; border-radius: var(--radius-lg); }
}

/* ---------- Toasts and bars ---------- */
.saved-toast,
.undo-toast {
  border-radius: var(--radius);
  background: var(--heading);
  color: var(--on-accent);
  box-shadow: var(--shadow-pop);
}
.undo-toast .dup-btn { min-height: 30px; }
.app-error-banner { border-radius: var(--radius); background: var(--expense-tint); border: 1px solid var(--expense); color: var(--expense); }
.app-error-copy { min-height: 30px; border-radius: var(--radius); }
.pwa-bar { border-radius: var(--radius-lg); background: var(--heading); color: var(--on-accent); }
.pwa-bar button { min-height: 36px; border-radius: var(--radius); background: var(--surface); color: var(--heading); font-weight: 500; white-space: nowrap; flex-shrink: 0; }

/* ---------- Lock screen ---------- */
.pwa-lock {
  background: var(--overlay-lock);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.pwa-lock-card {
  width: min(440px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  gap: 14px;
}
.pwa-lock-card h1 { font-size: 20px; font-weight: 600; color: var(--heading); }
.pwa-lock-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--surface-sub);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.pwa-lock-field { font-weight: 500; font-size: 13px; color: var(--text-strong-body); }
.pwa-lock-field input { min-height: 40px; height: 40px; border-radius: var(--radius); font-size: 15px; }
.pwa-lock-hint { font-weight: 400; font-size: 12.5px; color: var(--text-muted); }
.pwa-lock-primary, .pwa-lock-secondary { min-height: 40px; font-weight: 500; }
.pwa-lock-link { color: var(--accent); font-size: 13px; }
.pwa-lock-code { border-radius: var(--radius); background: var(--surface-sub); }
.pwa-welcome-points li { border-radius: var(--radius); background: var(--surface-sub); }
.pwa-install-dialog { border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
@media (pointer: coarse) {
  .pwa-lock-field input, .pwa-lock-primary, .pwa-lock-secondary { min-height: 48px; }
}

/* ---------- Charts ---------- */
.chart-tooltip { background: var(--heading); color: var(--on-accent); border-radius: var(--radius-sm); font-size: 12px; }
.chart-legend { color: var(--text-muted); font-size: 12px; }
.chart-legend-swatch { width: 8px; height: 8px; border-radius: 2px; }
/* Horizontal bars (categories, allocation): a 6px bar on a surface-sub track, data-3 fill, accent when chosen. */
.hbar { height: 6px; border-radius: 3px; background: var(--surface-sub); overflow: hidden; }
.hbar > i { display: block; height: 100%; border-radius: 3px; background: var(--data-3); }
.hbar.selected > i, .hbar-row.selected .hbar > i { background: var(--accent); }
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 180px) 1fr auto; align-items: center; gap: 12px; font-size: 14px; }
.hbar-label { color: var(--text-strong-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-value { color: var(--text-body); font-size: 13px; }
.hbar-row-muted .hbar > i { background: var(--border-strong); }
@media (max-width: 640px) {
  .hbar-row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .hbar-row .hbar { grid-column: 1 / -1; grid-row: 2; }
}

/* Motion: background / border only (design rule). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Welcome tour (public/tour.js) ---------- */
/* A spotlight around the real element and a card beside it; a bottom sheet on a phone. */
.wt-spot { position: fixed; z-index: 200000; border-radius: var(--radius); pointer-events: none; box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px var(--overlay); transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease; }
.wt-spot.wt-none { box-shadow: 0 0 0 9999px var(--overlay); width: 0 !important; height: 0 !important; top: 50% !important; left: 50% !important; }
.wt-card { position: fixed; z-index: 200001; width: min(360px, calc(100vw - 24px)); box-sizing: border-box; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px 14px; box-shadow: var(--shadow-pop); direction: rtl; font-family: inherit; }
.wt-card.wt-center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.wt-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--heading); }
.wt-card p { margin: 0; line-height: 1.55; font-size: 14px; color: var(--text-body); }
.wt-meta { margin-top: 14px; display: flex; align-items: center; gap: 8px; }
.wt-dots { display: flex; gap: 5px; margin-inline-end: auto; }
.wt-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.wt-dots i.on { background: var(--accent); }
.wt-btn { min-height: 44px; padding: 6px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: inherit; font: inherit; font-size: 14px; cursor: pointer; }
.wt-btn:hover { background: var(--surface-sub); }
.wt-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.wt-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.wt-skip { background: none; border: 0; color: var(--text-muted); text-decoration: underline; padding: 6px 4px; min-height: 44px; font: inherit; font-size: 14px; cursor: pointer; }
.wt-btn:focus-visible, .wt-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) {
  .wt-meta { flex-wrap: wrap; gap: 10px; }
  .wt-dots { flex: 1 0 100%; justify-content: center; margin: 0 0 2px; }
  .wt-btn { order: 2; flex: 1 1 0; min-height: 48px; font-size: 16px; }
  .wt-btn.primary { order: 1; flex: 2 1 0; }
  .wt-skip { order: 3; flex: 1 0 100%; text-align: center; }
  .wt-card, .wt-card.wt-center { top: auto !important; bottom: 0; left: 0 !important; right: 0; width: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; transform: none !important; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .wt-spot { transition: none; } }

/* ---------- Collapsible type groups (app.js makeGroupCollapsible) ---------- */
/* The card's content is hidden, not removed: the header band is all that remains, with the count and the total. */
.group-section > h2 { cursor: pointer; }
.group-toggle {
  display: inline-grid;
  place-items: center;
  flex: none;
  inline-size: 28px;
  block-size: 28px;
  margin-inline: -6px 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-body);
  cursor: pointer;
}
.group-toggle:hover { background: var(--surface-sub); color: var(--text); }
.group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.group-toggle svg { inline-size: 18px; block-size: 18px; stroke-width: 1.8; transition: transform var(--t-fast); }
.group-section.group-closed .group-toggle svg { transform: rotate(90deg); } /* RTL: closed points to the line's end */
.table-section.group-closed > :not(h2) { display: none; }
.table-section.group-closed > h2 { margin-bottom: -16px; border-bottom: 0; border-radius: calc(var(--radius) - 1px); }
.group-section.group-closed { margin-bottom: 12px; }
.group-summary { order: 2; margin-inline-start: auto; font-size: 13px; font-weight: 500; color: var(--text-body); font-variant-numeric: tabular-nums; }
.group-toolbar { display: flex; justify-content: flex-start; margin: 0 0 12px; }
.dup-btn.group-all { min-height: 32px; padding: 0 14px; font-size: 13px; }
@media (pointer: coarse), (max-width: 640px) { .dup-btn.group-all { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { .group-toggle svg { transition: none; } }

/* Touch: a bigger switch (its label is the wider target where there is one) and a full-size header toggle. */
@media (pointer: coarse), (max-width: 640px) {
  input[type="checkbox"].switch { inline-size: 44px; block-size: 26px; }
  input[type="checkbox"].switch::before { inset-block-start: 3px; inset-inline-start: 3px; inline-size: 20px; block-size: 20px; }
  input[type="checkbox"].switch:checked::before { inset-inline-start: 21px; }
  .group-toggle { inline-size: 44px; block-size: 44px; margin-block: -8px; }
}

/* ---------- The import box from every page ---------- */
#import-modal { z-index: 90; }
#import-modal .modal-close-btn { font-size: 22px; line-height: 1; }
.import-fab {
  position: fixed;
  inset-block-end: 16px;
  inset-inline-end: 16px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow-pop);
  cursor: pointer;
}
.import-fab:hover { filter: brightness(1.08); }
.import-fab-icon { display: inline-flex; }
@media (max-width: 640px) {
  .import-fab { inset-block-end: calc(12px + env(safe-area-inset-bottom)); min-width: 48px; padding: 0 14px; }
}
@media print { .import-fab { display: none; } }
.attached-docs { display: grid; gap: 10px; }
.attached-doc { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.attached-doc-name { font-weight: 700; overflow-wrap: anywhere; }
.attached-doc-where { color: var(--text-muted); font-size: 13px; }

/* ---------- Import window (2026-10-12 redesign, the mockup the user approved) ----------
   One row per file: type, name, what will happen to it, a status tag, and ×. Under the row only the question the
   family has to answer. One save for everything, in a bar that stays at the bottom of the window. */
/* one column that never grows past the window: a select with a long option ("אותה קופה — עדכון של …") widened the
   card past a phone's edge, 16px cut off on the left (found 2026-10-12, owner request M1) */
.import-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.import-card select { max-width: 100%; }
.import-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.import-card-attention { border-color: var(--attention-border); }
.import-card-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 12px; }
.import-card-type {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--surface-sub); color: var(--text-muted);
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
}
.import-card-main { flex: 1; min-width: 0; }
.import-card-name { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-card-what { margin-top: 2px; font-size: 13px; color: var(--text-body); overflow-wrap: anywhere; }
.import-card-what b { font-weight: 600; color: var(--text); }
.import-card-facts { font-weight: inherit; }
p.import-card-facts { margin: 0; font-size: 13px; color: var(--text); }
.import-card-side { flex: none; display: flex; align-items: center; gap: 8px; }
.import-card-badge.import-tag-ok { background: var(--row-selected); color: var(--accent); }
.import-card-badge.import-tag-wait { border: 1px solid var(--attention-border); background: var(--attention-bg); color: var(--attention-text); }
.import-card-badge.import-tag-done { background: var(--surface-sub); color: var(--text-muted); }
.import-card-badge.import-tag-error { background: var(--expense-tint); color: var(--expense); }
.import-card-remove {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--text-muted); cursor: pointer;
}
.import-card-remove:hover { border-color: var(--border); background: var(--surface-sub); color: var(--text); }
.import-card-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 12px 12px 14px; padding-inline-start: 60px; border-top: 1px solid var(--row-line); }
.import-card > .form-error { margin: 0 12px 12px; padding-inline-start: 48px; }
.import-card-pick, .import-card-fields, .import-card-preview, .import-card-number, .import-wizard-offer { display: grid; gap: 8px; }
.import-card-preview:empty, .import-card-number:empty { display: none; }
.import-holdings-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.import-holdings-list li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--row-line); }
.import-holdings-list li span { min-width: 0; overflow-wrap: anywhere; }
.import-holdings-list li strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The statement preview's rows ("מה ייכנס", and the rows that may already exist): date, description and amount on one
   line, the category and any flag under them; at 390px the description wraps and nothing scrolls sideways. */
.import-card-maybe { display: grid; gap: 6px; justify-items: start; }
.import-card-maybe > .import-rows-list { justify-self: stretch; }
.import-card-rows summary { cursor: pointer; font-size: 13px; color: var(--text-body); }
.import-card-rows[open] summary { margin-bottom: 4px; }
.import-card-rows .import-rows-more { margin-top: 6px; }
.import-rows-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.import-rows-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--row-line);
}
.import-row-date { color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.import-row-desc { min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.import-row-amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.import-row-tags, .import-row-old, .import-row-choice { grid-column: 1 / -1; }
.import-row-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.import-row-choice, .modal-body label.import-row-choice { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; color: var(--text-body); font-size: 13px; }
@media (pointer: coarse) { .modal-body label.import-row-choice { min-height: 44px; } }
.import-row-uncategorized { color: var(--text-muted); }
.import-row-old { color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.import-row-excluded .import-row-desc, .import-row-excluded .import-row-amount { color: var(--text-muted); text-decoration: line-through; }
.modal-body .import-card-field, .import-card-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-body); font-size: 13px; }
.import-card-field select, .import-card-field input:not([type="checkbox"]) { min-width: 220px; }
.import-card-note { margin: 0; color: var(--text-muted); font-size: 12px; }
.import-card-hint { margin: 0; color: var(--text-body); font-size: 13px; }
.import-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.import-structure-link { font-size: 12px; color: var(--text-body); }
.import-card .mu-btn, .import-footer .mu-btn { border-color: var(--border-strong); }
.import-card-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.import-card-chip {
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
}
.import-card-chip:hover { background: var(--surface-sub); }
.import-card-chip-on, .import-card-chip-on:hover { border-color: var(--accent); background: var(--row-selected); color: var(--accent); }
.import-card .import-wizard { padding: 0 12px 12px; }

/* the drop zone: big while the list is empty, a slim "add files" bar above the files */
.import-drop-big { display: grid; justify-items: center; gap: 8px; }
.import-drop-slim { display: none; align-items: center; justify-content: center; gap: 6px; font-size: 13px; color: var(--text-body); }
.import-drop-plus { color: var(--accent); font-size: 18px; line-height: 1; }
.import-drop-add { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.import-has-cards .import-drop { padding: 10px 12px; }
.import-has-cards .import-drop-big { display: none; }
.import-has-cards .import-drop-slim { display: flex; }

/* the one save */
.import-footer { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.mu-saveall-text { flex: 1; color: var(--text-body); font-size: 13px; }
.mu-saveall-text b { color: var(--text); font-weight: 600; }
.import-footer-close { display: none; }
#import-modal .import-footer-close { display: inline-flex; }
#import-modal .import-footer { position: sticky; bottom: -20px; z-index: 1; margin: 16px -20px -20px; padding: 12px 20px; background: var(--surface-foot); }

@media (pointer: coarse) {
  .import-card-remove { width: 44px; height: 44px; }
  .import-card-chip { min-height: 44px; }
}
@media (max-width: 640px) {
  .import-card-row { flex-wrap: wrap; row-gap: 6px; }
  .import-card-side { order: 3; flex-basis: 100%; padding-inline-start: 48px; }
  .import-card-remove { order: 2; }
  .import-card-body { padding-inline-start: 12px; }
  .import-card > .form-error { padding-inline-start: 0; }
  .import-card-field select, .import-card-field input:not([type="checkbox"]) { min-width: 0; width: 100%; }
  .import-footer { flex-wrap: wrap; }
  .mu-saveall-text { flex-basis: 100%; }
  .import-saveall-btn { flex: 1; }
  #import-modal .import-footer { bottom: -16px; margin: 16px -16px -16px; padding: 12px 16px; }
}

/* ---------- New liability window (2026-10-12) ----------
   A type picker, the terms the family knows, a live estimate and one footer with the summary and the save button. */
.nl-box { padding: 0; display: flex; flex-direction: column; overflow: hidden; width: min(720px, 100%); }
.nl-box .modal-header { position: static; margin: 0; padding: 10px 12px 10px 20px; flex: none; }
.nl-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; flex: 1; min-height: 0; }
.nl-body > section { margin: 0; }
.nl-step { margin: 0 0 8px; font-size: var(--fs-small); font-weight: 600; color: var(--text-strong-body); }
.nl-hint { margin: 0 0 8px; font-size: var(--fs-small); color: var(--text-body); }
.nl-opt { font-weight: 400; color: var(--text-muted); }
.nl-types { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.nl-type { display: flex; flex-direction: column; gap: 3px; padding: 10px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: center; cursor: pointer; }
.nl-type b { font-size: 14px; font-weight: 600; }
.nl-type span { font-size: var(--fs-label); color: var(--text-muted); line-height: 1.35; }
.nl-type:hover { background: var(--surface-sub); }
.nl-type.on { border-color: var(--accent); background: var(--row-selected); box-shadow: inset 0 0 0 1px var(--accent); }
.nl-type.on b { color: var(--accent); }
.nl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.nl-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.nl-grid-1 { grid-template-columns: minmax(0, 1fr); }
.nl-wide { grid-column: auto; }
.nl-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: var(--fs-small); color: var(--text-body); }
.nl-f small { color: var(--text-muted); font-size: var(--fs-label); }
.nl-body input:not([type="checkbox"]), .nl-body select { width: 100%; min-width: 0; height: 38px; }
.nl-unit { position: relative; display: block; }
.nl-unit input { padding-inline-end: 28px; }
.nl-unit i { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.nl-mode { margin: 0; }
.nl-tracks { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.nl-track { position: relative; display: grid; grid-template-columns: 1.5fr 1.2fr 0.8fr 0.8fr 1.1fr 28px; gap: 8px; align-items: end; padding: 10px 12px; border-top: 1px solid var(--row-line); }
.nl-track:first-child { border-top: 0; }
.nl-track:not(:has(.nl-kind)) { grid-template-columns: 1.2fr 0.8fr 0.8fr 1.1fr auto; }
.nl-rm { width: 28px; height: 38px; border: 0; background: none; color: var(--text-muted); font-size: 18px; cursor: pointer; border-radius: var(--radius-sm); }
.nl-rm:hover { background: var(--surface-sub); color: var(--expense); }
.nl-switch { display: flex; align-items: center; gap: 8px; height: 38px; font-size: var(--fs-small); color: var(--text-body); }
.nl-tracks-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--surface-foot); border-top: 1px solid var(--border); font-size: var(--fs-small); color: var(--text-body); }
.nl-link { border: 0; background: none; padding: 0; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--accent); cursor: pointer; }
.nl-link:hover { text-decoration: underline; text-underline-offset: 2px; }
@media (pointer: coarse), (max-width: 640px) { .nl-link { min-height: 44px; } } /* "+ הוספת מסלול" was 21px on a phone (UX round 5) */
.nl-calc { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-foot); }
.nl-calc.hidden { display: none; }
.nl-calc-wait { margin: 0; font-size: var(--fs-small); color: var(--text-muted); }
.nl-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.nl-kpis small { display: block; font-size: var(--fs-label); color: var(--text-muted); }
.nl-kpis b { display: block; margin-top: 2px; font-size: 18px; font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums; }
.nl-kpis em { margin-inline-start: 6px; padding: 1px 6px; border-radius: var(--radius-sm); background: var(--attention-bg); color: var(--attention-text); font-size: var(--fs-label); font-style: normal; font-weight: 500; vertical-align: 2px; }
.nl-note { margin: 10px 0 0; font-size: var(--fs-label); line-height: 1.5; color: var(--text-muted); }
.nl-more { padding-top: 12px; border-top: 1px solid var(--border); }
.nl-more summary { cursor: pointer; font-size: var(--fs-small); color: var(--text-body); }
.nl-more .nl-grid { margin-top: 10px; }
.nl-foot { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-foot); }
.nl-foot-sum { flex: 1; min-width: 0; font-size: var(--fs-small); color: var(--text-body); }
@media (max-width: 640px) {
  .nl-box { height: 100dvh; max-height: 100dvh; }
  .nl-body { padding: 16px; }
  .nl-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nl-types .nl-type:last-child { grid-column: span 2; }
  .nl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nl-grid .nl-wide { grid-column: span 2; }
  .nl-track, .nl-track:not(:has(.nl-kind)) { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 14px; }
  .nl-track .nl-kind { grid-column: span 2; padding-inline-end: 34px; }
  .nl-rm { position: absolute; top: 30px; inset-inline-end: 8px; }
  .nl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nl-foot { flex-wrap: wrap; padding: 12px 16px; }
  .nl-foot-sum { flex-basis: 100%; }
  .nl-foot .dup-btn-primary { flex: 1; }
}
.cell-sub { margin-top: 2px; font-size: var(--fs-label); color: var(--text-muted); }
.est-tag { padding: 1px 6px; border-radius: var(--radius-sm); background: var(--attention-bg); color: var(--attention-text); font-size: var(--fs-label); font-weight: 500; white-space: nowrap; cursor: help; }

/* the attached-documents block of the liability window, and the drop zone over the whole window */
.nl-docs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nl-docs-head .nl-step { margin: 0; }
.nl-box { position: relative; }
.nl-box.nl-dropping::after {
  content: attr(data-drop);
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  opacity: 0.94;
  pointer-events: none;
}

/* ---------- Round 9: category picker, details window, category manager (categories.js, transaction-details.js, category-manager.js) ---------- */
.txn-category-btn {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: start;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txn-category-btn:hover { background: var(--surface-sub); }
.txn-category-btn.txn-category-none { border-style: dashed; color: var(--text-muted); }
.txn-desc-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.txn-desc-btn:hover { text-decoration: underline; }
.cat-search { width: 100%; margin-bottom: 12px; }
.cat-list { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.cat-group-title { margin-top: 10px; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.cat-leaves, .cat-recent { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cat-opt:hover { background: var(--surface-sub); }
.cat-opt[aria-current="true"] { background: var(--chip-on); border-color: var(--chip-on); color: var(--on-accent); }
.cat-opt-none { align-self: flex-start; color: var(--text-muted); border-style: dashed; }
.cat-new { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.cat-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cat-mparent { margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.cat-mparent-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-bottom: 6px; }
.cat-mparent-title { display: flex; align-items: baseline; gap: 8px; }
.cat-mrow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--row-line); }
.cat-mrow-main { display: flex; align-items: baseline; gap: 8px; }
.cat-mrow-tools { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.cat-new-parent { margin-top: 12px; }
.txn-det-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.txn-det-name { font-size: 18px; color: var(--heading); }
.txn-det-amount { font-size: 18px; font-weight: 600; }
.txn-det-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.txn-det-row input { flex: 1 1 200px; }
.txn-det-fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.txn-det-fields dt { color: var(--text-muted); font-size: 12px; }
.txn-det-fields dd { margin: 0; overflow-wrap: anywhere; }
.txn-det-lookup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.txn-det-lookup .section-note { flex-basis: 100%; margin: 0; }
.txn-det-hist-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; padding: 4px 0; border-top: 1px solid var(--row-line); }
.bp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.bp-row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr 90px 130px; align-items: center; gap: 12px; width: 100%; padding: 8px 4px; border: 0; border-top: 1px solid var(--row-line); background: none; color: var(--text); font: inherit; font-size: 14px; text-align: start; }
button.bp-row { cursor: pointer; }
button.bp-row:hover { background: var(--surface-sub); }
.bp-head { color: var(--text-muted); font-size: 12px; border-top: 0; }
.bp-sub { padding-inline-start: 24px; font-size: 13px; }
.bp-total { font-weight: 600; border-top: 1px solid var(--border-strong); }
.bp-bar { position: relative; height: 10px; border-radius: var(--radius-pill); background: var(--surface-sub); }
.bp-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: var(--radius-pill); background: var(--expense-bar); }
.bp-avg-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--heading); }
.bp-month { font-weight: 600; text-align: end; }
.bp-avg { text-align: end; }
@media (max-width: 640px) {
  .bp-row { grid-template-columns: 1fr auto auto; }
  .bp-row .bp-bar { grid-column: 1 / -1; order: 3; }
  .bp-head .bp-bar { display: none; }
}
.budget-table tr.budget-parent td { font-weight: 600; border-top: 1px solid var(--border); }
.budget-table tr.budget-child td:first-child { padding-inline-start: 24px; }
