/* Clinical ward UI. Red is reserved for Urgent. */
@font-face {
  font-family: Poppins;
  src: url("/static/vendor/fonts/poppins-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Poppins;
  src: url("/static/vendor/fonts/poppins-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/static/vendor/fonts/source-sans-3-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/static/vendor/fonts/source-sans-3-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
:root {
  --bg: #ffffff;
  --surface: #f5f9fb;
  --line: #dce7ee;
  --ink: #1e2350;
  --ink-2: #5b6385;
  --brand: #434c9c;
  --brand-soft: #d6e8ef;
  --tier-0: #5b6385;
  --tier-1: #b7791f;
  --tier-2: #c2560c;
  --tier-3: #c62828;
  --paper: var(--bg);
  --paper-deep: var(--brand-soft);
  --panel: var(--surface);
  --ink-soft: var(--ink-2);
  --muted: var(--ink-2);
  --line-strong: #c5d5e0;
  --teal: var(--brand);
  --teal-deep: #32387a;
  --sage: var(--tier-0);
  --gold: var(--tier-1);
  --orange: var(--tier-2);
  --red: var(--tier-3);
  --effort: #434c9c;
  --airflow: #2f6f8f;
  --pulse: #7a4e6a;
  --display: Poppins, "Source Sans 3", sans-serif;
  --sans: "Source Sans 3", sans-serif;
  --serif: var(--display);
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font: 17px/1.45 var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 2rem; line-height: 1.1; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 10px; }
.fine { color: var(--muted); font-size: 0.84rem; margin: 4px 0 0; }
.eyebrow {
  margin: 0;
  font-size: 0.84rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
  font-weight: 600;
}

.skip {
  position: absolute; left: -999px; top: 8px;
  background: white; padding: 6px 10px; z-index: 5;
}
.skip:focus { left: 12px; }

.wrap { width: min(1200px, calc(100% - 32px)); margin: 0 auto 32px; }
.top {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 14px;
  display: flex;
  align-items: center;
  gap: 18px 22px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a, .quiet, .primary, .demo-btn {
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  padding: 6px 12px;
}
.nav a[aria-current="page"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.session { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.session__who { font-weight: 600; font-size: 0.95rem; }
.session__role { font-weight: 400; color: var(--ink-2); }
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  line-height: 1;
}
.chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 8px; background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft); font-size: 0.78rem;
}
.primary { background: var(--brand); color: #fff; border-color: var(--brand); padding: 8px 14px; }
.primary:disabled, .quiet:disabled { opacity: 0.45; cursor: not-allowed; }
.quiet { padding: 8px 12px; background: var(--panel); }

.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin: 6px 0 14px; }
.lede { margin: 6px 0 0; color: var(--ink-soft); }

.ward-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin: 8px 0 16px; }
.shift-stat { text-align: right; }
.shift-stat__nums { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.shift-stat__nums span { font-family: var(--sans); font-weight: 400; color: var(--ink-2); font-size: 0.95rem; }
#shift-rates { margin: 2px 0 0; }
.tier-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tier-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-weight: 600;
}
.tier-chip b { font-family: var(--display); font-weight: 600; }
.tier-chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tier-0); }
.tier-chip[data-tier="1"] .tier-chip__dot { background: var(--tier-1); }
.tier-chip[data-tier="2"] .tier-chip__dot { background: var(--tier-2); }
.tier-chip[data-tier="3"] { border-color: var(--tier-3); color: var(--tier-3); }
.tier-chip[data-tier="3"] .tier-chip__dot { background: var(--tier-3); }
.tier-chip[data-tier="0"] { color: var(--ink-2); }
.tier-chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); }

.board { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.census, .census-head {
  display: grid;
  grid-template-columns: 4.5rem minmax(14rem, 1.8fr) 10rem 5rem 6.5rem 8rem;
  column-gap: 16px;
  align-items: center;
}
.census-head {
  padding: 10px 16px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 0.84rem;
  font-weight: 600;
}
.census-head span:nth-child(3),
.census-head span:nth-child(4) { text-align: right; }
.census {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.census:hover { background: var(--surface); }
.census[data-tier="0"] { box-shadow: inset 4px 0 0 var(--tier-0); }
.census[data-tier="1"] { box-shadow: inset 4px 0 0 var(--tier-1); }
.census[data-tier="2"] { box-shadow: inset 4px 0 0 var(--tier-2); }
.census[data-tier="3"] { box-shadow: inset 4px 0 0 var(--tier-3); }
.census__bed { display: flex; flex-direction: column; gap: 2px; }
.census__bed span { color: var(--ink-2); font-size: 0.78rem; }
.census__bed b { font-family: var(--display); font-size: 1.45rem; font-weight: 600; line-height: 1; }
.census__name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.census__who { min-width: 0; }
.census__reason { display: block; color: var(--ink-2); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.census__stat { text-align: right; white-space: nowrap; }
.census__stat b { font-family: var(--display); font-size: 1.25rem; font-weight: 600; }
.census__stat small, .vital dd small { color: var(--ink-2); font-weight: 500; font-size: 0.78rem; }
.rate-note { font-family: var(--sans); font-size: 0.92rem; font-weight: 600; }
.trend-arrow { color: var(--ink-2); font-size: 0.9rem; }
.sig-warn {
  display: inline-flex; width: 1.05rem; height: 1.05rem; margin-left: 4px;
  align-items: center; justify-content: center; border-radius: 50%;
  background: var(--tier-1); color: #fff; font-size: 0.72rem; font-weight: 700;
}
.tag {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 1px 8px; background: var(--surface); color: var(--ink-2);
  font-size: 0.75rem; font-weight: 600;
}
.tag-live { background: var(--brand-soft); color: var(--brand); }
.census__tier { display: flex; flex-direction: column; align-items: flex-start; font-weight: 600; }
.census[data-tier="0"] .census__tier { color: var(--tier-0); }
.census[data-tier="1"] .census__tier { color: var(--tier-1); }
.census[data-tier="2"] .census__tier { color: var(--tier-2); }
.census[data-tier="3"] .census__tier { color: var(--tier-3); }
.census[data-tier="3"] .census__tier > span:first-child { animation: urgent-pulse 1.6s ease-in-out infinite; }
.census__tier small { font-weight: 500; color: var(--ink-2); min-height: 1.1em; }
.q-clean { color: var(--sage); }
.q-motion { color: var(--gold); }
.q-sensor_off, .q-unknown { color: var(--ink-soft); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel h2 small { font-family: var(--sans); color: var(--muted); font-size: 0.8rem; font-weight: 500; margin-left: 6px; }

.detail {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 12px;
}
.span { grid-column: 1 / -1; }
.patient-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 8px; }
.crumbs { margin: 0 0 8px; }
.crumbs a { text-decoration: none; }
.tier-flag { margin: 0; font-family: var(--serif); font-size: 1.8rem; line-height: 1; }
.tier-flag[data-tier="0"] { color: var(--sage); }
.tier-flag[data-tier="1"] { color: var(--gold); }
.tier-flag[data-tier="2"] { color: var(--orange); }
.tier-flag[data-tier="3"] { color: var(--red); }
.reason { margin: 0 0 8px; color: var(--ink-soft); }
.risk { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.risk .fine { flex-basis: 100%; }

.tile { border-left: 6px solid var(--sage); }
.tile[data-tier="1"] { border-left-color: var(--gold); }
.tile[data-tier="2"] { border-left-color: var(--orange); }
.tile[data-tier="3"] { border-left-color: var(--red); }
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.vital dt { color: var(--muted); font-size: 0.78rem; }
.vital dd { margin: 0; font-size: 1.85rem; font-weight: 600; line-height: 1.1; }
.badge, .ev {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font-size: 0.82rem;
}
.ev-obstructive { color: var(--teal-deep); }
.ev-central { color: var(--ink); }
.ev-mixed { color: var(--orange); }
.ev-hypopnea { color: var(--gold); }

.wave { margin-top: 8px; }
.wave__label { display: block; font-size: 0.75rem; color: var(--muted); }
.wave__plot, .trend { position: relative; }
.wave__plot { height: 92px; }
.trend { height: 220px; }
.link-note {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--ink);
  background: #fff;
}

.events, .alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.events li, .alert {
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline;
  padding-top: 8px; border-top: 1px solid var(--line);
}
.alert { display: block; }
.alert__top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.alert[data-status="awaiting_ack"] { background: #fff; box-shadow: inset 3px 0 0 var(--muted); }
.alert[data-status="awaiting_ack"] .awaiting { color: var(--ink); font-weight: 600; }
.alert[data-tier="3"] .pill { color: var(--red); }
.alert[data-tier="2"] .pill { color: var(--orange); }
.alert[data-tier="1"] .pill { color: var(--gold); }
.alert[data-tier="0"] .pill { color: var(--sage); }
.pill { font-weight: 700; font-size: 0.82rem; letter-spacing: 0; text-transform: none; }
.escalated { color: var(--red); font-weight: 600; margin: 4px 0; }
.ack { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ack input { flex: 1; min-width: 12rem; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare .big { font-family: var(--serif); font-size: 2rem; margin: 2px 0; line-height: 1; }

.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.summary-text { font-family: var(--serif); font-size: 1.08rem; line-height: 1.45; white-space: pre-wrap; max-width: 68ch; }
.sbar { display: grid; gap: 8px; margin-top: 10px; }
.sbar div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.sbar h3 { margin: 0 0 4px; font-family: var(--display); font-size: 0.95rem; font-weight: 600; letter-spacing: 0; text-transform: capitalize; color: var(--ink); }
.gemini { margin: 8px 0 0; font-size: 0.75rem; color: var(--ink-2); }
.model-line { margin: 8px 0 0; color: var(--ink-soft); font-size: 0.92rem; }
.calibrate { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.public-demo-banner {
  position: sticky; top: 0; z-index: 6;
  background: var(--brand-soft);
  color: var(--ink);
  text-align: center;
  padding: 8px 16px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}
.chart-img { display: block; width: min(720px, 100%); height: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }

.notice {
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--teal-deep);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}
form .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
label { display: grid; gap: 4px; font-size: 0.92rem; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 12px 0 0; padding: 8px 12px 12px; }
legend { padding: 0 6px; font-family: var(--serif); }
input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
.check input, .ack input { width: auto; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.stack { display: grid; gap: 12px; }
.ports { margin: 0; padding-left: 18px; }
.ports li { margin: 4px 0; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 8px 0 0; }
.statgrid div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.statgrid b { display: block; font-size: 1.15rem; }
.labels { display: flex; flex-wrap: wrap; gap: 8px; }
.labels button[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }

.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px 28px;
  background: var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 50px rgba(28, 36, 33, 0.06);
}
body.login.has-public-demo { justify-content: flex-start; padding-top: 0; }
body.login.has-public-demo .login-card { margin: auto; }
.login-card h1 { font-size: 2.2rem; }
.welcome-card { width: min(32rem, 100%); }
.welcome-copy { margin: 14px 0 16px; display: grid; gap: 8px; }
.welcome-copy p { margin: 0; }
.demo-grid { display: grid; gap: 8px; margin: 12px 0; }
.demo-btn { text-align: left; padding: 10px 12px; background: #fff; display: grid; }
.demo-btn small { color: var(--muted); }
.login-card form { margin-top: 8px; }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 16px 28px;
}
.empty { color: var(--ink-2); }

@keyframes urgent-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; row-gap: 8px; }
  .ward-head, .shift-stat { text-align: left; align-items: start; }
  .ward-head { flex-direction: column; }
  .census-head { display: none; }
  .census {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .census__stat { text-align: left; }
  .census__reason { white-space: normal; }
  .alert { flex-wrap: wrap; }
  .alert .ack { margin-left: 0; }
  .clinical-row, form .fields { grid-template-columns: 1fr; }
  .vital-strip .vitals { grid-template-columns: 1fr 1fr; }
  .patient-head { align-items: start; }
  .wave__plot { height: 72px; }
}

.patient-stack { display: flex; flex-direction: column; gap: 16px; }
body[data-role="physician"] #note-panel { order: -1; }
.bed-kicker { margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.vital-strip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.vital-strip .vitals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.vital-strip .vital dd { font-family: var(--display); font-size: 1.7rem; font-weight: 600; margin: 0; line-height: 1.1; }
.vital-strip .vital dt { color: var(--ink-2); font-size: 0.84rem; }
.fold {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.fold > summary { cursor: pointer; font-weight: 600; }
.clinical-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 20px;
  border-top: 1px solid var(--line);
  border-left: 4px solid var(--line);
}
.alert[data-tier="1"] { border-left-color: var(--tier-1); }
.alert[data-tier="2"] { border-left-color: var(--tier-2); }
.alert[data-tier="3"] { border-left-color: var(--tier-3); }
.alert[data-status="awaiting_ack"] { color: var(--ink-2); }
.alert__reason { flex: 1; min-width: 0; }
.alert .ack { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.alert .ack input { width: 12rem; }
.alert-group { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 0; }
.alert-group h3, h3.alert-group { margin: 12px 0 0; font-size: 0.95rem; }
.esc-tag { color: var(--tier-3); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.history { margin-top: 12px; }
.event-table { width: 100%; border-collapse: collapse; }
.event-table th { text-align: left; color: var(--ink-2); font-size: 0.84rem; font-weight: 600; padding: 4px 8px 4px 0; }
.event-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); }
.event-table th:nth-child(2), .event-table td:nth-child(2),
.event-table th:nth-child(4), .event-table td:nth-child(4) { text-align: right; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff;
}
.toggle input { accent-color: var(--brand); }
.toggle:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.choice { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.choice input, .check input { accent-color: var(--brand); }
form:has(input[name="kind"][value="live"]:checked) .sim-only { display: none; }
.advanced { margin-top: 12px; }
#new-form { max-width: 32rem; display: grid; gap: 12px; }
#new-form .form-actions { display: flex; gap: 8px; align-items: center; }
#new-form .form-actions .quiet { text-decoration: none; }
.status-line { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-2); flex: 0 0 auto; }
.status-dot[data-ok="1"] { background: var(--brand); }

@media (max-width: 720px) {
  .vital-strip .vitals { grid-template-columns: 1fr 1fr; }
  .clinical-row { grid-template-columns: 1fr; }
}
