/* payables — "ledger instrument" theme. Layered over Pico; vendored fonts, no CDN.
   Cool paper, ink text, deep-teal accent, monospace figures aligned like a ledger. */

@font-face {
  font-family: "Plex Sans";
  src: url("/static/fonts/plex-sans-400.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Plex Sans";
  src: url("/static/fonts/plex-sans-600.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/static/fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("/static/fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500; font-display: swap;
}

:root,
[data-theme="light"] {
  --pico-font-family-sans-serif: "Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --pico-font-family-monospace: "Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --pico-font-family: var(--pico-font-family-sans-serif);

  --ink: #15181b;
  --paper: #e5e8e9;
  --surface: #fcfcfb;
  --hairline: #d2d7da;
  --muted: #5a6166;
  --teal: #0e5a63;
  --teal-deep: #0a464d;
  --oxblood: #a8362b;
  --amber: #8f6312;
  --green: #1d7048;

  --pico-background-color: var(--paper);
  --pico-color: var(--ink);
  --pico-muted-color: var(--muted);
  --pico-primary: var(--teal);
  --pico-primary-hover: var(--teal-deep);
  --pico-primary-focus: rgba(14, 90, 99, 0.25);
  --pico-primary-inverse: #fff;
  --pico-border-color: var(--hairline);
  --pico-card-background-color: var(--surface);
  --pico-card-border-color: var(--hairline);
  --pico-card-sectioning-background-color: var(--surface);
  --pico-form-element-background-color: var(--surface);
  --pico-border-radius: 3px;
  --pico-spacing: 1.1rem;
  --pico-typography-spacing-vertical: 1rem;
  --pico-del-color: var(--oxblood);
}

body {
  background-image: linear-gradient(var(--paper) 0 0);
  letter-spacing: -0.003em;
}

/* Thin accent rule under the masthead — the ledger's top edge. */
body > header.container {
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 2px 0 -1px var(--teal);
  padding-block: 0.6rem;
}
/* Pico's nav is a nowrap flex row, so on a narrow window the last group (language + log out) is
   pushed past the right edge and takes the whole page's width with it. Let it wrap instead. */
body > header.container nav { flex-wrap: wrap; row-gap: 0.4rem; }
.wordmark {
  font-family: var(--pico-font-family-monospace);
  font-weight: 500;
  letter-spacing: 0.02em;
  border-left: 3px solid var(--teal);
  padding-left: 0.55rem;
  text-decoration: none;
  color: var(--ink);
}

/* Primary ledger switch in the masthead — Invoices ⇆ Documents. The active ledger is inked and
   underlined; the other is a muted link. Mono/uppercase to sit as a peer of the wordmark. */
.ledger-switch {
  display: flex; gap: 1.1rem; align-items: baseline;
  font-family: var(--pico-font-family-monospace);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.ledger-switch a { color: var(--muted); text-decoration: none; }
.ledger-switch a:hover { color: var(--teal); }
.ledger-switch [aria-current="page"] {
  color: var(--ink); font-weight: 500;
  border-bottom: 2px solid var(--teal); padding-bottom: 0.15rem;
}
.ledger-switch .tab-count {
  font-size: 0.7rem; color: var(--muted); margin-left: 0.15rem;
}

/* Language switcher in the masthead — active tag plain, others linked. */
.lang-switch {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lang-switch [aria-current="true"] { color: var(--ink); font-weight: 500; }
.lang-switch a { color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--teal); }
.lang-switch .sep { color: var(--hairline); margin: 0 0.1rem; }

main.container { padding-block: 2rem 4rem; }

/* Widen the ledger past Pico's default container caps (1200px @1280, 1450px @1536) so the
   invoice table breathes; masthead shares the rule to stay aligned. Viewport-relative so it's
   always wider than Pico yet keeps a margin on big screens. */
body > header.container, main.container { max-width: min(1640px, 96vw); }

/* Active status filter: a plain, non-clickable marker (the others stay links). */
.filter-nav span[aria-current="page"] {
  color: var(--ink); font-weight: 600; cursor: default; text-decoration: none;
}

/* Section eyebrow labels — tracked, small, monospace. */
.eyebrow {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 0.4rem;
}

/* Figures: align IBANs, amounts, dates like a ledger column. */
.num, .cell.num, .iban, code {
  font-family: var(--pico-font-family-monospace);
  font-variant-numeric: tabular-nums;
}
.iban { letter-spacing: 0.02em; word-break: break-all; }

/* Ledger "table" — a CSS grid, not a <table>, so each row can be a genuine link. One grid owns the
   eight columns; every .row re-uses those exact tracks via `grid-template-columns: subgrid`, which
   keeps columns aligned across the header and all rows (a real table's only real advantage) while
   each row stays a styleable box. Data rows wrap their cells in one <a class="row-anchor"> set to
   display:contents — no box of its own, so its cells drop straight into the row's subgrid, yet the
   whole row is one native link. */
.ledger-list {
  display: grid;
  /* Two tracks may shrink to nothing: the name (it wraps) and the status cell (its pills wrap).
     The rest are `max-content`, i.e. hard floors — without those two the grid would have a
     minimum width, and past it the page scrolls sideways and the last column leaves the window.
     The amount is a hard floor deliberately: money must never wrap mid-figure.

     Lines are *named* because the narrow-window rules below drop columns, and a `display:none`
     cell places nothing — the cells after it would shift into the wrong tracks. So each width has
     its own track list holding exactly the columns it shows, and anything positioned explicitly
     (the footer total) refers to a name rather than a number that keeps moving. */
  grid-template-columns:
    [pick] 2.6rem
    [received] max-content
    [creditor] minmax(0, 1fr)
    [amount] max-content
    [invoice-date] max-content
    [due] max-content
    [skonto] max-content
    [status] minmax(min-content, max-content);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 3px 3px 0 0;
}
.ledger-list .row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.12s ease, box-shadow 0.12s ease;
  position: relative;  /* containing block for the floating row-action kebab */
}
/* Reserve room at the right of the status cell so the floated kebab never overlaps the pill. */
.ledger-list .row-link .cell.status { padding-right: 2.4rem; }
/* A row can carry two pills (status + "flagged"). Let them stack instead of forcing the track
   wider than the window — the cell is the last one, so its overflow is what spills off-screen. */
.ledger-list .cell.status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }

/* documents ledger: same row/cell styling, a document-specific column set (no checkbox / amount /
   payment columns). Rows inherit these tracks via subgrid. */
.ledger-list.documents {
  grid-template-columns:
    [received] max-content
    [creditor] minmax(0, 1fr)
    [format] max-content
    [number] max-content
    [attached] max-content
    [review] minmax(min-content, max-content);
}
.ledger-list.documents .row-link .cell.review { padding-right: 2.4rem; }
.ledger-list .row:last-child { border-bottom: none; }
.cell { padding: 0.62rem 0.85rem; min-width: 0; transition: transform 0.12s ease; }
.cell.amount { text-align: right; font-family: var(--pico-font-family-monospace);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell.empty { grid-column: 1 / -1; color: var(--muted); }

/* Narrow windows. Rather than scroll the table — which would need a scroll container, and that
   would break the header's `position: sticky` against the page — drop columns in the order of how
   little they're read. Who, how much, when due and where it stands are the job and never go.
   Each step restates the whole track list (see the note above: a hidden cell places nothing, so
   the remaining cells would otherwise slide into the wrong tracks). Header and body cells carry
   the same class, so subgrid keeps the two aligned. */
@media (max-width: 1180px) {
  .ledger-list .col-invoice-date, .ledger-list.documents .col-format { display: none; }
  .ledger-list {
    grid-template-columns:
      [pick] 2.6rem [received] max-content [creditor] minmax(0, 1fr)
      [amount] max-content [due] max-content [skonto] max-content
      [status] minmax(min-content, max-content);
  }
  .ledger-list.documents {
    grid-template-columns:
      [received] max-content [creditor] minmax(0, 1fr)
      [number] max-content [attached] max-content
      [review] minmax(min-content, max-content);
  }
}
@media (max-width: 980px) {
  .ledger-list .col-skonto, .ledger-list .col-number { display: none; }
  .ledger-list {
    grid-template-columns:
      [pick] 2.6rem [received] max-content [creditor] minmax(0, 1fr)
      [amount] max-content [due] max-content [status] minmax(min-content, max-content);
  }
  .ledger-list.documents {
    grid-template-columns:
      [received] max-content [creditor] minmax(0, 1fr)
      [attached] max-content [review] minmax(min-content, max-content);
  }
}
@media (max-width: 860px) {
  .ledger-list .col-received, .ledger-list .col-attached { display: none; }
  .ledger-list {
    grid-template-columns:
      [pick] 2.6rem [creditor] minmax(0, 1fr)
      [amount] max-content [due] max-content [status] minmax(min-content, max-content);
  }
  .ledger-list.documents {
    grid-template-columns: [creditor] minmax(0, 1fr) [review] minmax(min-content, max-content);
  }
  .cell { padding: 0.62rem 0.5rem; }
}
/* Phone width. Bulk selection is a desk task, so the checkbox goes; the due date goes with it,
   since three columns of figures plus a name is more than this width holds — it's still one tap
   away on the row, and still sortable. The tracked uppercase pills step down a size too: at this
   width their letter-spacing is what decides whether the rest fits. */
@media (max-width: 560px) {
  .ledger-list .cell.pick, .ledger-list .col-due { display: none; }
  .ledger-list .pill { font-size: 0.62rem; padding: 0.1rem 0.36rem; letter-spacing: 0; }
  .ledger-list .flag { font-size: 0.6rem; letter-spacing: 0; }
  .ledger-list {
    grid-template-columns:
      [creditor] minmax(0, 1fr) [amount] max-content [status] minmax(min-content, max-content);
  }
  .cell { padding: 0.5rem 0.32rem; }
}

/* Header row: tracked-mono labels, ruled off with the heavy ink line. Sticks to the top of the
   viewport while the table is in view (native position:sticky — scrolls up with the page, pins at
   top:0, detaches again when scrolled back past it). Opaque background + z-index so the data rows
   scroll underneath it, not through it. Scoped `.ledger-list .row.head` to beat the row's
   position:relative. */
.row.head { border-bottom: 1.5px solid var(--ink); }
.ledger-list .row.head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
}
.cell.colhdr {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}

/* The genuine per-row link: zero-box anchor whose cells join the row's subgrid. So hover-preview,
   middle-/⌘-/right-click "open in new tab" all work natively, anywhere in the row. */
.row-anchor { display: contents; color: inherit; text-decoration: none; }
.ledger-list .row-link { cursor: pointer; }
.row-link .cell.creditor { font-weight: 500; overflow-wrap: anywhere; }
/* Hover a clickable row: soft tint + a teal marker down the leading edge (the "you're on this
   line" ledger cue), and the first reading column eases right a hair to confirm the target. */
.row-link:hover,
.row-link:focus-within { background: #eef4f4; box-shadow: inset 3px 0 0 var(--teal); }
.row-link:focus-within { outline: 2px solid var(--teal); outline-offset: -2px; }
.row-link:hover .row-anchor .cell:first-child { transform: translateX(2px); }
/* Set-aside non-billing rows ("no document") — muted, they carry nothing to pay. */
.ledger-list .row.no-document .cell { color: var(--muted); }
.ledger-list .row.no-document .cell.creditor { font-weight: 400; }
/* Selected rows tint teal; keep the marker on hover. */
.ledger-list .row:has(.row-pick:checked) { background: #e3eef0; }
.row-link:has(.row-pick:checked):hover { background: #dbeaec; }

/* Checkbox column — centered hit target, its own cell outside the row anchor (so it never navigates). */
.cell.pick { text-align: center; cursor: default; }
.cell.pick input { margin: 0; cursor: pointer; vertical-align: middle; }

/* Per-row action menu — a kebab floated over the row's right edge (absolute, so it's outside both
   the grid tracks and the row anchor: it never widens the table and never navigates). Native
   <details> popover (works without JS; a small handler adds outside-click / Esc dismiss). Faint at
   rest, surfaces on row hover/focus — keeps the ledger quiet. */
.cell.actions {
  position: absolute; right: 0.35rem; top: 0; bottom: 0;
  display: flex; align-items: center; padding: 0; cursor: default;
}
.row-menu { display: inline-block; margin: 0; }  /* drop Pico's details margin-bottom (shifts it up in the centred cell) */
.row-menu > summary {
  list-style: none; cursor: pointer; width: 1.7rem; height: 1.7rem; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;  /* not list-item → no triangle */
  background: none; border: 0; box-shadow: none;  /* override Pico's summary/button defaults */
  border-radius: 3px; color: var(--muted); font-size: 0; user-select: none;  /* hide the ⋮ text */
  opacity: 0.32; transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.row-menu > summary::-webkit-details-marker,
.row-menu > summary::marker,
.row-menu > summary::after { display: none; content: ""; }  /* kill UA + Pico chevrons */
/* Draw the kebab as three dots — geometrically centred (centre dot + two symmetric), so it never
   rides high the way the ⋮ glyph did. The literal ⋮ stays in the markup as a no-CSS fallback. */
.row-menu > summary::before {
  content: ""; width: 3px; height: 3px; border-radius: 50%; background: currentColor;
  box-shadow: 0 -0.32rem 0 currentColor, 0 0.32rem 0 currentColor;
}
.row-link:hover .row-menu > summary,
.row-menu[open] > summary,
.row-menu > summary:focus-visible { opacity: 1; }
.row-menu > summary:hover,
.row-menu[open] > summary { background: #e6eef0; color: var(--ink); }
/* Pico adds a margin-bottom to an open summary (accordion spacing); kill it so opening the menu
   doesn't shove the kebab up. Higher specificity than Pico's `details[open] > summary`. */
.row-menu[open] > summary { margin: 0; }
.row-menu > summary:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }

/* Absolute-positioned children escape the UA's closed-<details> hiding, so hide it explicitly —
   otherwise every row's (closed) popover renders. */
.row-menu:not([open]) .row-menu-pop { display: none; }
/* Lift the row whose menu is open above its siblings — otherwise later rows (also position:
   relative) paint over the popover, showing their pills/kebabs through it. */
.ledger-list .row:has(.row-menu[open]) { z-index: 20; }
.row-menu-pop {
  position: absolute; top: calc(100% - 0.4rem); right: 0; z-index: 30;
  min-width: 12.5rem; padding: 0.3rem;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 4px;
  box-shadow: 0 10px 28px rgba(21, 24, 27, 0.14), 0 2px 6px rgba(21, 24, 27, 0.08);
  text-align: left; font-weight: 400;
  transform-origin: top right; animation: menuIn 0.13s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes menuIn {
  from { opacity: 0; transform: scale(0.96) translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.row-menu-pop button,
.row-menu-pop a {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; margin: 0;
  padding: 0.46rem 0.6rem; border: 0; border-radius: 3px; background: none;
  font: inherit; font-size: 0.86rem; color: var(--ink); text-align: left; text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.row-menu-pop button:hover,
.row-menu-pop a:hover,
.row-menu-pop button:focus-visible,
.row-menu-pop a:focus-visible { background: #eef4f4; outline: none; }
.row-menu-pop .ico {
  width: 1.05rem; text-align: center; color: var(--muted);
  font-size: 0.9rem; flex: none;
}
.row-menu-pop .item-sepa { color: var(--teal); font-weight: 500; }
.row-menu-pop .item-sepa .ico { color: var(--teal); }
.row-menu-sep { height: 1px; background: var(--hairline); margin: 0.3rem 0.25rem; }
/* Caution glyph on Validate (it approves without opening the invoice). Tooltip carries the why. */
.row-menu-pop .menu-warn { margin-left: auto; padding-left: 0.6rem; color: var(--amber); cursor: help; }

/* Ledger total row — a ruled-off sum aligned in the amount column. */
.row.total { border-top: 1.5px solid var(--ink); border-bottom: none; }
.row.total .cell { color: var(--muted); padding-top: 0.5rem; padding-bottom: 0.5rem; }
/* Scoped away from the supporting documents grid on purpose: it has no `[amount]` line, and a `grid-column`
   naming a line that doesn't exist makes the browser invent implicit tracks to reach it — which
   is width out of nowhere. supporting documents's footer just spans the row. */
.ledger-list.documents .row.total .count { grid-column: 1 / -1; }
.ledger-list:not(.documents) .row.total .count {
  grid-column: 1 / amount;
  font-family: var(--pico-font-family-monospace); font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.ledger-list:not(.documents) .row.total .cell.amount {
  grid-column: amount; color: var(--ink); font-weight: 600;
}

/* Back-to-top: a quiet squared button pinned bottom-right (3px like the ledger, not a round FAB),
   revealed by JS once the page has scrolled ~two-thirds of a screen. Off-screen it's fully
   transparent and click-through so it never traps focus or taps. Bottom-right keeps clear of the
   centred bulk toolbar. */
.to-top {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 40;
  width: 2.75rem; height: 2.75rem; margin: 0; padding: 0;
  display: grid; place-items: center;
  font-family: var(--pico-font-family-monospace); font-size: 1.15rem; line-height: 1;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 3px;
  box-shadow: 0 2px 8px rgba(21, 24, 27, 0.14);
  cursor: pointer;
  opacity: 0; transform: translateY(0.5rem); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.12s ease,
    color 0.12s ease, border-color 0.12s ease;
}
.to-top.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.to-top:hover { background: #eef4f4; color: var(--teal); border-color: var(--teal); }
.to-top:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .to-top, .to-top.is-visible { transform: none; }
}

/* Contextual selection toolbar — floats at the viewport bottom, revealed (by JS) only while rows
   are selected. Sits above content so it's reachable on long lists; slides up + fades in. */
.bulk-bar {
  position: fixed; left: 50%; bottom: 0.8rem; z-index: 50;
  display: flex; align-items: center; gap: 0.7rem;
  max-width: calc(100vw - 2rem); flex-wrap: wrap;
  padding: 0.55rem 0.7rem 0.55rem 1.1rem;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(21, 24, 27, 0.18), 0 2px 8px rgba(21, 24, 27, 0.10);
  opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(150%);
  transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.bulk-bar.is-visible { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.bulk-spacer { width: 0.4rem; }
.bulk-count {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.bulk-bar button { margin: 0; width: auto; white-space: nowrap; padding: 0.45rem 0.85rem; font-size: 0.85rem; }
.bulk-bar button[disabled] { opacity: 0.4; }
@media (prefers-reduced-motion: reduce) { .bulk-bar { transition: opacity 0.12s ease; } }

/* "N approved, ready for SEPA" note in the action bar. */
.approved-note .muted-line { color: var(--muted); margin: 0; font-size: 0.9rem; }

/* Status pills */
.pill {
  display: inline-block; font-family: var(--pico-font-family-monospace);
  font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid currentColor;
  line-height: 1.5;
}
.pill.open         { color: var(--muted); }
.pill.approved     { color: var(--green); background: #e2f1e8; border-color: #aad6bd; }
.pill.exported     { color: var(--teal); background: #ddeef0; border-color: #a6d2d6; }
/* Set aside as never actionable. Struck through and dimmed: it reads as withdrawn at a glance,
   which is the point — it is not work, and not a payment. */
.pill.discarded    { color: var(--muted); text-decoration: line-through; opacity: 0.75; }
/* "flagged": data confidence, orthogonal to lifecycle — shown alongside the status pill. */
.pill.flagged      { color: var(--amber); background: #f7efdd; border-color: #e4cf9a; }

/* Extraction path (provenance). Structured e-invoices are parsed exactly; LLM rows are the
   ones enrichment / re-extraction can act on, so the badge doubles as a scannable target cue. */
.pill.fmt-structured { color: var(--teal); background: #ddeef0; border-color: #a6d2d6; }
.pill.fmt-llm        { color: var(--muted); }

/* Read-only export audit stamp under the status control on the detail view. */
.export-stamp { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.85rem; }
.export-stamp .eyebrow { margin-right: 0.4rem; }
/* Who made the current status: metadata beside the pill, never a pill itself. */
.status-by { color: var(--muted); font-size: 0.85rem; }

/* Handover state, in the status bar's own gap. Metadata weight, never a pill's: the pills there
   are what happens to the invoice next, this is whether our outbox drained. It borrows the bar's
   space rather than a line of its own, and `min-width: 0` lets it give that space back — the
   buttons on the right are the bar's job and must never be pushed out by a long error string,
   which is also why it truncates. `.handoff-error` (oxblood) still wins the colour when set. */
.handoff-state {
  min-width: 0; color: var(--muted); font-size: 0.8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.handoff-state .num { color: inherit; }

/* SEPA confirm modal (native <dialog>). */
.sepa-modal { max-width: 34rem; width: calc(100vw - 2rem); padding: 0; border: 1px solid var(--hairline); border-radius: 6px; }
.sepa-modal article { margin: 0; }
.sepa-modal::backdrop { background: rgba(20, 20, 20, 0.45); }

/* Source-email metadata block (detail view). */
.email-meta dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0.6rem 0 0; }
.email-meta dt { color: var(--muted); font-size: 0.85rem; }
.email-meta dd { margin: 0; }

/* Metadata tag — neutral chip for source / ingestion values (zugferd, email, …); the dropped
   "source"/"ingested" labels live on the title attribute for anyone who hovers. */
.tag {
  display: inline-block; font-family: var(--pico-font-family-monospace);
  font-size: 0.72rem; letter-spacing: 0.02em;
  color: var(--muted); background: var(--surface); border: 1px solid var(--hairline);
  padding: 0.05rem 0.45rem; border-radius: 3px; cursor: default;
}

/* Per-field validation note under a flagged input on the verify form — plain-language reason. */
.field-note {
  display: block; margin-top: 0.3rem;
  color: var(--oxblood); font-size: 0.8rem; line-height: 1.35;
}
.field-note::before { content: "⚠ "; }

/* Advisory note under an input — a detail worth knowing, not a field to fix. Muted and ⓘ-marked
   to stay clearly below `.field-note`, which is reserved for payment-critical flags. */
.field-hint {
  display: block; margin-top: 0.3rem;
  color: var(--muted); font-size: 0.8rem; line-height: 1.35;
}
.field-hint::before { content: "\24D8  "; }

/* deductions/invoice amount row wrapped in <details> — collapses to a quiet "deductions" toggle when
   there's nothing to deduct. Disclosure triangle as affordance (rotates open); the collapsed row
   keeps a full row's bottom margin so it doesn't crowd the Skonto row below. */
.row-collapse { margin-bottom: var(--pico-spacing); }
.row-collapse[open] { margin-bottom: 0; }
.row-collapse > summary::-webkit-details-marker,
.row-collapse > summary::marker { display: none; }  /* kill UA marker, use our own */
.row-collapse > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--muted); font-size: 0.9rem; margin-bottom: 0.4rem;
}
.row-collapse > summary:hover { color: var(--ink); }
.row-collapse > summary::before {
  content: "▸"; font-size: 0.7rem; transition: transform 0.12s ease;
}
.row-collapse[open] > summary::before { transform: rotate(90deg); }
.row-collapse > summary::after { display: none; }  /* kill Pico's right-side chevron */
/* State-labelled suffix — pure-CSS toggle, one span shown per open/closed state. */
.toggle-hint { font-size: 0.8rem; opacity: 0.7; }
.row-collapse > summary .when-open,
.row-collapse[open] > summary .when-closed { display: none; }
.row-collapse[open] > summary .when-open { display: inline; }

/* Flag chip — oxblood, drawn from per_field_confidence */
.flag {
  display: inline-block; font-family: var(--pico-font-family-monospace);
  font-size: 0.66rem; letter-spacing: 0.04em;
  color: var(--oxblood); border: 1px solid #e0b0a9; background: #f7e6e3;
  padding: 0.05rem 0.4rem; border-radius: 3px; margin: 0 0.15rem 0.15rem 0;
}

/* Possible-double-import flag: amber (a question — same creditor + number as another row, not a
   certainty) to set it apart from the red settlement flags (credit / direct debit / paid). */
.flag.dup { color: var(--amber); border-color: #e0c48a; background: #faf1dc; }

/* Taken-Skonto chip: green, because it is the only chip in this row that reports something going
   right — a saving, not a defect. Amber when the discount was taken past its deadline: the sum it
   sits beside may then be short, which is the one way this chip describes a problem. */
.flag.skonto { color: var(--green); border-color: #aad6bd; background: #e2f1e8; }
.flag.skonto.lapsed { color: var(--amber); border-color: #e0c48a; background: #faf1dc; }

/* "Already on file?" banner list on the detail view — the sibling copies of this document. */
/* "Already on file?" compare: one row per stored copy of the document, the open one marked. Columns
   are the facts that *differ* between copies, aligned so the comparison is a glance rather than a
   reconstruction. Sized to content and left-packed — a full-width table would strand the actions
   somewhere off to the right, away from the row they belong to. */
.dup-table { width: auto; margin: 0.5rem 0; font-size: 0.9rem; background: none; }
.dup-table td {
  padding: 0.15rem 0.9rem 0.15rem 0; border: none; background: none;
  white-space: nowrap; vertical-align: baseline;
}
.dup-table td:last-child { padding-right: 0; }
.dup-table .dup-which { color: var(--muted); }
.dup-table .is-current .dup-which { color: inherit; font-weight: 600; }
.dup-act { display: flex; align-items: baseline; gap: 0.5rem; }
.dup-act .inline-form { display: inline; margin: 0; }
.dup-note { color: var(--muted); font-style: italic; }

/* Evidence badge (3-way match): a small mark for the invoice↔document link. On an invoice row it
   follows the settlement flags in the creditor cell and carries the match state —
   present/consistent = a green check (attached / agrees); deviation = an amber warning a human
   should look at; absent renders nothing. On a supporting-document row it is its own column and
   says only whether the link exists, which from that side is the whole of it. */
.evidence-badge {
  display: inline-block; margin-left: 0.15rem; font-weight: 700; font-size: 0.82rem; line-height: 1;
}
.evidence-badge.present,
.evidence-badge.consistent { color: var(--green); }
.evidence-badge.deviation { color: var(--amber); }

/* Evidence section on the invoice detail: attached supporting documents + the "attach a supporting document" action. */
.evidence-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.evidence-head .attach-btn { width: auto; margin: 0; }
.evidence-list { list-style: none; margin: 0.6rem 0 0; padding: 0;
  border: 1px solid var(--hairline); border-radius: 3px; background: var(--surface); }
.evidence-item { display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--hairline); }
.evidence-item:last-child { border-bottom: none; }
.evidence-link { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0;
  color: inherit; text-decoration: none; }
.evidence-link:hover .evidence-name { color: var(--teal); }
.evidence-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evidence-empty { color: var(--muted); margin: 0.6rem 0 0; font-size: 0.9rem; }
.evidence-parent { margin-bottom: 1rem; }
.evidence-parent .inline-form { display: inline; }

.evidence-actions { display: flex; align-items: center; gap: 0.9rem; white-space: nowrap; }
.evidence-actions a { color: var(--muted); font-size: 0.85rem; }

/* A button that reads as a link (detach). */
.link-btn { background: none; border: none; padding: 0; margin: 0; width: auto;
  color: var(--muted); font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--oxblood); }

/* Match state chip (3-way match): overall state on the section header + per-doc state in the
   compare grid. Colour mirrors the row badge (green agrees, amber differs, grey present/absent). */
.match-chip {
  display: inline-block; font-family: var(--pico-font-family-monospace);
  font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.05rem 0.45rem; border-radius: 999px; border: 1px solid currentColor;
  margin-left: 0.3rem; vertical-align: middle;
}
.match-chip.absent { color: var(--muted); }
.match-chip.present { color: var(--teal); }
.match-chip.consistent { color: var(--green); }
.match-chip.deviation { color: var(--amber); background: #f7efdd; border-color: #e4cf9a; }

/* Compare grid: a field column + the invoice column + one column per attached supporting document. Mismatched
   cells go amber. Info rows (number/date, never compared) are muted. */
.match-grid { display: grid;
  grid-template-columns: max-content minmax(8rem, 1fr) repeat(var(--docs), minmax(8rem, 1fr));
  border: 1px solid var(--hairline); border-radius: 3px; background: var(--surface);
  margin-top: 0.6rem; overflow-x: auto; }
.match-grid .mrow { display: contents; }
.match-grid .mcell { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--hairline);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.match-grid .mrow:last-child .mcell { border-bottom: none; }
.match-grid .mcell.field { color: var(--muted); font-size: 0.8rem; }
.match-grid .mrow.head .mcell { border-bottom: 1.5px solid var(--ink); font-weight: 600; }
.match-grid .mrow.info .mcell.doc, .match-grid .mrow.info .mcell.ref { color: var(--muted); }
.match-grid .mcell.num { font-family: var(--pico-font-family-monospace);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.match-grid .mcell.doc.differ { background: #f7efdd; color: var(--amber); font-weight: 600; }
/* A tying reference number corroborates the attachment — highlight it (green), never amber. */
.match-grid .mcell.doc.linked { color: var(--green); font-weight: 600; }

/* Framework-order suppression toggle under the compare grid. */
.framework-toggle { margin-top: 0.7rem; }
.framework-toggle .switch-field { font-size: 0.85rem; color: var(--muted); gap: 0.5rem; }

/* Inline per-doc edit (accordion under the compare grid). */
.doc-edit { margin: 0; }
.doc-edit > summary { display: flex; align-items: center; gap: 0.6rem; cursor: pointer;
  list-style: none; padding: 0.2rem 0; }
.doc-edit > summary::-webkit-details-marker { display: none; }
.doc-edit .toggle-hint { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.doc-edit .when-open { display: none; }
.doc-edit[open] .when-open { display: inline; }
.doc-edit[open] .when-closed { display: none; }
.doc-edit-form { margin: 0.5rem 0 0; }
.doc-edit-form button[type="submit"] { width: auto; }

/* Preview doc-switcher tab bar (3-way match) — sits above the single PDF viewer. */
.doc-tabs { display: flex; gap: 0.3rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.doc-tab { width: auto; margin: 0; padding: 0.25rem 0.75rem; font-size: 0.82rem;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 3px; cursor: pointer; }
.doc-tab.active { color: var(--teal); border-color: var(--teal);
  box-shadow: inset 0 -2px 0 var(--teal); font-weight: 600; }
.doc-panel.is-hidden { display: none; }

/* Reusable list search (invoice list, supporting documents list) — a compact search row above the controls. */
.list-search { display: flex; gap: 0.5rem; margin-top: 1.25rem; }
.list-search input[type="search"] { margin: 0; flex: 1 1 auto; min-width: 0; border-radius: 3px; }
/* [type=submit] lifts specificity above Pico's `button[type=submit]{width:100%}` (a plain
   `.list-search button` only ties it) so the submit button stays content-width, not full-width. */
.list-search button[type="submit"] { flex: 0 0 auto; width: auto; margin: 0; border-radius: 3px; }
.search-active { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 0; }

/* supporting document picker (attach.html): search + scope hint + two-pane list/preview. */
.attach-search { display: flex; gap: 0.6rem; margin-top: 1.5rem; }
.attach-search input[type="search"] { margin: 0; }
.attach-search button { width: auto; margin: 0; }
.attach-scope { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0; }
.attach-row-btn { width: auto; margin: 0; padding: 0.2rem 0.7rem; font-size: 0.8rem; }

/* Two panes: candidate list (left) + sticky PDF preview (right). */
.attach-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 1.5rem; align-items: start; margin-top: 1rem; }
.cand-list { list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--hairline); border-radius: 3px; background: var(--surface);
  max-height: 78vh; overflow-y: auto; }
.cand-row { display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--hairline); }
.cand-row:last-child { border-bottom: none; }
.cand-row.empty { color: var(--muted); justify-content: center; padding: 1.5rem; }
.cand-row.active { background: #e3eef0; box-shadow: inset 3px 0 0 var(--teal); }
.cand-info { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0;
  color: inherit; text-decoration: none; cursor: pointer; }
.cand-info.no-pdf { cursor: default; }
.cand-row:hover:not(.active):has(a.cand-info) { background: #eef4f4; }
.cand-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand-attach { margin: 0; flex-shrink: 0; }

.attach-preview { position: sticky; top: 1rem; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0 0 0.4rem; }
.preview-head .preview-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-open { flex-shrink: 0; }
.attach-preview .pdf-view { width: 100%; height: 78vh; border: 1px solid var(--hairline); border-radius: 3px; background: var(--surface); }
.preview-placeholder { display: grid; place-items: center; height: 78vh; margin: 0;
  border: 1px dashed var(--hairline); border-radius: 3px; color: var(--muted); background: var(--surface); }

/* Narrow: single column, drop the preview pane — the row link opens the PDF in a new tab. */
@media (max-width: 819px) {
  .attach-layout { grid-template-columns: 1fr; }
  .attach-preview { display: none; }
}

/* Callout banners. Layout shared; colour carries meaning. Red (.banner-credit) stays for
   genuine problems/confirmations; the settlement banners convey *state*, not error, so they
   map onto the same palette as the status pills (teal=info, amber=caution, grey=neutral). */
.banner-credit, .banner-info, .banner-warn, .banner-note {
  padding: 0.75rem 1rem; border-radius: 3px; border-left: 4px solid var(--muted);
}
.banner-credit { border-left-color: var(--oxblood); background: #f8eae7; }
.banner-info { border-left-color: var(--teal); background: #ddeef0; }       /* money owed to us */
.banner-warn { border-left-color: var(--amber); background: #f7efdd; }      /* double-pay caution */
.banner-note { border-left-color: var(--hairline); background: var(--surface); color: var(--muted); }

/* Status control block on the detail page */
#status-control { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap;
  padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 3px; margin-bottom: 1.6rem; }
#status-control button { margin: 0; width: auto; }

/* Action bar: ingest (left) + pay (right) */
/* Upload on the left, then the pay summary and — when a consumer is configured — the handover
   indicator, each sized to its text. `auto` repeated rather than a fixed count so the bar is the
   same rule whether the third cell is there or not. */
.actions-bar { display: grid; grid-template-columns: 1fr auto auto; gap: 1.5rem; align-items: start; }
.actions-bar form { margin: 0; }
.actions-bar .sepa button { white-space: nowrap; }
@media (max-width: 720px) { .actions-bar { grid-template-columns: 1fr; } }

/* Upload control: one tidy row — pick button · filename · upload button. Buttons size to their
   text (Pico defaults them to full block width), so this lines up with the SEPA button. */
.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
}
.upload-form .file-pick,
.upload-form button { width: auto; margin: 0; white-space: nowrap; }
/* Native file input visually hidden but focusable for keyboard/AT; we render our own label so the
   button text follows the in-app language, not the browser locale. */
.file-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.file-native:focus-visible + .file-pick { outline: 2px solid var(--teal); outline-offset: 2px; }
/* Filename drops to its own line under the button pair; placeholder when empty, truncate if long. */
.upload-form .file-name {
  flex-basis: 100%;
  min-width: 0;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-form .file-name:empty::before { content: attr(data-placeholder); color: var(--muted); }

/* Verify layout: form beside the source PDF on wide screens. */
.verify-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.8rem; align-items: start; }
.verify-grid.no-pdf { grid-template-columns: minmax(0, 38rem); }
.pdf-pane { position: sticky; top: 1.2rem; }
.pdf-view { width: 100%; height: 78vh; border: 1px solid var(--hairline);
  border-radius: 3px; background: var(--surface); }
@media (max-width: 900px) {
  .verify-grid { grid-template-columns: 1fr; }
  .pdf-pane { position: static; }
  .pdf-view { height: 60vh; }
}

/* 2:1 split — a wide field paired with a narrow one (IBAN|BIC, payable amount|currency). Built as a
   3-equal-column track with the wide field spanning 2, so the narrow column's boundary lines up
   with the 3rd column of the sibling 3-col amount rows (gross total, Skonto applied) — a plain 2fr/1fr
   split shifts that boundary by gap/3 and reads as misaligned. */
.grid.grid-2-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.grid-2-1 > :first-child { grid-column: span 2; }

/* Skonto switch: lift it off its label and give it presence, so it doesn't read as an
   afterthought crammed against the text. Label on top like the sibling fields; switch below. */
.switch-field { display: flex; flex-direction: column; align-items: flex-start; }
.switch-field input[role="switch"] {
  margin-top: 0.55rem; transform: scale(1.25); transform-origin: left center;
}

/* Amount-to-pay — the number that actually gets paid. Read-only, but the most important field on
   the form, so override the muted disabled look: teal, bold, larger, faint tinted panel. */
.payable-field { font-weight: 600; color: var(--teal-deep); }
input.num.payable:disabled {
  opacity: 1; font-weight: 600; font-size: 1.2rem;
  color: var(--teal-deep); -webkit-text-fill-color: var(--teal-deep);
  background: rgba(14, 90, 99, 0.07);
  border-color: var(--teal); border-left-width: 3px;
}

/* Frozen verify form (validated row). The fieldset is a layout no-op; `disabled` on it is what
   actually locks every control inside, submit included. Pico greys disabled inputs, which would
   read as a form that is broken rather than as figures that are settled — so restore full
   contrast and strip the input chrome: what is left reads as the values themselves, laid out
   where the fields were, and the eye-compare against the PDF still works. */
.verify-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.verify-fields.locked :disabled {
  opacity: 1; color: var(--text); -webkit-text-fill-color: var(--text);
  background: transparent; border-color: transparent; border-bottom-color: var(--hairline);
  border-radius: 0; padding-left: 0; cursor: default;
}
/* The one field that keeps its panel: it is the figure that was paid, and it already overrides
   the disabled look for that reason. Give it back its left rule and padding. */
.verify-fields.locked input.num.payable:disabled {
  background: rgba(14, 90, 99, 0.07); border-color: var(--teal);
  border-left-width: 3px; padding-left: 0.6rem;
}
.verify-fields.locked select:disabled { appearance: none; background-image: none; }
.verify-fields.locked input[role="switch"]:disabled { border-bottom-color: transparent; }
.locked-note { margin: 0 0 1rem; color: var(--muted); font-size: 0.85rem; }

/* Handover: a third cell in the actions bar carrying only where invoices are going. Health
   is not here — it is rare, and it is said in the banner above where it can be seen. */
.handoff-note .num { color: var(--muted); }
.handoff-error { color: var(--oxblood); font-variant-numeric: tabular-nums; }

/* Login card */
.login-wrap { max-width: 22rem; margin: 5rem auto; }
.login-wrap .wordmark { font-size: 1.5rem; display: inline-block; margin-bottom: 1.5rem; }
.login-wrap > a[role=button] { display: block; text-align: center; }
.login-or { margin: 1.2rem 0 0.6rem; }

/* Restrained page-load motion: a single staggered reveal. */
@keyframes riseIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
main.container > * { animation: riseIn 0.42s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
main.container > *:nth-child(2) { animation-delay: 0.05s; }
main.container > *:nth-child(3) { animation-delay: 0.1s; }
main.container > *:nth-child(4) { animation-delay: 0.15s; }
.ledger-list .row-link { animation: riseIn 0.4s ease both; }
.ledger-list .row-link:nth-child(2){animation-delay:.04s} .ledger-list .row-link:nth-child(3){animation-delay:.08s}
.ledger-list .row-link:nth-child(4){animation-delay:.12s} .ledger-list .row-link:nth-child(5){animation-delay:.16s}
.ledger-list .row-link:nth-child(6){animation-delay:.20s} .ledger-list .row-link:nth-child(7){animation-delay:.24s}
.ledger-list .row-link:nth-child(8){animation-delay:.28s} .ledger-list .row-link:nth-child(9){animation-delay:.32s}

/* HTMX swap settle for the approve transition */
#status-control.htmx-swapping { opacity: 0.4; transition: opacity 0.1s; }

/* Count badge on the filter tabs — small tracked figure after each label. */
.tab-count {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.72rem; font-variant-numeric: tabular-nums;
  color: var(--muted); margin-left: 0.15rem;
}
[aria-current="page"] .tab-count,
[aria-current="true"] .tab-count { color: var(--teal); }

/* List control bar — lifecycle tabs (left) vs. orthogonal refinements + per-page (right). Two axes
   kept apart so the bar stays calm as filters accrue. Wraps on narrow widths. */
.controls-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem 1.5rem; flex-wrap: wrap;
  /* The page-load `riseIn` animation (main.container > *) leaves a residual transform on every
     direct child, making each its own stacking context. Without an explicit z-index this bar would
     paint *below* the later-in-DOM ledger table, hiding the Filters popover behind it. Lift the bar
     (and its dropdown) above the table; stays under the fixed bulk-bar (z 50). */
  position: relative; z-index: 40;
}
.controls-bar .filter-nav { margin: 0; }
.controls-right { display: flex; align-items: center; gap: 1.1rem; }

/* "Filters" popover — a quiet outline button revealing a checklist of orthogonal refinements.
   Mirrors the row-menu popover's look; positioned under the button (right-aligned). */
.filter-menu { position: relative; display: inline-block; margin: 0; }
.filter-menu > summary {
  margin: 0; width: auto; padding: 0.3rem 0.7rem; font-size: 0.85rem;
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
}
.filter-menu > summary::after { display: none; }  /* drop Pico's dropdown caret */
/* Pico's `details[open] > summary` (specificity 0,1,2) re-adds a margin-bottom on open, beating a
   plain `.filter-menu > summary` (0,1,1) and shoving the button down — the "jump". Match its
   specificity with the [open] attr so margin stays 0. (Same trick as .row-menu[open] > summary.) */
.filter-menu[open] > summary { margin: 0; }
.filter-menu > summary.has-active { border-color: var(--teal); color: var(--teal); }
.filter-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.05rem; height: 1.05rem; padding: 0 0.25rem;
  background: var(--teal); color: #fff; border-radius: 999px;
  font-family: var(--pico-font-family-monospace); font-size: 0.66rem; font-weight: 600;
}
.filter-menu:not([open]) .filter-menu-pop { display: none; }
.filter-menu-pop {
  position: absolute; top: calc(100% + 0.35rem); right: 0; z-index: 30;
  min-width: 13rem; padding: 0.45rem 0.4rem 0.35rem;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 4px;
  box-shadow: 0 10px 28px rgba(21, 24, 27, 0.14), 0 2px 6px rgba(21, 24, 27, 0.08);
  transform-origin: top right; animation: menuIn 0.13s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.filter-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.46rem 0.55rem; border-radius: 3px;
  font-size: 0.86rem; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.filter-item:hover, .filter-item:focus-visible { background: #eef4f4; outline: none; }
/* Nothing behind this filter *in the current view* — the counts are conditioned on the
   filters already applied, so a zero here means the click would land on an empty ledger.
   Dimmed rather than hidden: "none of these" is an answer the clerk came for. */
.filter-item.empty, .filter-nav a.empty { color: var(--muted); }
.filter-item .check {
  width: 1.05rem; flex: none; text-align: center; color: var(--teal); font-size: 0.9rem;
}
.filter-item.on { font-weight: 500; }
.filter-item .tab-count { margin-left: auto; }

/* Per-page selector — small mono links, current value inked. */
/* Label and digits share one font size + line-height, so baseline alignment renders them as a
   single clean line (a smaller eyebrow-sized label rode low/high against the larger digits). */
/* margin:0 kills Pico's `[role=group]` margin-bottom (the role is there for a11y); without it the
   group's margin box centres in the controls row and rides the visible text too high. */
.per-page { display: inline-flex; align-items: baseline; gap: 0.5rem; margin: 0; }
.per-page-label {
  margin: 0; line-height: 1;
  font-family: var(--pico-font-family-monospace);
  font-size: 0.82rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.per-page-opt {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.82rem; font-variant-numeric: tabular-nums; line-height: 1;
  color: var(--muted); text-decoration: none;
}
.per-page-opt:hover { color: var(--teal); }
.per-page-opt[aria-current="true"] { color: var(--ink); font-weight: 600; cursor: default; }

/* Pager — range caption left, windowed page links right. */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-top: 1.1rem;
}
.pager-range {
  font-family: var(--pico-font-family-monospace);
  font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.pager-pages { display: flex; align-items: center; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.pager-pages li { margin: 0; }
.pager-num, .pager-step {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9rem; height: 1.9rem; padding: 0 0.4rem;
  font-family: var(--pico-font-family-monospace);
  font-size: 0.84rem; font-variant-numeric: tabular-nums;
  color: var(--muted); text-decoration: none; border-radius: 3px;
}
.pager-num:hover, .pager-step:not(.disabled):hover { background: #e6eef0; color: var(--ink); }
.pager-num[aria-current="page"] {
  background: var(--teal); color: #fff; font-weight: 600; cursor: default;
}
.pager-step.disabled { color: var(--hairline); cursor: default; }
.pager-gap { padding: 0 0.25rem; color: var(--muted); }

/* Sortable column headers: the <a> inherits the header's tracked-mono look; active column gets
   ink weight + a direction caret. */
.colhdr .sort-h { color: var(--muted); text-decoration: none; display: inline-flex; align-items: baseline; gap: 0.25rem; }
.colhdr .sort-h:hover { color: var(--teal); }
.colhdr .sort-h.active { color: var(--ink); font-weight: 600; }
.sort-arrow { font-size: 0.85em; color: var(--teal); }

/* Date urgency — only painted on rows that still owe something (see `_ledger.html`), on the due
   date and the Skonto deadline alike. Overdue shouts; due-soon warns. */
.cell.due-overdue { color: var(--oxblood); font-weight: 600; }
.cell.due-soon { color: var(--amber); }

/* Live selected-€ total in the bulk bar, beside the count. */
.bulk-sum { font-size: 0.85rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.bulk-sum::before { content: "·"; color: var(--hairline); margin: 0 0.45rem 0 0.1rem; }

/* SEPA pre-export modal: the summary line stands out; the notes below are smaller + coloured. */
.sepa-summary { font-size: 1.05rem; color: var(--ink); margin: 0.2rem 0 0.6rem; font-variant-numeric: tabular-nums; }
.sepa-credits-note { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0; }
.sepa-warn { color: var(--oxblood); font-size: 0.88rem; margin: 0.2rem 0; }
.sepa-warn::before { content: "⚠ "; }

/* Approve / approve-&-next button pair on the detail status control. */
.approve-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.approve-actions button { margin: 0; width: auto; }

/* Discard sits last in the bar (and last in tab order — the safe buttons come first), but must not
   read as a third Validate. A rule + a wider gap break the group, and oxblood says "other kind of
   move" without the alarm of a solid danger button: this one is reversible, and overstating it
   would train the clerk to ignore the styling that guards the destructive things. */
.approve-actions .discard-btn {
  position: relative; margin-left: 1.6rem;
  color: var(--oxblood); border-color: #e0b0a9;
}
.approve-actions .discard-btn::before {  /* the group rule, drawn in the gap */
  content: ""; position: absolute; left: -0.8rem; top: 0.2rem; bottom: 0.2rem;
  border-left: 1px solid var(--hairline);
}
.approve-actions .discard-btn:hover,
.approve-actions .discard-btn:focus { color: var(--oxblood); border-color: var(--oxblood); }
@media (max-width: 560px) {  /* wrapped onto its own line, the rule would point at nothing */
  .approve-actions .discard-btn { margin-left: 0; }
  .approve-actions .discard-btn::before { display: none; }
}

/* Pager over the queue, opposite the back-link in the detail eyebrow: ◂ 3 of 12 ▸. Floated rather
   than making `.eyebrow` a flex row — that class is a shared label style used in a dozen other
   places. The arrows are set larger than the eyebrow's 0.72rem so they're an honest click target. */
.queue-nav { float: right; }
.queue-pos { color: var(--muted); margin: 0 0.2rem; }
.queue-arrow {
  display: inline-block; padding: 0 0.45rem; font-size: 1rem; line-height: 1;
  vertical-align: -0.1em; text-decoration: none;
}
.queue-arrow.off { color: var(--hairline); }  /* end of the list — no wrap-around */

@media (prefers-reduced-motion: reduce) {
  main.container > *, .ledger-list .row-link { animation: none; }
}
