/* The one stylesheet of the dashboard, the setup wizard, the public pages and the operator console. It is served from
   this origin because the Content-Security-Policy allows no inline style and no other origin. Every colour is a token
   on :root (UI rework design, 3.1), light only, so no rule below the token block names a raw colour. */
@layer tokens, base, layout, components, pages;

@font-face {
    font-family: "DM Sans";
    src: url("fonts/dm-sans.woff2") format("woff2");
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "DM Mono";
    src: url("fonts/dm-mono.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("fonts/cormorant-garamond.woff2") format("woff2");
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("fonts/cormorant-garamond-italic.woff2") format("woff2");
    font-weight: 500;
    font-style: italic;
    font-display: swap;
}

@layer tokens {
    :root {
        --ink: #15382f;
        --paper: #f5f1e8;
        --card: #fffdf8;
        --white: #ffffff;
        --muted: #50685e;
        --teal: #08766d;
        --lime: #d6f58b;
        --sage: #e4ede6;
        --selected: #f1f8f4;
        --line: rgba(21, 56, 47, 0.12);
        --line-strong: rgba(21, 56, 47, 0.28);
        --row-hover: rgba(21, 56, 47, 0.03);
        --field-edge: #768a82;
        --side-text: #e4ede6;
        --side-label: #8fb0a3;
        --side-hover: rgba(228, 237, 230, 0.1);
        --side-rule: rgba(228, 237, 230, 0.16);
        --done-bg: #d6f58b;
        --done-text: #15382f;
        --active-bg: #dcebe5;
        --active-text: #06665e;
        --waiting-bg: #fff2c9;
        --waiting-text: #6b4c00;
        --failed-bg: #f6dcd5;
        --failed-text: #8a2a17;
        --serif: "Cormorant Garamond", Georgia, serif;
        --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
        --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        --radius-card: 12px;
        --radius-field: 10px;
        --radius-pill: 999px;
        --s1: 4px;
        --s2: 8px;
        --s3: 12px;
        --s4: 16px;
        --s5: 24px;
        --s6: 32px;
        --s7: 48px;
        --shadow-card: 0 0 0 1px var(--line), 0 1px 2px rgba(21, 56, 47, 0.06);
        --ease: cubic-bezier(0.2, 0, 0, 1);
    }
}

@layer base {
    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body {
        margin: 0;
        min-height: 100vh;
        background: var(--paper);
        color: var(--ink);
        font: 400 16px/1.5 var(--sans);
        -webkit-font-smoothing: antialiased;
    }
    h1, h2, h3 { margin: 0; color: var(--ink); }
    h1 { font: 500 40px/1.05 var(--serif); letter-spacing: -0.03em; text-wrap: balance; }
    h2 { font-size: 18px; font-weight: 600; line-height: 1.3; }
    h3 { font-size: 16px; font-weight: 600; line-height: 1.3; }
    p { margin: 0 0 var(--s3); }
    ul, ol { margin: 0 0 var(--s3); padding-left: var(--s5); }
    figure { margin: 0; }
    a { color: var(--teal); text-underline-offset: 3px; }
    a:hover { color: var(--ink); }
    code, pre { font-family: var(--mono); font-size: 14px; }
    strong { font-weight: 600; }
    :focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
    [hidden] { display: none !important; }
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after { transition: none !important; animation: none !important; }
    }
}

@layer layout {
    .skip {
        position: absolute;
        left: var(--s4);
        top: -64px;
        z-index: 10;
        padding: var(--s2) var(--s4);
        border-radius: var(--radius-pill);
        background: var(--lime);
        color: var(--ink);
        font-weight: 600;
    }
    .skip:focus { top: var(--s3); }

    body.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: var(--s5);
        padding: var(--s5) var(--s3) var(--s4);
        background: var(--ink);
        color: var(--side-text);
    }
    .sidebar :focus-visible, .rail :focus-visible, .brand-panel :focus-visible { outline-color: var(--lime); }
    .sidebar-head { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s2); }
    .wordmark {
        font: 600 22px/1 var(--serif);
        letter-spacing: -0.02em;
        color: var(--paper);
        text-decoration: none;
        white-space: nowrap;
    }
    .wordmark:hover { color: var(--paper); }
    .tag {
        padding: 2px var(--s2);
        border-radius: var(--radius-pill);
        background: var(--lime);
        color: var(--ink);
        font: 400 11px/1.4 var(--mono);
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }
    .menu-button {
        display: none;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin-left: auto;
        padding: 0;
        border: 1px solid var(--side-rule);
        border-radius: var(--radius-pill);
        background: transparent;
        color: var(--paper);
        cursor: pointer;
    }
    .nav-panel { display: flex; flex-direction: column; gap: var(--s5); flex: 1; }
    .nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
    .nav-link {
        display: flex;
        align-items: center;
        gap: var(--s3);
        min-height: 40px;
        padding: var(--s2) var(--s3);
        border-radius: var(--radius-pill);
        color: var(--side-text);
        text-decoration: none;
        transition: background-color 150ms var(--ease), color 150ms var(--ease);
    }
    .nav-link:hover { background: var(--side-hover); color: var(--paper); }
    .nav-link[aria-current="page"] { background: var(--lime); color: var(--ink); font-weight: 600; }
    .nav-group { display: flex; flex-direction: column; gap: 2px; }
    .nav-label {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0 var(--s2);
        margin: var(--s4) var(--s3) var(--s1);
        font: 400 12px/1.4 var(--mono);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--side-label);
        overflow-wrap: anywhere;
    }
    .badge {
        margin-left: auto;
        min-width: 22px;
        padding: 1px 7px;
        border-radius: var(--radius-pill);
        background: var(--lime);
        color: var(--ink);
        font-size: 12px;
        font-weight: 600;
        text-align: center;
        font-variant-numeric: tabular-nums;
    }
    .badge:empty { display: none; }
    .nav-link[aria-current="page"] .badge { background: var(--ink); color: var(--lime); }
    /* A tenant page's total, beside the badge's alert: neutral text, so the lime stays the sign of what waits. */
    .nav-count {
        margin-left: auto;
        font: 400 12px/1.4 var(--mono);
        color: var(--side-label);
        font-variant-numeric: tabular-nums;
    }
    .nav-count + .badge { margin-left: var(--s2); }
    .nav-link[aria-current="page"] .nav-count { color: var(--ink); }
    .sidebar-foot {
        display: flex;
        flex-direction: column;
        gap: var(--s1);
        padding: var(--s4) var(--s2) 0;
        border-top: 1px solid var(--side-rule);
        font-size: 14px;
    }
    .who { padding: 0 var(--s3); color: var(--side-label); overflow-wrap: anywhere; }
    .sidebar-foot form, .rail-foot form { margin: 0; }
    .signout {
        display: inline-flex;
        align-items: center;
        gap: var(--s2);
        min-height: 40px;
        padding: var(--s2) var(--s3);
        border: 0;
        border-radius: var(--radius-pill);
        background: transparent;
        color: var(--side-text);
        font: 600 14px/1.2 var(--sans);
        cursor: pointer;
    }
    .signout:hover { background: var(--side-hover); color: var(--paper); }

    .main { min-width: 0; }
    .page { max-width: 1200px; margin: 0 auto; padding: var(--s6) var(--s5) var(--s7); }
    .page-header {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        justify-content: space-between;
        gap: var(--s4);
        margin: 0 0 var(--s5);
    }
    .eyebrow, .label-mono {
        margin: 0 0 var(--s2);
        font: 400 12px/1.4 var(--mono);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
    }
    .lead { margin: var(--s2) 0 0; max-width: 72ch; color: var(--muted); }
    .page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
    .section { margin: var(--s6) 0 0; }
    .section > h2 { margin: 0 0 var(--s3); }
    .section-head {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--s3);
        margin: 0 0 var(--s3);
    }
    .back {
        display: inline-flex;
        align-items: center;
        gap: var(--s2);
        min-height: 40px;
        margin: 0 0 var(--s3);
        color: var(--muted);
        font-weight: 600;
        text-decoration: none;
    }
    .back:hover { color: var(--ink); }

    @media (max-width: 899px) {
        body.shell { display: block; }
        .sidebar { position: static; height: auto; gap: var(--s3); padding: var(--s3); }
        .js .menu-button { display: inline-flex; }
        .js .sidebar:not([data-open]) .nav-panel { display: none; }
        .page { padding: var(--s5) var(--s4) var(--s6); }
        h1 { font-size: 32px; }
    }
}

@layer components {
    .icon {
        width: 18px;
        height: 18px;
        flex: none;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .visually-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }
    .muted { color: var(--muted); }
    .mono { font-family: var(--mono); font-size: 14px; }

    .btn, .btn-secondary, .btn-danger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--s2);
        min-height: 40px;
        padding: var(--s2) var(--s5);
        border-radius: var(--radius-pill);
        font: 600 15px/1.2 var(--sans);
        text-decoration: none;
        cursor: pointer;
        touch-action: manipulation;
        transition: background-color 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
    }
    .btn { border: 1px solid var(--ink); background: var(--ink); color: var(--paper); }
    .btn:hover { border-color: var(--teal); background: var(--teal); color: var(--white); }
    .btn-secondary { border: 1px solid var(--line-strong); background: transparent; color: var(--ink); }
    .btn-secondary:hover { border-color: var(--ink); color: var(--ink); }
    .btn-danger { border: 1px solid currentColor; background: transparent; color: var(--failed-text); }
    .btn-danger:hover { background: var(--failed-bg); color: var(--failed-text); }
    .btn-quiet {
        display: inline-flex;
        align-items: center;
        gap: var(--s2);
        min-height: 40px;
        padding: var(--s2) var(--s1);
        border: 0;
        background: none;
        color: var(--muted);
        font: 600 14px/1.2 var(--sans);
        text-decoration: underline;
        text-underline-offset: 3px;
        cursor: pointer;
    }
    .btn-quiet:hover { color: var(--ink); }
    button:disabled, fieldset:disabled button { opacity: 0.5; cursor: not-allowed; }
    @media (pointer: coarse) {
        .btn, .btn-secondary, .btn-danger, .btn-quiet, .nav-link, .signout, .back { min-height: 44px; }
    }
    .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s4) 0 0; }
    td .actions, td form.actions { margin: 0 0 var(--s1); }
    .buttons { display: inline-flex; flex-wrap: wrap; gap: var(--s2); min-width: 0; margin: 0; padding: 0; border: 0; }
    .buttons.reverse { flex-direction: row-reverse; }
    .busy { display: none; color: var(--muted); font-size: 14px; }
    .htmx-request .busy { display: inline; }

    .notice, .alert { margin: 0 0 var(--s4); padding: var(--s3) var(--s4); border-radius: var(--radius-card); }
    .notice { background: var(--active-bg); color: var(--active-text); }
    .alert { background: var(--failed-bg); color: var(--failed-text); }
    .notice p:last-child, .alert p:last-child { margin-bottom: 0; }
    .notice code, .alert code { overflow-wrap: anywhere; }

    .panel {
        padding: var(--s4) var(--s5);
        background: var(--card);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
    }
    .panel + .panel { margin-top: var(--s4); }
    .panel > h2, .panel > h3 { margin: 0 0 var(--s3); }
    .empty {
        margin: 0;
        padding: var(--s6) var(--s4);
        border: 1px dashed var(--line-strong);
        border-radius: var(--radius-card);
        background: var(--card);
        color: var(--muted);
        text-align: center;
    }

    .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); margin: 0 0 var(--s5); }
    .kpi {
        display: flex;
        flex-direction: column;
        gap: var(--s1);
        padding: var(--s4) var(--s5);
        background: var(--card);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
    }
    .kpi-label { font: 400 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
    .kpi-value {
        color: var(--ink);
        font-size: 28px;
        font-weight: 600;
        line-height: 1.2;
        letter-spacing: -0.02em;
        font-variant-numeric: tabular-nums;
        text-decoration: none;
    }
    a.kpi-value:hover { color: var(--teal); }
    .kpi-hint { color: var(--muted); font-size: 14px; }
    .kpi-list { display: flex; flex-direction: column; gap: 2px; margin: var(--s1) 0 0; padding: 0; list-style: none; font-size: 14px; }

    .meter { display: block; width: 100%; height: 6px; margin-top: var(--s2); border-radius: var(--radius-pill); overflow: hidden; }
    .meter .track { fill: var(--sage); }
    .meter .fill { fill: var(--teal); }
    .meter .fill.over { fill: var(--failed-text); }
    .chart { display: block; width: 100%; height: auto; }
    .chart .bar-fill { fill: var(--teal); transition: opacity 150ms var(--ease); }
    .chart .bar-fill:hover { opacity: 0.7; }
    .chart .axis { stroke: var(--line-strong); stroke-width: 1; }
    .chart text { fill: var(--muted); font: 11px var(--sans); }

    .table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
    .table { width: 100%; border-collapse: collapse; font-size: 15px; }
    .table th {
        padding: var(--s3) var(--s4);
        border-bottom: 1px solid var(--line);
        color: var(--muted);
        font: 400 12px/1.4 var(--mono);
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        white-space: nowrap;
    }
    .table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
    .table tbody tr:last-child td { border-bottom: 0; }
    .table tbody tr:hover { background: var(--row-hover); }
    .table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .table .sub { display: block; color: var(--muted); font-size: 14px; }
    .table .wide { min-width: 240px; }
    .row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
    .row-link:hover { color: var(--teal); text-decoration: underline; }

    .pill {
        display: inline-block;
        padding: 2px 10px;
        border-radius: var(--radius-pill);
        background: var(--sage);
        color: var(--ink);
        font-size: 13px;
        font-weight: 600;
        line-height: 1.5;
        white-space: nowrap;
        text-transform: lowercase;
    }
    .pill::first-letter { text-transform: uppercase; }
    .status-completed, .status-synced, .status-sent, .status-approved, .status-loaded, .status-succeeded,
    .status-fine { background: var(--done-bg); color: var(--done-text); }
    .status-running, .status-sending { background: var(--active-bg); color: var(--active-text); }
    .status-pending, .status-partial, .status-held, .status-awaiting_approval, .status-awaiting_load,
    .status-quarantined, .status-look { background: var(--waiting-bg); color: var(--waiting-text); }
    .status-failed, .status-budget_exceeded, .status-rejected, .status-screened_out,
    .status-fix { background: var(--failed-bg); color: var(--failed-text); }
    .status-discarded, .status-skipped, .status-none, .status-dropped,
    .status-charged { background: var(--sage); color: var(--ink); }
    .status-submitted { background: var(--waiting-bg); color: var(--waiting-text); }
    .status-applied { background: var(--done-bg); color: var(--done-text); }
    .score {
        display: inline-block;
        min-width: 36px;
        padding: 2px 8px;
        border-radius: var(--radius-pill);
        background: var(--lime);
        color: var(--ink);
        font-weight: 600;
        text-align: center;
        font-variant-numeric: tabular-nums;
    }
    .score:empty { display: none; }

    .tabs { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s4); }
    .tabs a {
        display: inline-flex;
        align-items: center;
        gap: var(--s2);
        min-height: 36px;
        padding: var(--s1) var(--s4);
        border-radius: var(--radius-pill);
        box-shadow: 0 0 0 1px var(--line-strong);
        color: var(--ink);
        font-size: 15px;
        text-decoration: none;
    }
    .tabs a:hover { box-shadow: 0 0 0 1px var(--ink); }
    .tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); box-shadow: none; }

    .filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); margin: 0 0 var(--s4); }
    .filters .field { min-width: 160px; }
    .pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin: var(--s4) 0 0; }

    .facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4) var(--s5); margin: 0; }
    .facts dt { color: var(--muted); font: 400 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
    .facts dd { margin: var(--s1) 0 0; font-weight: 600; overflow-wrap: anywhere; }
    .detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
    .text-block {
        margin: 0;
        padding: var(--s3) var(--s4);
        border-radius: var(--radius-field);
        background: var(--paper);
        font: inherit;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }
    @media (max-width: 899px) { .detail { grid-template-columns: minmax(0, 1fr); } }

    .form { display: flex; flex-direction: column; gap: var(--s4); max-width: 640px; }
    .form-wide { max-width: none; }
    .field { display: flex; flex-direction: column; gap: var(--s1); }
    label { font-size: 15px; font-weight: 600; }
    .help { margin: 0; color: var(--muted); font-size: 14px; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]), select, textarea {
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border: 1px solid var(--field-edge);
        border-radius: var(--radius-field);
        background: var(--white);
        color: var(--ink);
        font: inherit;
    }
    input[type="file"] { font: inherit; }
    textarea { min-height: 96px; resize: vertical; }
    select[multiple] { min-height: 220px; }
    input:focus-visible, select:focus-visible, textarea:focus-visible {
        outline: 2px solid var(--teal);
        outline-offset: 1px;
        border-color: var(--teal);
    }
    [aria-invalid="true"] { border-color: var(--failed-text) !important; }
    .field-error { margin: 0; color: var(--failed-text); font-size: 14px; }
    .input-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
    .input-row input { flex: 1 1 240px; width: auto; }
    fieldset.group {
        display: flex;
        flex-direction: column;
        gap: var(--s3);
        min-width: 0;
        margin: 0;
        padding: var(--s3) var(--s4) var(--s4);
        border: 1px solid var(--line-strong);
        border-radius: var(--radius-card);
        background: var(--card);
    }
    legend { padding: 0 var(--s1); font-weight: 600; }
    .checks { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
    .check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 32px; font-weight: 400; cursor: pointer; }
    .check input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
    textarea.code, pre.code { font-family: var(--mono); font-size: 14px; line-height: 1.5; }
    pre.code {
        margin: 0;
        padding: var(--s4);
        border-radius: var(--radius-card);
        background: var(--card);
        box-shadow: var(--shadow-card);
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }
    .guide { padding: var(--s2) var(--s3); border-radius: var(--radius-field); background: var(--sage); font-size: 14px; }
    .guide summary { color: var(--teal); font-weight: 600; cursor: pointer; }
    .guide[open] summary { margin-bottom: var(--s2); }
    .guide ol, .guide ul { margin: var(--s1) 0 0; }
    .guide p:last-child { margin-bottom: 0; }
}

@layer pages {
    /* Run detail: the steps as a timeline. */
    .timeline { display: flex; flex-direction: column; gap: var(--s3); margin: 0; padding: 0; list-style: none; }
    .step { padding: var(--s4) var(--s5); background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
    .step-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
    .step-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s5); margin: var(--s2) 0 0; color: var(--muted); font-size: 14px; }
    .step-meta div { display: flex; gap: var(--s1); }
    .step-meta dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
    .step-output { margin: var(--s3) 0 0; }
    .step-output summary { min-height: 32px; color: var(--teal); font-weight: 600; cursor: pointer; }
    .step-output pre {
        margin: var(--s2) 0 0;
        padding: var(--s2) var(--s3);
        border-radius: var(--radius-field);
        background: var(--sage);
        font-family: var(--mono);
        font-size: 14px;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }
    .step-error {
        margin: var(--s3) 0 0;
        padding: var(--s2) var(--s3);
        border-radius: var(--radius-field);
        background: var(--failed-bg);
        color: var(--failed-text);
        font-size: 14px;
        overflow-wrap: anywhere;
    }

    /* Outreach: one card per draft, the person on the left and the email on the right. */
    .draft-card {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
        gap: var(--s5);
        margin: 0 0 var(--s4);
        padding: var(--s5);
        background: var(--card);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
    }
    .draft-card h2 { font-size: 18px; }
    .draft-meta { margin: var(--s2) 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
    .draft-why { margin: var(--s3) 0 0; padding: var(--s2) var(--s3); border-radius: var(--radius-field); background: var(--sage); font-size: 14px; }
    .draft-mail { display: flex; flex-direction: column; gap: var(--s3); margin: 0; }
    .draft-mail .actions { justify-content: flex-end; margin: 0; }
    .unreviewed {
        align-self: flex-start;
        padding: 2px var(--s2);
        border-radius: 4px;
        background: var(--waiting-bg);
        color: var(--waiting-text);
        font: 400 12px/1.4 var(--mono);
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }
    .receipt {
        margin: 0 0 var(--s4);
        padding: var(--s4) var(--s5);
        border-radius: var(--radius-card);
        background: var(--active-bg);
        color: var(--active-text);
        animation: fade-in 200ms var(--ease);
    }
    @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
    @media (max-width: 899px) { .draft-card { grid-template-columns: minmax(0, 1fr); } }

    /* This week: the batch card and the inline stop confirmation. */
    .batch {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: space-between;
        gap: var(--s5);
        margin: 0 0 var(--s5);
        padding: var(--s5);
        background: var(--card);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
    }
    .batch-figure { margin: var(--s1) 0 var(--s2); font-size: 28px; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
    .batch-text { max-width: 64ch; color: var(--muted); font-size: 14px; }
    .batch-actions { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s3); }
    .batch-actions form { margin: 0; }
    .confirm summary { list-style: none; }
    .confirm summary::-webkit-details-marker { display: none; }
    .confirm[open] summary { margin-bottom: var(--s3); }
    .confirm-body {
        max-width: 320px;
        padding: var(--s3) var(--s4);
        border-radius: var(--radius-field);
        background: var(--failed-bg);
        color: var(--failed-text);
    }
    .disclosure summary { min-height: 40px; color: var(--teal); font-weight: 600; cursor: pointer; }

    /* The setup wizard: choice cards, the green step rail and the sticky footer. */
    .choices {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: var(--s3);
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
    }
    .choice {
        display: flex;
        gap: var(--s3);
        padding: var(--s4);
        border-radius: var(--radius-card);
        background: var(--card);
        box-shadow: var(--shadow-card);
        font-weight: 400;
        cursor: pointer;
        transition: box-shadow 150ms var(--ease), background-color 150ms var(--ease);
    }
    .choice:hover { box-shadow: 0 0 0 1px var(--teal); }
    .choice input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--teal); }
    .choice:has(input:checked) { box-shadow: 0 0 0 2px var(--teal); background: var(--selected); }
    .choice:has(input:focus-visible) { outline: 2px solid var(--teal); outline-offset: 2px; }
    .choice-title { display: block; font-weight: 600; }
    .choice-text { display: block; margin-top: var(--s1); color: var(--muted); font-size: 14px; }

    body.wizard { display: grid; grid-template-columns: 280px minmax(0, 1fr); }
    .rail {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: var(--s5);
        padding: var(--s5) var(--s4);
        background: var(--ink);
        color: var(--side-text);
    }
    .rail-steps { display: flex; flex-direction: column; gap: 2px; flex: 1; margin: 0; padding: 0; list-style: none; }
    .rail-step {
        display: flex;
        align-items: center;
        gap: var(--s3);
        min-height: 40px;
        padding: var(--s1) var(--s2);
        border-radius: var(--radius-pill);
        color: var(--side-label);
        text-decoration: none;
    }
    a.rail-step { color: var(--side-text); }
    a.rail-step:hover { background: var(--side-hover); color: var(--paper); }
    .rail-step[aria-current="step"] { background: var(--lime); color: var(--ink); font-weight: 600; }
    .rail-num {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: none;
        width: 24px;
        height: 24px;
        border: 1px solid var(--side-label);
        border-radius: 50%;
        font: 400 12px/1 var(--mono);
    }
    .rail-step.done .rail-num { border-color: transparent; background: var(--side-hover); color: var(--lime); }
    .rail-step[aria-current="step"] .rail-num { border-color: var(--ink); }
    .rail-num .icon { width: 14px; height: 14px; }
    .rail-foot {
        display: flex;
        flex-direction: column;
        gap: var(--s1);
        padding-top: var(--s4);
        border-top: 1px solid var(--side-rule);
        font-size: 14px;
    }
    .wizard-main { min-width: 0; max-width: 800px; padding: var(--s6) var(--s6) 0; }
    .wizard-main > h1 { margin: 0 0 var(--s4); }
    .step-count {
        margin: 0 0 var(--s2);
        color: var(--muted);
        font: 400 12px/1.4 var(--mono);
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }
    .wizard-main .lead { margin: 0 0 var(--s4); }
    .wizard-main .panel { margin: var(--s4) 0 0; }
    .wizard-foot {
        position: sticky;
        bottom: 0;
        display: flex;
        flex-direction: row-reverse;
        justify-content: space-between;
        gap: var(--s3);
        margin: var(--s5) 0 0;
        padding: var(--s3) 0 var(--s4);
        border-top: 1px solid var(--line);
        background: var(--paper);
    }
    dl.answers { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr); gap: var(--s2) var(--s4); margin: 0; }
    dl.answers dt { color: var(--muted); font-size: 14px; }
    dl.answers dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
    @media (max-width: 899px) {
        body.wizard { display: block; }
        .rail { position: static; height: auto; gap: var(--s2); padding: var(--s3) var(--s4); }
        .rail-steps { display: none; }
        .rail-foot { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: var(--s2); }
        .wizard-main { padding: var(--s5) var(--s4) 0; }
        dl.answers { grid-template-columns: minmax(0, 1fr); }
    }

    /* Sign-in, invite and error: the green brand panel beside the form. */
    body.public { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
    .brand-panel {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        gap: var(--s6);
        padding: var(--s7);
        background: var(--ink);
        color: var(--side-text);
    }
    .brand-panel .wordmark { font-size: 28px; }
    .tagline { margin: 0; color: var(--paper); font: 500 52px/1.02 var(--serif); letter-spacing: -0.03em; }
    .tagline em { color: var(--lime); font-style: italic; }
    .operated { margin: 0; color: var(--side-label); font: 400 12px/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
    .form-column { display: flex; align-items: center; justify-content: center; padding: var(--s7) var(--s5); }
    .form-card { width: 100%; max-width: 400px; }
    .form-card h1 { margin: 0 0 var(--s4); }
    .form-card .form { max-width: none; }
    .form-card .btn { width: 100%; }
    @media (max-width: 899px) {
        body.public { display: block; }
        .brand-panel { gap: var(--s4); padding: var(--s5) var(--s4); }
        .tagline { font-size: 32px; }
        .form-column { padding: var(--s6) var(--s4); }
    }

    /* Unsubscribe: one card, no brand, because the reader never heard of Verba. */
    body.neutral { display: grid; place-items: center; padding: var(--s4); }
    .neutral-card {
        width: 100%;
        max-width: 420px;
        padding: var(--s6);
        border-radius: var(--radius-card);
        background: var(--card);
        box-shadow: var(--shadow-card);
    }
    .neutral-card h1 { margin: 0 0 var(--s3); font: 600 24px/1.2 var(--sans); letter-spacing: 0; }
    .neutral-card .btn { width: 100%; margin-top: var(--s3); }
}
