/*
 * The stylesheet for the public site, the admin panel, the sign-in and the
 * error pages. One file, no framework, no CDN, no web font: the content
 * security policy is self-only and nothing here makes an external request.
 *
 * The design system is docs/UI-UX-ARCHITECTURE.md. Every colour, size, space,
 * radius and shadow below comes from the tokens in :root. Two of them, --accent
 * and --ink, are also settings: the layout's one nonce-bearing style block
 * redefines them when an operator has chosen other colours.
 *
 * Sections, in order: tokens; base; shared components (buttons, forms, cards,
 * tables, badges, banners, states); the public shell and pages; calculators
 * and results; the admin shell and screens; auth and error pages; utilities;
 * print.
 */

/* =====================================================================
   Tokens
   Light theme only, by decision (see the architecture document).
   ===================================================================== */

:root {
    /* Brand, sampled from the supplied logo and icon */
    --brand-navy: #023672;
    --brand-deep: #022262;
    --brand-blue: #0276ca;
    --brand-sky: #0292fa;

    /* Interface */
    --accent: #0a66bd;
    --accent-hover: #08549c;
    --accent-ink: #ffffff;
    --focus: #0a66bd;

    --ink: #172b4d;
    --ink-soft: #4a5b73;
    --ink-faint: #5b6b82;

    --paper: #ffffff;
    --paper-soft: #f3f7fb;
    --tint: #eaf2fa;
    --line: #d6dfea;
    --line-strong: #b8c6d8;

    --good: #13734b;
    --good-soft: #e7f5ee;
    --good-line: #b3dcc6;
    --warn: #8a5a00;
    --warn-soft: #fff5e0;
    --warn-line: #ecd29a;
    --bad: #b42318;
    --bad-soft: #fdecea;
    --bad-line: #f0bcb6;

    /* Type */
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: 0.8125rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: clamp(1.9rem, 4vw, 2.6rem);
    --leading: 1.6;
    --leading-tight: 1.25;

    /* Space */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;

    /* Shape and depth */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-1: 0 1px 2px rgba(2, 34, 98, 0.06);
    --shadow-2: 0 6px 20px rgba(2, 34, 98, 0.1), 0 1px 3px rgba(2, 34, 98, 0.08);

    /* Layout */
    --container: 76rem;
    --measure: 68ch;
    --reading: 52rem;
    --gutter: clamp(1rem, 4vw, 2rem);
    --control-height: 2.75rem;

    /* Layers */
    --z-header: 20;
    --z-menu: 30;
    --z-consent: 40;
    --z-skip: 100;
}

/* =====================================================================
   Base
   ===================================================================== */

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--paper-soft);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--text-md);
    line-height: var(--leading);
    /* A long unbroken string (a key, a URL, a pasted note) wraps rather than
       widening its column past the screen. */
    overflow-wrap: break-word;
}

/* A visible focus ring everywhere, never removed. */
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* And an unconditional one on the fields you type into.
   :focus-visible is a browser heuristic, and at least one browser declines to
   apply it to a date input focused from the keyboard — which leaves the one
   control that is hardest to operate without sight showing no focus at all. */
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent-hover);
    text-decoration-thickness: 2px;
}

h1, h2, h3, h4 {
    line-height: var(--leading-tight);
    margin: 0 0 0.5em;
    color: var(--ink);
    text-wrap: balance;
}

h1 { font-size: var(--text-2xl); font-weight: 750; letter-spacing: -0.015em; }
h2 { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--text-lg); font-weight: 650; }
h4 { font-size: var(--text-md); font-weight: 650; }

p, ul, ol, dl, table {
    margin: 0 0 var(--space-4);
}

img {
    max-width: 100%;
    height: auto;
}

code, pre, .mono {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* The hidden attribute always wins. Without this, a class that sets display
   (".button { display: inline-flex }") shows an element the markup hides. */
[hidden] { display: none !important; }

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

/* ---------- Skip link ---------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: var(--space-2);
    background: var(--brand-navy);
    color: #ffffff;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    z-index: var(--z-skip);
}

.skip-link:focus {
    left: var(--space-2);
}

/* =====================================================================
   Shared components
   ===================================================================== */

/* ---------- Buttons ---------- */

.button,
button {
    font: inherit;
    font-weight: 600;
    font-size: var(--text-sm);
    line-height: 1.2;
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    padding: 0.7rem 1.1rem;
    min-height: var(--control-height);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button:hover,
button:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-ink);
    text-decoration: none;
}

.button--secondary {
    background: var(--paper);
    color: var(--accent);
    border-color: var(--line-strong);
}

.button--secondary:hover {
    background: var(--tint);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.button--quiet {
    background: transparent;
    border-color: transparent;
    color: var(--ink-soft);
}

.button--quiet:hover {
    background: var(--tint);
    border-color: transparent;
    color: var(--ink);
}

.button--danger {
    background: var(--bad);
    border-color: var(--bad);
    color: #ffffff;
}

.button--danger:hover {
    background: #8f1c13;
    border-color: #8f1c13;
    color: #ffffff;
}

.button--small {
    padding: 0.35rem 0.7rem;
    min-height: 2.25rem;
    font-size: var(--text-xs);
}

.button--large {
    padding: 0.85rem 1.4rem;
    font-size: var(--text-md);
}

button:disabled,
.button[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.55;
}

.actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: center;
    margin-top: var(--space-5);
}

.inline-form {
    display: inline;
}

/* ---------- Forms ---------- */

.field {
    margin-bottom: var(--space-4);
    max-width: 44rem;
}

.field label,
.fieldset legend,
fieldset > legend {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-1);
    color: var(--ink);
}

.field__required {
    font-weight: 400;
    color: var(--ink-faint);
    font-size: var(--text-xs);
}

.field__help {
    display: block;
    color: var(--ink-soft);
    font-size: var(--text-sm);
    margin-bottom: var(--space-2);
    line-height: 1.45;
}

.field__error {
    display: block;
    color: var(--bad);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="date"],
input[type="number"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: var(--control-height);
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
    font: inherit;
    line-height: 1.4;
    transition: border-color 120ms ease;
}

input[type="file"] {
    padding: 0.45rem;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--ink-faint);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
    border-color: var(--bad);
    box-shadow: 0 0 0 1px var(--bad);
}

input[type="checkbox"],
input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
    vertical-align: -0.15em;
}

textarea {
    min-height: 8rem;
    resize: vertical;
}

.field--inline,
.field--check {
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
}

.field--inline label,
.field--check label {
    font-weight: 400;
    margin-bottom: 0;
}

/* A checkbox with help text: the help goes on its own line beneath the label,
   indented to the label's text, rather than squeezed into a second column. */
.field--check {
    flex-wrap: wrap;
}

.field--check > label {
    flex: 1 1 0;
    min-width: 0;
}

.field--check > .field__help {
    flex-basis: 100%;
    margin: var(--space-1) 0 0 1.75rem;
}

/* A fieldset defaults to min-width: min-content, which means it refuses to
   shrink below the widest thing inside it; wrap a table in one and the
   fieldset, not the table, pushes the page sideways on a phone. */
fieldset {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    padding: var(--space-4) var(--space-5) var(--space-2);
    margin: 0 0 var(--space-5);
}

fieldset > legend,
.fieldset legend {
    padding: 0 var(--space-2);
    margin-left: calc(-1 * var(--space-2));
    font-size: var(--text-md);
}

.fieldset {
    margin: 0 0 var(--space-5);
}

.field-row {
    display: grid;
    gap: 0 var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    max-width: 44rem;
}

.field-row--tight {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* Fields side by side share a baseline for their controls, whatever help text
   sits above each one: the field is a column and its control takes the space
   left at the bottom. Without this a select with no help text sat a line or
   two higher than its neighbour. */
.field-row > .field {
    display: flex;
    flex-direction: column;
}

.field-row > .field > :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    margin-top: auto;
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
    font-size: var(--text-sm);
    color: var(--ink-faint);
}

.breadcrumbs ol {
    list-style: none;
    margin: 0 0 var(--space-3);
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
}

.breadcrumbs li + li::before {
    content: "\203A";
    margin-right: var(--space-2);
    color: var(--line-strong);
}

.breadcrumbs a {
    color: var(--ink-soft);
}

.breadcrumbs [aria-current="page"] {
    color: var(--ink-faint);
}

/* ---------- Cards and grids ---------- */

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-1);
}

.card__title {
    margin-top: 0;
    font-size: var(--text-lg);
}

.card__note {
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.grid {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    margin-bottom: var(--space-5);
}

.grid > .card {
    margin-bottom: 0;
}

.grid--halves         { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid--main-and-aside { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > *             { min-width: 0; }

@media (max-width: 60rem) {
    .grid--halves,
    .grid--main-and-aside { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Stat tiles ---------- */

.stat {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-1);
    color: var(--ink);
    text-decoration: none;
    position: relative;
}

a.stat:hover {
    border-color: var(--accent);
    color: var(--ink);
}

.stat__value {
    display: block;
    font-size: 2rem;
    font-weight: 750;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--brand-navy);
}

.stat__label {
    display: block;
    margin-top: var(--space-1);
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.stat--warn { border-color: var(--warn-line); background: var(--warn-soft); }
.stat--warn .stat__value { color: var(--warn); }
.stat--bad  { border-color: var(--bad-line);  background: var(--bad-soft); }
.stat--bad .stat__value { color: var(--bad); }
.stat--good { border-color: var(--good-line); background: var(--good-soft); }
.stat--good .stat__value { color: var(--good); }

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--space-5);
    /* Contains the visually hidden labels inside the table: positioned
       absolutely at a column far to the right, they otherwise escape this
       scroll box and widen the page on a phone. */
    position: relative;
}

.table-wrap > table.data {
    margin: 0;
}

table.data {
    border-collapse: collapse;
    width: 100%;
    background: var(--paper);
    font-size: var(--text-sm);
}

table.data caption:not(.sr-only):not(.visually-hidden) {
    text-align: left;
    font-weight: 600;
    padding: var(--space-3) var(--space-4) 0;
}

table.data th,
table.data td {
    border-bottom: 1px solid var(--line);
    padding: 0.7rem var(--space-4);
    text-align: left;
    vertical-align: top;
}

table.data thead th {
    background: var(--paper-soft);
    font-weight: 650;
    font-size: var(--text-xs);
    letter-spacing: 0.02em;
    color: var(--ink-soft);
    white-space: nowrap;
}

table.data tbody th {
    font-weight: 600;
}

table.data tbody tr:last-child th,
table.data tbody tr:last-child td {
    border-bottom: 0;
}

table.data tbody tr:hover {
    background: var(--paper-soft);
}

table.data td.numeric,
table.data th.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* In the wide rules table the headings wrap, and a row heading always may, so
   one long label cannot set the width of the whole table. */
table.data.rules-table thead th { white-space: normal; min-width: 5rem; }
table.data.rules-table tbody th { min-width: 8rem; }

/* The rules table uses the width of the window on a desktop. */
@media (min-width: 60rem) {
    .site-main:not(.site-main--wide) .table-wrap--wide {
        width: min(100vw - 2rem, 80rem);
        max-width: none;
        margin-left: calc(50% - min(50vw - 1rem, 40rem));
    }
}

/* On a wide screen, wider than the page column too: twelve columns read
   better side by side than scrolled. */
@media (min-width: 80rem) {
    .site-main--wide .table-wrap--wide {
        width: min(100vw - 4rem, 100rem);
        max-width: none;
        margin-left: calc(50% - min(50vw - 2rem, 50rem));
    }
}

/* On a phone each rule is a card: the transaction as its heading, then each
   column as a labelled line. Nothing to scroll sideways to read. */
@media (max-width: 40rem) {
    .rules-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .table-wrap:has(.rules-table) {
        border: 0;
        background: transparent;
    }

    .rules-table,
    .rules-table tbody,
    .rules-table tr,
    .rules-table th,
    .rules-table td {
        display: block;
        width: auto;
        min-width: 0;
    }

    .rules-table tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        margin-bottom: var(--space-3);
        background: var(--paper);
    }

    .rules-table tbody th { border-bottom: 1px solid var(--line); }
    .rules-table td { border-bottom: 0; padding: var(--space-1) var(--space-4); }

    .rules-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: var(--text-xs);
        font-weight: 600;
        color: var(--ink-soft);
    }

    table.data.rules-table tbody tr:last-child td { border-bottom: 0; }
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    border-radius: var(--radius-pill);
    padding: 0.12rem 0.6rem;
    font-size: var(--text-xs);
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge--draft     { background: #edf0f4; color: #3f4b5c; border-color: #d3dae3; }
.badge--testing   { background: var(--tint); color: var(--brand-navy); border-color: #c2d6ee; }
.badge--review    { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge--published { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.badge--archived  { background: #f1eff4; color: #554e60; border-color: #dad4e0; }
.badge--danger    { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.badge--muted     { background: var(--paper-soft); color: var(--ink-faint); border-color: var(--line); }

/* ---------- Banners ---------- */

.banner {
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    background: var(--paper);
}

.banner--success { border-color: var(--good-line); border-left-color: var(--good); background: var(--good-soft); }
.banner--error   { border-color: var(--bad-line);  border-left-color: var(--bad);  background: var(--bad-soft); }
.banner--notice  { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-soft); }
.banner--info    { border-color: #c2d6ee; border-left-color: var(--accent); background: var(--tint); }

.banner p:last-child { margin-bottom: 0; }
.banner__title { font-size: 1rem; margin: 0 0 var(--space-2); }
.banner input[readonly] { width: 100%; }

/* A list of one-button forms, each with its explanation (user access actions). */
.action-list { display: grid; gap: var(--space-3); }
form + .card--actions,
.table-wrap + .card--actions { margin-top: var(--space-6); }
.card--alert { border-color: var(--danger); border-left-width: 4px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.action-list__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--line);
}
.action-list__item:first-child { border-top: 0; padding-top: 0; }
.action-list__item > div { flex: 1 1 18rem; min-width: 0; }
.action-list__item .field__help { margin: var(--space-1) 0 0; }

.page-notice {
    background: var(--tint);
    border: 1px solid #c2d6ee;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    max-width: var(--measure);
}

/* ---------- Empty states ---------- */

.empty {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    padding: var(--space-6) var(--space-5);
    text-align: center;
    color: var(--ink-soft);
    background: var(--paper);
}

.empty h2,
.empty h3 {
    margin-top: 0;
    font-size: var(--text-lg);
    font-weight: 650;
    color: var(--ink);
}

.empty p {
    margin-left: auto;
    margin-right: auto;
    max-width: 52ch;
}

/* ---------- Definition lists ---------- */

dl.detail {
    display: grid;
    grid-template-columns: minmax(10rem, 16rem) 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

dl.detail dt {
    font-weight: 600;
    color: var(--ink-soft);
}

dl.detail dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 40rem) {
    dl.detail { grid-template-columns: 1fr; gap: 0 0; }
    dl.detail dd { margin-bottom: var(--space-2); }
}

.run-log { margin-top: var(--space-1); }
.run-log ol { margin: var(--space-1) 0 0; padding-left: 1.25rem; }

/* ---------- Checklists ---------- */

/* Sub-navigation between related admin pages (Updates: overview, keys, releases). */
.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    border-bottom: 1px solid var(--line);
    margin: 0 0 var(--space-5);
}

.subnav__link {
    padding: var(--space-2) var(--space-3);
    color: var(--ink-soft);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    font-weight: 600;
}

.subnav__link:hover { color: var(--ink); }
.subnav__link[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* A value shown once for copying (a new token, a public key). */
.secret-once {
    display: block;
    padding: var(--space-3);
    background: var(--paper-soft);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
    user-select: all;
}

.checklist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.checklist li {
    border-bottom: 1px solid var(--line);
    padding: var(--space-3) 0;
}

.checklist li:last-child { border-bottom: 0; }

.checklist__mark {
    font-weight: 700;
    margin-right: var(--space-2);
}

.checklist__mark--pass { color: var(--good); }
.checklist__mark--fail { color: var(--bad); }
.checklist__mark--skip { color: var(--warn); }
.checklist__mark--off  { color: var(--ink-faint); }

.checklist__detail {
    display: block;
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.checklist__remedy {
    display: block;
    color: var(--bad);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
}

/* ---------- Filters and pagination ---------- */

.filters,
.table-filters fieldset {
    display: flex;
    gap: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.filters .field,
.table-filters .field {
    margin-bottom: 0;
    max-width: 15rem;
    flex: 1 1 12rem;
}

/* In a filter bar the label sits above its control, so every control in the
   row lines up whatever the length of its label. */
.filters .field--inline,
.table-filters .field--inline {
    display: grid;
    gap: var(--space-1);
    align-items: stretch;
}

.filters .field--inline label,
.table-filters .field--inline label {
    font-weight: 600;
    font-size: var(--text-sm);
}

.pagination {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
    margin-top: var(--space-4);
    font-size: var(--text-sm);
}

/* ---------- Trace ---------- */

.trace { font-size: var(--text-sm); }
.trace__row--selected { background: var(--good-soft); font-weight: 600; }

/* =====================================================================
   Public shell
   ===================================================================== */

.site-header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: var(--z-header);
}

.site-header__inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-3) var(--gutter);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    min-height: 4.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
    color: var(--brand-navy);
    margin-right: auto;
    border-radius: var(--radius-sm);
}

.brand__image {
    display: block;
    height: 40px;
    width: auto;
}

/* On a desktop the wordmark is drawn larger, so its lettering stays legible on
   a standard-density screen. Height only: the width follows its proportions. */
@media (min-width: 60rem) {
    .site-header .brand__image--logo {
        height: 48px;
    }
}

.brand__text {
    font-size: var(--text-lg);
    font-weight: 750;
    letter-spacing: -0.01em;
}

/* The phone menu button. Shown only when the script is running; without it
   the navigation is always visible. */
.nav-toggle {
    background: var(--paper);
    color: var(--brand-navy);
    border-color: var(--line-strong);
}

.nav-toggle:hover {
    background: var(--tint);
    color: var(--brand-navy);
    border-color: var(--accent);
}

.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
}

.nav-toggle__icon::before,
.nav-toggle__icon::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle__icon::before { top: -6px; }
.nav-toggle__icon::after  { top: 6px; }

.site-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-weight: 600;
    font-size: var(--text-sm);
    text-decoration: none;
    cursor: pointer;
}

.site-nav__link:hover {
    background: var(--tint);
    color: var(--brand-navy);
}

.site-nav__link[aria-current="page"],
.site-nav__link.is-current {
    color: var(--brand-navy);
    box-shadow: inset 0 -3px 0 var(--brand-blue);
}

/* The guides menu: a native disclosure, so it works by keyboard and without
   a script. */
.nav-menu {
    position: relative;
}

.nav-menu > summary {
    list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
    display: none;
}

.nav-menu > summary::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    margin-left: var(--space-2);
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.nav-menu[open] > summary::after {
    transform: translateY(2px) rotate(-135deg);
}

.nav-menu__list {
    list-style: none;
    margin: 0;
    padding: var(--space-2);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    min-width: 16rem;
}

.nav-menu__list a {
    display: block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-size: var(--text-sm);
}

.nav-menu__list a:hover {
    background: var(--tint);
    color: var(--brand-navy);
}

.nav-menu__list a[aria-current="page"] {
    font-weight: 650;
    color: var(--brand-navy);
}

@media (min-width: 60rem) {
    .nav-toggle {
        display: none !important;
    }

    .nav-menu__list {
        position: absolute;
        right: 0;
        top: calc(100% + var(--space-2));
        z-index: var(--z-menu);
    }
}

/* The narrowest phones: a smaller logo and a tighter button keep the two on
   one line. The logo is scaled by height, so its proportions hold. */
@media (max-width: 23rem) {
    .site-header__inner {
        gap: var(--space-2);
    }

    .site-header .brand__image--logo {
        height: 30px;
    }

    .nav-toggle {
        padding-inline: var(--space-3);
    }
}

@media (max-width: 59.99rem) {
    .site-nav {
        flex-basis: 100%;
    }

    .site-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        border-top: 1px solid var(--line);
        padding-top: var(--space-2);
    }

    .site-nav__link {
        width: 100%;
        padding: 0 var(--space-2);
    }

    .site-nav__link[aria-current="page"],
    .site-nav__link.is-current {
        box-shadow: inset 3px 0 0 var(--brand-blue);
    }

    .nav-menu__list {
        box-shadow: none;
        border: 0;
        padding: 0 0 var(--space-2) var(--space-4);
    }

    /* With the script running, the menu starts collapsed. */
    .js .site-nav:not(.is-open) {
        display: none;
    }

    .brand__image {
        height: 34px;
    }
}

/* ---------- Main ---------- */

.site-main {
    max-width: var(--reading);
    margin: 0 auto;
    padding: var(--space-6) var(--gutter) var(--space-8);
}

.site-main--wide {
    max-width: var(--container);
}

.site-main > h1 {
    margin-top: var(--space-2);
}

.lede {
    font-size: var(--text-lg);
    color: var(--ink-soft);
    max-width: var(--measure);
    line-height: 1.55;
}

.eyebrow {
    margin: 0 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    /* The darker accent: small bold text in brand blue on the tinted hero
       background measures 4.4:1, under the 4.5:1 WCAG AA asks of it. */
    color: var(--accent);
}

/* Reading text, wherever it appears. */
.prose {
    max-width: var(--measure);
}

.prose figure {
    margin: var(--space-5) 0;
}

.prose figure img,
.prose > img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.prose figcaption {
    margin-top: var(--space-2);
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.prose blockquote {
    margin: var(--space-5) 0;
    padding: var(--space-2) var(--space-4);
    border-left: 4px solid var(--line-strong);
    color: var(--ink-soft);
}

.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.prose li { margin-bottom: var(--space-2); }

.prose table {
    border-collapse: collapse;
    width: 100%;
    font-size: var(--text-sm);
    background: var(--paper);
}

.prose th,
.prose td {
    border: 1px solid var(--line);
    padding: var(--space-2) var(--space-3);
    text-align: left;
    vertical-align: top;
}

.prose th { background: var(--paper-soft); }

.prose blockquote {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid var(--brand-blue);
    background: var(--tint);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.pillar,
.content-page,
.guide {
    margin-top: var(--space-7);
}

.site-main > .content-page,
.site-main > .guide {
    margin-top: 0;
}

/* ---------- Footer ---------- */

.site-footer {
    background: var(--brand-deep);
    color: #c5d4e8;
    font-size: var(--text-sm);
}

.site-footer__inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-7) var(--gutter) var(--space-6);
    display: grid;
    gap: var(--space-6);
}

.site-footer a {
    color: #ffffff;
    text-decoration-color: rgba(255, 255, 255, 0.45);
}

.site-footer a:hover {
    color: #ffffff;
    text-decoration-color: #ffffff;
}

.site-footer :focus-visible {
    outline-color: #8fc9ff;
}

.brand--footer {
    color: #ffffff;
    margin-right: 0;
}

.brand--footer .brand__image {
    height: 40px;
    border-radius: var(--radius-sm);
}

.brand__name {
    font-weight: 700;
    font-size: var(--text-md);
    color: #ffffff;
}

.site-footer__tagline {
    margin: var(--space-2) 0 0;
    color: #c5d4e8;
}

.site-footer__nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
    gap: var(--space-5) var(--space-6);
}

.site-footer__nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--space-2);
}

.site-footer__heading {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9fc2ee;
    margin: 0 0 var(--space-3);
}

.disclaimer {
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding-top: var(--space-5);
    max-width: 90ch;
}

.disclaimer p {
    margin-bottom: var(--space-3);
}

/* ---------- Consent banner and ad slots (only when the owner enables them) ---------- */

.consent {
    position: fixed;
    inset: auto 0 0 0;
    z-index: var(--z-consent);
    background: var(--paper);
    border-top: 2px solid var(--brand-navy);
    box-shadow: 0 -6px 24px rgba(10, 30, 60, 0.12);
    padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

.consent__inner { max-width: var(--container); margin: 0 auto; display: grid; gap: var(--space-3); }
.consent__inner p { margin: 0; max-width: var(--measure); }
.consent .actions { margin: 0; }

.link-button {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.ad-slot {
    max-width: var(--container);
    margin: var(--space-6) auto;
    padding: var(--space-2) var(--space-3) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper-soft);
    min-width: 0;
}

.ad-slot__label {
    margin: 0 0 var(--space-2);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.adsbygoogle { display: block; }

/* The admin's emergency stop: one row, explanation and button. */
.emergency { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-5); }
.emergency > div { flex: 1 1 20rem; min-width: 0; }

/* Side rails: fixed beside the content, on screens wide enough that they
   cannot touch it. site.js also measures and hides a rail that would. */
.ad-rail {
    position: fixed;
    top: 8rem;
    width: 160px;
    margin: 0;
    z-index: 1;
}

.ad-rail .adsbygoogle { width: 160px; min-height: 600px; }
.ad-rail--left { left: max(var(--space-4), calc((100vw - var(--container)) / 2 - 160px - 3.5rem)); }
.ad-rail--right { right: max(var(--space-4), calc((100vw - var(--container)) / 2 - 160px - 3.5rem)); }

@media print {
    .consent, .ad-slot { display: none !important; }
}

.site-footer__legal {
    margin: 0;
    color: #9fc2ee;
}

/* =====================================================================
   Public pages
   ===================================================================== */

/* ---------- Homepage ---------- */

.hero {
    display: grid;
    gap: var(--space-6);
    align-items: start;
    padding: var(--space-6);
    margin: 0 0 var(--space-7);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
}

@media (min-width: 60rem) {
    .hero {
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
        padding: var(--space-7);
    }
}

/* On a phone the hero drops its frame, so the quick start (which keeps
   its own) arrives sooner. */
@media (max-width: 40rem) {
    .hero {
        padding: 0;
        gap: var(--space-5);
        background: none;
        border: 0;
        box-shadow: none;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero .lede {
        font-size: var(--text-md);
    }

    .hero__points {
        margin-top: var(--space-4);
        font-size: var(--text-sm);
    }

    .quick-start {
        background: var(--paper);
        box-shadow: var(--shadow-1);
        padding: var(--space-5) var(--space-4);
    }
}

.hero h1 {
    font-size: var(--text-3xl);
    letter-spacing: -0.025em;
    color: var(--brand-navy);
    margin-bottom: var(--space-4);
}

.hero__points {
    list-style: none;
    padding: 0;
    margin: var(--space-5) 0 0;
    display: grid;
    gap: var(--space-2);
}

.hero__points li {
    position: relative;
    padding-left: 1.75rem;
    color: var(--ink);
}

.hero__points li::before {
    content: "";
    position: absolute;
    left: 0.15rem;
    top: 0.3rem;
    width: 0.55rem;
    height: 0.9rem;
    border-right: 2.5px solid var(--good);
    border-bottom: 2.5px solid var(--good);
    transform: rotate(40deg);
}

.quick-start {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-5);
}

.quick-start__heading {
    font-size: var(--text-lg);
    margin-bottom: var(--space-4);
}

.quick-start .field,
.quick-start .field-row {
    max-width: none;
}

.quick-start button {
    width: 100%;
    margin-top: var(--space-2);
}

.quick-start__note {
    margin: var(--space-3) 0 0;
    color: var(--ink-soft);
}

.home-section {
    margin: 0 0 var(--space-8);
}

.home-section--tinted {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
}

@media (max-width: 40rem) {
    .home-section--tinted {
        padding: var(--space-5) var(--space-4);
    }
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2) var(--space-5);
    margin-bottom: var(--space-5);
}

.section-head h2 {
    margin: 0;
    font-size: var(--text-xl);
}

.section-head__text {
    margin: 0;
    color: var(--ink-soft);
}

.card-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr));
}

.card-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
}

.tool-card,
.guide-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5) var(--space-5);
    position: relative;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.tool-card:hover,
.guide-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-2);
}

/* The whole card is the link's target; the link itself stays the name. */
.tool-card__link::after,
.guide-card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
}

.tool-card__link,
.guide-card__link {
    display: grid;
    gap: var(--space-1);
    text-decoration: none;
    color: var(--brand-navy);
}

/* The focus ring stays on the link itself (the global ring), so it is on the
   element that has focus; the card's border also marks which card it is. */
.tool-card:focus-within,
.guide-card:focus-within {
    border-color: var(--accent);
}

.tool-card__name,
.guide-card__link {
    font-weight: 700;
    font-size: var(--text-md);
}

.tool-card__when {
    font-size: var(--text-xs);
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent); /* small text: the AA-passing blue, as .eyebrow */
}

.tool-card__text,
.guide-card__text {
    margin: var(--space-2) 0 0;
    font-size: var(--text-sm);
    color: var(--ink-soft);
}

.steps {
    list-style: none;
    margin: 0 0 var(--space-5);
    padding: 0;
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr));
    counter-reset: step;
}

.steps__item {
    counter-increment: step;
    position: relative;
    padding-left: 3rem;
}

.steps__item::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--radius-pill);
    background: var(--tint);
    color: var(--brand-navy);
    font-weight: 750;
    display: grid;
    place-items: center;
}

.steps__title {
    font-size: var(--text-md);
    margin: 0.3rem 0 var(--space-1);
}

.steps__item p {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.trust {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    border-top: 1px solid var(--line);
    padding-top: var(--space-4);
}

.trust .review-date {
    margin: 0;
}

.trust__links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    font-size: var(--text-sm);
    font-weight: 600;
}

.qa-list {
    margin: 0;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr));
}

.qa-list__item {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
}

.qa-list dt {
    font-weight: 700;
    color: var(--brand-navy);
    margin-bottom: var(--space-2);
}

.qa-list dd {
    margin: 0;
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.home-about .prose {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-5) var(--space-6);
    max-width: none;
}

.home-about .prose > :first-child {
    margin-top: 0;
}

.home-about .prose h2 {
    font-size: var(--text-lg);
    margin-top: var(--space-5);
}

/* ---------- Hubs and lists ---------- */

.tool-list ul,
ul.tool-list {
    list-style: none;
    padding: 0;
    margin: var(--space-5) 0;
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr));
}

.tool-list__item {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
}

.tool-list__item h2 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-2);
}

.tool-list__item h2 a {
    text-decoration: none;
    color: var(--brand-navy);
}

.tool-list__item h2 a:hover {
    text-decoration: underline;
}

.tool-list__item p {
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    color: var(--ink-soft);
}

.tool-list__item p:last-child { margin-bottom: 0; }

.tool-list__when {
    color: var(--ink) !important;
}

.guide-list {
    list-style: none;
    padding: 0;
    margin: var(--space-5) 0;
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fill, minmax(min(18rem, 100%), 1fr));
}

.guide-list__item {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
}

.guide-list__title {
    font-size: var(--text-md);
    margin: 0 0 var(--space-1);
}

.guide-list__title a {
    color: var(--brand-navy);
    text-decoration: none;
}

.guide-list__title a:hover {
    text-decoration: underline;
}

.guide-list__summary {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--ink-soft);
}

/* ---------- Related links, tool switcher, FAQs ---------- */

.tool-switcher {
    margin: var(--space-7) 0 0;
}

.tool-switcher__heading,
.related h2 {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    margin-bottom: var(--space-3);
}

.tool-switcher ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: var(--space-2);
    grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
}

.tool-switcher a {
    display: grid;
    gap: 0.1rem;
    padding: var(--space-3) var(--space-4);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    text-decoration: none;
    height: 100%;
}

.tool-switcher a:hover {
    border-color: var(--accent);
}

.tool-switcher__name {
    font-weight: 650;
    color: var(--brand-navy);
}

.tool-switcher__short {
    font-size: var(--text-xs);
    color: var(--ink-soft);
}

.related {
    border-top: 1px solid var(--line);
    margin-top: var(--space-6);
    padding-top: var(--space-4);
}

.related ul {
    padding-left: 1.1rem;
}

.faq-list,
.faqs {
    margin-top: var(--space-7);
    max-width: var(--measure);
}

.faq-list dl {
    margin: 0;
    border-top: 1px solid var(--line);
}

.faq-list__question {
    font-weight: 700;
    color: var(--brand-navy);
    padding-top: var(--space-4);
}

.faq-list__answer {
    margin: var(--space-2) 0 0;
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--line);
}

.calculator__links {
    margin-top: var(--space-7);
    padding: var(--space-4) var(--space-5);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    max-width: var(--measure);
}

.calculator__links h2 {
    font-size: var(--text-md);
}

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

/* ---------- Bylines, review dates, sources ---------- */

.byline {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: var(--text-sm);
    max-width: var(--measure);
}

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

.byline__reduced {
    background: var(--warn-soft);
    border: 1px solid var(--warn-line);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    color: var(--ink);
}

.review-date {
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.source-block {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
}

.source-block h4 {
    margin: 0 0 var(--space-2);
    font-size: var(--text-md);
    color: var(--brand-navy);
}

/* The source record: label and value side by side, stacked on a phone. */
.source {
    display: grid;
    grid-template-columns: minmax(7rem, max-content) 1fr;
    gap: var(--space-1) var(--space-4);
    margin: 0;
}

.source dt { font-weight: 600; color: var(--ink-soft); }
.source dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 40rem) {
    .source { grid-template-columns: 1fr; gap: 0; }
    .source dd { margin-bottom: var(--space-2); }
}

.table-header {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    max-width: var(--measure);
}

.table-header p { margin: 0; }

.method-pages {
    margin-top: var(--space-6);
}

/* ---------- The public change log ---------- */

.change-log {
    list-style: none;
    padding: 0;
    margin: var(--space-5) 0 0;
    display: grid;
    gap: var(--space-3);
}

.change-log__entry {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
}

.change-log__title {
    font-size: var(--text-md);
    margin: 0 0 var(--space-1);
}

/* Visible for everyone rather than revealed on hover. */
.change-log__permalink {
    text-decoration: none;
    margin-left: var(--space-2);
    color: var(--ink-soft);
}

.change-log__dates {
    margin: 0 0 var(--space-3);
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.change-log__values {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-1) var(--space-4);
    margin: 0 0 var(--space-3);
}

.change-log__values dt {
    color: var(--ink-soft);
    font-size: var(--text-sm);
}

.change-log__values dd {
    margin: 0;
}

.change-log__note {
    margin: 0 0 var(--space-3);
}

/* ---------- The merchant-class helper ---------- */

.class-helper {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    margin: var(--space-6) 0;
    background: var(--paper);
    max-width: var(--measure);
}

.class-helper__heading {
    font-size: var(--text-md);
    margin-top: 0;
}

.class-helper__question {
    border: 0;
    padding: 0;
    margin: 0 0 var(--space-3);
    background: transparent;
}

.class-helper__question legend {
    padding: 0;
    margin: 0 0 var(--space-2);
}

.class-helper__options {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.class-helper__suggestion:empty {
    display: none;
}

.class-helper__caveat {
    margin-bottom: 0;
    color: var(--ink-soft);
}

/* =====================================================================
   Calculators and results
   ===================================================================== */

.calculator {
    margin: var(--space-5) 0 var(--space-6);
}

/* One transaction: the form beside its result on a wide screen. The order in
   the document — summary, form, result — is the order on a phone and for a
   screen reader; the grid only places them. */
@media (min-width: 60rem) {
    .calculator--single {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
        grid-template-areas:
            "outcome outcome"
            "form result";
        gap: var(--space-5) var(--space-6);
        align-items: start;
    }

    .calculator--single > .outcome { grid-area: outcome; margin: 0; }
    .calculator--single > .calculator__form { grid-area: form; }

    .calculator--single > .calculator__result {
        grid-area: result;
        margin-top: 0;
        position: sticky;
        top: var(--space-4);
    }
}

.calculator__form {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-2);
}

.calculator__form fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 var(--space-4);
    background: transparent;
}

.calculator__form fieldset > legend {
    font-size: var(--text-lg);
    margin: 0 0 var(--space-4);
    padding: 0;
}

.calculator__form .field {
    max-width: none;
}

.calculator__form .actions {
    margin-top: var(--space-4);
}

.calculator__privacy {
    font-size: var(--text-xs);
    color: var(--ink-soft);
    margin: var(--space-3) 0 0;
}

@media (max-width: 40rem) {
    .calculator__form {
        padding: var(--space-4);
        border-radius: var(--radius);
    }
}

.calculator__prompt {
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-5);
    text-align: center;
    margin: 0;
}

.calculator__result {
    margin-top: var(--space-5);
}

.calculator__result:focus {
    outline: none;
}

/* What happened when a form was sent: an error summary or a short result, at
   the top of the calculator, where a submission lands. */
.outcome {
    border: 1px solid var(--good-line);
    border-left: 4px solid var(--good);
    border-radius: var(--radius);
    background: var(--good-soft);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.outcome--error {
    border-color: var(--bad-line);
    border-left-color: var(--bad);
    background: var(--bad-soft);
}

.outcome:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.outcome__heading { font-size: var(--text-md); margin: 0 0 var(--space-1); }
.outcome__headline { font-weight: 600; margin-bottom: var(--space-2); }
.outcome__list { margin: var(--space-2) 0 0; padding-left: 1.25rem; }
.outcome__list a { color: var(--bad); font-weight: 600; }

.outcome__figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr));
    gap: var(--space-2) var(--space-4);
    margin: var(--space-2) 0;
}

.outcome__figures dt { font-size: var(--text-xs); color: var(--ink-soft); }
.outcome__figures dd { margin: 0; font-size: var(--text-lg); font-weight: 750; overflow-wrap: break-word; font-variant-numeric: tabular-nums; }
.outcome p:last-child { margin-bottom: 0; }

.result {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-1);
}

.result h3 {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    margin: var(--space-5) 0 var(--space-2);
}

/* Each state is stated in words in the heading; the stripe only repeats it. */
.result__status {
    border-left: 4px solid var(--line-strong);
    padding: var(--space-1) 0 var(--space-1) var(--space-4);
}

.result__status--figure { border-left-color: var(--good); }
.result__status--unknown_rate,
.result__status--external,
.result__status--no_match,
.result__status--no_rules_published { border-left-color: var(--warn); }
.result__status--invalid,
.result__status--error { border-left-color: var(--bad); }

.result__status h2 { font-size: var(--text-lg); margin: 0 0 var(--space-1); }
.result__next { margin: 0; color: var(--ink-soft); }
.result__links { margin: var(--space-2) 0 0; padding-left: 1.25rem; }

.result__figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(10rem, 100%), 1fr));
    gap: var(--space-3);
    margin: var(--space-5) 0;
}

.figure {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
}

.figure dt { font-size: var(--text-xs); font-weight: 600; color: var(--ink-soft); }
.figure dd { margin: 0; }

/* A figure breaks only if it cannot fit on a line of its own, never mid-number
   because a column was narrow. */
.figure__value {
    font-size: clamp(1.2rem, 4.5vw, 1.5rem);
    font-weight: 750;
    letter-spacing: -0.01em;
    color: var(--brand-navy);
    overflow-wrap: break-word;
    font-variant-numeric: tabular-nums;
}

.figure--total {
    background: var(--tint);
    border-color: #a9c6e8;
}

/* On a phone the figures become one compact list, label and value on a line,
   so the rule and its source are not pushed a screen further down. */
@media (max-width: 40rem) {
    .result__figures {
        grid-template-columns: 1fr;
        gap: 0;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        overflow: hidden;
    }

    .figure {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 0 var(--space-3);
        border: 0;
        border-radius: 0;
    }

    .figure + .figure {
        border-top: 1px solid var(--line);
    }

    .figure { flex-wrap: nowrap; }
    .figure dt { font-size: var(--text-sm); flex: 1 1 auto; min-width: 0; }
    .figure dd { flex: 0 0 auto; text-align: right; }
    .figure__value { font-size: 1.25rem; }
}

/* A qualifier on a headline figure: smaller than the label it follows, and
   never the only thing distinguishing the figure — it says what it means. */
.figure__qualifier {
    display: block;
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--ink-soft);
}

.result__detail,
.provenance {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) 1fr;
    gap: var(--space-2) var(--space-4);
    margin: var(--space-3) 0;
    font-size: var(--text-sm);
}

.result__detail dt,
.provenance dt { font-weight: 600; color: var(--ink-soft); }
.result__detail dd,
.provenance dd { margin: 0; overflow-wrap: anywhere; }

.result__tax-note,
.result__evaluated,
.result__disclaimer {
    font-size: var(--text-xs);
    color: var(--ink-soft);
}

.result__disclaimer {
    border-top: 1px solid var(--line);
    padding-top: var(--space-3);
}

.result__notices ul { margin: 0; padding-left: 1.25rem; }

.checker__answer { font-size: var(--text-lg); font-weight: 650; }

.checker__components,
.gst__components {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
    gap: var(--space-3);
    margin: var(--space-4) 0;
}

.checker__component,
.gst__component {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
}

.checker__component h3 {
    font-size: var(--text-sm);
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    margin: 0 0 var(--space-1);
}

.gst__component dd { margin: 0; }
.gst__estimate { display: block; font-size: var(--text-xs); color: var(--ink-soft); }

.band--unpriced th,
.band--unpriced td { background: var(--warn-soft); }

.simple-mode { margin: var(--space-4) 0; }
.simple-mode summary { cursor: pointer; font-weight: 600; color: var(--accent); }

/* The multi-row tools: their forms and results are wide tables, so they stay
   in one column; the panel styling is shared. */
.calculator--monthly .calculator__form,
.calculator--business .calculator__form,
.calculator--compare .calculator__form {
    margin-bottom: var(--space-5);
}

.calculator--compare .calculator__form {
    max-width: 44rem;
}

.share {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
}

.share__heading {
    font-size: var(--text-md);
    margin: 0 0 var(--space-1);
}

.share__row {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.share__url {
    flex: 1 1 16rem;
    min-width: 0;
}

.share__status {
    font-size: var(--text-sm);
    color: var(--good);
    margin: var(--space-2) 0 0;
}

.share__status:empty {
    margin: 0;
}

@media (max-width: 30rem) {
    .result__detail,
    .provenance { grid-template-columns: 1fr; }
    .result__detail dd,
    .provenance dd { margin-bottom: var(--space-2); }
}

/* ---------- Multi-row input forms on a phone ----------

   The monthly bands and the business streams are tables on a wide screen.
   On a phone a row of four controls does not fit, so each row becomes a
   stacked group, and the per-control labels the table hides for screen
   readers ("Stream 2, payment method") are shown, since the column headings
   are no longer above them. */

@media (max-width: 40rem) {
    table.bands,
    table.bands tbody,
    table.bands tr,
    table.bands td {
        display: block;
        width: auto;
    }

    .table-wrap:has(table.bands) {
        border: 0;
        background: transparent;
    }

    table.bands thead,
    table.bands th[scope="row"] {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    table.bands tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: var(--space-2) var(--space-3);
        margin-bottom: var(--space-3);
        background: var(--paper);
    }

    table.bands td {
        border: 0;
        padding: var(--space-1) 0;
    }

    table.bands .sr-only {
        position: static;
        width: auto;
        height: auto;
        margin: 0 0 0.15rem;
        overflow: visible;
        clip: auto;
        white-space: normal;
        display: block;
        font-size: var(--text-sm);
        font-weight: 600;
    }

    table.bands select,
    table.bands input {
        width: 100%;
        max-width: none;
    }
}

/* ---------- The bulk calculator ---------- */

.bulk__input {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-2);
    max-width: 44rem;
}

.bulk__status {
    font-weight: 600;
    color: var(--brand-navy);
}

.bulk__contract {
    margin-top: var(--space-7);
    max-width: var(--measure);
}

/* =====================================================================
   Admin panel
   An operations console: dense enough for daily work, every screen usable
   down to a phone.
   ===================================================================== */

body.admin-body {
    background: var(--paper-soft);
}

.admin {
    display: grid;
    grid-template-columns: 15.5rem minmax(0, 1fr);
    min-height: 100vh;
}

.admin__sidebar {
    background: var(--brand-deep);
    color: #dbe6f4;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: var(--space-4) 0 var(--space-5);
}

.admin__sidebar :focus-visible {
    outline-color: #8fc9ff;
}

.admin__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-1) var(--space-4) var(--space-4);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none;
}

.admin__brand .brand__image {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
}

.admin__brand-text {
    display: grid;
    min-width: 0;
}

.admin__brand strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: var(--text-sm);
    line-height: 1.3;
    color: #ffffff;
}

.admin__brand span span,
.admin__brand-role {
    color: #9fc2ee;
    font-size: var(--text-xs);
}

.admin__nav {
    list-style: none;
    margin: 0;
    padding: 0 var(--space-3);
}

.admin__nav a {
    display: flex;
    align-items: center;
    min-height: 2.4rem;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    color: #dbe6f4;
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
}

/* Three states that never look alike: hover is a faint fill; the current
   page is a stronger fill with an accent bar and bold text, and stays so when
   hovered; keyboard focus adds a ring on top of either. */
.admin__nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.admin__nav a[aria-current="page"],
.admin__nav a[aria-current="page"]:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-weight: 650;
    box-shadow: inset 3px 0 0 var(--brand-sky);
}

.admin__nav a:focus-visible {
    outline: 3px solid #8fc9ff;
    outline-offset: -3px;
}

.admin__nav-heading {
    padding: var(--space-4) var(--space-3) var(--space-1);
    color: #9fc2ee;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.admin__main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin__bar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: var(--space-2) var(--space-6);
    min-height: 3.75rem;
    display: flex;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.admin__bar-warning {
    text-decoration: none;
}

.admin__bar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

/* ---------- The account menu ----------
   A native <details>: the panel is positioned against the menu, layered above
   everything in the content area (the bar it sits in is itself above the
   content), and kept inside the viewport on a phone. */
.user-menu {
    position: relative;
}

.user-menu__button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.5rem;
    padding: 0 var(--space-3) 0 var(--space-1);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.user-menu__button::-webkit-details-marker {
    display: none;
}

.user-menu__button::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    margin-left: var(--space-1);
}

.user-menu__button:hover {
    border-color: var(--accent);
    background: var(--tint);
}

.user-menu[open] > .user-menu__button {
    border-color: var(--accent);
}

.user-menu__avatar {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-navy);
    color: #ffffff;
    font-size: var(--text-sm);
    font-weight: 700;
}

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + var(--space-2));
    z-index: var(--z-menu);
    width: 17rem;
    max-width: calc(100vw - 2 * var(--gutter));
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: var(--space-2);
}

.user-menu__identity {
    display: grid;
    gap: 0.1rem;
    margin: 0;
    padding: var(--space-2) var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--line);
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

.user-menu__identity span {
    color: var(--ink-soft);
}

.user-menu__list {
    list-style: none;
    margin: var(--space-2) 0;
    padding: 0;
}

.user-menu__list a {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--ink);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
}

.user-menu__list a:hover {
    background: var(--tint);
    color: var(--brand-navy);
}

.user-menu__signout {
    margin: 0;
    padding: var(--space-2) var(--space-1) var(--space-1);
    border-top: 1px solid var(--line);
}

.user-menu__signout button {
    width: 100%;
}

@media (max-width: 40rem) {
    .user-menu__name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

.admin__brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding-right: var(--space-3);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.admin__brand-row .admin__brand {
    border-bottom: 0;
    margin-bottom: 0;
    min-width: 0;
}

.admin__menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    padding: 0 var(--space-3);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 650;
    cursor: pointer;
}

.admin__menu-toggle:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.admin__menu-toggle[hidden] {
    display: none;
}

.admin__content {
    padding: var(--space-6);
    width: 100%;
    max-width: 90rem;
}

.admin__header {
    margin-bottom: var(--space-5);
    display: grid;
    gap: var(--space-1);
}

.admin__header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.admin__header p {
    color: var(--ink-soft);
    max-width: var(--measure);
    margin: 0;
}

.admin__header .actions {
    margin-top: var(--space-3);
}

.admin__content > .card:last-child {
    margin-bottom: 0;
}

/* ---------- The article editor ----------
   Main column for writing, side column for publishing and page details;
   one column below 70rem. */
.editor-layout {
    display: grid;
    gap: var(--space-5);
    align-items: start;
}

@media (min-width: 70rem) {
    .editor-layout {
        grid-template-columns: minmax(0, 1fr) 20rem;
    }

    .editor-side {
        position: sticky;
        top: 5rem;
    }
}

.editor-main .field {
    max-width: none;
}

.editor-main #title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.editor-side {
    display: grid;
    gap: var(--space-4);
}

.editor-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.editor-panel__title {
    margin: 0 0 var(--space-3);
    font-size: var(--text-md);
}

.editor-panel .field:last-child {
    margin-bottom: 0;
}

.editor-panel__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.editor-panel__note {
    margin: var(--space-2) 0 0;
}

.editor-section {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 var(--space-4);
    margin-bottom: var(--space-4);
}

.editor-section > summary {
    cursor: pointer;
    font-weight: 650;
    min-height: 3rem;
    display: flex;
    align-items: center;
}

.editor-section[open] {
    padding-bottom: var(--space-4);
}

/* Two-factor setup on the profile page. */
.setup-steps { margin: 0 0 var(--space-4); padding-left: 1.25rem; display: grid; gap: var(--space-1); }
.qr { margin: 0 0 var(--space-4); display: grid; justify-items: start; gap: var(--space-2); }
/* The code keeps its white quiet zone in both themes and never shrinks below
   a scannable size. */
.qr svg { width: min(220px, 100%); height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stack-form { border-top: 1px solid var(--line); padding-top: var(--space-4); margin-top: var(--space-4); }
.stack-form__title { font-size: 1rem; margin: 0 0 var(--space-3); }

/* The rich-text field itself. */
.rte {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--paper);
}

.rte:focus-within {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.rte__toolbar {
    position: sticky;
    top: 3.75rem;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2);
    border-bottom: 1px solid var(--line);
    background: var(--paper-soft);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.rte__toolbar.is-source > :not([data-command="source"]) {
    opacity: 0.45;
    pointer-events: none;
}

.rte__button,
.rte__block {
    min-height: 2.25rem;
    padding: 0 var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}

.rte__block {
    border-color: var(--line-strong);
    background: var(--paper);
    width: auto;
}

.rte__button:hover {
    background: var(--tint);
    border-color: var(--line);
}

.rte__button[aria-pressed="true"] {
    background: var(--tint);
    border-color: var(--accent);
    color: var(--brand-navy);
}

.rte__button--bold { font-weight: 800; }
.rte__button--italic { font-style: italic; }

.rte__separator {
    width: 1px;
    align-self: stretch;
    margin: var(--space-1) var(--space-1);
    background: var(--line);
}

.rte__surface {
    min-height: 22rem;
    max-width: none;
    padding: var(--space-4);
    outline: none;
    overflow-wrap: break-word;
}

.rte__surface:focus-visible {
    outline: none;
}

.rte__surface table {
    width: 100%;
}

.rte__surface th,
.rte__surface td {
    border: 1px solid var(--line);
    padding: var(--space-1) var(--space-2);
}

.rte__source {
    border: 0;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    min-height: 22rem;
    width: 100%;
}

/* Dialogs opened from the editor (native <dialog>). */
.rte-dialog {
    width: min(36rem, calc(100vw - 2 * var(--gutter)));
    max-height: calc(100vh - 4rem);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    padding: var(--space-5);
    color: var(--ink);
}

.rte-dialog::backdrop {
    background: rgba(2, 34, 98, 0.45);
}

.rte-dialog__title {
    margin: 0 0 var(--space-4);
    font-size: var(--text-lg);
}

.rte-dialog .field {
    max-width: none;
}

.rte-image__source {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin: 0 0 var(--space-4);
}

.rte-image__library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: var(--space-2);
    max-height: 14rem;
    overflow-y: auto;
    margin-bottom: var(--space-3);
}

.rte-image__option {
    padding: 0;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper-soft);
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}

.rte-image__option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rte-image__option[aria-selected="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

/* The image library page. */
.media-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
}

.media-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.media-card img {
    display: block;
    width: 100%;
    height: 10rem;
    object-fit: cover;
    background: var(--paper-soft);
}

.media-card__body {
    padding: var(--space-3) var(--space-4) var(--space-4);
}

.media-card__alt {
    margin: 0 0 var(--space-1);
    font-size: var(--text-sm);
}

/* An index of the sections on a long admin page. */
.page-index {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-5);
    font-size: var(--text-sm);
}

.page-index__title {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--ink-soft);
}

.page-index ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.page-index a {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0 var(--space-3);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
    text-decoration: none;
    color: var(--brand-navy);
    font-weight: 600;
}

.page-index a:hover {
    border-color: var(--accent);
}

.admin__content .card[id] {
    scroll-margin-top: 5rem;
}

/* Status tiles on the dashboard: one row of equal tiles. */
.admin__content .grid:has(> .stat) {
    grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
    gap: var(--space-3);
}

/* Admin tables are denser than the public ones, and a column of short prose
   never collapses to one word per line because a neighbour is wide. */
.admin__content table.data th,
.admin__content table.data td {
    padding: 0.6rem var(--space-3);
}

.admin__content table.data td.small {
    min-width: 10rem;
}

/* An admin table on a phone: each row a card, each cell labelled with its
   column heading (admin.js supplies the labels). */
@media (max-width: 40rem) {
    .admin__content table.data--stackable thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .admin__content table.data--stackable,
    .admin__content table.data--stackable tbody,
    .admin__content table.data--stackable tr {
        display: block;
        width: 100%;
    }

    .admin__content table.data--stackable tr {
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--line);
    }

    .admin__content table.data--stackable tbody tr:last-child {
        border-bottom: 0;
    }

    /* The label sits in a fixed left column; the cell's own content flows
       normally beside it, however many elements it holds. */
    .admin__content table.data--stackable td,
    .admin__content table.data--stackable tbody th {
        display: block;
        position: relative;
        min-height: 1.75rem;
        border: 0;
        padding: var(--space-1) var(--space-3) var(--space-1) calc(36% + var(--space-3));
        text-align: left;
        overflow-wrap: anywhere;
    }

    .admin__content table.data--stackable td:not([data-label]) {
        padding-left: var(--space-3);
    }

    .admin__content table.data--stackable td[data-label]::before,
    .admin__content table.data--stackable tbody th[data-label]::before {
        content: attr(data-label);
        position: absolute;
        left: var(--space-3);
        top: var(--space-1);
        width: calc(36% - var(--space-3));
        font-weight: 600;
        font-size: var(--text-xs);
        line-height: 1.6;
        color: var(--ink-soft);
    }
}

/* Side-by-side panels keep their own height rather than stretching to the
   taller neighbour. */
.admin__content .grid {
    align-items: start;
}

@media (max-width: 60rem) {
    .admin {
        grid-template-columns: 1fr;
    }

    .admin__sidebar {
        position: static;
        height: auto;
        padding: var(--space-3) 0;
    }

    /* With the script running, the section list collapses behind the Menu
       button in the bar; without it the list stays visible above the page. */
    .js .admin__sidebar:not(.is-open) .admin__nav {
        display: none;
    }

    .admin__brand {
        padding-bottom: var(--space-1);
    }

    .js .admin__sidebar:not(.is-open) .admin__brand-row {
        border-bottom: 0;
        margin-bottom: 0;
    }

    .admin__nav {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(10rem, 100%), 1fr));
        gap: 0 var(--space-2);
    }

    .admin__nav-heading {
        grid-column: 1 / -1;
    }

    .admin__bar {
        position: static;
        padding: var(--space-2) var(--gutter);
    }

    .admin__content {
        padding: var(--space-5) var(--gutter);
    }

    dl.detail { grid-template-columns: 1fr; }
    dl.detail dt { margin-top: var(--space-2); }
}

@media (min-width: 60rem) {
    .admin__menu-toggle {
        display: none !important;
    }

    /* No toggle beside the brand on a desktop, so its name gets the room. */
    .admin__brand-row {
        padding-right: 0;
    }
}

.admin__brand {
    gap: var(--space-2);
}

/* The narrowest phones: the Sections button keeps its icon and its accessible
   name, and gives the site's name the width. */
@media (max-width: 23rem) {
    .admin__menu-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .admin__menu-toggle {
        padding: 0 var(--space-3);
    }
}

/* ---------- Auth screens ---------- */

.auth {
    max-width: 26rem;
    margin: var(--space-8) auto;
    padding: 0 var(--gutter);
}

.auth__brand {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}

.auth__card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-2);
}

.auth__card h1 {
    font-size: var(--text-xl);
}

.auth__card .field {
    max-width: none;
}

.auth__card button[type="submit"] {
    width: 100%;
}

/* ---------- Message and error pages ---------- */

.page--message {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* The error page's brand bar, aligned with the message beneath it. */
.message__header {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: var(--space-3) max(var(--gutter), calc((100% - 40rem) / 2 + var(--gutter)));
}

.message__header .brand__image {
    height: 36px;
}

.message {
    flex: 1 0 auto;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
    padding: var(--space-8) var(--gutter) var(--space-6);
}

.message h1 {
    color: var(--brand-navy);
}

.message__reference {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
}

.message__footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--line);
    color: var(--ink-faint);
    font-size: var(--text-sm);
    padding: var(--space-4);
    text-align: center;
    background: var(--paper);
}

.debug {
    border: 1px solid var(--warn);
    background: var(--warn-soft);
    border-radius: var(--radius-sm);
    padding: var(--space-4);
    margin-top: var(--space-6);
}

.debug__note {
    color: var(--warn);
    font-size: var(--text-sm);
}

.debug__meta dt {
    font-weight: 600;
    margin-top: var(--space-2);
}

.debug__meta dd {
    margin: 0 0 var(--space-1);
}

.debug__trace {
    overflow-x: auto;
    background: var(--paper);
    border: 1px solid var(--line);
    padding: var(--space-3);
    white-space: pre;
}

/* =====================================================================
   Utilities
   These exist because the Content Security Policy grants no inline styles:
   a style attribute is silently dropped, so anything a template needs to say
   about spacing or width is named here.
   ===================================================================== */

/* .sr-only is the name the calculator templates use; the two are one rule. */
.visually-hidden,
.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;
}

.muted { color: var(--ink-soft); }
.small { font-size: var(--text-sm); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: var(--space-4); }

.u-flush-top          { margin-top: 0; }
.u-gap-below          { margin-bottom: var(--space-4); }
.u-space-above-tight  { margin-top: var(--space-2); }
.u-space-above        { margin-top: var(--space-4); }
.u-space-above-wide   { margin-top: var(--space-5); }
.u-full-width         { max-width: none; }
.u-tall-editor        { min-height: 26rem; }
.u-centre-row         { justify-content: center; }
.u-break-anywhere     { word-break: break-all; }
.u-readable-code      { font-size: 1.05rem; line-height: 2; }
.u-narrow-page        { max-width: 52rem; margin: var(--space-6) auto; }

/* =====================================================================
   Print
   ===================================================================== */

@media print {
    .admin__sidebar, .admin__bar, .actions { display: none; }
    .admin { grid-template-columns: 1fr; }
}

/* A printed result has to carry everything that makes the figure meaningful —
   the source, the confidence, the review date and the disclaimers — and none of
   the things that only work on a screen. Link destinations are printed after
   external links, because a reader holding paper cannot follow a hyperlink. */
@media print {
    .site-header,
    .site-nav,
    .site-footer__nav,
    .site-footer__brand,
    .breadcrumbs,
    .skip-link,
    .tool-switcher,
    .related,
    .calculator__links,
    .pagination,
    .class-helper,
    .consent,
    .quick-start,
    main form .actions,
    main form button,
    [data-share],
    [data-share-copy] {
        display: none !important;
    }

    .result,
    .result__figures,
    .source-block,
    .result__disclaimer,
    .review-date,
    .disclaimer,
    .byline {
        display: block !important;
        break-inside: avoid;
    }

    .result__figures {
        display: grid !important;
    }

    body,
    .site-footer {
        background: #ffffff;
        color: #000000;
    }

    .calculator__form,
    .result,
    .hero {
        box-shadow: none;
    }

    .prose a[href^="http"]::after,
    .source-block a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        word-break: break-all;
    }
}
