/* CEG Health Centre -- clinic console.
 *
 * Hand-written, no framework, no build step (spec section 3).
 *
 * The Counter Board (4 Oct 2026). The token display board above a clinic
 * counter: a graphite frame -- the rail down the left, the search bar across
 * the top and each screen's board under it -- holds what is live, in lit
 * numerals; the work below sits on white, in square sections ruled in ink,
 * never in cards. Lit means chosen: a tap option, the page you are on and the
 * one primary action fill with teal.
 *
 * The colour meanings did not change: teal is act, chosen and focus; red is
 * allergy, void and destruction; amber needs attention; green is done; indigo
 * is the doctor's alone. Every state also has a line form, so colour is never
 * the only sign: dashed is "so far" or typed, struck through is voided, a
 * doubled red rule closes round an allergy.
 *
 * Atkinson Hyperlegible Next for words and Atkinson Hyperlegible Mono for the
 * numerals that are read off a board -- roll numbers, beds, waits, blood group
 * -- both from the Braille Institute, drawn so 0 and O, 1, l and I never pass
 * for each other. Held on this machine (OFL, atkinson-LICENSE.txt).
 *
 * The accessibility floor from spec section 7 is not decoration: 48px targets,
 * 16px base text and nothing below 14px, every icon beside a text label, full
 * keyboard operation, visible focus, and no horizontal scrolling at 1366x768.
 */

@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/static/atkinson-next-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible Mono';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/static/atkinson-mono-latin.woff2') format('woff2');
}

:root {
  /* The frame: rail, top bar and boards. */
  --frame: #14181d;
  --frame-2: #1e242b;
  --frame-3: #2a323b;
  --frame-line: #39424c;
  --frame-ink: #f2f4f3;
  --frame-muted: #aab4be;
  --frame-lit: #6fd3d9;
  --frame-soft: #cfd6dc;
  --frame-field-lit: #0f1316;
  --accent-board-hover: #0d8089;

  /* The workspace. */
  --canvas: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f4;
  --surface-3: #e8ebea;

  --ink: #14181d;
  --ink-2: #39424c;
  --muted: #5b6671;

  --line: #dde1e0;
  --line-strong: #8a939b;
  --line-hover: #4d5660;

  --accent: #0b6e76;
  --accent-hover: #095a61;
  --accent-ink: #07525a;
  --accent-wash: #e6f2f2;
  --accent-line: #a9d2d5;

  --danger: #b42318;
  --danger-hover: #912018;
  --danger-ink: #7a271a;
  --danger-wash: #fef3f2;
  --danger-line: #fecdca;

  --warn: #b54708;
  --warn-ink: #93370d;
  --warn-wash: #fffaeb;
  --warn-line: #fedf89;

  --ok: #067647;
  --ok-ink: #085d3a;
  --ok-wash: #ecfdf3;
  --ok-line: #abefc6;

  --restricted: #3e4784;
  --restricted-wash: #eef0fb;

  --sans: 'Atkinson Hyperlegible Next', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: 'Atkinson Hyperlegible Mono', ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;

  --tap: 48px;
  --radius: 0;
  --radius-lg: 0;
  --sidebar: 232px;
  --brandbar: 72px;
  --gutter: 32px;

  --shadow-pop: 0 16px 40px rgba(20, 24, 29, 0.18), 0 2px 6px rgba(20, 24, 29, 0.08);
  --shadow-bar: 0 -10px 28px rgba(20, 24, 29, 0.14);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='square' stroke-linejoin='miter'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #bfe3e5; color: var(--ink); }
input, textarea { caret-color: var(--accent); }
* { scrollbar-color: #9aa3ab transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #9aa3ab; border: 3px solid transparent; background-clip: content-box; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; text-wrap: balance; }
h2 { font-size: 18px; line-height: 1.35; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 700; margin: 0 0 10px; color: var(--ink); }
p { margin: 0 0 12px; }
strong { font-weight: 700; }

.page-sub { color: var(--muted); margin: 0 0 24px; max-width: 72ch; }
.card-sub { color: var(--muted); margin: -4px 0 16px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 15px; margin: 12px 0 0; max-width: 80ch; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.strong { font-weight: 700; color: var(--ink); }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.push { margin-left: auto; }
.flush { margin: 0; }
.flush-top { margin-top: 0; }
.spaced { margin-top: 16px; }
.narrow { max-width: 680px; }
ul.plain { margin: 0; padding-left: 18px; }

[hidden] { display: none !important; }

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

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 12px 16px;
  border: 2px solid var(--accent);
}
.skip:focus { top: 12px; }

kbd {
  display: inline-block; min-width: 24px; padding: 0 6px;
  font: 500 14px/22px var(--mono); color: var(--ink-2); text-align: center;
  background: var(--surface); border: 1px solid var(--line-strong); border-bottom-width: 2px;
}

svg { flex: none; }

/* ===================================================================== */
/* The frame: the rail, the top bar, and each screen's board             */
/* ===================================================================== */

body.app {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh;
  /* The rail's graphite runs the full height of a long page. */
  background: linear-gradient(to right, var(--frame) var(--sidebar), var(--canvas) var(--sidebar));
}

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--frame); color: var(--frame-ink);
  scrollbar-color: var(--frame-line) transparent;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--brandbar); padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--frame-line);
  color: inherit; text-decoration: none;
}
.brand:hover { color: inherit; }
.crest-img { display: block; flex: none; height: auto; }
.brand-unit { display: block; font-weight: 800; font-size: 19px; line-height: 1.15; letter-spacing: -0.01em; }
.brand-org { display: block; font-size: 14px; color: var(--frame-muted); line-height: 1.3; }

/* On a wide screen the menu is simply there; on a narrow one it folds behind "Menu". */
.menu { display: flex; flex-direction: column; flex: 1; }
.menu > summary { display: none; }
.menu-body { display: flex; flex-direction: column; flex: 1; }

.nav { display: grid; gap: 0; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); padding: 0 20px; border: 0;
  background: transparent; color: var(--frame-soft); text-decoration: none;
  font: 600 16px var(--sans); cursor: pointer; width: 100%; text-align: left;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.nav-item svg { width: 20px; height: 20px; color: var(--frame-muted); transition: color 150ms var(--ease); }
.nav-item:hover { background: var(--frame-3); color: #fff; }
.nav-item:hover svg { color: #fff; }
/* The page you are on is lit. */
.nav-item[aria-current='page'] { background: var(--accent); color: #fff; font-weight: 700; }
.nav-item[aria-current='page'] svg { color: #fff; }
.nav-item:focus-visible { outline-color: var(--frame-lit); outline-offset: -2px; }
.nav-item kbd { margin-left: auto; background: var(--frame-2); border-color: var(--frame-line); color: var(--frame-muted); }

.sidebar-foot { margin-top: auto; display: grid; padding: 8px 0 16px; border-top: 1px solid var(--frame-line); }
.who { display: grid; gap: 0; padding: 12px 20px 0; }
.who-text { display: grid; padding: 0 0 4px; }
.who-name { font-weight: 700; line-height: 1.3; color: #fff; }
.who-role { font-size: 14px; color: var(--frame-muted); }
.who-link {
  display: flex; align-items: center; min-height: var(--tap); margin: 0 -20px; padding: 0 20px;
  color: var(--frame-soft); font-size: 15px; font-weight: 500; text-decoration: none;
}
.who-link:hover { color: #fff; background: var(--frame-3); }
.who-link:focus-visible { outline-color: var(--frame-lit); outline-offset: -2px; }
/* Sign out is a form (a POST, so no other page can sign anyone out); the button looks like the link it was. */
.who-form { display: grid; margin: 4px 0 0; }
.who-switch {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: var(--tap); border: 1px solid var(--frame-line); background: transparent;
  color: #fff; font: 700 15px var(--sans); cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.who-switch svg { width: 18px; height: 18px; }
.who-switch:hover { background: var(--frame-3); border-color: var(--frame-muted); }
.who-switch:focus-visible { outline-color: var(--frame-lit); }

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

/* The search on Find a record and New visit sits on the page's board (DECISIONS #55),
 * drawn like the pharmacy's scan box; its matches are a ruled list under the board. */
.findbox { max-width: 900px; }
.search-list { border-top: 2px solid var(--ink); margin-bottom: 36px; }
.search-list:empty { display: none; }
.search-note { margin: 0; padding: 12px 0; font-size: 15px; color: var(--muted); border-bottom: 1px solid var(--line); }
.search-empty { padding: 24px 0; color: var(--ink-2); }
.search-empty p { margin-bottom: 12px; }

.results { display: grid; }
.result {
  display: flex; align-items: center; gap: 16px;
  min-height: 72px; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.result:last-child { border-bottom: 0; }
.result > svg { width: 20px; height: 20px; color: var(--muted); }
.result:hover, .result:focus-visible { background: var(--accent-wash); color: inherit; outline-offset: -2px; }
.result:focus-visible { box-shadow: inset 4px 0 0 var(--accent); }
.result:hover > svg, .result:focus-visible > svg { color: var(--accent); }
.result-static { flex-wrap: wrap; }
.who-line { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.who-line .name, .result .name { font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; line-height: 1.3; }
.result a.name:hover { color: var(--accent); text-decoration: underline; }
.who-line .meta { color: var(--muted); font-size: 15px; }
.who-line .meta .num { font-family: var(--mono); color: var(--ink-2); }

main { flex: 1; width: 100%; max-width: 1360px; padding: 24px var(--gutter) 96px; }

.back {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: var(--tap); margin: -12px 0 4px -6px; padding: 0 8px 0 2px;
  color: var(--muted); font-weight: 600; font-size: 15px; text-decoration: none;
}
.back svg { width: 18px; height: 18px; }
.back:hover { color: var(--ink); background: var(--surface-2); }


/* A screen's board: the top of the page, in the frame's graphite, carrying
 * what is live in lit numerals. It runs to both edges of the workspace and
 * scrolls away under the search bar. */
.slab {
  position: relative;
  margin: -24px 0 40px; padding: 24px 0 28px;
  background: var(--frame); color: var(--frame-ink);
  box-shadow: 0 0 0 100vmax var(--frame); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}
.slab h1 { color: #fff; margin: 0; font-size: 36px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.slab a:not(.btn) { color: var(--frame-lit); }
.slab a:not(.btn):hover { color: #fff; }
.slab :focus-visible { outline-color: var(--frame-lit); }
.slab .back { color: var(--frame-muted); margin: -8px 0 8px -6px; }
.slab .back:hover { color: #fff; background: var(--frame-3); }
.slab .muted, .slab-sub { color: var(--frame-muted); }
.slab-sub { margin: 6px 0 0; font-size: 17px; }
.slab-row { display: flex; align-items: center; gap: 16px 32px; flex-wrap: wrap; }
.slab-title { flex: 1 1 260px; min-width: 0; }
.slab-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Readouts: a lit numeral over its label, ruled apart like a board's modules. */
.readouts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: stretch;
  margin: 20px 0 0; border-top: 1px solid var(--frame-line);
}
.readout {
  display: grid; align-content: start; gap: 2px; min-width: 0; min-height: var(--tap);
  padding: 14px 20px 2px; border-left: 1px solid var(--frame-line);
  color: inherit; text-decoration: none;
}
a.readout { transition: background-color 150ms var(--ease); }
a.readout:hover { background: var(--frame-2); color: inherit; }
a.readout:hover .readout-k { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.readout-n { font: 700 46px/1 var(--mono); letter-spacing: -0.02em; color: #fff; font-variant-numeric: tabular-nums; }
.readout-k { font-size: 15px; font-weight: 600; color: var(--frame-soft); line-height: 1.3; }
.readout-note { font-size: 14px; color: var(--frame-muted); }
.readout:first-child { border-left: 0; padding-left: 0; }
.readout.is-zero .readout-n { color: var(--frame-muted); }

/* The board's buttons, on graphite. */
.slab .btn {
  background: transparent; border-color: var(--frame-line); color: #fff; box-shadow: none;
}
.slab .btn:hover { background: var(--frame-3); border-color: var(--frame-muted); color: #fff; }
.slab .btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.slab .btn-primary:hover { background: var(--accent-board-hover); border-color: var(--accent-board-hover); }
.slab .btn:focus-visible { outline-color: var(--frame-lit); }

/* A token: a graphite square with one lit figure -- a bed, a wait, a blood group. */
.token, .occ-tile, .wait-tile, .blood {
  flex: none; display: grid; place-content: center; justify-items: center; gap: 2px;
  background: var(--frame); color: #fff;
}
.occ-tile { width: 72px; min-height: 68px; padding: 6px 4px; }
.occ-n, .wait-n, .blood-value { font-family: var(--mono); font-weight: 600; letter-spacing: -0.02em; color: #fff; font-variant-numeric: tabular-nums; }
.occ-n { font-size: 30px; line-height: 1; }
.occ-k, .wait-k, .blood-label { font-size: 14px; font-weight: 500; color: var(--frame-muted); line-height: 1.2; }

.help {
  margin: 0 var(--gutter) 32px; max-width: calc(1360px - 2 * var(--gutter));
  background: var(--surface); border-top: 2px solid var(--ink);
}
.help:not([open]) { display: none; }
.help > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0; font-weight: 700; font-size: 18px; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.help > summary::-webkit-details-marker { display: none; }
.help > summary svg { width: 20px; height: 20px; color: var(--muted); }
.help-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 48px; padding: 16px 0 0; }
.help-body ul { margin: 0 0 12px; padding-left: 20px; }
.help-body li + li { margin-top: 4px; }
.help-foot { grid-column: 1 / -1; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  max-width: min(640px, calc(100% - 32px)); padding: 14px 20px 14px 16px;
  background: var(--frame); color: #fff; font-weight: 600;
  border-top: 2px solid var(--frame-lit);
  box-shadow: var(--shadow-pop);
  animation: toast-in 280ms var(--ease) both, toast-out 400ms 5.6s var(--ease) forwards;
}
.toast svg { width: 20px; height: 20px; color: #6ce9a6; }
/* The Esc guard's warning: stays until it is answered or times out, never fades early. */
.toast-warn { animation: toast-in 280ms var(--ease) both; background: var(--warn-ink); border-top-color: #fedf89; }
/* The server could not be reached (DECISIONS #46): above any save toast, until it answers again. */
#net-note { bottom: 88px; }
/* A list that refreshes itself says when it last did, once it cannot. */
.stale-note {
  margin: 0 0 12px; padding: 10px 14px; border: 1px dashed var(--warn);
  background: var(--warn-wash); color: var(--warn-ink); font-weight: 700;
}
/* A live search on its way: htmx marks the box, and the magnifier pulses. */
.scanbox:has(input.htmx-request) > svg { color: var(--frame-lit); animation: searching 700ms var(--ease) infinite alternate; }
input.terminology-search.htmx-request { border-color: var(--accent); }
@keyframes searching { from { opacity: 1; } to { opacity: 0.3; } }

/* ===================================================================== */
/* Sections: an ink rule and a heading, never a card                     */
/* ===================================================================== */

.panel, .card {
  background: transparent; border-top: 3px solid var(--ink);
  margin-bottom: 40px; min-width: 0;
  /* A jump link (e.g. /admin#readiness) must not land under the sticky app bar. */
  scroll-margin-top: 16px;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; flex: 1; display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.panel-head h2 svg { width: 20px; height: 20px; color: var(--muted); }
/* A count beside a heading is read off like a board: right-aligned, in the board's figures. */
.panel-count, .h2-count {
  margin-left: auto; font: 700 20px var(--mono); color: var(--ink); font-variant-numeric: tabular-nums;
}
.panel-body { padding: 16px 0; }
.panel-pad { padding: 20px 0; }
.panel-attention { border-top-color: var(--warn); }
.panel-attention .panel-head h2, .panel-attention .panel-head svg { color: var(--warn-ink); }

.card { padding: 0 0 4px; }
.card > h2 {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; margin: 0 0 16px; padding: 10px 0;
  font-size: 20px; font-weight: 800; letter-spacing: -0.01em; border-bottom: 1px solid var(--line);
}
.card > h2 svg { width: 20px; height: 20px; color: var(--muted); }
.card-plain { padding-top: 20px; }
/* The doctor's alone: the rule turns indigo, and so does the heading. */
.card-doctor { border-top: 3px double var(--restricted); padding-top: 2px; }
.card-doctor > h2 { color: var(--restricted); }
/* Completing a visit (DECISIONS #56): the doctor's part leads, and this line
   marks where what the counter logged begins. */
.form-divider { margin: 0 0 24px; padding-top: 12px; border-top: 1px dashed var(--line-strong); color: var(--muted); font-size: 15px; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 24px; }
.grid-top { align-items: start; }

.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty-title { color: var(--ink); font-weight: 700; margin-bottom: 4px; }
.empty p:last-child { margin-bottom: 0; }
.card .empty, .panel .empty, .panel-body .empty { margin: 16px 0; background: var(--surface-2); border: 1px dashed var(--line-strong); }

/* ===================================================================== */
/* Home: the board, who is in the centre now, today, the rail            */
/* ===================================================================== */


/* In the centre now: the peak of the home screen. */
.board-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.board-col { min-width: 0; padding-bottom: 4px; }
.board-col + .board-col { border-left: 1px solid var(--line); padding-left: 24px; }
.board-col:first-child { padding-right: 24px; }
.board-title {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 16px 0 4px;
  font-size: 15px; font-weight: 700; color: var(--ink-2);
}
.board-title svg { width: 20px; height: 20px; color: var(--muted); }
.board-empty { margin: 0; padding: 8px 0 16px; color: var(--muted); }

/* A person in the centre, led by their token: bed number, or time waiting. */
.occupants { list-style: none; margin: 0; padding: 0; }
.occupant { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.occupant + .occupant { border-top: 1px solid var(--line); }
.occ-who { flex: 1; min-width: 0; display: grid; gap: 2px; }
.occ-name { justify-self: start; font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--ink); text-decoration: none; }
.occ-name:hover { color: var(--accent); text-decoration: underline; }
.occ-meta { font-size: 15px; color: var(--muted); }
.occupant form { margin: 0; }
.occupant > .btn, .occupant form { flex: none; }

/* The doctor's next patient: the board's own grammar, one step down. */
.next { margin-bottom: 36px; }
.next .panel-head .muted { font-size: 15px; }
.next-body { display: flex; align-items: flex-start; gap: 24px; padding: 20px 0 8px; }
.next-id { flex: 1; min-width: 0; }
.next-name {
  display: inline-block; margin: 0 0 8px; font-size: 32px; line-height: 1.2; font-weight: 700;
  letter-spacing: -0.01em; color: var(--ink); text-decoration: none; text-wrap: balance;
}
.next-name:hover { color: var(--accent); text-decoration: underline; }
.next-side { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 216px; }
.wait-tile { padding: 12px 16px 14px; }
.wait-n { font-size: 40px; line-height: 1.05; }
.wait-unit { font-family: var(--sans); font-size: 16px; font-weight: 600; letter-spacing: 0; color: var(--frame-muted); }
.empty-lg { padding: 48px 20px; }


.dash { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.rail { display: grid; gap: 0; }
.rail-line { margin: 12px 0 14px; color: var(--ink-2); }
.rail-link {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0;
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line);
  color: var(--ink); font-weight: 700; text-decoration: none;
}
.rail-link svg { width: 20px; height: 20px; color: var(--muted); }
.rail-link svg:last-child { margin-left: auto; }
.rail-link:hover { background: var(--surface-2); color: var(--ink); }

.status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }
.status-live { color: var(--ink); font-weight: 700; }

/* Progress: square, in ink -- a count of work done is not a choice. */
.progress { height: 8px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); }

/* ===================================================================== */
/* Chips and status                                                      */
/* ===================================================================== */

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px;
  padding: 1px 8px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2);
  font-size: 14px; font-weight: 600; line-height: 1.4; white-space: nowrap;
}
.chip-strong { background: var(--surface); border-color: var(--line-strong); color: var(--ink); font-weight: 700; }
.chip-danger { background: var(--danger-wash); border: 3px double var(--danger); color: var(--danger-ink); font-weight: 700; }
.chip-warn { background: var(--warn-wash); border-color: var(--warn-line); color: var(--warn-ink); }
.chip-ok { background: var(--ok-wash); border-color: var(--ok); color: var(--ok-ink); }
.chip-restricted { background: var(--restricted-wash); border-color: var(--restricted); color: var(--restricted); font-weight: 700; }
.chip-note { font-weight: 400; color: inherit; opacity: 0.9; }
/* An allergy or condition with its note can be longer than the line: it wraps rather than run off the page. */
.chip:has(.chip-note) { flex-wrap: wrap; max-width: 100%; white-space: normal; }
.chip-note::before { content: '·'; margin-right: 6px; }
/* Typed with no concept on the clinic list (DECISIONS #50): a dashed edge and the word, never colour alone. */
.chip-typed { border-style: dashed; white-space: normal; text-align: left; }

/* Colour by meaning (DECISIONS #53). Four hues, teal first, validated with
 * the dataviz script as a set and apart from the status colours. An outcome
 * keeps one hue everywhere, and so does a kind of patient: a dot for an
 * outcome, a square for a kind of patient, always beside its words. Wine,
 * nearest the warnings, goes to the rarest of each set. Text never wears
 * these colours. */
:root { --cat-1: #00929c; --cat-2: #7a5cd6; --cat-3: #b08900; --cat-4: #8a3b5c; }
.cat-1 { --cat-color: var(--cat-1); }
.cat-2 { --cat-color: var(--cat-2); }
.cat-3 { --cat-color: var(--cat-3); }
.cat-4 { --cat-color: var(--cat-4); }
.cat::before {
  content: ''; display: inline-block; flex: none; width: 10px; height: 10px; margin-right: 8px;
  border-radius: 50%; background: var(--cat-color); vertical-align: 0.02em;
}
.cat-kind::before { border-radius: 0; }
.chip.cat::before, .status.cat::before { margin-right: 0; }
.option.cat::before { margin-right: 10px; }
.chip-tag { font-size: 14px; font-weight: 400; color: var(--ink-2); white-space: nowrap; }
.chip-tag::before { content: '·'; margin-right: 6px; }
.typed-box { margin-top: 16px; }

/* A row that answers a click anywhere: its one link stretches over it, and a
   button inside it still takes its own click (DECISIONS #58). */
.is-link { position: relative; cursor: pointer; transition: background-color 120ms var(--ease); }
.is-link .row-link::after { content: ''; position: absolute; inset: 0; }
.is-link .btn, .is-link form, .is-link button, .is-link select, .is-link input { position: relative; z-index: 1; }
.is-link:hover { background: var(--surface-2); }
.is-link:has(.row-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.is-link .row-link:focus-visible { outline: none; }
.occupant.is-link { margin: 0 -12px; padding-left: 12px; padding-right: 12px; }

/* A doctor reading a patient not sent to them: the doctor's indigo, said once. */
.readonly-note {
  margin: 0 0 8px; padding: 12px 16px; font-size: 16px;
  background: var(--restricted-wash); color: var(--restricted); border-top: 1px solid var(--restricted); border-bottom: 1px solid var(--restricted);
}

/* ===================================================================== */
/* Buttons                                                               */
/* ===================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1.5px solid var(--ink); background: var(--surface); color: var(--ink);
  font: 700 16px/1.2 var(--sans); letter-spacing: 0.005em; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 100ms var(--ease);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { background: var(--ink); border-color: var(--ink); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); padding: 0 10px; }
.btn-ghost:hover { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
.btn-lg { min-height: 56px; padding: 0 24px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-sm { padding: 0 14px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.save-row { margin: 8px 0 16px; }

/* The save bar: pinned under the form while it scrolls. Light, with its own
   ink rule, so it never reads as part of the graphite rail beside it; on the
   left it says what will be saved, on the right the way out and the save. */
.savebar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  margin: 8px 0 0; padding: 16px 0;
  background: var(--surface-2); color: var(--ink);
  /* The tint runs on to the window's right edge and back over the gutter, never
     up over the form or left over the rail. */
  box-shadow: 0 0 0 100vmax var(--surface-2); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}
.savebar::before {
  content: ''; position: absolute; top: 0; left: calc(-1 * var(--gutter)); right: 0; height: 2px;
  background: var(--ink); box-shadow: 0 0 0 100vmax var(--ink); clip-path: inset(0 -100vmax 0 0);
}
.savebar-note { margin-right: auto; display: grid; gap: 2px; min-width: 0; color: var(--muted); font-size: 15px; }
.savebar-note strong { color: var(--ink); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savebar-note strong.is-missing { color: var(--warn-ink); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0 0; }
.inline-form input[type='text'], .inline-form input[type='search'] { width: auto; flex: 1; min-width: 160px; }
.inline-form .field { margin: 0; }

/* ===================================================================== */
/* Tap options                                                           */
/* Spec 7.4: positions are fixed forever so muscle memory forms. Never   */
/* reordered by frequency at runtime. Packed edge to edge in one ruled   */
/* block; a chosen one is lit.                                           */
/* ===================================================================== */

.optiongrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 0;
  padding: 0 1px 1px 0;
}
.optiongrid:empty { display: none; }
.optiongrid:not(:empty) + .field { margin-top: 16px; }
.optiongrid-3 { grid-template-columns: repeat(3, 1fr); }
.optiongrid-blood { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }

.option {
  position: relative;
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 60px; padding: 8px 30px;
  /* Every cell carries its own rule and overlaps its neighbour's, so a short
     last row closes where its last option ends. */
  border: 1px solid var(--line-strong); margin: 0 -1px -1px 0;
  background: var(--surface);
  font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--ink);
  cursor: pointer; user-select: none;
  transition: background-color 120ms var(--ease), color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.option:hover { z-index: 2; background: var(--accent-wash); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.option:active { transform: translateY(1px); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { position: relative; z-index: 1; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.option:has(input:checked):hover { background: var(--accent-hover); }
.option:has(input:checked)::after {
  content: ''; position: absolute; top: 8px; right: 8px; width: 16px; height: 16px;
  background: #fff; -webkit-mask: var(--check) center / contain no-repeat; mask: var(--check) center / contain no-repeat;
}
.option:has(input:checked).cat::before { box-shadow: 0 0 0 2px #fff; }
.option:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: -5px; }
.option:has(input:checked):has(input:focus-visible) { outline-color: #fff; }
/* An option standing on its own (a tick in a form) keeps its own frame. */
.option-inline { display: inline-flex; max-width: 380px; margin: 8px 0 0; }
.option-row { justify-content: flex-start; text-align: left; gap: 10px; padding-left: 16px; }

.allergy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 16px 12px; }
.allergy-choice { display: grid; gap: 6px; }
.allergy-choice .option { margin: 0; }
.allergy-choice select { min-height: var(--tap); font-size: 16px; }
.visit-picks { display: grid; gap: 0; padding: 0 1px 1px 0; }

/* Choosing a role is choosing a job: each option says what that person can do. */
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 0 1px 1px 0; }
.role-grid-1 { grid-template-columns: 1fr; }
.role-option { min-height: 64px; padding: 10px 40px 10px 16px; align-items: center; }
.role-option .grow { display: grid; gap: 2px; }
.role-summary { font-size: 15px; font-weight: 400; }
.option:has(input:checked) .role-summary { color: #e6f2f2; }

/* ===================================================================== */
/* Fields                                                                */
/* ===================================================================== */

.field { display: block; margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field .label, fieldset .label, .label {
  display: block; margin-bottom: 6px; padding: 0;
  font-weight: 700; font-size: 15px; color: var(--ink-2);
}
.field .note { display: block; color: var(--muted); font-size: 14px; margin-top: 6px; }
.note-ok { color: var(--ok-ink) !important; font-weight: 700; }
.note-warn { color: var(--warn-ink) !important; font-weight: 700; }

input[type='text'], input[type='number'], input[type='date'], input[type='search'],
input[type='tel'], input[type='email'], input[type='password'], input[type='file'], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 0;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input::placeholder, textarea::placeholder { color: #6b7580; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input[type='file'] { padding: 10px; background: var(--surface-2); }
input[type='file']::file-selector-button {
  margin-right: 12px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong);
  background: var(--surface); font: 700 15px var(--sans); color: var(--ink); cursor: pointer;
}
select { appearance: none; padding-right: 40px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314181d' stroke-width='2' stroke-linecap='square'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 12px center / 18px no-repeat; }
textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-wash);
}
input.amber { border-color: var(--warn); background: var(--warn-wash); box-shadow: 0 0 0 1px var(--warn); }

.vitals-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 16px; }
.vitals-row .field { margin: 0; }
.vitals-row input { font-family: var(--mono); font-size: 18px; }
.unit { color: var(--muted); font-weight: 400; }

.more { margin-top: 16px; }
.more > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 10px 0 6px; margin-left: -6px;
  font-weight: 700; color: var(--accent);
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before {
  content: ''; width: 8px; height: 8px; margin: 0 4px 0 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 150ms var(--ease);
}
.more[open] > summary::before { transform: rotate(45deg); }
.more > summary:hover { background: var(--accent-wash); }
.more-body { padding-top: 12px; }
.reveal { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line-strong); }
.medicine-line { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
.medicine-line .field { margin-bottom: 8px; }

/* ===================================================================== */
/* The chart: the digitised case sheet                                   */
/* ===================================================================== */

/* The patient's board: who this is, lit in the frame, before the eye moves. */
.chart-head { margin-bottom: 0; }
.chart-id.slab { margin-bottom: 0; padding-bottom: 20px; }
.chart-id .slab-row { align-items: flex-start; flex-wrap: nowrap; }
.photo-block { display: grid; gap: 6px; justify-items: start; }
.photo-upload > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 6px; margin-left: -6px;
  font-size: 15px; font-weight: 700; color: var(--accent);
}
.slab .photo-upload > summary { color: var(--frame-lit); }
.photo-upload > summary::-webkit-details-marker { display: none; }
.photo-upload > summary svg { width: 18px; height: 18px; }
.photo-upload > summary:hover { background: var(--accent-wash); }
.slab .photo-upload > summary:hover { background: var(--frame-3); color: #fff; }
.photo-upload form { max-width: 280px; margin-top: 6px; }
.slab .photo-upload .label { color: var(--frame-muted); }

.identity { flex: 1; min-width: 240px; }
.identity h1 { font-size: 34px; line-height: 1.15; margin: 0 0 10px; }
.identity-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 6px; color: var(--ink-2); }
.slab .identity-line { color: #dfe4e8; }
.slab .identity-line.muted { color: var(--frame-muted); }
.identity-line .num.strong, .roll { font-family: var(--mono); font-weight: 600; letter-spacing: 0.01em; }
.slab .identity-line .strong { color: #fff; font-size: 18px; }
.slab .chip { background: var(--frame-2); border-color: var(--frame-line); color: #fff; }

.chart-side { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 188px; }
/* The blood group: the board's biggest lit figure, in a module of its own. */
.blood { padding: 10px 16px 14px; background: var(--frame-2); border: 1px solid var(--frame-line); }
.blood-value { font-size: 44px; line-height: 1.05; }
.chart-head:not(:has(.slab)) .blood { background: var(--frame); }

/* Allergies: a red band closed by a doubled red rule, across the whole workspace. */
.allergy {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; font-size: 18px; line-height: 1.4;
  background: var(--danger-wash); color: var(--danger-ink);
  border-top: 3px double var(--danger); border-bottom: 3px double var(--danger);
  box-shadow: 0 0 0 100vmax var(--danger-wash); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}
.allergy svg { width: 24px; height: 24px; color: var(--danger); margin-top: 1px; }
.allergy strong { margin-right: 12px; color: var(--danger); font-weight: 800; }
.allergy-none {
  background: var(--surface-2); color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  box-shadow: 0 0 0 100vmax var(--surface-2); font-size: 16px;
}
.allergy-none strong { color: var(--ink-2); }
/* On a form the band runs on under the board, and the form starts below it. */
.allergy-standalone { margin-bottom: 28px; }
.slab + .allergy-standalone { margin-top: -32px; }

.chart-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 0.7fr)) minmax(0, 2fr); margin: 0; border-bottom: 1px solid var(--line); }
.chart-facts > div { padding: 14px 20px 16px; border-left: 1px solid var(--line); }
.chart-facts > div:first-child { border-left: 0; padding-left: 0; }
.chart-facts dt { font-size: 14px; font-weight: 600; color: var(--muted); }
.chart-facts dd { margin: 4px 0 0; font-size: 20px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.chart-facts dd.num { font: 600 24px/1.2 var(--mono); }
.chart-facts-wide dd { font: 400 16px/1.5 var(--sans); }

/* Which doctor this patient is with. Only that doctor can open the record. */
.care {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px;
  padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.care-who { flex: 1 1 260px; min-width: 0; display: grid; gap: 2px; }
.care-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.care-name { font-size: 18px; font-weight: 700; color: var(--restricted); }
.care-name-none { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.care-who .muted { font-size: 14px; }
.care form { display: flex; align-items: center; gap: 8px; margin: 0; }
.care select { min-height: 48px; font-size: 16px; max-width: 260px; }

.chart-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.chart-rail .panel { position: sticky; top: 76px; }

.note-line { display: flex; align-items: center; gap: 10px; margin: -12px 0 24px; padding: 0; color: var(--ink-2); }
.note-line svg { width: 20px; height: 20px; color: var(--muted); }

/* The patient strip: the board, folded to one line, stays in view while the history scrolls. */
.chart-strip {
  position: fixed; top: 0; left: var(--sidebar); right: 0; z-index: 25;
  display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap;
  min-height: 56px; padding: 6px var(--gutter);
  background: var(--frame-2); color: #fff; border-bottom: 1px solid var(--frame-line);
  box-shadow: 0 8px 20px rgba(20, 24, 29, 0.18);
  transform: translateY(-110%); visibility: hidden;
  transition: transform 200ms var(--ease), visibility 0s linear 200ms;
}
.chart-strip.is-visible { transform: translateY(0); visibility: visible; transition: transform 200ms var(--ease); }
.chart-strip-name { font-weight: 700; font-size: 17px; }
.chart-strip .num { font-family: var(--mono); color: var(--frame-muted); }
.chart-strip-blood { color: var(--frame-muted); }
.chart-strip-blood strong { font-family: var(--mono); color: #fff; margin-left: 6px; font-size: 18px; }
.chart-strip-allergy {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  background: var(--danger); color: #fff; font-weight: 700;
}
.chart-strip-allergy svg { width: 18px; height: 18px; }
.chart-strip .muted { color: var(--frame-muted); }
.chart-strip .btn { margin-left: auto; }

.stack-kv { margin: 0; padding: 4px 0 16px; }
.stack-kv dt { margin-top: 16px; font-size: 14px; font-weight: 600; color: var(--muted); }
.stack-kv dd { margin: 4px 0 0; }
.stack-kv dd.chips { margin-top: 6px; }

/* Identity photo. A real photo when this machine holds one, a neutral frame
 * when not -- never coloured initials, which confirm nothing (DECISIONS #18). */
.photo {
  width: 46px; height: 56px; flex: none; display: block; object-fit: cover;
  border: 1px solid var(--line); background: var(--surface-3);
}
.photo-lg { width: 92px; height: 116px; }
.slab .photo { border-color: var(--frame-line); background: var(--frame-2); }
.photo-empty { display: grid; place-items: center; align-content: center; gap: 2px; }
.photo-empty svg { width: 24px; height: 24px; color: #8a939b; }
.photo-lg.photo-empty svg { width: 40px; height: 40px; }
.photo-caption { font-size: 14px; color: var(--muted); }
.slab .photo-caption, .slab .photo-empty svg { color: var(--frame-muted); }

/* ===================================================================== */
/* Banners                                                               */
/* ===================================================================== */

.banner {
  display: flex; gap: 10px; padding: 14px 18px; margin: 0 0 20px;
  border: 1px solid; font-size: 16px;
}
.banner strong { display: block; margin-bottom: 2px; }
.banner form { margin: 8px 0 0; }
.banner-danger { background: var(--danger-wash); border-color: var(--danger); color: var(--danger-ink); }
.banner-danger strong { color: var(--danger); }
.banner-warn { background: var(--warn-wash); border-color: var(--warn); color: var(--warn-ink); }
.banner-info { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink-2); }
.banner-info strong { color: var(--ink); }
.banner-ok { background: var(--ok-wash); border-color: var(--ok); color: var(--ok-ink); }

/* ===================================================================== */
/* Visits: the history as a ledger                                       */
/* ===================================================================== */

.visits { display: grid; }
.visit { border-bottom: 1px solid var(--line); }
.visit:last-child { border-bottom: 0; }
.visit > summary {
  list-style: none; cursor: pointer;
  display: grid; grid-template-columns: 16px 196px minmax(0, 1fr) auto; align-items: center; gap: 4px 14px;
  min-height: 60px; padding: 10px 0;
  transition: background-color 120ms var(--ease);
}
.visit > summary::-webkit-details-marker { display: none; }
.visit > summary::before {
  content: ''; width: 8px; height: 8px; justify-self: center;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(-45deg); transition: transform 150ms var(--ease);
}
.visit[open] > summary::before { transform: rotate(45deg); }
.visit > summary:hover { background: var(--surface-2); }
.visit > summary:focus-visible { outline-offset: -2px; }
.visit[open] > summary { background: var(--surface-2); }
.visit .when { font-weight: 700; font-variant-numeric: tabular-nums; }
.visit-outcome { color: var(--ink-2); font-size: 15px; justify-self: end; padding-right: 4px; }
.visit .body { padding: 16px 16px 20px 30px; background: var(--surface-2); border-top: 1px solid var(--line); }
/* A voided entry keeps its place, struck through. */
.visit.voided .when { text-decoration: line-through; color: var(--muted); }
.visit.voided > summary .chip-strong { color: var(--muted); font-weight: 500; text-decoration: line-through; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 20px; margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-tight { grid-template-columns: 140px 1fr; gap: 8px 14px; }
.kv-visit .data { background: var(--surface); border: 1px solid var(--line); max-width: 420px; }

/* ===================================================================== */
/* Tables                                                                */
/* ===================================================================== */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 16px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th {
  padding-top: 10px; padding-bottom: 10px;
  font-size: 14px; font-weight: 700; color: var(--muted);
  background: transparent; border-bottom: 1px solid var(--ink);
}
table.data th:first-child, table.data td:first-child { padding-left: 0; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
table.data tbody tr:last-child td, table.data tbody tr:last-child th { border-bottom: 0; }
table.data tbody tr { transition: background-color 120ms var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .right { text-align: right; }
table.data tbody th { font-weight: 600; color: var(--ink-2); }
table.data-compact th, table.data-compact td { padding: 8px 12px; font-size: 15px; }
.visit .body table.data-compact th:first-child, .visit .body table.data-compact td:first-child { padding-left: 12px; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 16px; white-space: nowrap; }
.muted-cell { color: var(--muted); white-space: nowrap; }
td.time, .data td.num.muted-cell { font-weight: 600; color: var(--ink-2); }
.cell-sub { color: var(--muted); font-size: 14px; }
.cell-sub.num, .cell-sub .num { font-family: var(--mono); }
.strong-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.strong-link:hover { color: var(--accent); text-decoration: underline; }
tr.row-off td { color: var(--muted); }
.tick { width: 52px; }
.tick input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

table.bars th { width: 96px; }
table.bars td:last-child { width: 64px; }
.bar { display: block; height: 16px; background: var(--chart, #00929c); min-width: 2px; }

/* ===================================================================== */
/* Admin, queue, registers                                               */
/* ===================================================================== */

.sticky-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 0 0 20px; padding: 10px 0;
  background: var(--canvas); border-bottom: 1px solid var(--ink);
  box-shadow: 0 0 0 100vmax var(--canvas); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}

.jump {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 0;
  margin: 0 0 28px; padding: 0;
  background: var(--canvas); border-bottom: 1px solid var(--ink);
  box-shadow: 0 0 0 100vmax var(--canvas); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}
.jump a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px;
  color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 600;
  box-shadow: inset 0 -3px 0 transparent;
}
.jump a:first-child { padding-left: 0; }
.jump a:hover { color: var(--ink); box-shadow: inset 0 -3px 0 var(--line-strong); }

.danger-zone { margin-top: 18px; padding: 16px 18px; border: 1px solid var(--danger); background: var(--danger-wash); color: var(--danger-ink); }

.checklist { list-style: none; margin: 0; padding: 0; }
.check { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check-mark {
  width: 26px; height: 26px; flex: none; margin-top: 1px;
  border: 2px solid var(--line-strong); display: grid; place-items: center; color: #fff;
}
.check-mark svg { width: 16px; height: 16px; }
.check.done .check-mark { background: var(--ok); border-color: var(--ok); }
.check-title { font-weight: 700; }
.check-status { font-size: 15px; margin-top: 4px; color: var(--warn-ink); font-weight: 700; }
.check-status.ok { color: var(--ok-ink); }
.check-kind { display: inline-block; margin-top: 6px; font-size: 14px; color: var(--muted); }

.dupes { display: grid; }
.dupe { display: grid; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.dupe:first-child { padding-top: 0; }
.dupe:last-child { border-bottom: 0; padding-bottom: 0; }
.dupe .chip { justify-self: start; }
.dupe-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.compare > .card { padding-top: 16px; }
.keep-choice { margin-bottom: 16px; font-weight: 700; }
.compare-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.compare-head .name { font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.compare-head .name:hover { color: var(--accent); text-decoration: underline; }
.compare-col h3 { margin-top: 16px; }
.compare-visits { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.compare-visits li { padding: 8px 0; border-bottom: 1px solid var(--line); }

.register-image { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); }
.fastentry-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: start; }
.page-pane { position: sticky; top: 16px; }

/* ===================================================================== */
/* Sign in and first start                                               */
/* ===================================================================== */

.signin-page { min-height: 100vh; }
.signin { width: min(100% - 32px, 480px); margin: 0 auto; padding: 48px 0 40px; }

/* Sign-in: the board on the left holds who this is; the form stands on white. */
.signin-page:has(> .signin-board) { display: grid; grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr); }
.signin-page:has(> .signin-board) .signin { align-self: center; }
.signin-board {
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 48px 40px; background: var(--frame); color: var(--frame-ink);
}
.signin-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; color: inherit; text-decoration: none; }
.signin-brand:hover { color: inherit; }
.signin-board .signin-brand { flex-direction: column; align-items: flex-start; gap: 24px; margin: 0; color: #fff; }
.signin-board .signin-brand:focus-visible { outline-color: var(--frame-lit); }
.signin-unit { display: block; font-size: 22px; font-weight: 700; line-height: 1.25; }
.signin-board .signin-unit { font-size: 40px; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; margin-bottom: 8px; }
.signin-org { display: block; font-size: 15px; color: var(--muted); }
.signin-board .signin-org { font-size: 17px; color: var(--frame-muted); }

.demo-flag {
  margin: 0 0 24px; padding: 12px 16px;
  background: var(--warn-wash); border: 1px solid var(--warn); color: var(--warn-ink);
}

.signin-card { background: var(--surface); border-top: 2px solid var(--ink); padding: 24px 0 0; }
.signin-card h1 { font-size: 28px; margin-bottom: 4px; }
.signin-foot { margin: 20px 0 0; color: var(--muted); font-size: 15px; }
.signin-board .signin-foot { margin: 0; max-width: 42ch; color: var(--frame-muted); }

/* ===================================================================== */
/* Welcome -- the front door for anyone not signed in                    */
/* ===================================================================== */

.welcome-page, .verify-page { min-height: 100vh; display: flex; flex-direction: column; }
.welcome-header { background: var(--frame); color: var(--frame-ink); }
.welcome-bar {
  width: min(100% - 48px, 1200px); margin: 0 auto; min-height: 76px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.welcome-header .btn { background: transparent; border-color: var(--frame-line); color: #fff; }
.welcome-header .btn:hover { background: var(--frame-3); border-color: var(--frame-muted); }
.welcome-brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.welcome-brand:hover { color: inherit; }
.welcome-unit { display: block; font-size: 18px; font-weight: 700; line-height: 1.25; }
.welcome-org { display: block; font-size: 14px; color: var(--frame-muted); }

.welcome-footer {
  width: min(100% - 48px, 1200px); margin: 0 auto; min-height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 14px;
}

/* ===================================================================== */
/* The public page (DECISIONS #57)                                       */
/* The board grammar, turned outward: a graphite hero whose right half   */
/* is the centre's own token board, ruled sections on white ordered by   */
/* what a visitor needs, and one graphite board at the end.              */
/* ===================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html:has(body.site-page) { scroll-behavior: smooth; }
}
.site-page { min-height: 100vh; display: flex; flex-direction: column; background: var(--canvas); }

/* The header: the crest, the sections, Sign in. It casts a shadow once the
   page has moved under it. */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--frame); color: var(--frame-ink); border-bottom: 1px solid var(--frame-line);
  transition: box-shadow 240ms var(--ease);
}
.site-header.is-scrolled { box-shadow: 0 10px 28px rgba(20, 24, 29, 0.22); }
.site-bar { width: min(100% - 48px, 1200px); margin: 0 auto; min-height: 72px; display: flex; align-items: center; gap: 24px; }
.site-bar .welcome-brand { flex: none; }
.site-nav { position: relative; flex: 1; align-self: stretch; display: flex; justify-content: flex-end; }
.site-nav a {
  display: inline-flex; align-items: center; padding: 0 12px;
  color: var(--frame-soft); font-size: 15px; font-weight: 600; text-decoration: none;
  transition: color 160ms var(--ease);
}
.site-nav a:hover, .site-nav a[aria-current] { color: #fff; }
/* The lit mark under the section being read. One element, carried from link
   to link, so the eye follows it instead of watching underlines blink. */
.site-nav-mark {
  position: absolute; left: 0; bottom: -1px; width: 1px; height: 3px;
  background: var(--frame-lit); transform-origin: 0 0; opacity: 0; pointer-events: none;
  transition: transform 420ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms var(--ease);
}
.site-menu { display: none; }
.site-header .btn { flex: none; background: transparent; border-color: var(--frame-line); color: #fff; }
.site-header .btn:hover { background: var(--frame-3); border-color: var(--frame-muted); }
.site-header :focus-visible, .site-hero :focus-visible, .site-close :focus-visible { outline-color: var(--frame-lit); }

main.site { width: min(100% - 48px, 1200px); max-width: none; margin: 0 auto; padding: 0; flex: 1; }
.site-contact, .site-login { scroll-margin-top: 72px; }
/* A jump lands with the section's rule just under the header: the section's
   own top padding is the breathing room. */
.site-section { scroll-margin-top: 0; }

/* The hero: who this is and what to do, beside the centre's token board. */
.site-hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px 72px; align-items: center;
  padding: 56px 0 64px; background: var(--frame); color: var(--frame-ink);
  box-shadow: 0 0 0 100vmax var(--frame); clip-path: inset(0 -100vmax);
}
.site-hero-solo { grid-template-columns: minmax(0, 1fr); }
.site-hero-crest { display: block; margin-bottom: 24px; }
.site-hero-crest img { display: block; width: 88px; height: auto; }
.site-hero-copy h1 { font-size: 64px; line-height: 1.02; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 18px; color: #fff; text-wrap: balance; }
.site-tagline { max-width: 32ch; margin: 0 0 32px; font-size: 22px; line-height: 1.45; color: var(--frame-soft); text-wrap: pretty; }
.site-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.site-hero .btn-primary { background: var(--accent); border-color: var(--accent); }
.site-hero .btn-primary:hover { background: var(--accent-board-hover); border-color: var(--accent-board-hover); }
.site-hero .btn:not(.btn-primary) { background: transparent; border-color: var(--frame-line); color: #fff; }
.site-hero .btn:not(.btn-primary):hover { background: var(--frame-3); border-color: var(--frame-muted); }
.site-actions .btn svg { transition: transform 160ms var(--ease); }
.site-actions .btn:hover svg:last-child { transform: translateX(3px); }

/* At a glance: packed cells ruled in board lines, the ambulance across the top. */
.site-glance {
  margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  background: var(--frame-line); border: 1px solid var(--frame-line);
}
.site-glance > div { background: var(--frame-2); padding: 18px 20px 20px; min-width: 0; }
.site-glance > .is-wide, .site-glance-lead { grid-column: 1 / -1; }
.site-glance dt { color: var(--frame-muted); font-size: 14px; margin-bottom: 4px; }
.site-glance dd { margin: 0; color: #fff; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.site-glance a { color: var(--frame-lit); text-decoration: none; }
.site-glance a:hover { color: #fff; text-decoration: underline; text-underline-offset: 5px; }
.site-glance .num { font-size: 26px; font-weight: 700; letter-spacing: 0.01em; }
.site-glance-lead { background: var(--frame) !important; padding: 22px 24px 24px !important; }
.site-glance-lead dt { color: var(--frame-soft); font-weight: 600; }
.site-glance-lead .num { font-size: 46px; line-height: 1.1; }
/* The page's one authored moment: the board switches on, a cell at a time,
   the way a counter's token display lights when the clinic opens. */
@media (prefers-reduced-motion: no-preference) {
  .site-glance > div { animation: glance-on 560ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .site-glance > div:nth-child(2) { animation-delay: 110ms; }
  .site-glance > div:nth-child(3) { animation-delay: 190ms; }
  .site-glance > div:nth-child(4) { animation-delay: 270ms; }
  .site-glance-lead .num { animation: glance-lit 900ms 180ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .site-hero-photo img { animation: site-reveal 900ms 200ms cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@keyframes glance-on { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
@keyframes glance-lit { from { color: var(--frame-muted); } to { color: var(--frame-lit); } }
@keyframes site-reveal { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }

/* The centre's photograph runs across the foot of the hero. */
.site-hero-photo { grid-column: 1 / -1; margin: 8px 0 0; }
.site-hero-photo img { display: block; width: 100%; height: auto; aspect-ratio: 5 / 2; object-fit: cover; border: 1px solid var(--frame-line); }

.site-demo { margin: 24px 0 0; }

/* A section: an ink rule, the heading, one line of introduction. More room
   above the rule than below the heading, so each section reads as a unit. */
.site-section { padding: 88px 0 0; }
.site-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px 32px; flex-wrap: wrap;
  border-top: 2px solid var(--ink); padding-top: 16px; margin-bottom: 32px;
}
.site-section-head h2 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.015em; }
.site-section-head p { margin: 0; color: var(--muted); max-width: 52ch; }

.site-about { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 64px; align-items: start; }
.site-about-solo { grid-template-columns: minmax(0, 1fr); }
.site-about-text { margin: 0; font-size: 22px; line-height: 1.6; max-width: 56ch; color: var(--ink-2); text-wrap: pretty; }
.site-director { margin: 0; display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 24px; align-items: start; border-top: 1px solid var(--line); padding-top: 24px; }
.site-director figcaption { display: grid; gap: 4px; }
.site-director .pp-name { font-size: 22px; padding-top: 0; }
.site-director blockquote { margin: 12px 0 0; padding: 0; color: var(--ink-2); font-size: 17px; line-height: 1.6; text-wrap: pretty; }
.site-director .pp-initials { font-size: 44px; }

/* Office holders: the office first, then who holds it. */
.site-offices { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); column-gap: 48px; }
.site-offices li { display: grid; gap: 2px; padding: 16px 0 18px; border-bottom: 1px solid var(--line); }
.site-office-role { color: var(--accent-ink); font-size: 15px; font-weight: 700; }
.site-office-name { color: var(--ink); font-size: 20px; font-weight: 700; line-height: 1.3; }
.site-office-note { color: var(--muted); font-size: 15px; }

/* People: packed edge to edge, each cell closed by its own rule, a portrait
   beside the name. The doctors larger than the staff. */
.pp-grid { list-style: none; margin: 0; padding: 0 1px 1px 0; display: grid; }
.pp-grid-large { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.pp-grid-small { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.pp {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 16px; row-gap: 2px;
  align-content: start; padding: 16px; margin: 0 -1px -1px 0; border: 1px solid var(--line);
  transition: background-color 160ms var(--ease);
}
.pp:hover { background: var(--surface-2); }
.pp-grid-large .pp { grid-template-columns: 112px minmax(0, 1fr); padding: 20px; column-gap: 20px; }
.pp > .pp-photo { grid-row: 1 / span 3; }
.pp-photo { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--surface-2); }
.pp-initials {
  display: grid; place-items: center; background: var(--frame); color: var(--frame-lit);
  font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: 0.04em;
}
.pp-grid-large .pp-initials { font-size: 30px; }
.pp-name { font-weight: 700; font-size: 18px; line-height: 1.3; color: var(--ink); padding-top: 2px; }
.pp-grid-large .pp-name { font-size: 20px; padding-top: 6px; }
.pp-role { color: var(--ink-2); font-size: 16px; }
.pp-note { color: var(--muted); font-size: 15px; }

.site-consultants { margin-top: 48px; }
.site-consultants h3 { font-size: 20px; margin: 0 0 8px; }

/* Facilities: columns side by side, each opened by a rule on its left. */
.site-facilities {
  list-style: none; margin: 0 0 0 -25px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); row-gap: 24px;
  clip-path: inset(0 0 0 25px);
}
.site-facilities li { padding: 2px 24px 4px; border-left: 1px solid var(--line); }
.site-facilities p { margin: 8px 0 0; color: var(--ink-2); max-width: 46ch; }

/* Programmes: a dated ledger. */
.site-ledger { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.site-ledger > li { padding: 20px 0; border-top: 1px solid var(--line); }
.site-ledger > li:first-child { border-top: 0; padding-top: 4px; }
.site-ledger-title { display: block; font-weight: 700; font-size: 19px; color: var(--ink); }
.site-ledger-when { display: block; color: var(--accent-ink); font-weight: 600; font-size: 15px; margin-top: 2px; }
.site-ledger p { margin: 6px 0 0; color: var(--ink-2); max-width: 62ch; }
.site-ledger-dated { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; }
.site-ledger-dated .site-ledger-when { margin-top: 3px; }

/* The closing board: how to reach the centre, beside the ways in. */
.site-close {
  margin-top: 104px; padding: 56px 0 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px 72px; align-items: start;
  background: var(--frame); color: var(--frame-ink);
  box-shadow: 0 0 0 100vmax var(--frame); clip-path: inset(0 -100vmax);
}
.site-close h2 { margin: 0 0 20px; font-size: 32px; font-weight: 800; letter-spacing: -0.015em; color: #fff; }
.site-contact dl {
  margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  background: var(--frame-line); border: 1px solid var(--frame-line);
}
.site-contact dl > div { background: var(--frame); padding: 16px 18px 18px; min-width: 0; }
.site-contact dl > .is-wide, .site-contact-lead { grid-column: 1 / -1; }
.site-contact dt { color: var(--frame-muted); font-size: 14px; margin-bottom: 4px; }
.site-contact dd { margin: 0; color: #fff; font-size: 17px; overflow-wrap: anywhere; }
.site-contact a { color: var(--frame-lit); text-decoration: none; }
.site-contact a:hover { color: #fff; text-decoration: underline; text-underline-offset: 5px; }
.site-contact a.num { font-size: 24px; font-weight: 700; }
.site-contact-lead { background: var(--frame-2) !important; }
.site-contact-lead a.num { font-size: 36px; }
.site-contact-none { margin: 0; color: var(--frame-muted); }

.site-doors { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--frame-line); }
.site-doors > li { border-bottom: 1px solid var(--frame-line); }
.site-door {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'title go' 'text go';
  gap: 4px 24px; align-items: center; padding: 18px 16px 18px 0;
  color: var(--frame-soft); text-decoration: none; transition: background-color 160ms var(--ease), padding-left 260ms var(--ease);
}
.site-door:hover { color: var(--frame-soft); background: var(--frame-2); padding-left: 16px; }
.site-door-title { grid-area: title; font-size: 20px; font-weight: 700; color: #fff; }
.site-door-text { grid-area: text; font-size: 15px; max-width: 54ch; }
.site-door-go { grid-area: go; display: inline-flex; align-items: center; gap: 4px; color: var(--frame-lit); font-weight: 700; white-space: nowrap; }
.site-door-go svg { width: 18px; height: 18px; transition: transform 160ms var(--ease); }
.site-door:hover .site-door-go svg { transform: translateX(3px); }
.site-login-note { margin: 20px 0 0; color: var(--frame-muted); font-size: 15px; }
.site-page .welcome-footer { border-top: 0; }
@media (prefers-reduced-motion: reduce) { .site-door, .site-nav-mark { transition: none; } }

@media (max-width: 1040px) {
  .site-nav { display: none; }
  /* On a narrow screen the sections fold behind one button. */
  .site-menu { display: block; position: relative; margin-left: auto; }
  .site-menu > summary {
    list-style: none; display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px;
    border: 1px solid var(--frame-line); color: #fff; font-weight: 700; cursor: pointer;
  }
  .site-menu > summary::-webkit-details-marker { display: none; }
  .site-menu > summary svg { width: 20px; height: 20px; }
  .site-menu[open] > summary { background: var(--frame-3); }
  .site-menu-body {
    position: absolute; right: 0; top: calc(100% + 12px); min-width: 240px; display: grid; padding: 6px 0;
    background: var(--frame-2); border: 1px solid var(--frame-line); box-shadow: var(--shadow-pop);
  }
  .site-menu-body a { display: flex; align-items: center; min-height: 48px; padding: 0 18px; color: var(--frame-soft); font-weight: 600; text-decoration: none; }
  .site-menu-body a:hover { background: var(--frame-3); color: #fff; }
  .site-hero { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 40px 0 48px; }
  .site-hero-copy h1 { font-size: 48px; }
  .site-about { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .site-close { grid-template-columns: minmax(0, 1fr); gap: 48px; }
}
@media (max-width: 640px) {
  main.site, .site-bar { width: min(100% - 32px, 1200px); }
  .site-bar { gap: 8px; min-height: 64px; }
  /* The crest stands for the name, so the bar has room for Sections and Sign in. */
  .site-bar .welcome-brand > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .site-hero-crest { display: none; }
  .site-section { scroll-margin-top: 16px; }
  .site-contact, .site-login { scroll-margin-top: 64px; }
  .site-hero-copy h1 { font-size: 38px; }
  .site-tagline { font-size: 19px; }
  .site-actions .btn { flex: 1 1 100%; justify-content: center; }
  .site-glance, .site-contact dl { grid-template-columns: minmax(0, 1fr); }
  .site-glance-lead .num { font-size: 36px; }
  .site-contact-lead a.num { font-size: 30px; }
  .site-section { padding-top: 56px; }
  .site-section-head h2, .site-close h2 { font-size: 26px; }
  .site-about-text { font-size: 18px; }
  .site-director { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; }
  .pp-grid-large, .pp-grid-small { grid-template-columns: minmax(0, 1fr); }
  .pp, .pp-grid-large .pp { grid-template-columns: 64px minmax(0, 1fr); padding: 12px 0; border-width: 0 0 1px; margin: 0; }
  .pp-grid { border-top: 1px solid var(--line); padding: 0; }
  .pp:hover { background: transparent; }
  .pp-grid-large .pp-initials { font-size: 20px; }
  .pp-grid-large .pp-name { font-size: 18px; padding-top: 2px; }
  .site-ledger-dated { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .site-close { margin-top: 72px; padding: 40px 0; }
  .site-door { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'title' 'text' 'go'; padding-right: 0; }
  .site-door:hover { padding-left: 0; }
  .site-consultants .data thead { display: none; }
  .site-consultants .data tr { display: grid; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .site-consultants .data td { border: 0; padding: 1px 0 !important; }
}

/* Keeping the public page, in the console. */
.site-list { list-style: none; margin: 0 0 16px; padding: 0; border-top: 1px solid var(--line); }
.site-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: start; padding: 16px 0; border-bottom: 1px solid var(--line); }
.site-row:not(:has(.site-thumb)) { grid-template-columns: minmax(0, 1fr) auto; }
.site-thumb { display: block; width: 56px; height: 56px; object-fit: cover; }
.site-thumb-none { display: grid; place-items: center; background: var(--frame); color: var(--frame-lit); font-family: var(--mono); font-weight: 700; }
.site-row-note { margin: 4px 0 0; color: var(--muted); font-size: 15px; max-width: 70ch; }
.site-move { display: flex; gap: 6px; }
.site-move form { margin: 0; }
.site-edit, .site-add { margin-top: 8px; }
.site-edit > summary, .site-add > summary { display: inline-flex; align-items: center; min-height: 48px; cursor: pointer; color: var(--accent); font-weight: 700; }
.site-edit[open] > summary, .site-add[open] > summary { margin-bottom: 8px; }
.site-edit form, .site-add form { margin: 0 0 12px; }
.site-photo-now { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.site-photo-now img { display: block; width: 240px; height: 150px; object-fit: cover; border: 1px solid var(--line); }

/* The public certificate check. */
.verify { width: min(100% - 32px, 640px); margin: 0 auto; padding: 40px 0 56px; }
.verify-card { background: var(--surface); border: 1px solid var(--line-strong); overflow: hidden; margin-bottom: 16px; }
.verify-card .kv { padding: 20px 24px 24px; }
.verdict { display: flex; align-items: center; gap: 16px; padding: 20px 24px; font-size: 16px; border-bottom: 1px solid; }
.verdict strong { display: block; font-size: 20px; }
.verdict-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; color: #fff; }
.verdict-icon svg { width: 24px; height: 24px; }
.verdict-ok { background: var(--ok-wash); border-color: var(--ok); color: var(--ok-ink); }
.verdict-ok .verdict-icon { background: var(--ok); }
.verdict-bad { background: var(--danger-wash); border-color: var(--danger); color: var(--danger-ink); }
.verdict-bad .verdict-icon { background: var(--danger); }
.verdict-warn { background: var(--warn-wash); border-color: var(--warn); color: var(--warn-ink); border-bottom: 0; }
.verdict-warn .verdict-icon { background: var(--warn); }

/* ===================================================================== */
/* Motion: state changes only                                            */
/* ===================================================================== */

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); visibility: hidden; } }
/* A board's figures come up like a display being lit, once, when the page arrives. */
@keyframes lit { from { opacity: 0.25; color: var(--frame-muted); } }
@media (prefers-reduced-motion: no-preference) {
  .readout-n, .blood-value, .occ-n, .wait-n { animation: lit 420ms var(--ease) both; }
  .readout:nth-child(2) .readout-n { animation-delay: 40ms; }
  .readout:nth-child(3) .readout-n { animation-delay: 80ms; }
  .readout:nth-child(4) .readout-n { animation-delay: 120ms; }
  .readout:nth-child(5) .readout-n { animation-delay: 160ms; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .toast { animation: none; }
}

@media (forced-colors: active) {
  .option:has(input:checked) { outline: 3px solid CanvasText; outline-offset: -4px; }
  .nav-item[aria-current='page'] { outline: 2px solid CanvasText; outline-offset: -4px; }
}

@media (max-width: 1200px) {
  .dash, .chart-body { grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; }
  .readout { min-width: 96px; padding: 4px 16px; }
}
/* ===================================================================== */
/* Prescriptions, the pharmacy and the printed slip (DECISIONS #39)       */
/* ===================================================================== */

.rx { border: 0; padding: 0; margin: 0; min-width: 0; }
.rx-title { display: block; padding: 0; margin: 0 0 4px; font-size: 17px; font-weight: 650; color: var(--ink); }
.rx-title .muted { font-weight: 500; font-size: 15px; }
.rx-line { margin-bottom: 4px; }

.rx-line .field { margin-bottom: 8px; }
.rx-where { margin-top: 16px; }
.rx-record .plain { margin: 6px 0; }
.rx-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.rx-bought { margin-left: 8px; vertical-align: 1px; }
.rx-record .btn-row { margin-top: 8px; }
.rx-order { display: grid; gap: 10px; }
.rx-order .option-row { min-height: 64px; align-items: center; }
.rx-how { display: block; font-size: 15px; margin-top: 2px; }

/* The pharmacy's scan box: the counter's search box, on the page itself. */
.scanbox { position: relative; display: flex; gap: 12px; align-items: center; margin: 0 0 20px; max-width: 760px; }
.scanbox > svg { position: absolute; left: 16px; width: 22px; height: 22px; color: var(--muted); pointer-events: none; }
.scanbox input[type='search'] { min-height: 56px; padding-left: 50px; font-size: 17px; }
.scanbox .btn { min-height: 56px; flex: none; }

/* The slip: a plain page that prints on A5 or A4, or saves as a PDF. */
.slip-page { background: var(--surface-2); margin: 0; padding: 24px 16px 64px; }
.slip-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 720px; margin: 0 auto 16px; }
.slip {
  max-width: 720px; margin: 0 auto; padding: 32px 36px;
  background: #fff; color: #101828; border: 1px solid var(--line-strong);
}
.slip-head { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 2px solid #101828; }
.slip-unit { margin: 0; font-size: 20px; font-weight: 700; }
.slip-org { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.slip-number { margin-left: auto; display: grid; justify-items: end; gap: 2px; font-size: 14px; }
.slip-number strong { font-size: 17px; }
.slip-k { text-transform: uppercase; letter-spacing: 0.06em; font-size: 14px; color: var(--muted); font-weight: 600; }
.slip-who { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; margin: 20px 0; }
.slip-who dt { color: var(--muted); }
.slip-who dd { margin: 0; font-weight: 600; }
.slip-items { width: 100%; border-collapse: collapse; font-size: 16px; }
.slip-items th { text-align: left; font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 10px 8px 0; border-bottom: 1px solid #101828; }
.slip-items td { padding: 12px 10px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.slip-foot { margin-top: 28px; }
.slip-foot p { margin: 0 0 4px; }

@media print {
  @page { margin: 12mm; }
  .slip-page { background: #fff; padding: 0; }
  .slip-tools, .slip-page .toast { display: none !important; }
  .slip { border: 0; padding: 0; max-width: none; }
}

/* ===================================================================== */
/* Reports (DECISIONS #40)                                                */
/* ===================================================================== */

.report-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.segmented { display: inline-flex; border: 1px solid var(--ink); overflow: hidden; background: var(--surface); }
.segmented a {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px;
  color: var(--ink-2); font-weight: 700; text-decoration: none; border-left: 1px solid var(--ink);
}
.segmented a:first-child { border-left: 0; }
.segmented a:hover { background: var(--surface-2); color: var(--ink); }
.segmented a[aria-current='page'] { background: var(--accent); color: #fff; }
.report-step { display: flex; align-items: center; gap: 12px; }
.report-step svg { width: 18px; height: 18px; }
.report-step [aria-disabled='true'] { opacity: 0.45; pointer-events: none; }
.report-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
.report-panel { margin-bottom: 20px; }
.report-sub { font-size: 15px; font-weight: 700; color: var(--ink-2); margin: 24px 0 10px; }
.report-sub.flush-top { margin-top: 0; }

/* The period is the heading; "So far" says it is still running (DECISIONS #52). */
.report-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.report-sofar {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px;
  border: 1px dashed var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 700; letter-spacing: 0;
}
.page-sub { max-width: 72ch; }
/* What changed: the page's peak (DECISIONS #53). How many came, in display
 * type with the figures at full weight; the change beside it, marked in the
 * brand teal; the commonest complaint and the biggest mover, quieter, apart. */
.report-lead {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 20px 40px; align-items: end;
  margin: 4px 0 32px; padding: 28px 0 30px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line);
}
.lead-main {
  margin: 0; max-width: 18ch; font-size: 52px; line-height: 1.08; letter-spacing: -0.03em;
  font-weight: 400; color: var(--ink-2); text-wrap: balance;
}
.report-lead > .lead-main { max-width: 32ch; font-size: 30px; line-height: 1.25; letter-spacing: -0.02em; }
.lead-n { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.lead-change { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 16px 0 0; font-size: 18px; color: var(--ink-2); }
.lead-change strong { color: var(--ink); font-weight: 700; }
.lead-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  background: var(--accent-wash); color: var(--accent-ink); font-weight: 700; font-variant-numeric: tabular-nums;
}
.lead-pill .tile-arrow { fill: currentColor; }
.lead-more { padding: 4px 0 4px 32px; border-left: 1px solid var(--line); }
.lead-more p { margin: 0; max-width: 46ch; font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.lead-more p + p { margin-top: 12px; }
.report-lead p + p { margin-top: 4px; }
.report-toc { display: flex; flex-wrap: wrap; gap: 0 4px; margin: 0 0 16px; }
.report-toc a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 12px; font-weight: 700; }
.report-toc a:first-child { padding-left: 0; }
.report-toc a:hover { background: var(--surface-2); }
.report-section, .report-panel { scroll-margin-top: 16px; }
.report-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; }
.hint { max-width: 80ch; }
.data tr.is-total th, .data tr.is-total td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.num-col { text-align: right; width: 160px; font-variant-numeric: tabular-nums; }

/* Headline figures, each with how it compares to the period before. */
.tiles {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 36px;
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line);
}
.tile { min-width: 0; padding: 16px 20px; border-left: 1px solid var(--line); }
.tiles > .tile:first-child { padding-left: 0; }
.tile:first-child { border-left: 0; }
.tile-k { font-size: 14px; font-weight: 500; color: var(--muted); }
.tile-n { font: 600 32px/1.2 var(--mono); letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile-d { margin-top: 2px; font-size: 14px; color: var(--ink-2); }

/* Charts (DECISIONS #42, #52). One series, one validated hue; hairline grid;
 * bars capped at 24px with a square end; every figure drawn as it is.
 * Each plot is one keyboard stop, read with the arrow keys. */
.viz { --chart: #00929c; margin: 0; }
.viz-plot { position: relative; height: 200px; margin: 22px 0 0 44px; }
.viz-grid { position: absolute; inset: 0; pointer-events: none; }
.viz-gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.viz-tick { position: absolute; right: calc(100% + 8px); top: -10px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.viz-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.viz-bar { display: block; width: min(24px, 72%); min-height: 1px; background: var(--chart); }
.viz-bar.is-partial { background: var(--chart-soft); }
.viz-zero { display: block; width: min(24px, 72%); height: 0; }
.viz-col.is-active .viz-bar { filter: brightness(1.15); }
.viz-col.is-active::after {
  content: ''; position: absolute; inset: 0 -1px; background: var(--ink); opacity: 0.06; pointer-events: none;
}
.viz-slot { display: block; width: min(24px, 72%); height: 0; }
.viz-val { position: absolute; left: 50%; transform: translateX(-50%); font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.viz-x { display: flex; gap: 2px; margin: 6px 0 0 44px; }
.viz-x span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 14px; color: var(--muted); white-space: nowrap; }
.viz-table { margin-top: 8px; }
.viz-table summary { display: inline-flex; align-items: center; min-height: 48px; color: var(--accent); font-weight: 700; cursor: pointer; }
.viz-table table { margin-top: 4px; }
.viz-table th a { display: flex; align-items: center; min-height: 48px; }
.viz-tip {
  position: absolute; z-index: 70; pointer-events: none; display: grid; gap: 2px; max-width: 260px;
  padding: 8px 12px; background: var(--frame); color: #fff; box-shadow: var(--shadow-pop); font-size: 14px;
}
.viz-tip strong { font-size: 15px; }
.viz-tip span { color: #c9d0d8; }

.viz-empty { margin: 0; padding: 18px 20px; background: var(--surface-2); color: var(--ink-2); max-width: 80ch; }

.barlist { --chart: #00929c; margin: 0; }
.barlist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
/* Label, bar, figure, and (given a total) its share, each in a column of its own. */
.barlist-row {
  display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) minmax(3ch, auto);
  gap: 12px; align-items: center; min-height: 32px;
}
.barlist.has-share .barlist-row { grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) minmax(3ch, auto) 4.5ch; }
.barlist-label { font-size: 15px; color: var(--ink-2); overflow-wrap: anywhere; }
.barlist-label a { display: flex; align-items: center; min-height: 48px; width: 100%; }
.barlist-track { display: block; min-width: 0; }
.barlist-bar { display: block; height: 14px; background: var(--chart); }
.barlist-bar.c1 { background: var(--cat-1); }
.barlist-bar.c2 { background: var(--cat-2); }
.barlist-bar.c3 { background: var(--cat-3); }
.barlist-bar.c4 { background: var(--cat-4); }
.barlist-bar.r0 { background: var(--line-strong); }
.barlist-bar.r1 { background: #73c0c7; }
.barlist-bar.r2 { background: #2da6b0; }
.barlist-bar.r3 { background: #048891; }
.barlist-bar.r4 { background: #026970; }
.barlist-bar.r5 { background: #014c52; }
.barlist-value { font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.barlist-more { margin-top: 6px; }
.barlist-more summary { display: inline-flex; align-items: center; min-height: 48px; color: var(--accent); font-weight: 700; cursor: pointer; }

/* Finding a past report: a month's days, a year's months, as large links. */
.daygrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.daygrid-head { text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.daycell {
  display: grid; align-content: center; justify-items: center; min-height: 56px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); text-decoration: none;
}
a.daycell:hover { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }
.daycell-n { font-size: 16px; font-weight: 700; }
.daycell-w { display: none; font-size: 14px; color: var(--muted); }
.daycell-v { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.daycell.is-future, .monthcell.is-future { background: var(--surface-2); color: var(--muted); }
.monthgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.monthcell {
  display: grid; gap: 2px; align-content: center; min-height: 64px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
a.monthcell:hover { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }
.monthcell-n { font-weight: 700; }
.monthcell-v { font-size: 14px; color: var(--muted); }
.report-find { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.report-find .field { margin: 0; min-width: 180px; }
.panel-head .btn-sm { margin-left: 8px; }

/* ---- Reports in more detail (DECISIONS #51, #52) ----
   One hue (#00929c) for the period itself, a lighter step of it (#99d3d9) for
   the point still being counted; the period before as a dashed slate line
   (#525c6b: 3:1 on white, and apart from the teal for every kind of colour
   vision, checked with the dataviz validator); a five-step ramp of the same
   teal for the heatmap, validated as ordinal on white. Text never wears a
   series colour. */
:root { --chart-soft: #99d3d9; --chart-before: #525c6b; }
.tiles-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tile-d { display: flex; align-items: center; gap: 6px; text-wrap: pretty; }
.tile-arrow { flex: none; width: 12px; height: 12px; fill: var(--ink-2); }

.viz-line .viz-plot, .viz[data-chart='columns'] .viz-plot { cursor: crosshair; }
.viz-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.viz-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.viz-path, .viz-path-before, .viz-path-partial { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.viz-path { stroke: var(--chart); }
.viz-path-partial { stroke: var(--chart); stroke-dasharray: 3 4; }
.viz-path-before { stroke: var(--chart-before); stroke-width: 1.5px; stroke-dasharray: 6 4; }
.viz-area { fill: var(--chart); opacity: 0.1; }
.viz-dot {
  position: absolute; width: 8px; height: 8px; margin: 0 0 -6px -6px; box-sizing: content-box;
  background: var(--chart); border: 2px solid var(--surface); border-radius: 50%; pointer-events: none;
}
.viz-dot-before { background: var(--chart-before); }
/* The point still being counted: hollow, so a half-counted day never reads as a fall. */
.viz-dot-partial { background: var(--surface); border-color: var(--chart); }
.viz-cross { position: absolute; top: 0; bottom: 0; width: 1px; margin-left: -0.5px; background: var(--muted); pointer-events: none; }
.is-compare-off .viz-path-before, .is-compare-off .viz-dot-before { display: none; }
.viz-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-bottom: 4px; }
.viz-key { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; font-size: 14px; color: var(--ink-2); }
.viz-key-toggle {
  padding: 0 14px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.viz-key-toggle:hover { border-color: var(--line-strong); background: var(--surface-2); }
.viz-key-toggle[aria-pressed='false'] { color: var(--muted); text-decoration: line-through; }
.viz-key-toggle[aria-pressed='false'] .viz-keyline { opacity: 0.4; }
.viz-keyline { flex: none; width: 16px; height: 2px; background: var(--chart, #00929c); }
.viz-keyline-before { height: 0; background: none; border-top: 2px dashed var(--chart-before); }
.viz-keydot { flex: none; width: 8px; height: 8px; border: 2px solid #00929c; border-radius: 50%; background: var(--surface); }
.viz-tip .viz-tip-title { color: #fff; font-weight: 700; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; }
.viz-tip-row strong { color: #fff; }
.viz-tip-row .viz-keyline:not(.viz-keyline-before) { background: #00929c; }
.viz-tip-row strong { white-space: nowrap; }
/* On the dark tooltip the slate is too dark to see; the dash is drawn in the light grey of its text. */
.viz-tip-row.is-before .viz-keyline { border-top-color: #98a2b3; }

.heat .viz-plot { height: auto; margin: 0; }
.heat-grid { display: grid; grid-template-columns: 40px repeat(var(--cols), minmax(0, 1fr)); gap: 2px; }
.heat-row { display: flex; align-items: center; font-size: 14px; color: var(--muted); }
.heat-col { padding-top: 6px; font-size: 14px; color: var(--muted); text-align: center; white-space: nowrap; }
.heat-col.is-sparse { visibility: hidden; }
.heat-cell {
  display: flex; align-items: center; justify-content: center; min-height: 32px;
  font-size: 14px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums;
}
.heat-cell.is-active { box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px var(--surface); }
.heat-cell.s0, .heat-swatch.s0 { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.heat-cell.s0.is-active { box-shadow: inset 0 0 0 2px var(--ink); }
.heat-cell.s1, .heat-swatch.s1 { background: #73c0c7; color: var(--ink); }
.heat-cell.s2, .heat-swatch.s2 { background: #2da6b0; color: var(--ink); }
.heat-cell.s3, .heat-swatch.s3 { background: #048891; }
.heat-cell.s4, .heat-swatch.s4 { background: #026970; }
.heat-cell.s5, .heat-swatch.s5 { background: #014c52; }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.heat-swatch { display: inline-block; width: 20px; height: 12px; }
.heat-legend-gap { width: 8px; }


/* Small multiples: one strip of months per complaint, all on one scale, the months written once. */
.multiples { --chart: #00929c; }
.multiple {
  display: grid; grid-template-columns: minmax(120px, 24%) minmax(0, 1fr) minmax(120px, 16%);
  align-items: center; gap: 16px; margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line);
}
.multiple-axis { border-bottom: 0; padding: 0; }
.multiple-axis .viz-x { margin: 0; }
.multiple-name { display: flex; align-items: center; min-height: 48px; font-weight: 700; }
.multiple .viz-plot.multiple-strip { height: 48px; margin: 0; }
.multiple-v { font-size: 14px; color: var(--ink-2); text-align: right; }
.barlist-share { font-size: 14px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: no-preference) {
  .viz-bar { transform-origin: bottom; animation: viz-rise 560ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .barlist-bar { transform-origin: left; animation: viz-grow 560ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .viz-line .viz-svg,   .heat-cell { animation: viz-fade 480ms ease-out both; }
}
@keyframes viz-rise { from { transform: scaleY(0); } }
@keyframes viz-grow { from { transform: scaleX(0); } }
@keyframes viz-reveal { from { clip-path: inset(0 100% 0 0); } }
@keyframes viz-fade { from { opacity: 0; } }


/* ===================================================================== */
/* Smaller screens                                                       */
/* The clinic screen is 1366x768; these keep a phone or a narrow window  */
/* usable without sideways scrolling.                                    */
/* ===================================================================== */

.who-mini { display: none; font-size: 15px; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-mini span { display: block; font-size: 14px; font-weight: 500; color: var(--frame-muted); }

@media (max-width: 1040px) {
  .dash, .chart-body { grid-template-columns: minmax(0, 1fr); }
  .board-cols { grid-template-columns: minmax(0, 1fr); }
  .board-col + .board-col { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); }
  .board-col:first-child { padding-right: 0; }
  .report-cols { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile:nth-child(3) { border-left: 0; }
  .tile:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-5 .tile:nth-child(odd) { border-left: 0; padding-left: 0; }
  .tiles-5 .tile:last-child { grid-column: 1 / -1; }
  .report-pair { grid-template-columns: minmax(0, 1fr); }
  .report-lead { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .lead-more { padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .monthgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .chart-rail .panel { position: static; }
  .chart-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-facts-wide { grid-column: 1 / -1; border-left: 0 !important; padding-left: 0 !important; border-top: 1px solid var(--line); }
  .chart-id .slab-row { flex-wrap: wrap; }
}

@media (max-width: 900px) {
  :root { --gutter: 16px; }
  body.app { display: block; background: var(--canvas); }
  /* The rail folds into a top bar: the crest, who is signed in, and Menu. Who
     is signed in stays on screen: on a shared computer it is what stops a
     visit being saved under a colleague's name (DECISIONS #46). */
  .sidebar {
    position: relative; height: auto; overflow: visible;
    display: flex; flex-direction: row; align-items: center; gap: 0; padding: 0 0 0 16px;
    border-bottom: 1px solid var(--frame-line);
  }
  .brand { flex: none; border-bottom: 0; padding: 8px 16px 8px 0; min-height: 64px; }
  .who-mini { display: block; flex: 1; min-width: 0; }
  .menu { flex: none; display: block; align-self: stretch; }
  .menu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; height: 100%;
    min-height: 64px; padding: 0 16px; border-left: 1px solid var(--frame-line);
    font-weight: 700; color: #fff;
  }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu > summary svg { width: 20px; height: 20px; }
  .menu[open] > summary { background: var(--accent); }
  .menu > summary:focus-visible { outline: 2px solid var(--frame-lit); outline-offset: -4px; }
  .menu:not([open]) .menu-body { display: none; }
  /* The menu opens over the page, under the bar it came from. */
  .menu-body {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
    /* The open menu covers the whole screen under its bar, so no half-covered button shows beneath it. */
    display: flex; flex-direction: column; min-height: 100dvh;
    background: var(--frame); border-top: 1px solid var(--frame-line);
  }
  /* Two columns, so a long menu (the in-charge has nine items) stays short. */
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px 0; }
  .nav-item { padding: 0 16px; line-height: 1.25; }
  .sidebar-foot { margin: 0; padding: 8px 0 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .sidebar-foot > .nav-item kbd, .who-text { display: none; }
  .who { padding: 0 16px 0 0; }
  .who-link { margin: 0; padding: 0 16px; }
  .who-form { margin: 0; }
  .role-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .help-body, .compare, .dupe-pair, .fastentry-layout { grid-template-columns: 1fr; }
  .page-pane { position: static; }
  .sticky-bar, .jump { position: static; }
  .signin-page:has(> .signin-board) { grid-template-columns: minmax(0, 1fr); }
  .signin-board { padding: 20px 16px; gap: 16px; }
  .signin-board .signin-brand { flex-direction: row; align-items: center; gap: 16px; }
  .signin-board .signin-brand img { width: 56px; }
  .signin-board .signin-unit { font-size: 24px; margin-bottom: 2px; }
  .signin-board .signin-org { font-size: 15px; }
  .signin-page:has(> .signin-board) .signin { align-self: start; padding-top: 28px; }
  .chart-strip { left: 0; top: 0; }
  .slab { margin-top: -24px; padding: 16px 0 20px; }
}
@media (min-width: 901px) {
  .who-mini { display: none; }
}

@media (max-width: 640px) {
  main { padding-top: 16px; }
  /* On a phone the crest stands for the name, so the bar has room for who is signed in. */
  .brand-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  h1 { font-size: 26px; }
  .slab { margin-top: -16px; }
  .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 0; margin-top: 16px; }
  .readout { padding: 10px 12px 10px 0; border-left: 0; border-top: 1px solid var(--frame-line); }
  .readout:nth-child(even) { padding-left: 12px; border-left: 1px solid var(--frame-line); }
  .readout:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .readout-n { font-size: 32px; }
  .slab-actions { width: 100%; }
  .slab-actions .btn { flex: 1; }
  .next-body { flex-wrap: wrap; gap: 16px; }
  .next-side { flex-direction: row; flex-wrap: wrap; width: 100%; min-width: 0; }
  .next-side > * { flex: 1 1 140px; }
  .next-name { font-size: 26px; }
  .occupant { gap: 12px; flex-wrap: wrap; }
  .occ-tile { width: 60px; min-height: 60px; }
  .occ-n { font-size: 26px; }
  .scanbox { flex-wrap: wrap; }
  .report-bar .segmented { width: 100%; }
  .tile { padding: 12px 14px; }
  .tile-n { font-size: 24px; }
  .monthgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Seven columns cannot each be 48px wide on a phone, so the days flow as
     labelled tiles instead of a weekday grid. */
  .daygrid { display: flex; flex-wrap: wrap; gap: 6px; }
  .daygrid-head, .daygrid-pad { display: none; }
  .daycell { flex: 0 0 calc((100% - 18px) / 4); min-height: 64px; }
  .daycell-w { display: block; }
  .viz-plot { height: 160px; margin-left: 36px; }
  .viz-x { margin-left: 36px; }
  .viz-x .is-phone-hidden { visibility: hidden; }
  /* Room on the right for the last hour's label, which is wider than its cell. */
  .heat-grid { grid-template-columns: 32px repeat(var(--cols), minmax(0, 1fr)); padding-right: 14px; }
  .heat-cell { min-height: 28px; font-size: 0; }
  .heat-col.is-sparse, .heat-col { visibility: visible; }
  .heat-col.is-phone-hidden { visibility: hidden; }
  .multiple { grid-template-columns: minmax(0, 1fr) auto; gap: 0 12px; }
  .multiple .viz-plot.multiple-strip { grid-column: 1 / -1; grid-row: 2; }
  .multiple-axis { grid-template-columns: minmax(0, 1fr); }
  .multiple-axis > span { display: none; }
  .barlist-row, .barlist.has-share .barlist-row { grid-template-columns: minmax(0, 1fr) minmax(3ch, auto) 4.5ch; gap: 0 12px; }
  .barlist:not(.has-share) .barlist-row { grid-template-columns: minmax(0, 1fr) minmax(3ch, auto); }
  .barlist-label { grid-column: 1 / -1; }
  .report-lead { padding: 20px 0; }
  .lead-main { font-size: 34px; }
  .lead-change { font-size: 16px; }
  .lead-more p { font-size: 16px; }
  .report-toc a { padding: 0 8px; }
  .report-bar .segmented a { flex: 1; justify-content: center; padding: 0 8px; }
  .report-step { width: 100%; justify-content: space-between; gap: 8px; }
  .num-col { width: auto; }
  .scanbox .btn { width: 100%; }
  .slip { padding: 20px; }
  .slip-head { flex-wrap: wrap; }
  .slip-number { margin-left: 0; justify-items: start; }
  .slip-who { grid-template-columns: 1fr; gap: 0 0; }
  .slip-who dd { margin-bottom: 8px; }
  .chart-id .slab-row { gap: 16px; }
  .photo-block { order: 0; }
  .identity { order: 1; flex-basis: calc(100% - 120px); min-width: 0; }
  .identity h1 { font-size: 26px; }
  .chart-side { order: 2; flex-direction: row; flex-wrap: wrap; width: 100%; }
  .chart-side > * { flex: 1 1 140px; }
  .blood-value { font-size: 36px; }
  .allergy { font-size: 17px; }
  .chart-facts { grid-template-columns: 1fr 1fr; }
  .chart-facts > div:nth-child(3) { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); }
  .chart-facts > div:nth-child(4) { border-top: 1px solid var(--line); }
  .optiongrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .optiongrid-3 { grid-template-columns: 1fr; }
  .option { padding: 8px 26px 8px 12px; }
  .kv, .kv-tight { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .visit > summary { grid-template-columns: 16px minmax(0, 1fr) auto; }
  .visit > summary .chips { grid-column: 2 / -1; grid-row: 2; }
  .visit .when { white-space: nowrap; }
  /* The outcome takes its own line under the complaints, so it never presses against the time. */
  .visit-outcome { grid-column: 2 / -1; grid-row: 3; justify-self: start; padding-right: 0; }
  .visit .body { padding-left: 16px; }
  .chip { white-space: normal; }
  .welcome-bar .btn { display: none; }
  .signin { padding-top: 28px; }
  .savebar-note { flex-basis: 100%; }
  .savebar-note > span { display: none; }
  .savebar .btn { flex: 1; }
  .chart-strip .btn, .chart-strip .num { display: none; }

  /* Today's list stacks into rows rather than scrolling sideways. */
  .data-today thead { display: none; }
  .data-today tbody tr { display: grid; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .data-today tbody tr:last-child { border-bottom: 0; }
  .data-today tbody td { border: 0; padding: 1px 0 !important; }
  .data-today tbody td:first-child { font-size: 15px; }
  .data-today tbody td.nowrap { white-space: normal; color: var(--muted); font-size: 15px; }

  /* A table whose columns will not fit any width stacks into label-above-value
   * rows instead of scrolling sideways -- so a long certificate number never
   * pushes Status and Links off screen. Label above value, not beside it,
   * because a value can hold more than one line's worth (the cancel form). */
  .data-stack thead { display: none; }
  .data-stack tbody tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .data-stack tbody tr:last-child { border-bottom: 0; }
  .data-stack tbody td { display: block; border: 0; padding: 8px 0 0 !important; white-space: normal; }
  .data-stack tbody td:first-child { padding-top: 0 !important; }
  .data-stack tbody td::before { display: block; content: attr(data-label); font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
}

/* Access log (DECISIONS #44): filters in one wrapping row, then the count and the download. */
.log-card { padding-top: 20px; }
.log-filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.log-filters .field { margin: 0; flex: 1 1 200px; min-width: 0; }
.log-filters .log-date { flex: 0 1 170px; }
.log-filters .log-what { flex: 1.4 1 280px; }
.log-filters .log-go { flex: 0 0 auto; min-height: var(--tap); }
.log-chosen { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: var(--tap); font-weight: 600; }
.log-any { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 500; font-size: 15px; }
.log-summary { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.log-count { margin: 0; font-size: 17px; }
.log-hint { margin: 8px 0 16px; }
.log-role { display: block; font-size: 14px; }
.log-pager { margin-top: 16px; }
@media (max-width: 640px) {
  .log-filters .field, .log-filters .log-date { flex: 1 1 100%; }
}
.slab-name { color: #fff; font-weight: 700; }

/* The pharmacy's scan box sits on its board, drawn like the counter's search. */
.slab .scanbox { margin: 20px 0 0; max-width: 820px; }
.slab .scanbox > svg { color: var(--frame-muted); }
.slab .scanbox input[type='search'] { background: var(--frame-2); border-color: var(--frame-line); color: #fff; }
.slab .scanbox input[type='search']::placeholder { color: var(--frame-muted); }
.slab .scanbox input[type='search']:focus { background: var(--frame-field-lit); border-color: var(--frame-lit); box-shadow: 0 0 0 1px var(--frame-lit); caret-color: var(--frame-lit); }
.slab .scanbox:focus-within > svg { color: var(--frame-lit); }
.panel-head .muted { font-size: 15px; }

/* The report's board: the period, its controls, and what changed, lit (DECISIONS #53). */
.slab .report-title { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.slab .report-sofar { border-color: var(--frame-lit); color: var(--frame-lit); }
.slab .report-bar { margin: 20px 0 0; }
.slab .segmented { background: transparent; border-color: var(--frame-line); }
.slab .segmented a { color: var(--frame-soft); border-left-color: var(--frame-line); }
.slab .segmented a:hover { background: var(--frame-3); color: #fff; }
.slab .segmented a[aria-current='page'] { background: var(--accent); color: #fff; }
.slab .segmented a:focus-visible { outline-color: var(--frame-lit); outline-offset: -4px; }
.slab .report-lead { margin: 24px 0 0; padding: 24px 0 4px; border-top: 1px solid var(--frame-line); border-bottom: 0; }
.slab .lead-main { color: var(--frame-soft); }
.slab .lead-n { font-family: var(--mono); font-weight: 600; letter-spacing: -0.04em; color: #fff; }
.slab .lead-change { color: var(--frame-soft); }
.slab .lead-change strong { color: #fff; }
.slab .lead-pill { background: transparent; border: 1px solid var(--frame-line); color: #fff; }
.slab .lead-more { border-left-color: var(--frame-line); }
.slab .lead-more p { color: var(--frame-soft); }
.slab .readout-note { display: block; margin-top: 4px; line-height: 1.5; }
.slab .readout-note .tile-arrow { fill: currentColor; margin-right: 6px; }
@media (max-width: 1040px) {
  .slab .lead-more { border-top-color: var(--frame-line); }
}
.slab .chip-ok { background: var(--ok-wash); border-color: var(--ok); color: var(--ok-ink); }
.slab .chip-danger { background: var(--danger-wash); border-color: var(--danger); color: var(--danger-ink); }

.rx-order { gap: 0; padding: 0 1px 1px 0; }
.option:has(input:checked) .muted, .option:has(input:checked) .rx-how { color: #d9eeef; }
.option:has(input:checked) .med-short, .option:has(input:checked) .med-qty, .option:has(input:checked) .med-sentence { color: #fff; }
.option:has(input:checked) .med-form, .option:has(input:checked) .med-note { color: #d9eeef; }
.allergy-grid + .field { margin-top: 24px; }
/* The day or month still being counted is drawn dashed: "so far" has a line form (DECISIONS #54). */
.daycell.is-partial, .monthcell.is-partial { border-style: dashed; border-color: var(--accent); }
.scanbox > svg { top: 17px; }
.scanbox input::-webkit-search-cancel-button { display: none; }
.who-line { min-width: 0; }
@media (max-width: 640px) {
  .result { gap: 12px; }
  .result .chips { flex-direction: column; align-items: flex-end; }
}

/* ===================================================================== */
/* Explore (DECISIONS #62): count by one thing, narrow by the rest.      */
/* ===================================================================== */

.explore-by { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.explore-period { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.explore-period .field { margin: 0; flex: 0 1 200px; }
.explore-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.explore-presets .btn[aria-current] { background: var(--ink); border-color: var(--ink); color: #fff; }
.explore-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 20px; }
.explore-filters .field { margin-bottom: 14px; }
.card > h2 .chip { margin-left: 4px; }

.explore-find { position: relative; display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; }
.explore-find > svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.explore-find input { flex: 0 1 420px; padding-left: 42px; }
.explore-find input::-webkit-search-cancel-button { display: none; }

.explore-table { --chart: #00929c; }
.explore-table .explore-bar-head { width: 38%; }
.explore-bar-cell { vertical-align: middle !important; }
.explore-bar { display: block; height: 14px; background: var(--chart); }
.explore-table td.strong a { color: var(--ink); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.explore-table td.strong a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .explore-by { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explore-period .field { flex: 1 1 140px; }
  .explore-table .explore-bar-head, .explore-table .explore-bar-cell { display: none; }
  .explore-table th:first-child, .explore-table td:first-child { display: none; }
  .explore-find input { flex: 1 1 auto; }
}
.explore-more { margin: 0 0 4px; }
.explore-more > summary {
  display: inline-flex; align-items: center; min-height: 48px; cursor: pointer;
  color: var(--accent); font-weight: 700;
}
.explore-more[open] > summary { margin-bottom: 8px; }

/* One medicine line (DECISIONS #63): name and form, then dose, how often
   (1-0-1), when, days and the quantity worked out, then a note. */
.dose-line { margin: 0 0 8px; padding: 14px 0 4px; border: 0; border-top: 1px solid var(--line); min-width: 0; }
.dose-line > legend { padding: 0; margin-bottom: 8px; font-weight: 700; color: var(--ink); }
.dose-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 14px; }
.dose-grid .field { margin-bottom: 12px; min-width: 0; }
.dose-name { grid-column: span 4; }
.dose-form { grid-column: span 2; }
.dose-dose, .dose-timing, .dose-days, .dose-quantity { grid-column: span 1; }
.dose-frequency { grid-column: span 2; }
.dose-note { grid-column: 1 / -1; }
.dose-name input { text-transform: none; }
@media (max-width: 640px) {
  .dose-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dose-name, .dose-frequency, .dose-quantity, .dose-note { grid-column: 1 / -1; }
  .dose-form, .dose-dose, .dose-timing, .dose-days { grid-column: span 1; }
}

/* A medicine as staff read it (DECISIONS #63): the generic name in capitals,
   the shorthand in the board's figures, the quantity, the note. */
.med { display: grid; gap: 2px; }
.med-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.med-name { text-transform: uppercase; letter-spacing: 0.01em; }
.med-form { color: var(--muted); font-size: 15px; }
.med-sig { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.med-short { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.med-qty { color: var(--ink-2); }
.med-sentence { color: var(--ink-2); }
.med-note { color: var(--muted); font-size: 15px; }

/* ===================================================================== */
/* The pharmacy's medicines, offered as the prescriber types (#66)       */
/* ===================================================================== */

/* The list opens under the name box, over what follows, never pushing it down. */
.dose-name { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; z-index: 30;
  margin: 2px 0 0; padding: 0; list-style: none;
  max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1.5px solid var(--ink);
  box-shadow: 0 10px 24px rgba(17, 20, 24, 0.14);
}
.suggest [role="option"] {
  display: flex; align-items: center; min-height: 48px; padding: 0 14px;
  border-top: 1px solid var(--line); font-size: 16px; cursor: pointer;
}
.suggest [role="option"]:first-child { border-top: 0; }
.suggest [role="option"]:hover,
.suggest [role="option"][aria-selected="true"] { background: var(--accent-wash); color: var(--accent-ink); }

/* The pharmacist's list: add in one row, then the list with its stock. */
.medicine-add { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) auto; gap: 0 14px; align-items: end; }
.medicine-add .field { margin-bottom: 0; }
.medicine-add .btn { min-height: 48px; }
.medicine-actions { justify-content: flex-end; flex-wrap: nowrap; }
.data.medicine-table td { vertical-align: middle; }
.medicine-table tr.is-out td.strong { color: var(--muted); }
@media (max-width: 720px) {
  .medicine-add { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .medicine-add .btn { justify-self: start; }
  .medicine-actions { flex-wrap: wrap; justify-content: flex-start; }
}

/* A report as numbers (#68): each chart's table standing on its own. */
.viz-numbers, .numlist { margin: 0; }
.numlist .data th[scope="row"] { font-weight: 600; }
.numlist .barlist-more { margin-top: 6px; }

/* Made-up data on every console screen (#69): a demonstration or a trial. A
 * band across the top of the workspace, edge to edge like the board under it. */
.made-up-strip {
  position: relative; margin: -24px 0 24px; padding: 8px 0; font-size: 15px;
  background: var(--warn-wash); color: var(--warn-ink); border-bottom: 1px solid var(--warn);
  box-shadow: 0 0 0 100vmax var(--warn-wash); clip-path: inset(0 -100vmax 0 calc(-1 * var(--gutter)));
}
/* It takes the place of the workspace's top padding, so the board below sits as it always does. */
@media (max-width: 640px) { .made-up-strip { margin: -16px 0 16px; } }

/* Feedback (#71): the student's form behind the email's link, and the list the in-charge reads. */
.feedback-card h1 { font-size: 28px; margin: 0 0 8px; }
.feedback-rating { border: 0; margin: 16px 0 0; padding: 0; min-width: 0; }
.feedback-rating .optiongrid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.feedback-card textarea { min-height: 120px; }
.feedback-list { list-style: none; margin: 0; padding: 0; }
.feedback-list li { padding: 16px 0; border-top: 1px solid var(--line); }
.feedback-list li:first-child { border-top: 0; }
.feedback-body { margin: 0 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-list .muted { margin: 0; font-size: 15px; }
