/* Personal Finance: app-specific layout and components on top of the Standard Design System.
   Rules: only var(--token) values, spacing from the 4–48 scale, both themes, phone width. */

h1, h2, h3 { margin: 0; }
.page-title { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.01em; }
.section-title { font-size: 18px; line-height: 24px; font-weight: 700; letter-spacing: -0.005em; margin-bottom: var(--space-3); }
h3 { font-size: 15px; font-weight: 700; margin: var(--space-5) 0 var(--space-2); }
.neg { color: var(--danger-text); }
.pos { color: var(--success); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.archived { opacity: .6; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .btn, .bar-icon, .field input, .field select, .seg, .data-table td { transition: background-color 120ms, border-color 120ms, color 120ms; }
}

/* App bar additions */
.app-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
.bar-icons + .bar-icons { margin-left: var(--space-2); }
button.bar-icon { border: 0; background: transparent; cursor: pointer; }
.company-select { max-width: 260px; }

/* Page */
.page { max-width: 1360px; margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-7); display: flex; flex-direction: column; gap: var(--space-4); }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; }
.page-subtitle { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: 12.5px; line-height: 18px; }
.page-actions, .page-tools { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.page-tools { justify-content: space-between; margin-bottom: var(--space-3); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.subsection, .danger-zone { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.danger-zone h3 { margin-top: 0; }
.card > .section-title:first-child { margin-top: 0; }

/* Month / year stepper */
.stepper { display: inline-flex; align-items: center; gap: var(--space-1); background: var(--surface); border-radius: var(--radius-s); box-shadow: var(--shadow-card); }
.stepper-label { min-width: 140px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper .btn-ghost { padding: var(--space-2); font-size: 18px; line-height: 1; }

/* Notice: something that needs attention, links to where to fix it */
.notice { display: block; background: var(--highlight); color: var(--warning-text); border-radius: var(--radius-s); padding: var(--space-3) var(--space-4); font-size: 14px; text-decoration: none; margin: 0; }
a.notice:hover { text-decoration: underline; }
.notice p { margin: 0 0 var(--space-2); }

/* KPI cards on the overview */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.kpi-card { padding: var(--space-4); }
.kpi-sub { margin-top: var(--space-1); font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.kpis.spaced { background: var(--surface); border-radius: var(--radius-m); box-shadow: var(--shadow-card); padding: var(--space-4) var(--space-5); gap: var(--space-5); }

/* Dashboard grid */
.widget-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.widget-grid .span-2 { grid-column: span 2; }
.widget-grid .span-3 { grid-column: span 3; }
.widget-grid .span-4 { grid-column: 1 / -1; }
.widget-foot { margin-top: auto; padding-top: var(--space-3); }
.legend-list { font-size: 13px; gap: var(--space-2); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); font-size: 13px; }
.bar-row { display: flex; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-1); }
.bar-row .num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-muted); }

/* Charts */
.chart-wrap { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart-wrap .legend { flex-direction: row; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.chart-wrap .legend .lv { margin-left: var(--space-2); padding-left: 0; }

/* Progress bar */
.progress { height: 8px; background: var(--chart-track); border-radius: var(--radius-pill); overflow: hidden; min-width: 60px; }
.progress-fill { height: 100%; background: var(--chart-blue-3); border-radius: var(--radius-pill); }
.progress-fill.over { background: var(--danger); }
.progress-cell { width: 18%; vertical-align: middle !important; }

/* Segmented control (tabs, type switch) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 2px; gap: 2px; margin-bottom: var(--space-4); }
.page-header .segmented { margin-bottom: 0; }
.seg { border: 0; background: transparent; color: var(--text-muted); font: 600 14px var(--font-sans); padding: 7px 14px; border-radius: 4px; cursor: pointer; min-height: 36px; }
.seg:hover { color: var(--text); }
.seg.on { background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-card); }

/* Tables */
.table-scroll { overflow-x: auto; border-radius: var(--radius-m); box-shadow: var(--shadow-card); }
.table-scroll > .data-table { box-shadow: none; }
.table-scroll.tall { max-height: 60vh; overflow-y: auto; }
.table-scroll.tall thead th { position: sticky; top: 0; z-index: 1; }
.data-table td.neg { color: var(--danger-text); }
.data-table.compact td { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; }
.grid-table th, .grid-table td { padding: 8px 10px; white-space: nowrap; }
.grid-table .row-head { text-align: left; font-weight: 600; color: var(--text); background: var(--surface); position: sticky; left: 0; z-index: 1; font-size: 14px; }
.grid-table .group-row th { background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 700; text-transform: none; }
.grid-table .sub-row td { padding-top: 0; }
.grid-table tr:has(+ .sub-row) td, .grid-table tr:has(+ .sub-row) th { border-bottom: none; }
.card .table-scroll { box-shadow: none; border: 1px solid var(--line); }
.summary-line { display: flex; gap: var(--space-5); flex-wrap: wrap; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-bottom: var(--space-2); }
.budget-group + .budget-group { margin-top: var(--space-5); }

/* Inline inputs in tables */
.cell-input { width: 100%; min-width: 84px; max-width: 130px; padding: 5px 8px; border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; color: var(--text); font: 14px var(--font-sans); text-align: right; font-variant-numeric: tabular-nums; }
.cell-input:hover:not(:disabled) { border-color: var(--line-strong); }
.cell-input:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 2px var(--accent-tint); }
.inline-select { padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--text); font: 13px var(--font-sans); max-width: 240px; }

/* Category source and suggestions (Transactions) */
.cat-note { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.suggest { border: 1px dashed var(--accent); background: var(--accent-tint); color: var(--accent-text); border-radius: var(--radius-pill); font: 600 12px var(--font-sans); padding: 2px 10px; cursor: pointer; }
.suggest:hover { border-style: solid; }
.suggest-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* Rule preview (Rules dialog) */
.rule-preview { margin-top: var(--space-3); padding: var(--space-3); background: var(--surface-2); border-radius: var(--radius-s); font-size: 13px; min-height: 24px; }
.rule-preview:empty { display: none; }
.rule-preview p { margin: 0 0 var(--space-2); }
ul.plain.compact li { font-size: 12.5px; padding: 2px 0; }

/* Toolbars and forms */
.toolbar { flex-wrap: wrap; }
.toolbar.wrap { align-items: flex-end; margin-bottom: var(--space-3); }
.toolbar.end { justify-content: flex-end; margin: var(--space-4) 0 0; }
.toolbar .field { margin-bottom: 0; }
.toolbar input:not([type=checkbox]), .toolbar select { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text); font: 14px var(--font-sans); }
.bulk-bar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; background: var(--accent-tint); color: var(--accent-text); padding: var(--space-2) var(--space-3); border-radius: var(--radius-s); font-size: 14px; font-weight: 600; }
.bulk-bar select { padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text); font: 13px var(--font-sans); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 var(--space-3); }
.field.check label, label.check { display: flex; gap: var(--space-2); align-items: center; color: var(--text); font-size: 14px; font-weight: 400; cursor: pointer; }
.field.check input[type=checkbox], label.check input { width: auto; }
.check-list { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding: var(--space-1) 0; }
.field input[type=file] { padding: 7px; }
.inline-field { max-width: 260px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
details summary { cursor: pointer; color: var(--accent-text); font-size: 13px; margin: var(--space-3) 0 var(--space-2); }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-1) 0; border-bottom: 1px solid var(--line); font-size: 14px; }

/* Version history in Settings > About */
.history { margin: 0; font-size: 14px; }
.history dt { font-weight: 700; margin-top: var(--space-3); font-variant-numeric: tabular-nums; }
.history dd { margin: var(--space-1) 0 0; color: var(--text-muted); }

/* Categories in settings */
.cat-columns { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-4); }
.cat-columns h3 { margin-top: var(--space-2); }

/* Goals */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-3); }
.goal-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.goal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.goal-head .section-title { margin: 0; }
.goal-amounts { font-variant-numeric: tabular-nums; }
.goal-amounts strong { font-size: 19px; }
.goal-card .btn { align-self: flex-start; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4); margin: 0; font-size: 13px; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
/* Transaction dialog: what the bank's export said about the row (read-only). */
.bank-details { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.bank-details .facts dd { text-align: left; font-weight: 400; overflow-wrap: anywhere; }

/* Login / onboarding */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-2); }
.auth-card .page-title { margin-bottom: var(--space-2); }
.auth-brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 700; color: var(--accent-text); margin-bottom: var(--space-3); }
.auth-logo { color: var(--accent); }
.auth-switch { text-align: center; font-size: 14px; margin: var(--space-2) 0 0; }
.auth-switch a, .card a:not(.btn) { color: var(--accent-text); }
.btn-block { width: 100%; justify-content: center; min-height: 40px; }

/* Modal + toast hosting (component styles come from bundle.css) */
.scrim { position: fixed; inset: 0; background: rgba(20, 26, 34, .42); display: flex; align-items: flex-start; justify-content: center; padding: var(--space-7) var(--space-4); overflow-y: auto; z-index: 50; }
[data-theme="dark"] .scrim { background: rgba(0, 0, 0, .6); }
.modal-wide { max-width: 960px; }
.modal-body p { margin-top: 0; }
.toast-host { position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: 60; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: toast-in 180ms ease-out; } }
@keyframes toast-in { from { opacity: 0; } to { opacity: 1; } }

/* Responsive: 4 → 2 columns up to 1100px, 1 on phones */
@media (max-width: 1100px) {
  .widget-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cat-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appbar-inner { flex-wrap: wrap; }
  .appbar-spacer { display: none; }
}
/* Tables on phones: columns marked .hide-phone are hidden; .phone-only lines (e.g. date · account under the
   description) carry what matters from them. */
.phone-only { display: none; }
@media (max-width: 700px) {
  .hide-phone { display: none; } .phone-only { display: block; }
  .num-inline { font-weight: 600; font-variant-numeric: tabular-nums; }   /* the amount under the description */
}
@media (max-width: 700px) {
  .page { padding: var(--space-4) var(--space-4) var(--space-7); }
  .appbar-inner { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .app-name { display: none; }
  .company-select { flex: 1; max-width: none; }
  .bar-icons { flex-wrap: wrap; }
  .bar-icon { width: 40px; }
  .widget-grid, .cat-columns { grid-template-columns: 1fr; }
  .widget-grid .span-2, .widget-grid .span-3 { grid-column: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr; }
  .page-title { font-size: 24px; line-height: 30px; }
  .progress-cell { display: none; }
}

/* Transactions: filter bar and column headers stay in view while the list scrolls. The table may not clip
   (overflow), or the sticky headers would stick to the table instead of the window; on phones it scrolls sideways. */
/* The app bar stays at the top on every page (height in --appbar-h, set by app.js); on a phone held sideways
   (little height) it scrolls away, or it would take most of the screen. */
.appbar { position: sticky; top: 0; z-index: 10; }
html { scroll-padding-top: var(--appbar-h, 0px); } /* scrollIntoView and anchors land below the bar */
@media (max-height: 500px) { .appbar { position: static; } :root { --appbar-h: 0px !important; } }
.sticky-top { position: sticky; top: var(--appbar-h, 0px); z-index: 3; background: var(--bg); padding: var(--space-3) 0 var(--space-1); display: grid; gap: var(--space-2); }
.sticky-top .summary-line { margin-bottom: 0; }
.tx-scroll, .tx-scroll > .data-table { overflow: visible; }
.tx-scroll thead th { position: sticky; top: calc(var(--appbar-h, 0px) + var(--sticky-h, 0px)); z-index: 2; }
.tx-scroll thead th:first-child { border-top-left-radius: var(--radius-m); }
.tx-scroll thead th:last-child { border-top-right-radius: var(--radius-m); }
@media (max-width: 700px) { .tx-scroll { overflow-x: auto; } .sticky-top, .tx-scroll thead th { position: static; } }

/* Dated rows (loan rate changes, asset valuations): date, value, suffix, remove. */
.dated-list { display: grid; gap: var(--space-2); margin-bottom: var(--space-2); }
.dated-row { display: grid; grid-template-columns: 1fr 130px auto auto; gap: var(--space-2); align-items: center; }

/* Transaction dialog: suggestion / "Show all categories" buttons under the category field. */
.cat-wrap > .btn { margin: calc(-1 * var(--space-2)) var(--space-2) var(--space-4) 0; }

/* Overview: monthly import reminder (one row per account with its Import button). */
.due-note ul { margin: var(--space-2) 0; }
.due-note ul.plain li { display: flex; align-items: center; justify-content: flex-start; gap: var(--space-2); padding: 2px 0; border: 0; }

/* My account → Appearance, as in the CRM: light/dark/auto buttons and colour scheme swatches. */
.mode-grid { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; margin: 6px 0 4px; }
.mode-opt { padding: 8px 16px; border: 0; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.mode-opt + .mode-opt { border-left: 1px solid var(--line-strong); }
.mode-opt.selected { background: var(--accent); color: #fff; }
.theme-grid { display: flex; flex-wrap: wrap; gap: 12px; margin: 6px 0 4px; }
.theme-opt { width: 132px; padding: 8px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.theme-opt:hover { border-color: var(--line-strong); }
.theme-opt.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.theme-opt .sw-bar { display: block; height: 18px; border-radius: 5px 5px 0 0; }
.theme-opt .sw-body { display: flex; gap: 5px; align-items: center; height: 26px; padding: 0 6px; background: var(--surface-2); border-radius: 0 0 5px 5px; }
.theme-opt .sw-dot { width: 22px; height: 10px; border-radius: 3px; }
.theme-opt .sw-name { display: block; margin-top: 7px; font-size: 13.5px; font-weight: 600; }

/* Investments → Watchlists and Charts (from the Stock Tracker): canvas charts with tooltip, instrument picker,
   mini-chart grid, detail stats. Tabs at the top of the page use the segmented control. */
.inv-tabs { margin-bottom: var(--space-3); }
.canvas-chart { position: relative; width: 100%; height: 100%; touch-action: pan-y; }
.canvas-chart canvas { display: block; }
.chart-tip { position: absolute; left: 0; top: 0; display: none; pointer-events: none; z-index: 5; white-space: nowrap; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); box-shadow: var(--shadow-modal); padding: var(--space-2) var(--space-3); font-size: 12.5px; line-height: 18px; font-variant-numeric: tabular-nums; }
.chart-tip .tip-date, .chart-tip .muted { color: var(--text-muted); }
.dot { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: var(--space-2); vertical-align: middle; }
.chartbox { height: 340px; }
.chartbox.big { height: calc(100vh - 320px); min-height: 360px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-top: var(--space-3); font-size: 12.5px; }
.spark { vertical-align: middle; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-3) var(--space-4); margin-top: var(--space-4); }
.stats .kpi-value { font-size: 16px; }
.charts-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (max-width: 900px) { .charts-layout { grid-template-columns: 1fr; } }
.picker { padding: var(--space-3); max-height: calc(100vh - 200px); overflow: auto; }
.picker .toolbar { margin-bottom: var(--space-2); }
.pick { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); border-radius: var(--radius-s); cursor: pointer; }
.pick:hover { background: var(--accent-tint); }
.pick .sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line-strong); flex: none; }
.pick .info { flex: 1; min-width: 0; }
.pick .info b { display: block; font-size: 14px; }
.pick .info span { display: block; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick .q { text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chart-toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--space-3); }
.chart-toolbar select { padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text); font: 14px var(--font-sans); }
.minigrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); }
.mini { cursor: pointer; }
.mini:hover h3 { color: var(--accent-text); }
.mini .mh { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.mini .mh h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .mc { height: 160px; margin-top: var(--space-2); }

/* Phones: the two icon groups each fill one row (no stray icon wrapping onto a line of its own). */
@media (max-width: 700px) {
  .bar-icons { flex-wrap: nowrap; width: 100%; }
  .bar-icons + .bar-icons { margin-left: 0; }
  .bar-icon { flex: 1 1 0; width: auto; min-width: 0; }
}

/* Investments → Portfolio as a dashboard (value chart + key figures, allocation, watchlist, movers), and the
   Portfolio development widget on the overview (chart beside its key figures; stacked on narrow screens). */
.inv-dash { margin-bottom: var(--space-4); }
.inv-dash .chartbox { height: 300px; }
.data-table.compact td { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.data-table tr.gap td { padding: var(--space-1) 14px; color: var(--text-muted); }
.pw { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: var(--space-5); align-items: center; }
.pw-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.pick-remove { padding: 2px 8px; color: var(--text-muted); }
@media (max-width: 1100px) { .widget-grid .span-3 { grid-column: 1 / -1; } }
@media (max-width: 900px) { .pw { grid-template-columns: 1fr; } }
.inv-dash .widget-body { flex-direction: column; align-items: stretch; gap: var(--space-3); }
.inv-dash .widget-body > svg.donut { width: 170px; align-self: center; }

/* Budget year grids (plan and result): fit the page without sideways scrolling on a normal screen. Fixed layout,
   equal number columns, a narrower category column whose names may wrap, inputs that fill their cell. Below
   900px (phones) the table still scrolls sideways: 14 numbers don't fit there. */
@media (min-width: 901px) {
  .grid-table { table-layout: fixed; width: 100%; }
  .grid-table col.c-cat { width: 13%; }
  .grid-table col.c-year { width: 6.5%; }
  .grid-table th, .grid-table td { padding: 6px 4px; font-size: 13px; vertical-align: middle; }
  .grid-table thead th, .grid-table .totals-row td, .grid-table .totals-row th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid-table .row-head { white-space: normal; font-size: 13px; padding-left: 10px; line-height: 1.25; }
  .grid-table .row-head .btn { padding: 0 4px; }
  .grid-table .cell-input { width: 100%; min-width: 0; padding: 4px 3px; font-size: 13px; text-align: right; }
}

/* Two-factor set-up (My account): QR code on white in both themes, the key and recovery codes in monospace. */
.qr-box { display: flex; justify-content: center; margin: var(--space-3) 0; }
.qr-box svg { width: 200px; height: 200px; border-radius: var(--radius-s); }
.totp-key { display: block; margin-top: var(--space-2); font: 15px var(--font-mono); letter-spacing: .04em; word-break: break-all; user-select: all; }
.recovery-codes { columns: 2; padding: var(--space-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); font: 15px var(--font-mono); line-height: 1.8; user-select: all; }
.text-danger { color: var(--danger-text); }
.qr-box + details { margin-bottom: var(--space-4); }

/* Warning before logging out after inactivity (app.js), above everything at the bottom of the screen. */
.idle-warn { position: fixed; left: 50%; bottom: var(--space-5); transform: translateX(-50%); z-index: 200; display: flex; align-items: center; gap: var(--space-3);
  width: max-content; max-width: calc(100vw - 32px); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-m); box-shadow: var(--shadow-modal); }
.idle-warn .btn { white-space: nowrap; }

/* Long lists: rows shown (200 · 400 · 600 · All) at the top right and, with Show more, at the bottom (core.js). */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); }
.page-size { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text-muted); }
.page-size > span { margin-right: var(--space-2); }
.page-size button { border: 0; background: none; padding: 3px 8px; border-radius: var(--radius-s); font: inherit; color: var(--text-muted); cursor: pointer; }
.page-size button:hover { color: var(--text); background: var(--surface-2); }
.page-size button[aria-pressed="true"] { color: var(--accent); background: var(--accent-tint); font-weight: 600; }

/* Category picker (catpicker.js): a text box that filters as you type; the list floats above the page. */
.cat-picker { position: relative; min-width: 0; }
.cat-picker input { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface); color: var(--text);
  font: 14px var(--font-sans); text-overflow: ellipsis; }
.cat-picker input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.toolbar .cat-picker { width: 15rem; }
.bulk-bar .cat-picker { width: 14rem; }
.cat-picker.inline input { padding: 5px 8px; border-color: var(--line); font-size: 13px; max-width: 240px; }
.cat-picker.inline.missing input { background: var(--highlight); border-color: var(--highlight-strong); color: var(--warning-text); }
.cat-list { position: fixed; z-index: 300; overflow-y: auto; padding: 4px 0; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  box-shadow: var(--shadow-modal); font-size: 14px; }
.cat-group { padding: 8px 12px 2px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.cat-opt { padding: 6px 12px 6px 18px; cursor: pointer; }
.cat-opt.current { font-weight: 600; }
.cat-opt.active { background: var(--accent-tint); color: var(--accent); }
.cat-opt.add { margin-top: 4px; border-top: 1px solid var(--line); padding-left: 12px; color: var(--accent); }
.cat-empty { padding: 8px 12px; color: var(--text-muted); }
@media (max-width: 700px) { .data-table .cat-picker.inline input { max-width: 9.5rem; } }

/* Overview → Customise: a Show/Hide switch on each card, seen only while customising; hidden cards greyed there, gone otherwise. */
.overview { display: flex; flex-direction: column; gap: var(--space-4); } /* same spacing as .page: the overview sits in one wrapper */
.overview .switch, .overview .ov-edit-note { display: none; }
.overview.ov-edit .ov-edit-note { display: block; }
.overview:not(.ov-edit) .w-off { display: none; }
.overview.ov-edit .widget, .overview.ov-edit .kpi-grid { position: relative; outline: 2px dashed var(--line-strong); outline-offset: 2px; }
.overview.ov-edit .w-off > :not(.switch) { opacity: .35; }
.overview.ov-edit .kpi-grid { padding-top: 34px; }
.overview.ov-edit a.widget-link { cursor: default; }
.overview.ov-edit .switch { display: inline-flex; position: absolute; top: 8px; right: 8px; z-index: 2; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); font: inherit; font-size: 12px; color: var(--text); cursor: pointer; }
.switch-knob { width: 28px; height: 16px; border-radius: 8px; background: var(--line-strong); position: relative; transition: background .15s; }
.switch-knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch[aria-pressed=true] .switch-knob { background: var(--accent); }
.switch[aria-pressed=true] .switch-knob::after { transform: translateX(12px); }
.switch .switch-text::after { content: attr(data-off); }
.switch[aria-pressed=true] .switch-text::after { content: attr(data-on); }
.page-actions .btn[aria-pressed=true] { background: var(--accent-tint); color: var(--accent-text); border-color: var(--accent); }
/* Net worth: unticked lines are greyed and struck through, and left out of the sum. */
.worth-list label.check { font-size: 13px; color: var(--text-muted); gap: 6px; min-width: 0; }
.worth-list input[type=checkbox] { width: 15px; height: 15px; flex: 0 0 auto; }
.worth-list li.off label, .worth-list li.off .lv { opacity: .5; text-decoration: line-through; }
.h3-link { color: inherit; text-decoration: none; } .h3-link:hover { color: var(--accent-text); }

/* Transaction note (several lines) and files: tiles with a thumbnail or a file icon, × to delete, drop target. */
.tx-note { white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tx-files { display: inline-flex; align-items: center; gap: 4px; }
.tx-files svg { width: 14px; height: 14px; }
.files { margin: var(--space-3) 0; padding: var(--space-3); border: 1px dashed var(--line-strong); border-radius: var(--radius-m); display: flex; flex-direction: column; gap: var(--space-2); }
.files.drop { border-color: var(--accent); background: var(--accent-tint); }
.files-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.files-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.files-title svg { width: 16px; height: 16px; }
.file-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); }
.file-tile { position: relative; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); overflow: hidden; }
.file-tile.waiting { opacity: .7; }
.file-open { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; color: var(--text); text-decoration: none; font-size: 11.5px; }
.file-open img { width: 100%; height: 72px; object-fit: cover; border-radius: 4px; }
.file-icon { height: 72px; display: grid; place-items: center; color: var(--text-muted); }
.file-icon svg { width: 32px; height: 32px; }
.file-name { width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-del { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }

/* Economic health: a coloured dot per check (good / watch / act / unknown). */
.health-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.health-list li { display: grid; grid-template-columns: 14px 1fr; gap: var(--space-2); font-size: 13.5px; }
.health-list a { color: var(--accent-text); }
.health-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 3px; background: var(--line-strong); }
.health-good .health-dot { background: var(--success); }
.health-watch .health-dot { background: var(--chart-orange); }
.health-act .health-dot { background: var(--danger); }
.health-info .health-dot { background: transparent; border: 2px solid var(--accent); width: 8px; height: 8px; } /* no limit used: for reference */

/* Reports (feedback): the thread, the admins' answers set off; Admin tools: households with no members dimmed. */
.ticket-msg { border-left: 3px solid var(--line-strong); padding: var(--space-2) var(--space-3); margin: var(--space-3) 0; }
.ticket-msg.from-admin { border-left-color: var(--accent); background: var(--accent-tint); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.ticket-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.row-muted td { color: var(--text-muted); }
.tabs-scroll { overflow-x: auto; max-width: 100%; } /* page tabs on a phone: scroll sideways rather than widen the page */
.tabs-scroll .segmented { flex-wrap: nowrap; white-space: nowrap; }
/* Terms of use (sign-up, acceptance screen, admin preview), the admin log's grave lines, a report's screenshot. */
.terms-text { max-height: 50vh; overflow-y: auto; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-s); margin: var(--space-3) 0; }
.terms-text p { white-space: pre-line; margin: 0 0 var(--space-2); }
.terms-card { max-width: 640px; }
.terms-check { display: flex; gap: 8px; align-items: flex-start; margin: var(--space-2) 0 var(--space-3); font-size: 14px; }
.terms-edit { font-family: inherit; line-height: 1.5; }
.log-grave td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.ticket-shot img { max-width: 100%; max-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-s); margin: var(--space-2) 0; }
