/* Doctor outreach: one small stylesheet.
   Patterns borrowed from the GOV.UK Design System (task list, summary list, tags, notification banner,
   error summary), in our own colours and type. Light by default; dark when the switch sets data-theme="dark". */

:root {
  --bg: #eceef2;
  --card: #ffffff;
  --text: #1b1f24;
  --text-2: #3b4350;
  --muted: #5a6472;
  --line: #c3c9d1;
  --line-strong: #8d97a3;
  --accent: #0b6e6e;
  --accent-hover: #085656;
  --accent-soft: #e3f2f1;
  --good: #17784a;
  --good-soft: #e3f4ea;
  --warn: #8a5300;
  --warn-strong: #c27a00;
  --warn-soft: #fff1d9;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --waiting: #2459a8;
  --waiting-soft: #e6eefb;
  --muted-soft: #e6e9ee;
  --mark: #fff0a3;
  --focus: #f2a900;
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #111418;
  --card: #1a1f26;
  --text: #e8ebef;
  --text-2: #c9cfd7;
  --muted: #9ba5b3;
  --line: #3c4553;
  --line-strong: #6b7687;
  --accent: #5cc2bd;
  --accent-hover: #7fd3cf;
  --accent-soft: #15302f;
  --good: #6fd09a;
  --good-soft: #15301f;
  --warn: #f0b660;
  --warn-strong: #f0b660;
  --warn-soft: #3a2a10;
  --bad: #ff8a80;
  --bad-soft: #3b1714;
  --waiting: #8fb4ff;
  --waiting-soft: #1d2a44;
  --muted-soft: #252c36;
  --mark: #5a4b00;
  --focus: #f2a900;
}

* { box-sizing: border-box; }
html { color-scheme: light; font-size: 93.75%; touch-action: manipulation; } /* 15px. Laptops at 150 to 175% display scaling give the browser a
   small page, so the layout is compact. A percentage still follows the browser's own text size setting. */
:root[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h2 .small { font-weight: 400; margin-left: 4px; }
h1, h2, h3 { text-wrap: balance; }
h3 { font-size: 1rem; margin: 0; }
code { font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
mark.danger { background: var(--bad-soft); color: var(--bad); font-weight: 600; }

/* Header */
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1200px; margin: 0 auto; padding: 6px 24px; display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand small { color: var(--muted); font-size: 0.85rem; }
/* Our own mark: an approved email. Its colours follow the light or dark theme. */
.logo { width: 30px; height: 30px; flex: none; }
.logo-bg { fill: var(--accent); }
.logo-line, .logo-tick { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.logo-line { stroke: var(--card); }
.logo-badge { fill: var(--card); stroke: var(--accent); stroke-width: 1.5; }
.logo-tick { stroke: var(--accent); }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: 6px; color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; }
.top nav a:hover { background: var(--muted-soft); }
.top nav a.on { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 -3px 0 var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--card); font-size: 0.75rem; text-align: center; font-variant-numeric: tabular-nums; }
.count.warn { background: var(--warn-strong); }
.header-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.phone-link { font-size: 0.85rem; font-weight: 600; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); text-decoration: none; }
.phone-link:hover, .phone-link.on { border-color: var(--accent); color: var(--accent); }
.theme-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.theme-switch a { padding: 5px 12px; font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.theme-switch a.on { background: var(--text); color: var(--card); }
.theme-switch a:not(.on):hover { background: var(--muted-soft); color: var(--text); }
.demo-banner { padding: 6px 16px; text-align: center; font-size: 0.86rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); }
.demo-banner.laptop { background: var(--accent-soft); color: var(--accent); }
.run-banner { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px 16px; background: var(--waiting-soft); color: var(--waiting); font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 16px 24px 24px; }
.foot { max-width: 1200px; margin: 0 auto; padding: 0 24px 16px; color: var(--muted); font-size: 0.82rem; text-align: center; }
.foot p { margin: 4px 0; }
.pagehead { margin-bottom: 12px; }
.pagehead p { margin: 2px 0; }
.lead { font-size: 1.05rem; color: var(--text-2); max-width: 820px; }

/* Cards, buttons, forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; min-width: 0; }
.empty { text-align: center; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.actions form, .copy-row { margin: 0; }
.actions-inline { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; }
.actions-help { margin: 0 0 14px; padding-left: 1.2em; color: var(--text-2); font-size: 0.93rem; }
.actions-help li { margin: 1px 0; }
button, .button { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; display: inline-block; text-decoration: none; line-height: 1.3; }
button:hover, .button:hover { border-color: var(--accent); color: var(--text); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--card); box-shadow: 0 2px 0 var(--accent-hover); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); color: var(--card); }
button.danger { color: var(--bad); }
button.quiet { font-weight: 400; color: var(--muted); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
/* A small "i" that opens an explanation box (the HTML popover attribute: no JavaScript). */
button.info { display: inline-grid; place-items: center; width: 1.3em; height: 1.3em; margin: 0 0 0 0.35em; padding: 0; border: 1px solid var(--accent); border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: italic 700 0.8em/1 Georgia, "Times New Roman", serif; vertical-align: 0.1em; box-shadow: none; }
button.info:hover { background: var(--accent); color: var(--card); }
.info-pop { max-width: min(26rem, calc(100vw - 32px)); margin: auto; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.info-pop p { margin: 0 0 10px; }
.info-pop::backdrop { background: rgba(0, 0, 0, 0.3); }
.confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px; }
label { font-weight: 600; font-size: 0.9rem; }
.field-hint { display: block; font-weight: 400; font-size: 0.86rem; color: var(--muted); margin: 1px 0 2px; overflow-wrap: anywhere; }

/* Notification banner and error summary (GOV.UK patterns) */
.banner { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; margin-bottom: 14px; border: 2px solid var(--good); border-left-width: 8px; border-radius: 6px; background: var(--card); }
.banner.warn { border-color: var(--warn-strong); }
.banner.bad { border-color: var(--bad); }
.banner.info { border-color: var(--waiting); }
/* Messages after an action: a toast in the top-right corner (the bottom on a phone). A success fades after 6 seconds
   unless the pointer or keyboard is on it; a warning or problem stays until closed. It's a <dialog> that's open when the
   page arrives and closed by its own button, so it needs no JavaScript. */
.toast[open] { position: fixed; top: 70px; right: 20px; bottom: auto; left: auto; z-index: 30; margin: 0; width: min(25rem, calc(100vw - 32px)); padding: 12px 44px 12px 16px; border: 1px solid var(--line-strong); border-left: 6px solid var(--good); border-radius: var(--radius); background: var(--card); color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); animation: toast-in 0.25s ease-out; }
.toast div { display: grid; gap: 2px; }
.toast.warn { border-left-color: var(--warn-strong); }
.toast.bad { border-left-color: var(--bad); }
.toast.ok[open] { animation: toast-in 0.25s ease-out, toast-out 0.4s ease 6s forwards; }
.toast.ok:hover, .toast.ok:focus-within { animation-play-state: paused; }
.toast form { margin: 0; }
.toast-close { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: none; box-shadow: none; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.toast-close:hover { background: var(--muted-soft); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast[open] { animation: none; } .toast.ok[open] { animation: toast-out 0s linear 8s forwards; } }
.error-summary { border: 3px solid var(--bad); border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; background: var(--card); }
.error-summary h3 { color: var(--bad); margin-bottom: 4px; }
.error-summary p { margin: 0; }

/* Tags: one colour per meaning */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; background: var(--muted-soft); color: var(--text-2); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.waiting { background: var(--waiting-soft); color: var(--waiting); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn-strong); }

/* Overview: start panel, to-do list, alerts */
.steps-plain { padding-left: 22px; margin: 12px 0; }
.steps-plain li { margin-bottom: 4px; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 0; }
.todo form { margin: 0; }
.todo li > .button, .todo li > button, .todo li > form > button { min-width: 7.5rem; text-align: center; } /* every to-do button the same size */
.todo-count { font-size: 1.4rem; font-weight: 700; text-align: center; color: var(--accent); font-variant-numeric: tabular-nums; }
.todo-text strong { display: block; }
.todo-text span { display: block; color: var(--muted); font-size: 0.93rem; }
.todo-count.warn { color: var(--warn-strong); }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { padding: 6px 0; border-top: 1px solid var(--line); }
.alerts li:first-child { border-top: 0; }

/* Overview: the workflow board. A box a step, in order, on a dotted ground like a map, each with a slim bar of the
   doctors who reached it. How a step decides sits behind its "i". */
.bd-story { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.board { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 12px; margin-top: 8px; }
.zone { padding: 10px 10px 12px; border-radius: 12px; background-color: var(--bg);
  background-image: radial-gradient(circle, var(--line) 1px, transparent 1.4px); background-size: 14px 14px; }
.zone-label { margin: 0 2px 10px; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.zone ol { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; }
.bd-box { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 8px 9px 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 2px rgba(20, 34, 60, 0.06), 0 6px 14px rgba(20, 34, 60, 0.06); }
.bd-box + .bd-box::before { content: ""; position: absolute; left: -13px; top: 20px; width: 12px; height: 2px; background: var(--line-strong); }
.bd-box:hover { border-color: var(--line-strong); }
.bd-box.warn { border-color: var(--warn-strong); } /* the border is the status: amber needs a person */
.bd-box.waiting { border-color: var(--waiting); }
.bd-box h3 { margin: 0; font-size: 0.86rem; line-height: 1.25; min-height: 2.5em; }
.bd-link { color: inherit; text-decoration: none; }
.bd-link::after { content: ""; position: absolute; inset: 0; border-radius: 10px; } /* the whole box opens the step */
.bd-link:focus-visible { outline: none; }
.bd-link:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.bd-box .info, .bd-button { position: relative; z-index: 1; }
/* Nine "i" buttons in a row are noisy, so on the board they stay grey until you point at the step. */
.bd-box button.info { width: 1.15em; height: 1.15em; border-color: var(--line-strong); background: transparent; color: var(--muted); }
.bd-box:hover button.info, .bd-box button.info:focus-visible { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.bd-after { margin: 0; color: var(--muted); font-size: 0.78rem; }
.bd-count { margin: 0; color: var(--muted); font-size: 0.78rem; }
.bd-count b { margin-right: 2px; color: var(--text); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.bd-bar { display: flex; height: 8px; margin: 4px 0; border-radius: 999px; overflow: hidden; background: var(--muted-soft); }
.bd-key i { display: inline-block; width: 8px; height: 8px; margin: 0 1px 0 4px; border-radius: 2px; }
.bd-bar i.done, .bd-key i.done { background: var(--good); }
.bd-bar i.waiting, .bd-key i.waiting { background: var(--waiting); }
.bd-bar i.person, .bd-key i.person { background: var(--warn-strong); }
.bd-bar i.stopped, .bd-key i.stopped { background: var(--text-2); }
.bd-out { display: flex; flex-wrap: wrap; gap: 4px; margin: auto 0 0; }
.bd-out .tag { font-size: 0.7rem; white-space: normal; }
.bd-button { margin-top: 6px; padding: 5px 8px; font-size: 0.82rem; text-align: center; }
/* Your move: the step where a person is needed next. It pulses three times when the page opens, then keeps still. */
.bd-box.move { border: 2px solid var(--waiting); box-shadow: 0 0 0 4px var(--waiting-soft); animation: your-move 1.4s ease-in-out 3; }
@keyframes your-move { 50% { box-shadow: 0 0 0 9px var(--waiting-soft); } }
@media (prefers-reduced-motion: reduce) { .bd-box.move { animation: none; } }
.bd-move { position: absolute; z-index: 1; top: -10px; left: 50%; transform: translateX(-50%); padding: 2px 9px; border-radius: 999px;
  background: var(--waiting); color: var(--card); font-size: 0.7rem; font-weight: 700; white-space: nowrap; }
.bd-box.later { background: transparent; border-style: dashed; border-color: var(--line-strong); box-shadow: none; }
.bd-box.later h3 { color: var(--muted); }
.bd-key { margin: 10px 0 0; }
.board-card .callout { margin-top: 10px; }
.callout { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 6px; padding: 10px 14px; background: var(--good-soft); border-left: 6px solid var(--good); border-radius: 0 6px 6px 0; }
.callout p { margin: 2px 0 0; }

/* Doctors: search, tabs, list */
.search { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px; }
.search label { display: flex; flex-direction: column; gap: 4px; }
.search .grow { flex: 1 1 260px; }
.search input, .search select { width: 100%; }
.search .clear { align-self: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tabs a { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-2); text-decoration: none; font-size: 0.9rem; background: var(--card); }
.tabs a span { font-weight: 700; }
.tabs a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tabs a:not(.on):hover { border-color: var(--accent); color: var(--text); }
.list-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.list-bar p { margin: 0; }
.list-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.legend { color: var(--muted); margin: 0 0 8px; }
.legend .key { display: inline-block; width: 11px; height: 11px; margin: 0 3px 0 8px; vertical-align: -1px; border-radius: 50%; border: 2px solid var(--line-strong); }
.doctor-list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.doctor { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr) minmax(170px, 1fr); gap: 4px 20px; padding: 10px 16px; border-top: 1px solid var(--line); }
.doctor:first-child { border-top: 0; }
.doctor-who { display: flex; flex-direction: column; min-width: 0; }
.doctor-where p { margin: 0; }
.where-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; } /* the dots, then where they got to */
.where-head .tracker { margin: 0; }
.doctor-email { overflow-wrap: anywhere; }
.doctor-list .empty { padding: 20px; }
.where-lead { font-weight: 700; }
.where-lead.final { color: var(--good); }
.where-lead.needs { color: var(--warn); }
.where-lead.removed, .where-lead.unchecked { color: var(--text-2); }

/* The parcel-style tracker: shape and colour both carry the state */
.tracker { list-style: none; display: flex; align-items: center; margin: 2px 0 8px; padding: 0; }
.tracker li { position: relative; flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--card); }
.tracker li + li { margin-left: 9px; }
.tracker li + li::before { content: ""; position: absolute; top: 50%; right: calc(100% + 2px); width: 9px; height: 2px; background: var(--line-strong); transform: translateY(-50%); }
.tracker li.done + li::before { background: var(--good); }
.tracker li.done, .legend .key.done { background: var(--good); border-color: var(--good); }
.tracker li.waiting, .legend .key.waiting { border-color: var(--waiting); border-width: 4px; }
.tracker li.person, .legend .key.person { background: var(--warn-strong); border-color: var(--warn-strong); }
.tracker li.stopped, .legend .key.stopped { background: var(--text-2); border-color: var(--text-2); border-radius: 3px; }
.tracker.big li { width: 18px; height: 18px; }
.tracker.big li + li { margin-left: 14px; }
.tracker.big li + li::before { width: 14px; }

/* Review: queue beside one email */
.reviewer-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 10px 16px; }
.reviewer-bar label { display: grid; gap: 2px; flex: 1 1 260px; max-width: 420px; }
.reviewer-bar details { display: inline-flex; gap: 8px; align-items: center; }
.reviewer-bar summary { cursor: pointer; color: var(--accent); }
.review-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
.queue { position: sticky; top: 12px; padding: 12px; max-height: calc(100vh - 24px); overflow-y: auto; overscroll-behavior: contain; } /* a long panel scrolls on its own */
.queue .pagination { margin: 2px 0 12px; gap: 8px; font-size: 0.85rem; }
.queue h2 { font-size: 0.95rem; margin: 14px 0 6px; }
.queue h2:first-child { margin-top: 0; }
.queue-list { list-style: none; margin: 0 0 8px; padding: 0; }
.queue-list a { display: flex; flex-direction: column; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.queue-list a:hover { background: var(--muted-soft); }
.queue-list li.on a { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.queue form { margin-top: 8px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager a { margin-left: 14px; }
.review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1200px) { .review { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); } }
.facts h2 { margin-bottom: 2px; }
.facts > p { margin: 0 0 10px; }
.legend mark { font-weight: 600; }

/* Summary list (GOV.UK pattern) */
.summary-list { margin: 0; }
.summary-list > div { display: grid; grid-template-columns: minmax(110px, 32%) minmax(0, 1fr); gap: 4px 16px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.summary-list dt { font-weight: 600; margin: 0; }
.summary-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.summary-list dd .small { display: block; margin-top: 2px; }
dd.notes { line-height: 1.6; }

/* Draft, checks and email preview */
.checks-summary { font-weight: 700; margin-bottom: 6px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.checks-summary.ok { color: var(--good); }
.checks-summary.ok::before { content: "\2713"; }
.checks-summary.fail { color: var(--bad); }
.checks-summary.fail::before { content: "\2717"; }
.checks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 14px; font-size: 0.86rem; }
.checks.list { display: block; }
.checks.list li { margin-bottom: 2px; }
.checks li::before { font-weight: 700; margin-right: 6px; }
.checks li.ok { color: var(--good); }
.checks li.ok::before { content: "\2713"; }
.checks li.fail { color: var(--bad); font-weight: 600; }
.checks li.fail::before { content: "\2717"; }
.checks li.fix { color: var(--warn); }
.checks li.fix::before { content: "\270E"; }
details.all-checks { margin-bottom: 12px; font-size: 0.88rem; }
details.all-checks summary, details.edit summary, details.other summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.all-checks .checks { margin-top: 8px; }
.email-preview { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.email-preview .subject { padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 600; }
.email-preview .part { padding: 10px 12px 12px 14px; border-left: 4px solid; }
.email-preview .part.personal { border-left-color: var(--waiting); background: var(--waiting-soft); }
.email-preview .part.standard { border-left-color: var(--line-strong); background: var(--bg); color: var(--muted); }
.part-label { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; color: var(--muted); }
.part.personal .part-label { color: var(--waiting); }
.email-preview .text { white-space: pre-wrap; font-size: 0.92rem; }
.draft form { margin: 0; }
.draft label { display: block; margin-bottom: 10px; }
.draft input, .draft textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; }
.draft textarea { resize: vertical; line-height: 1.5; }
details.edit { margin: 0 0 12px; }
details.edit[open] summary { margin-bottom: 10px; }
details.other { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
details.other form { margin-top: 12px; display: grid; gap: 4px; }

/* Decision card for doctors the rules couldn't decide */
.decide { border-left: 6px solid var(--warn-strong); }
.decide-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; margin-top: 10px; }
.decide-form { display: grid; gap: 8px; align-content: start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.decide-form h3 { margin: 0; }
.decide-form p { margin: 0; }
.decide-form label { display: grid; gap: 4px; }
.upload-list summary { cursor: pointer; color: var(--accent); }
.upload-list form { display: grid; gap: 10px; margin-top: 10px; max-width: 620px; }
.decide-form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; }
.decide-form label.check input { margin-top: 3px; }
.decide-form input:not([type="checkbox"]), .decide-form select { width: 100%; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field-row .grow { flex: 1 1 200px; }
.small-button { padding: 5px 12px; font-size: 0.85rem; }

/* Doctor page */
.layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 14px; align-items: start; }
.timeline { list-style: none; padding: 0; margin: 0 0 8px; }
.timeline li { padding: 7px 0 7px 34px; position: relative; border-bottom: 1px solid var(--line); }
.timeline li::before { position: absolute; left: 4px; top: 7px; width: 20px; height: 20px; border-radius: 50%; text-align: center; font-size: 0.75rem; font-weight: 700; line-height: 20px; }
.timeline li.done::before { content: "\2713"; background: var(--good-soft); color: var(--good); }
.timeline li.waiting::before { content: "\2026"; background: var(--waiting-soft); color: var(--waiting); }
.timeline li.person::before { content: "!"; background: var(--warn-soft); color: var(--warn); }
.timeline li.stopped::before { content: "\2717"; background: var(--muted-soft); color: var(--text-2); }
.timeline li.todo::before { content: ""; border: 2px solid var(--line); width: 16px; height: 16px; }
.timeline li.todo { color: var(--muted); }
.tl-head { display: flex; gap: 10px; align-items: baseline; }
.tl-state { font-size: 0.75rem; color: var(--muted); }
details.draftlog { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
details.draftlog summary { cursor: pointer; }
details.draftlog .email-preview { margin-top: 10px; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 4px 0; }

/* Tables (log and history) */
.table-wrap { overflow-x: auto; }
/* Page links under a long table, and the key that says what each status means. */
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 12px 0 0; font-size: 0.92rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pagination a { font-weight: 600; }
.pagination a[rel="next"] { justify-self: end; }
.status-key { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; font-size: 0.9rem; color: var(--muted); }
/* Two short cards side by side on wide screens. */
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.pair > .card { margin-bottom: 0; }
.status-key .tag { margin-right: 8px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

/* Run page */
.run-log { list-style: none; margin: 0 0 16px; padding: 0; }
.run-log li { padding: 6px 0 6px 28px; position: relative; border-bottom: 1px solid var(--line); }
.run-log li.done::before { content: "\2713"; position: absolute; left: 4px; color: var(--good); font-weight: 700; }
.run-log li.working { display: flex; gap: 10px; align-items: center; padding-left: 4px; color: var(--waiting); font-weight: 600; }
.spinner { flex: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } } /* the line beside it still says what's happening */

/* Phone view and the copy page */
.phone-wrap { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.phone { padding: 12px; border-radius: 38px; background: #1b1f24; }
.phone iframe { display: block; width: 390px; height: 760px; border: 0; border-radius: 28px; background: var(--bg); }
.phone-links { flex: 1 1 240px; max-width: 360px; }
.tsv { display: block; width: 100%; margin-top: 12px; font: 0.82rem/1.45 ui-monospace, Consolas, monospace; white-space: pre; overflow-x: auto; }

/* Smaller screens */
@media (max-width: 1000px) {
  .review-layout { grid-template-columns: minmax(0, 1fr); }
  .review-layout .current { order: -1; }
  .queue { position: static; max-height: none; overflow: visible; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .pair { grid-template-columns: minmax(0, 1fr); }
  .board { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .top-inner { padding: 10px 16px; }
  .brand small { display: none; }
  .phone-link { display: none; }
  .top nav { order: 3; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .top nav a { text-align: center; padding: 8px 6px; border: 1px solid var(--line); }
  .top nav a.on { box-shadow: none; border-color: var(--accent); }
  .wide-only { display: none; }
  .lead { font-size: 1rem; }
  .actions > form, .actions > .button { width: 100%; }
  .actions button, .actions .button { width: 100%; text-align: center; }
  .zone ol { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bd-box + .bd-box::before { display: none; }
  .bd-box h3 { min-height: 0; }
  h2 .small { display: block; margin: 2px 0 0; }
  .status-key { grid-template-columns: minmax(0, 1fr); }
  .callout .button { width: 100%; text-align: center; }
  .search { display: grid; grid-template-columns: 1fr 1fr; }
  .search .grow, .search button, .search .clear { grid-column: 1 / -1; }
  .list-actions, .list-actions .button { width: 100%; text-align: center; }
  .reviewer-bar label { max-width: none; }
  .pager { font-size: 0.95rem; }
  main { padding: 14px 16px 28px; }
  .foot { padding: 0 16px 24px; }
  .card { padding: 14px; }
  .doctor { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .todo li { grid-template-columns: 40px minmax(0, 1fr); }
  .todo li > .button, .todo li > button, .todo li > form { grid-column: 2; justify-self: start; }
  .summary-list > div { grid-template-columns: minmax(0, 1fr); }
  .decide-grid { grid-template-columns: minmax(0, 1fr); }
  .phone iframe { width: min(390px, calc(100vw - 56px)); }
  .toast[open] { top: auto; right: 16px; bottom: 16px; left: 16px; width: auto; }
  h1 { font-size: 1.4rem; }
}

/* Team alerts: a mock-up of a team chat in this app's own style, with no real app's logo or look. */
.chat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; margin-bottom: 6px; }
.chat-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chat-messages { list-style: none; margin: 0; padding: 12px 16px 16px; display: grid; gap: 14px; }
.chat-msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: start; }
.chat-avatar { width: 36px; height: 36px; border-radius: 8px; }
.chat-bubble { min-width: 0; }
.chat-bubble p { margin: 0 0 4px; overflow-wrap: anywhere; }
.chat-meta time { margin-left: 6px; color: var(--muted); font-size: 0.85rem; }
.chat-tag { padding: 1px 5px; border-radius: 4px; background: var(--muted-soft); color: var(--text-2); font-size: 0.7rem; font-weight: 700; }
.chat-title { font-weight: 700; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chat-actions a { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 6px; font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.chat-empty { padding: 8px 0; color: var(--muted); }
.chat-teams .chat-messages, .chat-whatsapp .chat-messages { background: var(--bg); }
.chat-teams .chat-bubble { padding: 10px 12px; border: 1px solid var(--line); border-top: 4px solid var(--warn-strong); border-radius: 6px; background: var(--card); }
.chat-whatsapp .chat-bubble { max-width: 34rem; padding: 8px 12px; border-radius: 0 10px 10px 10px; background: var(--good-soft); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); }
.chat-whatsapp .chat-actions a { padding: 0; border: 0; text-decoration: underline; }
.payload { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-size: 0.82rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Production architecture drawing, in the app's own colours so it follows light and dark. On a phone it
   scrolls sideways rather than shrinking the words. */
.arch-wrap { overflow-x: auto; }
.arch { display: block; width: 100%; max-width: 900px; min-width: 680px; height: auto; margin: 8px auto 0; }
.arch .zone { fill: var(--muted-soft); stroke: var(--line-strong); stroke-width: 1; }
.arch .box { fill: var(--card); stroke: var(--line-strong); stroke-width: 1.25; }
.arch .box.main { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.arch .link { fill: none; stroke: var(--line-strong); stroke-width: 1.25; }
.arch .head { font-size: 13px; font-weight: 600; fill: var(--text); }
.arch .line, .arch .label { font-size: 11.5px; fill: var(--muted); }
.arch .line.main { fill: var(--text); }

/* Replay page: the last run played back by replay.js. Without the script it shows the finished run. */
.replay-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 12px; }
.replay-head h1 { margin-bottom: 4px; }
.replay-keys { display: flex; flex-wrap: wrap; gap: 8px; }
.replay-keys kbd { font: 600 0.72rem/1 ui-monospace, Consolas, monospace; padding: 2px 6px; margin-left: 6px; border: 1px solid currentColor; border-radius: 4px; opacity: 0.75; }
.rp-section { margin-bottom: 14px; }
.rp-section h2 { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; }
.rp-num { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 1rem; }
.rp-steps { list-style: none; margin: 10px 0 0; padding: 0; }
.rp-step { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 6px 18px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); transition: opacity 0.4s ease, transform 0.4s ease; }
.rp-step:first-child { border-top: 0; }
.rp-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rp-count { font-size: 1.4rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.rp-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.rp-dots .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--accent); transition: background 0.5s ease, border-color 0.5s ease, transform 0.5s ease; }
.rp-dots .dot.stop { background: transparent; border-color: var(--line-strong); transform: translateY(5px); }
.rp-trays { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; transition: opacity 0.4s ease; }
.rp-trays .tag { font-size: 0.9rem; }
.rp-result { font-size: 1.05rem; margin: 10px 0 0; padding: 10px 14px; border-radius: var(--radius); background: var(--good-soft); transition: opacity 0.5s ease; }
.rp-cards { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.rp-card { border: 1px solid var(--line); border-left: 5px solid var(--line-strong); border-radius: var(--radius); padding: 10px 12px; background: var(--card); transition: opacity 0.4s ease, transform 0.4s ease; }
.rp-card.good { border-left-color: var(--good); }
.rp-card.warn { border-left-color: var(--warn-strong); }
.rp-card.flagged { border-left-color: var(--bad); }
.rp-card-head { display: flex; flex-direction: column; margin-bottom: 6px; }
.rp-tries { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
.rp-tries li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 8px; padding: 3px 0; transition: opacity 0.3s ease; }
.rp-try { font-weight: 600; }
.rp-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-tries li.pass span:last-child { color: var(--good); }
.rp-tries li.fail span:last-child { color: var(--warn); }
.rp-card.flagged .rp-tries li.fail:first-child span:last-child { color: var(--bad); font-weight: 600; }
.rp-outcome { margin: 8px 0 0; font-weight: 600; transition: opacity 0.3s ease; }
.rp-flag { margin: 6px 0 0; color: var(--bad); font-size: 0.92rem; transition: opacity 0.3s ease; }
.rp-bars { display: grid; gap: 12px; margin: 10px 0 12px; }
.rp-bar { display: grid; grid-template-columns: 250px minmax(0, 1fr) 120px; gap: 14px; align-items: center; }
.rp-bar-label { font-weight: 600; }
.rp-track { height: 16px; border-radius: 999px; background: var(--muted-soft); overflow: hidden; }
.rp-fill { display: block; height: 100%; width: var(--w); min-width: 4px; border-radius: 999px; background: var(--accent); transform-origin: left; transition: transform 1.4s ease; }
.rp-bar.by-hand .rp-fill { background: linear-gradient(to right, var(--warn-strong) 0 var(--low), var(--warn-soft) var(--low) 100%); }
.rp-bar-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.rp-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 8px; }
.rp-how h3 { margin: 8px 0 4px; }
.rp-how p { margin: 0 0 8px; color: var(--muted); }
.rp-how pre, .prompt-pop pre { margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-size: 0.82rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.rp-icon { width: 64px; height: 48px; fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.rp-icon .hit { stroke: var(--accent); }
.rp-checklist { list-style: none; margin: 0 0 8px; padding: 0; }
.rp-checklist .tick { color: var(--good); font-weight: 700; margin-right: 8px; }
.prompt-pop { max-width: min(52rem, calc(100vw - 32px)); max-height: 85vh; overflow: auto; overscroll-behavior: contain; }
.prompt-pop h3 { margin: 12px 0 6px; }
.replay:fullscreen { background: var(--bg); overflow: auto; padding: 24px 32px; }

/* While it plays, whatever the replay hasn't reached yet is hidden. */
.replay.playing .rp-step:not(.shown), .replay.playing .rp-card:not(.shown) { opacity: 0; transform: translateY(8px); }
.replay.playing .rp-step:not(.settled) .dot.stop { background: var(--accent); border-color: var(--accent); transform: none; }
.replay.playing .rp-step:not(.settled) .rp-trays,
.replay.playing .rp-result:not(.shown),
.replay.playing .rp-tries li:not(.shown),
.replay.playing .rp-card:not(.settled) .rp-outcome,
.replay.playing .rp-card:not(.settled) .rp-flag { opacity: 0; }
.replay.playing .rp-bar:not(.shown) .rp-fill { transform: scaleX(0); }

@media (max-width: 760px) {
  .rp-step { grid-template-columns: minmax(0, 1fr); }
  .rp-trays { grid-column: 1; }
  .rp-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .rp-bar .rp-track { grid-column: 1 / -1; grid-row: 2; }
  .rp-how { grid-template-columns: minmax(0, 1fr); }
  .replay-keys kbd { display: none; }
  .rp-dots .dot { width: 11px; height: 11px; }
}
