/* Keyturn AI portal: one stylesheet for the whole site. */

/* ---------------------------------------------------------------------
   Colour tokens. EVERY colour on the site comes from here: stylesheets,
   templates and inline SVG use these custom properties (or currentColor),
   never a literal colour (core/test_theme.py guards this and recomputes
   the WCAG contrast of the text/background pairs below in both themes).

   Light values are the original palette. The dark theme (below) sets the
   same names again; it applies on screen only, so printing is always light:
   - automatically when the system prefers dark and the visitor has not
     chosen Light (<html> has no data-theme, or data-theme="system");
   - always when the visitor chose Dark (data-theme="dark", rendered by the
     server from the "theme" cookie; core/theme.py).
   --------------------------------------------------------------------- */
:root {
  color-scheme: light;
  /* Surfaces, lowest to highest */
  --surface-page: #f4f6f3;      /* page behind the cards */
  --surface-inset: #f4f6f3;     /* boxes set into a card: notices, prompts, table heads */
  --surface-sunken: #f8faf8;    /* staff filter bar, table head and row hover, empty states */
  --surface: #ffffff;           /* cards, panels, secondary buttons */
  --surface-raised: #ffffff;    /* menus, the selected segment */
  --surface-input: #ffffff;     /* text boxes */
  --surface-code: #ffffff;      /* copyable prompt text on the checklist */
  --surface-hover: #f0f5f3;     /* menu and quick-action rows on hover */
  --surface-band: #e4ece8;      /* tinted band on the public home page */
  --topbar-bg: #ffffff;
  --segment-hover: rgb(255 255 255 / 0.6);
  --track: #e4e9e5;             /* bar and meter tracks, segmented controls */
  /* Text */
  --text: #0f2a26;              /* body text and links, 14.9:1 on --surface */
  --text-secondary: #3d524e;    /* help, meta, 8.4:1 */
  --text-muted: #56665f;        /* quieter labels, 6.1:1 */
  --text-inverse: #ffffff;      /* on --brand */
  --text-on-accent: #0f2a26;    /* on --accent (amber), 9.0:1 */
  --control-accent: #0f2a26;    /* ticked checkboxes and radios */
  /* Borders */
  --border: #d5dbd6;            /* panel and row rules (decorative) */
  --border-subtle: #e4e9e5;     /* card borders in the staff shell */
  --border-strong: #c9d2cd;     /* quiet buttons, badges, dashed empty states */
  --border-hover: #56665f;
  --border-input: #7d8c88;      /* form control boundaries, 3.5:1 */
  --border-ink: #0f2a26;        /* strong rules and outlines */
  --button-border: #0f2a26;     /* amber button outline (public pages) */
  /* Brand and accent */
  --brand: #0f2a26;             /* dark green fills ("New" button) */
  --brand-hover: #1d4f47;
  --brand-mid: #1d4f47;         /* icons in the quick actions */
  --accent: #f2b63c;            /* amber: fills only, always with dark text or an outline */
  --accent-hover: #f5c662;
  --accent-border: #c9901b;
  --accent-text: #8a5a00;       /* amber as text or an outline, 5.9:1 */
  --accent-soft: #fdf0d2;       /* "in progress" and "needs a conversation" tints */
  /* Focus ring: an outline plus an amber halo */
  --focus: #0f2a26;
  --focus-halo: #f2b63c;
  /* Status families: fg (text), strong (lines, icons, fills), bg tints, border */
  --success-fg: #1a6640;
  --success-strong: #1f7a4d;
  --success-bg: #e7f3ec;
  --success-bg-strong: #d8eadf;
  --success-border: #9cc5ab;
  --warning-fg: #6e3c00;
  --warning-text: #8a4a00;
  --warning-strong: #a65a00;
  --warning-bg: #fff7e8;
  --warning-bg-soft: #fffaf0;
  --warning-bg-faint: #fffcf5;
  --warning-bg-hover: #fff5e1;
  --internal-note-bg: #fdf6e7;  /* staff-only notes on a ticket */
  --recheck-bg: #fbf0d0;
  --recheck-border: #e0c56e;
  --danger-fg: #a3261b;
  --danger-strong: #a3261b;
  --danger-solid: #a3261b;      /* filled badges, with --on-danger text */
  --on-danger: #ffffff;
  --danger-border: #a3261b;
  --danger-bg: #fbefed;
  --danger-bg-faint: #fdf7f6;
  --danger-bg-hover: #f8e6e3;
  --info-fg: #1a5c8a;
  --info-strong: #5b6f9a;
  --info-bg: #eaf1f7;
  --neutral-strong: #56665f;
  /* Charts, sparklines and meters */
  --chart-1: #1d4f47;           /* raised, received, jobs */
  --chart-2: #f2b63c;           /* answered (amber fill) */
  --chart-2-edge: #8a5a00;      /* its outline, and "new" bars */
  --chart-area: #e3ece9;        /* sparkline fill */
  /* Staff sidebar and public header */
  --header-bg: #0f2a26;
  --header-text: #ffffff;
  --header-link: #e6efec;
  --header-sub: #cfdcd8;
  --header-muted: #a9c2bb;
  --header-hover: rgb(255 255 255 / 0.08);
  --header-current: rgb(255 255 255 / 0.12);
  --header-divider: rgb(255 255 255 / 0.14);
  --header-divider-soft: #ffffff2e;
  --header-toggle-border: #ffffff99;
  --header-toggle-open: #ffffff1a;
  --header-badge-bg: #ffffff;
  --header-badge-text: #0f2a26;
  /* Dark sections of the public home page */
  --hero-bg: #0f2a26;
  --hero-text: #ffffff;
  --hero-lead: #e3ebe8;
  --hero-soft: #cbd8d4;
  --hero-card: #173b36;
  --hero-divider: #ffffff2e;
  /* Always white: the authenticator QR code needs a light quiet zone to scan */
  --qr-bg: #ffffff;
  /* Shadows */
  --shadow-card: 0 1px 2px rgb(15 42 38 / 0.05);
  --shadow-pop: 0 8px 24px rgb(15 42 38 / 0.16), 0 1px 3px rgb(15 42 38 / 0.1);
  --shadow-sticky: 0 2px 6px rgb(15 42 38 / 0.12);
  /* Print (always light) */
  --print-paper: #ffffff;
  --print-ink: #000000;
  --print-rule: #999999;
  --print-fill: #dddddd;

  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme: the same token names with values for dark surfaces. Deep
   green-tinted neutrals (not black), lighter surfaces for higher elevation,
   the amber accent kept, status colours re-tuned for dark backgrounds.
   The two blocks below must hold the same values (core/test_theme.py
   checks): one for "System" when the system prefers dark, one for "Dark".
   Screen only, so printing always uses the light values above. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-page: #0c1614;
    --surface-inset: #1b2a27;
    --surface-sunken: #111d1b;
    --surface: #152320;
    --surface-raised: #213430;
    --surface-input: #0f1a18;
    --surface-code: #0f1a18;
    --surface-hover: #22362f;
    --surface-band: #13251f;
    --topbar-bg: #111d1b;
    --segment-hover: rgb(255 255 255 / 0.06);
    --track: #2a3b37;
    --text: #e4ece9;
    --text-secondary: #bccbc6;
    --text-muted: #9fb2ab;
    --text-inverse: #ffffff;
    --text-on-accent: #0f2a26;
    --control-accent: #f2b63c;
    --border: #31443f;
    --border-subtle: #273834;
    --border-strong: #3f5550;
    --border-hover: #8fa49d;
    --border-input: #71877f;
    --border-ink: #a9bcb6;
    --button-border: #c9901b;
    --brand: #235a50;
    --brand-hover: #2b6b5f;
    --brand-mid: #84c9b7;
    --accent: #f2b63c;
    --accent-hover: #f5c662;
    --accent-border: #c9901b;
    --accent-text: #f2b63c;
    --accent-soft: #3a2d10;
    --focus: #f4f8f6;
    --focus-halo: #f2b63c;
    --success-fg: #86d9ab;
    --success-strong: #45b67c;
    --success-bg: #11301f;
    --success-bg-strong: #173f2a;
    --success-border: #2f7a52;
    --warning-fg: #f7cd84;
    --warning-text: #f1bd6a;
    --warning-strong: #d8902e;
    --warning-bg: #33250d;
    --warning-bg-soft: #2a1f0f;
    --warning-bg-faint: #241c10;
    --warning-bg-hover: #3a2b10;
    --internal-note-bg: #2c2312;
    --recheck-bg: #382d10;
    --recheck-border: #a88a2e;
    --danger-fg: #ffa293;
    --danger-strong: #ec6e60;
    --danger-solid: #b5362a;
    --on-danger: #ffffff;
    --danger-border: #ec6e60;
    --danger-bg: #3a1714;
    --danger-bg-faint: #2a1513;
    --danger-bg-hover: #461d19;
    --info-fg: #93c8f2;
    --info-strong: #92a6d4;
    --info-bg: #13263a;
    --neutral-strong: #8fa49d;
    --chart-1: #5cb8a5;
    --chart-2: #f2b63c;
    --chart-2-edge: #c9901b;
    --chart-area: #1d3a34;
    --header-bg: #0f2421;
    --header-text: #ffffff;
    --header-link: #e6efec;
    --header-sub: #cfdcd8;
    --header-muted: #a9c2bb;
    --header-hover: rgb(255 255 255 / 0.08);
    --header-current: rgb(255 255 255 / 0.12);
    --header-divider: rgb(255 255 255 / 0.14);
    --header-divider-soft: #ffffff2e;
    --header-toggle-border: #ffffff99;
    --header-toggle-open: #ffffff1a;
    --header-badge-bg: #e4ece9;
    --header-badge-text: #0f2a26;
    --hero-bg: #12322c;
    --hero-text: #ffffff;
    --hero-lead: #e3ebe8;
    --hero-soft: #cbd8d4;
    --hero-card: #1a443d;
    --hero-divider: #ffffff2e;
    --qr-bg: #ffffff;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.45);
    --shadow-pop: 0 8px 24px rgb(0 0 0 / 0.55), 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow-sticky: 0 2px 8px rgb(0 0 0 / 0.5);
  }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --surface-page: #0c1614;
    --surface-inset: #1b2a27;
    --surface-sunken: #111d1b;
    --surface: #152320;
    --surface-raised: #213430;
    --surface-input: #0f1a18;
    --surface-code: #0f1a18;
    --surface-hover: #22362f;
    --surface-band: #13251f;
    --topbar-bg: #111d1b;
    --segment-hover: rgb(255 255 255 / 0.06);
    --track: #2a3b37;
    --text: #e4ece9;
    --text-secondary: #bccbc6;
    --text-muted: #9fb2ab;
    --text-inverse: #ffffff;
    --text-on-accent: #0f2a26;
    --control-accent: #f2b63c;
    --border: #31443f;
    --border-subtle: #273834;
    --border-strong: #3f5550;
    --border-hover: #8fa49d;
    --border-input: #71877f;
    --border-ink: #a9bcb6;
    --button-border: #c9901b;
    --brand: #235a50;
    --brand-hover: #2b6b5f;
    --brand-mid: #84c9b7;
    --accent: #f2b63c;
    --accent-hover: #f5c662;
    --accent-border: #c9901b;
    --accent-text: #f2b63c;
    --accent-soft: #3a2d10;
    --focus: #f4f8f6;
    --focus-halo: #f2b63c;
    --success-fg: #86d9ab;
    --success-strong: #45b67c;
    --success-bg: #11301f;
    --success-bg-strong: #173f2a;
    --success-border: #2f7a52;
    --warning-fg: #f7cd84;
    --warning-text: #f1bd6a;
    --warning-strong: #d8902e;
    --warning-bg: #33250d;
    --warning-bg-soft: #2a1f0f;
    --warning-bg-faint: #241c10;
    --warning-bg-hover: #3a2b10;
    --internal-note-bg: #2c2312;
    --recheck-bg: #382d10;
    --recheck-border: #a88a2e;
    --danger-fg: #ffa293;
    --danger-strong: #ec6e60;
    --danger-solid: #b5362a;
    --on-danger: #ffffff;
    --danger-border: #ec6e60;
    --danger-bg: #3a1714;
    --danger-bg-faint: #2a1513;
    --danger-bg-hover: #461d19;
    --info-fg: #93c8f2;
    --info-strong: #92a6d4;
    --info-bg: #13263a;
    --neutral-strong: #8fa49d;
    --chart-1: #5cb8a5;
    --chart-2: #f2b63c;
    --chart-2-edge: #c9901b;
    --chart-area: #1d3a34;
    --header-bg: #0f2421;
    --header-text: #ffffff;
    --header-link: #e6efec;
    --header-sub: #cfdcd8;
    --header-muted: #a9c2bb;
    --header-hover: rgb(255 255 255 / 0.08);
    --header-current: rgb(255 255 255 / 0.12);
    --header-divider: rgb(255 255 255 / 0.14);
    --header-divider-soft: #ffffff2e;
    --header-toggle-border: #ffffff99;
    --header-toggle-open: #ffffff1a;
    --header-badge-bg: #e4ece9;
    --header-badge-text: #0f2a26;
    --hero-bg: #12322c;
    --hero-text: #ffffff;
    --hero-lead: #e3ebe8;
    --hero-soft: #cbd8d4;
    --hero-card: #1a443d;
    --hero-divider: #ffffff2e;
    --qr-bg: #ffffff;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.45);
    --shadow-pop: 0 8px 24px rgb(0 0 0 / 0.55), 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow-sticky: 0 2px 8px rgb(0 0 0 / 0.5);
  }
}

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

html { font-size: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding-block: 1.5rem 3rem; }
main:focus { outline: none; }

.wrap { width: 100%; max-width: 60rem; margin-inline: auto; padding-inline: 1rem; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.75rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; }

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

/* Visible focus for everything keyboard-reachable */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus-halo);
}

.skip-link {
  position: absolute; left: 0.5rem; top: -3rem;
  background: var(--accent); color: var(--text-on-accent);
  padding: 0.5rem 1rem; border-radius: var(--radius); z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header / footer */
.site-header { background: var(--header-bg); color: var(--header-text); }
.header-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1rem; padding-block: 0.75rem;
}
.site-header a, .site-header .link-button { color: var(--header-text); }
.site-header :focus-visible { outline-color: var(--header-text); }
.brand { font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.brand::before {
  content: ""; display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.4em;
  background: var(--accent); border-radius: 2px;
}
.nav { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0; padding: 0; }
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}

.site-footer { border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--text-secondary); }
.site-footer p { margin: 1rem 0; }

/* Panels */
.panel, .auth-page > form, .auth-page > section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.auth-page { max-width: 34rem; }
.hero h1 { font-size: 2rem; }
.lead { font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Messages */
.message { background: var(--surface); border-left: 4px solid var(--accent); padding: 0.6rem 0.9rem; margin: 0 0 1rem; }
.message-error { border-left-color: var(--danger-border); }

/* Forms */
form p, .field { margin: 0 0 1.1rem; }
label, legend { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.radio label, .field-checkbox label { display: inline; font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; min-width: 0; }
.radio { margin: 0.35rem 0; display: flex; gap: 0.5rem; align-items: flex-start; }
.radio input { margin-top: 0.3rem; flex: none; }
.field-checkbox { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.field-checkbox .errors { flex-basis: 100%; }
.field-checkbox input { margin-top: 0.3rem; flex: none; }
input[type="radio"], input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--control-accent); }

input[type="text"], input[type="email"], input[type="number"], input[type="password"],
input[type="tel"], input:not([type]), select, textarea {
  display: block; width: 100%; max-width: 100%;
  font: inherit; color: var(--text);
  background: var(--surface-input); border: 1px solid var(--border-input); border-radius: 6px;
  padding: 0.55rem 0.65rem;
}
textarea { resize: vertical; }
.has-error input, .has-error textarea, .has-error select { border-color: var(--danger-border); border-width: 2px; }
.req { color: var(--danger-fg); }
.help { margin: 0 0 0.3rem; color: var(--text-secondary); font-size: 0.9rem; }
.errors { list-style: none; margin: 0 0 0.35rem; padding: 0; color: var(--danger-fg); font-weight: 600; }
.errorlist { color: var(--danger-fg); font-weight: 600; padding-left: 1rem; }
.form-error-summary { color: var(--danger-fg); font-weight: 600; }
.notice { font-size: 0.9rem; color: var(--text-secondary); background: var(--surface-inset); padding: 0.75rem; border-radius: 6px; }

/* Honeypot: hidden from people, still in the HTML for bots. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--text-on-accent);
  border: 2px solid var(--button-border); border-radius: 6px;
  padding: 0.6rem 1.2rem; text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-hover); }
.button-secondary { background: var(--surface); color: var(--text); border-color: var(--border-ink); }
.button-secondary:hover { background: var(--surface-inset); }
.site-header .link-button { border: 0; background: none; padding: 0; font-weight: 400; }

.q-section { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 1rem; }

/* Staff tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--surface-inset); }
.status { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-inset); border: 1px solid var(--border); white-space: nowrap; }
.status-new { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.flag { display: inline-block; font-size: 0.8rem; font-weight: 600; color: var(--on-danger); background: var(--danger-solid); border-radius: 4px; padding: 0 0.35rem; }
.details { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: 0.4rem 1rem; margin: 0; }
.details dt { font-weight: 600; }
.details dd { margin: 0; }
.pre { white-space: pre-wrap; }
.pagination { display: flex; gap: 1rem; margin-top: 1rem; }

@media (max-width: 36rem) {
  h1 { font-size: 1.45rem; }
  .details { grid-template-columns: 1fr; }
  .details dd { margin-bottom: 0.5rem; }
  .panel { padding: 1rem; }
}
.auth-page img { display: block; max-width: 14rem; height: auto; background: var(--qr-bg); margin-bottom: 1rem; }

/* Milestone 2: companies, documents, portal */
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.panel-head h1 { margin: 0; }
input[type="file"], input[type="date"] {
  display: block; max-width: 100%; font: inherit; color: var(--text);
  background: var(--surface-input); border: 1px solid var(--border-input); border-radius: 6px; padding: 0.45rem 0.55rem;
}
.button-small {
  font-size: 0.9rem; padding: 0.25rem 0.7rem; background: var(--surface); color: var(--text); border-color: var(--border-ink); border-width: 1px; white-space: nowrap;
}
.button-small:hover { background: var(--surface-inset); }
.button-danger { color: var(--danger-fg); border-color: var(--danger-border); }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.status-active { background: var(--success-bg-strong); border-color: var(--success-border); }
.status-closed, .status-revoked, .status-expired { color: var(--text-secondary); }
.status-onboarding, .status-pending { background: var(--accent-soft); border-color: var(--accent); }
.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin-bottom: 1rem; }
.filter-form .field { margin: 0; min-width: min(100%, 18rem); }
.details-json { font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; }

/* Milestone 3: onboarding checklist (technicians, often at phone width) */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 0.4rem 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.plain-list li:first-child { border-top: 0; }
.attachment-list { margin-top: 0.5rem; font-size: 0.95rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0 0 1rem; }
.tabs [aria-current="page"] { font-weight: 700; text-decoration-thickness: 3px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.75rem; padding: 0; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.75rem; font-size: 0.9rem; background: var(--surface); }
.chip.band-low { border-color: var(--warning-strong); color: var(--warning-text); font-weight: 600; }
.chip.band-mid { font-weight: 600; }
.chip.band-high { border-color: var(--success-strong); color: var(--success-fg); font-weight: 600; }
.phase-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.25rem 0.75rem; }
.phase-head h2, .phase-head h3 { margin: 0 0 0.5rem; }
.count { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-size: 0.9rem; }
.bar { height: 0.6rem; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--success-strong); }
.live-status { min-height: 1.5em; margin-top: 0.5rem; font-weight: 600; }
.live-status-error { color: var(--danger-fg); }
.steps { list-style: none; margin: 0; padding: 0; }
.step { border-top: 1px solid var(--border); padding: 0.75rem 0; }
.step:first-child { border-top: 0; }
.step form { margin: 0; }
.step-main { display: flex; gap: 0.6rem; align-items: flex-start; }
.step-state { flex: none; min-width: 5.5rem; text-align: center; font-size: 0.8rem; font-weight: 600; border-radius: 4px; padding: 0.1rem 0.4rem; border: 1px solid var(--border); background: var(--surface-inset); }
.step-state-done { background: var(--success-bg-strong); border-color: var(--success-border); }
.step-state-skipped, .step-state-not_applicable { color: var(--text-secondary); }
.step-done .step-title, .step-not_applicable .step-title { color: var(--text-secondary); text-decoration: line-through; }
.step-skipped .step-title { color: var(--text-secondary); }
.step-meta { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-secondary); }
.step-body { margin: 0.35rem 0 0; }
.step .row-actions { margin-top: 0.5rem; }
.button-tick { background: var(--accent); }
.button-tick:hover { background: var(--accent-hover); }
.step-notes { margin-top: 0.5rem; }
.step-notes summary { cursor: pointer; font-size: 0.9rem; }
.step-notes textarea { margin-bottom: 0.4rem; }
.tag { font-size: 0.75rem; font-weight: 600; border-radius: 4px; padding: 0 0.4rem; border: 1px solid var(--warning-strong); color: var(--warning-text); white-space: nowrap; }
.person-group { border-top: 2px solid var(--border); padding-top: 0.75rem; margin-top: 0.75rem; }
.person-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.75rem; }
.person-row legend { padding: 0 0.25rem; }
.person-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0 1rem; }
.role { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.prompt { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: flex-start; background: var(--surface-inset); border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.75rem; margin-bottom: 0.6rem; }
.prompt p { margin: 0; flex: 1 1 14rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; overflow-wrap: anywhere; }
.prompt h3 { flex-basis: 100%; margin: 0; font-size: 0.95rem; }
.status-in_progress, .status-planned { background: var(--accent-soft); border-color: var(--accent); }
.status-handed_over { background: var(--success-bg-strong); border-color: var(--success-border); }
.status-cancelled { color: var(--text-secondary); }
details.panel > summary { cursor: pointer; font-weight: 600; }
@media (max-width: 36rem) {
  .step-main { flex-direction: column; gap: 0.25rem; }
  .step-state { min-width: 0; }
  .step .row-actions button { flex: 1 1 auto; padding-block: 0.5rem; }
}
.live-status:empty { min-height: 0; margin: 0; }
.live-status + .role { border-top: 0; margin-top: 0.5rem; padding-top: 0; }

/* Milestone 4: advice tickets */
.tier { display: inline-block; font-size: 0.8rem; font-weight: 600; border-radius: 4px; padding: 0 0.4rem; border: 1px solid var(--border); white-space: nowrap; }
.tier-priority { border-color: var(--border-ink); background: var(--accent); color: var(--text-on-accent); }
.status-ticket-open { background: var(--accent-soft); border-color: var(--accent); }
.status-ticket-answered { background: var(--success-bg-strong); border-color: var(--success-border); }
.status-ticket-closed { color: var(--text-secondary); }
.allowance { margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.allowance .help { margin: 0; }
.tier-choice .tier-option { border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.75rem; margin-bottom: 0.6rem; display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; align-items: start; }
.tier-option input { margin-top: 0.3rem; }
.tier-option label { margin: 0; }
.tier-option .help { grid-column: 2; margin: 0; }
.tier-option-disabled { background: var(--surface-inset); }
.tier-option-disabled label { color: var(--text-secondary); }
.thread { list-style: none; margin: 0 0 1.25rem; padding: 0; }
.msg { border-left: 4px solid var(--border); padding: 0.4rem 0 0.4rem 0.75rem; margin-bottom: 0.9rem; overflow-wrap: anywhere; }
.msg-staff { border-left-color: var(--success-strong); }
.msg-internal { border-left-color: var(--warning-strong); background: var(--internal-note-bg); }
.msg-meta { margin: 0 0 0.25rem; display: flex; flex-wrap: wrap; gap: 0.1rem 0.6rem; align-items: baseline; font-size: 0.9rem; color: var(--text-secondary); }
.msg-meta strong { color: var(--text); }
.note-form { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1rem; }
.ticket-table a { overflow-wrap: anywhere; }
@media (max-width: 36rem) {
  .ticket-table { font-size: 0.9rem; }
  .thread .msg { padding-left: 0.5rem; }
}

/* Milestone 5: targets, dashboard */
.target { display: inline-block; font-size: 0.8rem; font-weight: 700; border-radius: 4px; padding: 0 0.4rem; border: 1px solid var(--border); white-space: nowrap; }
.target-icon { font-weight: 700; }
.target-at_risk { background: var(--accent-soft); border-color: var(--warning-strong); color: var(--warning-fg); }
.target-breached { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-danger); }
.target-on_track { color: var(--text-secondary); font-weight: 600; }
.target-when { display: block; font-size: 0.85rem; color: var(--text-secondary); }
tr.row-at_risk td:first-child { box-shadow: inset 4px 0 0 var(--warning-strong); }
tr.row-at_risk { background: var(--warning-bg-soft); }
tr.row-breached td:first-child { box-shadow: inset 4px 0 0 var(--danger-border); }
tr.row-breached { background: var(--danger-bg); }
.notice-guarantee { border-left: 4px solid var(--accent); color: var(--text); }
.notice-closed { border-left: 4px solid var(--text-secondary); color: var(--text); margin-bottom: 1rem; }
.notice-closed p { margin: 0; }

/* Staff productivity: navigation groups, header search, my work, timeline */
.header-search { display: flex; gap: 0.4rem; align-items: center; margin: 0; }
.header-search input[type="search"] { width: 12rem; max-width: 100%; padding: 0.3rem 0.5rem; }
input[type="search"] {
  display: block; width: 100%; max-width: 100%; font: inherit; color: var(--text);
  background: var(--surface-input); border: 1px solid var(--border-input); border-radius: 6px; padding: 0.55rem 0.65rem;
}
.site-header .header-search .button-small { background: var(--accent); color: var(--text-on-accent); }
.search-group h2 { margin-top: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-entry { border-left: 4px solid var(--border); padding: 0.35rem 0 0.35rem 0.75rem; margin-bottom: 0.6rem; overflow-wrap: anywhere; }
.timeline-entry p { margin: 0; }
.timeline-when { font-size: 0.85rem; color: var(--text-secondary); }
.timeline-title { font-weight: 600; }
.timeline-ticket { border-left-color: var(--success-strong); }
.timeline-job { border-left-color: var(--accent); }
.timeline-enquiry, .timeline-company { border-left-color: var(--border-ink); }
.timeline-people, .timeline-survey { border-left-color: var(--info-strong); }
.timeline-allowance, .timeline-document { border-left-color: var(--warning-strong); }
@media (max-width: 36rem) {
  .header-search { width: 100%; }
  .header-search input[type="search"] { flex: 1; width: auto; }
}

/* ---------------------------------------------------------------------
   Shared components (visual QA). Every page uses these; prefer them to
   page-specific rules.
     .panel             card
     .panel-head        page/section header: heading + actions on one row
     .table-scroll      wide table scrolls inside its own box
     .field             form row (includes/field.html)
     .button / .button-secondary / .button-small / .button-danger
     .status            status badge (always text, never colour alone)
     .empty             empty state: what it means and what to do next
     .message-*         alerts after an action (success, info, error)
   --------------------------------------------------------------------- */

/* Headings: a heading that starts a card sits at the top of it. */
.panel > h2:first-child, .panel > h3:first-child, .panel-head h2, .panel-head h3 { margin-top: 0; }
.panel-head > :last-child:not(h1):not(h2):not(h3) { margin-bottom: 0; }
h1 .status, h2 .status { font-size: 0.9rem; font-weight: 600; vertical-align: middle; }

/* Wide tables scroll sideways inside their own box, never the page.
   position: relative keeps visually-hidden captions inside the box. */
.table-scroll { position: relative; max-width: 100%; }
.table-scroll:focus-visible { outline-offset: 0; }
caption { text-align: left; font-weight: 600; padding: 0 0 0.4rem; }

/* Alerts after an action */
.message-success { border-left-color: var(--success-strong); }
.message-info { border-left-color: var(--text-secondary); }
.message-warning { border-left-color: var(--warning-strong); }
.message-error { border-left-color: var(--danger-border); }
.message { border-radius: 0 6px 6px 0; }
.message-success::before { content: "\2713  "; font-weight: 700; color: var(--success-fg); }
.message-error::before { content: "\2715  "; font-weight: 700; color: var(--danger-fg); }

/* Empty states */
.empty { color: var(--text-secondary); background: var(--surface-inset); border: 1px dashed var(--border); border-radius: 6px; padding: 0.75rem 1rem; }

/* Buttons */
.button-danger:hover { background: var(--danger-bg); }
button:disabled, .button[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.actions form { margin: 0; }

/* Form rows */
.field-checkbox label { flex: 1 1 0; min-width: 12rem; }
input[type="date"], input[type="time"] { padding: 0.55rem 0.65rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.5rem; }

/* Header: search sits at the right; nothing pokes out at phone width. */
.header-search { margin-left: auto; }
.header-search input[type="search"] { min-width: 0; }
.header-search .button-small { flex: none; }


/* Phones: everything you tap is at least 44px high. */
@media (max-width: 36rem) {
  .header-inner { gap: 0.25rem 1rem; padding-block: 0.5rem; }
  .nav { gap: 0 0.9rem; }
  .nav a, .nav summary, .nav .link-button { display: inline-flex; align-items: center; min-height: 44px; }
  .header-search { margin: 0 0 0.25rem; }
  .header-search input[type="search"], .header-search .button-small { min-height: 44px; }
  button, .button, .button-small, details > summary { min-height: 44px; }
  .button, .button-small { display: inline-flex; align-items: center; justify-content: center; }
  .button-small { padding-inline: 0.8rem; }
  .tabs a { display: inline-flex; align-items: center; min-height: 44px; }
  select, input[type="text"], input[type="email"], input[type="number"], input[type="password"],
  input[type="tel"], input[type="date"], input:not([type]) { min-height: 44px; }
  input[type="radio"], input[type="checkbox"] { width: 1.4rem; height: 1.4rem; }
  .radio label, .field-checkbox label { padding-block: 0.3rem; }
  .table-scroll { margin-inline: -0.25rem; padding-inline: 0.25rem; }
}

/* Printing a questionnaire result or a ticket: content only. */
@media print {
  .site-header nav, .site-footer, .skip-link, .header-search, form, .actions, .row-actions,
  .saved-reply-picker, .messages, .button, .note-actions, nav { display: none !important; }
  body { background: var(--print-paper); display: block; font-size: 11pt; }
  .site-header { background: none; border-bottom: 2px solid var(--print-ink); margin-bottom: 1rem; }
  .site-header a { color: var(--print-ink); text-decoration: none; }
  main { padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; margin-bottom: 1rem; }
  a { text-decoration: none; }
  .status, .tier, .tag, .target { border: 1px solid var(--print-ink) !important; background: none !important; color: var(--print-ink) !important; }
  .msg, .timeline-entry { break-inside: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* allauth pages (sign in, password reset, authenticator set-up): one card,
   the same form rows and buttons as the rest of the site. The layout is
   templates/allauth/layouts/base.html; elements in templates/allauth/elements/. */
main.auth-page {
  flex: 0 0 auto; margin-block: 1.5rem auto; padding: 1.5rem 1.25rem;
  width: calc(100% - 2rem); max-width: 34rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.auth-page > form, .auth-page > section { background: none; border: 0; padding: 0; margin-bottom: 1rem; }
.auth-page .auth-section { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.auth-page .auth-section h2 { margin-top: 0; font-size: 1.15rem; }
.auth-page .rule { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.auth-page h2 { font-size: 1.15rem; }
.auth-page ol { padding-left: 1.25rem; }
.auth-page img { border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem; }
.auth-page input[readonly] { background: var(--surface-inset); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.auth-page textarea[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.05em; }
@media (max-width: 36rem) {
  main.auth-page { width: calc(100% - 1rem); padding: 1.25rem 1rem; margin-block: 0.75rem auto; }
}
@media (max-width: 36rem) {
  .brand { display: inline-flex; align-items: center; min-height: 44px; }
  .radio { margin: 0; align-items: center; }
  .radio label, .field-checkbox label { flex: 1 1 0; padding-block: 0.6rem; min-height: 44px; }
  .field-checkbox { align-items: center; }
}
.message-success, .message-error { display: flex; gap: 0.4rem; align-items: baseline; }
.message p { margin: 0; }
.message p + p { margin-top: 0.35rem; }
.details { margin-bottom: 1rem; }
.panel form + .actions, .panel .details + .actions { margin-top: 1.25rem; }
/* Danger buttons are always red on white (red on amber is only 4:1). */
.button-danger, .button.button-danger { background: var(--surface); color: var(--danger-fg); border-color: var(--danger-border); }
.button-danger:hover, .button.button-danger:hover { background: var(--danger-bg); }
@media (max-width: 36rem) {
  input[type="file"] { min-height: 44px; }
  .panel-head > a:not(.button), .plain-list li > a:first-child, .search-group li > a:first-child { display: inline-block; padding-block: 0.65rem; }
  .pagination a { display: inline-block; padding-block: 0.65rem; }
}
@media (max-width: 36rem) {
  /* Narrow columns become unreadable; let wide tables scroll instead. */
  .table-scroll td, .table-scroll th { min-width: 6.5rem; }
  .table-scroll td:first-child:not(:has(a)), .table-scroll th:first-child { min-width: 4rem; }
}
@media (max-width: 36rem) {
  .tier-choice .tier-option { align-items: center; }
  .tier-option label { padding-block: 0.6rem; }
}
/* Page/section header: heading on the left, every action together on the right. */
.panel-head { justify-content: flex-start; }
.panel-head > h1, .panel-head > h2, .panel-head > h3 { margin-right: auto; }
.auth-page input[readonly] { font-size: 0.9rem; letter-spacing: 0; }

/* ---------------------------------------------------------------------
   Header and phone menu (templates/base.html).
   From 50rem up: the "Menu" toggle is hidden and .nav-panel is
   display: contents, so the nav sits in the header row itself: brand on
   the left, nav on the right. Staff get the sidebar instead (shell.css).
   Below 50rem: brand and "Menu" on one row; the panel (search, then
   the nav as a list of 44px rows) shows only while Menu is open. No
   JavaScript needed; static/js/nav.js adds Escape / click-away /
   tab-out closing.
   --------------------------------------------------------------------- */
.menu-toggle > summary {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px;
  padding: 0 0.75rem; border: 1px solid var(--header-toggle-border); border-radius: 6px;
  cursor: pointer; list-style: none; font-weight: 600; color: var(--header-text);
}
.menu-toggle > summary::-webkit-details-marker { display: none; }
.menu-toggle[open] > summary { background: var(--header-toggle-open); }
.menu-icon { fill: currentColor; flex: none; }
.nav a[aria-current="page"] { text-decoration-thickness: 3px; text-decoration-color: var(--accent); }
.nav-sub { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

@media (min-width: 50.0625rem) {
  .menu-toggle { display: none; }
  .nav-panel { display: contents; }
}

@media (max-width: 50rem) {
  .header-inner { flex-wrap: wrap; gap: 0.5rem 1rem; padding-block: 0.5rem; }
  .brand { display: inline-flex; align-items: center; min-height: 44px; }
  .menu-toggle { margin-left: auto; }
  .menu-toggle:not([open]) + .nav-panel { display: none; }
  .nav-panel { flex-basis: 100%; min-width: 0; padding-bottom: 0.5rem; }
  .header-search input[type="search"] { min-width: 0; }
  .header-search { width: 100%; margin: 0 0 0.5rem; }
  .header-search input[type="search"] { flex: 1; width: auto; min-height: 44px; }
  .header-search .button-small { min-height: 44px; }
  .nav { flex-direction: column; flex-wrap: nowrap; gap: 0; }
  .nav > li { border-top: 1px solid var(--header-divider-soft); }
  .nav a, .nav summary, .nav .link-button { display: flex; align-items: center; min-height: 44px; width: 100%; }
  .nav .inline-form { display: block; }
}

@media print {
  .menu-toggle { display: none !important; }
}

/* ---------------------------------------------------------------------
   Public home (templates/core/home.html, signed-out visitors only).
   Decoration is CSS only: the amber square from the brand mark.
   --------------------------------------------------------------------- */
main.home { padding-top: 1.25rem; }
.home h2 { font-size: 1.5rem; margin: 0 0 0.5rem; }
.home h3 { font-size: 1.1rem; margin: 0 0 0.4rem; }
.home p { margin: 0 0 0.75rem; }
.home-section { margin-top: 2.75rem; scroll-margin-top: 1rem; }
.home-intro { color: var(--text-secondary); font-size: 1.05rem; max-width: 42rem; }
.home-note { color: var(--text-secondary); font-size: 0.95rem; max-width: 46rem; margin-top: 1rem !important; }

/* Dark sections: white text, white focus ring. */
.home-hero, .home-closing { background: var(--hero-bg); color: var(--hero-text); border-radius: var(--radius); }
.home-hero a:not(.button), .home-closing a:not(.button) { color: var(--hero-text); }
.home-hero :focus-visible, .home-closing :focus-visible { outline-color: var(--hero-text); }

.home-hero {
  display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem 2rem;
  padding: 2rem; position: relative; overflow: hidden;
}
.home-hero::after {
  content: ""; position: absolute; right: -2.5rem; top: -2.5rem; width: 8rem; height: 8rem;
  border: 1.25rem solid var(--accent); border-radius: 0.75rem; opacity: 0.18; pointer-events: none;
}
.home-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.85rem;
}
.home-eyebrow::before { content: ""; width: 0.7em; height: 0.7em; background: var(--accent); border-radius: 2px; }
.home-hero h1 { font-size: 2.25rem; line-height: 1.15; margin-bottom: 1rem; max-width: 22ch; }
.home-hero .lead { font-size: 1.15rem; color: var(--hero-lead); }
.home-hero .actions { margin: 1.25rem 0 1rem; }
.home-hero .button { border-color: var(--accent); }
.home-hero .button-secondary { border-color: var(--hero-text); }
.home-where { color: var(--hero-soft); font-size: 0.95rem; }
.home-hero-card {
  align-self: start; background: var(--hero-card); border: 1px solid var(--hero-divider); border-radius: var(--radius);
  padding: 1.25rem; position: relative; z-index: 1;
}
.home-hero-card h2 { font-size: 1.1rem; color: var(--accent); }

.home-ticks { list-style: none; margin: 0; padding: 0; }
.home-ticks li { position: relative; padding: 0.3rem 0 0.3rem 1.4rem; }
.home-ticks li::before {
  content: ""; position: absolute; left: 0; top: 0.75em; width: 0.6em; height: 0.6em;
  background: var(--accent); border-radius: 2px;
}

.home-grid { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
.home-grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.home-grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.home-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.home-card p:last-child { margin-bottom: 0; }
.home-card-accent { border-top: 4px solid var(--accent); }
.home-figure { font-weight: 700; font-size: 1.1rem; }

.home-steps { list-style: none; counter-reset: step; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 0; }
.home-steps li {
  counter-increment: step; position: relative; padding: 0 0 1.25rem 3.25rem;
  border-left: 2px solid var(--border); margin-left: 1.1rem;
}
.home-steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.home-steps li::before {
  content: counter(step); position: absolute; left: -1.15rem; top: -0.2rem;
  width: 2.3rem; height: 2.3rem; display: grid; place-items: center;
  background: var(--accent); color: var(--text-on-accent); font-weight: 700; border-radius: 6px;
  border: 2px solid var(--button-border);
}
.home-steps h3 { padding-top: 0.15rem; }
.home-steps p { max-width: 44rem; }

.home-package { display: flex; flex-direction: column; border-top: 4px solid var(--border-ink); }
.home-package .home-ticks { margin-bottom: 1rem; }
.home-suits { color: var(--text-secondary); }
.home-package-cta { margin-top: auto !important; }

.home-band { background: var(--surface-band); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.home-plain li { border-top: 2px solid var(--border-ink); padding-top: 0.75rem; }
.home-plain p { margin: 0; }

.home-promise {
  margin-top: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-left: 6px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 1rem 1.25rem;
}
.home-promise p { margin: 0; }

.home-readiness {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
}
.home-readiness > div { flex: 1 1 24rem; }
.home-readiness > div p { margin: 0; }
.home-readiness > p { margin: 0; }

.home-faq { max-width: 46rem; }
.home-faq h3 { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.home-faq h3:first-child { border-top: 0; padding-top: 0; margin-top: 0.5rem; }

.home-closing { padding: 2rem; }
.home-closing p { color: var(--hero-lead); max-width: 40rem; }
.home-closing .actions { margin: 1.25rem 0 0; }
.home-closing .button-secondary { border-color: var(--hero-text); }

@media (max-width: 50rem) {
  .home-hero { grid-template-columns: 1fr; padding: 1.5rem; }
}
@media (max-width: 36rem) {
  main.home { padding-top: 0.75rem; }
  .home-hero, .home-closing { padding: 1.25rem 1rem; }
  .home-hero h1 { font-size: 1.65rem; }
  .home-hero .lead { font-size: 1.05rem; }
  .home-hero .actions .button, .home-closing .actions .button { flex: 1 1 100%; }
  .home-hero::after { display: none; }
  .home-section { margin-top: 2.25rem; }
  .home h2 { font-size: 1.3rem; }
  .home-band, .home-readiness { padding: 1.25rem 1rem; }
  .home-steps li { padding-left: 2.5rem; margin-left: 1rem; }
  .home-steps li::before { width: 2rem; height: 2rem; left: -1rem; }
  .home-readiness > p, .home-readiness .button { width: 100%; }
}

/* Public enquiry page: "What happens next" box. */
.next-steps { background: var(--surface-inset); border-left: 4px solid var(--accent); border-radius: 0 6px 6px 0; padding: 0.75rem 1rem; margin: 0 0 1.25rem; }
.next-steps h2 { margin-top: 0; font-size: 1.1rem; }
.next-steps ol { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.next-steps p { margin: 0; }

/* ---------------------------------------------------------------------
   Onboarding, client journeys and staff office additions (audit). Built
   on the shared components above: .panel, .panel-head, .empty, .status,
   .button*, .table-scroll; phone tap targets come from the shared phone
   rule. Job pages also load css/ticket-tools.css (.job-page, the sticky
   .job-progress-bar with its "Next step" link).
   --------------------------------------------------------------------- */
/* Client-facing journeys: home choices, questionnaire result, authenticator set-up, portal "What happens next" */
.choice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.choice-list li { border-top: 1px solid var(--border); padding-top: 1rem; }
.choice-list li:first-child { border-top: 0; padding-top: 0; }
.choice-list p { margin: 0.5rem 0 0; }
.phase-list { padding-left: 1.25rem; }
.phase-list li { margin-bottom: 0.6rem; }
.phase-list .help { display: block; margin: 0; }
.notice h2 { font-size: 1.05rem; margin: 0 0 0.5rem; color: var(--text); }
.notice p { margin: 0 0 0.5rem; }
.notice p:last-child { margin-bottom: 0; }
.setup-help h2 { font-size: 1.1rem; }
.setup-key { background: var(--surface-inset); border-radius: 6px; padding: 0.75rem; margin: 1rem 0; }
.setup-key p { margin: 0 0 0.5rem; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.key { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.05em; word-break: break-all; user-select: all; }
.auth-page .qr { max-width: 12rem; }
.continue { margin-top: 1.5rem; }
.continue .button { font-size: 1.1rem; padding: 0.7rem 1.25rem; }
@media (max-width: 36rem) {
  .continue .button, .setup-key .button { min-height: 2.75rem; }
}

/* Onboarding checklist content (audit-engine): step guidance, setup prompts,
   skip reasons, re-check after rewording, unsaved notes, Prompts page print */
.step-how { margin-top: 0.4rem; }
.step-how summary { cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.step-how-count { font-weight: 400; color: var(--text-secondary); }
.step-how .step-body { margin: 0.4rem 0 0.6rem; line-height: 1.55; }
.body-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-secondary); }
.body-label-say { color: var(--info-fg); }
.body-label-check { color: var(--success-fg); }
.body-label-watch-for { color: var(--warning-text); }
.setup-prompt { border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.75rem; margin: 0.75rem 0; }
.setup-prompt-title { margin: 0 0 0.2rem; font-size: 1rem; }
.setup-prompt-meta { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--text-secondary); }
.setup-prompt-meta span { display: block; }
.setup-prompt .prompt { margin-bottom: 0.4rem; }
.setup-prompt-result { margin: 0; font-size: 0.9rem; }
.phase-prompts { margin-bottom: 0.75rem; }
.prompt h4 { flex-basis: 100%; margin: 0; font-size: 0.95rem; }
.step-skip { display: inline-block; }
.step-skip > summary { list-style: none; cursor: pointer; display: inline-block; font-size: 0.9rem; font-weight: 600; border: 1px solid var(--border-ink); border-radius: var(--radius); padding: 0.3rem 0.75rem; background: var(--surface); }
.step-skip > summary::-webkit-details-marker { display: none; }
.step-skip[open] { display: block; width: 100%; margin-top: 0.4rem; }
.step-skip textarea { margin-bottom: 0.4rem; }
.step-reason { margin: 0.35rem 0 0; font-size: 0.9rem; }
.step-recheck { background: var(--warning-bg-soft); box-shadow: inset 4px 0 0 var(--warning-strong); padding-left: 0.75rem; }
.recheck-notice { margin: 0.4rem 0 0; font-weight: 600; color: var(--warning-fg); }
.unsaved-note { border: 2px solid var(--danger-border); border-radius: var(--radius); padding: 0.5rem 0.75rem; margin-top: 0.5rem; }
.unsaved-note .saved-note { margin: 0 0 0.4rem; font-size: 0.9rem; }
.unsaved-label { color: var(--danger-fg); font-weight: 700; }
.step-person { font-weight: 600; }
@media (max-width: 36rem) {
  .step-skip > summary { padding-block: 0.5rem; }
}
@media print {
  .no-print, .prompts-page [data-copy], .prompts-page .live-status { display: none !important; }
  .prompts-page { max-width: none; padding: 0; }
  .prompts-page .panel { border: 0; box-shadow: none; padding: 0; margin: 0 0 1rem; }
  .prompts-page .prompt { background: none; border: 1px solid var(--print-rule); break-inside: avoid; }
  .prompts-page .prompt p { font-size: 10pt; }
  .prompts-page .setup-prompt, .prompts-page h3, .prompts-page h4 { break-inside: avoid; break-after: avoid-page; }
  .prompts-page .setup-prompt { break-after: auto; }
  .prompts-page a { text-decoration: none; }
}

/* Staff area: company page jump links and tap-to-call links */
.jump-links { margin: 0 0 1rem; }
.jump-links .chip { display: inline-block; padding: 0.35rem 0.85rem; }
.tap-link { display: inline-block; padding: 0.15rem 0; }
@media (max-width: 36rem) {
  .tap-link { min-height: 2.75rem; line-height: 2.4rem; }
}

/* Navigation count badges (core/context_processors.py) */
.nav-badge { display: inline-block; min-width: 1.35rem; padding: 0 0.4rem; border-radius: 999px; background: var(--header-badge-bg); color: var(--header-badge-text); font-size: 0.8rem; font-weight: 700; text-align: center; line-height: 1.35rem; }
.nav-badge-alert { background: var(--accent); }
tr.row-needs-conversation { background: var(--accent-soft); }
tr.row-needs-conversation td:first-child { box-shadow: inset 4px 0 0 var(--warning-strong); font-weight: 600; }
.next-action { border-left: 4px solid var(--accent); color: var(--text); }


/* Technician on site (checklist agent): phone checklist (sticky progress bar,
   phase and people indexes, collapsible phases, people and prompts), site
   card, job record, visit brief, hand-over page. */
.phase-index, .people-index { list-style: none; margin: 0; padding: 0; }
.phase-index li, .people-index li { display: flex; flex-wrap: wrap; gap: 0 0.5rem; align-items: center; border-top: 1px solid var(--border); }
.phase-index li:first-child, .people-index li:first-child { border-top: 0; }
.phase-index a, .people-index a { display: inline-flex; align-items: center; min-height: 2.75rem; font-weight: 600; margin-right: auto; }
.people-index { margin-bottom: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 0.75rem; }
.people-index .help { margin: 0; }
.person-done a { color: var(--text-secondary); }
.done-tick { color: var(--success-fg); font-weight: 700; }
.done-tick[hidden] { display: none; }
.show-filter { margin: 0.5rem 0 0; }
.show-filter a, .show-filter strong { display: inline-block; padding-block: 0.6rem; }
details.phase > summary, details.person-group > summary { cursor: pointer; list-style: none; align-items: center; min-height: 2.75rem; }
details.phase > summary::-webkit-details-marker, details.person-group > summary::-webkit-details-marker { display: none; }
details.phase > summary h2, details.person-group > summary h3 { margin: 0.25rem 0; }
details.phase > summary h2::before, details.person-group > summary h3::before { content: "\25B8\00A0"; display: inline-block; width: 1.1em; color: var(--text-secondary); }
details.phase[open] > summary h2::before, details.person-group[open] > summary h3::before { content: "\25BE\00A0"; }
details.phase[open] > summary { margin-bottom: 0.5rem; }
.step-feedback { margin: 0.4rem 0 0; font-weight: 600; font-size: 0.9rem; }
.step-feedback-error { color: var(--danger-fg); }
.step-feedback[hidden] { display: none; }
.setup-prompt-collapsible > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.5rem; min-height: 2.75rem; }
.setup-prompt-collapsible > summary .setup-prompt-title { font-weight: 600; }
.setup-prompt-who { font-size: 0.85rem; color: var(--text-secondary); }
.setup-prompt-tools { margin: 0.25rem 0 0.4rem; }
.draft-note { margin: 0 0 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--warning-text); }
.step-help-link { font-weight: 600; }
@media (max-width: 36rem) {
  .step-notes > summary, .step-how > summary { display: flex; align-items: center; }
  .step-skip > summary { display: inline-flex; align-items: center; }
}
@media print {
  .job-progress-bar, .checklist-index, .step-form .row-actions, [data-copy] { display: none !important; }
}
.site-card .details { margin-bottom: 0.5rem; }
.site-contact { display: inline-block; }
.site-more { margin-top: 0.5rem; }
.site-more > summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.5rem; }
.site-flagged { background: var(--accent-soft); border-left: 4px solid var(--warning-strong); padding: 0.4rem 0.75rem; margin: 0.5rem 0; border-radius: 4px; }
.site-flagged p, .site-flagged ul { margin: 0.2rem 0; }
.site-flagged .help { display: block; margin: 0; }
.handover-page h3 { margin-top: 1rem; }
.handover-label { margin: 0.5rem 0 0.2rem; font-weight: 600; }
.handover-page ul { margin-top: 0.2rem; }
.paste-people { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.75rem; margin: 1rem 0; background: var(--surface-inset); }
.paste-people > summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.paste-people textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
.paste-problems li { margin-bottom: 0.25rem; }
.step-outcome { margin-top: 0.5rem; padding: 0.4rem 0.6rem; border: 1px dashed var(--border); border-radius: 6px; background: var(--surface-inset); }
.step-outcome label { font-weight: 600; font-size: 0.9rem; display: block; }
.step-outcome textarea { margin: 0.2rem 0 0.4rem; min-height: 2.75rem; }
.step-outcome-readonly { margin: 0.35rem 0 0; }
.record-list { margin: 0; }
.record-list dt { font-weight: 600; border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.5rem; }
.record-list dt:first-child { border-top: 0; margin-top: 0; }
.record-list dd { margin: 0.2rem 0 0.3rem; }
.record-list dd p { margin: 0.15rem 0; }
.record-missing { color: var(--warning-text); font-style: italic; }
.record-text textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
@media print {
  .no-print, [data-print] { display: none !important; }
  .record-page .panel, .brief-page .panel { border: 0; box-shadow: none; padding: 0; margin-bottom: 0.75rem; }
  .record-phase { break-inside: auto; }
  .record-list dt { break-after: avoid; }
}
.brief-steps { list-style: none; margin: 0; padding: 0; }
.brief-steps li { border-top: 1px solid var(--border); padding: 0.35rem 0; }
.brief-steps li:first-child { border-top: 0; }
.brief-steps .step-state { display: inline-block; min-width: 5.5rem; margin-right: 0.4rem; }
@media print {
  .brief-page .site-more > summary { list-style: none; }
  .brief-page .site-more > summary::-webkit-details-marker { display: none; }
  .brief-page .site-card .maps-link { display: none; }
  .brief-page .table-scroll { overflow: visible; }
  .brief-page table { font-size: 9pt; }
  .brief-section { break-inside: avoid-page; }
  .brief-page h2 { font-size: 13pt; margin: 0.6rem 0 0.3rem; }
  .brief-page { font-size: 10pt; }
}
.people-index .count, details.person-group > summary .count, details.phase > summary .count { margin-left: auto; white-space: nowrap; }
[data-copy][hidden], [data-print][hidden] { display: none !important; }
.step-how > summary, .step-notes > summary { gap: 0 0.3rem; }
.handover-list > summary { cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; }
.handover-page li { margin-bottom: 0.3rem; }

/* ===== Workflow: steps waiting to be re-confirmed (review S8) ===== */
.step-state-recheck { background: var(--recheck-bg); border-color: var(--recheck-border); }

/* ---- Outcomes recorded under earlier wording (re-test N3) ---- */
.outcome-stale { border-left: 4px solid var(--warning-strong); padding: 0.25rem 0.5rem; margin: 0.25rem 0; background: var(--warning-bg-soft); color: var(--warning-fg); }

/* Stacked tables on a phone (.table-stack, with explicit ARIA table roles and
   a data-label per cell, core/test_table_aria.py) and full-width filters. */
@media (max-width: 36rem) {
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-stack tr { border-bottom: 2px solid var(--border); padding: 0.4rem 0; }
  .table-stack td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--text-secondary); }
  .table-stack a { overflow-wrap: anywhere; }
  /* Label beside the cell's content as a block, so a cell holding a link
     and a note is not split into grid columns. */
  .table-stack td { position: relative; padding: 0.25rem 0.5rem 0.25rem 7.25rem; min-height: 1.6em; border-bottom: 0; }
  /* Stacked rows replace sideways scrolling; no minimum column width. */
  .table-scroll .table-stack td, .table-scroll .table-stack th { min-width: 0; }
  /* Floated, not absolute, so a two-line label ("Onboarding job") beside a
     one-line value still pushes the next row down. */
  .table-stack td { display: flow-root; }
  .table-stack td[data-label]::before { float: left; width: 6.25rem; margin-left: -6.75rem; }
  .table-stack .bar { max-width: 100%; }
  .table-stack td:empty { display: none; }
  .filter-form .field { flex: 1 1 100%; min-width: 0; }
  .filter-form input, .filter-form select { width: 100%; box-sizing: border-box; }
}

/* ---- Prompts page folded by phase and role (re-test N13) ---- */
.prompt-index ul { list-style: none; margin: 0.2rem 0 0.6rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; }
.prompt-index li { border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.6rem; }
.prompt-index li a { text-decoration: none; }
.prompt-index li .count { margin-left: 0.2rem; }
.prompt-index-head { font-size: 1rem; margin: 0.6rem 0 0.2rem; }
details.prompt-group { border-top: 1px solid var(--border); padding: 0.25rem 0; }
details.prompt-group > summary { cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; gap: 0.5rem; }
details.prompt-group > summary h3 { margin: 0; font-size: 1.05rem; }
details.prompt-group > summary .count { margin-left: auto; white-space: nowrap; }
details.prompt-group > summary { list-style: none; }
details.prompt-group > summary::-webkit-details-marker { display: none; }
details.prompt-group > summary::before { content: "\25B8"; color: var(--accent); font-size: 1.1rem; }
details.prompt-group[open] > summary::before { content: "\25BE"; }
@media print {
  details.prompt-group::details-content { content-visibility: visible; }
  details.prompt-group > *:not(summary) { display: block !important; }
  details.prompt-group > summary::before { content: none; }
}


/* ---------------------------------------------------------------------
   Public home page (core/home.html): feature lists, the package table and
   the numbered steps. Built on .panel, .table-scroll and .table-stack.
   --------------------------------------------------------------------- */
.feature-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.feature-list li { border-left: 4px solid var(--accent); padding-left: 0.75rem; }
.steps-list { margin: 0 0 1rem; padding-left: 1.5rem; display: grid; gap: 0.6rem; }
.steps-list li::marker { font-weight: 700; }
.package-table th[scope="row"] { font-weight: 600; white-space: nowrap; }
.package-table thead th { border-bottom: 2px solid var(--border-ink); }
.home-page .hero .actions { margin-top: 1rem; }
@media (max-width: 36rem) {
  .package-table th[scope="row"] { display: block; white-space: normal; border-bottom: 0; padding-bottom: 0; }
  .package-table tr { border-top: 0; }
  .package-table td { padding-left: 5.5rem; }
  .package-table td[data-label]::before { width: 4.75rem; margin-left: -5.25rem; }
  .package-table caption { display: block; width: 100%; font-size: 1.05rem; }
}
@media print {
  .home-page .hero .actions { display: none; }
  .home-page .panel { break-inside: avoid; }
  .package-table th, .package-table td { border-bottom: 1px solid var(--print-ink); }
}

/* Merged public home: the package comparison table under the package cards,
   and the contact line under the "Where would you like to start?" choices. */
.home-packages + .table-scroll { margin-top: 1.75rem; }
.home-closing .choice-list { margin-bottom: 1.25rem; }
.home-closing .choice-list li { border-top-color: var(--hero-divider); }
/* Questionnaire: the optional follow-up section. */
.q-contact { border-top: 2px solid var(--border); padding-top: 1rem; margin-top: 1.5rem; }
.q-contact .notice { margin-top: 1rem; }
.q-contact { margin-bottom: 1.25rem; }
.row-actions + .help { margin-top: 0.5rem; }

/* "Also show prompts for another role" on a person's session block and the Prompts page (run-through 5, F10) */
.also-prompts { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0 0 0.75rem; }
.also-prompts label { font-weight: normal; margin: 0; }
.also-prompts select { max-width: 100%; }

/* Prompts page: starter prompts grouped by trade or sector, and the filter box (run-through 5, section 4) */
.sector-group { border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.75rem; margin-bottom: 0.6rem; }
.sector-group > summary { cursor: pointer; font-weight: 600; padding: 0.2rem 0; }
.sector-group > summary .count { font-weight: normal; margin-left: 0.4rem; }
.sector-group[open] > summary { margin-bottom: 0.5rem; }
.prompt-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0 0 0.75rem; }
.prompt-filter label { margin: 0; }
.prompt-filter input[type="search"] { flex: 1 1 12rem; min-width: 0; max-width: 24rem; }
.prompt-filter .help { flex-basis: 100%; margin: 0; }

/* Staff "Log an enquiry" (templates/staff/enquiry_log.html): the
   "We may already have this person" warning before saving. */
.duplicate-warning { background: var(--warning-bg); border: 1px solid var(--warning-strong); border-left-width: 4px; border-radius: 6px; padding: 0.75rem 1rem; margin: 0 0 1.25rem; }
.duplicate-warning h2 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--warning-fg); }
.duplicate-warning ul { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; }
.duplicate-warning p { margin: 0 0 0.4rem; }
.duplicate-warning p:last-child { margin-bottom: 0; }
input[type="datetime-local"] {
  display: block; max-width: 100%; font: inherit; color: var(--text);
  background: var(--surface-input); border: 1px solid var(--border-input); border-radius: 6px; padding: 0.55rem 0.65rem;
}
@media (max-width: 36rem) {
  input[type="datetime-local"] { min-height: 44px; }
}

/* ---------------------------------------------------------------------
   Appearance control (templates/includes/appearance.html): System / Light
   / Dark as a small segmented row of buttons. In the public footer, the
   staff sidebar's user area and the client portal header.
   --------------------------------------------------------------------- */
.appearance { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin: 0 0 1rem; }
.appearance-label { font-size: 0.85rem; font-weight: 600; }
.appearance-options {
  display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface);
}
form.appearance .appearance-options button {
  min-height: 2rem; padding: 0.15rem 0.7rem; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-secondary); font-size: 0.85rem; font-weight: 600;
}
form.appearance .appearance-options button:hover { background: var(--surface-hover); color: var(--text); }
form.appearance .appearance-options button[aria-pressed="true"] {
  background: var(--accent); color: var(--text-on-accent); border-color: var(--accent-border);
}
/* In the dark header bar and the staff sidebar */
.site-header .appearance { margin: 0; }
.site-header .appearance-label { color: var(--header-muted); font-weight: 500; }
.site-header .appearance-options { background: transparent; border-color: var(--header-divider); }
.site-header form.appearance .appearance-options button { color: var(--header-link); }
.site-header form.appearance .appearance-options button:hover { background: var(--header-hover); color: var(--header-text); }
.site-header form.appearance .appearance-options button[aria-pressed="true"] { color: var(--text-on-accent); background: var(--accent); }
.nav-appearance { padding: 0.5rem 0.75rem 0.25rem; }
.staff-shell .site-header .nav-appearance .appearance { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
@media (max-width: 50rem) {
  .nav-appearance { padding: 0.5rem 0 0.75rem; }
  .staff-shell .site-header .nav-appearance { padding-inline: var(--space-4, 1rem); }
}
@media (max-width: 36rem) {
  form.appearance .appearance-options button { min-height: 44px; padding-inline: 0.9rem; }
}
@media print {
  .appearance, .nav-appearance { display: none !important; }
}

/* ---------------------------------------------------------------------
   Windows high contrast (forced colours): the system draws text and
   backgrounds; keep the borders and the few fills that carry meaning
   (progress, chart bars, status dots) visible in the system colours.
   --------------------------------------------------------------------- */
@media (forced-colors: active) {
  .bar span, .countdown span, .swatch, .feed-dot, .brand::before, .home-eyebrow::before,
  .home-ticks li::before, .status::before, .nav-user-avatar {
    forced-color-adjust: none; background: CanvasText;
  }
  .meter-fill, .hbar-fill, .col-raised, .col-answered, .spark-line { forced-color-adjust: none; fill: CanvasText; stroke: CanvasText; }
  .meter-track, .spark-area { fill: Canvas; }
  .meter, .hbar { border: 1px solid CanvasText; }
  .status, .badge, .tier, .target, .tag, .flag, .chip, .card, .kpi, .panel, .queue-item, .message,
  .notice, .empty, .duplicate-warning, .appearance-options { border: 1px solid CanvasText; }
  form.appearance .appearance-options button[aria-pressed="true"] { border-color: Highlight; outline: 2px solid Highlight; }
  .auth-page img { forced-color-adjust: none; background: var(--qr-bg); }
}
/* Client portal header: the label is read out but not shown on wide screens, to keep one row. */
@media (min-width: 50.0625rem) {
  .appearance-header .appearance-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .portal-shell .nav-appearance { padding: 0; }
}
