/* ==========================================================================
   Atlas Foundry — core/css/core.css — Atlas Foundry design system

   Design tokens, the reset, type scale, accessibility helpers, the
   application shell (root layout, sidebar, header) and the base component
   set: buttons, cards, tables, form fields, dialogs, tooltips, charts.

   [Core extraction, Stage 3] Split from the single css/styles.css at ONE
   line boundary, so the two files concatenated in load order are the
   original file byte-for-byte. That is what makes the cascade provably
   unchanged: no rule moved relative to any other rule.
   ========================================================================== */
/* ==========================================================================
   Atlas Foundry — Self-Assessment Calculator
   styles.css — design tokens + base reset + shell layout

   Token source of truth: Atlas Foundry Design Specification v2 (§1–3) and
   the SATaxCalc UX Specification (§6.1–6.3). Every colour, size and spacing
   value used anywhere in this app must come from one of these custom
   properties — no screen or component is permitted to hardcode a value.

   Light-mode values live here as the default. themes.css overrides the
   theme-dependent subset for [data-theme="dark"].
   ========================================================================== */

/* ---- Self-hosted typeface (Poppins, SIL OFL) — see --font-family's own
   comment below for why Poppins rather than Inter. Local files only,
   zero network requests, works fully offline. ---------------------------- */
@font-face {
  font-family: "Poppins";
  src: url("../../assets/fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../../assets/fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../../assets/fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 600 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* ---- Colour: surfaces & text (light mode defaults; Design Spec §1) ---- */
  --surface-canvas: #F7F8FA;
  --surface-card: #FFFFFF;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --border-hairline: #E5E7EB;

  /* ---- Colour: accents (identical across both themes; Design Spec §1) --- */
  --accent-navy: #0F2A4A;
  --accent-navy-hover: #163A63;
  --accent-teal: #2FB8AC;
  --accent-teal-hover: #279E94;
  --accent-coral: #FF6B5E;
  --accent-gold: #E8B84B;

  /* Chart-only colour, distinct from --accent-navy: the base navy
     (#0F2A4A) has a 1.15:1 contrast ratio against the dark-mode card
     background — effectively invisible (design review flagged the
     Income-by-Source chart's navy bar as "barely a sliver" in dark
     mode). This lighter blue clears the WCAG non-text-contrast minimum
     (3:1) against BOTH the light card (#FFFFFF, 4.43:1) and dark card
     (#1B1E29, 3.75:1), so one value works for both themes without a
     themes.css override, while staying in the same navy-blue family so
     "self-employment = blue" still reads consistently. */
  /* Kept as an alias for one release so nothing breaks mid-change; remove once
     no stylesheet or screen refers to it. See the palette block below. */
  --chart-series-blue: var(--chart-series-1);

  /* Two more dedicated chart-only colours for Property and Partnership
     income (Dashboard's Income by Source chart) — deliberately NOT
     reusing --accent-coral here even though it was visually convenient:
     coral is reserved for "needs attention," max one per screen, and a
     4th income category is neither of those things. Both contrast-
     checked the same way as --chart-series-blue (≥3:1 against both
     theme card backgrounds). */
  --chart-series-purple: var(--chart-series-5);
  --chart-series-rose: var(--chart-series-2);

  /* ---------------------------------------------------------------------
     [C-2, 8 September 2026] THE CHART SERIES PALETTE, CORRECTED.

     WHAT WAS WRONG. --chart-series-blue (#4A7AB5) and --chart-series-purple
     (#8B6FB8) sat beside each other in the calculator's Income by Source
     chart, labelled "Self-employment" and "Property". Simulated for
     protanopia they measure ΔE 1.6 apart — for a red-blind viewer, the same
     colour. Roughly one man in twelve has some colour-vision deficiency.

     WHY SIX PHASES OF ACCESSIBILITY WORK MISSED IT. axe-core checks a colour
     against its BACKGROUND. It has no concept of two colours being confusable
     with EACH OTHER, so a clean automated sweep says nothing about whether two
     series can be told apart. The whole class is invisible to the tooling the
     platform already runs, which is why qa/chartPaletteTest.mjs exists and
     reads these values out of the BUILT stylesheet rather than trusting a list.

     ASSIGN IN SLOT ORDER AND NEVER CYCLE. The order is deliberate: adjacent
     slots are the ones guaranteed to separate. Slots 1 and 5 are only ~4.5
     apart under protanopia, so a chart using three series must use 1, 2 and 3
     — which all-pairs-check at 17.2 or better — and never 1 and 5 together.

     FIVE SERIES IS THE MAXIMUM, and a pie or donut may hold at most three,
     because slices touch in every combination rather than only neighbouring
     ones. Full rules: products/nwt/spec/NWT-DESIGN-SPECIFICATION.md §5.2–5.3.

     Dark values are chosen rather than flipped, and live in themes.css.
     --------------------------------------------------------------------- */
  --chart-series-1: #2F6FBF;  /* blue   */
  --chart-series-2: #C6577A;  /* rose — unchanged from the old palette */
  --chart-series-3: #B9821F;  /* gold   */
  --chart-series-4: #1F9E93;  /* teal   */
  --chart-series-5: #7A5AA8;  /* purple */

  /* [V2.0 feedback, Finding 01] "The option you elected" on a
     comparison card — deliberately navy, NOT the teal used for
     "recommended", so that stating what is in use never reads as
     endorsing it. Overridden in themes.css for dark mode, where base
     navy (#0F2A4A) is effectively invisible against the dark card for
     the same reason --chart-series-blue exists. */
  --elected-border: var(--accent-navy);

  /* The recommendation badge's own text. NOT --accent-teal-text: this
     badge sits on a teal tint that itself sits on the recommended
     column's teal tint, compositing to ~#D9EDED rather than white, and
     --accent-teal-text (#1E766E) measures only 4.46:1 there (axe-core).
     This darker teal clears 4.5:1 on that doubled tint. Overridden in
     themes.css, where the ground is dark instead. */
  --badge-teal-text: #146359;

  /* Darkened variants specifically for white-text buttons — the base
     accent-teal/accent-coral values above are correct for chips/rings
     (which pair them with dark text and already pass WCAG AA), but white
     text directly on the base teal/coral fails AA (2.45:1 / 2.79:1).
     These pass at 4.75:1 / 5.32:1 while staying visibly the same hue. */
  --accent-teal-button: #208078;
  --accent-teal-button-hover: #1B6D66;
  --accent-coral-button: #B24A41;
  --accent-coral-button-hover: #9C3F37;

  /* [V18 — Final Pre-Destruction Audit, F-017] A third, distinct pairing
     from the two above: base --accent-teal used AS THE TEXT COLOUR
     directly on a light surface (welcomeScreen.js's section eyebrow
     labels and step-index numbers, on --surface-canvas/--surface-card)
     — axe-core measured 2.3:1/2.44:1 against #F7F8FA/#FFFFFF, both well
     under the 4.5:1 AA minimum for normal-size text. #208078
     (--accent-teal-button, validated for the OPPOSITE pairing — white
     text ON teal) got close but not quite there against #F7F8FA
     (4.471:1, axe-core measured) — this value is darkened one step
     further, same hue family, computed via the WCAG relative-luminance
     formula directly (contrast 5.10:1 against #F7F8FA, higher again
     against #FFFFFF), then confirmed via the same axe-core scan.
     Theme-aware: overridden back to the brighter base teal in dark mode
     in themes.css, since a foreground darkened for light-surface
     contrast would UNDER-contrast against the dark surfaces the
     light-mode fix doesn't apply to. */
  --accent-teal-text: #1E766E;

  /* The coral equivalent, for a figure that is a LOSS. Base --accent-coral
     (#FF6B5E) as text on a light surface measures about 2.5:1 — the same trap
     the teal note above describes. This is the darkened coral already proven
     for buttons, which reads at roughly 5.3:1 as text on white. Overridden in
     themes.css for dark surfaces. */
  --accent-coral-text: #B24A41;

  /* STATUS INK, BY THEME. [13 September 2026] The three status chip text
     colours were written straight into their rules, as the darkened values
     that pass on a light card. Dark mode never overrode them, so it drew dark
     ink on a dark tint: 1.83:1 on "Paid" and every positive chip, 1.99:1 on
     "Review suggested", "Outstanding" and every caution chip (axe-core, both
     UI/UX audits). WCAG AA wants 4.5:1. The Remove link used the attention
     value the same way and measured 2.43:1. Light values unchanged; dark
     values in themes.css. */
  --status-positive-text: #146359;
  --status-caution-text: #8A5F0E;
  --status-attention-text: #A82E24;

  /* ---- Colour: functional aliases (keeps intent readable in component CSS) */
  --colour-positive: var(--accent-teal);   /* "on track" */
  --colour-attention: var(--accent-coral); /* "needs action now" — max 1/screen */
  --colour-caution: var(--accent-gold);    /* "worth watching" */
  --colour-focus-ring: var(--accent-teal);

  /* ---- Typography (Design Spec §2 / UX Spec §6.2) ----------------------- */
  /* Self-hosted Poppins (SIL OFL licensed), not Inter — Inter's own font
     files weren't obtainable without a network dependency this build
     environment doesn't have, and shipping a system-font fallback
     indefinitely was flagged as the single highest-impact "looks like a
     template" issue in design review. Poppins is a legitimate,
     distinctive geometric sans in the same family of choices as Inter/SF
     Pro for this kind of product — genuinely self-hosted (see
     assets/fonts/, @font-face below), zero runtime network dependency,
     fully consistent with the offline-first constraint. System-stack
     fallback still applies before the webfont loads / if font loading
     ever fails. */
  --font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --text-display-size: 36px;
  --text-display-weight: 600;
  --text-display-line: 1.15;

  --text-title-size: 22px;
  --text-title-weight: 600;
  --text-title-line: 1.3;

  /* Raised from 14px on 5 September 2026. Jordan, reviewing Small Business
     Manager: "make sure the text size is adequate (not too small)". 14px is
     defensible for dense tabular data and mean for prose, and these products
     are mostly prose — explanations of why a figure is what it is. 15px with a
     more generous line height reads as considered rather than cramped. */
  --text-body-size: 15px;
  --text-body-weight: 400;
  --text-body-line: 1.6;

  --text-label-size: 12px;
  --text-label-weight: 500;
  --text-label-line: 1.4;
  --text-label-tracking: 0.02em;

  /* THE ONE THAT MATTERED MOST. 11px was being used for whole explanatory
     paragraphs — the tooltip sources, the "why this figure is what it is"
     notes, the HMRC caveats — and at 11px a customer skips them. That is the
     opposite of what they are for: they exist because somebody would otherwise
     misread a tax figure.
     12.5px keeps a clear step below body (15px) so the hierarchy still reads,
     while being large enough that a paragraph is worth starting. The line
     height goes up more than the size does, because long-form text at a small
     size fails on leading before it fails on size. */
  --text-caption-size: 12.5px;
  --text-caption-weight: 400;
  --text-caption-line: 1.55;

  /* ---- Spacing: 8px base unit (Design Spec §3) --------------------------- */
  --space-1: 4px;   /* half-step, used sparingly (icon gaps etc.) */
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 40px;
  --space-7: 48px;
  --space-8: 64px;

  /* ---- Radius & elevation ------------------------------------------------- */
  --radius-card: 14px;   /* 12–16px range per spec */
  --radius-control: 8px; /* buttons, inputs, chips */
  --radius-pill: 999px;  /* status chips */

  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04), 0 4px 12px rgba(17, 24, 39, 0.05);
  --shadow-dialog: 0 8px 24px rgba(17, 24, 39, 0.16), 0 2px 6px rgba(17, 24, 39, 0.08);

  /* ---- Motion (Design Spec §5 — static-equivalent motion cues) ---------- */
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-easing: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Layout constants used by the shell -------------------------------- */
  --nav-width: 248px;
  --header-height: 64px;
  --content-max-width: 1280px;
  /* The reading measure for a screen that is a form or a piece of prose rather
     than a table — Settings, Setup, My Profile. It was the literal 640px in
     four separate files, which is the kind of number that drifts one file at a
     time; naming it is the only way the three screens stay agreed. Data screens
     keep --content-max-width, and the Welcome hero keeps its own wider column:
     three measures for three purposes, deliberately, not by accident. */
  --content-measure: 640px;
}

/* ---- Reset -------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* [QA fix] The browser's default `[hidden] { display: none }` UA rule
   has the same specificity as any component's own `.foo { display: ... }`
   class rule, and author stylesheets load after the UA stylesheet — so
   without this, a component that sets its own `display` (nearly all of
   them: .nav-link, .nav-cluster, tooltip bubbles, field error/warning
   text) silently wins the cascade over the `hidden` attribute. Every
   `element.hidden = true` in the codebase (sidebar circumstance gating,
   tooltips, currency/date field validation messages) was therefore
   updating the DOM correctly but never visibly hiding anything. This is
   the actual root cause behind "the sidebar doesn't hide what's
   irrelevant" across every previous report of that symptom — the
   gating logic itself was correct throughout; only this one rule was
   ever missing. `!important` is deliberate here: it needs to outrank
   every component's own display declaration regardless of selector
   specificity or source order, which is exactly what `[hidden]` is
   supposed to guarantee and didn't. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--text-body-size);
  font-weight: var(--text-body-weight);
  line-height: var(--text-body-line);
  color: var(--text-primary);
  background: var(--surface-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--motion-base) var(--motion-easing),
    color var(--motion-base) var(--motion-easing);
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* ZERO SPECIFICITY, AND NOTHING ELSE ABOUT IT CHANGED. [13 September 2026]
   As `h1, h2, h3, h4, p` this out-ranked every zero-specificity rule, so the
   card rhythm in components.css ("every block in a card is separated") could
   not both lose to spacing a component sets on purpose and beat this. Checked
   before changing it: every other rule that sets a heading or paragraph margin
   is already more specific or loads later, so nothing that won before loses
   now. */
:where(h1, h2, h3, h4, p) {
  margin: 0;
}

/* Tabular figures everywhere numeric data appears — non-negotiable per
   UX Spec §6.2 given the volume of aligned monetary data in this product. */
.numeric,
.tabular-nums {
  font-variant-numeric: tabular-nums lining-nums;
}

/* ---- Type scale utility classes ------------------------------------------ */
.text-display {
  font-size: var(--text-display-size);
  font-weight: var(--text-display-weight);
  line-height: var(--text-display-line);
}

.text-title {
  font-size: var(--text-title-size);
  font-weight: var(--text-title-weight);
  line-height: var(--text-title-line);
}

.text-body {
  font-size: var(--text-body-size);
  font-weight: var(--text-body-weight);
  line-height: var(--text-body-line);
}

.text-label {
  font-size: var(--text-label-size);
  font-weight: var(--text-label-weight);
  line-height: var(--text-label-line);
  letter-spacing: var(--text-label-tracking);
  color: var(--text-secondary);
}


/* ---- Uppercase belongs to column headings, not to field labels -----------
   Every .text-label was uppercased: field labels, card labels, table headings,
   the lot. Heavy uppercase is the strongest "admin panel" signal left in the
   design and is measurably slower to read — it was the main thing making a
   considered product feel like an internal tool.

   A table's column heading is a different job: it is scanned rather than read,
   it repeats down a page of figures, and caps help it recede from the data
   beneath. `th` separates the two cleanly, with no markup changes anywhere.

   Sentence case everywhere else. The source strings are already written that
   way ("Money in", "All months", "Payment terms, in days"), so this changes
   only how they are drawn — and note that `innerText` now returns the source
   casing, which several tests were written around. */
th.text-label {
  text-transform: uppercase;
}

.text-caption {
  font-size: var(--text-caption-size);
  font-weight: var(--text-caption-weight);
  line-height: var(--text-caption-line);
  color: var(--text-secondary);
}

/* ---- Focus visibility (accessibility — core requirement, not optional) -- */
:focus-visible {
  outline: 2px solid var(--colour-focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

/* ---- Accessibility: visually-hidden but screen-reader-accessible -------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Accessibility: skip link ------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: var(--space-3) var(--space-4);
  background: var(--accent-navy);
  color: #fff;
  border-radius: 0 0 var(--radius-control) 0;
}

.skip-link:focus {
  left: 0;
}

/* ---- App shell layout ---------------------------------------------------- */
.app-root {
  display: flex;
  min-height: 100vh;
  background: var(--surface-canvas);
  color: var(--text-primary);
}

.app-nav {
  flex: 0 0 auto;
  width: 0;
  background: var(--accent-navy);
  overflow-y: auto;
}

.app-nav--ready {
  width: var(--nav-width);
  padding: var(--space-4) var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.app-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  flex: 0 0 auto;
  height: 0;
  border-bottom: 1px solid var(--border-hairline);
}

.app-header--ready {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  background: var(--surface-card);
}

.app-header__save-status {
  color: var(--text-secondary);
}

/* [V17 Phase 6] Mobile nav toggle + backdrop — hidden entirely above the
   767px breakpoint, where the sidebar is already always visible and the
   viewport has room for it alongside content. See the max-width: 767px
   block below for the off-canvas nav behaviour itself, and
   components/header.js for the open/close/focus wiring. */
.mobile-nav-toggle {
  display: none;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-2);
  margin-right: var(--space-2);
  border-radius: var(--radius-control);
}

.mobile-nav-toggle:hover {
  background: var(--surface-canvas);
}

.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  z-index: 1090; /* below the nav's own z-index, above ordinary content */
}

.app-header__title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-header__title {
  margin: 0;
}

/* [Tax year navigation] Every available/upcoming year shown as its own
   permanent, clickable tab — the active year is visually distinct and
   non-interactive; a switchable year switches sessions on click; an
   upcoming (not-yet-published) year opens an informational dialog
   instead. Deliberately not arrows/a single badge — see
   components/header.js's own comment for why, and for where the arrow
   pattern should return once the year count outgrows this. */
.app-header__tax-year-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: var(--surface-canvas);
}

.app-header__tax-year-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption-size);
  white-space: nowrap;
}

.app-header__tax-year-tab:hover:not(:disabled):not(.app-header__tax-year-tab--active) {
  background: var(--surface-card);
  color: var(--text-primary);
}

.app-header__tax-year-tab--active {
  background: var(--surface-card);
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}

.app-header__tax-year-tab:disabled:not(.app-header__tax-year-tab--active) {
  color: var(--border-hairline);
  cursor: default;
}

@media (max-width: 767px) {
  /* No room for the tabs beside the title on a phone. [13 September 2026]
     The reason given here was that "the current year is still readable in
     Settings/Tax Year". It was not: Settings never showed it, so a phone
     customer could neither see nor change the year (calculator UI/UX audit,
     H4). The year line and drawer switch below replace the tabs here. */
  .app-header__tax-year-tabs {
    display: none;
  }
}

/* ---- THE TAX YEAR ON A PHONE ---------------------------------------------
   [13 September 2026] Drawn by products/sa-tax/ui/taxYearTabs.js, placed by
   core/components/header.js. Above the title rather than beside it: measured
   at 390px, six screen titles already fill two lines of the row, and at 320px
   three fill three and spill out of the 64px header. So on a phone the header
   keeps its height where it can and grows where a title needs it, rather than
   letting text run out of it. Products with no year simply have neither. */
.app-header__tax-year-current,
.nav-tax-year {
  display: none;
}

@media (max-width: 767px) {
  .app-header--ready {
    height: auto;
    min-height: var(--header-height);
    padding-block: var(--space-1);
  }

  .app-header__title-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
  }

  /* Visually above the title; after it in the page, where the heading that
     names the screen should come first. */
  .app-header__tax-year-current {
    order: -1;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    /* The WCAG 2.2 minimum target height. */
    min-height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--text-caption-size);
    font-weight: 500;
    cursor: pointer;
  }

  .app-header__tax-year-current::after {
    content: "▾";
  }

  .nav-tax-year {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }
}

.nav-tax-year__heading {
  margin: 0;
  padding: 0 var(--space-2);
  color: rgba(255, 255, 255, 0.58);
}

.nav-tax-year__options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}

/* The sidebar's own vocabulary: the resting and active colours of a nav link,
   which already pass contrast on the navy. */
.nav-tax-year__option {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption-size);
  font-weight: 500;
  cursor: pointer;
}

.nav-tax-year__option:hover:not(.nav-tax-year__option--active) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-tax-year__option--active {
  background: var(--accent-teal);
  border-color: var(--accent-teal);
  color: var(--accent-navy);
  font-weight: 600;
  cursor: default;
}

.nav-tax-year__option:focus-visible {
  outline: 2px solid var(--accent-teal);
  outline-offset: 2px;
}

/* ---- Sidebar below the mobile breakpoint --------------------------------- */
/*
 * MOVED HERE FROM products/sa-tax/css/screens.css ON 2 SEPTEMBER 2026, and the
 * move is the point rather than a tidy-up.
 *
 * These rules style CORE chrome — the sidebar and the toggle button that
 * core/components/nav.js and core/components/header.js render for every
 * product. They were sitting in the tax calculator's stylesheet, which meant a
 * package that does not ship the calculator got the markup with none of the
 * behaviour: the sidebar stayed a static 248px block, and at a 320px viewport
 * it took 248 of the 320 available and pushed the page sideways.
 *
 * That is what it did. Every one of Small Business Manager's screens failed
 * WCAG 1.4.10 in the assembled SBM package — including Overview, which has no
 * tables and no wide content of its own to blame. The calculator's own reflow
 * test passed throughout, because in the calculator's package the rules were
 * present. Nothing was wrong with the tax calculator; the fault only existed in
 * packages built without it, and nothing had ever scanned one.
 *
 * Same shape as the MTD checker living in products/sa-tax/taxEngine: shared
 * behaviour parked in the first product that happened to need it, invisible
 * until a second product existed.
 */
@media (max-width: 767px) {
  /* [V17 Phase 6] WCAG 1.4.10 (Reflow) fix — the sidebar previously had
     no responsive handling at all: a fixed 248px width with no
     collapse, which forced horizontal page scrolling at any viewport
     narrower than roughly 248px plus a usable content minimum
     (confirmed failing at 320px on every route tested, via
     qa/e2e/accessibility-reflow.spec.mjs). Below this breakpoint the
     nav becomes an off-canvas drawer, hidden by default and toggled by
     .mobile-nav-toggle (components/header.js) — position: fixed takes
     it out of the flex flow entirely, so .app-body gets the full
     viewport width automatically with no other layout change needed. */
  .app-nav--ready {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform var(--motion-base) var(--motion-easing);
    box-shadow: var(--shadow-dialog);
  }

  .app-nav--ready.app-nav--open {
    transform: translateX(0);
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav-backdrop:not([hidden]) {
    display: block;
  }
}

/* ---- Sidebar: brand row + theme toggle ----------------------------------- */
.nav-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-brand__top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.nav-brand__identity {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.nav-brand__logo-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.nav-brand__logo {
  width: 32px;
  height: 32px;
}

.nav-brand__mark {
  /* Deliberately smaller than --text-title-size, and smaller again now
     that the logo badge grew from 28px to 44px — a 248px sidebar still
     has to fit logo + wordmark + theme toggle on one row. This size is
     what actually stops "Atlas St…" truncating, with ellipsis kept as a
     safety net rather than the primary fix. */
  font-size: 16px;
  font-weight: var(--text-title-weight);
  color: #fff;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-brand__subtitle {
  margin: 0;
  padding-left: 52px; /* aligns under the wordmark, past the logo badge */
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-toggle {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-easing);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ---- Sidebar: clusters + links -------------------------------------------- */
.nav-cluster {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-cluster--home {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-cluster__heading {
  color: rgba(255, 255, 255, 0.5);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-control);
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: var(--text-body-size);
  line-height: 1.3;
  transition: background var(--motion-fast) var(--motion-easing),
    color var(--motion-fast) var(--motion-easing);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link--active {
  background: var(--accent-teal);
  color: var(--accent-navy);
  font-weight: 600;
}

.nav-link__icon {
  opacity: 0.75;
  flex: 0 0 auto;
}

.nav-link--active .nav-link__icon {
  opacity: 1;
}

/* ---- Buttons (base — full variant set arrives with Milestone 6's
   component library; only what Dashboard needs exists here for now) ------- */
.button {
  appearance: none;
  border: none;
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body-size);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-easing),
    transform var(--motion-fast) var(--motion-easing);
}

/* ---- A button that is not available should look it -------------------------
   Nothing in this stylesheet styled `:disabled` or `[aria-disabled]`, so an
   unavailable primary button rendered as a solid, confident, fully enabled
   one — most visibly the Continue on "Why are you filing?", the first real
   control in the product. People click it, nothing happens, and nothing
   explains why. Found in the 5 September 2026 UI/UX audit.

   Both selectors: `:disabled` for controls that genuinely take the attribute,
   `[aria-disabled="true"]` for the ones kept in the tab order on purpose so
   they can still be reached and can still answer. */
.button:disabled,
.button[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.button:disabled:active,
.button[aria-disabled="true"]:active {
  transform: none;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  background: var(--accent-teal-button);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-teal-button-hover);
}

.button--secondary {
  background: transparent;
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}

.button--secondary:hover {
  background: var(--surface-canvas);
}

.button--danger {
  background: var(--accent-coral-button);
  color: #fff;
}

/*
 * A quiet button, for an action that must be available without competing with
 * the one the screen is for — "Remove" on a table row, "Skip this step".
 *
 * Added 2 September 2026 because Small Business Manager needed one sixteen
 * times and the platform had only primary, secondary and danger. SBM's screens
 * had been written against the design mockups in products/sbm/spec/design,
 * which use a `btn btn--*` naming the stylesheets have never used — so every
 * button in the product matched no rule at all and rendered as a raw operating
 * system button. Renaming them to the platform's `button button--*` needed a
 * tertiary to rename INTO, and it belongs in Core for the same reason the
 * sidebar rules do: it is a shared component, not one product's.
 */
.button--tertiary {
  background: transparent;
  border: none;
  color: var(--accent-teal-text);
  padding: var(--space-1) var(--space-2);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.button--tertiary:hover {
  background: var(--surface-canvas);
}

.button--danger:hover {
  background: var(--accent-coral-button-hover);
}

/* ---- KPI Card / Chart Card grid spans (shared with Dashboard's own
   dash-card spans so both can sit in the same 12-col grid) --------------- */
.kpi-card--span-3, .chart-card--span-3 { grid-column: span 3; }
.kpi-card--span-4, .chart-card--span-4 { grid-column: span 4; }
.kpi-card--span-6, .chart-card--span-6 { grid-column: span 6; }
.kpi-card--span-12, .chart-card--span-12 { grid-column: span 12; }

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

.kpi-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card__label-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  /* [Real user feedback, 18 August 2026] Reserve room for a 2-line label
     so the hero value below always starts at the same height whether a
     given card's label wraps or not — otherwise a row of cards with
     mixed 1-line/2-line labels shows its values at visibly different
     heights (e.g. Savings & Dividends' KPI row). */
  min-height: calc(var(--text-label-size) * var(--text-label-line) * 2);
}

.kpi-card__icon {
  color: var(--accent-teal);
  flex: 0 0 auto;
}

.kpi-card__value {
  margin: var(--space-1) 0 0;
}

/* STACKED, THE FIGURES FORM A COLUMN, SO THEY LINE UP LIKE ONE. [13 September
   2026] Below 768px the cards stack full width, and each value stayed at the
   left, so a run of figures down the screen ended 23-95px apart (calculator
   UI/UX audit, H2). Right-aligned they share one edge, as the tracker's phone
   layout already does. The label stays where it reads first. */
@media (max-width: 767px) {
  .kpi-card__value {
    text-align: right;
  }
}

.kpi-card__secondary {
  margin: 0;
}

.kpi-card__empty-hint {
  margin-top: var(--space-2);
  color: var(--text-secondary);
}

.kpi-card__status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* [V17 Phase 6] Scoped to this element only, not the shared --colour-*
   tokens (also used elsewhere, e.g. .payments-calendar__amount--refund,
   not individually re-verified in this pass — see
   docs/V17-Accessibility-Audit.md for why a broader accent-color sweep
   is tracked as a separate follow-up rather than done here). This dot
   is a graphical status indicator (role="img", see kpiCard.js) so WCAG
   1.4.11 Non-Text Contrast (3:1 against its white card background)
   applies, not the 4.5:1 text minimum — the base accent colors measured
   2.45:1/2.79:1/1.84:1, all failing even that lower bar. */
.kpi-card__status--positive { background: #147a71; }
.kpi-card__status--attention { background: #c73529; }
.kpi-card__status--caution { background: #8a6407; }

/* ---- Status Chip ----------------------------------------------------------- */
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-caption-size);
  font-weight: 600;
}

/* [V17 Phase 6] positive/attention darkened from #1F8478/#C8392E — axe-core
   color-contrast: 4.01:1 / 4.46:1 against this pill's own tinted background,
   both below the 4.5:1 WCAG AA text minimum. caution (#92650F, 4.61:1) and
   neutral already passed and are unchanged. */
/* Ink from the --status-*-text tokens since 13 September 2026, so dark mode can
   brighten it. The light values, and the measurements below, are unchanged. */
.status-chip--positive { background: rgba(47, 184, 172, 0.14); color: var(--status-positive-text); }
.status-chip--attention { background: rgba(255, 107, 94, 0.14); color: var(--status-attention-text); }
/* #92650F measured 4.36:1 against 4.5 when this chip sits on the page canvas
   rather than inside a white card — its background is semi-transparent, so its
   contrast depends on what is behind it. The calculator only ever puts chips in
   cards, so it passed there and failed the moment Small Business Manager put a
   ledger row straight on the canvas. Darkened until it holds in BOTH places
   (4.83:1 on canvas, 5.10:1 on a card) rather than tuned to one of them. */
.status-chip--caution { background: rgba(232, 184, 75, 0.18); color: var(--status-caution-text); }
.status-chip--neutral { background: var(--surface-canvas); color: var(--text-secondary); }

/* ---- Alert Banner ----------------------------------------------------------- */
.alert-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  border: 1px solid transparent;
}

.alert-banner--attention {
  background: rgba(255, 107, 94, 0.08);
  border-color: rgba(255, 107, 94, 0.32);
}

.alert-banner--caution {
  background: rgba(232, 184, 75, 0.1);
  border-color: rgba(232, 184, 75, 0.36);
}

.alert-banner--positive {
  background: rgba(47, 184, 172, 0.08);
  border-color: rgba(47, 184, 172, 0.32);
}

.alert-banner__title {
  font-weight: 600;
  margin: 0;
}

.alert-banner__message {
  margin: var(--space-1) 0 0;
  /* [V17 Phase 6] Overrides the inherited .text-caption color
     (var(--text-secondary), #6B7280) — axe-core color-contrast: 4.46:1
     on the attention tint and 4.50:1 on the positive tint, both below
     the 4.5:1 WCAG AA text minimum (caution's tint passed at 4.56:1,
     but a single override covers all three tones with margin). This
     hex was tuned against LIGHT mode's tinted backgrounds only — dark
     mode was never accounted for, so the same dark grey landed on a
     dark tinted background there too (real user feedback: "the text is
     grey and difficult to read... should be white text not grey"). */
  color: #4B5563;
}

[data-theme="dark"] .alert-banner__message {
  color: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
  [data-theme="system"] .alert-banner__message {
    color: var(--text-primary);
  }
}

.alert-banner__dismiss {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-body-size);
  line-height: 1;
}

/* ---- Data Table -------------------------------------------------------------- */
.data-table-wrapper {
  padding: var(--space-3);
  /* [V18 — Final Pre-Destruction Audit, F-020] No horizontal-scroll
     handling existed here at all — at narrow (mobile) viewports the
     table (columns: date, client/source, description, amount, plus
     icon/action columns) genuinely exceeded the wrapper's own width
     (measured directly: table scrollWidth 407px vs wrapper clientWidth
     309px at 375px viewport), the Amount column was clipped off-screen,
     and because `overflow-x` was unset (`visible`), the excess spilled
     out and made the WHOLE PAGE scroll horizontally — a genuine,
     reproduced WCAG 1.4.10 (Reflow) violation. `overflow-x: auto`
     contains the scroll to the table itself instead — this is the
     first wide-content container in this stylesheet to need it; no
     other rule currently sets `overflow-x` anywhere. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;

  /* ---- Say that there is more to the right --------------------------------
     The scroll above is correct, but on macOS the scrollbar is an overlay that
     stays hidden until you scroll — so a narrow window showed a column sliced
     off mid-figure ("£4…") with nothing to suggest it could be reached. It
     reads as a rendering fault rather than as scrollable content.

     The classic two-layer trick: `local` gradients paint the card colour over
     each end and scroll WITH the content, so they uncover as you reach an edge;
     `scroll` gradients stay put and draw the shadow. At rest the shadow shows
     only on the side that has more content. Purely decorative — nothing is
     conveyed by it that the scrolling itself does not. */
  background-image:
    linear-gradient(to right, var(--surface-card), transparent 24px),
    linear-gradient(to left, var(--surface-card), transparent 24px),
    linear-gradient(to right, rgba(0, 0, 0, 0.13), transparent 12px),
    linear-gradient(to left, rgba(0, 0, 0, 0.13), transparent 12px);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 24px 100%, 24px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

.mtd-figures__scroll {
  background-image:
    linear-gradient(to right, var(--surface-card), transparent 24px),
    linear-gradient(to left, var(--surface-card), transparent 24px),
    linear-gradient(to right, rgba(0, 0, 0, 0.13), transparent 12px),
    linear-gradient(to left, rgba(0, 0, 0, 0.13), transparent 12px);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 24px 100%, 24px 100%, 12px 100%, 12px 100%;
  background-attachment: local, local, scroll, scroll;
}

.data-table-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}

.data-table-empty {
  text-align: center;
  padding: var(--space-5) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
}

/* A measure, so the explanation reads as a paragraph rather than one long
   line across a wide card. */
.data-table-empty > p {
  max-width: 46ch;
}

.data-table-empty__title {
  margin-bottom: 0;
}

.data-table-empty__hint {
  color: var(--text-secondary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-card);
  text-align: left;
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border-hairline);
}

.data-table tbody tr:nth-child(odd) {
  background: rgba(17, 24, 39, 0.02);
}

.data-table td {
  padding: var(--space-3) var(--space-2);
}

.data-table--right {
  text-align: right;
}

/* [Column alignment fix] `.data-table thead th` above (0,1,2
   specificity: one class + two type selectors) otherwise always beats
   the plain `.data-table--right` class (0,1,0) on a <th>, regardless
   of source order — right-aligned numeric column headers ("Amount",
   etc.) stayed left-aligned while their own data cells correctly
   right-aligned, so the header text and the values it labelled visibly
   didn't line up. Real user feedback: "the columns do not align with
   the row information." This selector (0,2,2) wins over both. */
.data-table thead th.data-table--right {
  text-align: right;
}

.data-table__icon-cell {
  width: 32px;
  padding-right: 0 !important;
}

.data-table__row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-canvas);
  color: var(--accent-teal);
}

.data-table__actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
}

.data-table__action-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--motion-fast) var(--motion-easing),
    color var(--motion-fast) var(--motion-easing);
}

.data-table__action-btn:hover {
  background: var(--surface-canvas);
  color: var(--accent-teal);
}

.data-table__action-btn--danger:hover {
  color: var(--accent-coral);
}

/* ---- Form fields (Currency Input / Date Input) -------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

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

.field__label-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.field__hint {
  color: var(--text-secondary);
  margin: 0;
  min-height: 1em;
}

/* The error line under a field keeps its space whether or not it says
   anything. Removing it from flow moved the Save button 23px the moment a
   corrected value cleared the message on blur — so the button was no longer
   under the cursor that was pressing it. Content must not move under a
   pointer that is already committing to a click. */
.field__error {
  color: var(--accent-coral);
  margin: 0;
  min-height: 1.55em;
}

.field__error--empty {
  visibility: hidden;
}

.field__warning {
  color: #92650F;
  margin: 0;
}

.field--invalid input {
  border-color: var(--accent-coral) !important;
}

.currency-input__row {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: 0 var(--space-3);
  background: var(--surface-card);
}

.currency-input__row:focus-within {
  border-color: var(--accent-teal);
}

.currency-input__prefix {
  color: var(--text-secondary);
  margin-right: var(--space-1);
}

.currency-input__field {
  border: none;
  outline: none;
  padding: var(--space-2) 0;
  width: 100%;
  background: transparent;
  text-align: right;
}

.date-input__field {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-card);
}

.date-input__field:focus {
  border-color: var(--accent-teal);
}

/* ---- Expandable Section ---------------------------------------------------- */
.expandable-section {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-card);
  margin-bottom: var(--space-2);
}

.expandable-section__summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.expandable-section__summary::-webkit-details-marker {
  display: none;
}

/* [V13 — QA D5] The optional heading nested inside <summary> (see
   expandableSection.js) exists purely to give screen-reader heading
   navigation a real target — it must not visually differ from the
   plain-text title this component has always rendered. Explicitly
   inherit every relevant property from the <summary> it sits inside,
   since browsers apply their own default h1-h6 font-size/weight/margin
   that would otherwise override .expandable-section__summary's rules. */
.expandable-section__summary-heading {
  display: inline;
  font: inherit;
  font-weight: inherit;
  margin: 0;
  color: inherit;
}

.expandable-section__summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--space-2);
  transition: transform var(--motion-fast) var(--motion-easing);
}

.expandable-section[open] .expandable-section__summary::before {
  transform: rotate(90deg);
}

.expandable-section__body {
  margin-top: var(--space-3);
}

/* ---- Dialog/Modal ------------------------------------------------------------ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 1000;
}

.dialog {
  background: var(--surface-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-dialog);
  padding: var(--space-5);
  max-width: 440px;
  width: 100%;
}

.dialog__title {
  margin-bottom: var(--space-2);
}

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

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ---- Info Tooltip -------------------------------------------------------- */
.info-tooltip {
  position: relative;
  display: inline-flex;
}

.info-tooltip__trigger {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: help;
  font-size: var(--text-caption-size);
  line-height: 1;
  padding: 0 var(--space-1);
}

/* [V2.1 feedback] Reported: the Business setup tooltip "goes outside of
   the frame of the screen and cuts off, you cannot read it all."
   Measured before fixing — the bubble rendered at top: -34px, i.e. 34px
   above the top of the window, so its opening sentence was unreadable.

   The cause was here, not in the text: the bubble was pinned upward
   (bottom: 100%) with no awareness of whether there was room. Six of the
   app's tooltips are long enough to hit it, the worst being 826
   characters. tooltip.js now measures on open and sets --tooltip-shift
   (horizontal correction), the `is-below` class (flip when there is no
   room above) and a max-height when neither side has room. The
   declarations below are the defaults it starts from and corrects. */
.info-tooltip__bubble {
  --tooltip-shift: 0px;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(calc(-50% + var(--tooltip-shift)));
  margin-bottom: var(--space-1);
  background: var(--accent-navy);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-control);
  width: max-content;
  max-width: 240px;
  z-index: 50;
  overscroll-behavior: contain;
}

/* Flipped to sit below the trigger, when there is not enough room above. */
.info-tooltip__bubble.is-below {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: var(--space-1);
}

/* Last resort: taller than the room on either side, so it scrolls rather
   than spilling off-screen. tooltip.js sets the height itself. */
.info-tooltip__bubble.is-scrollable {
  overflow-y: auto;
}

/* ---- Progress Ring ------------------------------------------------------- */
.progress-ring {
  --progress-percent: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-2);
  background: conic-gradient(
    var(--accent-teal) calc(var(--progress-percent) * 1%),
    var(--border-hairline) 0
  );
}

.progress-ring::before {
  content: "";
  position: absolute;
}

.progress-ring--empty {
  background: var(--border-hairline);
  color: var(--text-secondary);
}

.progress-ring--attention {
  background: conic-gradient(
    var(--accent-coral) calc(var(--progress-percent) * 1%),
    var(--border-hairline) 0
  );
}

.progress-ring--caution {
  background: conic-gradient(
    var(--accent-gold) calc(var(--progress-percent) * 1%),
    var(--border-hairline) 0
  );
}

.progress-ring__value {
  background: var(--surface-card);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Chart Card ------------------------------------------------------------ */
.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-card__legend {
  display: flex;
  gap: var(--space-3);
}

.chart-card__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.chart-card__legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.chart-card__area {
  margin-top: var(--space-3);
  min-height: 140px;
  border: 1px dashed var(--border-hairline);
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3);
}

/* ---- Icons (components/icons.js) ------------------------------------------ */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.icon svg {
  width: 100%;
  height: 100%;
}


/* ---- [Stage 6b] Sidebar: one section per product -------------------------
   The sidebar used to be a flat list of groups, because there was only ever
   one product, and .app-nav's own gap separated them. Groups now sit INSIDE a
   product section, so that gap no longer reaches them and the spacing is
   restored here instead. */
.nav-product {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* The product name. Louder than a group heading because it names the thing
   the customer bought, and it is what a second product will sit beside. */
.nav-product__heading {
  color: #fff;
  padding: 0 var(--space-2) var(--space-2);
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

/* Group headings inside a product are deliberately quieter than the product
   name above them — three levels of shouting would flatten the hierarchy the
   nesting exists to create. */
/* 0.58, not lower. Group headings must stay quieter than the product name
   above them, but 0.45 measured 4.1:1 against the navy sidebar and WCAG AA
   wants 4.5:1 for 12px text — caught by the axe scan on all 30 routes. 0.58
   gives 5.85:1, still visibly secondary. */
.nav-product .nav-cluster__heading {
  color: rgba(255, 255, 255, 0.58);
  text-transform: none;
  letter-spacing: 0.01em;
}

.nav-cluster--product-home {
  padding-bottom: var(--space-1);
}

/* A product the customer has not bought. Present, legible, not competing with
   what they actually own. */
.nav-product--available .nav-product__heading {
  color: rgba(255, 255, 255, 0.62);
  font-weight: 500;
}

.nav-product--available {
  gap: var(--space-1);
}

.nav-link--promo {
  color: var(--accent-teal);
}

.nav-link--promo:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-teal);
}

/* Same reason: 0.42 measured 3.74:1 at 11px. 0.60 gives 6.14:1. */
.nav-product__blurb {
  padding: 0 var(--space-2);
  margin: 0;
  color: rgba(255, 255, 255, 0.60);
  line-height: 1.45;
}

/* Account closes the sidebar, separated from the products above it. */
.nav-cluster--account {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

/* ---- [v2.2] "About this copy" rows in Settings ---------------------------
   Label and value on one line, so a person can read their release code out
   loud to support without hunting for it. */
.about-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.about-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  justify-content: space-between;
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: var(--space-2);
}

.about-row__value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
}

/* ---- Restoring from the folder, on Settings ------------- [9 Sep 2026]
   Core's chrome again: the picker is Core's and both products embed it, so a
   package containing either one must carry the styles. */
.folder-restore {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.folder-restore .settings-save-row {
  margin-top: var(--space-2);
}

/* ---- Backups are paused, above every screen ------------- [9 Sep 2026]
   Gold, not coral. Nothing is broken and nothing is lost — copies have stopped,
   which is worth acting on and is not an emergency. Coral is reserved for
   things that are actually wrong, or it stops meaning anything. */
.backup-paused-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--accent-gold);
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-card);
  background: var(--surface-card);
}

.backup-paused-banner__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.backup-paused-banner__text {
  flex: 1 1 320px;
}

/* ---- Records with nothing protecting them --------------- [9 Sep 2026]
   Three tones, and the quiet one is the point. The first-run ask is an
   invitation, not an alarm: somebody's introduction to the product should not
   be a red box. Gold and coral are kept for the two states where something is
   genuinely wrong, so that when one appears it still means something.

   Shares the paused banner's shape deliberately — same slot, same proportions,
   same place on the screen — so the two never read as different kinds of thing.
   See qa/cssOwnershipTest.mjs: Core's chrome is styled from Core, because every
   package shows this. */
.records-at-risk {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-hairline);
  border-left: 4px solid var(--accent-teal);
  border-radius: var(--radius-card);
  background: var(--surface-card);
}

.records-at-risk--caution {
  border-color: var(--accent-gold);
  border-left-color: var(--accent-gold);
}

.records-at-risk--attention {
  border-color: var(--accent-coral);
  border-left-color: var(--accent-coral);
}

.records-at-risk__title {
  font-weight: 600;
  margin-bottom: 2px;
}

.records-at-risk__text {
  flex: 1 1 320px;
}

/* Wraps onto its own line on a narrow screen rather than squeezing three
   buttons into a column the width of a word. */
.records-at-risk__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* AFTER "NOT NOW": ONE LINE, NOT GONE. [13 September 2026] The same slot, tone
   and border, so it still reads as the same message, at about a third of the
   height; two short lines on a phone rather than a third of the first screen.
   Why it shrinks instead of disappearing: core/ui/recordsAtRiskBanner.js,
   bannerForm. */
.records-at-risk--compact {
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

.records-at-risk--compact .records-at-risk__title {
  flex: 1 1 16rem;
  margin: 0;
}

.records-at-risk--compact .button {
  padding: var(--space-1) var(--space-2);
}

/* ---- A copy outside this browser, on Settings ----------- [9 Sep 2026]
   Core's chrome, styled from Core: every package shows this card, including
   ones that contain no product declaring a backup. See qa/cssOwnershipTest.mjs. */
.backup-folder {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.backup-folder .settings-save-row {
  margin-top: var(--space-2);
}

/* ---- Also from Atlas Foundry, on Settings --------------- [C-11, 9 Sep 2026]
   Core's chrome, styled from Core: an SBM-only or tracker-only package must not
   ship this unstyled. See qa/cssOwnershipTest.mjs. Deliberately quieter than
   the sidebar's promo — Settings is a reference screen a customer opened on
   purpose, not a place to sell at them. */
.settings-available__heading {
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
}

.settings-available {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-hairline);
}

.settings-available__name {
  font-weight: 500;
}

.settings-available__blurb {
  margin: 0;
}

.settings-available__link {
  align-self: flex-start;
  margin-top: var(--space-1);
  /* NOT --accent-teal: the base teal as text on a light card measures about
     2.5:1 and axe-core failed it on this very element. --accent-teal-text is
     the darkened value proven for light surfaces, and themes.css reverts it to
     the brighter base in dark mode, where the darkened one would under-contrast
     instead. Both notes are already in core.css and themes.css. */
  color: var(--accent-teal-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---- Making Tax Digital Checker ------------------------ [Core extraction] Moved here with the screen: Core owns it so it reaches an SBM-only customer. */
.mtd-screen {
  max-width: var(--content-max-width);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.mtd-limitation-card {
  border-color: var(--accent-gold);
  background: rgba(232, 184, 75, 0.06);
}

/* The caption on this card is the legal caveat — the sentence most worth
   reading on the screen — and secondary grey over the gold tint measured 4.4:1
   against the 4.5:1 minimum. It missed by a tenth, which is exactly the kind of
   thing an eye does not catch and axe does. Primary text colour, so it holds in
   both themes rather than being tuned to one composite background. */
.mtd-limitation-card .text-caption {
  color: var(--text-primary);
}

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

.mtd-result-card h2 {
  display: inline;
  margin-right: var(--space-2);
}

.mtd-tier-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-hairline);
}

.mtd-tier-row:last-child {
  border-bottom: none;
}


/* ---- Where a shared value came from ---------------------------------------
   Shown under a field on My Profile when a value arrived from another Atlas
   Foundry product. A transferred figure must never look like something the
   customer typed. */
.shared-fact__source {
  margin-top: calc(var(--space-1) * -1);
  color: var(--text-secondary);
}

/* ---- Windowed list --------------------------------------------------------
   A long list that renders one page at a time, with the total stated so a
   customer is never left wondering where the rest of their records went. */
.windowed-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.windowed-list__status {
  color: var(--text-secondary);
}

.windowed-list__pager {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ---- Storage usage --------------------------------------------------------
   Sits at the foot of the sidebar. Every Atlas Foundry product opened from disk
   shares one allowance, so this reports the whole bucket rather than one
   product's share — and stays hidden until it is worth knowing. */
.nav-storage:empty {
  display: none;
}

.nav-storage {
  margin-top: auto;
  padding: var(--space-3) var(--space-4) var(--space-2);
}

.nav-storage__line {
  color: var(--text-on-dark-secondary, var(--text-secondary));
  margin: 0;
}

.nav-storage__line--warning {
  color: var(--accent-gold);
}


/* ---- Core shell: main region, footer, overlay layers, placeholder -------- */
/*
 * MOVED HERE FROM products/sa-tax/css/screens.css ON 2 SEPTEMBER 2026, for the
 * same reason as the sidebar rules above, and found by looking for the same
 * mistake once the sidebar one had been fixed.
 *
 * Every element below is rendered by Core for every product — #app-main and the
 * footer by index.html and core/shell.js, the overlay layers by Core's toast and
 * dialog components, the placeholder by core/router.js for a route with no
 * screen yet. Their styling was in the tax calculator's stylesheet, so a package
 * without the calculator shipped the elements with none of it.
 *
 * What that meant in the Small Business Manager package specifically:
 *   - .app-main had no padding, so every screen's content sat flush against the
 *     edge of the window;
 *   - the toast and dialog layers were not positioned, so anything Core put in
 *     them would have appeared inline in the document rather than over it.
 *
 * Neither is caught by an accessibility scan and neither shows up in the
 * calculator, which is why both survived until a second product was packaged.
 */
/* ---- Screen placeholder (used by every route not yet built) -------------- */
.screen-placeholder {
  max-width: var(--content-measure);
}

.screen-placeholder__title {
  margin-top: var(--space-1);
}

.screen-placeholder__purpose {
  margin-top: var(--space-3);
  color: var(--text-secondary);
}

.screen-placeholder__note {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.app-main {
  flex: 1 1 auto;
  padding: var(--space-5);
  outline: none;
}

/* TWO CARDS STRAIGHT INTO THE MAIN REGION MUST NOT TOUCH. [13 September 2026]
   Every screen but one renders a single wrapper that spaces its own cards.
   Quick estimate appends its introduction card and its form card directly
   into #app-main, which has no gap, so the two sat at 0px and read as one
   broken card (calculator UI/UX audit, H1). Zero specificity, and the 24px
   every account screen already puts between its cards. */
:where(.app-main) > * + * {
  margin-top: var(--space-4);
}

/* [Real user request, 17 August 2026] Static disclaimer, identical on
   every screen, sits at the bottom of each page's actual content (see
   the sibling-of-#app-main placement note in index.html), not pinned to
   the viewport. flex: 0 0 auto so it never competes with .app-main
   (flex: 1 1 auto) for the column's available height. */
.app-footer {
  flex: 0 0 auto;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-hairline);
  text-align: center;
}

.app-footer .text-caption {
  color: var(--text-secondary);
  max-width: 720px;
  margin: 0 auto;
}

.app-toast-layer,
.app-dialog-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
}

/* ---- Folding a navigation section away ------------------------------------
 *
 * The heading becomes a button. It keeps the heading's own class as well, so
 * .nav-product__heading and .nav-cluster__heading still style it and the two
 * levels stay visually distinct — the fold is a behaviour added to the
 * hierarchy, not a replacement for it.
 */
.nav-fold {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
}

.nav-fold__label {
  flex: 1 1 auto;
  min-width: 0;
}

/* One glyph, rotated. Pointing right when shut, down when open — the rotation
   is what carries the state, so it reads the same way in every language. */
.nav-fold__chevron {
  flex: 0 0 auto;
  opacity: 0.7;
  transition: transform var(--motion-fast) var(--motion-easing);
}

.nav-fold[aria-expanded="true"] .nav-fold__chevron {
  transform: rotate(90deg);
}

.nav-fold:hover .nav-fold__chevron {
  opacity: 1;
}

/* A visible focus ring on the sidebar's dark ground. The default browser
   outline is dark-on-dark here and effectively invisible. */
.nav-fold:focus-visible {
  outline: 2px solid var(--accent-teal);
  outline-offset: 2px;
  border-radius: var(--radius-control);
}

/* A product heading that is a button must not lose the rule beneath it. */
.nav-product__heading.nav-fold {
  padding: 0 var(--space-2) var(--space-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

/* Folded away. A class rather than [hidden], because updateVisibility() in
   nav.js owns `hidden` for relevance gating and the two must not fight — when
   they did, screens reappeared inside a section the customer had shut. */
.nav-product.is-folded > *:not(.nav-fold) {
  display: none;
}

.nav-cluster.is-folded > .nav-cluster__links {
  display: none;
}

/* ---- When they last took a copy out --------------------------------------
   Beneath the storage line and styled like it: quiet by default, and only
   coloured once it is genuinely worth acting on. */
.nav-backup {
  padding: 0 var(--space-2) var(--space-3);
}

.nav-backup__line {
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

.nav-backup__line--warning {
  color: var(--accent-amber-text, #F0B429);
  font-weight: 500;
}

.nav-backup__detail {
  color: rgba(255, 255, 255, 0.5);
  margin: var(--space-1) 0 0;
  line-height: 1.45;
}


/* ---------------------------------------------------------------------------
   Content links
   ---------------------------------------------------------------------------
   The Updates card carries the first ordinary hyperlink in the product — every
   other "link" on screen is a button styled to look like one. With no rule for
   `a`, it rendered in the browser's default blue, which is the one colour
   nowhere else in the palette.

   `--accent-teal-text` rather than `--accent-teal`: the raw teal was found to
   fail contrast as text in the V18 audit (F-017), and this is body copy.

   The global :focus-visible rule above already gives it a ring, so there is
   nothing to add for the keyboard.
   ------------------------------------------------------------------------- */
.text-link {
  color: var(--accent-teal-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-link:hover {
  text-decoration-thickness: 2px;
}
