:root {
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  --display-font: Georgia, serif;
  --ink: #102a35;
  --muted: #4b6269;
  --border: #cddbd8;
  --line: #e2eae7;
  --bg: #f1f5f2;
  --surface: #fff;
  --subtle: #f6f9f7;
  --navy: #102a35;
  --navy-line: #39525a;
  --on-navy: #c8d8d8;
  --mint: #a9dfcd;
  --teal: #075e51;
  --teal-dark: #06483e;
  --teal-light: #e5f3ed;
  --teal-line: #b4d7ca;
  --teal-strong: #087361;
  --red: #9c3634;
  --red-light: #faeeec;
  --red-line: #ecd1ce;
  --amber: #7b4d16;
  --amber-light: #f9f0dd;
  --amber-line: #e8d6ad;
  --radius: 6px;
  --shell-inset: clamp(20px, 3.334vw, 52px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 2px solid var(--teal-strong); outline-offset: 3px; }
::selection { color: var(--navy); background: var(--mint); }
svg { display: block; flex: none; width: 18px; height: 18px; }
h1, h2, h3, p, ul, ol { margin: 0; }
h1, h2 { text-wrap: balance; }
.wrap { width: min(100% - 2 * var(--shell-inset), 1500px); margin-inline: auto; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.skip {
  position: fixed;
  inset: 8px auto auto 8px;
  transform: translateY(-160%);
  z-index: 5;
  padding: 8px 14px;
  color: var(--ink);
  background: var(--surface);
}
.skip:focus { transform: none; }

.masthead { color: #fff; background: var(--navy); }
.masthead-inner, .masthead-right, .brand {
  display: flex;
  align-items: center;
}
.masthead-inner { min-height: 67px; gap: 22px; }
.brand { gap: 10px; }
.logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--mint);
  border-radius: var(--radius);
  color: var(--mint);
}
.logo svg { width: 24px; height: 24px; stroke-width: 1.4; }
.brand strong, .brand span, .clock span, .clock strong { display: block; white-space: nowrap; }
.brand strong { font: 700 21px/1 var(--display-font); letter-spacing: -.04em; }
.brand span { margin-top: 4px; color: var(--on-navy); font-size: 10px; letter-spacing: .035em; }
.department { border-left: 1px solid var(--navy-line); padding-left: 22px; color: #fff; font-size: 17px; font-weight: 650; white-space: nowrap; }
.masthead-right { margin-left: auto; gap: 20px; }
.demo-label {
  border: 1px solid var(--navy-line);
  border-radius: 3px;
  padding: 5px 8px;
  color: var(--mint);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.clock { border-left: 1px solid var(--navy-line); padding-left: 20px; }
.clock span { color: var(--on-navy); font-size: 11px; }
.clock strong { color: #fff; font-size: 17px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.safety { border-bottom: 1px solid var(--teal-line); color: var(--teal-dark); background: var(--teal-light); }
.safety-inner {
  display: flex;
  min-height: 37px;
  align-items: center;
  gap: 8px;
  padding-block: 7px;
  font-size: 13px;
  line-height: 1.3;
}
.safety svg { width: 16px; height: 16px; }
.safety strong { font-weight: 650; }
.content { padding-block: 16px 22px; }
.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.page-actions { display: flex; flex: none; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:hover:not(:disabled) { border-color: var(--teal-strong); background: var(--subtle); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { border-color: var(--teal); color: #fff; background: var(--teal); }
.btn.primary:hover:not(:disabled) { background: var(--teal-dark); }
.surge-button svg { color: var(--teal); }
.switch-ui {
  display: flex;
  width: 30px;
  height: 16px;
  margin-left: 2px;
  align-items: center;
  padding: 2px;
  border-radius: 10px;
  background: #657b80;
}
.switch-ui::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 140ms ease-out;
}
.surge-button[aria-checked=true] { border-color: var(--teal-strong); background: var(--teal-light); }
.surge-button[aria-checked=true] .switch-ui { background: var(--teal); }
.surge-button[aria-checked=true] .switch-ui::after { transform: translateX(14px); }
.surge-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  color: var(--teal-dark);
  background: var(--teal-light);
  font-size: 13px;
  line-height: 1.3;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: start;
}
.metric { min-width: 0; padding: 0 24px; border-inline-start: 1px solid var(--border); }
.metric:first-child { border-inline-start: 0; padding-inline-start: 0; }
.metric h2 { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-value {
  display: inline;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.metric-value small { margin-inline-start: 2px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0; }
.metric p { display: inline; margin-inline-start: 6px; color: var(--muted); font-size: 12px; line-height: 1.28; }
.metric.red .metric-value { color: var(--red); }
.metric.amber .metric-value { color: var(--amber); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 355px);
  gap: 20px;
  align-items: start;
}
.panel { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel-heading { padding: 19px 20px 13px; }
.queue-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel h2 { font-size: 21px; font-weight: 650; line-height: 1.2; letter-spacing: -.035em; }
.panel-heading p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.model-state { display: inline-flex; flex: none; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.model-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.model-state.available { color: var(--teal); }
.model-state.offline, .model-state.web { color: var(--amber); }
.queue-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 20px 12px;
}
.filters { display: flex; flex: none; gap: 5px; }
.filters button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.filters button:hover { background: var(--subtle); }
.filters button[aria-pressed=true] { border-color: var(--teal-line); color: var(--teal-dark); background: var(--teal-light); }
.filters button span { color: var(--teal); font-size: 12px; font-variant-numeric: tabular-nums; }
.search {
  display: flex;
  width: 214px;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding-inline: 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.search:focus-within { outline: 2px solid var(--teal-strong); outline-offset: 1px; }
.search svg { width: 16px; height: 16px; }
.search input {
  width: 100%;
  min-height: 42px;
  padding: 6px 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 14px;
}
.search input::placeholder { color: var(--muted); }
.table-scroll {
  max-height: min(625px, max(430px, calc(100dvh - 412px)));
  overflow: auto;
  scroll-padding-top: 36px;
  scrollbar-color: #8ca39d var(--subtle);
}
.table-scroll:focus-visible { outline-offset: -3px; }
.queue-table { width: 100%; min-width: 590px; border-spacing: 0; text-align: left; }
.queue-table th, .queue-table td { padding: 6px 12px; }
.queue-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  border-block: 1px solid var(--line);
  color: var(--muted);
  background: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.queue-table th:first-child, .queue-table td:first-child { width: 8%; padding-left: 20px; }
.queue-table th:nth-child(2), .queue-table td:nth-child(2) { width: 26%; }
.queue-table th:nth-child(5), .queue-table td:nth-child(5) { white-space: nowrap; }
.queue-table td {
  height: 48px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
.queue-table tbody tr:last-child td { border-bottom: 0; }
.queue-table tr[data-patient] { cursor: pointer; }
.queue-table tr[data-patient]:hover { background: var(--subtle); }
.queue-table .immediate-row { background: var(--red-light); }
.queue-table tr.immediate-row:hover { background: #f8e4e1; }
.queue-table tr.is-selected, .queue-table tr.is-selected:hover, .queue-table tr:focus-within { background: var(--teal-light); }
.queue-table tr:has(.patient-button:focus-visible) { outline: 2px solid var(--teal-strong); outline-offset: -2px; }
.rank { color: var(--ink); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.immediate-row .rank { color: var(--red); }
.patient-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}
.queue-table td:nth-child(2) { position: relative; }
.patient-button::after { position: absolute; inset: 0; content: ""; }
.patient-button:hover, .is-selected .patient-button { color: var(--teal-dark); text-decoration: underline; text-underline-offset: 3px; }
.row-meta, .mobile-complaint {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}
.row-meta { white-space: nowrap; font-variant-numeric: tabular-nums; }
.edit-mark { color: var(--teal); }
.edit-mark svg { width: 13px; height: 13px; }
.complaint-col { min-width: 105px; }
.mobile-complaint { display: none; }
.acuity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.acuity strong {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 3px;
  color: #fff;
  background: var(--esi);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
/* ponytail: common ED tracking-board ESI colours (1 red, 2 orange, 3 yellow, 4 green, 5 blue) */
.acuity-1 { --esi: #b3261e; }
.acuity-2 { --esi: #b4491a; }
.acuity-3 { --esi: #e7b416; }
.acuity-3 strong { color: var(--ink); }
.acuity-4 { --esi: #2e7d4f; }
.acuity-5 { --esi: #2f6aa3; }
.wait { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.wait-unit { color: var(--muted); font-size: 11px; }
.long-wait { color: var(--amber); }
.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.flag svg { width: 14px; height: 14px; }
.flag.high { color: var(--red); }
.row-arrow { width: 32px; color: var(--muted); }
.row-arrow svg { width: 15px; height: 15px; }
.is-selected .row-arrow { color: var(--teal-dark); }
.muted { color: var(--muted); }
.empty-table { padding: 33px 15px; color: var(--muted); text-align: center; }
.panel-footer { padding: 11px 20px; border-top: 1px solid var(--line); color: var(--muted); background: var(--subtle); font-size: 12px; }

.monitoring { display: grid; gap: 13px; }
.aside-heading { padding-bottom: 10px; }
.fairness-body { padding: 0 20px 15px; }
.fairness-filters { justify-content: flex-start; }
.fairness-window { margin-block: 5px 12px; color: var(--muted); font-size: 12px; }
.equity-alert {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 9px 10px;
  margin-bottom: 12px;
  border: 1px solid;
  border-radius: var(--radius);
  line-height: 1.28;
}
.equity-alert.has-gap { color: var(--red); background: var(--red-light); border-color: var(--red-line); }
.equity-alert.has-watch { color: var(--amber); background: var(--amber-light); border-color: var(--amber-line); }
.equity-alert.within-gap { color: var(--teal-dark); background: var(--teal-light); border-color: var(--teal-line); }
.equity-alert svg { width: 17px; height: 17px; }
.equity-alert strong, .equity-alert span { display: block; }
.equity-alert strong { font-size: 13px; }
.equity-alert span { margin-top: 2px; font-size: 11px; }
.group-table { width: 100%; border-spacing: 0; text-align: left; font-variant-numeric: tabular-nums; }
.group-table th, .group-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.group-table thead th { padding-block: 4px; color: var(--muted); font-size: 11px; font-weight: 650; }
.group-table th:nth-child(n+2), .group-table td { padding-left: 8px; text-align: right; white-space: nowrap; }
.group-table tbody th, .group-table td { font-size: 13px; }
.group-table tbody th { width: 53%; font-weight: 650; }
.group-table tbody th div { display: flex; align-items: baseline; gap: 5px; }
.group-table small { color: var(--muted); font-size: 10px; font-weight: 500; }
.group-table progress {
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  margin-top: 4px;
  border: 0;
  color: var(--teal-strong);
  background: var(--line);
}
.group-table progress.gap { color: var(--red); }
.group-table progress.watch { color: var(--amber); }
.group-table progress::-webkit-progress-bar { background: var(--line); }
.group-table progress::-webkit-progress-value { background: currentColor; }
.group-table progress::-moz-progress-bar { background: currentColor; }
.baseline { color: var(--muted); font-size: 11px; }
.gap-value { color: var(--teal-dark); font-size: 12px; }
.gap-value.gap-red { color: var(--red); }
.gap-value.gap-amber { color: var(--amber); }
.fairness-note { display: flex; gap: 6px; padding-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.fairness-note svg { width: 14px; height: 14px; margin-top: 1px; color: var(--teal); }
.override-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0 10px;
  margin: 0 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.override-summary div { display: flex; align-items: baseline; gap: 6px; }
.override-summary strong { color: var(--ink); font-size: 26px; line-height: 1; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.override-summary strong small { margin-inline-start: 2px; font-size: 14px; letter-spacing: 0; }
.override-summary p { text-align: right; }
.empty-audit { display: flex; align-items: center; gap: 7px; margin: 11px 20px 2px; color: var(--muted); font-size: 12px; }
.empty-audit svg { width: 14px; height: 14px; }
.text-btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  color: var(--teal);
  background: none;
  font-size: 13px;
  font-weight: 700;
}
.text-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.text-btn svg { width: 14px; height: 14px; }
.audit-link { margin-inline: 20px; }
.audit-list { padding: 0 20px; list-style: none; }
.audit-entry { padding-block: 10px; border-bottom: 1px solid var(--line); }
.audit-entry-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-entry-head strong { font-size: 14px; }
.audit-entry-head span { display: flex; align-items: center; gap: 4px; color: var(--teal); font-size: 12px; font-weight: 700; }
.audit-entry-head svg { width: 14px; height: 14px; }
.audit-entry p { margin-block: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.audit-entry time { color: var(--muted); font-size: 11px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; color: var(--muted); font-size: 12px; }

dialog {
  border: 1px solid var(--border);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 12px 54px #102a3535;
}
dialog::backdrop { background: #102a3550; }
.detail-dialog {
  --detail-inset: 27px;
  width: min(100%, 560px);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  padding: 0;
  border-block: 0;
  border-right: 0;
}
.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.detail-dialog .dialog-header {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 22px var(--detail-inset) 20px;
  border-bottom: 1px solid var(--border);
  background: var(--subtle);
}
.dialog-header h2 { font: 400 35px/1.08 var(--display-font); letter-spacing: -.04em; }
.dialog-header p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.dialog-header .record-id { margin: 0 0 5px; color: var(--teal); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.record-id span { color: var(--muted); font-weight: 500; }
.icon-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}
.icon-btn:hover { border-color: var(--teal-strong); background: var(--teal-light); }
.detail-body { display: grid; gap: 18px; padding: 18px var(--detail-inset) 25px; }
.detail-summary { display: grid; grid-template-columns: 1.35fr 1fr .58fr; gap: 8px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.detail-summary > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.detail-summary > div > span:first-child, .detail-section-head span, .coverage-detail span { color: var(--muted); font-size: 12px; }
.detail-summary strong { font-size: 15px; }
.detail-summary small { color: var(--muted); font-size: 12px; }
.detail-summary .acuity strong { width: 22px; height: 22px; font-size: 12px; }
.detail-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.detail-body h3 { font-size: 16px; font-weight: 700; letter-spacing: -.016em; }
.vital-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.detail-vital {
  position: relative;
  display: grid;
  align-content: end;
  min-width: 0;
  min-height: 80px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--subtle);
}
.detail-vital > span:first-child { align-self: start; }
.detail-vital span, .detail-vital small { color: var(--muted); font-size: 11px; line-height: 1.15; }
.detail-vital strong { margin-block: 4px 2px; font-size: 17px; line-height: 1; letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vital-cue { border-color: var(--red-line); background: var(--red-light); }
.vital-cue strong, .vital-cue .vital-signal { color: var(--red); }
.vital-signal { position: absolute; right: 5px; bottom: 5px; }
.vital-signal svg { width: 12px; height: 12px; }
.rationale { padding: 13px 15px; border: 1px solid var(--teal-line); border-radius: var(--radius); background: var(--teal-light); }
.rationale-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rationale-head p { margin-top: 2px; color: var(--teal-dark); font-size: 12px; }
.rationale-head p.is-model { font-weight: 650; }
.recommendation-position { color: var(--teal-dark); font-size: 33px; font-weight: 600; line-height: 1; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
#rationale-text { margin-block: 9px; color: var(--ink); font-size: 15px; line-height: 1.45; }
.reason-facts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0; list-style: none; }
.reason-facts li { padding: 3px 5px; border: 1px solid var(--teal-line); border-radius: 3px; color: var(--teal-dark); background: var(--subtle); font-size: 11px; }
.rank-method { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.lwbs-detail, .pathway-detail { padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--subtle); }
.lwbs-detail { display: flex; gap: 8px; border-color: var(--amber-line); color: var(--amber); background: var(--amber-light); }
.lwbs-detail p, .pathway-detail p, .recent-override { padding-top: 3px; font-size: 13px; line-height: 1.35; }
.pathway-detail p { color: var(--muted); }
.recent-override { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--teal); overflow-wrap: anywhere; }
.recent-override svg { width: 14px; height: 14px; }
.move-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.move-controls .btn { padding-inline: 9px; font-size: 13px; }
.coverage-detail { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.coverage-detail strong { font-size: 13px; }
.form-dialog {
  width: min(100% - 24px, 560px);
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border-radius: var(--radius);
}
.dialog-intro { margin-block: 12px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.form-grid, .vital-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid label, .vital-form label, #override-form label { display: block; font-size: 13px; font-weight: 700; }
.form-grid label small, .vital-form label small { color: var(--muted); }
.form-dialog input, .form-dialog select, #override-form select, #override-form textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  font-size: 16px;
}
#override-form { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
#override-note-label { margin-top: 9px; }
#override-form textarea { resize: vertical; }
.form-dialog fieldset { padding: 8px 10px 10px; margin: 14px 0 0; border: 1px solid var(--border); border-radius: var(--radius); }
.form-dialog legend { font-size: 13px; font-weight: 700; }
.vital-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; }
.form-error { margin-top: 6px; color: var(--red); font-size: 13px; }
#audit-history .audit-list { padding: 8px 0 0; }
.toast {
  position: fixed;
  z-index: 3;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: min(410px, calc(100vw - 36px));
  padding: 10px 13px;
  border-radius: var(--radius);
  color: var(--surface);
  background: var(--navy);
  font-size: 14px;
}
.toast svg { width: 16px; height: 16px; color: var(--mint); }

@media (max-width: 1160px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 310px; gap: 13px; }
  .queue-table { min-width: 0; }
  .queue-table th, .queue-table td { padding-inline: 7px; }
  .queue-table th:first-child, .queue-table td:first-child { padding-left: 14px; }
  .row-arrival { display: none; }
  .acuity { gap: 3px; padding-inline: 4px; }
}

@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .monitoring { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .table-scroll { max-height: 510px; }
  .row-arrival { display: inline; }
}

@media (max-width: 620px) {
  :root { --shell-inset: 14px; }
  .masthead-inner { min-height: 59px; gap: 8px; }
  .masthead-right { gap: 8px; }
  .brand { gap: 7px; }
  .brand strong { font-size: 18px; }
  .brand span { font-size: 8px; }
  .logo { width: 31px; height: 31px; }
  .logo svg { width: 21px; height: 21px; }
  .department { display: none; }
  .clock { padding-left: 8px; }
  .clock span, .demo-label { font-size: 9px; }
  .clock strong { font-size: 14px; }
  .demo-label { padding-inline: 5px; }
  .safety-inner { font-size: 12px; }
  .content { padding-top: 20px; }
  .page-top { display: block; margin-bottom: 12px; }
  .page-actions { margin-top: 12px; }
  .page-actions .btn { flex: 1; padding-inline: 7px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 6px 9px 6px 13px; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--border); }
  .metric:nth-child(odd) { padding-left: 0; border-inline-start: 0; }
  .metric h2 { font-size: 12px; }
  .metric-value { font-size: 20px; }
  .metric p { display: block; margin-inline-start: 0; }
  .metric-value small, .metric p { font-size: 11px; }
  .panel-heading { padding: 13px 12px 10px; }
  .panel h2 { font-size: 19px; }
  .model-state { font-size: 11px; }
  .queue-toolbar { gap: 5px; padding: 0 9px 8px; }
  .filters { gap: 0; }
  .filters button { gap: 4px; padding-inline: 6px; font-size: 12px; }
  .filters button span { font-size: 11px; }
  .search { flex: 1; padding-inline: 7px; }
  .search input { font-size: 16px; }
  .search input::placeholder { font-size: 12px; }
  .queue-table th, .queue-table td { padding-inline: 5px; }
  .queue-table th:first-child, .queue-table td:first-child { padding-left: 8px; }
  .queue-table th:nth-child(2), .queue-table td:nth-child(2) { width: auto; }
  .queue-table th:nth-child(3), .queue-table th:last-child, .complaint-col, .row-arrow { display: none; }
  .queue-table th:nth-child(6) { padding-right: 8px; }
  .queue-table th { font-size: 10px; }
  .queue-table td { height: 52px; }
  .queue-table .rank { font-size: 12px; }
  .patient-button { font-size: 14px; }
  .queue-table .acuity { padding: 3px; }
  .queue-table .acuity span, .queue-table .flag span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
  .queue-table .wait { font-size: 13px; }
  .queue-table .row-meta { font-size: 10px; }
  .row-arrival { display: none; }
  .mobile-complaint { display: block; color: var(--ink); }
  .panel-footer { padding-inline: 12px; }
  .table-scroll { max-height: 390px; }
  .monitoring { grid-template-columns: minmax(0, 1fr); }
  .fairness-body { padding-inline: 12px; }
  .override-summary, .empty-audit, .audit-link { margin-inline: 12px; }
  .audit-list { padding-inline: 12px; }
  .page-footer { font-size: 10px; }
  .detail-dialog { --detail-inset: 14px; border: 0; }
  .detail-dialog .dialog-header { padding-block: 13px; }
  .dialog-header h2 { font-size: 30px; }
  .detail-body { gap: 14px; padding-block: 13px 18px; }
  .detail-summary { grid-template-columns: 1fr 1fr auto; padding-bottom: 12px; }
  .detail-vital { padding-inline: 4px; }
  .detail-vital span, .detail-vital small { font-size: 10px; }
  .detail-vital strong { font-size: 15px; }
  .vital-grid { gap: 4px; }
  .form-dialog { padding: 14px; }
}

@media (max-width: 360px) {
  :root { --shell-inset: 10px; }
  .queue-toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  .row-age { display: none; }
  .vital-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}

.top-toggle {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--navy-line);
  border-radius: 3px;
  color: var(--on-navy);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.top-toggle:hover { border-color: var(--mint); color: #fff; }
.top-toggle:focus-visible, .link-button:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.link-button {
  margin-inline-start: 10px;
  padding: 0;
  border: 0;
  color: var(--teal);
  background: none;
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
@media (max-width: 620px) {
  .top-toggle { min-height: 28px; padding: 3px 6px; font-size: 10px; }
  .demo-label { display: none; }
}

:root[data-theme=dark] {
  color-scheme: dark;
  --ink: #e4eeeb;
  --muted: #a3b8b4;
  --border: #2e4650;
  --line: #24393f;
  --bg: #0b1c22;
  --surface: #12262d;
  --subtle: #172e35;
  --navy: #06141a;
  --navy-line: #2a434b;
  --teal: #4fc2a6;
  --teal-dark: #7fd6bf;
  --teal-light: #173a36;
  --teal-line: #285a50;
  --teal-strong: #4fc2a6;
  --red: #ff8f86;
  --red-light: #3a1d1d;
  --red-line: #5c2c2a;
  --amber: #f0c27a;
  --amber-light: #33291a;
  --amber-line: #5a4626;
}
:root[data-theme=dark] .btn.primary { border-color: #0e7a68; background: #0e7a68; }
:root[data-theme=dark] .btn.primary:hover:not(:disabled) { background: #0b6657; }
:root[data-theme=dark] .queue-table tr.immediate-row:hover { background: #432222; }
:root[data-theme=dark] .acuity-3 strong { color: #102a35; }
