/*
 * core/css/components.css — how Core's own components and screens look.
 *
 * MOVED HERE FROM products/sa-tax/css/screens.css ON 2 SEPTEMBER 2026.
 *
 * These rules style things CORE renders for every product: the card, the entry
 * form, the text field, the enum select, the search input, the toast, and the
 * Help, Settings and Feedback screens that every Atlas Foundry customer gets
 * whatever they bought. They had all been written into the tax calculator's
 * stylesheet, because when they were written there was one product and one
 * stylesheet.
 *
 * A package without the calculator therefore shipped Core's components with no
 * appearance at all. In the Small Business Manager package .card had no
 * background, border or padding, .entry-form no layout, .text-field no border,
 * and a toast rendered as plain black text across the top of the page — found
 * because it appeared over every screenshot taken for that product's user
 * guide.
 *
 * WHY A SEPARATE FILE RATHER THAN THE END OF core.css. Order decides which of
 * two equally specific rules wins. Appending these to core.css was tried first
 * and changed the calculator's rendering on 24 of its 27 routes, because rules
 * that had sat after them in screens.css suddenly sat before them. Loading this
 * file between core.css and the product stylesheet keeps every one of these
 * rules in the same position it held relative to everything else.
 *
 * Nothing below has been edited — same rules, same order. Verified by
 * screenshotting all 27 of the calculator's routes before and after.
 */


/* [Bug fix] `.dash-banner` also carries the base `.card` class (for its
   padding/radius/shadow), but `.card`'s own `background`/`border` rules
   are declared later in this file, so at equal specificity they silently
   won and overwrote this banner back to the plain card surface colour —
   in light mode that left the hardcoded white title/body text invisible
   against a white card. In dark mode the card surface is dark enough
   that white text stayed legible by coincidence, which is why this went
   unnoticed until reported in light mode specifically. Using the
   compound `.card.dash-banner` selector (higher specificity than plain
   `.card`) makes this win regardless of file order. */
.card.dash-banner {
  background: var(--accent-navy);
  border-color: transparent;
}

/* ---- Enum Select --------------------------------------------------------- */
.enum-select__field {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
  width: 100%;
  appearance: none;
}

.enum-select__field:focus {
  border-color: var(--accent-teal);
}

/* ---- Plain text field (name, UTR — no formatting needed) ----------------- */
.text-field {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
  width: 100%;
}

.text-field:focus {
  border-color: var(--accent-teal);
}

.entry-form {
  padding: var(--space-4);
}

/* [Real user feedback, 18 August 2026] A card's own h2 title (e.g.
   "Adjust your position", "Appearance", "Losses & BADR tracking",
   "Foreign Income and Gains (FIG) regime") had no margin of its own
   (global h1-h4/p reset) and the content that follows it (grid, field,
   paragraph, button) had none either, so the heading sat flush against
   the first row of content — across every screen using a card with a
   heading as its literal first element, `.entry-form` or plain `.card`
   alike, not just What If?. Scoped to `:first-child` so it never
   touches an h2 nested inside its own header-row wrapper (those already
   carry their own spacing, e.g. `.reliefs-screen__section-header`). */
.card > h2:first-child {
  margin-bottom: var(--space-3);
}

/* A descriptive paragraph directly under that same first heading (e.g.
   Settings' "Save Project"/"Reset Data" intro line, FIG's regime
   explanation) had the same zero-margin problem one level further down
   — the heading-to-paragraph gap above already fixes the h2 itself, but
   the paragraph-to-next-control gap needs its own rule since `<p>` and
   `.field`/button/grid combinations don't share one common ancestor
   selector the way `.card > h2:first-child` alone can reach. */
.card > h2:first-child + p {
  margin-bottom: var(--space-3);
}

.entry-form__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3) var(--space-4);
}

/* ---- Feedback screen (real user request, 18 August 2026) ------------------ */
.feedback-screen {
  max-width: var(--content-max-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.feedback-screen__intro {
  color: var(--text-secondary);
}

.feedback-screen__prompt-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.feedback-screen__checklist {
  margin: 0;
  padding-left: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  color: var(--text-secondary);
}

.feedback-screen__privacy-note {
  color: var(--text-secondary);
}

/* ---- Export Controls ---------------------------------------------------------- */
.export-controls {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  /* [Real user feedback, 18 August 2026] Tax Breakdown/Tax Audit
     Report/HMRC Box Mapping's own wrapper elements have no flex/gap of
     their own, so this row previously sat flush against whatever came
     next with zero space. */
  margin-bottom: var(--space-4);
}

/* ---- Settings screen ------------------------------------------------------------ */
.settings-screen {
  max-width: var(--content-measure);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ---- Toast --------------------------------------------------------------------- */
/* BOTTOM RIGHT, not bottom centre. Centred, a toast sits directly over the
   Save button at the foot of a form — the one control somebody is most likely
   to reach for while it is still on screen. The corner is out of the way of
   every action in the product. */
.toast {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  max-width: min(28rem, calc(100vw - var(--space-6)));
  background: var(--accent-navy);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-dialog);
  font-size: var(--text-body-size);
  z-index: 1100;
  animation: toast-in var(--motion-base) var(--motion-easing);
}

.toast--attention {
  background: var(--accent-coral-button);
}

/* [Found live while investigating an intermittent a11y-scan failure, 18
   August 2026] Was `opacity: 0`, transitioned over 200ms — the toast's
   OWN colours (white text on navy) are genuinely high-contrast, but
   opacity blends BOTH toward the page content sitting behind this
   fixed-position overlay, and axe-core sampling mid-transition measured
   a real, reproducible (~1 run in 6) sub-4.5:1 result partway through
   that blend. Marking the element aria-hidden at the same moment
   (toast.js) didn't help — axe-core's contrast check is a rendering
   check, unaffected by the accessibility-tree change aria-hidden makes.
   The only fix that removes the failure mode entirely rather than
   narrowing its window: never change opacity at all. Slides down and
   away instead, staying at full, compliant contrast for its whole
   visible lifetime until the DOM node is removed outright. */
.toast--leaving {
  transform: translateY(24px);
  transition: transform 200ms var(--motion-easing);
}

/* ---- Search Input --------------------------------------------------------------- */
.search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
  margin: var(--space-3) 0 var(--space-4);
}

.search-input__field {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: var(--text-body-size);
}

/* ---- Help / FAQ screen ------------------------------------------------------------ */
.help-screen {
  max-width: var(--content-max-width);
}

.help-screen__intro {
  margin-top: var(--space-2);
  color: var(--text-secondary);
}

.help-screen__list {
  display: flex;
  flex-direction: column;
}

/* ---- Shared card shell (Design Spec §3 card anatomy) ---------------------
   Concrete card component with real content arrives in Milestone 6; this
   class exists now so any placeholder or early screen can already look
   correct rather than bare. */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}


/* ---------------------------------------------------------------------------
 * SECOND PASS, same day: the rest of Core's components.
 *
 * The first pass moved only what a package without the calculator draws. That
 * left about forty rules for Core components only the calculator happens to use
 * today — the donut chart, the monthly ledger, the payments calendar, the
 * comparison and employment cards, the multi-select toggle. They are still
 * Core's, and leaving them in a product's stylesheet only means the next
 * product to draw one finds it unstyled, which is exactly the fault this whole
 * exercise started from. Moved, and the calculator verified unchanged again.
 * ------------------------------------------------------------------------ */


/* ---- Multi-select Toggle Group (Student Loan plans) ------------------------ */
/* [F-031, V18 Phase B] createMultiSelectToggle() now renders a real
   <fieldset>/<legend> pair for screen-reader group semantics, instead
   of a plain <div>/<p> — this resets the browser's default fieldset
   chrome (border, padding, inline margin) so nothing about it looks
   visually different from the element it replaced. */
.multi-select-toggle {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-3) 0;
  min-width: 0; /* fieldset's default min-width: min-content can otherwise force overflow in a narrow flex/grid parent */
}

.multi-select-toggle > legend.field__label {
  padding: 0;
  width: 100%;
}

.multi-select-toggle__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.multi-select-toggle__item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  cursor: pointer;
}

.multi-select-toggle__item:hover {
  background: var(--surface-canvas);
}

.multi-select-toggle__checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex: 0 0 auto;
  border: 1.5px solid var(--border-hairline);
  border-radius: 5px;
  background: var(--surface-card);
  cursor: pointer;
  position: relative;
  transition: background var(--motion-fast) var(--motion-easing),
    border-color var(--motion-fast) var(--motion-easing);
}

.multi-select-toggle__checkbox:hover {
  border-color: var(--accent-teal);
}

.multi-select-toggle__checkbox:checked {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
}

.multi-select-toggle__checkbox:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.multi-select-toggle__checkbox:focus-visible {
  outline: 2px solid var(--colour-focus-ring);
  outline-offset: 2px;
}

.multi-select-toggle__text {
  display: flex;
  flex-direction: column;
}

.multi-select-toggle__helper {
  margin-top: 2px;
}

/* [Minimise-card feature] Holds the collapse toggle and Remove button
   in a single right-aligned row — replaces the previous absolute
   positioning (which only ever had to make room for one button). */
.employment-card__header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.employment-card__collapse-toggle {
  appearance: none;
  border: 1px solid var(--border-hairline);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-caption-size);
  padding: 2px var(--space-2);
  border-radius: var(--radius-control);
}

.employment-card__remove {
  appearance: none;
  border: none;
  background: transparent;
  /* [V17 Phase 6] var(--accent-coral) directly on white measured 2.79:1
     (axe-core color-contrast) against the 4.5:1 WCAG AA text minimum —
     scoped here rather than changing the shared token, which is also
     used for non-text purposes (borders, focus rings) elsewhere.

     [13 September 2026] Now the status token of the same light value, because
     the literal never changed in dark mode and measured 2.43:1 there. */
  color: var(--status-attention-text);
  cursor: pointer;
  font-size: var(--text-caption-size);
}

/* [Minimise-card feature] Collapsed-state summary — employer name plus
   the four figures a user is most likely to want a quick read of
   without expanding the full form (real user request: "an option to
   minimise the total card and it just displays the summary of Income,
   tax paid, expenses, BIK"). */
.employment-card__summary-name {
  font-size: var(--text-body-size);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.employment-card__summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
}

.employment-card__summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- Comparison Card --------------------------------------------------------- */
.comparison-card__columns {
  display: grid;
  /* minmax(0, …) NOT 1fr. A bare `1fr` is `minmax(auto, 1fr)`, and `auto`
     floors at the column's min-content — so once the content inside stopped
     fitting, the columns refused to shrink and pushed straight out through the
     side of the page. Measured 5 September 2026: whole-page horizontal scroll
     of 39px at 480px and 159px at 360px, a WCAG 1.4.10 (Reflow) failure. These
     stack at 767px, but they stopped fitting at about 820px, so there was a
     band where neither the two-column nor the stacked layout worked — the same
     shape of fault as the SBM invoice rows.

     A floor of 0 lets the text wrap instead, which fixes the overflow without
     moving the breakpoint or changing how any width that already works looks. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
}

/* THE CARD STACKS ON A PHONE, AND CORE HAS TO SAY SO. [13 September 2026]
   The one-column rule lived in the calculator's stylesheet, which loads BEFORE
   this file, so the two-column rule above beat it at equal specificity. At
   390px both columns stayed side by side, 101px each, and "Actual expenses"
   was broken letter by letter down its column, 130px past its edge, scrolling
   the page sideways (calculator UI/UX audit, H3). Measured before fixing. */
@media (max-width: 767px) {
  .comparison-card__columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.comparison-card__column {
  /* A grid item's default min-width is auto, which floors it at its content
     even when the track above allows shrinking — so the column kept 23px more
     than the card had to give at 360px. */
  min-width: 0;
  /* break-word, not anywhere. `anywhere` also shrinks every word's minimum
     width to one letter, which is what let the title break mid-word instead
     of wrapping at its spaces. break-word only splits a word too long for the
     line on its own. [13 September 2026] */
  overflow-wrap: break-word;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: var(--space-4);
}

/* The title wraps as ordinary text. It was a flex row holding the title and
   its pills, which turned the title into one flex item that could not wrap at
   its own spaces. [13 September 2026] */
.comparison-card__title {
  margin-bottom: var(--space-3);
}

/* [V2.0 feedback, Finding 01] A column can carry a recommendation badge AND a
   "Your choice" marker. [13 September 2026] They sit on their own line under
   the title rather than squeezed beside it, so neither the pills nor the title
   break mid-phrase. Beside each other the columns are compared row by row, so
   a column without pills keeps the same line empty and its rows stay level
   with its neighbour's. Stacked, there is nothing to line up with. */
.comparison-card__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

@media (min-width: 768px) {
  .comparison-card__badges {
    /* One pill's height: its line, 2px padding and 1px border each side. */
    min-height: calc(var(--text-caption-size) * var(--text-title-line) + 6px);
  }
}

@media (max-width: 767px) {
  .comparison-card__badges:empty {
    display: none;
  }

  /* Where the card sits inside another card (Self-Employment Expenses, UK
     Property) a 390px screen leaves a column 176px of room, and the pill
     "£4,763.10 less profit taxed" is 180px: measured 4px past the column after
     the stacking fix. Less padding on a phone, and a pill that still cannot
     fit wraps inside itself rather than crossing the border. */
  .comparison-card__column {
    padding: var(--space-3);
  }

  .comparison-card__badge,
  .comparison-card__marker {
    white-space: normal;
  }
}

.comparison-card__marker {
  font-size: var(--text-caption-size);
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-secondary);
  /* Its own solid ground rather than sitting directly on the elected
     column's tint: --text-secondary over that tint measured 4.49:1,
     one hundredth under the 4.5:1 WCAG AA minimum for small text.
     On the card surface the same token measures 4.83:1 in light and
     6.4:1 in dark, and the pill reads as a proper chip besides. */
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
}

.comparison-card__badge {
  font-size: var(--text-caption-size);
  white-space: nowrap;
  font-weight: 600;
  /* [V17 Phase 6] var(--accent-teal) on this badge's own tinted
     background measured 2.08:1 (axe-core color-contrast) against the
     4.5:1 WCAG AA text minimum — same darkened teal used for
     .status-chip--positive against the same background tint.

     [V2.0 feedback, Finding 01] That darkened teal was hardcoded here
     as the literal #146359, so it never got the dark-mode treatment
     the rest of the app has: on the dark card it was dark teal on a
     dark ground, effectively unreadable. --accent-teal-text is the
     token that already exists for exactly this — darkened in light
     mode, reverted to the brighter base teal in themes.css for dark —
     and is what .status-chip--positive uses against this same tint. */
  color: var(--badge-teal-text);
  background: rgba(47, 184, 172, 0.14);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
}

.comparison-card__row {
  display: flex;
  justify-content: space-between;
  /* Label on the left, figure on the right. Neither could shrink and neither
     could wrap, so at 360px the pair spilled 44px out of the card. */
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.comparison-card__row:last-child {
  border-bottom: none;
}

/* A figure that wraps under a long label stays at the right. [13 September
   2026] Once the columns stacked on a phone, a row whose label filled the
   line dropped its amount onto the next line at the LEFT, while its
   neighbours' amounts sat at the right: £0.00 figures 185px apart down one
   column, measured on Child Benefit at 390px. */
.comparison-card__value {
  margin-left: auto;
  text-align: right;
}

/* ---- Payments Calendar / Timeline -------------------------------------------- */
/* THE AMOUNTS ARE A COLUMN, AND THE ROWS ARE SPACED. [13 September 2026]
   Calculator UI/UX audit, H1 and H2. Each amount sat under its own label, as
   wide as that label, so £2,090.00, £2,090.00 and £5,933.22 ended 8-9px apart;
   the rows had 0px between them and date, label and amount 2px. Now each row's
   content fills the row, the amount is right-aligned in a column of its own
   beside the date and label wherever there is room for both, and on its own
   right-aligned line where there is not — so the figures line up either way.
   The space between rows is the same 24px as before, now a gap plus padding
   rather than padding alone, and the timeline line still runs through it. */
.payments-calendar {
  display: flex;
  flex-direction: column;
  row-gap: var(--space-2);
  container-type: inline-size;
}

.payments-calendar__row {
  display: flex;
  gap: var(--space-3);
}

.payments-calendar__marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}

.payments-calendar__marker::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-teal);
  flex: 0 0 auto;
}

.payments-calendar__line {
  width: 2px;
  flex: 1 1 auto;
  background: var(--border-hairline);
  /* On through the gap between rows, stopping the same 4px short of the next
     marker it always did. */
  margin: var(--space-1) 0 calc(var(--space-1) - var(--space-2));
}

.payments-calendar__content {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: var(--space-1);
  padding-bottom: var(--space-3);
}

.payments-calendar__label {
  margin: 0;
}

.payments-calendar__amount {
  margin: 0;
  text-align: right;
}

/* Room for the amount beside the date and label: its own column, centred on
   the pair. Measured on the calendar's own width, not the window's, because
   the same timeline sits in a full-width card and in half of a two-card row. */
@container (min-width: 28rem) {
  .payments-calendar__content {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--space-4);
  }

  .payments-calendar__amount {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
}

/* Import uses a <label> styled as a button wrapping a hidden file input —
   keeps the native file picker accessible while matching button styling. */
label.button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-left: var(--space-2);
}

.chart-card__area--chart {
  border: none;
  padding: var(--space-2) 0 0;
  display: block;
  min-height: 0;
}

/* ---- Bar Chart (real, offline SVG — QA C2 fix) ---------------------------- */
.bar-chart {
  width: 100%;
}

.bar-chart__empty {
  padding: var(--space-4) 0;
  text-align: center;
}

/**
 * THE CHART'S OWN TEXT AND FILLS (calculator 3.1, build step 14 — fault C-14).
 *
 * These were in products/sa-tax/css/screens.css, so Core drew the charts and
 * the CALCULATOR styled them: every package built without the calculator got
 * chart text at the browser's default size and colour, on a track with no fill.
 * The same shape as kpi-card and chart-card, moved here on 4 September for the
 * same reason.
 *
 * It survived the CSS ownership test because an SVG element has no writable
 * `className`, so these classes are set with setAttribute — which the test's
 * scan of Core's source did not read. It reads it now.
 *
 * `fill` rather than `color`, and `stroke` on the rings: SVG text is painted,
 * not coloured.
 */
.bar-chart__label {
  font-size: 12px;
  fill: var(--text-secondary);
  dominant-baseline: middle;
}

.bar-chart__value {
  font-size: 12px;
  font-weight: 600;
  fill: var(--text-primary);
}

.bar-chart__track {
  fill: var(--surface-canvas);
}

.bar-chart__month-label {
  font-size: 10px;
  fill: var(--text-secondary);
}

.bar-chart__reference-line {
  stroke: var(--accent-coral);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/**
 * THE OPT-IN PARTS OF THE VERTICAL CHART (fault C-15). Present for every
 * package, but only ever drawn when a caller asks for `hoverValues` or
 * `figuresList` — a chart that asks for neither gets no hit areas and no list,
 * so these rules match nothing and change nothing.
 */
.bar-chart__bar {
  transition: opacity var(--motion-fast) var(--motion-easing);
}

/* Hovering the chart dims every bar; hovering one bar's hit area brings that
   bar back, so the one being read stands out from the rest. Scoped to
   `--interactive`, which only a chart that asked for hover values ever has. */
.bar-chart--interactive:hover .bar-chart__bar {
  opacity: 0.85;
}

.bar-chart--interactive .bar-chart__hit:hover + .bar-chart__bar {
  opacity: 1;
}

/* The figures under the chart. Hidden wherever a pointer can hover, because
   the tooltip is there and twelve months of figures would swamp a card meant
   to be glanced at (Jordan, 17 September 2026). Shown on a touch screen, where
   a tooltip can never appear. */
.bar-chart__figures {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.bar-chart__figures li {
  display: flex;
  flex-direction: column;
  min-width: 5.5rem;
}

.bar-chart__figures-value {
  font-variant-numeric: tabular-nums;
}

@media (hover: hover) and (pointer: fine) {
  .bar-chart__figures { display: none; }
}

.donut-chart {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.donut-chart__track {
  stroke: var(--surface-canvas);
}

.donut-chart__segment {
  transition: stroke-dasharray var(--motion-fast) var(--motion-easing);
}

.donut-chart__centre-value {
  font-size: 15px;
  font-weight: 600;
  fill: var(--text-primary);
}

.donut-chart__centre-label {
  font-size: 10px;
  fill: var(--text-secondary);
}

/* The compact variant — ring above, legend below — is Core's option, so its
   layout belongs with the component rather than with whoever asked for it
   first (createDonutChart's `compact` parameter). */
.donut-chart--compact {
  flex-direction: column;
  align-items: center;
  text-align: left;
}

.donut-chart--compact .donut-chart__legend {
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
  max-width: 220px;
}

.donut-chart__ring-wrap {
  flex: 0 0 auto;
}

.donut-chart__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 160px;
  min-width: 160px;
}

.donut-chart__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.donut-chart__legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.donut-chart__legend-label {
  flex: 1 1 auto;
  color: var(--text-secondary);
}

.donut-chart__legend-value {
  color: var(--text-primary);
}

.donut-chart__empty {
  color: var(--text-secondary);
}

/* ---- Monthly ledger (V2.0 feedback, Phase 4) ---------------------------------- */
.monthly-ledger {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.monthly-ledger__mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.monthly-ledger__toggle {
  flex: 0 0 auto;
}

/* The twelve month rows are a single vertical stack — one row per
   month, reading like a statement. (An earlier version tiled the rows
   into 2-3 columns, which combined with each row's own internal grid to
   overflow the card horizontally.) */
.monthly-ledger__table {
  display: flex;
  flex-direction: column;
}

.monthly-ledger__summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.monthly-ledger__summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Month subtotal rows inside an existing dated ledger table
   (self-employment income, expenses, mileage). */
.data-table__month-row td {
  font-weight: 600;
  background: var(--card-sunk, var(--surface-canvas));
}

.data-table__month-row--label {
  text-transform: none;
  letter-spacing: 0;
}

/* Grouped monthly ledger: a month label, then one input per figure. */
.monthly-ledger__row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.monthly-ledger__row:last-child { border-bottom: none; }

/* [13 September 2026] Top, not centre. Centred against a row of labelled
   fields it sat below the field labels and above the amounts, level with
   neither (calculator UI/UX audit, H2). At the top it reads as the row's
   heading, level with the labels beside it. */
.monthly-ledger__month { align-self: start; }

.monthly-ledger__inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

/* [V2.1 feedback, fourth round] Column-heading mode: the field title is
   stated once at the top instead of against all twelve months. The
   per-cell labels stay in the DOM for screen readers — a column heading
   is a visual association only, and removing the labels would leave
   sixty unlabelled money inputs. */
.monthly-ledger--columns .monthly-ledger__inputs .field__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.monthly-ledger__head {
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: var(--space-2);
}

/* The monthly ledger's responsive behaviour, which lives with the component
   rather than with whichever product happens to draw it. Kept in the same order
   relative to everything else, like the rest of this file. */
@media (min-width: 700px) {
  .monthly-ledger__row { grid-template-columns: 7.5rem minmax(0, 1fr); align-items: start; }
  /* minmax(0, 1fr) rather than a fixed minimum: a grid track's default
     min-width is auto, which lets wide children push the row past the
     card and scroll the whole page sideways. */
  /* [V2.1 feedback, fourth round] The column count now follows the
     number of fields (set inline by monthlyLedger.js). It was hard-coded
     to 3, sized for the employment ledger's three payslip figures, so
     the property expense group's five boxes wrapped 3 + 2 on every one
     of the twelve months. Falls back to 3 if the variable is absent. */
  .monthly-ledger__inputs {
    grid-template-columns: repeat(var(--ledger-columns, 3), minmax(0, 1fr));
  }

  /* A MONTH'S AMOUNTS SIT ON ONE LINE. [13 September 2026] Each field stacked
     its own label, box and error line, so when one label wrapped ("Student
     Loan deducted via payroll") that box sat 17px below the other three on all
     twelve months (calculator UI/UX audit, H2, measured). As a subgrid, every
     field in the row shares one label track, one box track and one error track:
     the longest label sets the label track, and every box starts on the same
     line. A browser without subgrid falls back to the old stacking. */
  .monthly-ledger__inputs > .field {
    grid-row: span 3;
    display: grid;
    grid-template-rows: subgrid;
    align-content: start;
  }

  /* With the labels stated once as column headings, the row starts at the
     boxes, so the month sits level with the figures' text inside them. */
  .monthly-ledger--columns .monthly-ledger__month {
    padding-top: var(--space-2);
  }
}

/* Five long SA105 titles do not fit a narrow screen. The headings only
   apply where the columns do; below that the ledger is one field per
   row and each input keeps its own visible label. */
@media (max-width: 699px) {
  .monthly-ledger__head { display: none; }
  .monthly-ledger--columns .monthly-ledger__inputs .field__label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}


/* Shared details: one fact per row, with where it came from underneath it. */
.shared-fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.shared-fact:last-child { border-bottom: none; }

.shared-fact__value { font-weight: 600; }

.shared-fact__source,
.shared-fact__note { color: var(--text-secondary); }

/* Help topics grouped by the product that contributed them. */
.help-screen__group {
  margin: var(--space-5) 0 var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border-hairline);
}

.help-screen__group:first-child {
  margin-top: var(--space-2);
}

.help-screen__group-count {
  font-weight: 400;
  color: var(--text-secondary);
}


/* ---- Settings screen rows -------------------------------------------------
 *
 * MOVED HERE FROM products/sa-tax/css/screens.css, 3 September 2026.
 *
 * Settings is Core's screen and it renders every installed product's section.
 * These classes were written by the calculator because it was the only product
 * with a section; Small Business Manager now has one too, and a rule living in
 * one product's stylesheet is absent from every package built without that
 * product — the same fault qa/cssOwnershipTest.mjs exists to catch, which it
 * would not have caught here because the markup comes from product code rather
 * than core/ui.
 *
 * Safe to move because this file loads AFTER the product stylesheet, and every
 * rule below either wins on specificity (.settings-save-row .text-field,
 * .settings-project-row__info p) or only ever competed with core.css, which
 * still loads first. Checked before moving rather than after — the last CSS
 * move changed the calculator on 24 of 27 routes.
 */
.settings-save-row {
  display: flex;
  gap: var(--space-2);
}

.settings-save-row .text-field {
  flex: 1 1 auto;
}

/* The Export / Back Up / Import buttons on Settings.
   They were appended straight to the card, so they sat edge to edge with no
   gap and no row of their own — Jordan, 9 September 2026: "they are all
   touching one another". Wraps rather than squashing, because a package with
   three buttons and a narrow window has to put one on a second line rather
   than shrink all three below a readable width. */
.settings-button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.settings-button-row > .button,
.settings-button-row > label.button {
  /* label.button carries the hidden file input for Import; without this it
     sizes to its text and sits lower than the real buttons beside it. */
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Wraps, and the name gives way first (19 September 2026): a long project
   name — "As it was before 3.1 (2026/27)", the calculator's safety copy, is the
   one that showed it — pushed Open and Delete off a 320px screen. The buttons
   now drop below the name only when there is no room beside it. */
.settings-project-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.settings-project-row__info {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.settings-project-row:last-child {
  border-bottom: none;
}

.settings-project-row__info p {
  margin: 0;
}

.settings-project-row__actions {
  display: flex;
  gap: var(--space-2);
}

/* Declaration removed 2 September 2026. It had never taken effect: .card and
   .entry-form are equally specific and came LATER in this same file, so source
   order decided and this always lost. Moving those two into
   core/css/components.css would have made it start applying — a visible change
   to a product already on sale — so the dead declaration goes instead and the
   product renders exactly as it does today. Recorded in
   products/sbm/DECISIONS.md §6 in case the effect was wanted. */
.settings-reset-year-list {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-2);
}

.settings-reset-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.settings-reset-year-row:last-child {
  border-bottom: none;
}

.settings-reset-year-row__label-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.settings-reset-year-row__label-row p {
  margin: 0;
}

.settings-reset-all-hint {
  margin-top: var(--space-4);
  color: var(--text-secondary);
}

/* ---- KPI cards and their grid ---------------------------------------------
 *
 * MOVED/ADDED 4 September 2026. `core/components/kpiCard.js` is a Core
 * component shipped in every package, but the rules that put its cards in a row
 * — `.kpi-card--span-*` — lived only in products/sa-tax/css/screens.css. Small
 * Business Manager therefore had three unstyled block elements stacked
 * vertically where the design called for one row, and had done since it
 * shipped. Jordan asked for "all on one row"; they were never in one.
 *
 * `.kpi-grid` had NO rules anywhere at all — SBM's Overview created the element
 * and nothing styled it.
 *
 * qa/cssOwnershipTest.mjs did not catch this because it derives `kpi-card` from
 * the component's source and the offending selectors were `.kpi-card--span-4` —
 * a BEM modifier of a Core class. The test now treats those as Core-owned too.
 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-3);
  align-items: stretch;
}

.kpi-card--span-3 { grid-column: span 3; }
.kpi-card--span-4 { grid-column: span 4; }
.kpi-card--span-6 { grid-column: span 6; }
.kpi-card--span-12 { grid-column: span 12; }

/* Tablet: two across. Below that a KPI card's figure starts wrapping, which is
   worse than stacking — a money figure broken across two lines is misread. */
@media (max-width: 1199px) {
  .kpi-card--span-3, .kpi-card--span-4 { grid-column: span 6; }
}

@media (max-width: 767px) {
  .kpi-card--span-3, .kpi-card--span-4, .kpi-card--span-6 { grid-column: span 12; }
}

/* ---- Chart, comparison and payments-calendar modifiers --------------------
 *
 * MOVED FROM products/sa-tax/css/screens.css, 4 September 2026, with the
 * .kpi-card--span-* rules above. All three are Core components — chartCard.js,
 * comparisonCard.js, paymentsCalendar.js — whose modifier rules lived only in
 * the calculator's stylesheet, so any package without the calculator shipped
 * them unstyled. Found when qa/cssOwnershipTest.mjs was taught that a modifier
 * of a Core class belongs to Core too.
 */
.chart-card--span-3 { grid-column: span 3; }
.chart-card--span-4 { grid-column: span 4; }
.chart-card--span-6 { grid-column: span 6; }
.chart-card--span-12 { grid-column: span 12; }

@media (max-width: 1199px) {
  .chart-card--span-3, .chart-card--span-4 { grid-column: span 6; }
}

@media (max-width: 767px) {
  .chart-card--span-3, .chart-card--span-4, .chart-card--span-6 { grid-column: span 12; }
}

.comparison-card__column--recommended {
  border-color: var(--accent-teal);
  background: rgba(47, 184, 172, 0.05);
}

.payments-calendar__amount--refund {
  color: var(--colour-positive);
}

/* [V2.0 feedback, Finding 01] The column the person actually elected.
   Deliberately a neutral navy outline, not the teal "recommended"
   treatment — it states what is in use without also implying it is the
   better option, which is exactly the conflation the badge fix undoes.
   Stacks with --recommended when the two coincide; the teal badge and
   this border then reinforce each other rather than competing. */
.comparison-card__column--elected {
  /* Border + "Your choice" pill only, deliberately NO background tint.
     A tint here would override the recommended column's teal one when a
     column is both (the common case: you elected what we recommend),
     and the navy tint it replaced it with measured fractionally darker,
     dropping "Taxable profit" and the column title from 4.51:1 to
     4.47:1 against --text-secondary. The border carries the state at
     13.4:1 in light and 3.4:1 in dark, well clear of the 3:1 non-text
     minimum, so the tint was redundant as well as harmful. */
  border-color: var(--elected-border);
}

/* A KPI card whose figure is a profit or a loss. The colour is on the VALUE,
   not the card: a whole card in coral reads as an error, and a loss is not an
   error. Uses the accessible text variants — the base brand teal and coral
   measure about 2.5:1 as text on a light surface. */
.kpi-card--profit .kpi-card__value { color: var(--accent-teal-text); }
.kpi-card--loss .kpi-card__value { color: var(--accent-coral-text); }

/* Entries handed over from another product, summarised by month. Replaced a
   card per send: a customer thinks in months and in the year their return
   covers, not in "the batch I sent on Tuesday". */
.shared-monthly__table {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.shared-monthly__row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
  align-items: baseline;
}

.shared-monthly__row .numeric { font-variant-numeric: tabular-nums; text-align: right; }
.shared-monthly__row--total { border-bottom: none; font-weight: 700; border-top: 1px solid var(--border-strong, var(--border-hairline)); }

/* ---- Making Tax Digital: what each update would contain -------------------
   Core's, like the rest of the checker — the screen is shared by every product
   combination, so its styles cannot live in a product stylesheet. */
/* The one table in the app that was not inside a scrolling container. Its row
   headers are `white-space: nowrap` (a period like "6 Apr 2026 to 5 Jul 2026"
   reads badly broken across lines), so its min-content is wide, and with no
   `overflow-x` the excess spilled out and scrolled the WHOLE PAGE sideways —
   233px of it at 360px wide. core/css/core.css `.data-table-wrapper` carries
   the note from the last time this exact violation was found and fixed; this is
   that fix, for the table that never got it. Kept separate from
   `.data-table-wrapper` because that one also pads, and this table already
   sits inside a padded card. */
.mtd-figures__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* NO MARGIN OF ITS OWN. [13 September 2026] The table's 16px sat INSIDE its
   scrolling wrapper, so the wrapper's box touched the paragraph above it and
   the caption below (0px, measured) while the gap was drawn by the table. The
   card rhythm now spaces the wrapper itself; a margin here as well would make
   that gap 32px. */
.mtd-figures__table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.mtd-figures__table th,
.mtd-figures__table td {
  padding: var(--space-2) var(--space-2) var(--space-2) 0;
  text-align: left;
  border-bottom: 1px solid var(--border-hairline);
}

.mtd-figures__table th[scope="row"] { font-weight: 400; white-space: nowrap; }
.mtd-figures__table thead th { color: var(--text-secondary); }

.mtd-figures__table .numeric,
.mtd-figures__table td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The period a customer can actually act on today. */
.mtd-figures__table tr.is-due { background: rgba(47, 184, 172, 0.10); }
.mtd-figures__table tr.is-overdue td:last-child { color: var(--accent-coral-text); }

/* Said once at the top and hard to miss, because every instinct says quarters. */
.mtd-figures__cumulative {
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--accent-teal);
  background: rgba(47, 184, 172, 0.08);
  margin: var(--space-3) 0;
}

.mtd-figures__note {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.mtd-figures__note p { margin: var(--space-2) 0; }

/* The explanation that replaces the yearly/monthly toggle where there is no
   choice. Sits in the toggle's row, so it reads as the answer to "where has
   the yearly option gone?" rather than as general advice. */
.monthly-ledger__why {
  margin: 0;
  flex: 1 1 100%;
  color: var(--text-secondary);
}

/* EACH YEAR'S VERDICT, SPACED. [13 September 2026] The checker now draws one
   block per tax year (`.mtd-year`: its heading, a status chip, the figures
   and what they mean). Nothing spaced them, so all four sat at 0px, measured
   in every package with MTD figures. Zero specificity, the tight step used
   under a heading, so anything the screen sets itself still decides. */
:where(.mtd-year) > * + * {
  margin-top: var(--space-2);
}

/* One block per business — self-employment and property file separately. */
.mtd-figures__business {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

/* How the figures are worked out. Open, not collapsed: somebody about to send
   a number to HMRC should not have to click to learn what is in it. */
.mtd-figures__how {
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: var(--surface-sunken, rgba(0, 0, 0, 0.03));
  border-radius: 6px;
}

.mtd-figures__how p { margin: var(--space-2) 0; }

/* Reference content shown in a dialog. Capped and scrollable so the dialog's
   own buttons stay on screen — a dialog you have to scroll to dismiss is worse
   than the long card it replaced. */
/* A DIALOG MAY USE THE ROOM THE SCREEN ACTUALLY HAS.
 *
 * Jordan, 11 September 2026: *"when I added my ISAs i did not scroll down, as I
 * didnt see there were other fields to enter."* Measured afterwards: the Add
 * Account form is 670px tall in a 420px box, so 37% of it was below the fold —
 * with no scrollbar, because macOS only draws one WHILE you are scrolling.
 * There was nothing to tell him more existed.
 *
 * The 420px was a hard ceiling regardless of screen size: on any desktop
 * `60vh` is far more than that, so the `min()` always clamped to 420. Raised to
 * 78vh with a 720px ceiling, which uses the room a laptop has while still
 * leaving the dialog visibly inside the viewport rather than filling it.
 *
 * THE FADE IS NOT DECORATION. Where a form is still longer than the space —
 * the defined benefit pension one is — the mask makes the cut edge visibly a
 * cut rather than an ending. A clipped field below a fully readable label is
 * how a form comes to look finished when it is not.
 */
.dialog__body--rich {
  max-height: min(78vh, 720px);
  overflow-y: auto;
  text-align: left;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent 100%);
}

/* The mask would fade the last line of a form that fits, which is a fade over
   nothing. Removed once the content has been scrolled to the end, and absent
   entirely for anyone who has asked for less motion and effect. */
.dialog__body--rich:not([data-overflowing="true"]) {
  -webkit-mask-image: none;
  mask-image: none;
}

.dialog__body--rich p { margin: var(--space-2) 0; }
.dialog__body--rich p:first-child { margin-top: 0; }

/* ---- Rhythm inside a card -------------------------------------------------
   Stacked paragraphs in a card had no vertical rhythm of their own, so an
   explanation of three paragraphs read as one grey block. Jordan, 5 September
   2026: "make sure there is sufficient spacing between different text
   paragraphs".

   Applied to the card rather than globally so table cells, list items and
   form hints keep their own tighter spacing. First and last are trimmed so a
   card's padding is not doubled at its edges. */
.card > p + p,
.card > p + .text-caption,
.card > .text-caption + p {
  margin-top: var(--space-3);
}

/* :first-child, NOT :first-of-type. `first-of-type` matches the first <p> in
   the card even when a heading precedes it — so this was stripping the gap
   between a card's title and its opening sentence on every card in both
   products. Introduced by me on 5 September 2026 and found by looking at the
   Stock screen. */
.card > p:first-child { margin-top: 0; }
.card > p:last-child { margin-bottom: 0; }

/* A heading needs more space above it than a paragraph does, or a new section
   inside a card reads as a continuation of the one before. */
.card > h3:not(:first-child),
.card > h4:not(:first-child) {
  margin-top: var(--space-4);
}

/* ---- EVERY BLOCK IN A CARD IS SEPARATED FROM THE ONE ABOVE IT ------------
   [13 September 2026] Jordan, about the tracker, and true of all four
   products: "I dont want text touching a card, i want things clearly
   separated."

   WHAT WAS WRONG. The UI/UX audits of the calculator and Small Business
   Manager measured 30 and 40 places where two blocks inside a card sat 0-3px
   apart: "It is not a backup…" on the project-name field, "Or clear every tax
   year at once:" on the red Reset Everything button, a heading on its
   paragraph, a caption on its table. The rules above space only the pairs
   somebody listed, so a card built from any other pair started unspaced, and
   so did every new card. The cause is the reset in core.css, which zeroes
   heading and paragraph margins, with nothing putting a rhythm back.

   The tracker fixed this for itself on 8 September (`.nwt-screen .card > * +
   *`). This is that rule in Core, for every card in every product. The
   tracker's own screens are unchanged: its rules are more specific and still
   decide there, so nothing is spaced twice.

   IT LOSES TO ANYTHING DELIBERATE. Zero specificity (`:where`), so spacing a
   component or product has set on an element still wins. The reset was made
   zero-specificity so this can still beat it.

   THE STEP IS `--card-flow`, SET ON EACH CHILD. 16px by default. 8px under a
   heading or a status chip, because the sentence explaining a thing belongs
   closer to it than to whatever follows. 4px from a label to its control. A
   product can tune one pair by setting `--card-flow` on its own class. */
:where(.card) > * {
  --card-flow: var(--space-3);
}

:where(.card) > :where(h2, h3, h4, .status-chip) + * {
  --card-flow: var(--space-2);
}

:where(.card) > :where(label) + :where(input, select, textarea) {
  --card-flow: var(--space-1);
}

/* A ruled list is separated by its rules. A margin between its rows would open
   a gap between each rule and the row it belongs to. */
:where(.mtd-tier-row + .mtd-tier-row,
  .shared-fact + .shared-fact,
  .settings-available + .settings-available,
  .settings-project-row + .settings-project-row,
  .settings-reset-year-row + .settings-reset-year-row,
  .about-row + .about-row) {
  --card-flow: 0px;
}

/* A BUTTON DOES NOT SHARE A MARGIN WITH THE BLOCK ABOVE IT. Two stacked blocks'
   margins overlap; a button's top margin is added to the block's bottom margin
   instead. So under a block that already keeps 16px below itself, the step
   made 32px: measured on nine screens across all four packages the first time
   this rule ran (Reset, Pension & Gift Aid, Savings, Owed to you, Settings).
   After one of those blocks a button takes the block's own margin as its
   step. [13 September 2026] */
:where(.field, .expandable-section, .multi-select-toggle, .relief-entry,
  .savings-entry, .sbm-owed__list, .card > h2:first-child,
  .card > h2:first-child + p) + :where(button, .button) {
  --card-flow: 0px;
}

/* CARDS THAT LAY THEMSELVES OUT ARE LEFT ALONE. A flex or grid card already
   spaces its children with `gap`. A margin as well would double that space,
   or in a row or a grid push one item below its neighbours. CSS cannot ask
   what an element's display is, so they are listed: every card measured flex
   or grid on every screen of all four packages at 1280px and 390px, cross-
   checked against every class the stylesheets make flex or grid. The tracker's
   are absent because its own rule governs them. A new card should be a plain
   block unless it has a reason not to be. If it is flex or grid, it goes here. */
:where(.card:not(
  .kpi-card, .mtd-result-card, .feedback-screen__prompt-card,
  .dash-banner, .dash-card, .dashboard__completeness, .dashboard__confidence,
  .dashboard__explanations, .dashboard__liability, .dashboard__primary-result,
  .dashboard__suggestions, .dashboard__warnings, .dashboard__what-have-i-missed,
  .whats-next-card, .relief-entry, .mileage-signpost, .filing-checks-card,
  .filing-verdict-card, .ma-eligibility-card, .ma-reliefs-summary, .poa-notice,
  .tax-breakdown__answer, .tax-year-card, .vat-top-card, .welcome-cta-panel,
  .welcome-step, .welcome-year-card,
  .sbm-comparison, .sbm-entry-form, .sbm-mileage-summary, .sbm-overdue-card,
  .sbm-vat-card, .sbm-vehicle-card, .sbm-year-end-step
)) > * + * {
  margin-top: var(--card-flow);
}

/* ---- The Settings danger zone --------------------------------------------
   Approved by Jordan on 5 September 2026, from products/sbm/DECISIONS.md §6.
   This rule existed in the calculator's stylesheet from the beginning and never
   took effect: it was equally specific to `.card`, which came later in the same
   file and so won on source order alone. The class has been on the element in
   every shipped version with nothing behind it.

   It is worth having. Reset is the one place on Settings where a click has
   consequences that cannot be undone, and the border is the only thing marking
   it out from the ordinary cards around it. In Core rather than a product,
   because both products render this card.

   The border only — not a tinted background, which would read as an error
   state rather than as a boundary you are about to cross. */
.settings-danger-zone {
  border-color: rgba(255, 107, 94, 0.45);
}

/* The link to the full disclaimer. Reads as part of the sentence, not as a
   call to action — nobody should feel invited to press it, only able to. */
.app-footer__more {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* The MTD figures export: the control, then why the file reads as it does.
   Existing spacing tokens only. */
.mtd-figures__export {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

/* ---------------------------------------------------------------------------
   TOUCH SIZING — 8 October 2026

   Jordan opened the hosted calculator on his own iPhone on 8 October 2026, the
   first time any Atlas Foundry product had been opened on a phone by anybody,
   and said: *"It isn't very IOS"*. He is right, and it is two things, both
   measured rather than guessed (`docs/HOSTED-ON-A-PHONE-2026-10-08.md` §8).

   ONE. iOS Safari zooms the page in on any field whose text is under 16px and
   does not zoom back out. `core.css` sets `button, input, select, textarea
   { font: inherit }` and body text is 15px, so EVERY field in the product was
   one pixel under the line and the page lurched on every tap.

   TWO. Apple's minimum tap target is 44x44 and Google's 48x48. Measured across
   eighteen routes at 390px, nothing in the product reached it.

   WHY THIS IS SCOPED TO `pointer: coarse` AND NOT APPLIED EVERYWHERE.
   These are finger sizes. A mouse does not need them, the desktop product has
   been reviewed and signed off at its current density, and a global change
   would move every screen in all eight products for no gain to the people
   using them on a laptop. Scoping it also means the QA chain — which runs
   desktop Chromium — sees no change at all, so a 2,000-assertion suite is not
   re-baselined to deliver a phone fix. `components.css` already uses
   `@media (hover: hover) and (pointer: fine)` for the same kind of reason.

   The measurement harness that produced the numbers below drives Chromium with
   `isMobile` and `hasTouch`, which is a coarse pointer, so these rules are
   under test rather than asserted.
   ------------------------------------------------------------------------- */
@media (pointer: coarse) {

  /* THE ZOOM, and it is one rule. 16px exactly, not 16.1 or 1rem: the
     threshold is 16px and the smallest value that clears it keeps the fields
     closest to the 15px the rest of the product was designed at. Overrides
     `font: inherit` in core.css, which is the same element specificity and an
     earlier file. */
  input,
  select,
  textarea,
  /* `.search-input__field` sets `font-size: var(--text-body-size)` itself, at
     class specificity, so the bare element selectors above lose to it however
     late they appear. Named explicitly rather than reached for with `!important`
     — and it is named here rather than being quietly removed from its own rule,
     because 15px is still right for it on a desktop. Found by measuring: the
     Help screen's search box was the one field left zooming after the first
     pass of this block. */
  .search-input__field {
    font-size: 16px;
  }

  /* FIELDS. An input or a select centres its own text vertically, so
     `min-height` alone is enough and nothing needs to become a flex container.
     Measured before: text 42px, currency 40px, enum select 42px, stepper 40px.
     All of them were near misses rather than faults, which is why this is a
     minimum rather than a redesign. */
  input,
  select,
  textarea,
  .text-field,
  .currency-input__field,
  .enum-select__field,
  .stepper-input__field,
  .search-input__field {
    min-height: 44px;
  }

  /* BUTTONS GROW BY PADDING, NOT BY `min-height`.
     `.button` is `display: block`, so a button fills its container's width.
     `min-height` on a block leaves the label pinned to the top, and switching
     it to inline-flex to centre the label would also make every button in
     eight products shrink to its content. Four more pixels of padding reaches
     44 from the measured 40 and moves nothing else. */
  .button {
    padding-block: 10px;
  }

  /* ALREADY FLEX AND ALREADY CENTRED, so a minimum height is all they need and
     the content stays where it is. Measured: nav links 36px, cluster headings
     24px, the header's tax year 24px. */
  .nav-link,
  .nav-cluster__heading,
  .app-header__tax-year-current {
    min-height: 44px;
  }

  /* SQUARE ICON BUTTONS. Both dimensions, because these were 32x32 and 36x36 —
     short on the axis a fingertip is widest. */
  .theme-toggle,
  .mobile-nav-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  .stepper-input__btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* BLOCK ROWS THAT NEED THEIR LABEL CENTRING once they are taller. Safe to
     make these flex containers: each holds one run of text, and each is
     already a full-width row rather than something sitting inside a sentence. */
  .nav-tax-year__option,
  .welcome-hero__secondary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .welcome-hero__secondary {
    justify-content: center;
  }

  /* `inline-flex`, NOT `flex`. The footer's "more" control sits inside a line
     of footer text, and `display: flex` would take it out of that line and put
     it on its own. `inline-flex` keeps the inline flow and still centres. */
  .app-footer__more {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* A `<summary>` is a `list-item` and carries the disclosure marker, so its
     display must not be touched. Padding is the safe axis. 24px measured, and
     10px top and bottom clears 44. */
  .expandable-section__summary {
    padding-block: 10px;
  }

  /* THE SMALLEST THING IN THE PRODUCT, at 13x21, and the only one that cannot
     simply be made bigger: the tooltip trigger sits inside a sentence, and
     growing the button would open up the line it lives in. So the BUTTON stays
     13px and its TAP AREA becomes 44px, centred on it and invisible.
     `::after` was free on this selector — checked, it has no pseudo-elements —
     and `.multi-select-toggle__checkbox` deliberately is not treated this way
     because its `::after` already draws the tick. */
  .info-tooltip__trigger {
    position: relative;
  }

  .info-tooltip__trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: max(100%, 44px);
    height: max(100%, 44px);
    transform: translate(-50%, -50%);
  }

  /* WHAT IS DELIBERATELY LEFT ALONE, so the next person does not "finish" it.

     INLINE LINKS INSIDE SENTENCES — `.text-link` at 21px, `.inline-link` and
     `.settings-available__link` at 24px and 36px. These are words in a
     paragraph, not controls in a row. WCAG 2.5.8 exempts inline targets for
     exactly this reason: making them 44px tall would space out the sentence
     they are part of, which is a worse result than a slightly small link.

     CHECKBOXES. `.multi-select-toggle__checkbox` is 20x20 and an earlier count
     called all sixteen of them broken. That count was wrong: the checkbox is
     wrapped in a `<label>` 276px wide and over 44px tall, so the thing a
     finger actually hits is already big enough and the box is cosmetic.
     Measure the tap target, not the input.
     ----------------------------------------------------------------------- */
}
