/* Hallmark · genre: modern-minimal · macrostructure: Workbench (app) · Split Studio (sign-in) · design-system: design.md · designed-as-app
 * theme: custom (vibe: "Apple-calm clinical precision, teal signal on cool grey") · paper oklch(97.4% 0.003 250)
 * accent oklch(49% 0.095 196) refined teal · Geist + Geist Mono · nav: N1b (frosted) · footer: none (app)
 * enrichment: sign-in only, Tier-B hand-built SVG rhythm strip · Light only.
 * pre-emit critique: P4 H5 E4 S5 R4 V4
 */
@import url("tokens.css");

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow-x: clip;
}

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

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  letter-spacing: -0.006em;
  color: var(--color-ink);
  background: var(--color-paper);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--color-ink);
  font-style: normal;
}

p { max-width: 75ch; }

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

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

strong { font-weight: 600; }

::selection { background: var(--color-accent-tint); color: var(--color-ink); }

/* Keyboard focus — instant, never animated, 3:1+ against every surface */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

/* Counts and table figures never jiggle as digits change */
.count-badge, .stat-value, .data-table td, .doc-stat-value {
  font-variant-numeric: tabular-nums;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-paper-3) transparent;
}

/* The hidden attribute always wins over component display rules */
[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;
}

/* "Press / to search" in the account menu: a tick when it's on. */
.user-dropdown-check { margin-left: auto; color: var(--color-accent); }
#slash-shortcut-toggle[aria-pressed="false"] .user-dropdown-check { visibility: hidden; }
#slash-shortcut-toggle kbd { font-family: var(--font-mono); font-size: var(--text-xs); padding: 0 4px; border: 1px solid var(--color-rule-strong); border-radius: 4px; }
body.no-slash-shortcut .search-kbd { display: none; }

/* "Skip to main content": the first stop for the keyboard, shown on focus. */
.skip-link {
  position: fixed;
  top: var(--space-2xs);
  left: var(--space-2xs);
  z-index: calc(var(--z-toast) + 2);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-ink);
  color: var(--color-surface);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; outline: 2px solid var(--color-focus); outline-offset: 2px; }
main:focus { outline: none; }

/* Small uppercase label — used sparingly for panel and table section labels */
.overline,
.subhead {
  display: block;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-3);
  margin-bottom: var(--space-2xs);
}

.muted { color: var(--color-ink-3); }
.text-2 { color: var(--color-ink-2); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }

.empty-note {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

/* ==========================================================================
   Surfaces
   ========================================================================== */
/* The one raised surface: white, softly shadowed, generously rounded.
   Depth comes from the shadow, so there is no outline. */
.panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
}

/* Inset block inside a panel: no second raised box, a quiet fill instead */
.card-inset {
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* wide tables scroll inside, never widen the page */
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* Frosted top bar: content scrolls underneath and stays faintly visible. */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-lg);
  height: var(--header-h);
  padding: 0 var(--space-lg);
  background: color-mix(in oklch, var(--color-surface) 76%, transparent);
  -webkit-backdrop-filter: var(--blur-chrome);
  backdrop-filter: var(--blur-chrome);
  border-bottom: 1px solid var(--color-rule);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-header { background: var(--color-surface); }
}

.logo-section {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.logo-text {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--color-ink);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  height: 36px;
  padding: 0 var(--space-sm);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-button i { font-size: 0.85em; color: var(--color-ink-3); transition: color var(--dur-fast) var(--ease-out); }
.nav-button:hover { color: var(--color-ink); background: var(--color-paper-2); }
.nav-button:hover i { color: var(--color-ink-2); }
.nav-button.active { color: var(--color-ink); font-weight: 600; background: var(--color-paper-3); }
.nav-button.active i { color: var(--color-accent); }

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.user-menu { position: relative; }

.user-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  height: 40px;
  padding: 0 var(--space-xs) 0 4px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.user-chip-btn:hover,
.user-chip-btn.open { background: var(--color-paper-3); }
.user-chip-btn .user-avatar { width: 32px; height: 32px; font-size: var(--text-xs); }
.user-chip-name { font-weight: 500; white-space: nowrap; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }

.user-chip-caret {
  font-size: 0.65rem;
  color: var(--color-ink-3);
  transition: transform var(--dur-base) var(--ease-out);
}
.user-chip-btn.open .user-chip-caret { transform: rotate(180deg); }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 248px;
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: var(--space-2xs);
  z-index: var(--z-dropdown);
  transform-origin: top right;
  animation: menu-in var(--dur-base) var(--ease-out);
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(0.97) translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.user-dropdown-meta {
  padding: var(--space-2xs) var(--space-xs) var(--space-xs);
  border-bottom: 1px solid var(--color-rule);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.user-dropdown-meta .user-dropdown-name { font-weight: 600; font-size: var(--text-sm); }

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-xs);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
}
.user-dropdown-item i { width: 16px; text-align: center; color: var(--color-ink-3); }
.user-dropdown-item:hover { background: var(--color-paper-2); }

main {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  min-width: 0; /* let inner scrollers (stepper, tables) do their job */
}

/* Views arrive with a short rise and fade */
.view-section { display: none; }
.view-section.active { display: block; animation: view-in var(--dur-long) var(--ease-out); }

@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Page header: large title + one-line description left, actions right */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}
.page-header.divided { align-items: center; margin-bottom: var(--space-lg); }
.page-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.08;
  overflow-wrap: anywhere;
  min-width: 0;
}
.page-desc {
  margin-top: var(--space-2xs);
  font-size: var(--text-md);
  color: var(--color-ink-2);
  max-width: 62ch;
}
.page-actions {
  display: flex;
  gap: var(--space-2xs);
  flex-wrap: wrap;
  align-items: center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  height: 40px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn i { font-size: 0.9em; }
.btn:active { transform: scale(0.97); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.btn-primary:hover { background: var(--color-accent-hover); color: var(--color-on-accent); }

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-rule);
  box-shadow: var(--shadow-hairline);
  color: var(--color-ink);
}
.btn-secondary:hover { background: var(--color-paper-2); }
.btn-secondary i { color: var(--color-ink-2); }

.btn-ghost {
  background: transparent;
  color: var(--color-ink-2);
}
.btn-ghost:hover { background: var(--color-paper-3); color: var(--color-ink); }

.btn-danger {
  background: var(--color-surface);
  border-color: var(--color-rule);
  box-shadow: var(--shadow-hairline);
  color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger-tint);
  color: var(--color-danger-hover);
}
.btn-danger-solid {
  background: var(--color-danger);
  color: var(--color-on-accent);
}
.btn-danger-solid:hover { background: var(--color-danger-hover); color: var(--color-on-accent); }

.btn-sm { height: 32px; padding: 0 var(--space-xs); font-size: var(--text-xs); }
.btn-lg { height: 48px; padding: 0 var(--space-md); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--color-ink-2);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--color-paper-3); color: var(--color-ink); }
.icon-btn.danger:hover { background: var(--color-danger-tint); color: var(--color-danger); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  background: var(--color-paper-3);
  color: var(--color-ink-2);
}
.badge i { font-size: 0.85em; }

.badge-admin   { background: var(--color-ink); color: var(--color-surface); }
.badge-editor  { background: var(--color-accent-tint); color: var(--color-accent); }
.badge-readonly,
.badge-neutral { background: var(--color-paper-3); color: var(--color-ink-2); }
.badge-success { background: var(--color-success-tint); color: var(--color-success); }
.badge-warning,
.badge-disabled { background: var(--color-warning-tint); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-tint); color: var(--color-danger); }
.badge-accent  { background: var(--color-accent-tint); color: var(--color-accent); }

.count-badge {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: center;
  color: var(--color-ink-3);
}

.scenario-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-ink-2);
  background: var(--color-paper-3);
  padding: 2px var(--space-2xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.form-group { margin-bottom: var(--space-sm); }
.form-group:last-child { margin-bottom: 0; }

.form-group > label,
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: 6px;
}
.label-hint {
  font-weight: 400;
  color: var(--color-ink-3);
}
.required-mark { color: var(--color-danger); }

.form-help {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}
.form-help.is-warning { color: var(--color-warning); }
.form-help .link-btn { font-size: inherit; }

/* Field errors: a red border on the field and the reason right under it
   (linked with aria-describedby), plus a summary at the top of the form. */
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] { border-color: var(--color-danger); }
input[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--color-danger-tint); }
.field-error {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-top: 6px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-danger);
}
.editor-errors {
  margin-bottom: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-danger-tint);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-ink);
}
.editor-errors:focus { outline: 2px solid var(--color-danger); outline-offset: 2px; }
.editor-errors-title { display: flex; gap: var(--space-2xs); align-items: baseline; font-weight: 700; color: var(--color-danger); margin-bottom: var(--space-2xs); }
.editor-errors ul { margin: 0 0 0 var(--space-md); display: grid; gap: 4px; }
.editor-errors .btn { margin-top: var(--space-xs); }

/* A button that reads as an inline link (jump to a field, apply a hint). */
.link-btn {
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-align: left;
  cursor: pointer;
}
.link-btn:hover { color: var(--color-accent-hover); }
.editor-errors .link-btn { color: var(--color-ink); }

.allergy-confirm { margin-top: var(--space-2xs); }
input[readonly] { background: var(--color-paper-2); color: var(--color-ink-2); }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--color-ink);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
textarea { resize: vertical; min-height: 88px; }
select {
  appearance: none;
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-ink-2) 50%), linear-gradient(135deg, var(--color-ink-2) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
::placeholder { color: var(--color-ink-3); opacity: 1; }

input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) { border-color: var(--color-ink-3); }

/* Focus: a 2px teal edge plus a soft halo; the edge carries the 3:1 */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), 0 0 0 4px var(--color-accent-tint);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-paper-2);
  color: var(--color-ink-2);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
  cursor: pointer;
  flex-shrink: 0;
}

.input-sm,
.inline-row input[type="text"] {
  min-height: 36px;
  padding: 6px 12px;
  font-size: var(--text-sm);
}

.input-with-action {
  display: flex;
  gap: var(--space-2xs);
}
.input-with-action input { flex: 1; min-width: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.form-row-2,
.form-row-3,
.form-row-6 {
  display: grid;
  gap: var(--space-sm);
}
.form-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.form-row-2 > .form-group,
.form-row-3 > .form-group,
.form-row-6 > .form-group { margin-bottom: var(--space-sm); }
.form-row-2 > .span-all { grid-column: 1 / -1; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xl);
  align-items: start;
}

.dashboard-grid.has-sidebar { grid-template-columns: 232px minmax(0, 1fr); }

/* Source-list sidebar: quiet rows, rounded highlight, no box */
.sidebar-panel {
  position: sticky;
  top: calc(var(--header-h) + var(--space-xl));
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.sidebar-section .overline { padding-left: var(--space-xs); }

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-actions .btn-primary { margin-bottom: var(--space-xs); height: 44px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-xs);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sidebar-link i { width: 18px; text-align: center; color: var(--color-ink-3); font-size: 0.95em; }
.sidebar-link:hover { background: var(--color-paper-3); color: var(--color-ink); }

/* Greeting: date line over a large title */
.dash-hero { margin-bottom: var(--space-lg); }
.dash-date {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink-3);
  margin-bottom: var(--space-3xs);
}
.dash-greeting {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

/* Stats: one raised card, four large figures divided by hairlines */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: var(--space-2xl);
}
.stat-tile {
  padding: var(--space-md) var(--space-md) var(--space-md);
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: var(--space-3xs);
}
.stat-tile + .stat-tile { border-left: 1px solid var(--color-rule); }
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
}
.stat-unit { font-size: var(--text-base); font-weight: 600; color: var(--color-ink-3); margin-left: 3px; letter-spacing: -0.01em; }
.stat-label { font-size: var(--text-sm); color: var(--color-ink-2); }
.stat-tile.stat-warn .stat-value { color: var(--color-warning); }
.stat-tile.stat-attention .stat-value { color: var(--color-warning); }
.stat-tile.stat-attention .stat-label::before {
  content: "\f274";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.85em;
  color: var(--color-warning);
  margin-right: 5px;
}
.stat-tile.stat-ok .stat-value {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 1em;
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
  color: var(--color-success);
}
.stat-tile.stat-ok .stat-value i { font-size: 0.8em; }
.stat-tile.stat-warn .stat-label::before {
  content: "\f071";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.85em;
  color: var(--color-warning);
  margin-right: 5px;
}

.scenario-catalog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}
/* Section title under the greeting: smaller than the page's large title */
.scenario-catalog-header .section-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  min-width: 0;
}
.scenario-catalog-header .section-title + .page-desc { font-size: var(--text-base); margin-top: var(--space-3xs); }
.catalog-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2xs);
}

.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  width: 340px;
  max-width: 100%;
  height: 44px;
  padding: 0 var(--space-xs) 0 var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-pill);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.search-box:hover { border-color: var(--color-ink-3); }
.search-box:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), 0 0 0 4px var(--color-accent-tint);
}
.search-box .search-icon { color: var(--color-ink-3); font-size: var(--text-sm); flex-shrink: 0; }
.search-box input {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.search-box input:focus { box-shadow: none; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  background: var(--color-paper-2);
  border: 0;
  border-radius: 50%;
  color: var(--color-ink-2);
  cursor: pointer;
}
.search-clear:hover { background: var(--color-paper-3); color: var(--color-ink); }
.search-box:has(.search-clear:not([hidden])) .search-kbd { display: none; }

/* Dashboard search: scenario hits (each once, with their programmes), then
   matching programmes. Matches are marked. */
mark { background: var(--color-warning-tint); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 var(--color-warning-line); }
.search-results { grid-column: 1 / -1; }
.search-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2xs) var(--space-xs);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-xs);
}
.search-scope { font-size: var(--text-xs); font-weight: 500; color: var(--color-ink-3); letter-spacing: 0; }
.search-results-head .link-btn { font-size: var(--text-xs); font-weight: 500; }
.search-hit-list {
  list-style: none;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.search-hit-list li + li { border-top: 1px solid var(--color-rule); }
.search-hit {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-xs) var(--space-md);
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.search-hit:hover { background: var(--color-paper-2); }
.search-hit:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.search-hit .scenario-code { flex: none; }
.search-hit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.search-hit-title { font-weight: 600; overflow-wrap: anywhere; }
.search-hit-meta { font-size: var(--text-xs); color: var(--color-ink-2); }
.search-hit-meta i { color: var(--color-ink-3); margin-right: 2px; }
.search-hit-go { color: var(--color-ink-3); flex: none; }
.search-all-link { margin-top: var(--space-xs); font-size: var(--text-sm); }
.search-none, .search-note { font-size: var(--text-sm); color: var(--color-ink-3); }
.search-note { grid-column: 1 / -1; }
.search-results + .search-results { margin-top: var(--space-md); }
.search-kbd {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--color-ink-3);
  background: var(--color-paper-2);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-2xs);
  flex-shrink: 0;
}

.results-count {
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--space-md);
}

/* Raised content cards. Hover deepens the shadow; the title takes the accent. */
.scenario-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md);
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.scenario-card:hover { box-shadow: var(--shadow-card-hover); }

.scenario-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
}
.scenario-modality {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.scenario-card h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.2;
  margin-bottom: var(--space-2xs);
  overflow-wrap: anywhere;
}

.scenario-summary-text {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.scenario-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs) var(--space-sm);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-rule);
}
.scenario-meta-row:not(:last-child) { margin-bottom: var(--space-sm); }
.scenario-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.scenario-meta-item i { color: var(--color-ink-3); font-size: 0.9em; }

.scenario-actions {
  display: flex;
  gap: var(--space-2xs);
}
.scenario-actions .btn-grow { flex: 1; }

/* ==========================================================================
   Programmes
   ========================================================================== */
.programme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) var(--space-sm);
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.programme-card:hover { box-shadow: var(--shadow-card-hover); }
.programme-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xs);
}
.programme-card-head h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.2;
  overflow-wrap: anywhere;
  min-width: 0;
}
.programme-card-desc { font-size: var(--text-sm); color: var(--color-ink-2); }
.programme-scenarios {
  list-style: none;
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  padding: 2px var(--space-xs);
}
.programme-scenario-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-rule);
}
.programme-scenario-row:last-child { border-bottom: 0; }
.programme-scenario-row .scenario-code { background: var(--color-surface); }
.programme-scenario-row .row-title {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-width: 0;
}
.programme-scenario-row .row-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.programme-more {
  padding: var(--space-2xs) 0;
  font-size: var(--text-xs);
  color: var(--color-ink-2);
}
.programme-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2xs);
  margin-top: auto;
  min-height: 36px;
}
.programme-card-foot i { margin-right: 4px; color: var(--color-ink-3); }
/* Tools sit above the card's stretched link so they stay clickable */
.programme-card-tools { position: relative; z-index: var(--z-raised); display: flex; gap: 2px; }

/* The library-wide card is quieter: no raise, a dashed outline */
.programme-card-all {
  background: transparent;
  box-shadow: none;
  outline: 1.5px dashed var(--color-rule-strong);
  outline-offset: -1.5px;
}
.programme-card-all:hover { background: var(--color-surface); box-shadow: var(--shadow-card); }

/* Whole-card link: the title button stretches over the card. Its focus ring
   is drawn on the card so keyboard users see the full target. */
.card-link {
  all: unset;
  cursor: pointer;
  color: var(--color-ink);
  transition: color var(--dur-fast) var(--ease-out);
}
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.programme-card:has(.card-link:hover) .card-link,
.scenario-card:has(.card-link:hover) .card-link { color: var(--color-accent); }
.programme-card:has(.card-link:focus-visible),
.scenario-card:has(.card-link:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Programme editor checklist */
.programme-scenarios-select,
.prog-alloc-list {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
.programme-scenario-option,
.prog-alloc-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: var(--space-2xs) var(--space-xs);
  font-size: var(--text-sm);
  cursor: pointer;
  border-bottom: 1px solid var(--color-rule);
}
.programme-scenario-option:last-child,
.prog-alloc-item:last-child { border-bottom: 0; }
.programme-scenario-option:hover,
.prog-alloc-item:hover { background: var(--color-paper-2); }
.programme-scenarios-select .empty-note,
.prog-alloc-list .empty-note { padding: var(--space-xs); }

/* ==========================================================================
   Empty & loading
   ========================================================================== */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  color: var(--color-ink-2);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.empty-state .empty-icon,
.table-empty-state .empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-paper-2);
  font-size: 1.35rem;
  color: var(--color-ink-3);
  margin-bottom: var(--space-2xs);
}
.empty-state h3 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; }
.empty-state p { font-size: var(--text-sm); color: var(--color-ink-3); }
.empty-state .btn { margin-top: var(--space-xs); }
.table-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
}
.table-empty-state .empty-icon { margin-bottom: var(--space-2xs); }
.table-empty-title { font-size: var(--text-md); font-weight: 700; letter-spacing: -0.015em; color: var(--color-ink); }
.table-empty-state p:not(.table-empty-title) { max-width: 46ch; }
.table-empty-state .btn { margin-top: var(--space-xs); }

.skeleton-card {
  min-height: 248px;
  padding: var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.skeleton-card .sk-spacer { flex: 1; }
.skeleton-line {
  height: 12px;
  border-radius: var(--radius-sm);
  background: var(--color-paper-3);
  animation: skeleton-pulse 1.6s var(--ease-in-out) infinite;
}
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-70 { width: 70%; height: 20px; }
.skeleton-line.w-85 { width: 85%; }
.skeleton-line.w-100 { width: 100%; }
.skeleton-line.h-btn { height: 36px; border-radius: var(--radius-pill); }

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ==========================================================================
   Scenario detail document
   ========================================================================== */
.detail-layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 980px);
  gap: var(--space-xl);
  justify-content: center;
}

/* Below 1100px the side contents list gives way to a sticky "Contents"
   menu above the document. */
.doc-jumpbar {
  display: none;
  position: sticky;
  top: calc(var(--header-h) + var(--space-2xs));
  z-index: var(--z-raised);
  align-items: center;
  gap: var(--space-xs);
  max-width: 980px;
  margin: 0 auto var(--space-sm);
  padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop);
}
.doc-jumpbar label { display: inline-flex; gap: 6px; align-items: center; font-size: var(--text-sm); font-weight: 600; white-space: nowrap; margin: 0; }
.doc-jumpbar select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; border-radius: var(--radius-pill); }

.back-to-top {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  z-index: var(--z-sticky);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink);
  cursor: pointer;
}
.back-to-top:hover { background: var(--color-paper-2); }

.not-found { max-width: 560px; margin: var(--space-2xl) auto 0; }
.not-found-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.025em; }
.not-found-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2xs); margin-top: var(--space-xs); }

/* Contents: each entry carries its group's colour as a small dot */
.detail-toc {
  position: sticky;
  top: calc(var(--header-h) + var(--space-xl));
  align-self: start;
  max-height: calc(100vh - var(--header-h) - var(--space-2xl));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.detail-toc a {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  min-height: 36px;
  padding: 0 var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  text-decoration: none;
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.detail-toc a::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sec, var(--color-rule-strong));
}
.detail-toc a span { overflow: hidden; text-overflow: ellipsis; }
.detail-toc a:hover { color: var(--color-ink); background: var(--color-paper-2); }
.detail-toc a.active {
  color: var(--color-ink);
  font-weight: 600;
  background: var(--color-paper-3);
}

.detail-doc {
  padding: var(--space-xl) clamp(var(--space-md), 4vw, 56px);
  font-size: var(--text-base);
  border-radius: var(--radius-xl);
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
  flex-wrap: wrap;
  padding-bottom: var(--space-lg);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-rule);
}
.doc-header > div { min-width: 0; }
.doc-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.08;
  margin-top: var(--space-sm);
  overflow-wrap: anywhere;
}
.doc-kicker {
  margin-top: var(--space-2xs);
  font-size: var(--text-md);
  color: var(--color-ink-2);
}

/* Governance: a quiet metadata row, label over value, divided by hairlines */
.doc-governance {
  display: grid;
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  grid-auto-columns: auto;
  column-gap: 0;
  row-gap: 2px;
  align-self: flex-end;
  font-size: var(--text-sm);
}
.doc-governance dt,
.doc-governance dd { padding: 0 var(--space-md); }
.doc-governance dt:not(:first-of-type),
.doc-governance dd:not(:first-of-type) { border-left: 1px solid var(--color-rule); }
.doc-governance dt:first-of-type,
.doc-governance dd:first-of-type { padding-left: 0; }
.doc-governance dt { font-size: var(--text-xs); color: var(--color-ink-3); }
.doc-governance dd { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Section key: each group's colour (tokens.css "Section key") appears as a
   small square marker in a tinted header band, and as the TOC dot. */
.sec-general     { --sec: var(--sec-general);     --sec-tint: var(--sec-general-tint); }
.sec-outcomes    { --sec: var(--sec-outcomes);    --sec-tint: var(--sec-outcomes-tint); }
.sec-patient     { --sec: var(--sec-patient);     --sec-tint: var(--sec-patient-tint); }
.sec-setup       { --sec: var(--sec-setup);       --sec-tint: var(--sec-setup-tint); }
.sec-progression { --sec: var(--sec-progression); --sec-tint: var(--sec-progression-tint); }
.sec-debrief     { --sec: var(--sec-debrief);     --sec-tint: var(--sec-debrief-tint); }
.sec-governance  { --sec: var(--sec-governance);  --sec-tint: var(--sec-governance-tint); }

.doc-section { margin-top: var(--space-2xl); }
.detail-section-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--sec-tint, var(--color-paper-2));
  border-radius: var(--radius-md);
  scroll-margin-top: calc(var(--header-h) + var(--space-md));
}
.detail-section-header h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.section-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}
.section-meta::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--sec, var(--color-rule-strong));
}
.section-num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-2);
}
.section-group {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-2);
}
.section-group::before { content: "·"; margin-right: var(--space-2xs); }

/* Opening paragraph of a section (scenario summary) */
.doc-lead {
  font-size: var(--text-md);
  line-height: 1.55;
  max-width: 72ch;
  margin-bottom: var(--space-sm);
}

/* Labelled facts: quiet tinted tiles, label above value */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
}
.fact-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fact-grid-1 { grid-template-columns: minmax(0, 1fr); margin-bottom: 0; }
.fact {
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  min-width: 0;
}
.fact-wide { grid-column: 1 / -1; }
.fact dt,
.fact-label,
.doc-stat-label {
  display: block;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-2);
  margin-bottom: 2px;
}
.fact dd { font-size: var(--text-sm); overflow-wrap: anywhere; }

/* Timings: scenario, debrief, total session */
.doc-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2xs);
  margin-bottom: var(--space-2xs);
}
.doc-stat {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 4px;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
}
.doc-stat-label { flex-basis: 100%; }
.doc-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.doc-stat-unit { font-size: var(--text-xs); color: var(--color-ink-2); }

/* Patient card: identity, then the allergy flag */
.patient-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xs) var(--space-sm);
  flex-wrap: wrap;
  padding: var(--space-sm);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}
.patient-id { display: flex; gap: var(--space-xs); align-items: flex-start; min-width: 0; }
.patient-avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  color: var(--color-ink-3);
}
.patient-name { font-size: var(--text-md); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.patient-meta { font-size: var(--text-sm); color: var(--color-ink-2); overflow-wrap: anywhere; }
.allergy-alert {
  flex: 1 1 240px;
  display: flex;
  gap: var(--space-2xs);
  align-items: baseline;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-danger-tint);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.allergy-none { font-size: var(--text-sm); color: var(--color-success); font-weight: 500; }
.allergy-as-entered { color: var(--color-ink-2); font-weight: 400; }
/* Not entered: neutral, and never worded as a negative finding. */
.allergy-missing {
  flex: 1 1 240px;
  display: flex;
  gap: var(--space-2xs);
  align-items: baseline;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper-3);
  color: var(--color-ink-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.presenting { margin-bottom: var(--space-sm); }
.presenting p {
  font-size: var(--text-md);
  font-weight: 500;
  padding-left: var(--space-xs);
  border-left: 2px solid var(--color-rule-strong);
}

.doc-subhead {
  font-size: var(--text-base);
  font-weight: 600;
  margin: var(--space-md) 0 var(--space-2xs);
}
.doc-subhead:first-child { margin-top: 0; }

/* Key/value and data tables in the document */
.meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--space-sm);
}
.meta-table th,
.meta-table td {
  padding: var(--space-2xs) var(--space-xs);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-rule);
}
.meta-table tbody th {
  width: 220px;
  font-weight: 500;
  color: var(--color-ink-2);
}
.meta-table thead th {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
  background: var(--color-paper-2);
  border-bottom: 1px solid var(--color-rule);
}
.meta-table tr:last-child > td,
.meta-table tr:last-child > th { border-bottom: 0; }
.meta-table .strong-cell { font-weight: 600; }
.meta-table .script-cell { font-style: italic; color: var(--color-ink-2); }
.meta-table .center { text-align: center; }
.table-scroll { position: relative; overflow-x: auto; margin-bottom: var(--space-sm); }
.table-scroll .meta-table { margin-bottom: 0; }

.flag-text { color: var(--color-danger); font-weight: 500; }

.outcomes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}
.outcomes-grid h3,
.outcomes-grid h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2xs);
}

.outcome-list { list-style: none; }
.outcome-item {
  padding: var(--space-2xs) 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-rule);
}
.outcome-item:last-child { border-bottom: 0; }
.outcome-item .outcome-num { font-family: var(--font-mono); color: var(--color-ink-3); margin-right: 4px; }
.outcome-row { display: flex; justify-content: space-between; gap: var(--space-xs); }
.outcome-mapping {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--color-ink-2);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  padding: 0 6px;
  border-radius: var(--radius-sm);
}

/* SBAR: labelled rows, the letter keyed to the section colour */
.sbar-card + .sbar-card { margin-top: var(--space-md); }
.sbar-list {
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  padding: 0 var(--space-sm);
}
.sbar-row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-rule);
  font-size: var(--text-sm);
}
.sbar-row:last-child { border-bottom: 0; }
.sbar-row dt {
  display: flex;
  align-items: center;
  align-self: start;
  gap: var(--space-2xs);
  font-weight: 600;
}
.sbar-letter {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--sec-tint, var(--color-surface));
  border: 1px solid var(--sec, var(--color-rule));
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink);
}

/* Progression phase blocks in the document */
.phase-stack { display: flex; flex-direction: column; gap: var(--space-xl); }
.phase-card {
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-rule);
  scroll-margin-top: calc(var(--header-h) + var(--space-md));
}

/* Phase track: one tile per phase (P1 · name · duration). In the full
   document each tile is a button that jumps to its phase. */
.phase-track {
  list-style: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: var(--space-2xs);
  margin-bottom: var(--space-2xs);
}
.phase-track li { display: flex; min-width: 0; }
.phase-step {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3xs);
  padding: var(--space-xs);
  background: var(--color-paper-2);
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  text-align: left;
  color: var(--color-ink);
}
button.phase-step {
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
button.phase-step:hover { background: var(--color-paper-3); }
.phase-step .phase-index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-2);
}
.phase-step-name { font-size: var(--text-sm); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.phase-step-dur { font-size: var(--text-xs); color: var(--color-ink-3); }

/* Vitals trend: small multiples, one per vital, sharing a hover crosshair. */
.trend { position: relative; margin-top: var(--space-2xs); }
.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: var(--space-2xs);
}
.trend-panel {
  margin: 0;
  padding: var(--space-2xs) var(--space-xs) 2px;
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  border-top: 3px solid var(--vital-color, var(--color-rule-strong));
}
.trend-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-2);
}
.trend-unit { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--color-ink-3); }
.trend-panel svg,
.trend-panel .trend-img { display: block; width: 100%; height: auto; overflow: visible; }
.trend-panel text { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.trend-cursor { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.trend-cursor.is-active { opacity: 1; }
.trend-dot { transition: r var(--dur-fast) var(--ease-out); }
.trend-dot.is-active { r: 5.5px; }
.trend-tip {
  position: absolute;
  z-index: var(--z-raised);
  min-width: 170px;
  max-width: 260px;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-xs);
  color: var(--color-ink);
  pointer-events: none;
}
.trend-tip-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-3xs); }
.trend-tip-title .phase-index { font-family: var(--font-mono); font-weight: 500; color: var(--color-ink-2); }
.trend-tip-row { display: flex; justify-content: space-between; gap: var(--space-sm); padding: 1px 0; }
.trend-tip-row span:first-child { color: var(--color-ink-2); }
.trend-tip-row span:last-child { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.trend-note { font-size: var(--text-xs); color: var(--color-ink-3); margin: var(--space-2xs) 0 var(--space-lg); }
.brief-doc .trend-note { margin-bottom: 0; }

.phase-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}
.phase-head h3 { font-size: var(--text-md); }
.phase-head .phase-index {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-accent);
  margin-right: var(--space-2xs);
}
.phase-trigger {
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  margin-bottom: var(--space-sm);
}
.phase-trigger strong { color: var(--color-ink); }

/* Vital chips in the scenario document, colour-keyed by a top rule */
.vitals-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
}
.vital-chip {
  padding: var(--space-2xs) var(--space-xs);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  border-top: 3px solid var(--vital-color, var(--color-rule-strong));
}
.vital-chip .vital-chip-label {
  display: block;
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-2);
}
.vital-chip .vital-chip-value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.vital-hr   { --vital-color: var(--vital-hr); }
.vital-rr   { --vital-color: var(--vital-rr); }
.vital-spo2 { --vital-color: var(--vital-spo2); }
.vital-bp   { --vital-color: var(--vital-bp); }
.vital-temp { --vital-color: var(--vital-temp); }
.vital-gcs  { --vital-color: var(--vital-gcs); }

.vital-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vital-color);
  margin-right: 6px;
  vertical-align: 1px;
}

.split-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
}
.split-2 + .split-2 { margin-top: var(--space-sm); }
.block-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-2xs);
}
.block-title i { font-size: 0.9em; color: var(--color-ink-3); }
.block-title.is-success i { color: var(--color-success); }
.block-title.is-warning i { color: var(--color-warning); }
.block-text { font-size: var(--text-sm); }
.block-text + .block-text { margin-top: 4px; }
.plain-list {
  padding-left: 1.1em;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}
.plain-list li + li { margin-top: 4px; }
.plain-list strong { color: var(--color-ink); }
.check-list { list-style: none; font-size: var(--text-sm); }
.check-list li { display: flex; gap: var(--space-2xs); align-items: baseline; }
.check-list li + li { margin-top: 4px; }
.check-list i { color: var(--color-success); }
.kv-line {
  font-size: var(--text-sm);
  padding: 4px 0;
  border-bottom: 1px solid var(--color-rule);
}
.kv-line:last-child { border-bottom: 0; }

/* Quoted patient / facilitator lines */
.quote {
  font-size: var(--text-sm);
  color: var(--color-ink);
  padding-left: var(--space-xs);
  border-left: 2px solid var(--color-warning-line);
  margin-top: var(--space-2xs);
}

/* Callouts: guidance boxes, a quiet tinted fill */
.callout {
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--color-paper-2);
  font-size: var(--text-sm);
}
.callout h4,
.callout .callout-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 4px;
}
.callout p { color: var(--color-ink-2); }
.callout-accent { background: var(--color-accent-tint); }
.callout-accent .callout-title i,
.callout-accent h4 i { color: var(--color-accent); }
.callout-warning { background: var(--color-warning-tint); }
.callout-warning .callout-title i,
.callout-warning h4 i { color: var(--color-warning); }

.debrief-guidance {
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--color-accent-tint);
  margin-bottom: var(--space-md);
}
.debrief-guidance h4 { font-size: var(--text-sm); margin-bottom: 4px; }
.debrief-guidance p { font-size: var(--text-sm); color: var(--color-ink-2); }

.debrief-phase + .debrief-phase { margin-top: var(--space-sm); }
.debrief-phase h4 { font-size: var(--text-base); margin-bottom: 2px; }
.debrief-phase .phase-purpose { font-size: var(--text-sm); color: var(--color-ink-2); margin-bottom: var(--space-2xs); }
.prompt-line {
  font-size: var(--text-base);
  font-weight: 500;
  padding-left: var(--space-xs);
  border-left: 2px solid var(--color-accent);
}

/* Brief / Full document switch: an iOS-style segmented control */
.view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-right: auto;
  background: var(--color-paper-3);
  border-radius: var(--radius-pill);
}
.view-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  height: 36px;
  padding: 0 var(--space-sm);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out), color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.view-switch-btn:hover { color: var(--color-ink); }
.view-switch-btn i { color: var(--color-ink-3); }
.view-switch-btn[aria-selected="true"] {
  background: var(--color-surface);
  box-shadow: var(--shadow-hairline);
  color: var(--color-ink);
  font-weight: 600;
}
.view-switch-btn[aria-selected="true"] i { color: var(--color-accent); }

/* Brief: the one-page faculty view */
.brief-wrap { max-width: 1000px; margin: 0 auto; }
.brief-doc .doc-header { margin-bottom: var(--space-lg); }
.brief-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-lg);
}
.brief-block { margin-top: var(--space-xl); }
.brief-grid .brief-block { margin-top: 0; }
.brief-title {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-sm);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--sec-tint, var(--color-paper-2));
  border-radius: var(--radius-md);
}
.brief-title::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--sec, var(--color-rule-strong));
}
.brief-sub { font-size: var(--text-sm); color: var(--color-ink-2); margin-bottom: var(--space-xs); }
.brief-subhead { font-size: var(--text-sm); font-weight: 600; margin: var(--space-md) 0 var(--space-xs); }
.brief-doc .vitals-row { margin-bottom: 0; }
.brief-doc .doc-lead { font-size: var(--text-base); }

/* ==========================================================================
   Scenario files — list + viewer, Finder-style
   ========================================================================== */
.tab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-pill);
  background: var(--color-paper-3);
  font-size: var(--text-2xs);
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
}
.view-switch-btn[aria-selected="true"] .tab-count { background: var(--color-accent-tint); color: var(--color-accent); }

.files-wrap { max-width: 1200px; margin: 0 auto; position: relative; }
.files-panel {
  position: relative;
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
}
.files-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}
.files-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.files-sub { font-size: var(--text-sm); color: var(--color-ink-2); margin-top: 2px; }
.files-uploading {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}
.files-uploading i { color: var(--color-accent); }

.files-layout {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: var(--space-md);
  align-items: start;
}

/* The list: rounded rows, the selected one filled */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(72vh, 760px);
  overflow-y: auto;
  padding: var(--space-3xs);
  margin: calc(-1 * var(--space-3xs));
}
.file-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 60px;
  padding: var(--space-2xs) var(--space-xs);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.file-row:hover { background: var(--color-paper-2); }
.file-row[aria-current="true"] { background: var(--color-accent-tint); }
.file-row:focus-visible { outline-offset: -2px; }

.file-thumb {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--color-paper-3);
  color: var(--color-ink-3);
  font-size: 1.15rem;
  overflow: hidden;
}
.file-thumb-pdf { background: var(--color-danger-tint); color: var(--color-danger); }
.file-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}
.file-thumb.has-img img { opacity: 1; }

.file-row-text { display: flex; flex-direction: column; min-width: 0; }
.file-name {
  font-size: var(--text-sm);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta { font-size: var(--text-xs); color: var(--color-ink-2); }

/* The viewer: title bar, actions, then the stage */
.file-viewer {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.file-viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
}
.file-viewer-title { min-width: 0; }
.file-viewer-title .file-name { display: block; font-size: var(--text-md); font-weight: 700; letter-spacing: -0.015em; }
.file-viewer-tools { display: flex; gap: var(--space-3xs); flex: none; }
.file-viewer-tools a[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
.file-actions { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }

.file-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(70vh, 720px);
  min-height: 320px;
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.file-stage-wait { color: var(--color-ink-3); font-size: 1.25rem; }
.file-stage-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  animation: fade-in var(--dur-slow) var(--ease-out);
}
.file-stage-pdf {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--color-surface);
}
.file-stage .empty-note { padding: var(--space-md); text-align: center; }

/* Empty state doubles as the drop target */
.files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--color-paper-2);
}
.files-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-ink-3);
  font-size: 1.35rem;
  margin-bottom: var(--space-2xs);
}
.files-empty h3 { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; }
.files-empty p { font-size: var(--text-sm); color: var(--color-ink-2); }
.files-empty .btn { margin-top: var(--space-xs); }

/* Dragging files over the panel shows a single drop target */
.files-drop-hint {
  position: absolute;
  inset: var(--space-2xs);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  border-radius: var(--radius-lg);
  outline: 2px dashed var(--color-accent);
  outline-offset: -2px;
  background: var(--color-accent-tint);
  color: var(--color-accent);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.files-wrap.is-dragging .files-drop-hint { opacity: 1; }

/* ==========================================================================
   Programme planner — board lanes and matrix
   ========================================================================== */
.planner-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

/* Bulk bar: a floating capsule that docks below the top bar while scrolling */
.planner-bulk {
  position: sticky;
  top: calc(var(--header-h) + var(--space-2xs));
  z-index: var(--z-raised);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  width: fit-content;
  max-width: 100%;
  margin-bottom: var(--space-md);
  padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop);
  animation: menu-in var(--dur-base) var(--ease-out);
}
.planner-bulk-count { font-size: var(--text-sm); font-weight: 700; }
.planner-bulk-from { font-size: var(--text-sm); color: var(--color-ink-2); }
.planner-bulk-actions { display: flex; gap: var(--space-3xs); flex-wrap: wrap; }

/* Board: lanes side by side, scrolling sideways when there are many */
/* Scroll containers are positioned so visually hidden labels inside them
   stay inside them, rather than widening the page (WCAG 1.4.10). */
.planner-board {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(244px, 1fr);
  gap: var(--space-xs);
  align-items: start;
  overflow-x: auto;
  padding-bottom: var(--space-sm);
  scroll-snap-type: x proximity;
}
.planner-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-xs) var(--space-xs);
  background: var(--color-paper-3);
  border-radius: var(--radius-lg);
  scroll-snap-align: start;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.planner-col-none {
  background: transparent;
  outline: 1.5px dashed var(--color-rule-strong);
  outline-offset: -1.5px;
}
.planner-col.is-drop-target { background: var(--color-accent-tint); }
.planner-col-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2xs);
  padding: 0 var(--space-2xs);
}
.planner-col-heading { min-width: 0; }
.planner-col-title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.planner-col-meta { font-size: var(--text-xs); color: var(--color-ink-2); margin-top: 2px; }
.planner-col-tools { display: flex; flex: none; margin: -4px -4px 0 0; }
.planner-col-tools .icon-btn:hover { background: var(--color-paper-2); }

.planner-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-height: 72px;
}
.planner-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2xs);
  padding: var(--space-xs) var(--space-3xs) var(--space-xs) var(--space-xs);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-base) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.planner-card[draggable="true"] { cursor: grab; }
.planner-card[draggable="true"]:active { cursor: grabbing; }
.planner-card:hover { box-shadow: var(--shadow-card-hover); }
.planner-card.is-selected { background: var(--color-accent-tint); box-shadow: 0 0 0 2px var(--color-accent); }
.planner-card.is-dragging { opacity: 0.4; }
.planner-card:not(:has(.planner-check)) { grid-template-columns: minmax(0, 1fr) auto; }
.planner-check { margin-top: 2px; }
.planner-card-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.planner-card-main:hover .planner-card-title { color: var(--color-accent); }
.planner-card-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px var(--space-2xs); min-width: 0; }
.planner-card-top .scenario-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.planner-card-mins { font-size: var(--text-xs); color: var(--color-ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.planner-card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color var(--dur-fast) var(--ease-out);
}
.planner-card-shared { font-size: var(--text-xs); color: var(--color-ink-2); }
.planner-card-shared i { color: var(--color-ink-3); margin-right: 2px; }
.planner-card-menu { width: 32px; height: 32px; }

/* Where a dragged card will land */
.planner-drop {
  padding: var(--space-xs);
  border-radius: var(--radius-md);
  outline: 2px dashed var(--color-accent);
  outline-offset: -2px;
  background: var(--color-surface);
  color: var(--color-accent);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
}
.planner-empty {
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--radius-md);
  outline: 1.5px dashed var(--color-rule-strong);
  outline-offset: -1.5px;
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  text-align: center;
}

/* Action menus anchored to a button */
.popover-menu {
  position: fixed;
  z-index: var(--z-dropdown);
  min-width: 220px;
  padding: var(--space-2xs);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: menu-in var(--dur-base) var(--ease-out);
}
.popover-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  min-height: 40px;
  padding: 0 var(--space-xs);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-ink);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.popover-item i { width: 16px; text-align: center; color: var(--color-ink-3); }
.popover-item:hover,
.popover-item:focus-visible { background: var(--color-paper-2); outline: 2px solid var(--color-focus); outline-offset: -2px; }
.popover-item.danger { color: var(--color-danger); }
.popover-item.danger i { color: var(--color-danger); }
.popover-sep { height: 1px; margin: var(--space-3xs) var(--space-xs); background: var(--color-rule); }

/* Matrix: scenarios down, programmes across, sticky header and first column */
.planner-matrix-panel { padding: 0; overflow: hidden; }
.planner-matrix-wrap { position: relative; overflow: auto; max-height: calc(100vh - var(--header-h) - 260px); min-height: 320px; }
.planner-matrix {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: var(--text-sm);
}
.planner-matrix th,
.planner-matrix td { border-bottom: 1px solid var(--color-rule); }
.planner-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-paper-2);
  vertical-align: bottom;
}
.pm-corner {
  left: 0;
  z-index: 3 !important;
  padding: var(--space-xs) var(--space-md);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
  min-width: 280px;
}
.pm-head { padding: var(--space-xs) var(--space-2xs); text-align: center; min-width: 120px; max-width: 160px; }
.pm-head-btn {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-ink);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.pm-head-btn:hover { color: var(--color-accent); }
.pm-head-count { display: block; margin-top: 2px; font-size: var(--text-2xs); color: var(--color-ink-3); font-variant-numeric: tabular-nums; }
.pm-total-head { font-size: var(--text-xs); font-weight: 600; color: var(--color-ink-2); }
.pm-row-head {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--color-surface);
  padding: var(--space-2xs) var(--space-md);
  text-align: left;
  font-weight: 400;
}
.pm-open {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: 0;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
  min-width: 0;
}
.pm-title { font-weight: 600; }
.pm-open:hover .pm-title { color: var(--color-accent); }
.pm-cell { text-align: center; padding: var(--space-2xs); transition: background-color var(--dur-fast) var(--ease-out); }
.pm-cell.is-in { background: var(--color-accent-tint); }
.pm-cell .fa-check { color: var(--color-accent); }
.pm-cell input { width: 20px; height: 20px; }
.pm-total { text-align: center; padding: var(--space-2xs) var(--space-sm); font-variant-numeric: tabular-nums; color: var(--color-ink-2); }
.planner-matrix tbody tr:hover .pm-row-head,
.planner-matrix tbody tr:hover td:not(.is-in) { background: var(--color-paper-2); }
.planner-matrix tbody tr:last-child > * { border-bottom: 0; }

/* Picker list inside modals */
.planner-add-search { width: 100%; margin-bottom: var(--space-sm); }
.planner-add-list { max-height: 320px; }
.planner-add-text { display: flex; flex-direction: column; min-width: 0; }

/* Toast action (Undo) */
.toast-action {
  pointer-events: auto;
  flex: none;
  margin-left: var(--space-2xs);
  padding: 0 var(--space-xs);
  height: 32px;
  background: transparent;
  border: 1px solid color-mix(in oklch, var(--color-surface) 40%, transparent);
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-surface);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.toast-action:hover { background: color-mix(in oklch, var(--color-surface) 16%, transparent); }
.toast-action:focus-visible, .toast-dismiss:focus-visible { outline: 2px solid var(--color-surface); outline-offset: 2px; }
/* Session time limit notice: above everything, including dialogs. */
.session-notice {
  position: fixed;
  top: calc(var(--header-h) + var(--space-sm));
  left: 50%;
  transform: translateX(-50%);
  z-index: calc(var(--z-toast) + 1);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
  width: min(560px, calc(100vw - 2 * var(--space-sm)));
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-sm);
}
.session-notice p { flex: 1 1 18rem; }
.session-notice p i { color: var(--color-warning); margin-right: 4px; }
/* An offer that waits to be used or dismissed: no countdown bar. */
.toast.is-sticky { padding-right: var(--space-2xs); }
.toast.is-sticky::after { display: none; }
.toast-dismiss {
  pointer-events: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: -4px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--color-surface);
  cursor: pointer;
}
.toast-dismiss:hover { background: color-mix(in oklch, var(--color-surface) 16%, transparent); }

/* ==========================================================================
   Programme categories — coloured tabs, group headings, card caps
   ========================================================================== */
.cat-blue   { --cat: var(--cat-blue);   --cat-tint: var(--cat-blue-tint); }
.cat-green  { --cat: var(--cat-green);  --cat-tint: var(--cat-green-tint); }
.cat-orange { --cat: var(--cat-orange); --cat-tint: var(--cat-orange-tint); }
.cat-purple { --cat: var(--cat-purple); --cat-tint: var(--cat-purple-tint); }
.cat-pink   { --cat: var(--cat-pink);   --cat-tint: var(--cat-pink-tint); }
.cat-cyan   { --cat: var(--cat-cyan);   --cat-tint: var(--cat-cyan-tint); }
.cat-amber  { --cat: var(--cat-amber);  --cat-tint: var(--cat-amber-tint); }
.cat-red    { --cat: var(--cat-red);    --cat-tint: var(--cat-red-tint); }

.cat-dot {
  flex: none;
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat, var(--color-rule-strong));
}

.category-bar {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
/* Category filters wrap onto more lines rather than scrolling out of sight;
   the management controls sit apart at the end of the bar. */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  flex: 1;
  min-width: 0;
  padding: 3px; /* room for focus rings */
  margin: -3px;
}
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  height: 40px;
  padding: 0 var(--space-xs) 0 var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-hairline);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.cat-tab:hover { color: var(--color-ink); background: var(--color-paper-2); }
.cat-tab[aria-selected="true"] {
  background: var(--cat-tint, var(--color-paper-3));
  border-color: var(--cat, var(--color-ink-3));
  color: var(--color-ink);
  font-weight: 600;
}
.cat-count {
  min-width: 22px;
  height: 20px;
  padding: 0 var(--space-2xs);
  border-radius: var(--radius-pill);
  background: var(--color-paper-2);
  font-size: var(--text-2xs);
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
}
.cat-tab[aria-selected="true"] .cat-count { background: var(--color-surface); color: var(--color-ink); }
.category-tools { display: flex; align-items: center; gap: var(--space-3xs); flex: none; padding-left: var(--space-xs); border-left: 1px solid var(--color-rule); min-height: 40px; }
.category-hint { font-size: var(--text-sm); color: var(--color-ink-2); padding: var(--space-2xs) 0; }

/* "All" tab: a tinted heading per category, spanning the grid */
.programme-group-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-top: var(--space-lg);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--cat-tint, var(--color-paper-3));
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.015em;
}
.programme-group-head:first-child { margin-top: 0; }
.programme-group-count { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); }

/* A programme card's category shows as a thin colour cap */
.programme-card.has-category { border-top: 4px solid var(--cat); }

/* Category dialog: colour swatches */
.swatches { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.swatch { position: relative; cursor: pointer; }
.swatch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.swatch-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--cat);
}
.swatch input:checked + .swatch-dot { outline: 2px solid var(--color-ink); outline-offset: 3px; }
.swatch input:checked + .swatch-dot::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: var(--text-sm);
  color: var(--color-surface);
}
.swatch input:focus-visible + .swatch-dot { outline: 2px solid var(--color-focus); outline-offset: 3px; }

/* Manage categories list */
.cat-manage-list {
  list-style: none;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  max-height: 360px;
  overflow-y: auto;
}
.cat-manage-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 56px;
  padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-sm);
  border-bottom: 1px solid var(--color-rule);
}
.cat-manage-row:last-child { border-bottom: 0; }
.cat-manage-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cat-manage-name { font-weight: 600; overflow-wrap: anywhere; }
.cat-manage-meta { font-size: var(--text-xs); color: var(--color-ink-2); }
.cat-manage-tools { display: flex; gap: 2px; flex: none; }

/* Organiser lane titles carry their category dot */
.planner-col-title .cat-dot { margin-right: var(--space-2xs); vertical-align: 1px; }

/* ==========================================================================
   Drafts and API keys
   ========================================================================== */
/* Dashboard: drafts waiting for review */
.drafts-panel {
  margin: calc(-1 * var(--space-lg)) 0 var(--space-2xl);
  padding: var(--space-md);
  background: var(--color-warning-tint);
  border-radius: var(--radius-lg);
}
.drafts-head { display: flex; gap: var(--space-sm); align-items: flex-start; margin-bottom: var(--space-sm); }
.drafts-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--color-warning);
}
.drafts-title { font-size: var(--text-md); font-weight: 700; letter-spacing: -0.015em; }
.drafts-sub { font-size: var(--text-sm); color: var(--color-ink-2); }
.drafts-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2xs); }
.drafts-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: 56px;
  padding: var(--space-2xs) var(--space-sm);
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hairline);
  font: inherit;
  color: var(--color-ink);
  text-align: left;
  cursor: pointer;
  transition: box-shadow var(--dur-base) var(--ease-out);
}
.drafts-item:hover { box-shadow: var(--shadow-card-hover); }
.drafts-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.drafts-item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drafts-item-meta { font-size: var(--text-xs); color: var(--color-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drafts-item-go { flex: none; font-size: var(--text-sm); font-weight: 600; color: var(--color-accent); white-space: nowrap; }

/* Scenario page: draft notice above the document */
.draft-banner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  max-width: 1000px;
  margin: 0 auto var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-warning-tint);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
}
.draft-banner > i { color: var(--color-warning); font-size: 1.2rem; }
.draft-banner-text { flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; }
.draft-banner-text strong { color: var(--color-warning); }
.draft-banner-text span { color: var(--color-ink-2); }
.draft-banner-text .draft-banner-missing { color: var(--color-ink); font-weight: 500; }
.draft-banner.is-incomplete { background: var(--color-paper-3); }
.draft-banner.is-incomplete > i,
.draft-banner.is-incomplete .draft-banner-text strong { color: var(--color-ink); }
.planner-card.is-draft { box-shadow: var(--shadow-hairline); background: var(--color-surface); }

/* Users screen: API keys */
.api-keys-panel { margin-top: var(--space-xl); }
.api-keys-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-rule);
}
.api-keys-head .section-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.025em; }
.api-keys-desc { margin-top: var(--space-3xs); font-size: var(--text-sm); color: var(--color-ink-2); max-width: 70ch; }
.api-keys-panel .user-name { font-weight: 500; margin-right: var(--space-2xs); }

/* A secret shown once, with its copy button */
.secret-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-sm);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
}
.secret-value {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-ink);
  overflow-wrap: anywhere;
  user-select: all;
}
.secret-block { align-items: flex-start; }
.secret-block .secret-value { white-space: pre; overflow-x: auto; overflow-wrap: normal; font-size: var(--text-xs); line-height: 1.5; }

/* ==========================================================================
   Scenario editor (wizard)
   ========================================================================== */
/* Layout: a labelled step list on the left (sticky), the form on the right
   with a sticky footer (Previous · save state · Save draft · Next). Below
   960px the step list folds behind a "Step 3 of 8 · …" button. */
.editor-page-header { margin-bottom: var(--space-md); }
.editor-page-header .page-desc { font-size: var(--text-base); }
.editor-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  padding: 0;
  overflow: clip;
  border-radius: var(--radius-xl);
}
.sec-review { --sec: var(--color-ink-3); --sec-tint: var(--color-paper-2); }
/* Fields scrolled to (by focus or a link) stay clear of the sticky top bar
   and the editor's sticky footer. */
html:has(#view-scenario-form.active) {
  scroll-padding-top: calc(var(--header-h) + var(--space-sm));
  scroll-padding-bottom: 96px;
}
/* Notifications sit above the editor's footer, not over Next (on phones,
   where they're full width, they stay at the bottom rather than cover the
   form). */
body:has(#view-scenario-form.active) #toast-container { bottom: 88px; }

.editor-nav {
  background: var(--color-paper-2);
  border-right: 1px solid var(--color-rule);
}
.editor-steps-panel {
  position: sticky;
  top: calc(var(--header-h) + var(--space-sm));
  max-height: calc(100vh - var(--header-h) - var(--space-md));
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
}
.editor-nav-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-3);
  padding: 0 var(--space-2xs);
}
.editor-steps-toggle { display: none; }
.editor-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: var(--space-xs) 0 var(--space-sm);
}
.editor-steps li { display: flex; }

.editor-tab {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  width: 100%;
  padding: var(--space-2xs) var(--space-2xs);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  text-align: left;
  color: var(--color-ink-2);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.editor-tab:hover { background: var(--color-paper-3); color: var(--color-ink); }
.editor-tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.editor-tab.active {
  background: var(--color-surface);
  box-shadow: var(--shadow-hairline);
  color: var(--color-ink);
}
.step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 3px; }
.step-label { font-size: var(--text-sm); font-weight: 600; line-height: 1.3; }
.editor-tab.active .step-label { font-weight: 700; }
.step-req {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: 600;
  line-height: 16px;
  color: var(--color-ink-2);
  vertical-align: 1px;
}
.step-status {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-3);
}
.step-status:empty { display: none; }
.editor-tab.is-complete .step-status { color: var(--color-success); }
.editor-tab.is-needed .step-status { color: var(--color-warning); }
.editor-tab.is-error .step-status { color: var(--color-danger); }

/* The step number sits in a ring of its section's colour (a marker, never
   behind text); the current step fills with the accent. */
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-ink-2);
  border: 2px solid var(--sec, var(--color-rule-strong));
  background: var(--color-surface);
  flex-shrink: 0;
}
.editor-tab.active .step-num {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}
.editor-nav-key {
  padding: var(--space-xs) var(--space-2xs) 0;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
}

.wizard-progress {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-2xs);
  padding: 0 var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
}
.wizard-progress-bar {
  flex: none;
  width: 64px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-paper-3);
  overflow: hidden;
}
.wizard-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
  transition: width var(--dur-slow) var(--ease-out);
}

.editor-main { display: flex; flex-direction: column; min-width: 0; }
.editor-body { flex: 1; padding: var(--space-lg) clamp(var(--space-md), 3.5vw, var(--space-xl)) var(--space-xl); }

/* Footer: Previous names where it goes; the save state and Save draft are
   always in reach; Next names where it goes (on Review, the main action). */
.wizard-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-2xs) var(--space-xs);
  padding: var(--space-xs) clamp(var(--space-md), 3.5vw, var(--space-xl));
  background: var(--color-surface);
  border-top: 1px solid var(--color-rule);
}
.wizard-nav-btn { max-width: 34ch; }
.wizard-nav-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wizard-nav-dir { font-weight: 500; }
.wizard-nav-dest { font-weight: 600; }
.wizard-footer .btn-secondary.wizard-nav-btn .wizard-nav-dir { color: var(--color-ink-2); }
.wizard-save-btn { margin-left: auto; }
.btn.is-blocked { opacity: 0.55; }
.save-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--color-ink-3);
  white-space: nowrap;
}
.save-state.is-dirty { color: var(--color-warning); }
.save-state.is-saved { color: var(--color-success); }
.save-state i { font-size: 0.85em; }

/* Step header: the section's tint band with its colour marker, the step's
   name and what "complete" means for it. */
.step-head {
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--sec-tint, var(--color-paper-2));
  border-radius: var(--radius-md);
  scroll-margin-top: calc(var(--header-h) + var(--space-sm));
}
.step-kicker {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
}
.sec-marker {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--sec, var(--color-ink-3));
}
.step-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2xs);
  margin-top: 2px;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.step-title i { font-size: 0.8em; color: var(--color-ink-3); }
.step-title:focus { outline: none; }
.step-title:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }
.step-intro { margin-top: 2px; font-size: var(--text-sm); color: var(--color-ink-2); }
.step-criteria {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--space-2xs);
  margin-top: var(--space-xs);
}
.step-criteria:empty { display: none; }
.criteria-lead { font-size: var(--text-xs); font-weight: 600; color: var(--color-ink-2); }
.criteria-lead i { color: var(--color-success); }
.criteria-list { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.criteria-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink);
  cursor: pointer;
}
.criteria-chip:hover { border-color: var(--color-rule-strong); }
.criteria-chip:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.criteria-chip i { color: var(--color-ink-3); }
.criteria-chip.is-done { color: var(--color-ink-2); }
.criteria-chip.is-done i { color: var(--color-success); }

/* Fields: labels state what's required ("*" to save, "Needed for use" to
   mark ready). Widths follow the content. */
.field-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3xs) var(--space-md);
  margin-bottom: var(--space-md);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
}
.use-tag {
  display: inline-block;
  margin-left: 2px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--color-paper-3);
  font-size: var(--text-2xs);
  font-weight: 600;
  line-height: 18px;
  color: var(--color-ink-2);
  vertical-align: 1px;
  white-space: nowrap;
}
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0 var(--space-sm);
}
.field-row > .form-group { margin-bottom: var(--space-sm); }
.field-row > .grow { flex: 1 1 16rem; min-width: 0; }
.w-xs { flex: 0 1 8rem; width: 8rem; max-width: 100%; }
.w-time { flex: 0 0 8.5rem; width: 8.5rem; }
.w-sm { flex: 0 1 12rem; width: 12rem; max-width: 100%; }
.w-date { flex: 0 1 13rem; width: 13rem; max-width: 100%; }
.w-md { flex: 0 1 20rem; width: 20rem; max-width: 100%; }
.w-lg { flex: 0 1 26rem; width: 26rem; max-width: 100%; }
.mono-input { font-family: var(--font-mono); }
.section-help { margin: -4px 0 var(--space-sm); font-size: var(--text-sm); color: var(--color-ink-2); }

.form-tab-group > * + .form-section-title,
.form-tab-group > * + .form-section-head,
.form-tab-group > * + .repeater-section,
.form-tab-group > * + .timing-block,
.form-tab-group > * + .aspih-section,
.review-section { margin-top: var(--space-lg); }
.form-section-title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-xs);
}
.form-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2xs) var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-xs);
}
.form-section-head .form-section-title { margin-bottom: 0; }

/* Starting point for a new scenario */
.start-point {
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
.start-point-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-2xs); }
.start-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2xs); }
.start-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  min-height: 44px;
  padding: var(--space-xs);
  background: var(--color-surface);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-md);
  font: inherit;
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
}
.start-option:hover { background: var(--color-paper-2); }
.start-option:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.start-option[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-tint); box-shadow: inset 0 0 0 1px var(--color-accent); }
.start-option > i { margin-top: 3px; color: var(--color-ink-2); }
.start-option[aria-pressed="true"] > i { color: var(--color-accent); }
.start-option strong { display: block; font-size: var(--text-sm); }
.start-option span span { display: block; font-size: var(--text-xs); color: var(--color-ink-2); }
.start-note { margin-top: var(--space-2xs); font-size: var(--text-sm); color: var(--color-ink-2); }
.start-note i { color: var(--color-ink-3); margin-right: 4px; }

/* Session timing: the parts add up in a row; the total is worked out unless
   extra time is allowed. */
.timing-block {
  border: 0;
  padding: var(--space-sm) var(--space-md) var(--space-md);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
}
.timing-block > legend { float: left; width: 100%; padding: 0; margin-bottom: var(--space-2xs); }
.timing-block > legend + * { clear: left; }
.timing-sum-row, .timing-total {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2xs) var(--space-xs);
}
.timing-part { flex: 0 0 auto; min-width: 8.5rem; margin-bottom: 0; }
.timing-part .input-unit { width: 8.5rem; }
.timing-part > label { white-space: nowrap; }
.timing-op { padding-bottom: 12px; font-size: var(--text-md); font-weight: 600; color: var(--color-ink-3); }
.timing-result { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }
.timing-result-label { font-size: var(--text-sm); font-weight: 600; }
.timing-result output { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.timing-total { margin-top: var(--space-sm); }
.timing-custom { padding-bottom: 12px; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 44px; font-variant-numeric: tabular-nums; }
.input-unit .unit { position: absolute; right: 12px; font-size: var(--text-sm); color: var(--color-ink-3); pointer-events: none; }
.timing-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin: -4px 0 var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}
.timing-note:empty { display: none; }

/* Repeaters: rows on a tinted fill, an "Add …" prompt below. An empty list
   is just its prompt. */
.repeater-list:empty { display: none; }
.repeater-card {
  position: relative;
  padding: var(--space-sm) calc(var(--space-sm) + 36px) var(--space-sm) var(--space-sm);
  margin-bottom: var(--space-2xs);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
}
.repeater-card > .form-group:last-child,
.repeater-card .form-row-2:last-child > .form-group:nth-last-child(-n + 2),
.repeater-card.form-row-2 > .form-group,
.repeater-card.form-row-3 > .form-group { margin-bottom: 0; }
.repeater-card.form-row-2 > .span-all { margin-top: 0; }
.row-wide-narrow, .row-role, .row-equipment, .row-medication, .row-version { display: grid; gap: var(--space-xs) var(--space-sm); }
.row-wide-narrow { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row-role { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 9rem; }
.row-equipment { grid-template-columns: 12rem minmax(0, 1.6fr) minmax(0, 1fr); }
.row-medication { grid-template-columns: minmax(0, 1.4fr) 8rem minmax(0, 1fr); }
.row-medication > .span-all { grid-column: 1 / -1; }
.row-version { grid-template-columns: 6rem 9rem minmax(0, 1fr) minmax(0, 2fr); }
.row-wide-narrow > .form-group, .row-role > .form-group, .row-equipment > .form-group,
.row-medication > .form-group, .row-version > .form-group { margin-bottom: 0; }
.repeater-remove { position: absolute; top: var(--space-2xs); right: var(--space-2xs); }

.add-prompt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--space-sm);
  background: transparent;
  border: 1px dashed var(--color-rule-strong);
  border-radius: var(--radius-pill);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-ink-2);
  cursor: pointer;
}
.add-prompt:hover { background: var(--color-paper-2); color: var(--color-ink); border-style: solid; }
.add-prompt:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

textarea.auto-grow { min-height: 44px; field-sizing: content; max-height: 24rem; }
textarea.auto-grow[rows="2"] { min-height: 68px; }
textarea.auto-grow[rows="3"] { min-height: 92px; }
textarea.auto-grow[rows="4"] { min-height: 116px; }

/* Progression: a strip of phase tabs over one phase at a time. The strip
   reads left to right like the phase track in the document; the open phase
   is a bordered panel whose header stays under the top bar while it scrolls. */
.phase-empty {
  padding: var(--space-md);
  border: 1px dashed var(--color-rule-strong);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
}
.phase-empty-actions { display: flex; flex-wrap: wrap; gap: var(--space-2xs); margin-top: var(--space-xs); }
.phase-rail-wrap { margin-bottom: var(--space-sm); scroll-margin-top: calc(var(--header-h) + var(--space-sm)); }
.phase-rail-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2xs) var(--space-sm);
  margin-bottom: var(--space-xs);
}
.phase-rail-title { font-size: var(--text-sm); font-weight: 600; color: var(--color-ink-2); }
.mk-model { display: flex; align-items: center; gap: var(--space-2xs); }
.mk-model label { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); margin: 0; }
.mk-model select { width: auto; min-width: 12rem; height: 36px; padding-top: 0; padding-bottom: 0; font-size: var(--text-sm); }
.phase-rail-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--space-2xs); }
.phase-rail { display: flex; flex-wrap: wrap; gap: var(--space-2xs); flex: 1 1 0; min-width: 0; }
.phase-tab {
  flex: 1 1 10rem;
  max-width: 17rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--space-2xs) var(--space-xs) var(--space-xs);
  background: var(--color-paper-2);
  border: 0;
  border-radius: var(--radius-md);
  box-shadow: inset 0 -3px 0 transparent;
  font: inherit;
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.phase-tab:hover { background: var(--color-paper-3); }
.phase-tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.phase-tab.is-current { background: var(--color-accent-tint); box-shadow: inset 0 0 0 1px var(--color-accent-line), inset 0 -3px 0 var(--color-accent); }
.phase-tab-top { display: flex; align-items: baseline; gap: var(--space-2xs); width: 100%; font-size: var(--text-xs); color: var(--color-ink-3); }
.phase-tab .phase-index { font-family: var(--font-mono); font-weight: 600; color: var(--color-ink-2); }
.phase-tab.is-current .phase-index { color: var(--color-accent); }
.phase-tab-dur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-tab-flag { margin-left: auto; color: var(--color-danger); }
.phase-tab-flag:empty { display: none; }
.phase-tab-name { font-size: var(--text-sm); font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.phase-tab-obs {
  width: 100%;
  font-size: var(--text-xs);
  color: var(--color-ink-2);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phase-rail-add { flex: none; align-self: stretch; min-height: 0; border-radius: var(--radius-md); }
.phase-rail-add:disabled { opacity: 0.5; cursor: not-allowed; }

.phase-editor {
  background: var(--color-surface);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-md);
}
.phase-panel-head {
  position: sticky;
  top: var(--header-h);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-rule);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
/* Fields scrolled into view (by Tab or a link) land below the pinned
   phase header too, never under it (WCAG 2.4.11). */
@media (min-width: 721px) {
  html:has(#view-scenario-form.active #tab-progression:not([hidden]) .phase-editor:not([hidden])) {
    scroll-padding-top: calc(var(--header-h) + 96px);
  }
}
.phase-panel-heading { flex: 1; min-width: 0; }
.phase-panel-pos { display: block; font-size: var(--text-xs); color: var(--color-ink-3); }
.phase-panel-title { font-size: var(--text-md); font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; scroll-margin-top: calc(var(--header-h) + var(--space-sm)); }
.phase-panel-title:focus { outline: none; }
.phase-panel-title:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.phase-tools { display: flex; flex: none; gap: 2px; }
.phase-body { padding: 0 var(--space-md) var(--space-md); }
.phase-section-title {
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-base);
  font-weight: 700;
}
.phase-panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-xs) var(--space-md);
  border-top: 1px solid var(--color-rule);
  background: var(--color-paper-2);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.phase-panel-foot [data-phase-go="next"], .phase-panel-foot .phase-go-add { margin-left: auto; }
.phase-go { max-width: 100%; }
.phase-go-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-go-dir { font-weight: 500; color: var(--color-ink-2); }
.phase-body > .field-row, .phase-body > .form-group { margin-top: var(--space-sm); }
.phase-vitals { border: 0; padding: 0; margin: var(--space-xs) 0 var(--space-sm); }
.phase-vitals > legend { padding: 0; }
.vitals-inputs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2xs); }
.vitals-inputs .form-group { margin-bottom: 0; }
.vitals-inputs label { font-size: var(--text-xs); white-space: nowrap; }
.vitals-inputs input { font-variant-numeric: tabular-nums; padding-left: 10px; padding-right: 10px; }
.unit-hint { font-weight: 400; color: var(--color-ink-3); }
.phase-sub { margin-top: var(--space-sm); padding: var(--space-sm); background: var(--color-paper-2); border-radius: var(--radius-md); }
/* Unused blocks are just their Add prompts, side by side. */
.phase-sub.is-empty { display: inline-block; margin-right: var(--space-2xs); padding: 0; background: none; vertical-align: top; }
.phase-sub.is-empty > .block-title { display: none; }
.phase-sub > .add-prompt { margin-top: var(--space-2xs); }
.phase-sub.is-empty > .add-prompt { margin-top: 0; }
.phase-sub .phase-pres-fields .form-group:last-child { margin-bottom: 0; }
.sub-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) 36px;
  gap: var(--space-2xs);
  align-items: end;
  padding: var(--space-2xs) 0;
  border-top: 1px solid var(--color-rule);
}
.sub-row:first-child { border-top: 0; padding-top: 0; }
.sub-row-act { grid-template-columns: 9rem minmax(0, 1fr) 36px; }
.sub-row .form-group { margin-bottom: 0; }
.sub-row label { font-size: var(--text-xs); }
.sub-row .sub-row-remove { margin-bottom: 4px; }
/* Side by side, rows read like a table: only the first row shows its
   labels; later rows keep theirs for screen readers. */
@media (min-width: 721px) {
  .sub-row + .sub-row label {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

/* ASPiH: one row per standard, a segmented choice of four states (icon and
   word each) and its own evidence. */
.aspih-summary { font-size: var(--text-sm); color: var(--color-ink-2); font-variant-numeric: tabular-nums; }
.aspih-list { display: flex; flex-direction: column; gap: var(--space-2xs); }
.aspih-item {
  min-width: 0;
  margin: 0;
  padding: var(--space-xs) var(--space-sm) var(--space-sm);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
.aspih-domain { padding: 0 4px; margin-left: -4px; font-size: var(--text-sm); font-weight: 600; }
.aspih-states { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-2xs) 0 var(--space-xs); }
.aspih-state { position: relative; display: inline-flex; cursor: pointer; }
.aspih-state input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.aspih-state span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 var(--space-xs);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  background: var(--color-surface);
}
.aspih-state:hover span { background: var(--color-paper-2); }
.aspih-state input:focus-visible + span { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.aspih-state input:checked + span { font-weight: 600; color: var(--color-ink); border-width: 2px; padding: 0 calc(var(--space-xs) - 1px); }
.aspih-state.is-not-reviewed input:checked + span { background: var(--color-paper-3); border-color: var(--color-ink-3); }
.aspih-state.is-met input:checked + span { background: var(--color-success-tint); border-color: var(--color-success); }
.aspih-state.is-met input:checked + span i { color: var(--color-success); }
.aspih-state.is-needs-work input:checked + span { background: var(--color-warning-tint); border-color: var(--color-warning); }
.aspih-state.is-needs-work input:checked + span i { color: var(--color-warning); }
.aspih-state.is-not-applicable input:checked + span { background: var(--color-paper-3); border-color: var(--color-ink-2); }
.aspih-notes-group { margin-bottom: 0; }
.aspih-notes-group > label { font-size: var(--text-xs); }

.option-card {
  padding: var(--space-sm);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}
.option-card .form-group { margin: var(--space-sm) 0 0; }

/* Review step */
.review-card {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.review-card:focus { outline: none; }
.review-card:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.review-card.is-success { background: var(--color-success-tint); }
.review-card.is-warning { background: var(--color-warning-tint); }
.review-card.is-danger { background: var(--color-danger-tint); }
.review-card-title { display: flex; gap: var(--space-2xs); align-items: baseline; margin-bottom: 4px; font-size: var(--text-base); font-weight: 700; }
.review-card.is-success .review-card-title i { color: var(--color-success); }
.review-card.is-warning .review-card-title i { color: var(--color-warning); }
.review-card.is-danger .review-card-title i { color: var(--color-danger); }
.review-group { list-style: none; margin-top: var(--space-2xs); display: grid; gap: var(--space-2xs); }
.review-group > li > ul { margin: 2px 0 0 var(--space-md); display: grid; gap: 2px; }
.review-group-name { font-weight: 600; }
.review-group .link-btn { color: var(--color-ink); }
.review-sections { list-style: none; border-top: 1px solid var(--color-rule); }
.review-sec { padding: var(--space-xs) 0; border-bottom: 1px solid var(--color-rule); }
.review-sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs) var(--space-sm); }
.review-sec-label { font-weight: 600; flex: 1 1 12rem; }
.review-status { display: inline-flex; align-items: baseline; gap: 5px; font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-3); }
.review-status.is-complete { color: var(--color-success); }
.review-status.is-needed { color: var(--color-warning); }
.review-todo { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--space-2xs) 0 0 18px; font-size: var(--text-xs); color: var(--color-ink-2); }
.review-facts { display: grid; gap: var(--space-xs); }
.review-facts > div { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: var(--space-sm); font-size: var(--text-sm); }
.review-facts dt { font-weight: 600; }
.review-facts dt i { color: var(--color-ink-3); margin-right: 4px; }
.review-brief { max-width: none; }
.review-brief .detail-doc { box-shadow: none; background: var(--color-paper); }

/* ==========================================================================
   User administration
   ========================================================================== */
.table-panel { padding: 0; overflow: hidden; }

.users-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-rule);
}
.users-toolbar .search-box { width: 300px; }
.users-toolbar .results-count { margin-left: auto; }
.toolbar-select { width: auto; min-height: 44px; font-size: var(--text-sm); border-radius: var(--radius-pill); padding-left: var(--space-sm); }

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  flex-wrap: wrap;
  padding: var(--space-xs) var(--space-md);
  background: var(--color-accent-tint);
  border-bottom: 1px solid var(--color-accent-line);
}
.bulk-bar-count { font-size: var(--text-sm); font-weight: 600; }
.bulk-bar-actions { display: flex; gap: var(--space-2xs); align-items: center; flex-wrap: wrap; }
.bulk-bar .toolbar-select { min-height: 32px; height: 32px; padding-top: 0; padding-bottom: 0; font-size: var(--text-xs); }

.table-wrap { position: relative; overflow-x: auto; } /* contains the sr-only header label */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table th {
  padding: var(--space-xs) var(--space-md);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-2);
  background: var(--color-paper-2);
  border-bottom: 1px solid var(--color-rule);
  white-space: nowrap;
}
.data-table td {
  padding: var(--space-xs) var(--space-md);
  border-bottom: 1px solid var(--color-rule);
  vertical-align: middle;
}
.data-table tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
.data-table tbody tr:hover { background: var(--color-paper-2); }
.data-table tbody tr.row-selected { background: var(--color-accent-tint); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .col-check { width: 44px; }
.data-table .col-actions { text-align: right; white-space: nowrap; }
.data-table .mono { font-size: var(--text-xs); color: var(--color-ink-2); }
.data-table .cell-muted { color: var(--color-ink-2); white-space: nowrap; }
.data-table .table-empty { text-align: center; padding: var(--space-xl); color: var(--color-ink-3); }
.data-table tr.row-disabled td { color: var(--color-ink-3); }
.data-table tr.row-disabled .user-avatar { opacity: 0.55; }

.user-cell { display: flex; align-items: center; gap: var(--space-2xs); flex-wrap: wrap; }
.user-cell .user-name { font-weight: 500; }
.user-cell .you { font-size: var(--text-xs); color: var(--color-ink-3); }
.alloc-hint { font-size: var(--text-xs); color: var(--color-ink-3); margin-top: 2px; }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--avatar-tint, var(--color-accent-tint));
  border: 1.5px solid var(--avatar-ring, transparent);
  color: var(--color-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}
/* A stable colour per person (from the category palette): tint fill, base
   colour ring, ink initials. Identity only; the name always sits beside it. */
.avatar-blue   { --avatar-tint: var(--cat-blue-tint);   --avatar-ring: var(--cat-blue); }
.avatar-green  { --avatar-tint: var(--cat-green-tint);  --avatar-ring: var(--cat-green); }
.avatar-orange { --avatar-tint: var(--cat-orange-tint); --avatar-ring: var(--cat-orange); }
.avatar-purple { --avatar-tint: var(--cat-purple-tint); --avatar-ring: var(--cat-purple); }
.avatar-pink   { --avatar-tint: var(--cat-pink-tint);   --avatar-ring: var(--cat-pink); }
.avatar-cyan   { --avatar-tint: var(--cat-cyan-tint);   --avatar-ring: var(--cat-cyan); }

.stale-account {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-warning);
  font-weight: 500;
}

.cred-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
}
.cred-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--color-rule);
  font-size: var(--text-sm);
}
.cred-row:last-child { border-bottom: 0; }
.cred-row > span { overflow: hidden; text-overflow: ellipsis; }
.cred-row code {
  background: var(--color-paper-2);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-ink);
}
.skipped-list { max-height: 120px; overflow-y: auto; font-size: var(--text-sm); color: var(--color-ink-2); margin-bottom: var(--space-sm); }
.skipped-list div { padding: 3px 0; }

/* ==========================================================================
   Modal, confirm, toasts
   ========================================================================== */
/* Sheets float over a blurred, dimmed page */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  background: var(--color-scrim);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in var(--dur-slow) var(--ease-out);
}

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100vh - 2 * var(--space-md));
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  animation: modal-in var(--dur-slow) var(--ease-out);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.modal-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.025em; }
.modal-head .icon-btn { background: var(--color-paper-2); }
.modal-head .icon-btn:hover { background: var(--color-paper-3); }
/* Two-step sign-in set-up */
.mfa-steps { padding-left: 1.25rem; display: grid; gap: var(--space-md); margin-bottom: var(--space-sm); }
.mfa-qr { width: 184px; margin: var(--space-xs) 0; padding: 8px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--color-rule); }
.mfa-qr svg { display: block; width: 100%; height: auto; }
.mfa-key { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-xs); margin-top: var(--space-3xs); }
.mfa-secret { font-family: var(--font-mono); font-size: var(--text-sm); letter-spacing: 0.04em; user-select: all; }
.mfa-codes { font-family: var(--font-mono); font-size: var(--text-base, 1rem); line-height: 1.8; columns: 2; padding: var(--space-sm) var(--space-md); background: var(--color-paper-3); border-radius: var(--radius-sm); margin: var(--space-sm) 0; white-space: pre; }

/* Audit log */
.audit-panel { margin-top: var(--space-xl); }
.audit-toolbar { flex-wrap: wrap; }
.audit-table td { vertical-align: top; }
.audit-details { font-size: var(--text-sm); color: var(--color-ink-2); overflow-wrap: anywhere; }
.audit-more { display: flex; justify-content: center; padding: var(--space-xs); }

.modal-intro { font-size: var(--text-sm); color: var(--color-ink-2); margin-bottom: var(--space-sm); }
.modal-intro i { color: var(--color-warning); margin-right: 4px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2xs);
  margin-top: var(--space-lg);
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
  background: var(--color-accent-tint);
  color: var(--color-accent);
  font-size: 1.1rem;
}
.confirm-icon.danger { background: var(--color-danger-tint); color: var(--color-danger); }
.confirm-title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; margin-bottom: var(--space-3xs); }
.confirm-message { font-size: var(--text-sm); color: var(--color-ink-2); }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* Toasts: dark capsules, bottom-right, newest last */
#toast-container {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2xs);
  pointer-events: none;
}
.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  max-width: min(420px, calc(100vw - 2 * var(--space-md)));
  min-height: 48px;
  padding: var(--space-xs) var(--space-md) var(--space-xs) var(--space-sm);
  background: var(--color-ink);
  color: var(--color-surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-sm);
  font-weight: 500;
  overflow: hidden;
  /* Clicks pass through a toast to whatever it covers (often a dialog's
     buttons); only its action button (Undo, Open) takes them. */
  pointer-events: none;
  animation: toast-in var(--dur-long) var(--ease-out) forwards;
}
.toast i { flex-shrink: 0; font-size: 1.05em; }
.toast.toast-success i { color: var(--vital-hr); }
.toast.toast-error { background: var(--color-danger); }
.toast.toast-error i { color: var(--color-on-accent); }
.toast.toast-leaving { animation: toast-out var(--dur-base) var(--ease-in) forwards; }
.toast::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: currentColor;
  opacity: 0.3;
  transform-origin: left;
  animation: toast-progress var(--toast-duration, 3.5s) linear forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(4px); }
}
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ==========================================================================
   Welcome tour — a scrim with a spotlight cut-out, and a coach card
   ========================================================================== */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-tour);
  animation: fade-in var(--dur-slow) var(--ease-out);
}
.tour-layer.tour-leaving { animation: tour-out var(--dur-base) var(--ease-in) forwards; }
@keyframes tour-out {
  to { opacity: 0; }
}

/* The cut-out: a huge spread shadow is the scrim, the box itself stays clear.
   It glides between stops (position and size), the tour's one layout animation. */
.tour-spotlight {
  position: fixed;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 200vmax var(--color-scrim);
  outline: 2px solid var(--color-accent);
  pointer-events: none;
  transition: left var(--dur-slow) var(--ease-out), top var(--dur-slow) var(--ease-out),
              width var(--dur-slow) var(--ease-out), height var(--dur-slow) var(--ease-out);
}
.tour-spotlight.is-empty { outline-color: transparent; }

.tour-card {
  position: fixed;
  left: 0;
  top: 0;
  width: min(380px, calc(100vw - 2 * var(--space-sm)));
  padding: var(--space-sm) var(--space-md) var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  transition: opacity var(--dur-fast) var(--ease-out);
}
.tour-card:focus { outline: none; }
.tour-card.is-waiting { opacity: 0; }
.tour-card.tour-card-in { animation: tour-card-in var(--dur-slow) var(--ease-out); }
@keyframes tour-card-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.tour-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: calc(-1 * var(--space-2xs));
  margin-bottom: var(--space-3xs);
}
.tour-count {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-3);
  font-variant-numeric: tabular-nums;
}
.tour-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.tour-context {
  margin-top: var(--space-3xs);
  font-size: var(--text-sm);
  color: var(--color-ink-3);
}
.tour-context .scenario-code { margin-right: 2px; }
.tour-body {
  margin-top: var(--space-2xs);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-ink-2);
}
.tour-body p + p { margin-top: var(--space-2xs); }
.tour-body strong { font-weight: 600; color: var(--color-ink); }
.tour-body kbd {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink);
  background: var(--color-paper-2);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
  padding: 0 6px;
  white-space: nowrap;
}

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.tour-actions { display: flex; gap: var(--space-2xs); margin-left: auto; }
.tour-meta { font-size: var(--text-xs); color: var(--color-ink-3); }
.tour-meta i { margin-right: 4px; }

/* Progress: a dot per stop; the current one stretches into a teal pill. */
.tour-progress { display: flex; align-items: center; gap: 5px; }
.tour-progress span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-rule);
}
.tour-progress span.is-done { background: var(--color-accent-line); }
.tour-progress span.is-current { width: 18px; background: var(--color-accent); }

/* The welcome card: centred, roomier, with the brand mark and the user's role. */
.tour-card.is-intro {
  width: min(460px, calc(100vw - 2 * var(--space-sm)));
  padding: var(--space-lg);
}
.tour-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 1.2rem; }
.tour-card.is-intro .tour-title {
  margin-top: var(--space-md);
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}
.tour-card.is-intro .tour-body { font-size: var(--text-base); }
.tour-card.is-intro .tour-foot { margin-top: var(--space-lg); flex-wrap: wrap; }
.tour-body .tour-role {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.tour-role .badge { flex-shrink: 0; }

@media (max-width: 720px) {
  .tour-card { width: calc(100vw - 2 * var(--space-xs)); padding: var(--space-xs) var(--space-sm) var(--space-sm); border-radius: var(--radius-lg); }
  .tour-card.is-intro { padding: var(--space-md); }
  .tour-card.is-intro .tour-actions { width: 100%; }
  .tour-card.is-intro .tour-actions .btn { flex: 1; }
}
@media (max-width: 420px) {
  .tour-progress { display: none; }
}

/* ==========================================================================
   Sign-in — split stage: statement + rhythm strip left, the form right
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) var(--space-sm);
  background: var(--color-paper);
  overflow-y: auto;
}
.login-stage {
  width: min(1180px, 100%);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 420px);
  align-items: center;
  gap: clamp(var(--space-xl), 6vw, var(--space-3xl));
}
.login-hero { min-width: 0; }
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-xl);
}
.login-brand .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 1.05rem; }
.login-brand .logo-text { font-size: var(--text-lg); }
.login-display {
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.02;
  max-width: 13ch;
  overflow-wrap: anywhere;
  min-width: 0;
}
.login-lede {
  margin-top: var(--space-md);
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--color-ink-2);
  max-width: 44ch;
}

/* Rhythm strip: an ECG trace on monitor paper, drawn once on arrival */
.rhythm-strip {
  position: relative;
  margin-top: var(--space-xl);
  max-width: 560px;
  aspect-ratio: 560 / 150;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  background-image:
    linear-gradient(var(--color-rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-rule) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: -1px -1px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.rhythm-strip svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rhythm-trace {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: trace-draw 2.4s var(--ease-in-out) 0.3s forwards;
}
.rhythm-blip {
  fill: var(--color-accent);
  opacity: 0;
  animation: fade-in var(--dur-slow) var(--ease-out) 2.6s forwards;
}
@keyframes trace-draw { to { stroke-dashoffset: 0; } }

.login-card {
  width: 100%;
  padding: var(--space-xl) var(--space-lg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
}
.login-heading { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.025em; }
.login-sub { font-size: var(--text-sm); color: var(--color-ink-2); margin: var(--space-3xs) 0 var(--space-lg); }
.login-card .btn { margin-top: var(--space-xs); }
.login-alt-actions { display: flex; justify-content: space-between; gap: var(--space-xs); margin-top: var(--space-sm); }
.login-sub code { font-family: var(--font-mono); font-size: 0.95em; }
.login-foot {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  text-align: center;
}

/* ==========================================================================
   Helpers (kept small on purpose)
   ========================================================================== */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-sm { margin-bottom: var(--space-sm); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-toc { display: none; }
  .doc-jumpbar { display: flex; }
  .detail-section-header, .phase-card { scroll-margin-top: calc(var(--header-h) + 76px); }
}

@media (max-width: 960px) {
  .app-header { gap: var(--space-sm); padding: 0 var(--space-sm); }
  main { padding: var(--space-md) var(--space-sm); }
  .dashboard-grid,
  .dashboard-grid.has-sidebar { grid-template-columns: minmax(0, 1fr); gap: var(--space-md); }
  .sidebar-panel { position: static; order: 2; }
  .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-tile:nth-child(3) { border-left: 0; }
  .stat-tile:nth-child(n + 3) { border-top: 1px solid var(--color-rule); }
  .form-row-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vitals-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .brief-grid { grid-template-columns: minmax(0, 1fr); }
  .brief-grid .brief-block + .brief-block { margin-top: var(--space-md); }
  .fact-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .files-layout { grid-template-columns: minmax(0, 1fr); }
  .file-list { max-height: 280px; }
  .login-stage { grid-template-columns: minmax(0, 1fr); max-width: 560px; gap: var(--space-xl); }
  .login-brand { margin-bottom: var(--space-lg); }
  .rhythm-strip { margin-top: var(--space-lg); }
}

@media (max-width: 720px) {
  .app-header {
    grid-template-columns: auto auto;
    grid-template-rows: var(--header-h) 44px;
    height: auto;
    row-gap: 0;
  }
  .app-container { grid-template-rows: auto 1fr; }
  .nav-links { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; margin: 0 calc(-1 * var(--space-sm)); padding: 0 var(--space-2xs) 6px; }
  .nav-button { height: 36px; padding: 0 var(--space-xs); }
  .user-profile { justify-self: end; }
  .user-chip-name, .user-chip-btn .badge { display: none; }
  .page-header { align-items: flex-start; }
  .page-title, .dash-greeting, .doc-title { font-size: var(--text-xl); letter-spacing: -0.028em; }
  .page-desc { font-size: var(--text-base); }
  .stat-value { font-size: var(--text-xl); }
  .stat-tile { padding: var(--space-sm); }
  .stats-strip { margin-bottom: var(--space-xl); }
  .form-row-2, .form-row-3, .split-2, .outcomes-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-row-6, .vitals-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenario-catalog-header { align-items: stretch; }
  .catalog-tools { align-items: stretch; width: 100%; }
  .search-box, .users-toolbar .search-box { width: 100%; }
  .doc-header { flex-direction: column; }
  .detail-doc { padding: var(--space-lg) var(--space-sm); border-radius: var(--radius-lg); }
  .detail-section-header { padding: var(--space-xs) var(--space-sm); }
  .doc-section { margin-top: var(--space-xl); }
  .login-card { padding: var(--space-lg) var(--space-md); }
  .login-lede { font-size: var(--text-base); }
  .modal-card { padding: var(--space-md); border-radius: var(--radius-lg); }
  .view-switch { order: 3; width: 100%; margin-right: 0; }
  .view-switch-btn { flex: 1; justify-content: center; padding: 0 var(--space-xs); }
  .files-panel { padding: var(--space-md) var(--space-sm); border-radius: var(--radius-lg); }
  .planner-toolbar .search-box { width: 100%; }
  .category-bar { gap: var(--space-2xs); }
  .category-tools .btn { width: 36px; padding: 0; }
  .category-tools-label { display: none; }
  .planner-board { grid-auto-columns: minmax(260px, 86vw); }
  .pm-corner { min-width: 200px; }
  .file-stage { height: 60vh; min-height: 260px; }
  .fact-grid, .fact-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .doc-stat-value { font-size: var(--text-lg); }
  .sbar-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-3xs); }
  .meta-table tbody th { width: 40%; }
  .page-actions { flex-wrap: wrap; }
  .category-bar { flex-direction: column; align-items: stretch; }
  .category-tools { border-left: 0; padding-left: 0; justify-content: flex-end; }
  .search-hit { padding: var(--space-xs) var(--space-sm); flex-wrap: wrap; }
  .doc-jumpbar { border-radius: var(--radius-md); }
  .back-to-top { right: var(--space-sm); bottom: var(--space-sm); }
  .phase-track { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #toast-container { left: var(--space-sm); right: var(--space-sm); bottom: var(--space-sm); align-items: stretch; }
  .toast { max-width: none; }
}

/* Scenario editor below 960px: the step list folds behind a labelled
   "Step 3 of 8 · …" button above the form; on phones the footer wraps and
   Previous / Next show their destination on a second line. */
@media (max-width: 960px) {
  .editor-shell { grid-template-columns: minmax(0, 1fr); border-radius: var(--radius-lg); }
  .editor-nav { border-right: 0; border-bottom: 1px solid var(--color-rule); padding: var(--space-2xs) var(--space-sm); }
  .editor-steps-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    width: 100%;
    min-height: 44px;
    padding: 0 var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-rule-strong);
    border-radius: var(--radius-md);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-ink);
    text-align: left;
    cursor: pointer;
  }
  .editor-steps-toggle:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
  .editor-steps-hint { flex: none; font-weight: 500; color: var(--color-ink-2); }
  .editor-steps-hint i { transition: transform var(--dur-fast) var(--ease-out); }
  .editor-nav.is-open .editor-steps-hint i { transform: rotate(180deg); }
  .editor-steps-panel { display: none; position: static; max-height: none; overflow: visible; padding: var(--space-xs) 0 var(--space-2xs); }
  .editor-nav.is-open .editor-steps-panel { display: block; }
  .editor-nav-title { display: none; }
  .wizard-progress { margin-top: 0; }
  .step-head { scroll-margin-top: calc(var(--header-h) + var(--space-sm)); }
  .start-options { grid-template-columns: minmax(0, 1fr); }
  .vitals-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row-role { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .row-role > .form-group:last-child { grid-column: 1 / -1; max-width: 12rem; }
  .row-equipment { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .row-equipment > .form-group:first-child { grid-column: 1 / -1; max-width: 16rem; }
  .row-version { grid-template-columns: 6rem 10rem minmax(0, 1fr); }
  .row-version > .form-group:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  html:has(#view-scenario-form.active) { scroll-padding-top: calc(var(--header-h) + 56px); scroll-padding-bottom: 136px; }
  body:has(#view-scenario-form.active) #toast-container { bottom: var(--space-sm); }
  .editor-page-header .page-actions { width: 100%; }
  .editor-page-header .page-actions .btn-primary { flex: 1; }
  .editor-body { padding: var(--space-md) var(--space-sm) var(--space-lg); }
  .step-head { padding: var(--space-xs) var(--space-sm); scroll-margin-top: calc(var(--header-h) + 44px + var(--space-xs)); }
  .step-title { font-size: var(--text-md); }
  .wizard-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: var(--space-2xs) var(--space-sm);
  }
  .wizard-footer .save-state { grid-column: 1; grid-row: 1; font-size: var(--text-xs); white-space: normal; }
  .wizard-save-btn { grid-column: 2; grid-row: 1; justify-self: end; height: 36px; }
  .wizard-nav-btn { grid-row: 2; max-width: none; height: auto; min-height: 48px; padding-top: 4px; padding-bottom: 4px; white-space: normal; }
  #btn-prev-tab { grid-column: 1; }
  #btn-next-tab { grid-column: 2; }
  .wizard-nav-text { display: flex; flex-direction: column; align-items: inherit; line-height: 1.2; }
  .wizard-nav-colon { display: none; }
  .wizard-nav-dir { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: 0.06em; }
  .wizard-nav-dest { font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  #btn-prev-tab .wizard-nav-text { align-items: flex-start; }
  #btn-next-tab .wizard-nav-text { align-items: flex-end; }
  .field-row > .grow, .w-md, .w-lg { flex: 1 1 100%; width: 100%; }
  .timing-block { padding: var(--space-xs) var(--space-sm) var(--space-sm); }
  .timing-part { min-width: 7.5rem; }
  .timing-part .input-unit { width: 7.5rem; }
  .timing-op { display: none; }
  .timing-result { flex-basis: 100%; flex-direction: row; align-items: baseline; gap: var(--space-2xs); padding-bottom: 0; }
  .vitals-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phase-tab { flex-basis: calc(50% - var(--space-2xs)); max-width: none; }
  .phase-rail { flex-basis: 100%; }
  .phase-rail-add { flex: 1 1 100%; min-height: 40px; justify-content: center; }
  .mk-model { width: 100%; }
  .mk-model select { flex: 1; min-width: 0; }
  .phase-panel-head { position: static; padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-sm); }
  .phase-tools .icon-btn { width: 32px; height: 32px; }
  .phase-body { padding: 0 var(--space-sm) var(--space-sm); }
  .phase-panel-foot { padding: var(--space-xs) var(--space-sm); }
  .phase-go-dir { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .sub-row, .sub-row-act { grid-template-columns: minmax(0, 1fr) 36px; }
  .sub-row .sub-a { grid-column: 1 / -1; }
  .sub-row .sub-b { grid-column: 1; }
  .row-wide-narrow, .row-role, .row-equipment, .row-medication, .row-version { grid-template-columns: minmax(0, 1fr); }
  .row-role > .form-group:last-child, .row-equipment > .form-group:first-child { max-width: none; }
  .review-facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .review-todo { margin-left: 0; }
}

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

/* ==========================================================================
   PDF export (html2pdf captures the live DOM with this class applied)
   ========================================================================== */
body.pdf-printing { background: var(--color-surface); }
body.pdf-printing .app-header,
body.pdf-printing #view-scenario-detail > .page-header,
body.pdf-printing .detail-toc,
body.pdf-printing .doc-jumpbar,
body.pdf-printing .back-to-top,
body.pdf-printing .draft-banner .btn,
body.pdf-printing .trend-tip { display: none !important; }
body.pdf-printing main { padding: 0 !important; max-width: none !important; }
body.pdf-printing .detail-layout { display: block !important; }
body.pdf-printing .detail-doc { border: 0 !important; padding: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
body.pdf-printing .view-section.active { animation: none !important; }
body.pdf-printing .brief-wrap { max-width: none; }
body.pdf-printing .trend-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
/* In a PDF the title gets the full width and the governance row (status,
   version, review dates) sits under it, as on screen. */
body.pdf-printing .doc-header > div { flex: 1 1 100%; }
body.pdf-printing .doc-header > div { min-width: 0; }
body.pdf-printing .doc-title { font-size: var(--text-xl); }
body.pdf-printing .doc-governance { flex: none; }
body.pdf-printing .phase-card,
body.pdf-printing .sbar-row,
body.pdf-printing .sbar-card,
body.pdf-printing .brief-block,
body.pdf-printing .patient-card,
body.pdf-printing .fact,
body.pdf-printing .doc-stats,
body.pdf-printing .vitals-row,
body.pdf-printing .detail-section-header,
body.pdf-printing .card-inset { break-inside: avoid; }

/* ==========================================================================
   Reviews: the review schedule
   ========================================================================== */

/* Status tiles: one raised card, each figure a filter button */
.rv-tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.rv-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3xs);
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.rv-tile + .rv-tile { border-left: 1px solid var(--color-rule); }
.rv-tile:hover { background: var(--color-paper-2); }
.rv-tile:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.rv-tile.is-on { background: var(--color-accent-tint); box-shadow: inset 0 -3px 0 var(--color-accent); }
.rv-tile-value { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.rv-tile-label { font-size: var(--text-xs); color: var(--color-ink-2); }
.rv-tile-label i { margin-right: 2px; }
.rv-tile.tone-danger .rv-tile-value,
.rv-tile.tone-danger .rv-tile-label i { color: var(--color-danger); }
.rv-tile.tone-warning .rv-tile-value,
.rv-tile.tone-warning .rv-tile-label i { color: var(--color-warning); }
.rv-tile.tone-success .rv-tile-label i { color: var(--color-success); }

.reviews-toolbar .search-box { width: 280px; }

/* Table: overdue rows take the danger tint, due-soon rows the warning tint;
   the status chip in the last column says which in words. */
.reviews-table td { vertical-align: top; }
.reviews-table tbody tr.is-overdue { background: var(--color-danger-tint); }
.reviews-table tbody tr.is-due { background: var(--color-warning-tint); }
.reviews-table tbody tr.is-overdue:hover,
.reviews-table tbody tr.is-due:hover { background: var(--color-paper-3); }
.reviews-table tbody tr.row-selected { background: var(--color-accent-tint); }
.reviews-table .col-check { padding-top: 14px; }
.reviews-table .col-check input { margin: 0; }
.rv-scenario { min-width: 220px; }
.rv-scenario .badge { margin-left: 4px; }
.rv-open {
  display: block;
  margin-top: 2px;
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  text-align: left;
  color: var(--color-ink);
  cursor: pointer;
}
.rv-open:hover { color: var(--color-accent); text-decoration: underline; }
.rv-open mark { background: var(--color-warning-tint); color: inherit; border-radius: 2px; }
.rv-sub { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--color-ink-3); font-weight: 400; }
.rv-progs { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-due { white-space: nowrap; }
.rv-due-date { display: block; margin-bottom: 4px; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.th-sort i { font-size: 0.9em; color: var(--color-ink-3); }
.th-sort.is-on { color: var(--color-ink); }
.th-sort.is-on i { color: var(--color-accent); }
.th-sort:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }

/* Dashboard review tile link */
.stat-link {
  align-self: flex-start;
  margin-top: var(--space-2xs);
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
}
.stat-link i { font-size: 0.75em; margin-left: 2px; }
.stat-link:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* Scenario document: "by <reviewer>" under the last-reviewed date */
.doc-gov-sub { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--color-ink-2); }

/* Dialogs */
.modal-card.is-wide { width: min(780px, 100%); }
.rv-target { margin-bottom: var(--space-sm); font-weight: 600; }
.rv-target .scenario-code { margin-right: 6px; }
.rv-targets { margin-bottom: var(--space-sm); font-size: var(--text-sm); }
.rv-targets-head { font-weight: 600; margin-bottom: var(--space-3xs); }
.rv-targets ul { margin: 0; padding: var(--space-2xs) var(--space-xs); list-style: none; max-height: 168px; overflow-y: auto; background: var(--color-paper-2); border-radius: var(--radius-md); }
.rv-targets li { padding: 3px 0; }
.rv-targets .scenario-code { margin-right: 6px; }
.rv-targets .badge, .rv-target .badge { margin-left: 4px; }
.rv-hidden-note { display: inline-flex; align-items: center; gap: 4px; margin-left: var(--space-2xs); font-weight: 600; color: var(--color-warning); }

/* "View selected" */
.rv-selected-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.rv-selected-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); padding: var(--space-2xs) 0; border-bottom: 1px solid var(--color-rule); font-size: var(--text-sm); }
.rv-selected-list li:last-child { border-bottom: 0; }
.rv-selected-name { min-width: 0; overflow-wrap: anywhere; }
.rv-selected-name .scenario-code { margin-right: 6px; }
.rv-fieldset { border: 0; padding: 0; margin: 0 0 var(--space-sm); min-width: 0; }
.rv-fieldset legend { margin-bottom: var(--space-2xs); }
.rv-choices { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.rv-choice { position: relative; display: inline-flex; cursor: pointer; }
.rv-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rv-choice span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-sm);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.rv-choice:hover span { background: var(--color-paper-2); }
.rv-choice input:checked + span { background: var(--color-accent-tint); border-color: var(--color-accent); color: var(--color-ink); font-weight: 600; }
.rv-choice input:focus-visible + span { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.rv-custom-date { margin: var(--space-2xs) 0 0; }
.rv-quick { display: flex; flex-wrap: wrap; gap: var(--space-3xs); margin: calc(-1 * var(--space-2xs)) 0 var(--space-sm); }
.rv-current { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2xs); margin-bottom: var(--space-sm); font-size: var(--text-sm); }

.rv-rename-controls { display: flex; flex-wrap: wrap; gap: 0 var(--space-lg); }
.rv-each { display: grid; gap: 0; max-height: 300px; overflow-y: auto; margin-bottom: var(--space-sm); }
.rv-each-row { display: flex; flex-wrap: wrap; gap: 0 var(--space-xs); }
.rv-each-row .form-group { margin-bottom: var(--space-xs); }
.rv-each-row .grow { flex: 1 1 16rem; min-width: 0; }
.rv-preview { margin-top: var(--space-xs); padding-top: var(--space-sm); border-top: 1px solid var(--color-rule); }
.rv-preview-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-xs); margin-bottom: var(--space-2xs); }
.rv-preview-title { font-size: var(--text-md); font-weight: 700; letter-spacing: -0.015em; }
.rv-preview-list { max-height: 280px; overflow-y: auto; background: var(--color-paper-2); border-radius: var(--radius-md); }
.rv-preview-list .empty-note { padding: var(--space-sm); }
.rv-preview-table th { background: var(--color-paper-3); position: sticky; top: 0; }
.rv-preview-table td { vertical-align: top; }
.rv-before { color: var(--color-ink-3); text-decoration: line-through; }
.rv-after { font-weight: 600; }
.rv-after .field-error, .rv-after .form-help { font-weight: 500; }

.rv-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--space-md); }
.rv-facts .badge { margin-top: 2px; }
.rv-history-title { font-size: var(--text-md); font-weight: 700; letter-spacing: -0.015em; margin-bottom: var(--space-2xs); }
.rv-timeline { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.rv-entry { display: flex; gap: var(--space-xs); padding: var(--space-xs) 0; border-bottom: 1px solid var(--color-rule); }
.rv-entry:last-child { border-bottom: 0; }
.rv-entry-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-paper-2);
  color: var(--color-ink-2);
}
.rv-entry-icon.is-review { background: var(--color-success-tint); color: var(--color-success); }
.rv-entry-body { min-width: 0; }
.rv-entry-title { font-weight: 600; }
.rv-entry-meta { font-size: var(--text-sm); color: var(--color-ink-2); }
.rv-entry-notes { margin-top: 4px; font-size: var(--text-sm); white-space: pre-line; overflow-wrap: anywhere; }
.rv-entry-stamp { margin-top: 4px; font-size: var(--text-xs); color: var(--color-ink-3); }

/* Compact table: below 1360px the Programmes, Written and Reviewed by columns
   fold into the Scenario and Last reviewed cells, so the due status and the
   actions stay on screen without sideways scrolling. A Sort select stands
   in for the headers that fold away. */
.rv-compact { display: none; }
.rv-sort-select { display: none; }
@media (max-width: 1359px) {
  .reviews-table .rv-wide { display: none; }
  .reviews-table .rv-compact { display: block; }
  .rv-sort-select { display: block; }
  .rv-scenario { min-width: 0; }
  .reviews-table .rv-scenario .rv-sub { overflow-wrap: anywhere; }
}

/* The header's user chip keeps its avatar and role but drops the name when
   space is short, so every nav tab keeps its full label. */
@media (max-width: 1180px) {
  .app-header { gap: var(--space-md); }
  .user-chip-name { display: none; }
}

@media (max-width: 1100px) {
  .rv-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rv-tile:nth-child(4) { border-left: 0; }
  .rv-tile:nth-child(n+4) { border-top: 1px solid var(--color-rule); }
}
@media (max-width: 720px) {
  .rv-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rv-tile:nth-child(4) { border-left: 1px solid var(--color-rule); }
  .rv-tile:nth-child(odd) { border-left: 0; }
  .rv-tile:nth-child(n+3) { border-top: 1px solid var(--color-rule); }
  .reviews-toolbar .search-box { width: 100%; }
  .reviews-toolbar .toolbar-select { flex: 1 1 10rem; }
  .rv-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Rows become stacked cards: checkbox · scenario · menu, then each value
     under its label, so the due date never scrolls out of sight. */
  .reviews-table thead { display: none; }
  .reviews-table .rv-compact { display: none; }
  .reviews-table,
  .reviews-table tbody { display: block; }
  .reviews-table tbody tr[data-sid] {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: var(--space-xs);
    padding: var(--space-sm);
    border-bottom: 1px solid var(--color-rule);
  }
  .reviews-table tbody tr[data-sid]:last-child { border-bottom: 0; }
  .reviews-table tbody tr[data-sid] > td { display: block; padding: 0; border: 0; white-space: normal; }
  .reviews-table td.col-check { grid-column: 1; grid-row: 1; width: auto; padding-top: 4px; }
  .reviews-table td.rv-scenario { grid-column: 2; grid-row: 1; min-width: 0; margin-bottom: var(--space-2xs); }
  .reviews-table td.col-actions { grid-column: 3; grid-row: 1; }
  .reviews-table tbody tr[data-sid] > td[data-label] {
    grid-column: 2 / 4;
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: var(--space-2xs);
    padding-top: 6px;
  }
  .reviews-table td[data-label]::before { content: attr(data-label); font-size: var(--text-xs); color: var(--color-ink-3); padding-top: 2px; }
  .rv-progs { max-width: 100%; white-space: normal; }
}

/* ---------------------------------------------------------------------------
   Manikin: the scenario page's Manikin tab, bulk export and import dialogs,
   and the Manikin panel in each phase of the editor.
   --------------------------------------------------------------------------- */
.mk-wrap { max-width: 1200px; margin: 0 auto; display: grid; gap: var(--space-md); }
.mk-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  min-width: 0;
}
.mk-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}
.mk-title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; }
.mk-sub { font-size: var(--text-sm); color: var(--color-ink-2); margin-top: var(--space-3xs); max-width: 60ch; }
.mk-actions { display: flex; gap: var(--space-2xs); align-items: center; flex-wrap: wrap; }
.mk-actions .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.mk-check {
  font-size: var(--text-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}
.mk-check i { margin-right: 4px; }
.mk-check.is-ok { background: var(--color-success-tint); }
.mk-check.is-ok i { color: var(--color-success); }
.mk-check.is-error { background: var(--color-danger-tint); }
.mk-check.is-error .mk-check-title i { color: var(--color-danger); }
.mk-check.is-warning { background: var(--color-warning-tint); }
.mk-check.is-warning .mk-check-title i { color: var(--color-warning); }
.mk-check-title { font-weight: 600; }
.mk-check ul { margin: var(--space-3xs) 0 0; padding-left: 1.4rem; color: var(--color-ink-2); }
.mk-check li + li { margin-top: 2px; }

.mk-table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--color-rule); border-radius: var(--radius-md); }
.mk-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.mk-table th, .mk-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--color-rule); }
.mk-table thead th { background: var(--color-paper-2); font-weight: 600; white-space: nowrap; }
.mk-table tbody th[scope="row"] { font-weight: 500; color: var(--color-ink-2); white-space: nowrap; width: 1%; }
.mk-table tr:last-child > * { border-bottom: 0; }
.mk-table .mk-group th {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-3);
  padding-top: var(--space-xs);
  padding-bottom: 4px;
}
.mk-cell { min-width: 7.5rem; }
.mk-cell.is-carried { color: var(--color-ink-3); }
.mk-cell.is-empty { color: var(--color-ink-3); }
.mk-cell.is-problem { color: var(--color-danger); font-weight: 500; }
.mk-notes { white-space: pre-line; min-width: 12rem; color: var(--color-ink-2); }
.mk-unit { color: var(--color-ink-3); font-size: var(--text-xs); }
.mk-legend, .mk-how { font-size: var(--text-xs); color: var(--color-ink-3); margin-top: var(--space-xs); }
.mk-how { margin-top: var(--space-md); max-width: 75ch; }
.mk-how i { margin-right: 4px; }
.mk-swatch { font-family: var(--font-mono); padding: 0 4px; border-radius: var(--radius-sm); background: var(--color-paper-2); }
.mk-swatch.is-carried { color: var(--color-ink-3); }
.mk-empty { padding: var(--space-lg) var(--space-sm); }

.mk-versions { list-style: none; margin: 0; padding: 0; }
.mk-version {
  display: flex;
  align-items: center;
  gap: var(--space-2xs) var(--space-xs);
  flex-wrap: wrap;
  padding: var(--space-xs) 0;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
}
.mk-version:first-child { border-top: 0; padding-top: 0; }
.mk-version-label { font-weight: 600; }
.mk-version-meta { color: var(--color-ink-2); }
.mk-version-actions { margin-left: auto; display: flex; gap: var(--space-2xs); }
.mk-version-loading, .mk-version-none { color: var(--color-ink-3); }

.mk-diff + .mk-diff { margin-top: var(--space-sm); }
.mk-diff-title { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-2xs); display: flex; align-items: center; gap: 6px; }
.mk-diff-table { font-size: var(--text-sm); }

.mk-bulk-list { list-style: none; margin: 0 0 var(--space-sm); padding: 0; max-height: 50vh; overflow-y: auto; }
.mk-bulk-row {
  display: grid;
  gap: 2px;
  padding: var(--space-2xs) 0;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
}
.mk-bulk-row:first-child { border-top: 0; }
.mk-bulk-name .scenario-code { margin-right: 6px; }
.mk-bulk-status { color: var(--color-ink-2); }
.mk-bulk-status i { margin-right: 4px; }
.mk-bulk-status.is-ok i { color: var(--color-success); }
.mk-bulk-status.is-warning i { color: var(--color-warning); }
.mk-bulk-status.is-error { color: var(--color-danger); }
.mk-notes-list { margin: 2px 0 0; padding-left: 1.4rem; font-size: var(--text-xs); color: var(--color-ink-2); }

/* Editor: Manikin, the last block of a phase, folded behind one summary
   line ("Sinus Rhythm · 2 more settings", or what needs fixing). */
.phase-manikin {
  margin-top: var(--space-lg);
  background: var(--color-paper-2);
  border-radius: var(--radius-md);
}
.phase-manikin > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  list-style: none;
  cursor: pointer;
}
.phase-manikin > summary::-webkit-details-marker { display: none; }
.phase-manikin > summary:hover { background: var(--color-paper-3); }
.phase-manikin > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.phase-mk-title { font-weight: 700; }
.phase-mk-title i { color: var(--color-ink-3); margin-right: 4px; }
.phase-mk-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-xs); flex: 1; min-width: 0; font-size: var(--text-sm); color: var(--color-ink-2); }
.phase-mk-flag { font-weight: 600; }
.phase-mk-flag i { margin-right: 2px; }
.phase-mk-flag.is-error { color: var(--color-danger); }
.phase-mk-flag.is-warning { color: var(--color-warning); }
.phase-mk-chevron { margin-left: auto; color: var(--color-ink-3); transition: transform var(--dur-fast) var(--ease-out); }
.phase-manikin[open] > summary .phase-mk-chevron { transform: rotate(180deg); }
.phase-mk-body { padding: 0 var(--space-sm) var(--space-sm); }
.phase-mk-body > .form-group:last-child { margin-bottom: 0; }
.mk-model-line { margin: 0 0 var(--space-3xs); }
.mk-readout { margin: 0 0 var(--space-xs); }
.mk-readout.is-problem { color: var(--color-danger); }
.mk-readout-problem { display: block; }
.mk-readout-problem i { margin-right: 4px; }
.mk-fields { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xs); align-items: flex-end; }
.mk-fields .form-group { margin-bottom: 0; }
.mk-fields label { font-size: var(--text-xs); white-space: nowrap; }
.mk-fields input { font-variant-numeric: tabular-nums; }
.mk-more { margin: var(--space-xs) 0; font-size: var(--text-sm); }
.mk-more > summary { cursor: pointer; color: var(--color-ink-2); font-weight: 500; }
.mk-more[open] > summary { margin-bottom: var(--space-2xs); }

@media (max-width: 720px) {
  .mk-card { padding: var(--space-sm); border-radius: var(--radius-lg); }
  .mk-version-actions { margin-left: 0; width: 100%; }
}
.modal-lede { font-size: var(--text-sm); color: var(--color-ink-2); margin-bottom: var(--space-sm); }
.mk-diff-table tbody th[scope="row"] { background: none; font-weight: 500; color: var(--color-ink-2); }

/* Four scenario tabs on a phone: words only, so they fit at 360px. */
@media (max-width: 520px) {
  .view-switch-btn { padding: 0 var(--space-2xs); gap: 4px; font-size: var(--text-xs); }
  .view-switch-btn > i { display: none; }
}
.mk-doc-line i { color: var(--color-ink-3); margin-right: 4px; }
.mk-group-block { padding-top: var(--space-xs); }
.mk-group-block + .mk-group-block { border-top: 1px solid var(--color-rule); margin-top: var(--space-xs); }
.mk-group-title { font-size: var(--text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-ink-3); margin-bottom: var(--space-3xs); }
.mk-field.is-unsupported select, .mk-field.is-unsupported input { border-style: dashed; }
.mk-field-note { display: block; font-size: var(--text-2xs); color: var(--color-warning); margin-top: 2px; }
.mk-readout-problem.is-warning { color: var(--color-warning); }
.mk-cell.is-fixed { color: var(--color-ink-2); }
.mk-fixed-note { font-size: var(--text-2xs); color: var(--color-ink-3); white-space: nowrap; }
