/* Self-hosted: Archivo and Archivo Narrow (SIL Open Font License), the
   variable latin and latin-ext files Google Fonts served on 13 September 2026.
   Loading them from Google sent every ward tablet's IP address to a third
   party on each page load and needed two extra hosts in the CSP. Indic scripts
   were never in these files and still fall back to the system font. */
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('../fonts/archivo-latin.woff2?v=1') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('../fonts/archivo-latin-ext.woff2?v=1') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Archivo Narrow'; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url('../fonts/archivo-narrow-latin.woff2?v=1') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Archivo Narrow'; font-style: normal; font-weight: 500 700; font-display: swap;
  src: url('../fonts/archivo-narrow-latin-ext.woff2?v=1') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ===========================================================================
   NeoBoard — Centralized Newborn Monitoring Dashboard
   Design tokens + shell + components
   Light is the designed default; dark is a selected companion theme.
   =========================================================================== */

/* ---------- Tokens ---------- */
/* Palette is the NeoBoard mark: ink #10214B, blue #2F5BEA, sky #7CA4FF,
   mist #EEF3FF, white. Amber and red are spent only on clinical status —
   brand blue never competes with an alert. */
:root {
  color-scheme: light;

  /* Planes */
  --bg:            #f7f9fe;
  --surface:       #ffffff;
  --surface-2:     #eef3ff;   /* mist */
  --surface-3:     #e4ecfd;

  /* Ink */
  --ink:           #10214b;
  --ink-2:         #445781;
  --muted:         #7a88a8;
  --on-accent:     #ffffff;

  /* Lines */
  --line:          #e2e9f8;
  --line-strong:   #c9d6f2;

  /* Brand */
  --accent:        #2f5bea;
  --accent-hover:  #2449c8;
  --accent-soft:   #eef3ff;
  --accent-ink:    #1c3a9e;
  --sky:           #7ca4ff;
  --hero-from:     #2f5bea;
  --hero-to:       #10214b;

  /* Chart chrome */
  --chart-surface: #ffffff;
  --grid:          #eaf0fd;
  --axis:          #c9d6f2;

  /* Categorical series (validated: light, surface #ffffff) */
  --s1: #2f5bea;   /* blue    */
  --s2: #eb6834;   /* orange  */
  --s3: #1baf7a;   /* aqua    */
  --s4: #eda100;   /* yellow  */

  /* Sequential blue ramp (used for meters / heat cells) */
  --seq-100: #dbe6fe;
  --seq-250: #7ca4ff;
  --seq-400: #2f5bea;
  --seq-550: #1c3a9e;
  --meter-track: #dbe6fe;

  /* Status (fixed, never themed — always shipped with icon + label) */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --good-ink:     #056b05;
  --warning-ink:  #8a5c00;
  --serious-ink:  #a1441c;
  --critical-ink: #9d2222;
  --good-soft:     #e6f6e6;
  --warning-soft:  #fdf1d8;
  --serious-soft:  #fdeee6;
  --critical-soft: #fbe8e8;

  /* Shape & depth — tighter than the template; this is a dense tool. */
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  --shadow-1: 0 1px 2px rgba(16, 33, 75, .05), 0 6px 18px rgba(16, 33, 75, .05);
  --shadow-2: 0 12px 32px rgba(16, 33, 75, .13);
  --ring: 0 0 0 3px rgba(47, 91, 234, .30);

  --brand-tile:    #2f5bea;
  --brand-glyph:   #ffffff;
  --sidebar-w: 178px;
  --font: Archivo, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-data: "Archivo Narrow", "Archivo", ui-sans-serif, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Dark keeps the ink hue as the ground, so the brand still reads as NeoBoard. */
  --bg:            #080d1c;
  --surface:       #101a33;
  --surface-2:     #16223f;
  --surface-3:     #1d2c4e;
  --ink:           #eef3ff;
  --ink-2:         #b3c3e6;
  --muted:         #7f8fb4;
  --line:          #22314f;
  --line-strong:   #33456b;
  --accent:        #6d93ff;
  --accent-hover:  #8aa9ff;
  --accent-soft:   #1a2a52;
  --accent-ink:    #a8c1ff;
  --sky:           #7ca4ff;
  --brand-tile:    #ffffff;
  --brand-glyph:   #10214b;
  --hero-from:     #1c3a9e;
  --hero-to:       #10214b;
  --chart-surface: #1b1c26;
  --grid:          #292b38;
  --axis:          #3a3d4f;

  /* Categorical series (validated: dark, surface #1b1c26) */
  --s1: #6d93ff;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;

  --seq-100: #1a2a52;
  --seq-250: #2f5bea;
  --seq-400: #6d93ff;
  --seq-550: #a8c1ff;
  --meter-track: #232c42;

  --good-ink:     #6ede6e;
  --warning-ink:  #f7cd6c;
  --serious-ink:  #f3ac8d;
  --critical-ink: #f08b8b;
  --good-soft:     #16301a;
  --warning-soft:  #33290f;
  --serious-soft:  #33221b;
  --critical-soft: #331a1a;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(133, 121, 245, .35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 8px;
}

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

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: 10px; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: -.01em;
}
.brand__mark { width: 26px; height: 26px; flex: none; display: block; }
.brand__mark svg { width: 26px; height: 26px; display: block; }

.nav-group__title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 700; padding: 0 6px 8px;
}
.nav-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
}
.nav-item {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: 14px;
  color: var(--ink-2); text-decoration: none;
  font-size: 11px; font-weight: 600; text-align: center; line-height: 1.25;
  hyphens: none; overflow-wrap: normal;
  transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item__icon {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nav-item:hover { color: var(--ink); }
.nav-item:hover .nav-item__icon { background: var(--surface-3); }
/* Weight, not only colour. NHS and GOV.UK wrap the current nav item in a
   <strong> for the same reason: anyone overriding colours - high contrast, a
   low-vision stylesheet - otherwise loses every trace of which page they are
   on. The base weight here is already 600, so this has to go further. */
.nav-item.is-active { color: var(--accent-ink); font-weight: 700; }
.nav-item.is-active .nav-item__icon {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 14px rgba(47, 91, 234, .30);
}
.nav-spacer { flex: 1; }

/* ---------- Topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 28px 8px;
}
.topbar__title { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.topbar__crumb { font-size: 12px; color: var(--muted); font-weight: 600; }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn--labelled {
  width: auto; padding: 0 12px; gap: 7px;
  grid-auto-flow: column; align-items: center;
}
.icon-btn__label { font-size: 12px; font-weight: 600; letter-spacing: -.01em; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn__dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--critical); border: 2px solid var(--surface);
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.user-chip__name { font-size: 12.5px; font-weight: 700; line-height: 1.1; }
.user-chip__role { font-size: 11px; color: var(--muted); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 700; font-size: 12px; letter-spacing: .02em;
}
.avatar--lg { width: 64px; height: 64px; font-size: 20px; }
.avatar--sm { width: 28px; height: 28px; font-size: 10.5px; }

.view { padding: 12px 28px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 18px;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px;
}
.card__title { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.card__sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card__tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.grid { display: grid; gap: 16px; }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent); color: var(--on-accent);
  font-size: 12.5px; font-weight: 700; letter-spacing: -.01em;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn svg { width: 15px; height: 15px; }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--sm { padding: 6px 11px; font-size: 11.5px; border-radius: 9px; }
.btn--danger { background: var(--critical); }
.btn--danger:hover { background: #b93232; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.seg__btn {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 5px 11px; border-radius: 8px;
  font-size: 11.5px; font-weight: 700; color: var(--ink-2);
}
.seg__btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Stat tile ---------- */
.stat { display: flex; flex-direction: column; gap: 10px; }
.stat__icon {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.stat__icon svg { width: 20px; height: 20px; }
.stat__icon--good { background: var(--good-soft); color: var(--good-ink); }
.stat__icon--warning { background: var(--warning-soft); color: var(--warning-ink); }
.stat__icon--serious { background: var(--serious-soft); color: var(--serious-ink); }
.stat__icon--critical { background: var(--critical-soft); color: var(--critical-ink); }
.stat__label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 700; letter-spacing: -.03em; color: var(--ink); }
.stat__value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat__delta { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.stat__delta svg { width: 13px; height: 13px; }
.stat__delta--up { color: var(--good-ink); }
.stat__delta--down { color: var(--critical-ink); }

/* ---------- Status chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: -.005em;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip svg { width: 12px; height: 12px; flex: none; }
.chip--good     { background: var(--good-soft);     color: var(--good-ink);     border-color: transparent; }
.chip--warning  { background: var(--warning-soft);  color: var(--warning-ink);  border-color: transparent; }
.chip--serious  { background: var(--serious-soft);  color: var(--serious-ink);  border-color: transparent; }
.chip--critical { background: var(--critical-soft); color: var(--critical-ink); border-color: transparent; }
/* The record, not the baby. Accent rather than a severity colour, on purpose:
   an unfinished admission is work to do, not a clinical state, and the two must
   not read the same on a ward round. */
.chip--accent   { background: var(--accent-soft);   color: var(--accent-ink);   border-color: transparent; }
.chip--accent   { background: var(--accent-soft);   color: var(--accent-ink);   border-color: transparent; }

/* ---------- Filter row ---------- */
.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.filters__label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.field__hint { font-size: 11px; color: var(--muted); }
.field__error { font-size: 11px; color: var(--critical-ink); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--critical); }
.textarea { min-height: 82px; resize: vertical; }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.input--sm, .select--sm { padding: 7px 10px; font-size: 12px; border-radius: 9px; }
.select--sm { padding-right: 28px; background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; }

.search {
  position: relative; display: flex; align-items: center; min-width: 230px; flex: 1;
}
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 620px; }
table.table--wide { min-width: 900px; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__name { display: flex; align-items: center; gap: 10px; }
.table__name b { font-weight: 700; white-space: nowrap; }
.table__meta { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- Chart card ---------- */
.chart { position: relative; }
.chart__plot { width: 100%; display: block; touch-action: none; }
.chart__plot:focus-visible { box-shadow: var(--ring); border-radius: 10px; }
.chart__legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.chart__legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.chart__key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.chart__key--rect { width: 11px; height: 11px; border-radius: 3px; }
.chart__key--dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); }
.chart__empty { padding: 34px 10px; text-align: center; color: var(--muted); font-size: 12.5px; }
/* Caption under a chart: which clock the axis uses, or why a curve is absent.
   Sized like a footnote because it explains the chart rather than competing
   with it, but not so faint that it reads as decoration. */
.chart__note { margin: 8px 2px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.tooltip {
  position: absolute; z-index: 20; pointer-events: none;
  background: var(--ink); color: var(--surface);
  border-radius: 10px; padding: 8px 10px;
  font-size: 11.5px; box-shadow: var(--shadow-2);
  transform: translate(-50%, -120%); white-space: nowrap;
  opacity: 0; transition: opacity .1s ease;
}
:root[data-theme="dark"] .tooltip { background: #f3f4fa; color: #14151d; }
.tooltip.is-on { opacity: 1; }
.tooltip__x { font-size: 10.5px; opacity: .72; margin-bottom: 4px; font-weight: 600; }
.tooltip__row { display: flex; align-items: center; gap: 7px; }
.tooltip__row + .tooltip__row { margin-top: 3px; }
.tooltip__key { width: 12px; height: 2.5px; border-radius: 2px; flex: none; }
.tooltip__val { font-weight: 700; font-variant-numeric: tabular-nums; }
.tooltip__name { opacity: .74; }

/* ---------- Meter ---------- */
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter__track {
  position: relative; height: 10px; border-radius: 999px;
  background: var(--meter-track); overflow: hidden;
}
.meter__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--seq-400); }
.meter__fill--warning { background: var(--warning); }
.meter__fill--serious { background: var(--serious); }
.meter__fill--critical { background: var(--critical); }
.meter__scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Definition list (record cards) ---------- */
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px 18px; }
.dl__k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.dl__v { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.dl__v small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin: 4px 0 10px;
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 10px 14px; font-size: 12.5px; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* ---------- Timeline / list rows ---------- */
.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row__icon {
  width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.row__icon svg { width: 17px; height: 17px; }
.row__body { min-width: 0; flex: 1; }
.row__title { font-size: 12.5px; font-weight: 700; }
.row__meta { font-size: 11px; color: var(--muted); }
.row__side { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.alert-row { border-left: 3px solid var(--line); padding-left: 11px; }
.alert-row--critical { border-left-color: var(--critical); }
.alert-row--serious  { border-left-color: var(--serious); }
.alert-row--warning  { border-left-color: var(--warning); }

/* ---------- Patient cards on dashboard ---------- */
.baby-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); cursor: pointer; text-align: left;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.baby-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.baby-card__head { display: flex; align-items: center; gap: 10px; }
.baby-card__name { font-size: 13.5px; font-weight: 700; letter-spacing: -.01em; }
.baby-card__meta { font-size: 11px; color: var(--muted); }
.baby-card__vitals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.vital { background: var(--surface-2); border-radius: 10px; padding: 7px 8px; }
.vital__k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.vital__v { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; }
.vital--flag { background: var(--critical-soft); }
.vital--flag .vital__v, .vital--flag .vital__k { color: var(--critical-ink); }
.vital--watch { background: var(--warning-soft); }
.vital--watch .vital__v, .vital--watch .vital__k { color: var(--warning-ink); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.form-grid--wide { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.fieldset { border: 0; padding: 0; margin: 0 0 22px; }
.fieldset:last-of-type { margin-bottom: 0; }
.fieldset > legend {
  padding: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin-bottom: 12px;
}
.col-span-2 { grid-column: span 2; }
.col-span-full { grid-column: 1 / -1; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.radio-pill input { accent-color: var(--accent); margin: 0; }
.radio-pill:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.radio-pill:has(input:focus-visible) { box-shadow: var(--ring); }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--good);
  border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-2);
  animation: toast-in .18s ease-out;
}
.toast--error { border-left-color: var(--critical); }
.toast--info { border-left-color: var(--accent); }
.toast__title { font-size: 12.5px; font-weight: 700; }
.toast__text { font-size: 11.5px; color: var(--ink-2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
/* One column. The right-hand hero panel is gone: a marketing illustration on
   the door of a clinical record is the wrong first thing to show a nurse at the
   start of a shift, and it pushed the actual sign-in form into half the width
   on the tablet sizes this runs on. */
.login {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg); padding: 24px;
}
.login__panel { width: 100%; max-width: 420px; }
.login__panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login__box { width: 100%; max-width: 380px; }
  position: relative; overflow: hidden; margin: 18px 18px 18px 0; border-radius: 26px;
  background: linear-gradient(150deg, var(--hero-from), var(--hero-to));
  color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: flex-end;
}
.login__title { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 18px; }
.login__sub { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.login__roles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 16px; }
.role-card {
  cursor: pointer; padding: 14px; border-radius: 14px; text-align: left;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.role-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-1); }
.role-card:has(input:focus-visible) { box-shadow: var(--ring); }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card__icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent-ink); margin-bottom: 9px; }
.role-card:has(input:checked) .role-card__icon { background: var(--accent); color: var(--on-accent); }
.role-card__t { font-size: 13px; font-weight: 700; }
.role-card__d { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- Print (reports) ---------- */
.print-doc { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); padding: 26px; }
.print-doc__head { display: flex; align-items: flex-start; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.print-doc h3 { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.print-doc h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.print-doc__field { margin-top: 14px; }
.print-doc__write { border-bottom: 1px dashed var(--line-strong); padding: 4px 2px; font-size: 13px; white-space: pre-wrap; outline: none; }
.print-doc__write:focus { background: var(--surface-2, rgba(0,0,0,.03)); }
.print-doc__sign { margin-top: 30px; display: flex; gap: 40px; }
.print-doc__sign div { flex: 1; border-top: 1px solid var(--line-strong); padding-top: 7px; font-size: 11px; color: var(--muted); }

@media print {
  .sidebar, .topbar, .filters, .no-print { display: none !important; }
  .app { display: block; }
  .view { padding: 0; }
  body { background: #fff; }
  .print-doc { border: 0; box-shadow: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .print-doc .table-wrap, .print-doc__field, .print-doc__sign { break-inside: avoid; }
  .print-doc h4 { break-after: avoid; }
  .print-doc__write { border-bottom-color: #000; }
  .print-doc .table-wrap { overflow: visible; }
}

/* ---------- Utility ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.rowflex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rowflex--tight { gap: 6px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mt-auto { margin-top: auto; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

.disclaimer {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--r-md);
  background: var(--warning-soft); color: var(--warning-ink);
  font-size: 11.5px; font-weight: 600; line-height: 1.45;
}
.disclaimer svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; z-index: 50;
    flex-direction: row; align-items: center; gap: 14px;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 10px 14px; overflow-x: auto;
    /* As a grid item the sidebar defaults to min-width:auto, so the nav's own
       width holds it open and the overflow-x above never engages - the whole
       page scrolls sideways instead of the strip. Letting it go narrower than
       its content is what turns that rule on. */
    min-width: 0;
  }
  .nav-group { display: flex; align-items: center; gap: 10px; }
  .nav-group__title { display: none; }
  .nav-grid { display: flex; }
  .nav-item { flex-direction: row; padding: 7px 10px; gap: 8px; }
  .nav-item__icon { width: 30px; height: 30px; border-radius: 10px; }
  .nav-spacer { display: none; }
  .grid--3, .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: 1fr; }
  .view, .topbar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 620px) {
  /* Seven controls will not fit across a phone. Wrapping puts the account chip
     on a second row rather than pushing the page wider than the screen; the
     spacer that separates title from actions has no job once they wrap. */
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar__spacer { display: none; }
  .user-chip { min-width: 0; }

  .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid--2 { grid-template-columns: minmax(0, 1fr); }
  .col-span-2 { grid-column: auto; }
  .baby-card__vitals { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ===========================================================================
   Overview — the cohort screen
   One row per baby, ranked by concern. Everything here is tuned for a
   physician scanning fifteen rows, so: hairlines not shadows, tabular figures
   in every data column, and no illustration anywhere.
   =========================================================================== */

/* ---------- Ward strip ----------
   Replaces the illustration hero. Six numbers, each one a filter. */
.wardstrip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.wardstrip__cell {
  appearance: none;
  background: none;
  border: 0;
  border-left: 1px solid var(--line);
  padding: 13px 16px 14px;
  text-align: left;
  cursor: pointer;
  position: relative;
  font: inherit;
  color: var(--ink);
  transition: background .13s ease;
}
.wardstrip__cell:first-child { border-left: 0; }
.wardstrip__cell:hover { background: var(--surface-2); }
.wardstrip__cell:focus-visible { outline: none; box-shadow: var(--ring) inset; }
.wardstrip__cell::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .18s ease;
}
.wardstrip__cell.is-on::after { transform: scaleX(1); }
.wardstrip__cell.is-on { background: var(--accent-soft); }
.wardstrip__n {
  font-family: var(--font-data);
  font-size: 25px; font-weight: 700; line-height: 1;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  display: block;
}
.wardstrip__cell.is-empty .wardstrip__n { color: var(--muted); }
.wardstrip__l {
  display: block; margin-top: 5px;
  font-size: 10px; font-weight: 600;
  letter-spacing: .085em; text-transform: uppercase;
  color: var(--muted);
}
.wardstrip__n--critical { color: var(--critical-ink); }
.wardstrip__n--serious  { color: var(--serious-ink); }
.wardstrip__n--warning  { color: var(--warning-ink); }

/* ---------- Toolbar ---------- */
.ovbar {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 10px;
}
.ovbar__count {
  font-size: 11.5px; color: var(--muted);
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.ovbar__search {
  position: relative; width: 232px;
}
.ovbar__search input {
  width: 100%; padding: 7px 10px 7px 30px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font: 500 12.5px var(--font);
}
.ovbar__search input:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.ovbar__search svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}

/* ---------- Visit schedule strip ---------- */
.sched {
  padding: 4px 2px 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.sched__host { width: 100%; height: 46px; }
.sched svg { display: block; overflow: visible; }
.sched__cap {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Concern table ---------- */
.ctable-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow-x: auto;
}
.ctable { width: 100%; border-collapse: collapse; min-width: 1160px; }
.ctable thead th {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); text-align: left;
  padding: 11px 12px 9px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  background: var(--surface);
}
.ctable thead th.is-num { text-align: right; }
.ctable tbody tr { border-bottom: 1px solid var(--line); }
.ctable tbody tr:last-child { border-bottom: 0; }
.ctable tbody tr:hover { background: var(--surface-2); }
.ctable tbody tr:focus-within { background: var(--surface-2); }
.ctable td { padding: 6px 12px; vertical-align: middle; }

/* The band rule. A colour edge on the row instead of a status chip — fifteen
   chips is fifteen things to read; fifteen rules is one gradient you take in
   at a glance. Stable rows deliberately get no colour at all. */
.ctable td.cell-name { border-left: 3px solid transparent; padding-left: 13px; }
tr.band--warning  td.cell-name { border-left-color: var(--warning); }
tr.band--serious  td.cell-name { border-left-color: var(--serious); }
tr.band--critical td.cell-name { border-left-color: var(--critical); }

.cname { display: block; font-size: 13px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.cname:hover { color: var(--accent); }
.cname:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 3px; }
.cmeta { font-size: 10.5px; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cnum {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
.cnum--muted { color: var(--muted); font-weight: 500; }

/* ---------- Concern cell: score + spine ---------- */
.concern { display: flex; align-items: center; gap: 9px; }
.concern__score {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 16px; font-weight: 700; line-height: 1;
  min-width: 26px; text-align: right;
  color: var(--ink);
}
.concern__score.is-zero { color: var(--muted); font-weight: 500; }

/* The spine — the one place this design raises its voice.
   Four fixed slots, always in the same order: jaundice, growth, screening,
   surveillance. Bar height is that domain's points, so the row's silhouette
   tells you what kind of problem it is before you read a word. */
.spine { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.spine__slot {
  width: 5px; height: 18px;
  background: var(--line);
  opacity: .55;
  border-radius: 1.5px;
  position: relative;
  overflow: hidden;
}
.spine__slot.has-fill { opacity: 1; }
.spine__fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--line-strong);
  border-radius: 1.5px;
  transform-origin: bottom;
  /* CSS handles the rise until anime.js loads and takes it over. */
  animation: spine-rise .32s cubic-bezier(.2,.7,.3,1) both;
}
.spine__fill--warning  { background: var(--warning); }
.spine__fill--serious  { background: var(--serious); }
.spine__fill--critical { background: var(--critical); }
@keyframes spine-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* Legend, shown once above the table so the spine is learnable. */
.spine-key { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--muted); }
.spine-key__b { display: flex; gap: 2px; align-items: flex-end; height: 12px; }
.spine-key__b i { width: 4px; background: var(--line-strong); border-radius: 1px; display: block; }

/* ---------- Weight trend ---------- */
.wtrend { display: flex; align-items: center; gap: 8px; }
.wtrend svg { display: block; flex: none; }
.wtrend__d {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
/* Weight deltas are NOT status. They get ink, never red or green — alert
   colour on a routine number is how a dashboard trains you to ignore it. */
.wtrend__d { color: var(--ink-2); }
.wtrend__d.is-loss { color: var(--ink); }
.wtrend__none { font-size: 10.5px; color: var(--muted); }
.wtrend__v { display: flex; flex-direction: column; line-height: 1.25; }
.wtrend__v b {
  font-family: var(--font-data); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap;
}

/* Latest observation set. Fixed positions, hairline separators, tabular
   figures — the header names the order once so the row needs no labels. */
.vrow { display: flex; align-items: baseline; gap: 0; white-space: nowrap; }
.vrow__v {
  font-family: var(--font-data); font-variant-numeric: tabular-nums;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  padding: 0 7px; border-left: 1px solid var(--line);
  min-width: 38px; text-align: right;
}
.vrow__v:first-child { border-left: 0; padding-left: 0; }
.vrow__v--none { color: var(--muted); font-weight: 500; }
.vrow__v--warning  { color: var(--warning-ink); font-weight: 700; }
.vrow__v--critical { color: var(--critical-ink); font-weight: 700; }
.vrow__v--bili { color: var(--ink-2); }
.vrow__none { font-size: 11px; color: var(--muted); }
.ctable thead th.th-vitals { letter-spacing: .05em; }

/* ---------- Leading reason ---------- */
.creason {
  font-size: 12px; color: var(--ink-2); line-height: 1.3;
  max-width: 46ch;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.creason__more {
  font-size: 10.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.creason-cell { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.creason--clear { color: var(--muted); font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  .spine__fill { animation: none; }
  .wardstrip__cell::after { transition: none; }
}

@media (max-width: 1180px) {
  .wardstrip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wardstrip__cell:nth-child(4) { border-left: 0; }
  .wardstrip__cell:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .wardstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wardstrip__cell:nth-child(3) { border-left: 0; }
  .wardstrip__cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ovbar { flex-wrap: wrap; }
  .ovbar__search { width: 100%; order: -1; }
}

/* ===========================================================================
   Screening tracker
   Twenty tests across the ward is a matrix, not a list. Cells are small and
   uniform so the eye reads the pattern of open loops rather than any one value.
   =========================================================================== */

.sbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 12px 16px;
}
.sbar__lead { font-size: 13px; color: var(--ink-2); margin: 0; }
.sbar__lead b {
  font-family: var(--font-data); font-variant-numeric: tabular-nums;
  font-size: 17px; color: var(--ink); font-weight: 700;
}
.sbar__lead b.is-bad { color: var(--critical-ink); }
.sbar__muted { color: var(--muted); }
.sbar .btn { margin-left: auto; }
.sbar .btn.is-on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.slegend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin: 12px 0 10px; font-size: 11px; color: var(--muted);
}
.slegend__i { display: flex; align-items: center; gap: 6px; }

/* ---------- the grid ---------- */
.sgrid-wrap {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); overflow-x: auto; overflow-y: visible;
}
.sgrid { border-collapse: separate; border-spacing: 0; width: 100%; }

.sgrid th, .sgrid td { padding: 0; }

.sgrid__group {
  font-size: 9.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); text-align: center; white-space: nowrap;
  padding: 10px 6px 5px; border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.sgrid__code {
  font-family: var(--font-data); font-size: 10px; font-weight: 700;
  color: var(--ink-2); text-align: center; white-space: nowrap;
  padding: 4px 3px 7px; min-width: 30px;
  border-bottom: 1px solid var(--line-strong);
}

/* The baby column stays put while twenty test columns scroll under it —
   a status square is meaningless once its row label is off-screen. */
.sgrid__corner, .sgrid__name {
  position: sticky; left: 0; z-index: 2;
  background: var(--surface);
  border-right: 1px solid var(--line-strong);
  text-align: left; padding: 8px 14px 8px 14px;
  min-width: 208px;
}
.sgrid__corner {
  z-index: 3;
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line);
}
.sgrid__corner--2 { border-bottom: 1px solid var(--line-strong); }
.sgrid__name { font-weight: 400; border-bottom: 1px solid var(--line); }
.sgrid tbody tr:hover .sgrid__name { background: var(--surface-2); }
.sgrid tbody tr:hover .sgrid__cell { background: var(--surface-2); }

.sgrid__cell {
  text-align: center; border-bottom: 1px solid var(--line);
  padding: 4px 2px;
}

/* A row with something past its chase window gets an edge, matching the
   overview's band rule so the two screens speak the same language. */
.sgrid tbody tr.is-overdue-row .sgrid__name { box-shadow: inset 3px 0 0 var(--critical); }

/* ---------- the status cell ---------- */
.scell {
  appearance: none; cursor: pointer;
  width: 26px; height: 26px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  position: relative;
  transition: transform .1s ease, box-shadow .12s ease;
}
.scell:hover { transform: scale(1.12); }
.scell:focus-visible { outline: none; box-shadow: var(--ring); z-index: 4; }
.scell__g { font-size: 11px; font-weight: 700; line-height: 1; font-family: var(--font-data); }

.scell--good     { background: var(--good-soft);     border-color: var(--good);     color: var(--good-ink); }
.scell--warning  { background: var(--warning-soft);  border-color: var(--warning);  color: var(--warning-ink); }
.scell--serious  { background: var(--serious-soft);  border-color: var(--serious);  color: var(--serious-ink); }
.scell--critical { background: var(--critical-soft); border-color: var(--critical); color: var(--critical-ink); }
.scell--none     { background: var(--surface-2);     border-color: var(--line);     color: var(--muted); }

/* An unresolved loop is drawn as an unclosed ring: a dashed border. A resolved
   refer keeps its colour but loses the dashes, so "dealt with" is visible
   without reading a date. */
.scell.is-open { border-style: dashed; border-width: 1.5px; }
.scell.is-overdue { box-shadow: 0 0 0 2px var(--critical-soft); }
.scell__flag {
  position: absolute; top: -2px; right: -2px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--critical); border: 1px solid var(--surface);
}
.scell--key { cursor: default; width: 20px; height: 20px; }
.scell--key:hover { transform: none; }

/* ---------- record panel ---------- */
.srec {
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 12px;
}
.srec__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.srec__title { font-size: 14px; font-weight: 700; color: var(--ink); margin: 0; letter-spacing: -.01em; }
.srec__baby { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.srec__note {
  font-size: 11.5px; color: var(--ink-2); margin: 0 0 10px;
  background: var(--surface-2); border-left: 3px solid var(--line-strong);
  padding: 7px 10px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.srec__results { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.srec__opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.srec__opt input { margin: 0; accent-color: var(--accent); }
.srec__opt input:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 3px; }
.srec__fields { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; margin-bottom: 14px; }
.srec__fields input {
  padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 500 12.5px var(--font);
}
.srec__fields input:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.srec__actions { display: flex; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  .scell { transition: none; }
  .scell:hover { transform: none; }
}
@media (max-width: 720px) {
  .sgrid__corner, .sgrid__name { min-width: 150px; padding-left: 10px; padding-right: 10px; }
  .srec__fields { grid-template-columns: minmax(0, 1fr); }
  .sbar .btn { margin-left: 0; }
}

/* ===========================================================================
   Visit examination
   A long form that has to stay scannable: the systems review is a table, not a
   stack of cards, so eleven systems read as one block instead of eleven.
   =========================================================================== */

.vex__head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 12px;
}
.vex__headside { margin-left: auto; }
.vex__eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-ink);
}
.vex__title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); margin: 5px 0 3px; }
.vex__meta { font-size: 11.5px; color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }

/* Validation summary. Named problems in a list, not a count in an alert box —
   the examiner needs to know which system is missing a comment, and be able to
   get to it. Each entry is a link, so the underline is doing real work here. */
.errsum {
  background: var(--critical-soft); border: 1px solid var(--critical);
  border-radius: var(--r-lg); padding: 13px 16px; margin-bottom: 12px;
}
.errsum:focus-visible { outline: none; box-shadow: var(--ring); }
.errsum__title { font-size: 13px; font-weight: 700; color: var(--critical-ink); margin: 0 0 6px; }
.errsum__list { margin: 0; padding-left: 18px; }
.errsum__list li { font-size: 12px; color: var(--critical-ink); line-height: 1.5; }
.errsum__list a {
  color: inherit; text-decoration: underline; text-underline-offset: 2px;
  border-radius: 2px;
}
.errsum__list a:hover { text-decoration-thickness: 2px; }
.errsum__list a:focus-visible { outline: none; box-shadow: var(--ring); }

/* The field an error points at, once you land on it. */
.field input:focus-visible, .field textarea:focus-visible, .field select:focus-visible {
  outline: none; box-shadow: var(--ring);
}

/* ---------- systems review ---------- */
.vex__systems { width: 100%; border-collapse: collapse; margin-top: 10px; }
.vex__systems thead th {
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); text-align: left; padding: 0 10px 8px;
  border-bottom: 1px solid var(--line-strong);
}
.vex__systems tbody tr { border-bottom: 1px solid var(--line); }
.vex__systems tbody tr:last-child { border-bottom: 0; }
.vex__systems tbody tr.is-invalid { background: var(--critical-soft); }
.vex__systems td, .vex__systems th[scope="row"] { padding: 7px 10px; vertical-align: middle; }
.vex__sys {
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  text-align: left; width: 210px;
}
.vex__systems input[type="text"] {
  width: 100%; padding: 6px 9px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 500 12px var(--font);
}
.vex__systems input[type="text"]:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
.vex__systems input[aria-invalid="true"] { border-color: var(--critical); }
.vex__err { display: block; font-size: 10.5px; color: var(--critical-ink); margin-top: 3px; font-weight: 600; }

.vex__findings { display: flex; gap: 4px; flex-wrap: wrap; }
.vex__finding {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
.vex__finding input { margin: 0; accent-color: var(--accent); }
.vex__finding input:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 50%; }
/* Only "abnormal" earns a status colour, and only once chosen. A normal finding
   is the expected case and must not light up green across eleven rows. */
.vex__finding--abnormal:has(input:checked) {
  background: var(--critical-soft); border-color: var(--critical); color: var(--critical-ink);
}
.vex__finding--normal:has(input:checked) { background: var(--surface-3); border-color: var(--line-strong); color: var(--ink); }
.vex__finding--not_examined:has(input:checked) { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); }

.vex__systems--eyes .vex__sys { width: 260px; }

/* ---------- yes / no ---------- */
.vex__ynrow { display: flex; gap: 6px; }
.vex__yn {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.vex__yn input { margin: 0; accent-color: var(--accent); }
.vex__yn input:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 50%; }
.vex__yn:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

@media (max-width: 860px) {
  .vex__sys, .vex__systems--eyes .vex__sys { width: auto; }
  .vex__systems, .vex__systems thead, .vex__systems tbody,
  .vex__systems tr, .vex__systems td, .vex__systems th { display: block; }
  .vex__systems thead { display: none; }
  .vex__systems tbody tr { padding: 8px 0; }
  .vex__headside { margin-left: 0; }
}

/* ---------- visit history rows on the profile ---------- */
.vhist__ab {
  font-size: 11.5px; color: var(--critical-ink); line-height: 1.45;
  margin-top: 3px;
}
.vhist__ab b { font-weight: 700; }
.vhist__act {
  font-size: 11.5px; color: var(--ink-2); margin-top: 3px;
  padding-left: 9px; border-left: 2px solid var(--line-strong);
}
.btn--sm { padding: 5px 10px; font-size: 11.5px; }

/* ---------- language picker ---------- */
.lang-wrap { display: flex; align-items: center; gap: 5px; }
.lang-picker {
  padding: 8px 10px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 12px var(--font); max-width: 150px;
}
.lang-picker:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
/* A draft translation is a standing clinical risk, so it gets a status colour
   rather than a neutral hint. */
.lang-flag { color: var(--warning-ink); font-size: 16px; line-height: 1; cursor: help; }
.card > .lang-picker { margin-top: 4px; max-width: 260px; }

/* ---------- sync indicator ----------
   Reads as status, not decoration: an entry that has not left the device is a
   clinical-safety fact, so it uses the status tokens. */
.syncpill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; height: 38px; flex: none;
  border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  font: 600 12px var(--font); text-decoration: none; white-space: nowrap;
}
.syncpill svg { width: 15px; height: 15px; }
.syncpill:focus-visible { outline: none; box-shadow: var(--ring); }
.syncpill--ok   { color: var(--good-ink);     border-color: var(--good);     background: var(--good-soft); }
.syncpill--wait { color: var(--warning-ink);  border-color: var(--warning);  background: var(--warning-soft); }
.syncpill--bad  { color: var(--critical-ink); border-color: var(--critical); background: var(--critical-soft); }
.syncpill--off  { color: var(--muted); }
@media (max-width: 720px) { .syncpill span { display: none; } .syncpill { padding: 0 10px; } }

/* ===========================================================================
   Polish pass — hierarchy, empty states, meaningful motion, print
   =========================================================================== */

/* ---------- empty states ----------
   An empty screen is an invitation to act. Centred, quiet, with the one thing
   to do next — not a bare sentence in a box. */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 52px 24px; gap: 4px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.empty__icon {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 10px;
  background: var(--surface-2); color: var(--sky);
}
.empty__icon svg { width: 21px; height: 21px; }
.empty__title { font-size: 15px; font-weight: 700; color: var(--ink); margin: 0; letter-spacing: -.01em; }
.empty__hint { font-size: 12.5px; color: var(--muted); margin: 0; max-width: 46ch; line-height: 1.55; }
.empty__action { margin-top: 14px; }

/* ---------- the change flash ----------
   A row whose concern score just moved. Two seconds, once, then gone — long
   enough to notice on a glance back, short enough not to become wallpaper. */
@keyframes row-changed {
  0%   { background: var(--accent-soft); }
  100% { background: transparent; }
}
.ctable tbody tr.is-changed { animation: row-changed 2s ease-out 1; }
.ctable tbody tr.is-changed td.cell-name { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- login ----------
   First screen anyone sees in a demo, so it gets the real lockup and room to
   breathe rather than a cramped form. */
.brand--login {
  display: inline-flex; align-items: center; gap: 10px;
  background: transparent; border: 0; padding: 0;
  font-size: 17px; letter-spacing: -.02em; margin-bottom: 22px;
}
.brand--login .brand__mark, .brand--login .brand__mark svg { width: 34px; height: 34px; }
.login__title { letter-spacing: -.025em; text-wrap: balance; }
.login__sub { max-width: 46ch; line-height: 1.6; }

/* ---------- typographic hierarchy ----------
   The record pages read flat: every heading was near enough the same weight
   and size as the label beneath it. Widen the gaps between levels. */
.card__title { font-size: 14.5px; letter-spacing: -.015em; }
.dl__k {
  font-size: 10px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.dl__v { font-size: 14px; color: var(--ink); line-height: 1.45; }
.dl__v small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; font-weight: 500; }
.row__title { letter-spacing: -.01em; }

/* Numbers are read in columns and compared, everywhere, always. */
.dl__v, .stat__value, .table td, .row__meta { font-variant-numeric: tabular-nums; }

/* ---------- skeletons ----------
   Charts compute centile curves before they draw. A grey block that holds the
   right amount of space beats a jump when it appears. */
.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}
@keyframes skeleton-sweep { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton--chart { height: 250px; }

/* ---------- print ----------
   A discharge summary gets printed and put in a file. Drop the furniture, keep
   the record, and never break a table row across a page. */
@media print {
  :root { --bg: #fff; --surface: #fff; --line: #ccc; --line-strong: #999; }
  .sidebar, .topbar, .ovbar, .wardstrip, .filters, .form-actions,
  .syncpill, .lang-wrap, .icon-btn, .skip-link, .toast-stack, .seg { display: none !important; }
  .app { grid-template-columns: 1fr !important; }
  .view { padding: 0 !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .ctable-wrap, .sgrid-wrap {
    border: 1px solid #ccc !important; box-shadow: none !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .card { margin-bottom: 10pt; }
  tr, .row { break-inside: avoid; page-break-inside: avoid; }
  a[href]::after { content: ''; }   /* URLs on paper help nobody here */
  /* The prototype warning must survive printing — a printed page outlives the
     screen it came from, and somebody will find it in a folder. */
  .disclaimer { border: 1px solid #000 !important; background: #fff !important; color: #000 !important; }
}

@media (prefers-reduced-motion: reduce) {
  .ctable tbody tr.is-changed { animation: none; }
  .skeleton { animation: none; }
}

/* ===========================================================================
   Radar, gauge, ring, sliding tab
   Design taken from Bklit's chart treatment and Kokonut's tab indicator;
   implementation is plain SVG and CSS, because those libraries are React and
   this app is not. The look travels, the dependency does not.
   =========================================================================== */

.radar-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.radar-mount { width: 100%; max-width: 300px; }
.radar-mount svg { display: block; width: 100%; height: auto; overflow: visible; }
.radar-note {
  font-size: 11.5px; color: var(--muted); margin: 0; text-align: center;
  max-width: 42ch; line-height: 1.5;
}
/* The grid is measured-against chrome, so it never competes with the shape. */
.radar__grid { pointer-events: none; }

.gauge-wrap, .ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge-wrap svg { display: block; max-width: 240px; width: 100%; height: auto; }
.ring-note { font-size: 11.5px; color: var(--muted); margin: 0; text-align: center; }

/* Screening panel: the ring sits beside the list, not above it, so "6 open"
   and which six are read together. */
.screen-panel { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; align-items: start; }
.screen-panel > .ring-wrap { padding-top: 4px; }
@media (max-width: 720px) {
  .screen-panel { grid-template-columns: minmax(0, 1fr); }
  .screen-panel > .ring-wrap { justify-self: center; }
}

/* ---------- sliding tab indicator ---------- */
.tabs { position: relative; }
.tabs__indicator {
  position: absolute; bottom: -1px; left: 0;
  height: 2px; width: 0;
  background: var(--accent); border-radius: 2px;
  pointer-events: none;
}
/* The per-tab border is now the indicator's job. Keeping both would draw the
   active state twice and they would disagree mid-transition. */
.tab.is-active { border-bottom-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  .tabs__indicator { transition: none; }
}

/* ---------- hold to confirm ----------
   The fill is the whole affordance: you can see how much longer to hold, and
   letting go early visibly undoes it. */
.holdbtn {
  position: relative; overflow: hidden;
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: 700 12.5px var(--font); letter-spacing: -.01em;
  touch-action: none;            /* holding must not scroll the page */
  user-select: none;
}
.holdbtn:focus-visible { outline: none; box-shadow: var(--ring); }
.holdbtn__fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: var(--accent-soft);
  pointer-events: none;
}
.holdbtn__label { position: relative; z-index: 1; }
.holdbtn.is-holding { border-color: var(--accent); }
.holdbtn--danger { border-color: var(--critical); color: var(--critical-ink); }
.holdbtn--danger .holdbtn__fill { background: var(--critical-soft); }
.holdbtn--danger.is-holding { border-color: var(--critical); }


/* ---------- Forced colours ----------
   Windows High Contrast and similar modes discard author colours outright. That
   is fine for chrome, but this app says "how worried should you be" in colour,
   so every band needs a second channel that survives. Borders and outlines are
   honoured in forced-colours mode where backgrounds are not, so the concern
   bands keep a left edge and the active nav item keeps a visible outline. */
@media (forced-colors: active) {
  .nav-item.is-active { outline: 2px solid; outline-offset: -2px; }

  /* Concern bands: the row keeps a thick edge even when the fill is dropped,
     and critical is doubled so it is still the odd one out at a glance. */
  tr.band--warning  td.cell-name,
  tr.band--serious  td.cell-name,
  tr.band--critical td.cell-name { border-left-width: 6px; border-left-style: solid; }
  tr.band--critical td.cell-name { border-left-style: double; border-left-width: 7px; }

  /* Chips need nothing here: all 39 of them carry a word - Pass, Refer, Watch,
     Overdue - so the status survives losing the fill without any help. */

  /* The charts carry clinical meaning in their colour, so they keep it rather
     than collapsing every series into one system colour. */
  .radar__area, .gauge__fill, .ring__fill, .sched svg { forced-color-adjust: none; }

  /* Focus has to stay obvious once the custom ring token is discarded. */
  :focus-visible { outline: 3px solid; outline-offset: 2px; }
}

/* ---------- Sections that can wait ----------
   The admission form asks 61 questions and a baby is admitted once, often in a
   hurry. The six that create a safe record stay open; the rest collapse behind
   a <details>, which is keyboard-operable and announced by a screen reader
   without any help from us. Nothing is removed - it is one click away, and the
   confirmation names whatever is still blank. */
.fieldset--later {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 0;
  margin-bottom: 14px;
}
.fieldset__later {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--r-lg);
}
.fieldset__later::-webkit-details-marker { display: none; }
.fieldset__later::before {
  content: '';
  width: 7px; height: 7px; flex: none;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
.fieldset--later[open] > .fieldset__later::before { transform: rotate(45deg); }
.fieldset--later[open] > .fieldset__later { border-bottom: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.fieldset__later:hover { background: var(--surface-2); }
.fieldset__later:focus-visible { outline: none; box-shadow: var(--ring); }
.fieldset__later-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.fieldset__later-hint { font-size: 12px; color: var(--muted); }
.fieldset--later > .form-grid { padding: 16px; }

@media (prefers-reduced-motion: reduce) {
  .fieldset__later::before { transition: none; }
}

/* ---------- Danger signs ----------
   The heaviest signal in the app, and until now the only one with no way to
   record it. Deliberately not styled like the other checkboxes: ticking one
   sends a baby to the top of the ward list, and the control should look like
   it means that. */
.dangergrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}
.dangerbox {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer;
  font-size: 13.5px; color: var(--ink-2);
  transition: border-color .12s ease, background .12s ease;
}
.dangerbox:hover { background: var(--surface-2); }
.dangerbox input { width: 17px; height: 17px; flex: none; accent-color: var(--critical); cursor: pointer; }
.dangerbox:has(input:checked) {
  border-color: var(--critical);
  background: var(--critical-soft);
  color: var(--critical-ink);
  font-weight: 600;
}
.dangerbox:focus-within { outline: none; box-shadow: var(--ring); }
.dangerecho { min-height: 26px; margin-top: 4px; }

@media (prefers-reduced-motion: reduce) { .dangerbox { transition: none; } }

/* :has() is not universal. Without it the tick still works and still saves —
   only the emphasis is lost, which is a cosmetic degradation, not a clinical one. */
@supports not selector(:has(*)) {
  .dangerbox input:checked { outline: 2px solid var(--critical); outline-offset: 2px; }
}

/* An active danger sign, and the only way out of one. */
.dangerstand {
  border: 1px solid var(--critical); border-radius: var(--r-lg);
  background: var(--critical-soft); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.dangerstand__now { font-size: 13.5px; color: var(--critical-ink); line-height: 1.5; }
.dangerbox--stand { background: var(--surface); border-color: var(--line); }
.dangerbox--stand:has(input:checked) {
  border-color: var(--good, var(--accent));
  background: var(--good-soft, var(--surface-2));
  color: var(--good-ink, var(--ink));
}

/* ===========================================================================
   Discharge — the form, the printable card, and the discharged list

   The card is a document, not a screen. It is laid out at a document's width
   and margins so that what a clinician approves on screen is what comes out of
   the printer, rather than a dashboard that happens to have a print button.
   =========================================================================== */

/* ---------- the form ---------- */

.dform__dt { display: flex; gap: 8px; }
.dform__dt .input { min-width: 0; }
.dform__dt .input[type="time"] { flex: 0 0 108px; }
.dform__tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }

/* Diagnoses added so far. Chips rather than lines, because the list is short,
   unordered, and every entry needs its own way out. */
.dform__chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 30px; }
.dform__chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 11px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent-ink); font-size: 12px; font-weight: 600; line-height: 1.3;
}
.dform__chipx {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; flex: none;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: inherit;
}
.dform__chipx svg { width: 12px; height: 12px; }
.dform__chipx:hover { background: var(--accent); color: var(--on-accent); }
.dform__chipx:focus-visible { outline: none; box-shadow: var(--ring); }

.dform__none { font-size: 11.5px; color: var(--muted); font-style: italic; }
.dform__addrow { display: flex; gap: 8px; margin-top: 8px; }
.dform__addrow .input { flex: 1; min-width: 0; }

/* What the ward has already flagged, one click from the card. */
.dform__suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.dform__suggestlead { font-size: 11px; font-weight: 700; color: var(--muted); }
.dform__sug {
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px dashed var(--line-strong); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 11.5px; text-align: left;
}
.dform__sug:hover { border-style: solid; border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.dform__sug:focus-visible { outline: none; box-shadow: var(--ring); }

/* A danger sign still standing at the moment somebody fills in a follow-up
   date. Loud on purpose; it does not block the save. */
.dform__active {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--critical);
  background: var(--critical-soft); color: var(--critical-ink);
  font-size: 12px; line-height: 1.5;
}
.dform__active svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }

/* ---------- the card ---------- */

.dcard-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

.dcard {
  max-width: 820px; margin: 0 auto;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 34px 38px 30px;
}

.dcard__head {
  display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 6px;
  border-bottom: 2px solid var(--ink);
}
.dcard__brand { flex: 1; min-width: 0; }
.dcard__hospital {
  font-size: 21px; font-weight: 700; letter-spacing: -.02em;
  color: var(--ink); margin: 0;
}
.dcard__unit {
  font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-top: 3px;
}
.dcard__doctype { text-align: right; }
.dcard__doctitle { font-size: 13px; font-weight: 700; color: var(--ink); }
.dcard__docmeta {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  font-family: var(--font-data); font-variant-numeric: tabular-nums;
}

.dcard__block { margin-top: 20px; break-inside: avoid; page-break-inside: avoid; }
.dcard__h {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted);
  margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.dcard__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; }
.dcard__row { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 10px; padding: 3px 0; }
.dcard__k { font-size: 11.5px; color: var(--muted); }
.dcard__v {
  font-size: 12.5px; color: var(--ink); font-weight: 600;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.dcard__p { font-size: 12.5px; line-height: 1.6; color: var(--ink-2); margin: 0; white-space: pre-wrap; }
.dcard__list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.dcard__list li { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.5; }

/* The red flags.
   The only block on the card drawn as a warning rather than as a record,
   because it is the only one read by somebody who is frightened at three in
   the morning. Never split across a page. */
.dcard__flags {
  margin-top: 22px; padding: 16px 18px;
  border: 2px solid var(--critical); border-radius: var(--r-md);
  background: var(--critical-soft);
  break-inside: avoid; page-break-inside: avoid;
}
.dcard__flagh {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-size: 13.5px; font-weight: 700; color: var(--critical-ink); line-height: 1.35;
}
.dcard__flagh svg { width: 19px; height: 19px; flex: none; }
.dcard__flaglist {
  margin: 0; padding-left: 22px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 24px;
}
.dcard__flaglist li { font-size: 13px; font-weight: 600; color: var(--critical-ink); line-height: 1.45; }

.dcard__sign {
  display: flex; gap: 40px; margin-top: 34px; padding-top: 4px;
  break-inside: avoid; page-break-inside: avoid;
}
.dcard__sign > div { flex: 1; border-top: 1px solid var(--line-strong); padding-top: 8px; }
.dcard__signname { font-size: 12.5px; font-weight: 600; color: var(--ink); min-height: 17px; }
.dcard__signrole { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- the discharged list ---------- */

.dlist td { vertical-align: top; }
.dlist__gap { color: var(--critical-ink); font-weight: 600; }

@media (max-width: 760px) {
  .dcard { padding: 22px 20px; }
  .dcard__grid, .dcard__flaglist { grid-template-columns: minmax(0, 1fr); }
  .dcard__row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .dcard__doctype { text-align: left; }
  .dcard__sign { flex-direction: column; gap: 22px; }
}

/* ---------- printing the card ----------
   A4 with real margins, the app chrome gone, and nothing on the sheet but the
   document. Colour is not assumed: the ward printer is as likely to be mono,
   so the warning box earns its weight from a black rule rather than from red
   ink that may arrive as pale grey. */
@page { size: A4; margin: 14mm; }

@media print {
  .sidebar, .topbar, .ovbar, .dcard-tools, .form-actions,
  .toast-stack, .skip-link, .no-print { display: none !important; }
  .app { display: block !important; grid-template-columns: 1fr !important; }
  .main, .view { padding: 0 !important; margin: 0 !important; }
  body { background: #fff; }

  .dcard {
    max-width: none; width: auto; margin: 0; padding: 0;
    border: 0 !important; border-radius: 0; box-shadow: none !important;
    background: #fff; color: #000; font-size: 10.5pt;
  }
  .dcard__head { border-bottom: 1.5pt solid #000; }
  .dcard__hospital { font-size: 17pt; color: #000; }
  .dcard__h { color: #000; border-bottom: .5pt solid #666; }
  .dcard__v, .dcard__list li { color: #000; }
  .dcard__p { color: #111; }

  .dcard__flags {
    border: 2pt solid #000 !important;
    background: #fff !important;
  }
  .dcard__flagh, .dcard__flaglist li { color: #000 !important; }

  .dcard__sign { margin-top: 26pt; }
  .dcard__sign > div { border-top: .5pt solid #000; }
}


/* ---------------------------------------------------------------------------
   The admission that is not finished yet.

   Deliberately quiet. This is paperwork with a clinical consequence, not an
   alarm - the concern colours belong to the baby's condition and borrowing
   them here would put a missing obstetrician's name in the same visual
   language as a falling saturation. Accent, not critical.
   --------------------------------------------------------------------------- */
.tab--todo { color: var(--accent-ink); }
.tab--todo::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
}

.admission-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px);
  gap: 10px 18px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.admission-row:last-child { border-bottom: 0; }
.admission-row__na { display: flex; flex-direction: column; gap: 6px; padding-top: 22px; }

/* An author rule with a `display` beats the user agent's [hidden] rule, so
   `.input { display: block }` quietly un-hid every element this app hides by
   setting the attribute. Every hidden element in the app went through this. */
[hidden] { display: none !important; }

.nabox {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12px; color: var(--muted);
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface);
}
.nabox:hover { background: var(--surface-2); }
.nabox input { width: 15px; height: 15px; flex: none; accent-color: var(--accent); cursor: pointer; }
.nabox:has(input:checked) { border-color: var(--accent); color: var(--accent-ink); }
.nabox:focus-within { outline: none; box-shadow: var(--ring); }

/* The board's own summary of every unfinished admission. */
.todo-card { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.todo-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); cursor: pointer; text-align: left;
}
.todo-row:hover { background: var(--surface-2); border-color: var(--line-strong); }
.todo-row + .todo-row { margin-top: 8px; }
.todo-row__why { color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .admission-row { grid-template-columns: minmax(0, 1fr); }
  .admission-row__na { padding-top: 0; }
}
