/*
 * BVA platform stylesheet.
 *
 * Visual direction (see .impeccable/surfaces/web-templates-base-html.md and docs/decisions):
 * the platform reads like BVA's own "Relatório e Contas" — an institutional printed
 * financial document that happens to be interactive. Plum from the logo owns the
 * header band and the active state; amounts are set like financial statements.
 *
 * No inline styles anywhere (strict CSP). All values come from the tokens below.
 */

/* ---------- Fonts (self-hosted, OFL; files in static/fonts) ---------- */
@font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-400-normal.27ab01c4cb50.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-400-normal.397d4f3b04fb.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF; }
@font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("../fonts/source-sans-3-latin-400-italic.410bdda67c60.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-600-normal.9a35cba76eda.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Source Sans 3"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-600-normal.2d5f5a2133ba.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-700-normal.9b13bd3653e3.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-700-normal.26cdfd79afb4.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Source Serif 4"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/source-serif-4-latin-400-normal.95bbd98f2b3c.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Source Serif 4"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/source-serif-4-latin-ext-400-normal.51744a8d7307.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/source-serif-4-latin-600-normal.beb0c8d8bee8.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/source-serif-4-latin-ext-600-normal.c4d949760b48.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }

/* ---------- Tokens ---------- */
:root {
  /* Brand, from the BV&A logo */
  --plum: #8e175a;
  --plum-deep: #73184b;
  --plum-ink: #4f1034;
  --mauve: #904d72;
  --mauve-soft: #bfabb7;
  --mauve-mist: #efe7ec;   /* selected rows, plum tints */
  --on-plum: #f9f8f9;
  --on-plum-muted: #e6dae1;

  /* Paper and ink */
  --paper: #f9f8f9;
  --paper-raised: #ffffff;
  --paper-sunk: #f1edf0;
  --ink: #1f1a1d;
  --ink-muted: #5e5359;
  --ink-faint: #8a7f85;
  --rule: #d9cfd5;
  --rule-strong: #1f1a1d;

  /* State (each passes 4.5:1 on its tint) */
  --ok: #1f6b45;      --ok-tint: #e3f0e8;
  --warn: #7f5200;    --warn-tint: #f7ecd6;
  --danger: #a3262a;  --danger-tint: #f6e1e1;
  --info: var(--plum-deep); --info-tint: var(--mauve-mist);

  /* Type */
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  /* One step larger than the pilot (BVA, 9 Nov: "texto um pouco maior"). */
  --text-xs: 0.875rem;
  --text-sm: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.25rem;
  --text-xl: 1.625rem;
  --text-2xl: 2.125rem;
  --leading: 1.5;

  /* Space (4px grid) */
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem; --s8: 4rem;

  --radius: 3px;
  --shell-max: 84rem;
  --measure: 68ch;
  --focus: 0 0 0 2px var(--paper), 0 0 0 4px var(--plum);
  --shadow-menu: 0 6px 18px -6px rgb(79 16 52 / 0.25);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text-md)/var(--leading) var(--font-sans);
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--plum); color: var(--on-plum); }
input, textarea { caret-color: var(--plum); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }
a { color: var(--plum); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--plum-deep); text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; color: var(--ink); text-wrap: balance; margin: 0; }
h1 { font-size: var(--text-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--s4); max-width: var(--measure); }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s6) 0; }
img { max-width: 100%; height: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: var(--s4); top: -3rem; background: var(--paper-raised); padding: var(--s2) var(--s4); z-index: 10; }
.skip-link:focus { top: var(--s2); }
html { scrollbar-color: var(--mauve-soft) var(--paper-sunk); }

/* ---------- Shell: plum header band ---------- */
.shell-header { background: var(--plum); color: var(--on-plum); }
.shell-header__inner {
  max-width: var(--shell-max); margin: 0 auto; padding: 0 var(--s5);
  display: flex; align-items: center; gap: var(--s6); min-height: 4rem;
}
.shell-header__brand { display: flex; align-items: center; gap: var(--s3); color: var(--on-plum); text-decoration: none; }
.shell-header__brand img { height: 2.5rem; width: auto; }
.shell-header__product { font: 600 var(--text-sm)/1.2 var(--font-sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--on-plum-muted); border-left: 1px solid var(--mauve); padding-left: var(--s3); }
.shell-nav { display: flex; gap: var(--s1); margin-right: auto; }
.shell-nav a {
  color: var(--on-plum); text-decoration: none; font-weight: 600; font-size: var(--text-sm);
  padding: var(--s2) var(--s3); border-radius: var(--radius);
}
.shell-nav a:hover { background: var(--plum-deep); }
.shell-nav a[aria-current="page"] { background: var(--plum-ink); box-shadow: inset 0 -2px 0 var(--on-plum); }
.shell-user { display: flex; align-items: center; gap: var(--s3); font-size: var(--text-sm); color: var(--on-plum-muted); }
.shell-user form { margin: 0; }
.shell-header :focus-visible { box-shadow: 0 0 0 2px var(--plum), 0 0 0 4px var(--on-plum); }

.shell-main { max-width: var(--shell-max); margin: 0 auto; padding: var(--s6) var(--s5) var(--s8); }
.shell-footer { border-top: 1px solid var(--rule); color: var(--ink-muted); font-size: var(--text-xs); }
.shell-footer__inner { max-width: var(--shell-max); margin: 0 auto; padding: var(--s4) var(--s5); display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }

/* ---------- Page heading: title + as-of line, like a statement heading ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); padding-bottom: var(--s4); margin-bottom: var(--s6); border-bottom: 2px solid var(--rule-strong); flex-wrap: wrap; }
.page-head__meta { color: var(--ink-muted); font-size: var(--text-sm); margin-top: var(--s2); }
.page-head__actions { display: flex; gap: var(--s3); flex-wrap: wrap; }
.section { margin-top: var(--s7); }
.section > h2 { margin-bottom: var(--s4); }
.lede { font-size: var(--text-lg); color: var(--ink-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: 600 var(--text-sm)/1 var(--font-sans); letter-spacing: 0.01em;
  padding: 0.625rem var(--s4); min-height: 2.5rem;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background-color 120ms var(--ease-out), border-color 120ms var(--ease-out);
}
.btn--primary { background: var(--plum); color: var(--on-plum); }
.btn--primary:hover { background: var(--plum-deep); color: var(--on-plum); }
.btn--secondary { background: var(--paper-raised); color: var(--plum-deep); border-color: var(--mauve-soft); }
.btn--secondary:hover { border-color: var(--plum); color: var(--plum-deep); }
.btn--quiet { background: transparent; color: var(--plum); padding-inline: var(--s2); }
.btn--quiet:hover { background: var(--mauve-mist); }
.btn--on-plum { background: transparent; color: var(--on-plum); border-color: var(--mauve); }
.btn--on-plum:hover { background: var(--plum-deep); color: var(--on-plum); }
/* Destructive actions stay outlined and isolated by space from neighbours. */
.btn--danger { background: var(--paper-raised); color: var(--danger); border-color: currentColor; margin-left: var(--s6); }
.btn--danger:hover { background: var(--danger); color: var(--paper-raised); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.htmx-request { opacity: 0.7; cursor: progress; }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--s5); max-width: 36rem; }
.field { display: grid; gap: var(--s2); }
.field label, .field legend { font-weight: 600; font-size: var(--text-sm); }
.field__help { color: var(--ink-muted); font-size: var(--text-sm); margin: 0; }
.field__error { color: var(--danger); font-size: var(--text-sm); font-weight: 600; margin: 0; }
.field__warning { color: var(--warn); background: var(--warn-tint); font-size: var(--text-sm); margin: var(--s1) 0 0; padding: var(--s1) var(--s2); border-radius: var(--radius); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  font: inherit; color: var(--ink); background: var(--paper-raised);
  border: 1px solid var(--mauve-soft); border-radius: var(--radius);
  padding: 0.5rem 0.75rem; min-height: 2.75rem; width: 100%;
  transition: border-color 120ms var(--ease-out);
}
input:hover, select:hover, textarea:hover { border-color: var(--mauve); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--plum); }
input[aria-invalid="true"], .field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { min-height: 7rem; resize: vertical; }
input.amount { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
fieldset { border: 0; padding: 0; margin: 0; }
.choice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-raised); cursor: pointer; }
.choice:hover { border-color: var(--mauve); }
.choice:has(input:checked) { border-color: var(--plum); background: var(--mauve-mist); }
.choice input { accent-color: var(--plum); margin-top: 0.3rem; }
.form-actions { display: flex; gap: var(--s3); align-items: center; padding-top: var(--s2); }

/* ---------- Statement tables: the signature ---------- */
.statement { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--paper-raised); }
.statement caption { text-align: left; font: 600 var(--text-lg)/1.3 var(--font-serif); padding-bottom: var(--s3); }
.statement th, .statement td { padding: 0.5rem var(--s3); text-align: left; vertical-align: baseline; border-bottom: 1px solid var(--rule); }
.statement thead th {
  font-weight: 600; font-size: var(--text-xs); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-muted); border-bottom: 1px solid var(--rule-strong); background: var(--paper);
  position: sticky; top: 0; z-index: 1;
}
.statement tbody tr:hover { background: var(--paper-sunk); }
.statement tbody tr[aria-selected="true"] { background: var(--mauve-mist); }
/* Ref column hangs in a narrow margin, like note references in a statement. */
.statement .ref { width: 5.5rem; color: var(--ink-muted); font-size: var(--text-xs); white-space: nowrap; border-right: 1px solid var(--rule); }
.statement .num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.statement .code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.statement .subtotal td { border-top: 1px solid var(--rule-strong); font-weight: 600; }
.statement .total td { font-weight: 700; border-bottom: 3px double var(--rule-strong); }
.statement .total td.num { border-top: 1px solid var(--rule-strong); }
.nature { font-size: 0.75em; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-muted); margin-left: 0.35em; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: var(--radius); }
.table-wrap .statement { border: 0; }
.table-empty { padding: var(--s6); text-align: center; color: var(--ink-muted); margin: 0 auto; }

/* ---------- Status badges (controlo + request states) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-size: var(--text-xs); font-weight: 600; line-height: 1; letter-spacing: 0.02em;
  padding: 0.3rem 0.5rem; border-radius: 2px; border: 1px solid currentColor; white-space: nowrap;
}
.badge::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--ok); background: var(--ok-tint); }
.badge--rec { color: var(--plum-deep); background: var(--mauve-mist); }
.badge--danger { color: var(--danger); background: var(--danger-tint); }
.badge--warn { color: var(--warn); background: var(--warn-tint); }
.badge--neutral { color: var(--ink-muted); background: var(--paper-sunk); }
/* NR (no reply) is hollow: absence of evidence, not a result. */
.badge--hollow { color: var(--ink-muted); background: transparent; }
.badge--hollow::before { background: transparent; border: 1px solid currentColor; }
/* Change marker: a plum dot beside the Refª that stays until the auditor acknowledges. */
.changed .ref::before { content: ""; display: inline-block; width: 0.45rem; height: 0.45rem; margin-right: 0.4rem; border-radius: 50%; background: var(--plum); vertical-align: 0.1em; }
.changed td { font-weight: 600; }

/* ---------- Messages ---------- */
.notice { padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid; font-size: var(--text-sm); margin-bottom: var(--s4); max-width: var(--measure); }
.notice--info { color: var(--plum-deep); background: var(--info-tint); border-color: var(--mauve-soft); }
.notice--success { color: var(--ok); background: var(--ok-tint); border-color: currentColor; }
.notice--warning { color: var(--warn); background: var(--warn-tint); border-color: currentColor; }
.notice--error { color: var(--danger); background: var(--danger-tint); border-color: currentColor; }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Engagement steps (checklist at the top of the engagement page) ---------- */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; border-top: 1px solid var(--rule); font-size: var(--text-sm); }
.steps__item { counter-increment: step; display: grid; grid-template-columns: 1.75rem minmax(12rem, 18rem) 10rem 1fr; gap: var(--s1) var(--s4); align-items: baseline; padding: var(--s2) 0; border-bottom: 1px solid var(--rule); }
.steps__item::before { content: counter(step) "."; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.steps__title { font-weight: 600; }
.steps__state { justify-self: start; }
.steps__detail { color: var(--ink-muted); }
.steps__item--done .steps__title { font-weight: 400; color: var(--ink-muted); }
@media (max-width: 48rem) {
  .steps__item { grid-template-columns: 1.75rem 1fr; }
  .steps__state, .steps__detail { grid-column: 2; }
}

/* ---------- Definition lists (engagement facts, letter details) ---------- */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s5); margin: 0; font-size: var(--text-sm); }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; font-weight: 600; }

/* ---------- Public pages: one task, BVA's mark, trust first ---------- */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-header { border-top: 6px solid var(--plum); background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
.public-header__inner { max-width: 48rem; margin: 0 auto; padding: var(--s4) var(--s5); display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.public-header img { height: 3.25rem; width: auto; }
.public-header__contact { font-size: var(--text-xs); color: var(--ink-muted); text-align: right; line-height: 1.4; }
.public-main { flex: 1; width: 100%; max-width: 48rem; margin: 0 auto; padding: var(--s7) var(--s5) var(--s8); }
.public-main h1 { margin-bottom: var(--s3); }
/* The company's preparation page carries tables and full letter texts: wider frame,
   while paragraphs keep their reading measure. */
.public-header__inner.public-wide, .public-main.public-wide, .public-footer__inner.public-wide { max-width: 64rem; }
.public-main.public-wide .letter-text { max-width: none; }
.verify-note { display: grid; gap: var(--s1); padding: var(--s4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); font-size: var(--text-sm); margin: var(--s5) 0; }
.verify-note strong { color: var(--plum-deep); }
.public-footer { border-top: 1px solid var(--rule); font-size: var(--text-xs); color: var(--ink-muted); }
.public-footer__inner { max-width: 48rem; margin: 0 auto; padding: var(--s4) var(--s5); }

/* Auth (login) uses the public frame with a narrow card-less column. */
.auth { max-width: 24rem; margin: 0 auto; }
.auth h1 { margin-bottom: var(--s5); }

/* ---------- Style guide page helpers ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--s3); list-style: none; padding: 0; margin: 0; }
.swatch { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; font-size: var(--text-xs); background: var(--paper-raised); }
.swatch__chip { height: 3.5rem; }
.swatch__label { padding: var(--s2); display: grid; }
.swatch__label code { color: var(--ink-muted); }
.chip-plum { background: var(--plum); } .chip-plum-deep { background: var(--plum-deep); } .chip-mauve { background: var(--mauve); }
.chip-mauve-soft { background: var(--mauve-soft); } .chip-mist { background: var(--mauve-mist); } .chip-paper { background: var(--paper); }
.chip-ink { background: var(--ink); } .chip-ok { background: var(--ok); } .chip-warn { background: var(--warn); } .chip-danger { background: var(--danger); }
.row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: var(--s4); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: var(--s6); align-items: start; }
.type-specimen { display: grid; gap: var(--s3); }

/* ---------- Responsive ---------- */
@media (max-width: 48rem) {
  .shell-header__inner { flex-wrap: wrap; gap: var(--s3); padding-block: var(--s3); }
  .shell-header__product { display: none; }
  .shell-nav { order: 3; width: 100%; overflow-x: auto; }
  .shell-main, .public-main { padding-inline: var(--s4); }
  .public-header__contact { display: none; }
  .btn--danger { margin-left: 0; margin-top: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Print: letters and review sheets ---------- */
@media print {
  @page { size: A4; margin: 18mm 16mm; }
  body { background: #fff; font-size: 10.5pt; }
  .shell-header, .shell-nav, .shell-footer, .page-head__actions, .btn, .skip-link, .no-print { display: none !important; }
  .shell-main { padding: 0; max-width: none; }
  .table-wrap { border: 0; overflow: visible; }
  .statement thead th { position: static; }
  .statement tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Compact controls inside tables ---------- */
.btn--compact { min-height: 2rem; padding: 0.375rem var(--s3); font-size: var(--text-xs); }
.select-toggle { margin: 0; }
.statement input[type="checkbox"] { accent-color: var(--plum); }

/* ---------- Public reply form ---------- */
.form--wide { max-width: 44rem; }
.form--full { max-width: none; }
.choice-inline { border: 0; padding: 0; margin: 0; display: flex; gap: var(--s3); white-space: nowrap; }
.choice-inline label { display: inline-flex; gap: var(--s1); align-items: center; }
.amount-line { display: grid; grid-template-columns: minmax(10rem, 14rem) 1fr; gap: var(--s4); align-items: start; padding: var(--s4); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-raised); }
.amount-line legend { font-weight: 600; font-size: var(--text-sm); padding: 0 var(--s1); }
.facts dd.num { font-variant-numeric: tabular-nums lining-nums; }
@media (max-width: 48rem) { .amount-line { grid-template-columns: 1fr; } }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s2); }
.choice input[type="checkbox"] { accent-color: var(--plum); margin-top: 0.3rem; }

/* ---------- Company preparation page ---------- */
.party-name { display: block; font-weight: 600; }
.party-meta { display: block; color: var(--ink-muted); font-size: var(--text-xs); }
.statement td.field { display: table-cell; }
.statement input[type="email"] { min-width: 15rem; min-height: 2.5rem; }
.letter-text { max-width: var(--measure); padding: var(--s5); margin-bottom: var(--s5); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); }
.letter-text h3 { margin-bottom: var(--s2); }
.prep-note { margin-top: var(--s4); max-width: var(--measure); }
/* On phones each party becomes a block (name, email, objection) instead of a wide row. */
@media (max-width: 40rem) {
  .statement--stack thead { display: none; }
  .statement--stack tr { display: grid; gap: var(--s2); padding: var(--s4) var(--s3); border-bottom: 1px solid var(--rule); }
  .statement--stack td, .statement td.field { display: block; padding: 0; border: 0; }
  .statement--stack input[type="email"] { min-width: 0; }
}

/* ---------- Address approval and sending ---------- */
.proposals { font-size: var(--text-sm); }
.proposals .party-meta + * { margin-bottom: var(--s2); }
.flag { margin: 0 var(--s1) var(--s1) 0; white-space: normal; line-height: 1.3; }
.approved { margin: 0 0 var(--s2); }
.approve-form { display: grid; gap: var(--s2); min-width: 18rem; }
.approve-form input, .approve-form select { min-height: 2.25rem; padding: 0.375rem 0.625rem; font-size: var(--text-sm); }
.approve-form .btn { justify-self: start; }
.bulk-approve { padding: var(--s4) var(--s5); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); }
.bulk-approve h2 { margin-bottom: var(--s2); }
.bulk-approve__form { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.bulk-approve__form select, .bulk-approve__form input { min-height: 2.25rem; padding: 0.375rem 0.625rem; font-size: var(--text-sm); }
.bulk-approve__form input { flex: 1 1 18rem; }
.letter-text table.balances { border-collapse: collapse; margin: var(--s3) 0 var(--s4) var(--s5); }
.letter-text table.balances td { padding: var(--s1) var(--s4) var(--s1) 0; }
.letter-text table.balances td.amount { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.letter-text table.balances td.nature { font-size: 0.75em; font-weight: 600; letter-spacing: 0.06em; color: var(--ink-muted); }
.letter-text ol { padding-left: var(--s5); }

/* ---------- Review ---------- */
.review-group { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper-raised); padding: var(--s4); margin-bottom: var(--s4); }
.review-group legend { font-weight: 600; padding: 0 var(--s2); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--s3) var(--s4); }
.intro-text { color: var(--ink-muted); max-width: var(--measure); }
.page-head__actions form { margin: 0; }
.review-grid { align-items: start; }
.review-grid input { min-height: 2.75rem; }

/* ---------- Controlo legend ---------- */
.legend-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--s2) var(--s5); margin: var(--s4) 0 0; font-size: var(--text-sm); }
.legend-list div { display: flex; gap: var(--s3); align-items: baseline; }
.legend-list dt { flex: none; min-width: 6rem; }
.legend-list dd { margin: 0; color: var(--ink-muted); }
.inline-form { display: inline; margin-left: var(--s2); }
.inline-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.reason-list { display: grid; gap: var(--s3); }
.reason__detail { margin: var(--s2) 0 0 var(--s5); }
.file-list { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: var(--s1); font-size: var(--text-sm); }
.file-list li { display: flex; gap: var(--s3); align-items: center; }
.team__list { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; gap: var(--s2); }
.team__list li { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; max-width: 36rem; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; margin-bottom: var(--s4); }
.filters__field { display: grid; gap: var(--s1); font-size: var(--text-sm); }
.filters__field select, .filters__field input { min-height: 2.25rem; padding: 0.375rem 0.625rem; font-size: var(--text-sm); }
.filters__actions { display: flex; gap: var(--s2); }
.filters__field--search input { width: min(22rem, 100%); }
.filters__count { margin: calc(-1 * var(--s2)) 0 var(--s3); }
.pager { display: flex; gap: var(--s4); align-items: center; font-size: var(--text-sm); }
.changes { font-size: var(--text-sm); margin-top: var(--s2); }
.changes ul { margin: var(--s2) 0 0; padding-left: var(--s5); display: grid; gap: var(--s1); }
.list-upload { display: grid; gap: var(--s2); padding: var(--s4); margin-bottom: var(--s4); background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); font-size: var(--text-sm); }
