/* =========================================================================
   A&E Live Simulator Ã¢â‚¬â€ NHS-inspired clinical software appearance.
   Deliberately generic: dark navy header, light grey workspace, clear
   tables, large readable waiting times, colour + text priority badges.
   ========================================================================= */

:root {
  --navy: #00354f;
  --navy-mid: #0a4a6b;
  --navy-deep: #00213a;
  --paper: #ffffff;
  --paper-2: #f4f6f8;
  --paper-3: #e6ecf1;
  --ink: #1a2530;
  --ink-soft: #536270;
  --ink-faint: #7c8a98;
  --line: #d3dde6;
  --line-2: #c2ced8;
  --danger: #b3261e;
  --danger-soft: #fbeaea;
  --warn: #a8620f;
  --warn-soft: #fdf3e4;
  --ok: #1d7a3a;
  --ok-soft: #e9f5ec;
  --red: #d23b2e;
  --orange: #e08a1e;
  --yellow: #d9b61a;
  --green: #3c8c4a;
  --blue: #3a6f9c;
  --mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-2);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; }
p { margin: 0 0 6px; }
a { color: var(--navy-mid); }

.hidden { display: none !important; }
/* ---------------------------------------------------------------- header */
/*
 * Bug #12: the header used to wrap onto a second row at every normal desktop width. `.topbar`,
 * `.topnav` and `.topcontrols` all carried `flex-wrap: wrap`, and the header's natural content
 * width was ~1905px — more than a 1920px viewport once padding and gaps are counted, so the
 * simulation controls were always pushed onto their own row.
 *
 * The bar is now a single non-wrapping row. The fix is threefold: the header can no longer wrap,
 * the controls are compacted and the labels shortened so it genuinely fits, and the two decorative
 * elements that are duplicated elsewhere (the "Educational simulation" marker, which is also in the
 * footer, and the wordmark text) are dropped before anything functional would be. If a viewport is
 * narrower still, the controls scroll horizontally rather than wrapping or overflowing the page.
 */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  background: var(--navy);
  color: #eef3f7;
  padding: 8px 12px;
  border-bottom: 3px solid var(--navy-deep);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  background: #fff; color: var(--navy); font-weight: 800;
  padding: 5px 9px; border-radius: 6px; font-size: 13px; letter-spacing: 0.4px;
}
.brand-title { font-weight: 600; font-size: 15px; white-space: nowrap; }
.clock-block { display: flex; flex-direction: column; line-height: 1.2; min-width: 140px; flex-shrink: 0; }
.clock { font-family: var(--mono); font-size: 17px; color: #fff; font-weight: 600; white-space: nowrap; }
.date { font-size: 12px; color: #bcd4e3; white-space: nowrap; }
.topnav { display: flex; gap: 2px; margin-left: auto; flex-wrap: nowrap; flex-shrink: 0; }
.topnav-link {
  color: #cfe0ec; text-decoration: none; padding: 6px 9px;
  border-radius: 6px; font-size: 12.5px; white-space: nowrap;
}
.topnav-link:hover { background: rgba(255, 255, 255, 0.12); }
.topnav-link.active { background: #fff; color: var(--navy); font-weight: 600; }
/* The controls never wrap either: below the width at which everything fits, they scroll sideways
   so that no control is ever pushed onto a second row or clipped out of reach. */
.topcontrols {
  display: flex; align-items: center; gap: 5px;
  flex-wrap: nowrap; flex-shrink: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.topcontrols::-webkit-scrollbar { display: none; }
/* Compact chrome for the header strip only — the wider button styling still applies inside panels. */
.topcontrols .btn { padding: 5px 8px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.mode-tag {
  background: var(--yellow); color: #3a2f00; font-weight: 800; font-size: 10px;
  letter-spacing: 0.7px; padding: 4px 8px; border-radius: 4px; white-space: nowrap; flex-shrink: 0;
}
/* "Educational simulation" is also stated permanently in the footer, so the header copy is the one
   to drop when the bar needs the space. */
.disclaimer-tag { display: none; }
/*
 * On a narrower laptop the wordmark text is the next thing to go, before any control is: the "A&E"
 * mark alone still identifies the app, and the full title is in the document title and footer. This
 * keeps every simulation control fully visible and clickable without scrolling the strip.
 */
@media (max-width: 1400px) {
  .brand-title { display: none; }
}

/* --------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.btn:hover { background: var(--paper-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #8f1e16; }

.btn-warning { background: #e67e22; color: #fff; border-color: #e67e22; }
.btn-warning:hover { background: #d35400; }

.closed-badge {
  background: var(--danger);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 12px;
  animation: pulse 2s infinite;
}

.scenario-badge {
  background: var(--warn);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 12px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ----------------------------------------------------------------- shell */
.btn-ghost { background: transparent; }
.topbar .btn-ghost { color: #e6f0f6; border-color: #2c6285; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }
.topbar .btn-ghost[aria-pressed="true"] { background: #fff; color: var(--navy); }

#main { padding: 16px; max-width: 1560px; margin: 0 auto; width: 100%; }
.app-footer {
  text-align: center; padding: 12px; color: var(--ink-faint);
  font-size: 11px; border-top: 1px solid var(--line); margin-top: 20px;
}
.dept-header {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px;
}
.dept-title { font-size: 20px; color: var(--navy); }
.dept-sub { font-size: 12px; color: var(--ink-soft); }
.pressure-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.8px; padding: 3px 9px;
  border-radius: 999px; background: var(--ok-soft); color: var(--ok); border: 1px solid #b9dcc3;
}
.pressure-label.BUSY { background: var(--warn-soft); color: var(--warn); border-color: #e8cf9e; }
.pressure-label.VERY_BUSY { background: #fdece4; color: #b4501a; border-color: #f0c6ad; }
.pressure-label.SEVERE_PRESSURE { background: var(--danger-soft); color: var(--danger); border-color: #efb6b1; }
.pause-tag, .speed-tag {
  font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 4px; margin-left: 6px;
}
.pause-tag { background: var(--danger); color: #fff; }
.speed-tag { background: var(--yellow); color: #3a2f00; }

/* -------------------------------------------------------------- KPI tiles */
.kpi-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); font-weight: 700; }
.kpi-value { font-size: 21px; font-weight: 700; color: var(--navy); margin-top: 3px; font-family: var(--mono); }
.kpi-sub { font-size: 11px; color: var(--ink-faint); }

/* ---------------------------------------------------------- area capacity */
.area-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; margin-bottom: 14px; }
.area-cell {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy-mid);
  border-radius: 6px; padding: 8px 10px;
}
.area-cell.full { border-left-color: var(--danger); background: var(--danger-soft); }
.area-cell.busy { border-left-color: var(--warn); background: var(--warn-soft); }
.area-name { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; }
.area-capacity { font-family: var(--mono); font-weight: 700; color: var(--navy); font-size: 15px; }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; align-items: center; }
.filter-chip {
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-soft);
  padding: 5px 11px; border-radius: 999px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.filter-chip:hover { background: var(--paper-3); }
.filter-chip.active { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.filter-count { opacity: 0.75; font-family: var(--mono); font-size: 11px; }
.filter-note { font-size: 11.5px; color: var(--ink-faint); margin-left: auto; }
.mono { font-family: var(--mono); }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
table.patient-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.patient-table th {
  text-align: left; padding: 8px 10px; background: var(--paper-3); color: var(--ink-soft);
  font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--line-2); cursor: pointer; white-space: nowrap;
}
table.patient-table th.sorted { color: var(--navy); }
table.patient-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.patient-table tbody tr { cursor: pointer; }
table.patient-table tbody tr:hover { background: var(--paper-2); }
table.patient-table tbody tr.critical { background: #fdf0ef; }
table.patient-table tbody tr.critical:hover { background: #fbe3e0; }
.wait-cell { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.wait-cell.long { color: var(--danger); }
.wait-cell.mid { color: var(--warn); }
.status-cell { min-width: 195px; }
.status-main { font-weight: 600; }
.status-timer { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.location-cell { white-space: nowrap; font-size: 12.5px; }
.flag-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.flag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px; padding: 1px 5px;
  border-radius: 3px; background: var(--paper-3); color: var(--ink-soft); text-transform: uppercase;
}
.flag.alert { background: var(--danger); color: #fff; }
.flag.amb { background: var(--navy-mid); color: #fff; }
.flag.child { background: #6a4c93; color: #fff; }

.priority-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
  font-weight: 800; color: #fff; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap;
}
.priority-badge.RED { background: var(--red); }
.priority-badge.ORANGE { background: var(--orange); }
.priority-badge.YELLOW { background: var(--yellow); color: #3a2f00; }
.priority-badge.GREEN { background: var(--green); }
.priority-badge.BLUE { background: var(--blue); }
.priority-badge.NONE { background: var(--paper-3); color: var(--ink-faint); }
.priority-badge.suggested { opacity: 0.85; outline: 1px dashed var(--ink-faint); }

.empty-note { color: var(--ink-faint); font-style: italic; padding: 22px; text-align: center; }

/* ---------------------------------------------------------- panels / log */
.panel-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-top: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 800;
  color: var(--ink-soft); margin-bottom: 8px;
}
.event-log { max-height: 280px; overflow-y: auto; font-family: var(--mono); font-size: 12px; }
.event-log .entry { padding: 2px 0; color: var(--ink-soft); border-bottom: 1px dotted var(--line); display: flex; gap: 8px; }
.event-log .entry .t { color: var(--ink-faint); flex: 0 0 46px; }
.event-log .entry.alert { color: var(--danger); font-weight: 600; }
.event-log .entry.ambulance, .event-log .entry.arrival { color: var(--navy-mid); }
.event-log .entry.outcome { color: var(--ok); }
.event-log .entry.pressure { font-weight: 700; color: var(--warn); }

.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 8px; }
.staff-card { border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-size: 12px; }
.staff-role { font-weight: 650; color: var(--navy); }
.staff-state { font-size: 11px; font-family: var(--mono); }
.staff-state.AVAILABLE { color: var(--ok); }
.staff-state.WITH_PATIENT, .staff-state.BUSY { color: var(--warn); }
.staff-state.BREAK, .staff-state.DOCUMENTING { color: var(--ink-faint); }
.staff-state.OFF_SHIFT { color: var(--ink-faint); text-decoration: line-through; }

.ward-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 8px; }
.ward-card { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 12px; }
.ward-bar { height: 6px; background: var(--paper-3); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.ward-bar > span { display: block; height: 100%; background: var(--navy-mid); }
.ward-bar > span.high { background: var(--warn); }
.ward-bar > span.critical { background: var(--danger); }

/* --------------------------------------------------------------- alerts */
.alert-container { display: grid; gap: 10px; margin-top: 16px; }
.alert-card {
  background: var(--danger-soft); border: 1px solid var(--danger); border-left: 5px solid var(--danger);
  border-radius: var(--radius); padding: 12px 14px;
}
.alert-card.reassess { background: var(--warn-soft); border-color: var(--warn); border-left-color: var(--warn); }
.alert-card.buzzer { background: #f6e9ff; border-color: #7d4fa8; border-left-color: #7d4fa8; }
.alert-card.call { background: var(--ok-soft); border-color: var(--ok); border-left-color: var(--ok); }
.alert-title {
  font-weight: 800; font-size: 11px; letter-spacing: 0.7px; text-transform: uppercase; margin-bottom: 5px;
}
.alert-card .alert-headline { font-weight: 650; margin-bottom: 4px; }
.alert-card .alert-meta { font-size: 12px; color: var(--ink-soft); }
.alert-actions { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }

/* ---------------------------------------------------- triage queue cards */
.triage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.triage-card {
  background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--navy-mid);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
}
.triage-card:hover { border-color: var(--navy-mid); box-shadow: 0 2px 8px rgba(0, 53, 79, 0.12); }
.triage-card.held { border-top-color: var(--yellow); }
.triage-card.critical { border-top-color: var(--red); }
.triage-id { font-family: var(--mono); font-weight: 700; color: var(--navy); }
.triage-name { font-size: 15px; font-weight: 650; }
.triage-age, .triage-method { font-size: 12px; color: var(--ink-soft); }
.triage-complaint { font-size: 13px; margin: 6px 0; }
.triage-wait { font-family: var(--mono); font-weight: 700; color: var(--warn); margin-bottom: 8px; }
.queue-count {
  display: inline-block; background: var(--navy); color: #fff; font-weight: 800;
  padding: 4px 11px; border-radius: 999px; font-size: 13px; margin-right: 8px;
}

/* ------------------------------------------------------- triage workspace */
.triage-workspace { display: grid; gap: 14px; }
.workspace-header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.workspace-header h2 { font-size: 19px; color: var(--navy); }
.workspace-columns { display: grid; grid-template-columns: 1.05fr 1fr; gap: 14px; align-items: start; }
.workspace-summary { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.workspace-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.workspace-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); margin-bottom: 8px; }
.summary-list { display: grid; grid-template-columns: 122px 1fr; gap: 4px 10px; font-size: 13px; }
.summary-list dt { color: var(--ink-soft); font-size: 12px; }
.summary-list dd { margin: 0; }
.story-block { margin-top: 10px; padding: 9px 11px; background: var(--paper-2); border-left: 3px solid var(--navy-mid); border-radius: 4px; font-size: 13px; }
.question-group { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.question-group legend { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 800; color: var(--navy); padding: 0 4px; }
.question-list { display: flex; flex-wrap: wrap; gap: 6px; }
.question-list .btn { font-size: 12px; padding: 4px 9px; }
.answers-display { max-height: 300px; overflow-y: auto; }
.answer-item { border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.answer-item .q { color: var(--ink-soft); font-size: 12px; }
.answer-item .a { font-weight: 600; }
.obs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 8px; margin-bottom: 10px; }
.obs-field { display: flex; flex-direction: column; }
.obs-field label { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.obs-field input { padding: 5px 7px; border: 1px solid var(--line-2); border-radius: 4px; font-family: var(--mono); font-size: 13px; width: 100%; }
.obs-field .unit { font-size: 10px; color: var(--ink-faint); }
.priority-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.priority-btn {
  border: 2px solid transparent; color: #fff; font-weight: 800; font-size: 12px;
  padding: 8px 14px; border-radius: 6px; cursor: pointer; letter-spacing: 0.5px; font-family: inherit;
}
.priority-btn.selected { outline: 3px solid var(--ink); }
.priority-btn small { display: block; font-weight: 500; font-size: 10px; opacity: 0.92; }
.priority-note { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.verdict { padding: 9px 11px; border-radius: 6px; font-size: 13px; margin-top: 8px; }
.verdict.MATCH { background: var(--ok-soft); border: 1px solid #b9dcc3; color: var(--ok); }
.verdict.near { background: var(--warn-soft); border: 1px solid #e8cf9e; color: var(--warn); }
.verdict.far { background: var(--danger-soft); border: 1px solid #efb6b1; color: var(--danger); }
.checklist { font-size: 12.5px; color: var(--ink-soft); margin: 0; padding-left: 18px; }
.checklist li { margin-bottom: 2px; }

/* ----------------------------------------------------------- waiting room */
.waiting-header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.waiting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); gap: 10px; }
.waiting-card {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy-mid);
  border-radius: 6px; padding: 10px 12px; cursor: pointer;
}
.waiting-card:hover { box-shadow: 0 2px 8px rgba(0, 53, 79, 0.12); }
.waiting-card.alert { border-left-color: var(--danger); background: var(--danger-soft); }
.waiting-card.amb { border-left-color: var(--navy); }
.waiting-id { font-family: var(--mono); font-weight: 700; color: var(--navy); }
.waiting-name { font-weight: 600; }
.waiting-age { font-size: 12px; color: var(--ink-soft); }
.waiting-wait { font-family: var(--mono); font-size: 16px; color: var(--warn); font-weight: 700; margin: 4px 0; }
.waiting-status { font-size: 12.5px; font-weight: 600; }
.waiting-location { font-size: 11.5px; color: var(--ink-faint); }
.waiting-empty { color: var(--ink-faint); font-style: italic; padding: 22px; text-align: center; }

/* ------------------------------------------------------------- statistics */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); font-weight: 700; }
.stat-value { font-size: 19px; font-weight: 700; font-family: var(--mono); color: var(--navy); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--ink-faint); }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 132px; padding: 8px 4px 0; border-bottom: 1px solid var(--line-2); }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 1px; min-width: 8px; }
.chart-bar { width: 100%; background: var(--navy-mid); border-radius: 2px 2px 0 0; min-height: 1px; }
.chart-bar.secondary { background: var(--warn); }
.chart-x { font-size: 9px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.priority-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.priority-table th, .priority-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.priority-table th { font-size: 11px; text-transform: uppercase; color: var(--ink-soft); }
.recent-list { max-height: 320px; overflow-y: auto; font-size: 12.5px; }
.recent-row { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.recent-row .id { font-family: var(--mono); color: var(--navy); flex: 0 0 62px; }
.recent-row .out { flex: 0 0 118px; font-weight: 600; }
.recent-row .detail { color: var(--ink-faint); }

/* ----------------------------------------------------------- waiting room */
.waiting-header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.waiting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); gap: 10px; }
.waiting-card {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy-mid);
  border-radius: 6px; padding: 10px 12px; cursor: pointer;
}
.waiting-card:hover { box-shadow: 0 2px 8px rgba(0, 53, 79, 0.12); }
.waiting-card.alert { border-left-color: var(--danger); background: var(--danger-soft); }
.waiting-card.amb { border-left-color: var(--navy); }
.waiting-id { font-family: var(--mono); font-weight: 700; color: var(--navy); }
.waiting-name { font-weight: 600; }
.waiting-age { font-size: 12px; color: var(--ink-soft); }
.waiting-wait { font-family: var(--mono); font-size: 16px; color: var(--warn); font-weight: 700; margin: 4px 0; }
.waiting-status { font-size: 12.5px; font-weight: 600; }
.waiting-location { font-size: 11.5px; color: var(--ink-faint); }
.waiting-empty { color: var(--ink-faint); font-style: italic; padding: 22px; text-align: center; }

/* ------------------------------------------------------------- statistics */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); font-weight: 700; }
.stat-value { font-size: 19px; font-weight: 700; font-family: var(--mono); color: var(--navy); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--ink-faint); }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 132px; padding: 8px 4px 0; border-bottom: 1px solid var(--line-2); }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 1px; min-width: 8px; }
.chart-bar { width: 100%; background: var(--navy-mid); border-radius: 2px 2px 0 0; min-height: 1px; }
.chart-bar.secondary { background: var(--warn); }
.chart-x { font-size: 9px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.priority-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.priority-table th, .priority-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.priority-table th { font-size: 11px; text-transform: uppercase; color: var(--ink-soft); }
.recent-list { max-height: 320px; overflow-y: auto; font-size: 12.5px; }
.recent-row { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.recent-row .id { font-family: var(--mono); color: var(--navy); flex: 0 0 62px; }
.recent-row .out { flex: 0 0 118px; font-weight: 600; }
.recent-row .detail { color: var(--ink-faint); }

/* ----------------------------------------------------------- waiting room */
.waiting-header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.waiting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); gap: 10px; }
.waiting-card {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy-mid);
  border-radius: 6px; padding: 10px 12px; cursor: pointer;
}
.waiting-card:hover { box-shadow: 0 2px 8px rgba(0, 53, 79, 0.12); }
.waiting-card.alert { border-left-color: var(--danger); background: var(--danger-soft); }
.waiting-card.amb { border-left-color: var(--navy); }
.waiting-id { font-family: var(--mono); font-weight: 700; color: var(--navy); }
.waiting-name { font-weight: 600; }
.waiting-age { font-size: 12px; color: var(--ink-soft); }
.waiting-wait { font-family: var(--mono); font-size: 16px; color: var(--warn); font-weight: 700; margin: 4px 0; }
.waiting-status { font-size: 12.5px; font-weight: 600; }
.waiting-location { font-size: 11.5px; color: var(--ink-faint); }
.waiting-empty { color: var(--ink-faint); font-style: italic; padding: 22px; text-align: center; }

/* ----------------------------------------------------------- waiting room */
.waiting-header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.waiting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr)); gap: 10px; }
.waiting-card {
  background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--navy-mid);
  border-radius: 6px; padding: 10px 12px; cursor: pointer;
}
.waiting-card:hover { box-shadow: 0 2px 8px rgba(0, 53, 79, 0.12); }
.waiting-card.alert { border-left-color: var(--danger); background: var(--danger-soft); }
.waiting-card.amb { border-left-color: var(--navy); }
.waiting-id { font-family: var(--mono); font-weight: 700; color: var(--navy); }
.waiting-name { font-weight: 600; }
.waiting-age { font-size: 12px; color: var(--ink-soft); }
.waiting-wait { font-family: var(--mono); font-size: 16px; color: var(--warn); font-weight: 700; margin: 4px 0; }
.waiting-status { font-size: 12.5px; font-weight: 600; }
.waiting-location { font-size: 11.5px; color: var(--ink-faint); }
.waiting-empty { color: var(--ink-faint); font-style: italic; padding: 22px; text-align: center; }

/* ------------------------------------------------------------- statistics */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); font-weight: 700; }
.stat-value { font-size: 19px; font-weight: 700; font-family: var(--mono); color: var(--navy); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--ink-faint); }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 132px; padding: 8px 4px 0; border-bottom: 1px solid var(--line-2); }
.chart-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 1px; min-width: 8px; }
.chart-bar { width: 100%; background: var(--navy-mid); border-radius: 2px 2px 0 0; min-height: 1px; }
.chart-bar.secondary { background: var(--warn); }
.chart-x { font-size: 9px; color: var(--ink-faint); font-family: var(--mono); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.priority-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.priority-table th, .priority-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.priority-table th { font-size: 11px; text-transform: uppercase; color: var(--ink-soft); }
.recent-list { max-height: 320px; overflow-y: auto; font-size: 12.5px; }
.recent-row { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dotted var(--line); }
.recent-row .id { font-family: var(--mono); color: var(--navy); flex: 0 0 62px; }
.recent-row .out { flex: 0 0 118px; font-weight: 600; }
.recent-row .detail { color: var(--ink-faint); }

/* ------------------------------------------------------ ambulance pre-alerts */
/* A slim one-line-per-crew bar under the area strip. This was originally a boxed panel with a card
   per crew, which read as a full dashboard section and crowded out the board it was meant to serve.
   Kept to a single compact line per crew, with the crew's full report on the line's tooltip. */
.inbound-strip {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 0 0 8px; padding: 6px 10px; background: #eef5fc;
  border: 1px solid #cfe0f0; border-left: 4px solid var(--nhs-blue, #005eb8);
  border-radius: 3px; font-size: 13px; line-height: 1.5;
}
.inbound-label {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--nhs-blue, #005eb8);
}
.inbound-mark { font-size: 13px; }
.inbound-count { flex: none; font-size: 11.5px; color: #768692; }
.inbound-list { display: flex; flex-wrap: wrap; gap: 4px 16px; min-width: 0; }

.inbound-row {
  display: inline-flex; align-items: baseline; gap: 7px; min-width: 0;
  /* A newly announced crew should register without the whole bar jumping. */
  animation: inbound-arrive 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes inbound-arrive {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .inbound-row { animation: none; } }

.inbound-eta {
  flex: none; min-width: 30px; font-weight: 700; text-align: right;
  color: var(--nhs-dark, #003087); font-variant-numeric: tabular-nums;
}
.inbound-id { flex: none; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.inbound-who { flex: none; font-size: 12px; color: #768692; }
.inbound-complaint {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--navy); font-weight: 600;
}

/* RED is the one that needs a bay cleared now, so it is the only crew given a red edge. */
.inbound-red .inbound-eta { color: var(--nhs-red, #d5281b); }
.inbound-red { box-shadow: inset 2px 0 0 var(--nhs-red, #d5281b); }
.inbound-orange .inbound-eta { color: #a85d00; }

@media (max-width: 620px) {
  .inbound-strip { gap: 4px; padding: 5px 8px; }
  .inbound-list { flex-direction: column; gap: 2px; width: 100%; }
}



/* --------------------------------------------------------------- main menu */
/* NHS-style landing: the official palette is NHS Blue #005EB8 on a #f0f4f5 page, with
   #003087 for headings and #425563 for body text. Deliberately generic and unbranded — this is an
   educational simulation and must not read as an official NHS service. */
.main-menu {
  position: fixed; inset: 0; z-index: 80; overflow-y: auto;
  background: var(--nhs-bg, #f0f4f5);
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
.main-menu.is-leaving { animation: menu-fade-out 260ms ease forwards; }
.main-menu-inner { width: 100%; max-width: 760px; }

.main-menu-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.main-menu-mark {
  flex: 0 0 auto; width: 62px; height: 62px; border-radius: 4px;
  background: var(--nhs-blue, #005eb8); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 700; letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0, 80, 148, 0.25);
  animation: menu-mark-in 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main-menu-brand h1 {
  margin: 0; font-size: 30px; line-height: 1.15; color: var(--nhs-dark, #003087);
  animation: menu-rise 480ms 60ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main-menu-tagline {
  margin: 5px 0 0; font-size: 15px; color: var(--nhs-text, #425563);
  animation: menu-rise 480ms 130ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.main-menu-actions { display: grid; gap: 12px; }
.nhs-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: #fff; border: 0; border-left: 6px solid var(--nhs-blue, #005eb8);
  border-radius: 2px; padding: 18px 20px; font: inherit; color: inherit;
  box-shadow: 0 1px 3px rgba(0, 33, 58, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  animation: menu-rise 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Staggered entrance, so the options arrive in reading order rather than as one block. */
.nhs-card:nth-child(1) { animation-delay: 180ms; }
.nhs-card:nth-child(2) { animation-delay: 250ms; }
.nhs-card:nth-child(3) { animation-delay: 320ms; }
.nhs-card:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 33, 58, 0.18); }
.nhs-card:focus-visible { outline: 3px solid #ffdd00; outline-offset: 2px; }
.nhs-card:disabled { opacity: 0.55; cursor: default; border-left-color: var(--line-2, #c2ced8); }
.nhs-card-primary:not(:disabled) { border-left-color: var(--nhs-green, #007f3b); }
.nhs-card-title {
  display: block; font-size: 18px; font-weight: 700;
  color: var(--nhs-blue, #005eb8); text-decoration: underline; text-underline-offset: 3px;
}
.nhs-card-primary:not(:disabled) .nhs-card-title { color: var(--nhs-green, #007f3b); }
.nhs-card-text { display: block; margin-top: 4px; font-size: 14px; color: var(--nhs-text, #425563); }

/* How to play is its own panel rather than a block tucked under the option cards. It used to render
   directly below the list, which meant the controls for closing it sat underneath the "What's new"
   card — clicking to dismiss would open the release notes instead. A centred panel over a backdrop
   cannot overlap the menu at all, and matches the other dialogs. */
.main-menu-help {
  position: fixed; inset: 0; z-index: 85; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(0, 33, 58, 0.45);
  animation: menu-fade-in 180ms ease both;
}
.main-menu-help > * { width: 100%; }
.main-menu-help-panel {
  background: #fff; border-radius: 10px; padding: 20px 22px; max-width: 620px;
  max-height: 86vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  animation: menu-rise 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main-menu-help-head {
  display: flex; align-items: center; gap: 16px; margin-bottom: 12px;
  border-bottom: 2px solid var(--nhs-blue, #005eb8); padding-bottom: 10px;
}
.main-menu-help-head h2 { margin: 0; font-size: 20px; color: var(--nhs-dark, #003087); }
.main-menu-help-head .btn { margin-left: auto; }
.main-menu-help ul { margin: 0; padding-left: 20px; }
.main-menu-help li { margin-bottom: 8px; font-size: 14px; line-height: 1.55; color: var(--nhs-text, #425563); }
@keyframes menu-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Credits reuses the same centred-dialog shell as "How to play": a full-screen backdrop with a white
   card inside, so it can never sit under or overlap another menu option. */
.main-menu-credits {
  position: fixed; inset: 0; z-index: 85; display: flex; align-items: center;
  justify-content: center; padding: 20px; background: rgba(0, 33, 58, 0.45);
  animation: menu-fade-in 180ms ease both;
}
.main-menu-credits > * { width: 100%; }
.main-menu-credits-panel {
  background: #fff; border-radius: 10px; padding: 20px 22px; max-width: 560px;
  max-height: 86vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  animation: menu-rise 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main-menu-credits-head {
  display: flex; align-items: center; gap: 16px; margin-bottom: 14px;
  border-bottom: 2px solid var(--nhs-blue, #005eb8); padding-bottom: 10px;
}
.main-menu-credits-head h2 { margin: 0; font-size: 20px; color: var(--nhs-dark, #003087); }
.main-menu-credits-head .btn { margin-left: auto; }

.credits-section { margin-bottom: 16px; }
.credits-section:last-child { margin-bottom: 0; }
.credits-section h3 {
  margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--nhs-text, #425563);
}
.credits-name { margin: 0 0 4px; font-size: 17px; font-weight: 600; color: var(--nhs-dark, #003087); }
.credits-links { margin: 0; font-size: 14px; line-height: 1.7; }
.credits-links a { color: var(--nhs-blue, #005eb8); }
.credits-section p { margin: 0 0 8px; font-size: 14px; line-height: 1.55; color: var(--nhs-text, #425563); }

/* The tester callout is the reason a player opens this panel, so it gets a highlighted box and the
   single obvious call to action. */
.credits-callout {
  background: #eef5fc; border-left: 3px solid var(--nhs-blue, #005eb8);
  border-radius: 0 4px 4px 0; padding: 12px 14px;
}
.credits-callout h3 { color: var(--nhs-blue, #005eb8); }
.credits-cta {
  display: inline-block; background: var(--nhs-blue, #005eb8); color: #fff !important;
  padding: 8px 14px; border-radius: 2px; text-decoration: none; font-weight: 600; font-size: 14px;
}
.credits-cta:hover { background: var(--nhs-dark, #003087); }

/* Submenu reached from "Start a new department" — swaps with the main options in place, so the
   menu never grows taller than the viewport. */
.main-menu-sub {
  background: #fff; border-radius: 2px; padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 33, 58, 0.12);
  animation: menu-rise 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.main-menu-sub h2 { margin: 0 0 14px; font-size: 19px; color: var(--nhs-dark, #003087); }
.main-menu-sub .nhs-card { animation: none; }
.main-menu-back { margin-top: 14px; }

.main-menu-notice {
  margin-top: 22px; border-top: 1px solid #d8dde0; padding-top: 14px;
  font-size: 12.5px; line-height: 1.55; color: var(--nhs-text, #425563);
  animation: menu-rise 460ms 400ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menu-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes menu-mark-in {
  from { opacity: 0; transform: scale(0.82) rotate(-6deg); }
  to { opacity: 1; transform: none; }
}
@keyframes menu-fade-out {
  from { opacity: 1; }
  to { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .main-menu-mark, .main-menu-brand h1, .main-menu-tagline, .nhs-card, .main-menu-notice, .main-menu-help {
    animation: none;
  }
  .nhs-card { transition: none; }
  .nhs-card:hover:not(:disabled) { transform: none; }
}

/* --------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; background: rgba(0, 33, 58, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px; overflow-y: auto; z-index: 60;
}
.patient-modal-content {
  background: var(--paper); border-radius: 10px; max-width: 950px; width: 100%;
  padding: 18px 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.modal-header { display: flex; align-items: flex-start; gap: 14px; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 12px; }
.modal-header h2 { font-size: 19px; color: var(--navy); }
.modal-header .sub { font-size: 12.5px; color: var(--ink-soft); }
.modal-header .btn { margin-left: auto; }
.modal-section { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.modal-section h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); margin-bottom: 6px; }
.modal-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.obs-entry, .inv-entry { border-left: 3px solid var(--line-2); padding: 5px 9px; margin-bottom: 7px; font-size: 12.5px; background: var(--paper-2); border-radius: 0 4px 4px 0; }
.obs-entry .when, .inv-entry .when { font-family: var(--mono); color: var(--ink-faint); font-size: 11.5px; }
.inv-entry.ready { border-left-color: var(--ok); }
.inv-entry.pending { border-left-color: var(--warn); }
.timeline { max-height: 300px; overflow-y: auto; }
.timeline-entry { display: flex; gap: 10px; padding: 3px 0; font-size: 12.5px; border-bottom: 1px dotted var(--line); }
.timeline-entry .t { font-family: var(--mono); color: var(--ink-faint); flex: 0 0 46px; }
.timeline-entry .elapsed { font-family: var(--mono); color: var(--ink-faint); font-size: 11.5px; flex: 0 0 66px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

/* --------------------------------------------------- unreadable save recovery */
.save-recovery {
  background: var(--paper); border-radius: 10px; max-width: 520px; width: 100%;
  margin: auto; padding: 22px 24px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border-top: 4px solid var(--warn);
}
.save-recovery h2 { font-size: 18px; color: var(--navy); margin-bottom: 10px; }
.save-recovery p { font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); margin-bottom: 10px; }
.save-recovery-apology { color: var(--ink); }
.save-recovery-reason {
  font-family: var(--mono); font-size: 12px; background: var(--paper-2);
  border-left: 3px solid var(--warn); border-radius: 0 4px 4px 0; padding: 7px 10px; color: var(--ink-soft);
}
.save-recovery-note { font-size: 12.5px; }
.save-recovery-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.badge-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }

/* ---------------------------------------------------------- shift objectives */
.objective-list { list-style: none; margin: 0; padding: 0; }
.objective {
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 10px; background: #fff;
}
/* The left border carries the verdict, and it is paired with a written status in the dialog, so
   colour is never the only signal. */
.objective-met { border-left-color: var(--ok, #007f3b); }
.objective-missed { border-left-color: var(--warn, #b45309); }
.objective-pending { border-left-color: var(--line); }
.objective-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.objective-status {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.objective-status-met { background: #e6f4ec; color: #00662f; }
.objective-status-missed { background: #fdf0e3; color: #8a4b06; }
.objective-status-pending { background: #eef1f4; color: var(--ink-soft); }
.objective-text { font-size: 14px; color: var(--ink-soft); margin-top: 5px; }
.objective-measure { margin-top: 7px; font-size: 15px; }
.objective-value { font-family: var(--mono); font-weight: 700; font-size: 19px; color: var(--navy); }
.objective-target { font-size: 13px; color: var(--ink-soft); }
.objective-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* -------------------------------------------------------------- handover */
.hand-content { max-height: 88vh; overflow-y: auto; }
.hand-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.hand-text {
  width: 100%; min-height: 240px; margin-bottom: 14px; padding: 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; resize: vertical;
}
.hand-area { margin-top: 18px; }
.hand-area-title {
  font-size: 15px; color: var(--navy); margin: 0 0 8px;
  padding-bottom: 6px; border-bottom: 2px solid var(--nhs-blue, #005eb8);
}
.hand-note { font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.hand-table { font-size: 13px; }
.hand-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.hand-priority { font-family: var(--mono); font-weight: 700; }
.hand-detail { color: var(--ink-soft); }
/* A patient flagged for reassessment is called out on the row, not only by colour — the text flag
   beside it is what a handover is actually read for. */
.hand-row.hand-flag { background: #fdf6ee; }
.hand-flag-text { color: #8a4b06; font-weight: 600; white-space: nowrap; }
.hand-verdict-met { color: #00662f; font-weight: 600; }
.hand-verdict-missed { color: #8a4b06; font-weight: 600; }
.hand-verdict-pending { color: var(--ink-soft); }

/* ------------------------------------------------------------ bedside board */
.board-table { font-size: 13px; }
.board-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.board-table th.sorted { color: var(--nhs-blue, #005eb8); }
/* An affordance rather than a colour-only cue: a small triangle marks the sort direction, and
   aria-sort carries the same information for a screen reader. */
.board-table th.sorted::after { content: attr(data-arrow); margin-left: 5px; font-size: 10px; }
.board-row { cursor: pointer; }
.board-row:focus-visible { outline: 2px solid var(--nhs-blue, #005eb8); outline-offset: -2px; }
/* The three emphasis states are all paired with text elsewhere (the obs column says "overdue", the
   expected-priority label says "expected X"), so colour is never the only signal. */
.board-row.board-critical { background: #fdeeee; }
.board-row.board-reassess { background: #fdf6ee; }
.board-row.board-obs-overdue td:last-child { color: #8a4b06; font-weight: 700; }
.board-mismatch .board-expected {
  display: block; font-size: 11px; color: #8a4b06; font-weight: 600; margin-top: 2px;
}
.board-alert { border-left: 4px solid var(--warn, #a8620f); }
.obs-due-list { display: flex; flex-direction: column; gap: 6px; }
.obs-due-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.obs-due-when { color: #8a4b06; font-weight: 600; margin-left: auto; }

/* ------------------------------------------------------------ staffing dialog */
.staffing-table td { vertical-align: middle; }
.staffing-table .staffing-num { font-family: var(--mono); font-weight: 700; }
.staffing-table .staffing-controls { text-align: right; white-space: nowrap; }
.staffing-table .btn-mini { padding: 3px 12px; font-size: 12.5px; }
.staffing-effect { color: var(--ink-soft); font-size: 12.5px; }
.staffing-note { font-size: 12.5px; color: var(--ink-soft); margin: 4px 0 8px; }
.modal-actions .staffing-note { margin: 0; align-self: center; }

/* ---------------------------------------------------------- departments dialog */
.dept-rows { display: flex; flex-direction: column; gap: 12px; max-height: 300px; overflow-y: auto; }
.dept-row { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--paper-2); }
.dept-row-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.dept-name { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.dept-toggle { cursor: pointer; }
.dept-explain { font-size: 12px; color: var(--ink-soft); flex: 1; margin-top: 2px; }
.dept-capacity { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dept-capacity-num { font-family: var(--mono); font-weight: 700; min-width: 24px; text-align: center; }
.modal-section { 
  border-top: 1px solid var(--line); 
  padding-top: 16px; 
  margin-top: 16px; 
  font-size: 13px; 
  font-weight: 600; 
  color: var(--navy); 
}

/* ------------------------------------------------------------ scenarios dialog */
.scenarios-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.scenario-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--paper); }
.scenario-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.scenario-icon { font-size: 24px; }
/* The icon was a bare emoji; on its own tinted chip it reads as a heading marker and keeps the
   card's left edge aligned across the grid. */
.scenario-icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: 0 0 34px; font-size: 18px; line-height: 1;
  border-radius: 9px; background: var(--paper-2); border: 1px solid var(--line);
}
.scenario-card h3 { font-size: 15px; color: var(--navy); margin: 0; }
.scenario-description { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; }
.scenario-variants { display: flex; flex-direction: column; gap: 6px; }
.scenario-trigger { 
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px;
  width: 100%; padding: 8px 11px; cursor: pointer; text-align: left; color: var(--ink);
  border-left: 3px solid var(--line-2);
  transition: background .12s ease, border-color .12s ease;
  background: var(--paper-2); border: 1px solid var(--line-2);
  border-radius: 6px; font-size: 12.5px;
}
.scenario-trigger:hover { background: var(--paper-3); border-color: var(--line); }
.variant-level { font-weight: 700; color: var(--navy); }
/* The load is what a player actually plans around, so it gets its own right-hand column. */
.variant-load { font-size: 11.5px; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.variant-load strong { font-size: 13px; color: var(--navy); }
.variant-desc { color: var(--ink-soft); grid-column: 1 / -1; font-size: 11.5px; line-height: 1.35; }
/* Severity rides on a coloured edge plus a matching hover tint. It never relies on colour alone —
   the level name and the patient count are still spelled out in the row. */
.scenario-trigger.variant-minor { border-left-color: var(--green); }
.scenario-trigger.variant-major { border-left-color: var(--orange); }
.scenario-trigger.variant-severe { border-left-color: var(--red); }
.scenario-trigger.variant-minor:hover { background: var(--ok-soft); }
.scenario-trigger.variant-major:hover { background: var(--warn-soft); }
.scenario-trigger.variant-severe:hover { background: var(--danger-soft); }
.scenario-trigger:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }
/* The shared `.modal` overlay is top-anchored because the patient record is long and should start
   where the eye already is. The scenario menu is a short, self-contained chooser, so it gets a
   proper centred popup instead: the panel is what scrolls, and the header stays put so the close
   button is always reachable. */
#scenarios-modal { align-items: center; justify-content: center; padding: 24px; }
.scenario-panel {
  display: flex; flex-direction: column;
  width: min(880px, 100%); max-height: min(86vh, 900px);
  background: var(--paper); border-radius: 12px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.scenario-panel .modal-header { flex: 0 0 auto; margin: 0; padding: 16px 20px 12px; background: var(--paper); }
.scenario-panel .modal-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px 20px; }
.scenarios-intro { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 14px; }

.scenario-active { 
  background: var(--warn-soft); border: 1px solid var(--warn); 
  border-radius: 8px; padding: 16px; 
}
.scenario-active-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.scenario-active-info { flex: 1; min-width: 0; }
.scenario-active-info h3 { font-size: 17px; color: var(--navy); margin: 0; }
.scenario-variant { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
/* "Scenario in progress" was plain text that read like a sentence. A pill with a pulsing dot makes
   the running state unmistakable without relying on the colour alone. */
.scenario-live {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--warn); background: var(--paper); border: 1px solid var(--warn);
  padding: 3px 9px; border-radius: 999px;
}
.scenario-live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
@media (prefers-reduced-motion: no-preference) {
  .scenario-live-dot { animation: scenario-pulse 1.6s ease-in-out infinite; }
}
@keyframes scenario-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}
@media (max-width: 720px) {
  .scenarios-list { grid-template-columns: 1fr; }
}
.scenario-status { 
  font-size: 13px; font-weight: 600; color: var(--warn); 
  margin: 12px 0; 
}
.scenario-cancel { margin-top: 8px; }

/* -------------------------------------------------------------- loader */
.loader { text-align: center; padding: 48px; color: var(--ink-soft); }
.loader-hint { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }
.spinner {
  display: inline-block; width: 30px; height: 30px; border: 3px solid var(--line);
  border-top-color: var(--navy); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- notices / shell */
.alert-bar {
  margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 13px;
  border: 1px solid var(--line-2); background: var(--paper-3); color: var(--ink);
}
.alert-bar.error { background: var(--danger-soft); border-color: #efb6b1; color: var(--danger); font-weight: 600; }
.alert-bar.warn { background: var(--warn-soft); border-color: #e8cf9e; color: var(--warn); }
.alert-bar.ok { background: var(--ok-soft); border-color: #b9dcc3; color: var(--ok); }
.filters input[type="search"] {
  padding: 6px 11px; border: 1px solid var(--line-2); border-radius: 999px;
  font-family: inherit; font-size: 12.5px; background: var(--paper); color: var(--ink); min-width: 232px;
}

/* --------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-grid, .workspace-columns, .modal-columns { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock-block { min-width: 0; }
}

/* Bug #3: catch-up progress */
.loader-bar {
  width: min(320px, 70vw);
  height: 8px;
  border-radius: 999px;
  background: var(--line-2);
  overflow: hidden;
  margin: 12px auto 6px;
}
.loader-bar > div,
#loader-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #2ecc71;
  transition: width 0.15s linear;
}
/* Bug #14: the track was white-on-white and therefore invisible, so the bar read as "missing"
   rather than "empty". It also only appeared once catch-up started, leaving the long "Preparing…"
   phase with nothing at all. Before the catch-up begins the exact progress is not yet known, so the
   bar sweeps instead; `runCatchup` drops the class when the width becomes meaningful. */
.loader-bar.indeterminate > div,
.loader-bar.indeterminate #loader-fill {
  width: 35%;
  animation: loader-sweep 1.1s ease-in-out infinite;
}
@keyframes loader-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(285%); }
}
@media (prefers-reduced-motion: reduce) {
  .loader-bar.indeterminate > div,
  .loader-bar.indeterminate #loader-fill { animation: none; width: 100%; opacity: 0.4; }
}
#loader-status {
  font-size: 0.85rem;
  opacity: 0.85;
}
