/* Finance's own styles (views/finance-*.js), apart from styles.css so
   each Finance update adds its block without touching the others'.
   Linked from index.html and app.html after styles.css. Tokens only
   (tokens.css); no font under 0.75rem; 44px targets on a coarse
   pointer. */

/* ==== The form kit (views/finance-forms.js) ==== */
.fin-form { display: grid; gap: 12px; min-width: 0; }
.fin-form-row { display: grid; gap: 4px; min-width: 0; }
.fin-form-row[hidden] { display: none; }
/* The folded "More options" of a form (formDialog `more`). */
.fin-form-more { min-width: 0; }
.fin-form-more > summary { cursor: pointer; font-size: 0.875rem; color: var(--accent-text); min-height: 24px; }
.fin-form-more > .fin-form-row { margin-top: 12px; }
@media (pointer: coarse) { .fin-form-more > summary { min-height: 44px; display: flex; align-items: center; } }
.fin-form-row label { font-size: 0.8125rem; color: var(--text-muted); }
.fin-form-bool { grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.fin-form-row input, .fin-form-row select { min-width: 0; max-width: 100%; }
.fin-form-hint { margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.fin-inline { cursor: text; border-radius: 4px; overflow-wrap: anywhere; }
.fin-inline:hover { background: var(--surface2); }
.fin-inline.num { font-variant-numeric: tabular-nums; }
.fin-inline-input { min-width: 0; max-width: 100%; font: inherit; }
.fin-inline-error { display: block; margin: 2px 0 0; font-size: 0.75rem; }
.fin-delete { font-size: 0.75rem; }
button.finance-settings-link, .finance-customise { background: transparent; font-family: inherit; cursor: pointer; }
.finance-customise { margin-left: auto; }
button.finance-settings-link:hover, .finance-customise:hover { background: var(--surface2); }
.finance-settings-missing { margin: 4px 0 8px; }
/* WP0: inline Clear, dates and months, figures with their ⓘ, bulk delete. */
.fin-inline-wrap { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.fin-inline-clear, .fin-fig-edit, .fin-field-default {
  font: inherit; font-size: 0.75rem; background: transparent; border: 0; padding: 2px 4px;
  color: var(--accent-text, var(--text-muted)); text-decoration: underline; cursor: pointer;
}
.fin-fig { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; min-width: 0; }
.fin-fig-label { color: var(--text-muted); font-size: 0.875rem; }
.fin-fig-value { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.fin-bulk-delete { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.fin-tabs-list .tab-layout-row { min-width: 0; }
.fin-tabs-reset { margin-top: 12px; }
.fin-import-page { display: grid; gap: 12px; justify-items: start; }
@media (pointer: coarse) {
  .fin-delete, .finance-settings-link, .finance-customise, .fin-inline-clear, .fin-fig-edit, .fin-field-default { min-height: 44px; }
  .fin-inline { display: inline-block; min-height: 44px; line-height: 44px; }
}

/* ==== Finance's controls in the app's style ====
   Dropdowns, typed fields, month and date pickers, checkboxes and the
   Delete buttons on every Finance page and dialog, matched to the rest
   of the app (styles.css .modal fields, .month-sel, .fpill): the dark
   surface, a thin border, the accent on focus, the app's own chevron.
   Was the browser's own controls (light select, grey Delete). */
#sec-finance, .fin-form { color-scheme: dark; }
#sec-finance select, .fin-form select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  min-height: 2rem; padding: 4px 28px 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background-color: var(--surface2); color: var(--text);
  font: inherit; font-size: 0.8125rem; line-height: 1.3;
  background-repeat: no-repeat; background-position: right 10px center; background-size: 10px 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237b8ba8'/%3E%3C/svg%3E");
}
#sec-finance select option, .fin-form select option { background: var(--surface2); color: var(--text); }
#sec-finance input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
#sec-finance textarea {
  min-height: 2rem; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font: inherit; font-size: 0.8125rem;
}
#sec-finance select:hover, .fin-form select:hover,
#sec-finance input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover { border-color: var(--text-muted); }
#sec-finance select:focus-visible, .fin-form select:focus-visible,
#sec-finance input:focus-visible, #sec-finance textarea:focus-visible { border-color: var(--accent); }
#sec-finance input[type="checkbox"], .fin-form input[type="checkbox"] { accent-color: var(--accent); width: 1rem; height: 1rem; cursor: pointer; }
#sec-finance input[type="file"] { font: inherit; font-size: 0.8125rem; color: var(--text-muted); }
#sec-finance input[type="file"]::file-selector-button {
  margin-right: 10px; padding: 3px 10px; border-radius: 16px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
/* Delete: the app's pill, in red (not the browser's grey button). */
.fin-delete {
  padding: 2px 10px; border-radius: 16px; border: 1px solid var(--red-border);
  background: transparent; color: var(--red-text); font: inherit; font-size: 0.75rem;
  cursor: pointer; white-space: nowrap; transition: background 0.12s;
}
.fin-delete:hover { background: var(--red-bg); }
.fin-delete:disabled { opacity: 0.55; cursor: default; }

/* Finance's buttons as the app's pills (Budget's .fin-btn was square),
   and its text links as links, never the browser's grey button. */
#sec-finance .fin-btn {
  padding: 3px 12px; border-radius: 16px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font: inherit; font-size: 0.8125rem; transition: all 0.12s;
}
#sec-finance .fin-btn:hover { border-color: var(--text-muted); background: var(--surface2); }
#sec-finance .fin-btn[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent-light); border-color: var(--accent); }
#sec-finance .fin-link {
  padding: 0 2px; border: 0; border-radius: 4px; background: none; color: var(--accent-text);
  font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
#sec-finance .fin-link:hover { background: var(--surface2); }

/* One Delete everywhere in Finance: the red pill (pages had their own). */
#sec-finance .fin-delete, #sec-finance .fpill.fin-delete {
  padding: 2px 10px; border-radius: 16px; border: 1px solid var(--red-border);
  background: transparent; color: var(--red-text); text-decoration: none; font-size: 0.75rem; white-space: nowrap;
}
#sec-finance .fin-delete:hover { background: var(--red-bg); }
/* A big figure never breaks inside its number: it gets smaller on a
   narrow card instead. */
#sec-finance .fin-fig-value, #sec-finance .fin-kpi-go { overflow-wrap: normal; word-break: normal; }
@media (max-width: 640px) {
  #sec-finance .fin-txn-totals .fin-fig-value { font-size: clamp(1rem, 5.2vw, 1.375rem); white-space: nowrap; }
}

/* A KPI figure that opens its page stays a target even when it is "0". */
#sec-finance .fin-kpi-go { min-width: 24px; min-height: 24px; text-align: left; }
@media (pointer: coarse) { #sec-finance .fin-kpi-go { min-width: 44px; min-height: 44px; } }

/* A wide table scrolls inside its own card, never the page. */
#sec-finance .fin-table-wrap { max-width: 100%; overflow-x: auto; }

/* ==== Transactions ==== */
/* The toolbar: the month and Show on the left, the Adds on the right;
   Add account and Import under them. A control keeps its ⓘ beside it. */
.fin-txn-bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin: 8px 0; min-width: 0; }
.fin-txn-nav { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; min-width: 0; }
.fin-txn-month { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.fin-txn-arrow { min-width: 2.25rem; font-size: 1rem; line-height: 1; justify-content: center; }
.fin-txn-month-pick input { min-width: 0; max-width: 100%; }
.fin-txn-ctl { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; min-width: 0; max-width: 100%; }
.fin-txn-kind { display: flex; gap: 6px; align-items: center; font-size: 0.875rem; min-width: 0; }
.fin-txn-kind select { min-width: 0; max-width: 100%; }
.fin-txn-add { display: flex; flex-wrap: wrap; gap: 8px; }
.fin-txn-more { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
/* Totals: a two-button toggle, then the four figures as tiles. */
.fin-txn-scope { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 12px 0 8px; }
.fin-txn-scope-label { font-size: 0.875rem; color: var(--text-muted); }
.fin-txn-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fin-txn-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 12px; margin: 0 0 8px; }
.fin-txn-figs .fin-fig { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); }
.fin-txn-figs .fin-fig-value { flex-basis: 100%; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-txn-figs .fin-txn-fig-pos .fin-fig-value { color: var(--green-text); }
.fin-txn-figs .fin-txn-fig-neg .fin-fig-value { color: var(--red-text); }
/* No transactions yet: one clear start. */
.fin-txn-empty-acts { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin-top: 12px; }
.fin-txn-empty-add { font-size: 1rem; padding: 8px 18px; }
.fin-txn-empty-import {
  font: inherit; font-size: 0.875rem; background: transparent; border: 0; padding: 4px;
  color: var(--accent-text, var(--text-muted)); text-decoration: underline; cursor: pointer;
}
.fin-txn-count { color: var(--text-muted); font-weight: 400; font-size: 0.875rem; }
/* Edit all and Delete selected on one line. */
.fin-txn-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
.fin-txn-tools .fin-bulk-delete { margin: 0; }
.fin-txn-tools .fin-bulk-delete[hidden] { display: none; }
/* The list: short columns never break mid-word (styles.css breaks any
   .fin-table cell anywhere); the date, amount, headers and Delete stay
   on one line and take only the room they need. */
.fin-txn-table td, .fin-txn-table th { vertical-align: top; }
.fin-txn-table th, .fin-txn-table td, .fin-txn-table .fin-inline { overflow-wrap: break-word; }
.fin-txn-table thead th { white-space: nowrap; }
.fin-txn-table .fin-txn-pickcol, .fin-txn-table .fin-txn-datecol, .fin-txn-table .fin-txn-delcol { width: 1%; white-space: nowrap; }
/* "Select all" is shown beside its tick on phones only (the stacked list
   has no column heads in view there). */
.fin-txn-pick-all-wrap { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.fin-txn-pick-all-text { display: none; font-size: 0.875rem; font-weight: 500; }
.fin-txn-table td.num { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.fin-txn-table tbody th { font-weight: 500; }
.fin-txn-table .fin-delete { white-space: nowrap; }
.fin-txn-table .fin-txn-in, .fin-txn-table .fin-txn-in .fin-inline { color: var(--green-text); }
.fin-txn-table .fin-txn-type-none { color: var(--text-muted); }
.fin-txn-table tfoot th, .fin-txn-table tfoot td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.fin-txn-table tfoot th { text-align: right; }
/* The hidden Delete header stays inside its scrolling table. */
.fin-txn-table th, .fin-plan-table th { position: relative; }
.fin-card-sub { margin: 16px 0 4px; font-size: 0.875rem; }
.fin-income-plan > .fpill { margin-top: 8px; }
@media (pointer: coarse) {
  .fin-txn-bar .fpill, .fin-txn-more .fpill, .fin-txn-scope .fpill, .fin-txn-tools .fpill, .fin-txn-empty .fpill,
  .fin-txn-empty-import, .fin-txn-kind select, .fin-txn-month-pick input, .fin-txn-table .fin-delete,
  .fin-income-plan > .fpill { min-height: 44px; }
  .fin-txn-arrow { min-width: 44px; }
  .fin-txn-pick-all-wrap { min-height: 44px; }
}
/* Phones: each row stacks. The tick, the description and the amount
   across the top; the date, category, type, account and Delete in a
   smaller line under it. The column heads stay for screen readers; the
   head's tick stays in view as "Select all", and a head with an ⓘ comes
   into view while the ⓘ has focus. */
@media (max-width: 640px) {
  .fin-txn-table, .fin-txn-table thead, .fin-txn-table tbody, .fin-txn-table tfoot { display: block; width: 100%; }
  .fin-txn-table thead th:not(.fin-txn-pickcol):not(:focus-within) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-txn-table thead tr { padding: 4px 0; }
  .fin-txn-pick-all-text { display: inline; }
  .fin-txn-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .fin-txn-table tr > * { display: block; width: auto; padding: 0; border: 0 !important; min-width: 0; }
  /* The desktop rule sizes these to 1%: undo it (same weight, later). */
  .fin-txn-table .fin-txn-pickcol, .fin-txn-table .fin-txn-datecol, .fin-txn-table .fin-txn-delcol { width: auto; }
  .fin-txn-row > .fin-txn-pickcol { order: 0; }
  .fin-txn-row > .fin-txn-desccol { order: 1; flex: 1 1 0; }
  .fin-txn-row > td.num { order: 2; }
  .fin-txn-row::after { content: ''; order: 3; flex-basis: 100%; height: 0; }
  .fin-txn-row > .fin-txn-datecol, .fin-txn-row > .fin-txn-cat, .fin-txn-row > .fin-txn-kindcol,
  .fin-txn-row > .fin-txn-account, .fin-txn-row > .fin-txn-delcol { order: 4; font-size: 0.8125rem; color: var(--text-muted); white-space: normal; }
  .fin-txn-row > .fin-txn-datecol { padding-left: 1.75rem; white-space: nowrap; }
  .fin-txn-row > .fin-txn-delcol { margin-left: auto; }
  .fin-txn-row > td:empty { display: none; }
  .fin-txn-table tfoot tr { justify-content: space-between; border-top: 2px solid var(--text); border-bottom: 0; }
  .fin-txn-table tfoot .fin-txn-pickcol, .fin-txn-table tfoot .fin-txn-delcol { display: none; }
  .fin-txn-table tfoot th { text-align: left; flex: 1 1 0; }
  .fin-txn-list > .fin-table-wrap { overflow: visible; }
  .fin-txn-bar { justify-content: flex-start; }
}

/* ==== Budget ==== */
.fin-btn { font: inherit; font-size: 0.875rem; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--surface-border); background: var(--surface2); color: var(--text); cursor: pointer; white-space: nowrap; }
.fin-btn:hover { border-color: var(--accent); }
.fin-btn[aria-disabled="true"] { opacity: 0.5; cursor: default; }
.fin-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.fin-btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.fin-month-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.fin-month-label { font-weight: 600; min-width: 9em; text-align: center; }
.fin-budget-bucket { margin: 12px 0 4px; font-size: 0.875rem; color: var(--text-muted); }
.fin-budget-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-width: 0; }
.fin-budget-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 4px 0; border-bottom: 1px solid var(--surface-border); min-width: 0; }
.fin-budget-name { flex: 1 1 10em; min-width: 0; overflow-wrap: anywhere; }
.fin-line-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.fin-budget-snapshot > .fin-btn { margin-top: 8px; }
@media (pointer: coarse) {
  .fin-btn { min-height: 44px; min-width: 44px; }
}
@media (pointer: fine) {
  .fin-btn { min-height: 24px; min-width: 24px; }
}
/* The Budget page (views/finance-budget.js, .fin-budget-page). */
/* The month on the left, Add expense and Add income on the right. */
.fin-bud-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-width: 0; }
.fin-bud-top .fin-bud-add { margin: 0; }
/* A card's title and its ⓘ on one row, the ⓘ in the corner. */
.fin-budget-page .fin-bud-card-head { margin: 0 0 8px; }
.fin-budget-page .fin-bud-card-head > .fin-card-title { margin: 0; }
/* Spent links and Remove / Delete drawn as what they are. */
.fin-budget-page .fin-link {
  padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit;
  text-decoration: underline; cursor: pointer; font-variant-numeric: tabular-nums;
}
.fin-budget-page .fin-delete {
  font: inherit; font-size: 0.8125rem; padding: 4px 12px; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--surface-border); background: transparent; color: var(--red-text); cursor: pointer;
}
.fin-budget-page .fin-delete:hover { border-color: var(--red-text); }
/* Numbers and choices typed in place look editable, touch or not. */
.fin-budget-page .fin-inline { border-bottom: 1px dashed var(--text-muted); border-radius: 4px 4px 0 0; padding: 0 4px; }
.fin-budget-page .fin-inline:hover, .fin-budget-page .fin-inline:focus-visible { border-bottom: 1px solid var(--accent); }
.fin-budget-page .fin-bud-pick::after, .fin-budget-page .fin-bud-line-bucket::after {
  content: ' \25BE'; color: var(--text-muted); font-size: 0.75rem;
}
/* Status words and overspending stand out. */
.fin-budget-page .fin-bud-band { display: inline-block; white-space: nowrap; }
.fin-bud-over { color: var(--red-text); white-space: nowrap; }
/* Tables: words wrap at spaces, headers stay on one line, a long name
   keeps a readable width (the table scrolls in .fin-table-wrap before
   a cell is squeezed to a letter). */
.fin-bud-table th, .fin-bud-table td { overflow-wrap: break-word; }
.fin-bud-table thead th, .fin-bud-table .fin-bud-row-add { white-space: nowrap; }
.fin-bud-table tbody th[scope="row"] { min-width: 9rem; }
.fin-bud-split-table .fin-bud-mojo th, .fin-bud-split-table .fin-bud-mojo td { color: var(--text-muted); border-top: 2px solid var(--surface-border); }
.fin-budget-page .fin-table-wrap + .fin-btn-row, .fin-budget-page .fin-table-wrap + .finance-soon { margin-top: 12px; }
.fin-budget-page .fin-bud-remove-all { margin-left: auto; }
/* Phones: each row stacks, the name across the top and each figure
   labelled by its column (data-col); the header row stays as a legend
   with its ⓘ. */
@media (max-width: 640px) {
  .fin-bud-table, .fin-bud-table thead, .fin-bud-table tbody { display: block; width: 100%; }
  .fin-bud-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-bud-table tr > * { display: block; padding: 0; border: 0; text-align: left; }
  .fin-bud-table thead tr { font-size: 0.8125rem; padding-top: 0; }
  .fin-bud-table tbody th[scope="row"] { flex: 1 0 100%; min-width: 0; }
  .fin-bud-table td:empty { display: none; }
  .fin-bud-table td.num[data-col]::before { content: attr(data-col); color: var(--text-muted); font-size: 0.75rem; font-weight: 400; margin-right: 4px; }
  .fin-bud-table .fin-bud-row-add { margin-left: auto; }
  .fin-bud-split-table .fin-bud-mojo { border-top: 2px solid var(--surface-border); }
  .fin-bud-split-table .fin-bud-mojo th, .fin-bud-split-table .fin-bud-mojo td { border-top: 0; }
}
/* The split's seven columns stack on tablets too. */
@media (min-width: 641px) and (max-width: 900px) {
  .fin-bud-split-table, .fin-bud-split-table thead, .fin-bud-split-table tbody { display: block; width: 100%; }
  .fin-bud-split-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-bud-split-table tr > * { display: block; padding: 0; border: 0; text-align: left; }
  .fin-bud-split-table thead tr { font-size: 0.8125rem; padding-top: 0; }
  .fin-bud-split-table tbody th[scope="row"] { flex: 1 0 100%; min-width: 0; }
  .fin-bud-split-table td:empty { display: none; }
  .fin-bud-split-table td.num[data-col]::before { content: attr(data-col); color: var(--text-muted); font-size: 0.75rem; font-weight: 400; margin-right: 4px; }
  .fin-bud-split-table .fin-bud-mojo { border-top: 2px solid var(--surface-border); }
  .fin-bud-split-table .fin-bud-mojo th, .fin-bud-split-table .fin-bud-mojo td { border-top: 0; }
}
/* Budget lines: column names once above, then (wide) each line on a
   grid so name, bucket, amount and Spent line up from row to row.
   Narrow: the name across the top, the rest flowing below it, the
   tools at the end. */
.fin-budget-lines .fin-budget-line > .fin-budget-name { flex: 1 0 100%; overflow-wrap: break-word; }
.fin-budget-lines .fin-budget-line > .fin-inline-error, .fin-budget-lines .fin-budget-line > .field-error { flex: 1 0 100%; grid-column: 1 / -1; }
.fin-budget-lines .fin-line-tools { justify-content: flex-end; justify-self: end; }
.fin-bud-line-head { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 4px 0; font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--surface-border); }
.fin-bud-col-order { margin-left: auto; }
@media (min-width: 960px) {
  .fin-budget-lines .fin-budget-line, .fin-bud-line-head {
    display: grid; grid-template-columns: minmax(0, 1fr) 10rem 8rem 10rem minmax(13rem, auto); align-items: center; gap: 4px 12px;
  }
  .fin-budget-lines .fin-line-tools, .fin-bud-col-order { margin-left: 0; justify-self: end; }
  .fin-bud-line-spent-word { display: none; }
}

/* ==== Investments ==== */
.fin-inv-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.fin-inv-row > th, .fin-inv-row > td { border-bottom: 0; }
.fin-inv-more > td { padding-top: 0; }
.fin-inv-details { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8125rem; min-width: 0; }
.fin-inv-detail { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; min-width: 0; }
.fin-inv-term { color: var(--text-muted); }
.fin-inv-reason { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
.fin-inv-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.fin-inv-btn { font-size: 0.75rem; }
.fin-inv-toggle { margin-left: 6px; }
.fin-inv-msg:empty { display: none; }
.fin-inv-soldout { margin-top: 8px; }
.fin-inv-soldout-title { margin: 0 0 4px; font-size: 0.875rem; }
.fin-inv-soldout-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
/* Tables: no word broken mid-letter. The name column keeps room and the
   wrapper scrolls sideways when the columns don't fit; a number, a
   header, Edit and Delete never wrap. */
.fin-inv-table th[scope="row"] { min-width: 10rem; overflow-wrap: break-word; }
.fin-inv-table thead th, .fin-inv-trades-table thead th { white-space: nowrap; overflow-wrap: normal; }
.fin-inv-table td, .fin-inv-trades-table td, .fin-inv-trades-table th[scope="row"] { overflow-wrap: normal; }
.fin-inv-trades-table th[scope="row"], .fin-inv-del-cell, .fin-inv-toggle { white-space: nowrap; }
.fin-inv-trade-name { min-width: 8rem; overflow-wrap: break-word; }
.fin-inv-table th, .fin-inv-table td, .fin-inv-trades-table th, .fin-inv-trades-table td { vertical-align: top; }
/* How a value was found: a muted line under it. */
.fin-inv-valued-line { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: 0.75rem; font-weight: 400; color: var(--text-muted); white-space: normal; }
.fin-inv-class-note { color: var(--text-muted); }
.fin-inv-table td[data-label="Value"] { min-width: 9rem; }
/* "Add price" and "Add yield": an empty editor that reads as a link. */
.fin-inv-add-link { color: var(--accent-text); text-decoration: underline; cursor: pointer; }
/* Delete as a secondary pill (the kit's button is otherwise unstyled). */
.fin-inv-trades-table .fin-delete, .fin-inv-actions .fin-delete, .fin-inv-soldout-item .fin-delete {
  font: inherit; font-size: 0.75rem; padding: 2px 10px; border: 1px solid var(--surface-border); border-radius: 999px;
  background: transparent; color: var(--red-text); white-space: nowrap; cursor: pointer;
}
.fin-inv-trades-table .fin-delete:hover, .fin-inv-actions .fin-delete:hover, .fin-inv-soldout-item .fin-delete:hover { border-color: var(--red); }
/* A card title with its ⓘ in the corner. */
.fin-inv-card-head { margin-bottom: 8px; }
.fin-inv-card-head > .fin-card-title { margin: 0; }
/* By asset class: the donut beside its table when there is room. */
.fin-inv-alloc-body { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: center; min-width: 0; }
@media (min-width: 768px) { .fin-inv-alloc-body { grid-template-columns: 220px minmax(0, 1fr); } }
/* The Money Master forms: fields in groups, inputs lined up, the ⓘ beside
   a field's label (not a grid cell of its own), Work it out its own size. */
.fin-inv-fee .fin-form { grid-template-columns: minmax(0, 1fr); }
.fin-inv-group { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); align-items: end; min-width: 0; margin: 0; padding: 8px 12px 12px; border: 1px solid var(--surface-border); border-radius: 8px; }
.fin-inv-group[hidden] { display: none; }
.fin-inv-legend { padding: 0 4px; font-size: 0.875rem; font-weight: 600; }
.fin-inv-funds { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 768px) { .fin-inv-funds { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fin-inv-funds .fin-inv-group { grid-template-columns: minmax(0, 1fr); }
.fin-inv-fee .fin-field, .fin-inv-buckets .fin-field { align-content: end; }
.fin-inv-fwrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 4px; align-items: start; align-self: end; min-width: 0; }
.fin-inv-buckets .fin-inv-own, .fin-inv-buckets .fin-inv-book, .fin-inv-split-total { grid-column: 1 / -1; }
.fin-inv-split-total { margin: 0; }
.fin-inv-split-total:empty { display: none; }
.fin-inv-fee .fin-form-go, .fin-inv-buckets .fin-form-go { grid-column: 1 / -1; justify-self: start; }
.fin-inv-book { margin-top: 0; }
.fin-inv-book-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fin-inv-book-line .fin-inv-book-head { margin: 4px 0 0; }
@media (pointer: coarse) {
  .fin-inv-btn { min-height: 44px; }
  .fin-inv-add-link { display: inline-block; min-height: 44px; }
}
/* Phones: each holding and each trade is a card, its cells two to a row,
   each named by its column (data-label), so nothing is squeezed to one
   letter a line. */
@media (max-width: 640px) {
  .fin-inv-table thead, .fin-inv-trades-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fin-inv-table, .fin-inv-table tbody, .fin-inv-trades-table, .fin-inv-trades-table tbody { display: block; }
  .fin-inv-table tr, .fin-inv-trades-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-inv-table th, .fin-inv-table td, .fin-inv-trades-table th, .fin-inv-trades-table td { display: block; padding: 2px 0; border: 0; text-align: left; min-width: 0; }
  .fin-inv-table th[scope="row"], .fin-inv-trades-table th[scope="row"], .fin-inv-more > td, .fin-inv-del-cell { grid-column: 1 / -1; }
  .fin-inv-table th[scope="row"], .fin-inv-table td[data-label="Value"] { min-width: 0; }
  .fin-inv-table td.num, .fin-inv-trades-table td.num { text-align: left; }
  .fin-inv-valued-line { justify-content: flex-start; }
  .fin-inv-trade-name { min-width: 0; overflow-wrap: break-word; }
  .fin-inv-blank:empty { display: none; }
  .fin-inv-table td[data-label]::before, .fin-inv-trades-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-muted);
  }
}

/* ==== Balance sheet ==== */
.fin-bs-month { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.fin-bs-pair { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 900px) { .fin-bs-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fin-bs-box { min-width: 0; }
.fin-bs-head { margin: 12px 0 4px; font-size: 0.9375rem; overflow-wrap: anywhere; }
.fin-bs-box .fin-bs-head { margin-top: 0; }
.fin-bs-in .fin-bs-head, .fin-bs-pos strong { color: var(--green-text); }
.fin-bs-out .fin-bs-head, .fin-bs-neg strong { color: var(--red-text); }
.fin-bs-cashflow { margin: 8px 0 0; }
.fin-bs-table .fin-bs-total th, .fin-bs-table .fin-bs-total td { font-weight: 700; border-bottom: 0; }
.fin-bs-table .fin-bs-empty th { color: var(--text-muted); font-weight: 400; }
.fin-bs-group { color: var(--text-muted); font-size: 0.8125rem; }
.fin-bs-tag { color: var(--text-muted); font-size: 0.8125rem; }
.fin-bs-link { padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: inherit; text-align: left; text-decoration: underline; cursor: pointer; overflow-wrap: anywhere; }
.fin-bs-add { margin: 8px 0; }
@media (pointer: coarse) { .fin-bs-link { min-height: 44px; } }
/* A section heading and its ⓘ on one line (the ⓘ beside the h5, never in it). */
.fin-bs-head-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin: 16px 0 4px; min-width: 0; }
.fin-bs-head-row > .fin-bs-head { margin: 0; }
/* Cells keep their words whole; only a row's name may break, and it keeps room. */
.fin-bs-table th, .fin-bs-table td { overflow-wrap: normal; }
.fin-bs-table th[scope="row"] { overflow-wrap: anywhere; min-width: 10rem; }
.fin-bs-table thead th { white-space: nowrap; }
.fin-bs-table td.num { font-variant-numeric: tabular-nums; }
.fin-bs-table td:last-child { width: 1%; white-space: nowrap; }
/* Delete in a row: a red text button, on one line (as on the Statement). */
.fin-bs-table .fin-delete {
  padding: 2px 4px; border: 0; border-radius: 4px; background: none; color: var(--red-text);
  font: inherit; font-size: 0.8125rem; text-decoration: underline; cursor: pointer; white-space: nowrap;
}
.fin-bs-table .fin-delete:hover { background: var(--surface2); }
/* Things edited in place look it: a dotted underline. */
.fin-bs-acct-kind, .fin-bs-debt-type { white-space: nowrap; text-decoration: underline dotted; text-underline-offset: 3px; }
/* Under an account's name: "Bank: … · Bucket: …". */
.fin-bs-acct-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin-top: 2px; font-size: 0.8125rem; font-weight: 400; min-width: 0; }
.fin-bs-meta-part { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px; min-width: 0; }
.fin-bs-meta-label, .fin-bs-meta-sep { color: var(--text-muted); }
.fin-bs-acct-meta .fin-inline, .fin-bs-holding-how .fin-inline { color: var(--accent-text); text-decoration: underline dotted; text-underline-offset: 3px; }
.fin-bs-acct-meta .fin-inline.fin-bs-unset { color: var(--text-muted); font-style: italic; }
/* A holding's "how it counts": one labelled line each. */
.fin-bs-holding-how { display: grid; gap: 2px; justify-items: start; font-size: 0.8125rem; min-width: 0; }
.fin-bs-how-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; min-width: 0; }
.fin-bs-how-label, .fin-bs-valued { color: var(--text-muted); }
/* The answer first: net worth, true cashflow net worth, debt-to-income. */
.fin-bs-facts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); margin: 4px 0 8px; min-width: 0; }
.fin-bs-facts .fin-fig { align-items: baseline; padding: 10px 12px; border: 2px solid var(--text); border-radius: 6px; min-width: 0; }
.fin-bs-facts .fin-fig-value { margin-left: auto; text-align: right; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-bs-inflation { margin: 8px 0; }
.fin-bs-inflation .fin-fig-value { font-size: 0.875rem; }
/* The month bar: the month field drawn like the pills beside it. */
.fin-bs-monthbar { align-items: center; }
.fin-bs-month-input {
  font: inherit; font-size: 0.875rem; padding: 4px 10px; border: 1px solid var(--surface-border); border-radius: 999px;
  background: var(--surface2); color: var(--text); min-width: 0; max-width: 100%;
}
.fin-bs-box > .fin-bs-add { margin: 8px 0 0; }
.fin-bs-cashflow-year { color: var(--text-muted); font-size: 0.875rem; }
.fin-bs-table .fin-bs-subtotal td { font-weight: 600; }
@media (pointer: coarse) {
  .fin-bs-table .fin-delete { min-height: 44px; min-width: 44px; }
  .fin-bs-monthbar .fpill, .fin-bs-month-input, .fin-bs-add { min-height: 44px; }
}
/* A column's ⓘ in its first row's figure is for phones only (the head has it). */
.fin-bs-table td.fin-bs-col-tip > .info-tip-wrap { display: none; }
/* Phones: each row stacks, its name across the top and its figures and
   Delete in a line under it; the column heads stay for screen readers
   only, and each figure says its column (data-col). */
@media (max-width: 640px) {
  .fin-bs-table-wrap { overflow: visible; }
  .fin-bs-table, .fin-bs-table tbody { display: block; width: 100%; }
  .fin-bs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-bs-table thead .info-tip-wrap, .fin-bs-table thead .info-tip { display: none; }
  .fin-bs-table td.fin-bs-col-tip > .info-tip-wrap { display: inline-flex; }
  .fin-bs-table tr { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-bs-table tr > * { display: block; padding: 0; border: 0 !important; }
  .fin-bs-table tr > th[scope="row"] { flex: 1 0 100%; min-width: 0; }
  .fin-bs-table tr.fin-bs-total > th[scope="row"], .fin-bs-table tr.fin-bs-group-row > th[scope="row"] { flex: 1 1 auto; }
  .fin-bs-table td:empty { display: none; }
  .fin-bs-table td:last-child { width: auto; }
  .fin-bs-table .fin-bs-holding-row > td:nth-child(2) { flex: 1 0 100%; }
  .fin-bs-table td.num::before { content: attr(data-col); color: var(--text-muted); font-size: 0.75rem; margin-right: 4px; font-weight: 400; }
}

/* ==== Finance settings ==== */
.fin-settings { display: grid; gap: 16px; min-width: 0; }
.fin-set-group { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0; min-width: 0; display: grid; gap: 14px; }
.fin-set-legend { font-weight: 600; font-size: 0.875rem; padding: 0 4px; }
.fin-set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; min-width: 0; }
.fin-set-row[hidden] { display: none; }
.fin-set-head { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.fin-set-label { font-size: 0.8125rem; color: var(--text); overflow-wrap: anywhere; }
.fin-set-source { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.fin-set-source.fin-set-yours { color: var(--accent-text, var(--text)); font-weight: 600; }
.fin-set-input { min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; }
.fin-set-default[hidden] { display: none; }
.fin-set-default, .fin-set-clear-mm, .fin-set-clear-old { font-size: 0.75rem; justify-self: start; }
.fin-set-row .field-error { grid-column: 1 / -1; }
/* A live region: kept in the layout while empty, so a note is announced. */
.fin-set-kept { grid-column: 1 / -1; margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.fin-set-status:empty { display: none; }
.fin-tax-debts { justify-self: start; margin-top: 8px; margin-right: 8px; }
@media (pointer: coarse) {
  .fin-set-input, .fin-set-default, .fin-set-clear-mm, .fin-set-clear-old, .fin-tax-debts { min-height: 44px; }
}

/* ==== Overview and charts ==== */
/* views/finance-charts.js: the SVG scales with the card; axis labels and
   legends are HTML beside it, so they keep their size on a phone. */
.fin-chart-wide { grid-column: 1 / -1; }
.fin-chart { margin: 8px 0 0; min-width: 0; overflow-x: clip; }
.fin-chart-plot { display: grid; grid-template-columns: 3.75em minmax(0, 1fr); column-gap: 6px; font-size: 0.75rem; }
.fin-chart-y { position: relative; min-width: 0; }
.fin-chart-ytick, .fin-chart-xtick { position: absolute; white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; line-height: 1.2; }
.fin-chart-ytick { right: 0; transform: translateY(-50%); }
.fin-chart-svg { display: block; width: 100%; max-width: 100%; height: auto; overflow: visible; }
.fin-chart-x { grid-column: 2; position: relative; height: 1.6em; }
.fin-chart-xtick { top: 3px; transform: translateX(-50%); }
.fin-chart-xtick.fin-x-start { transform: none; }
.fin-chart-xtick.fin-x-end { transform: translateX(-100%); }
/* groupedBars' months: every month on a plot 768px or wider, every second
   one below that. On the narrow plot the last month sits flush with the
   plot's right edge, so it clears the label two months before it. */
.fin-chart-months .fin-chart-x { container-type: inline-size; }
@container (max-width: 767.98px) {
  .fin-chart-months .fin-chart-xtick.fin-x-wide { display: none; }
  .fin-chart-months .fin-chart-xtick.fin-x-end { left: auto !important; right: 0; transform: none; }
}
.fin-chart-grid { stroke: var(--surface-border); stroke-width: 1; }
.fin-chart-zero { stroke: var(--text-muted); stroke-width: 1; }
.fin-c-0 { fill: var(--accent); }
.fin-c-income { fill: var(--green); }
.fin-c-spend, .fin-c-neg { fill: var(--red); }
.fin-chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.fin-chart-area { fill: var(--accent); opacity: 0.12; }
.fin-chart-dot { fill: var(--accent); }
.fin-chart-slice { stroke: var(--surface); stroke-width: 2; }
.fin-fan-outer { fill: var(--accent); opacity: 0.2; }
.fin-fan-inner { fill: var(--accent); opacity: 0.4; }
.fin-fan-median { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.fin-fan-target { stroke: var(--amber); stroke-width: 2; stroke-dasharray: 6 4; }
.fin-chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 0.75rem; color: var(--text-muted); }
.fin-chart-legend li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.fin-swatch { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.fin-swatch.fin-c-income { background: var(--green); }
.fin-swatch.fin-c-spend { background: var(--red); }
.fin-swatch.fin-fan-outer { background: var(--accent); opacity: 0.35; }
.fin-swatch.fin-fan-inner { background: var(--accent); opacity: 0.6; }
.fin-swatch.fin-fan-median { height: 3px; }
.fin-swatch.fin-fan-target { height: 3px; background: var(--amber); }
.fin-chart-donut .fin-chart-plot { display: block; max-width: 240px; margin: 0 auto; }
.fin-chart-donut .fin-chart-y, .fin-chart-donut .fin-chart-x, .fin-chart-donut .fin-chart-corner { display: none; }
.fin-spark { max-width: 360px; }
.fin-spark .fin-chart-line { stroke-width: 1.5; }
.fin-spark-mark { stroke: var(--amber); stroke-width: 1.5; }
.fin-chart-note { margin: 4px 0 0; font-size: 0.75rem; color: var(--text-muted); }
.fin-drill { margin-top: 10px; }
.fin-drill summary { cursor: pointer; min-height: 24px; font-size: 0.875rem; }
.fin-drill-title { margin: 12px 0 4px; font-size: 0.875rem; }
.fin-card-head .fpill { margin-left: auto; }
.fin-timeline-table td, .fin-timeline-table th { vertical-align: top; }
.fin-timeline-desc { display: block; color: var(--text-muted); font-size: 0.75rem; }
.fin-timeline-neg .fin-timeline-end { color: var(--red-text, var(--red)); }
.fin-timeline-actions { white-space: nowrap; }
.fin-timeline .fin-table-wrap { position: relative; }
@media (max-width: 640px) {
  .fin-timeline-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fin-timeline-table, .fin-timeline-table tbody { display: block; }
  .fin-timeline-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-timeline-table th, .fin-timeline-table td { display: block; padding: 2px 0; border: 0; text-align: left; }
  .fin-timeline-table tr > th, .fin-timeline-note, .fin-timeline-actions { grid-column: 1 / -1; }
  .fin-timeline-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-muted); }
  .fin-timeline-note:empty { display: none; }
}
.fin-edit { font-size: 0.75rem; margin-right: 4px; }
.fin-bhag-set { margin-top: 8px; }
@media (pointer: coarse) {
  .fin-edit, .fin-drill summary { min-height: 44px; }
}
/* Small row actions (Edit, Delete) as rounded pills like the page's other
   buttons, never the browser's grey box, on one line; the actions column
   hugs them. Delete in red. */
.fin-overview .fin-delete:not(.fpill), .fin-overview .fin-edit {
  font: inherit; font-size: 0.75rem; padding: 3px 10px; border-radius: 16px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); white-space: nowrap;
}
.fin-overview .fin-delete:not(.fpill) { color: var(--red-text); }
.fin-overview .fin-delete:not(.fpill):hover, .fin-overview .fin-edit:hover { border-color: var(--text-muted); }
.fin-overview td.fin-drill-actions, .fin-overview td.fin-timeline-actions { width: 1%; white-space: nowrap; }
.fin-timeline-table tbody th { white-space: nowrap; }
@media (max-width: 640px) { .fin-overview td.fin-timeline-actions { width: auto; } }
/* Buttons in a row keep a gap: the timeline's, the month pick's, the tax card's. */
.fin-timeline-bar, .fin-month-pick, .fin-ov-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fin-timeline-bar, .fin-ov-actions { margin-top: 8px; }
.fin-card-head .fin-month-pick { margin-left: auto; }
.fin-card-head .fin-month-pick .fpill { margin-left: 0; }
/* The month card: each figure's label (and ⓘ) above its value; the value
   is a link-like figure into its page. */
.fin-kpis .fin-kpi { align-content: flex-start; }
.fin-kpi .fin-fig-label { font-size: 0.8125rem; }
.fin-kpi > .fin-fig-value { flex: 1 0 100%; font-size: 1.25rem; font-weight: 700; }
.fin-kpi-go {
  font: inherit; padding: 0; border: 0; background: none; color: var(--text); text-align: left;
  cursor: pointer; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.fin-kpi-go:hover { color: var(--accent-text); text-decoration: underline; }
/* A text button that opens another page (the spending categories, Add an expense). */
.fin-overview .fin-link {
  font: inherit; padding: 0; border: 0; background: none; color: var(--accent-text);
  text-align: left; text-decoration: underline; cursor: pointer; overflow-wrap: anywhere;
}
.fin-freedom-add { margin-top: 8px; }
/* The Freedom Gap with no gap yet: a plain line, not the big figure. */
.fin-freedom .fin-freedom-none { font-size: 1.125rem; }
/* The Balance sheet summary: long labels wrap, the amounts never do and
   line up on the right. From 900px, with the account table, it spans the
   page, its figures on the left and the table on the right; without the
   table it keeps one column, so no amount sits far from its label. */
.fin-bs-summary .fin-bs-summary-facts { grid-template-columns: minmax(0, 1fr) auto; }
.fin-bs-summary .fin-bs-summary-facts dd { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.fin-ov-accounts caption { text-align: left; font-size: 0.875rem; color: var(--text-muted); padding: 8px 0 4px; }
.fin-ov-accounts tbody th { font-weight: 400; }
@media (min-width: 900px) {
  .fin-overview > .fin-bs-summary:has(> .fin-table-wrap) { grid-column: 1 / -1; }
  .fin-bs-summary:has(> .fin-table-wrap) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
  .fin-bs-summary > .fin-card-head { grid-column: 1 / -1; }
  .fin-bs-summary > .fin-table-wrap { grid-column: 2; grid-row: 2 / span 3; }
}
/* The 60/10/10/20 card: a planned figure looks typeable. */
.fin-barefoot-figures .fin-inline { text-decoration: underline dotted; text-underline-offset: 3px; }
/* One whole slice of a donut is one ring, no seams. */
.fin-chart-slice.fin-chart-slice-whole { stroke: none; }

/* ==== Debts ==== */
.fin-debts-add { margin: 0 0 8px; }
.fin-debt-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fin-debt-closed th, .fin-debt-closed td { color: var(--text-muted); }
.fin-debt-settled { font-size: 0.75rem; color: var(--text-muted); }
.fin-debts-table td, .fin-debts-table th { vertical-align: middle; }
/* The card's title and "+ Add debt" share the top row. */
.fin-debts-list-full { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
.fin-debts-list-full > * { flex: 1 1 100%; min-width: 0; }
.fin-debts-list-full > .fin-card-title { flex: 1 1 auto; margin: 0; }
.fin-debts-list-full > .fin-debts-add, .fin-debts-list-full > .info-tip-wrap { flex: 0 0 auto; margin: 0; }
.fin-debts-list-full > .fin-debt-total { margin-top: 8px; }
/* The tables never break a word: a column is as wide as its longest
   word, and a table too wide for its card scrolls inside its wrap. */
.fin-debts .fin-table th, .fin-debts .fin-table td, .fin-debts-table .fin-inline { overflow-wrap: normal; word-break: normal; }
.fin-debts-table th, .fin-debts-table td { padding: 6px; }
.fin-debts .fin-table tbody th { min-width: 8rem; }
.fin-debts .fin-debts-table tbody th { min-width: 9rem; }
.fin-debts-table thead th { vertical-align: bottom; }
.fin-debts-table thead th.num { white-space: normal; }
.fin-debts-table .fin-debt-order { text-align: center; }
.fin-debt-actions { flex-wrap: nowrap; }
.fin-debt-actions .fpill, .fin-debt-actions .fin-delete { white-space: nowrap; }
.fin-debt-actions .fin-delete {
  font: inherit; font-size: 0.75rem; padding: 2px 10px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--red-text); color: var(--red-text);
}
.fin-debt-actions .fin-delete:hover { background: var(--surface2); }
.fin-unset { color: var(--text-muted); font-style: italic; }
.fin-debt-details { display: grid; gap: 2px; margin-top: 4px; font-size: 0.75rem; }
.fin-debt-detail { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.fin-debt-detail-label, .fin-debt-detail .info-tip-wrap { white-space: nowrap; }
.fin-debt-detail-label { color: var(--text-muted); }
/* Repayments under the interest. */
.fin-debt-grows { margin: 8px 0; color: var(--red-text); font-size: 0.875rem; }
/* The dominoes' figures as tiles: label above value. */
.fin-debts-dominoes .fin-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 12px; margin: 8px 0; }
.fin-debts-dominoes .fin-figs .fin-fig { padding: 8px 12px; border-radius: 8px; background: var(--surface2); }
.fin-debts-dominoes .fin-figs .fin-fig-value { flex: 1 1 100%; font-weight: 600; }
/* Balance history: one small fold under the dominoes. */
.fin-debt-histories { margin-top: 8px; font-size: 0.875rem; }
.fin-debt-histories > summary { color: var(--text-muted); cursor: pointer; }
.fin-debt-history-name { margin: 8px 0 4px; font-weight: 600; overflow-wrap: anywhere; }
.fin-debt-history-list { margin: 0; padding-left: 1.25rem; display: grid; gap: 4px; }
.fin-debt-history-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
/* When each debt clears: a small subheading, the Clears header whole. */
.fin-debt-clears-label { margin: 16px 0 4px; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); }
.fin-debts-timeline .fin-table thead th { white-space: nowrap; }
/* The home loan: each field in its cell with its ⓘ beside it; Work it
   out on a row of its own. */
.fin-hl .fin-hl-cell { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 4px; align-items: start; min-width: 0; }
.fin-hl-needed { grid-column: 1 / -1; font-size: 0.75rem; color: var(--text-muted); }
.fin-hl .fin-form-go { grid-column: 1 / -1; justify-self: start; min-width: 10rem; }
.fin-hl-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* A phone or narrow tablet: each debt is a card, its cells labelled. */
@media (max-width: 768px) {
  .fin-debts-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-debts-table, .fin-debts-table tbody { display: block; }
  .fin-debts-table tr.fin-debt-row {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px;
    padding: 12px 0; border-bottom: 1px solid var(--surface-border);
  }
  .fin-debts-table tr.fin-debt-row > th, .fin-debts-table tr.fin-debt-row > td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  .fin-debts-table tr.fin-debt-row > th { grid-column: 1 / -1; font-size: 1rem; overflow-wrap: anywhere; }
  .fin-debts-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-muted); }
  .fin-debts-table td.fin-debt-actions-head { grid-column: 1 / -1; }
  .fin-debts-table td.fin-debt-actions-head::before { display: none; }
  .fin-debt-actions { flex-wrap: wrap; }
}
@media (pointer: coarse) {
  .fin-debts-add, .fin-debt-actions .fpill, .fin-debt-actions .fin-delete, .fin-debt-histories > summary { min-height: 44px; }
}

/* ==== Import bank CSV and Edit all (views/finance-import.js,
   finance-bulk-edit.js): a wider dialog whose tables scroll sideways
   inside it, never the page. ==== */
.modal.fin-modal-wide { width: min(60rem, 96vw); max-width: 96vw; }
.fin-modal-wide .modal-body { min-width: 0; }
.fin-modal-wide .fin-table-wrap { overflow-x: auto; max-width: 100%; }
.fin-bulk-table th, .fin-bulk-table td, .fin-import-table th, .fin-import-table td { vertical-align: top; }
.fin-bulk-table td, .fin-bulk-table th { min-width: 6rem; }
/* The import preview scrolls inside its wrap on a phone, never squashed:
   dates and amounts stay on one line, the headers whole. */
.fin-import-table td, .fin-import-table th { min-width: 6rem; }
.fin-import-table th, .fin-import-date, .fin-import-amount { white-space: nowrap; }
.fin-bulk-changed { box-shadow: inset 3px 0 0 var(--accent); }
.fin-bulk-status, .fin-import-summary { margin: 8px 0; font-size: 0.875rem; }
.fin-bulk-problem[hidden] { display: none; }
.fin-import-off td { color: var(--text-muted); opacity: 0.7; }
.fin-import input[type="file"] { padding: 6px 0; border: none; background: transparent; }
.fin-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.fin-section-head .fin-card-sub { margin: 0; }
@media (pointer: coarse) {
  .fin-section-head .fpill, .fin-txn-bar .fpill { min-height: 44px; }
}

/* ==== Review fixes: containment and target sizes ==== */
/* A table's hidden header words (absolute) stay inside its scrolling
   box, so a wide table never makes the page scroll sideways. */
.fin-table-wrap { position: relative; }
/* 24px to point at with a mouse (WCAG 2.5.8), 44px on touch. */
.fin-inline-clear, .fin-fig-edit, .fin-field-default, .fin-delete, .fin-link, .fin-stage-pin, .fin-kpi-go { min-height: 24px; }
.fin-inline { display: inline-block; min-height: 24px; line-height: 24px; }
.fin-check { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; }
@media (pointer: coarse) {
  .fin-link, .fin-stage-pin, .fin-check, .fin-kpi-go { min-height: 44px; }
}

/* ==== Barefoot (views/finance-barefoot.js) and the Overview's steps card ==== */
.fin-barefoot-page { display: grid; gap: 16px; min-width: 0; }
.fin-bf-bar, .fin-bf-step-bar {
  display: block; width: 100%; max-width: 100%; height: 0.625rem; accent-color: var(--accent);
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface2);
}
.fin-bf-bar::-webkit-progress-bar, .fin-bf-step-bar::-webkit-progress-bar { background: var(--surface2); border-radius: 999px; }
.fin-bf-bar::-webkit-progress-value, .fin-bf-step-bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.fin-bf-bar::-moz-progress-bar, .fin-bf-step-bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.fin-bf-where, .fin-steps-where { margin: 4px 0; font-weight: 600; overflow-wrap: anywhere; }
.fin-bf-count, .fin-steps-count { margin: 4px 0 0; font-size: 0.875rem; color: var(--text-muted); }
.fin-bf-clear { margin-top: 8px; }
.fin-bf-empty { margin: 0; overflow-wrap: anywhere; }
.fin-bf-group { display: grid; gap: 8px; min-width: 0; }
.fin-bf-group-title { margin: 8px 0 0; font-size: 1.125rem; }
.fin-bf-group-sub { margin: 0; }
.fin-bf-steps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; align-items: start; }
@media (min-width: 768px) {
  .fin-bf-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* An odd last card takes the whole row, not half of it. */
  .fin-bf-steps > .fin-bf-step:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.fin-bf-step { min-width: 0; }
.fin-bf-step[aria-current="step"] { border-color: var(--accent); }
.fin-bf-step-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.fin-bf-step-title { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.fin-bf-here {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--accent-text, var(--text)); border: 1px solid var(--accent);
}
.fin-bf-step-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0; min-width: 0; }
.fin-bf-step-progress .fin-bf-step-bar { flex: 1 1 8rem; width: auto; }
.fin-bf-step-count { font-size: 0.875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fin-bf-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.fin-bf-tasks { --fin-bf-box: 1.125rem; }
/* Each task: the box and its text, then the note (with its ⓘ) and "Use my
   figures" on one line under the text, at every width. */
.fin-bf-tasks li { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; min-width: 0; }
.fin-bf-tasks .fin-bf-label { display: flex; min-width: 0; align-items: flex-start; overflow-wrap: anywhere; }
.fin-bf-tasks .fin-bf-label input {
  flex: none; width: var(--fin-bf-box); height: var(--fin-bf-box); margin: 0.15em 0 0; accent-color: var(--accent);
}
.fin-bf-text { min-width: 0; overflow-wrap: anywhere; }
.fin-bf-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0;
  padding-left: calc(var(--fin-bf-box) + 6px);
}
.fin-bf-note { font-size: 0.75rem; color: var(--text-muted); overflow-wrap: anywhere; min-width: 0; }
.fin-bf-meta .fin-bf-use-data { margin-left: auto; }
.fin-bf-tasks .fin-bf-problem { padding-left: calc(var(--fin-bf-box) + 6px); }
.fin-bf-problem:empty { display: none; }
/* The worked-out and typed figures: a footer for the card. */
.fin-bf-figs { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.fin-bf-figs .fin-fig-value { font-size: 0.875rem; font-weight: 600; }
/* A figure typed in place looks typeable without a hover. */
.fin-bf-figs .fin-inline { border-bottom: 1px dashed var(--accent); border-radius: 0; padding: 0 4px; }
.fin-bf-fig-go { margin-top: 4px; }
.fin-bf-locked { color: var(--text-muted); }
.fin-steps-next { overflow-wrap: anywhere; }
@media (pointer: coarse) {
  .fin-bf-tasks { --fin-bf-box: 1.25rem; }
  .fin-bf-tasks .fin-bf-label { min-height: 44px; align-items: center; }
  .fin-bf-tasks .fin-bf-label input { margin-top: 0; }
  .fin-bf-fig-go .fpill { min-height: 44px; }
  .fin-bf-use-data { min-height: 44px; }
}

/* ==== Income (views/finance-income.js) ==== */
/* The month bar: ‹ month › always the same shape; › greyed on this month. */
.fin-inc-month .fin-month-label { min-width: 6.5rem; }
.fin-inc-month [aria-disabled="true"] { opacity: 0.45; cursor: default; }
/* The statement: actions first, then the headline, the figure tiles and
   the passive-cover line. */
.fin-inc-page .fin-income-statement > .fin-txn-add { margin: 8px 0 16px; }
.fin-inc-headline { margin: 0 0 12px; }
.fin-inc-headline.fin-inc-pos { color: var(--green-text); }
.fin-inc-headline.fin-inc-neg { color: var(--red-text); }
.fin-inc-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr)); gap: 12px; margin: 0 0 12px; min-width: 0; }
.fin-inc-figs .fin-fig {
  flex-direction: row; align-items: center; align-content: flex-start; gap: 2px 4px;
  padding: 10px 12px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--surface-border);
}
.fin-inc-figs .fin-fig-value { flex: 1 0 100%; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-inc-figs .fin-inc-cf.fin-inc-pos .fin-fig-value { color: var(--green-text); }
.fin-inc-figs .fin-inc-cf.fin-inc-neg .fin-fig-value { color: var(--red-text); }
.fin-inc-covered { margin: 0 0 4px; font-size: 0.875rem; color: var(--text-muted); overflow-wrap: anywhere; }
.fin-inc-start-lead { margin: 0 0 4px; font-size: 1.125rem; font-weight: 700; }
/* Net worth, one line at the foot of the statement. */
.fin-inc-nw { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); min-width: 0; }
.fin-inc-nw .fin-fig-value { font-weight: 700; }
/* Section headers: Edit all and its ⓘ together at the right. */
.fin-inc-section-actions { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
/* Only the first Edit all has an ⓘ; the others keep its space, so every
   header's Edit all ends at the same place. */
.fin-inc-section-actions > .info-tip-wrap { flex: 0 0 1.5rem; justify-content: center; margin: 0; }
.fin-inc-section-actions:not(:has(> .info-tip-wrap))::after { content: ''; flex: 0 0 1.5rem; }
/* The statement's tables: fixed columns, so every section lines up. */
.fin-inc-stmt { width: 100%; table-layout: fixed; }
.fin-inc-stmt .fin-inc-col-kind { width: 12rem; }
.fin-inc-stmt .fin-inc-col-amount { width: 8rem; }
.fin-inc-stmt .fin-inc-col-del { width: 6rem; }
.fin-inc-stmt th[scope="row"] { overflow-wrap: anywhere; font-weight: 400; }
.fin-inc-stmt td.num, .fin-inc-stmt th.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-inc-kind, .fin-inc-bucket { white-space: nowrap; }
/* Delete in a row: a red text button on one line, as on the Financial statement. */
.fin-inc-page td .fin-delete {
  padding: 2px 4px; border: 0; border-radius: 4px; background: none; font: inherit; font-size: 0.8125rem;
  color: var(--red-text); text-decoration: underline; cursor: pointer; white-space: nowrap;
}
.fin-inc-page td .fin-delete:hover { background: var(--surface2); }
.fin-inc-page td:last-child:has(> .fin-delete) { width: 1%; white-space: nowrap; }
/* The page's own pickers (Show, Financial year). */
.fin-inc-window, .fin-inc-fy-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; min-width: 0; }
.fin-inc-window label, .fin-inc-fy-pick label { font-size: 0.875rem; color: var(--text-muted); }
.fin-inc-window select, .fin-inc-fy-pick select {
  font: inherit; font-size: 0.875rem; padding: 4px 8px; min-width: 0; max-width: 100%;
  border-radius: 8px; border: 1px solid var(--surface-border); background: var(--surface2); color: var(--text);
}
/* A card title's ⓘ sits in the card's corner. */
.fin-inc-plan, .fin-inc-recent, .fin-inc-planned-card { position: relative; }
.fin-inc-plan > .fin-card-title, .fin-inc-recent > .fin-card-title, .fin-inc-planned-card > .fin-card-title { padding-right: 32px; }
.fin-inc-plan > .fin-card-title + .info-tip-wrap, .fin-inc-recent > .fin-card-title + .info-tip-wrap,
.fin-inc-planned-card > .fin-card-title + .info-tip-wrap { position: absolute; top: 14px; right: 14px; margin: 0; }
.fin-inc-fy .fin-inc-fy-total th, .fin-inc-fy .fin-inc-fy-total td { font-weight: 700; }
/* Headers and figures never break mid-word. */
.fin-inc-page .fin-plan-table th[scope="col"], .fin-inc-page .fin-plan-table td.num,
.fin-inc-page .fin-txn-table th[scope="col"], .fin-inc-recent-date, .fin-inc-page .fin-txn-table td.num,
.fin-inc-sources th[scope="col"], .fin-inc-sources td.num { white-space: nowrap; }
.fin-inc-sources th[scope="row"] { overflow-wrap: anywhere; }
/* Plan ahead: words break only when they cannot fit their column, and
   the month stays on one line (phones break anywhere, below). */
.fin-inc-page .fin-plan-table td { overflow-wrap: break-word; }
.fin-inc-page .fin-plan-table th[scope="row"] { white-space: nowrap; }
.fin-inc-page .fin-txn-table th[scope="row"], .fin-inc-recent-cat { overflow-wrap: anywhere; }
@media (pointer: coarse) {
  .fin-inc-page td .fin-delete, .fin-inc-window select, .fin-inc-fy-pick select, .fin-inc-nw .fpill { min-height: 44px; min-width: 44px; }
}
/* Phones: each row of the statement, plan and recent lists stacks, its
   name across the top and its fields in a line under it; the column
   heads are kept for screen readers only. */
@media (max-width: 640px) {
  .fin-inc-stmt, .fin-inc-stmt tbody, .fin-inc-page .fin-plan-table, .fin-inc-page .fin-plan-table tbody,
  .fin-inc-recent .fin-txn-table, .fin-inc-recent .fin-txn-table tbody { display: block; width: 100%; }
  .fin-inc-stmt colgroup { display: none; }
  .fin-inc-stmt thead, .fin-inc-page .fin-plan-table thead, .fin-inc-recent .fin-txn-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .fin-inc-stmt tr, .fin-inc-page .fin-plan-table tr, .fin-inc-recent .fin-txn-table tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--border);
  }
  .fin-inc-stmt tr > *, .fin-inc-page .fin-plan-table tr > *, .fin-inc-recent .fin-txn-table tr > * { display: block; padding: 0; border: 0; }
  .fin-inc-stmt tr > th[scope="row"], .fin-inc-page .fin-plan-table tr > th[scope="row"],
  .fin-inc-recent .fin-txn-table tr > th[scope="row"] { flex: 1 0 100%; }
  .fin-inc-stmt tr > td.num, .fin-inc-recent .fin-txn-table tr > td.num { margin-left: auto; }
  .fin-inc-stmt td:empty, .fin-inc-page .fin-plan-table td:empty { display: none; }
  .fin-inc-page td:last-child:has(> .fin-delete) { width: auto; }
  .fin-inc-page .fin-plan-table td { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
  .fin-inc-page .fin-plan-table td:last-child:has(> .fin-delete) { flex: 0 0 auto; }
  .fin-inc-page .fin-plan-table td[data-col]::before {
    content: attr(data-col); display: block; color: var(--text-muted); font-size: 0.75rem;
  }
  .fin-inc-page .fin-plan-table td.num { text-align: left; }
  .fin-inc-recent-date, .fin-inc-recent-cat { color: var(--text-muted); font-size: 0.875rem; }
  .fin-inc-sources .fin-table, .fin-inc-sources .fin-table tbody { display: block; width: 100%; }
  .fin-inc-sources .fin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-inc-sources .fin-table tr { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .fin-inc-sources .fin-table tr > * { display: block; padding: 0; border: 0; }
  .fin-inc-sources .fin-table tr > th[scope="row"] { flex: 1 0 100%; overflow-wrap: anywhere; }
  .fin-inc-sources .fin-table td { flex: 1 1 5rem; text-align: left; }
  .fin-inc-sources .fin-table td[data-col]::before { content: attr(data-col); display: block; color: var(--text-muted); font-size: 0.75rem; }
  .fin-inc-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fin-inc-figs .fin-inc-cf { grid-column: 1 / -1; }
}
/* Plan ahead's text, typed in place: whole words wrap above phones (the
   inline editor's own rule breaks anywhere). */
@media (min-width: 641px) { .fin-inc-page .fin-plan-table td .fin-inline { overflow-wrap: break-word; } }
/* (add Income rules above this line) */

/* ==== Tax (views/finance-tax.js) ==== */
/* The year for every card, above them. */
.fin-tax-fy { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.fin-tax-fy-label { font-size: 0.875rem; color: var(--text-muted); }
.fin-tax-fy-select { min-width: 0; max-width: 100%; font: inherit; font-size: 0.875rem; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
/* A card's heading and its ⓘ on one line, the ⓘ in the corner. */
.fin-tax-head { margin-bottom: 8px; flex-wrap: nowrap; }
.fin-tax-head > .fin-card-title { margin: 0; }
.fin-tax-sub { margin: 0 0 6px; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
/* Typed figures and worked-out ones side by side on a wide screen. */
.fin-tax-au-body { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 900px) { .fin-tax-au-body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; align-items: start; } }
.fin-tax-col { min-width: 0; }
/* Each figure: its label and ⓘ on the left, the amount at the right edge, so amounts line up. */
.fin-tax-inputs, .fin-tax-results, .fin-tax-hecs-figures { display: grid; gap: 6px; max-width: 36rem; min-width: 0; }
.fin-tax-page .fin-tax-inputs .fin-fig, .fin-tax-page .fin-tax-results .fin-fig, .fin-tax-hecs-figures .fin-fig { justify-content: flex-start; gap: 4px 8px; }
.fin-tax-page .fin-tax-inputs .fin-fig-value, .fin-tax-page .fin-tax-results .fin-fig-value, .fin-tax-hecs-figures .fin-fig-value { margin-left: auto; text-align: right; }
.fin-tax-inputs .fin-inline-wrap { justify-content: flex-end; }
/* What you can type looks like a field. */
.fin-tax-inputs .fin-inline { border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--surface); }
.fin-tax-inputs .fin-inline:hover { background: var(--surface2); }
.fin-tax-income { display: grid; gap: 4px; min-width: 0; }
.fin-tax-per { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-self: end; }
.fin-tax-per-btn[aria-pressed="true"] { background: var(--surface2); border-color: var(--accent); color: var(--text); font-weight: 600; }
.fin-tax-both { text-align: right; margin: 0; }
/* The answers: bigger, at the top of the results. */
.fin-tax-summary { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); margin-bottom: 8px; }
.fin-tax-summary .fin-fig-value { font-size: 1.25rem; font-weight: 700; }
.fin-tax-summary .fin-tax-payg-go { font-size: 0.875rem; font-weight: 400; }
/* Folds: how it is worked out, the small print, rarely needed figures. */
.fin-tax-fold { margin-top: 8px; min-width: 0; }
.fin-tax-fold > summary { cursor: pointer; font-size: 0.875rem; color: var(--text-muted); padding: 4px 0; }
.fin-tax-fold[open] > summary { margin-bottom: 6px; }
.fin-tax-hecs-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.fin-tax-franking-total { margin-top: 12px; }
.fin-tax-tools { margin-top: 12px; }
.fin-tax-years > .fpill { margin-top: 8px; }
.fin-tax-counted-head { margin: 0 0 8px; }
/* Table captions as small left-aligned lines, like the other Finance tables. */
.fin-tax-cgt-table caption, .fin-tax-div-table caption, .fin-tax-table caption { caption-side: top; text-align: left; font-size: 0.875rem; color: var(--text-muted); padding-bottom: 4px; }
.fin-tax-page .fin-tax-date { white-space: nowrap; }
.fin-tax-sofar { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }
/* The salary before super, under a package that includes it. */
.fin-tax-before-super { display: block; font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
@media (pointer: coarse) {
  .fin-tax-fy-select, .fin-tax-per-btn, .fin-tax-payg-go, .fin-tax-hecs-actions .fpill, .fin-tax-add, .fin-tax-add-payment, .fin-tax-fold > summary { min-height: 44px; }
}
/* Phones: each sale and dividend stacks, its name across the top and
   each figure under its column's name (data-label); the column heads
   are kept for screen readers only. */
@media (max-width: 600px) {
  .fin-tax-cgt-table, .fin-tax-cgt-table tbody, .fin-tax-div-table, .fin-tax-div-table tbody { display: block; width: 100%; }
  .fin-tax-cgt-table thead, .fin-tax-div-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-tax-cgt-table tr, .fin-tax-div-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--surface-border); }
  .fin-tax-cgt-table th, .fin-tax-cgt-table td, .fin-tax-div-table th, .fin-tax-div-table td { display: block; padding: 2px 0; border: 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  .fin-tax-cgt-table .fin-tax-name, .fin-tax-div-table .fin-tax-name { grid-column: 1 / -1; font-weight: 600; }
  .fin-tax-cgt-table td[data-label]::before, .fin-tax-div-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-muted); }
  .fin-tax-div-table .fin-inline-wrap { justify-content: flex-start; }
  .fin-tax-table th[scope="row"] { white-space: nowrap; }
}
/* (add Tax rules above this line) */

/* ==== Projections (views/finance-projections.js) ==== */
/* Each card's ⓘ sits in its corner, not on a row of its own. */
.fin-proj .fin-card { position: relative; }
.fin-proj .fin-card > .fin-card-title { padding-right: 32px; }
.fin-proj .fin-card > .fin-card-title + .info-tip-wrap { position: absolute; top: 16px; right: 16px; margin: 0; }
/* The form: one grid cell per field (3, 2 or 1 across), each ⓘ beside
   its label inside the field, the "Blank uses" line under the input. */
.fin-proj .fin-form {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 14px 16px; align-items: start; margin: 8px 0 0;
}
.fin-proj .fin-proj-field { grid-template-columns: fit-content(calc(100% - 2rem)) minmax(1.5rem, 1fr); align-content: start; column-gap: 4px; }
.fin-proj .fin-proj-field > * { grid-column: 1 / -1; }
.fin-proj .fin-proj-field > .fin-field-label { grid-column: 1; grid-row: 1; align-self: center; }
/* A long label wraps (large text on a phone), never widening the page. */
.fin-proj .fin-proj-field { min-width: 0; }
.fin-proj .fin-proj-field > .fin-field-label { min-width: 0; white-space: normal; overflow-wrap: break-word; }
.fin-proj .fin-proj-field > .fin-field-label + .info-tip-wrap { grid-column: 2; grid-row: 1; justify-self: start; align-self: center; margin: 0; }
.fin-proj .fin-proj-blank { margin: 0; }
.fin-proj .fin-proj-guesses { margin: 0 0 4px; font-size: 0.8125rem; }
/* Show projection and Reset to defaults: one row under the fields, same height. */
.fin-proj .fin-proj-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.fin-proj .fin-proj-actions .fpill { min-height: 36px; padding: 6px 16px; font-size: 0.875rem; }
@media (pointer: coarse) { .fin-proj .fin-proj-actions .fpill { min-height: 44px; } }
/* Month names are links to Transactions, drawn as text links. */
.fin-proj .fin-link {
  padding: 0; border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600;
  text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.fin-proj .fin-link:hover { color: var(--accent-light); }
.fin-proj .fin-proj-to-field { margin: 0 0 8px; }
.fin-proj .fin-proj-mc > .fin-result { margin-top: 12px; }
/* The 12 months: months on one line, "(to date)" on a small line under. */
.fin-proj-trend .fin-table th, .fin-proj-trend .fin-table td { overflow-wrap: normal; }
.fin-proj-trend .fin-table tbody th, .fin-proj-trend .fin-link { white-space: nowrap; }
.fin-proj .fin-proj-partial { display: block; color: var(--text-muted); font-size: 0.75rem; font-weight: 400; }
/* A net worth figure can be typed over: a dashed underline says so. */
.fin-proj-trend .fin-inline { text-decoration: underline dashed var(--text-muted); text-underline-offset: 3px; }
.fin-proj .fin-proj-legend { margin-top: 8px; }
.fin-proj .fin-proj-legend .info-tip-wrap { margin-right: 12px; }
/* Phones: Surplus (income less spending) steps aside so the rest fits. */
@media (max-width: 560px) {
  .fin-proj-trend .fin-table tr > :nth-child(4) { display: none; }
  /* A typed net worth's Clear goes under the figure, not past the edge. */
  .fin-proj-trend .fin-inline-wrap { flex-direction: column; align-items: flex-end; gap: 2px; }
  .fin-proj-trend .fin-table th, .fin-proj-trend .fin-table td { padding: 6px 4px; }
  .fin-proj-trend .fin-table thead th.num { white-space: normal; }
  .fin-proj-legend .fin-legend-term:first-of-type, .fin-proj-legend .fin-legend-term:first-of-type + .info-tip-wrap { display: none; }
}
/* (add Projections rules above this line) */

/* ==== Freedom (views/finance-freedom.js) ==== */
/* The form is a column of groups; each group lays out its own fields.
   Fields, selects and the button keep their own height. */
.fin-free .fin-form { grid-template-columns: minmax(0, 1fr); align-items: start; gap: 16px; }
.fin-free .fin-form-go { justify-self: start; }
.fin-free-needs { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--accent); }
.fin-free-group {
  position: relative; min-width: 0; margin: 0; padding: 12px;
  border: 1px solid var(--surface-border); border-radius: 8px;
}
.fin-free-group-title {
  float: left; width: 100%; margin: 0 0 8px; padding: 0 28px 0 0;
  font-size: 0.9375rem; font-weight: 600; color: var(--text);
}
/* A group's ⓘ sits in its corner, never in a cell of its grid. */
.fin-free-group > .info-tip-wrap { position: absolute; top: 12px; right: 12px; margin: 0; }
.fin-free-group-fields {
  clear: both; display: grid; gap: 12px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}
/* A field with a hint: its ⓘ beside the label, at the top right of the field. */
.fin-free-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 4px; align-items: start; min-width: 0; }
.fin-free-field > .info-tip-wrap { margin: 0; }
.fin-free .fin-field-suffix { font-size: 0.75rem; }
.fin-free-chip {
  display: inline-block; margin-left: 2px; padding: 0 6px; border-radius: 999px;
  border: 1px solid var(--surface-border); font-size: 0.75rem; line-height: 1.5; white-space: nowrap;
  color: var(--text-muted);
}
.fin-free-chip-needed { border-color: var(--accent); color: var(--text); }
.fin-free-per { clear: both; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.fin-free-per-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.fin-free-level.fin-sub { margin: 0; align-self: center; }
.fin-free-more { min-width: 0; }
.fin-free-more-summary { cursor: pointer; padding: 6px 0; font-weight: 600; font-size: 0.9375rem; }
.fin-free-more[open] > .fin-free-more-summary { margin-bottom: 8px; }
.fin-free-foot { display: grid; gap: 6px; justify-items: start; margin-top: 12px; }
.fin-free-foot .fin-sub { margin: 0; }
/* The label and its ⓘ share a row; the value and Change wrap under them. */
.fin-free-now .fin-fig-value { flex-basis: 100%; font-size: 1.375rem; font-weight: 700; }
.fin-free-now .fin-sub { margin: 6px 0 0; }
.fin-free-level-lines { padding: 10px 0; border-top: 1px solid var(--surface-border); }
.fin-free-level-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.fin-free-level-head .fin-actions { margin: 0; }
.fin-free-level-name { margin: 0; font-weight: 600; }
.fin-free-line-list { margin: 8px 0 0; padding-left: 1.25rem; }
@media (pointer: coarse) {
  .fin-free-per-btn { min-height: 44px; }
  .fin-free-more-summary { padding: 12px 0; }
}
/* (add Freedom rules above this line) */

/* ==== Financial statement (views/finance-statement.js) ==== */
/* Laid out like a paper cash flow sheet: each box headed by a solid bar,
   the income and expense boxes on the left with the summary beside them,
   assets and liabilities side by side. One column on a phone. */
.fin-stmt { display: grid; gap: 16px; min-width: 0; }
.fin-stmt-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 900px) {
  .fin-stmt-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
  .fin-stmt-summary { position: sticky; top: 12px; }
}
.fin-stmt-col { display: grid; gap: 16px; min-width: 0; }
.fin-stmt-box { min-width: 0; border: 2px solid var(--text); border-radius: 6px; overflow: hidden; background: var(--surface); }
.fin-stmt-head {
  margin: 0; padding: 6px 12px; background: var(--text); color: var(--surface);
  font-size: 0.9375rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.fin-stmt-box > .fin-table-wrap, .fin-stmt-box > .fin-fig, .fin-stmt-box > .fin-stmt-note { margin: 0 12px; }
.fin-stmt-box > .fin-fig { padding: 10px 0; border-top: 1px solid var(--border); }
.fin-stmt-box > .fin-fig:first-of-type { border-top: 0; }
.fin-stmt-table { width: 100%; }
.fin-stmt-table th[scope="row"] { overflow-wrap: anywhere; font-weight: 400; }
.fin-stmt-table .fin-stmt-group-row th, .fin-stmt-table .fin-stmt-group-row td { padding-top: 12px; font-weight: 600; border-bottom: 1px solid var(--text); }
.fin-stmt-group { font-weight: 600; color: var(--text); }
.fin-stmt-table .fin-stmt-line th { padding-left: 14px; }
.fin-stmt-from { color: var(--text-muted); font-size: 0.8125rem; }
.fin-stmt-none { color: var(--text-muted); }
.fin-stmt-table .fin-stmt-total th, .fin-stmt-table .fin-stmt-total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.fin-stmt-table .fin-stmt-add-row th { padding-left: 14px; border-bottom: 0; }
.fin-stmt-add { margin: 2px 0; }
.fin-stmt-note { padding: 8px 0 10px; }
/* Assets and liabilities side by side only when the Shares table has room. */
@media (min-width: 1200px) { .fin-stmt-grid-even { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Below 900px the summary (the answer) comes before the long lists. */
@media (max-width: 899px) { .fin-stmt-summary { order: -1; } }
/* A figure's label and ⓘ stay together on the left; its value sits at the right edge. */
.fin-stmt-summary .fin-fig, .fin-stmt-networth, .fin-stmt-assets-total, .fin-stmt-liabilities-total {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; gap: 4px 8px;
}
.fin-stmt-summary .fin-fig-value, .fin-stmt-networth .fin-fig-value,
.fin-stmt-assets-total .fin-fig-value, .fin-stmt-liabilities-total .fin-fig-value { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.fin-stmt-summary .fin-fig-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-stmt-passive .fin-fig-value { color: var(--green-text); }
.fin-stmt-cashflow { border-top: 2px solid var(--text) !important; }
.fin-stmt-cashflow .fin-fig-value { font-size: 1.5rem; }
.fin-stmt-neg .fin-fig-value { color: var(--red-text); }
.fin-stmt-bar { height: 12px; border-radius: 6px; background: var(--border); overflow: hidden; margin: 8px 0; }
.fin-stmt-bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.fin-stmt-bar-met .fin-stmt-bar-fill { background: var(--green); }
.fin-stmt-assets-total, .fin-stmt-liabilities-total { font-weight: 700; }
.fin-stmt-networth { margin-top: 12px; padding: 10px 12px; border: 2px solid var(--text); border-radius: 6px; }
.fin-stmt-networth .fin-fig-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fin-stmt-link { text-align: left; }
@media (pointer: coarse) { .fin-stmt-add { min-height: 44px; } }
.fin-stmt-detail { display: block; color: var(--text-muted); font-size: 0.8125rem; font-weight: 400; }
.fin-stmt-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.fin-stmt-autotax { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; cursor: pointer; }
.fin-stmt-auto th { font-style: normal; }
.fin-stmt-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-stmt-table .fin-delete, .fin-stmt-table .fin-stmt-edit { white-space: nowrap; }
.fin-stmt-table td:last-child { width: 1%; }
.fin-stmt-table .fin-stmt-zero th, .fin-stmt-table .fin-stmt-zero td { color: var(--text-muted); font-weight: 400; border-bottom-color: var(--border); }
.fin-stmt-table .fin-stmt-zero .fin-stmt-group { color: var(--text-muted); font-weight: 400; }
.fin-stmt-table .fin-stmt-subtotal th, .fin-stmt-table .fin-stmt-subtotal td { font-weight: 700; border-top: 1px solid var(--text); border-bottom: 0; }
/* Phones: each row stacks, its name across the top and its figures and
   buttons in a line under it; the column heads are kept for screen
   readers only (each figure's column still reads from its cell). */
@media (max-width: 640px) {
  .fin-stmt-table, .fin-stmt-table tbody { display: block; width: 100%; }
  .fin-stmt-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fin-stmt-table tr { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: flex-end; gap: 2px 14px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .fin-stmt-table tr > * { display: block; padding: 0; border: 0 !important; }
  .fin-stmt-table tr > th[scope="row"] { flex: 1 0 100%; padding-left: 0; }
  .fin-stmt-table tr.fin-stmt-group-row > th[scope="row"], .fin-stmt-table tr.fin-stmt-total > th[scope="row"],
  .fin-stmt-table tr.fin-stmt-subtotal > th[scope="row"] { flex: 1 1 auto; }
  .fin-stmt-table td:empty { display: none; }
  .fin-stmt-table td:last-child { width: auto; }
  .fin-stmt-table .fin-stmt-group-row { border-bottom: 1px solid var(--text); padding-top: 12px; }
  .fin-stmt-table .fin-stmt-total, .fin-stmt-table .fin-stmt-subtotal { border-top: 2px solid var(--text); border-bottom: 0; }
  .fin-stmt-table td.num::before { content: attr(data-col); color: var(--text-muted); font-size: 0.75rem; margin-right: 4px; font-weight: 400; }
  .fin-stmt-box > .fin-table-wrap { overflow: visible; }
}
.fin-stmt-sub { margin: 12px 12px 0; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }

/* Buttons in a row: one line, one style (text buttons; Delete in red). */
.fin-stmt-acts { flex-wrap: nowrap; align-items: baseline; }
.fin-stmt-table .fin-delete, .fin-stmt-table .fin-stmt-edit, .fin-stmt-small-add {
  padding: 2px 4px; border: 0; border-radius: 4px; background: none; font: inherit; font-size: 0.8125rem;
  text-decoration: underline; cursor: pointer; white-space: nowrap;
}
.fin-stmt-table .fin-delete { color: var(--red-text); }
.fin-stmt-table .fin-stmt-edit, .fin-stmt-small-add { color: var(--accent-text); }
.fin-stmt-table .fin-stmt-add-row td { border-bottom: 0; }
.fin-stmt-table .fin-stmt-note-row th { font-weight: 400; }
.fin-stmt-cf { display: flex; flex-direction: column; align-items: flex-end; }
.fin-stmt-cf-year { font-size: 0.875rem; font-weight: 400; color: var(--text-muted); }
.fin-stmt-neg .fin-stmt-cf-year { color: var(--red-text); }
@media (pointer: coarse) {
  .fin-stmt-table .fin-delete, .fin-stmt-table .fin-stmt-edit, .fin-stmt-small-add { min-height: 44px; min-width: 44px; }
}
@media (max-width: 640px) {
  /* An empty line is just its name, its $0 and its + Add: no year. */
  .fin-stmt-table .fin-stmt-zero td.num:nth-of-type(2) { display: none; }
}
