/* ══════════════════════════════════════════════════════════════════════
   NCDS — Nexmedis Clinical Design System
   Shared stylesheet for the klinik → RS Tipe D end-to-end prototype.

   Colour, type and geometry are set here and nowhere else. No raw colour
   literal may appear outside the :root block below.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  /* ── neutrals ─────────────────────────────────────────────────────── */
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --surface-2:     #f1f5f9;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --muted:         #64748b;
  --fg-2:          #475569;
  --fg:            #0f172a;
  --fg-deep:       #1e293b;

  /* ── one action colour ────────────────────────────────────────────── */
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   #eff6ff;

  /* ── criticality / semantic — IGD triage scale, fixed order ───────── */
  --crit-p3: #16a34a;  /* Hijau  · P3 · non-urgent          */
  --crit-p2: #d97706;  /* Kuning · P2 · urgent              */
  --crit-p1: #dc2626;  /* Merah  · P1 · emergent            */
  --crit-p0: #991b1b;  /* Hitam  · P0 · resusitasi          */

  /* ── type ─────────────────────────────────────────────────────────── */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;

  /* ── geometry ─────────────────────────────────────────────────────── */
  --r-xs: 0.25rem;
  --r-sm: 0.375rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-card: 14px;
  --r-capsule: 999px;

  --elev-1:
    0 1px 1px color-mix(in oklch, var(--fg) 4%, transparent),
    0 2px 6px color-mix(in oklch, var(--fg) 5%, transparent),
    0 8px 20px color-mix(in oklch, var(--fg) 6%, transparent);
  --elev-2:
    0 2px 4px color-mix(in oklch, var(--fg) 8%, transparent),
    0 12px 28px color-mix(in oklch, var(--fg) 11%, transparent),
    0 32px 72px color-mix(in oklch, var(--fg) 14%, transparent);

  /* ── motion ───────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-1: 120ms;
  --t-2: 200ms;
  --t-3: 320ms;

  /* ── spacing ──────────────────────────────────────────────────────── */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 28px;
  --s-7: 40px;

  --rail: 236px;
}

/* ── reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-xl); line-height: 1.2; }
h2 { font-size: var(--fs-lg); line-height: 1.3; }
h3 { font-size: var(--fs-md); line-height: 1.4; }
h4 { font-size: var(--fs-sm); line-height: 1.4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: color-mix(in oklch, var(--accent) 22%, transparent); }
::placeholder { color: color-mix(in oklch, var(--muted) 70%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.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;
}

/* ══ APP SHELL ══════════════════════════════════════════════════════ */
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-3);
  border-bottom: 1px solid var(--border);
}
.rail-brand .mark {
  width: 30px; height: 30px; flex: none;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--surface);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.rail-brand .who { min-width: 0; }
.rail-brand .who strong { display: block; font-size: var(--fs-sm); letter-spacing: -0.01em; }
.rail-brand .who span {
  display: block; font-size: var(--fs-xs); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.rail-scroll { flex: 1; overflow-y: auto; padding-bottom: var(--s-3); }
.rail-group { padding: var(--s-4) var(--s-3) 0; }
.rail-group + .rail-group { padding-top: var(--s-3); }
.rail-group > .eyebrow {
  padding-inline: var(--s-2); margin-bottom: 6px; display: flex;
  align-items: center; justify-content: space-between; gap: var(--s-2);
}
.rail-group > .eyebrow em { font-style: normal; color: var(--border-strong); }
.rail-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px var(--s-2);
  border-radius: var(--r-md);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  min-height: 36px;
  transition: background .13s ease, color .13s ease;
}
.rail-link svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.rail-link:hover { background: var(--surface-2); color: var(--fg); }
.rail-link:hover svg { color: var(--fg-2); }
.rail-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.rail-link[aria-current="page"] svg { color: var(--accent); }
.rail-link[aria-current="page"]::before {
  content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px;
  width: 3px; border-radius: var(--r-capsule); background: var(--accent);
}
.rail-link .step {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  margin-left: auto; flex: none; color: var(--border-strong);
}
.rail-link[aria-current="page"] .step { color: var(--accent); }
.rail-link .txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rail-switch {
  margin: var(--s-3) var(--s-3) 0;
  padding: 10px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 2px;
}
.rail-switch .lbl { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
.rail-switch .val { font-size: var(--fs-xs); font-weight: 500; color: var(--fg); }
.rail-foot {
  margin-top: auto;
  padding: var(--s-3) var(--s-4) var(--s-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--muted);
}

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--s-3) var(--s-6);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  flex-wrap: wrap;
}
.topbar .crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--muted); }
.topbar .crumbs b { color: var(--fg); font-weight: 500; font-size: var(--fs-sm); }
.topbar-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
/* solid surface + scroll-driven lift replaces the former translucent blur */
@supports (animation-timeline: scroll()) {
  .topbar { animation: topbar-lift linear both; animation-timeline: scroll(); animation-range: 0 80px; }
}
@keyframes topbar-lift { to { box-shadow: var(--elev-1); } }

.canvas { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-5); }
.canvas > header { display: flex; flex-direction: column; gap: var(--s-2); }
.canvas > header .row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }

/* ── patient context banner ─────────────────────────────────────────── */
.ptbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--elev-1);
  padding: var(--s-4) var(--s-5);
  display: flex; align-items: center; gap: var(--s-5);
  flex-wrap: wrap;
}
.ptbar .idblock { display: flex; align-items: center; gap: var(--s-3); min-width: 240px; }
.ptbar .avatar {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-capsule);
  background: var(--surface-2); color: var(--fg-2);
  display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm);
  border: 1px solid var(--border);
}
.ptbar .idblock strong { display: block; font-size: var(--fs-md); letter-spacing: -0.01em; }
.ptbar .idblock span { display: block; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.ptbar .facts { display: flex; gap: var(--s-6); flex-wrap: wrap; }
.ptbar .fact { display: flex; flex-direction: column; gap: 2px; }
.ptbar .fact dt { font-size: var(--fs-xs); color: var(--muted); }
.ptbar .fact dd { margin: 0; font-size: var(--fs-sm); font-weight: 500; }
.ptbar .spacer { margin-left: auto; }

/* ══ CARDS & PANELS ════════════════════════════════════════════════ */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--elev-1);
}
.card { padding: var(--s-5); }
.panel { overflow: hidden; }
.panel > header {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}
.panel > header h3 { font-size: var(--fs-sm); }
.panel > .body { padding: var(--s-5); }
.panel > .body.flush { padding: 0; }
.panel > footer {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}
/* a card nested in a card drops its shadow and sits on the canvas colour */
.card .card, .card .panel, .panel .card, .panel .panel {
  box-shadow: none;
  background: var(--bg);
}

.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.grid-split { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.push { margin-left: auto; }

/* ══ BUTTONS ═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 38px;
  padding: 8px var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--t-1) ease, border-color var(--t-1) ease, box-shadow var(--t-1) ease, transform 50ms ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); box-shadow: var(--elev-1); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--surface);
  box-shadow: var(--elev-1);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--fg); }
.btn--sm { min-height: 30px; padding: 4px var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn--cta { border-radius: var(--r-capsule); padding-inline: var(--s-6); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .5; cursor: not-allowed; box-shadow: none;
}
.btn[disabled]:hover { background: var(--surface); border-color: var(--border-strong); }
.btn--primary[disabled]:hover { background: var(--accent); border-color: var(--accent); }

/* ══ CHIPS, TAGS, STATUS ═══════════════════════════════════════════ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-capsule);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}
.chip--accent { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 28%, transparent); color: var(--accent); }
.chip--quiet { background: transparent; color: var(--muted); }
.chip .dot { width: 6px; height: 6px; border-radius: var(--r-capsule); background: currentColor; flex: none; }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

/* status ladder pill — mirrors the API status enums */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-capsule);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.status::before { content: ''; width: 6px; height: 6px; border-radius: var(--r-capsule); background: var(--border-strong); flex: none; }
.status--live::before  { background: var(--accent); }
.status--done::before  { background: var(--crit-p3); }
.status--wait::before  { background: var(--crit-p2); }
.status--stop::before  { background: var(--crit-p1); }
.status--live { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 30%, transparent); background: var(--accent-soft); }

/* ══ CRITICALITY FLAG — the ONLY place triage colour is applied ════ */
.crit-flag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-capsule);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.crit-flag svg { width: 13px; height: 13px; flex: none; }
.crit-flag .lbl { letter-spacing: 0.01em; }
.crit-flag--p3 { color: var(--crit-p3); background: color-mix(in oklch, var(--crit-p3) 12%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p3) 34%, transparent); }
.crit-flag--p2 { color: var(--crit-p2); background: color-mix(in oklch, var(--crit-p2) 12%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p2) 34%, transparent); }
.crit-flag--p1 { color: var(--crit-p1); background: color-mix(in oklch, var(--crit-p1) 12%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p1) 34%, transparent); }
.crit-flag--p0 { color: var(--crit-p0); background: color-mix(in oklch, var(--crit-p0) 12%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p0) 40%, transparent); }
.crit-flag--solid.crit-flag--p0 { background: var(--crit-p0); color: var(--surface); border-color: var(--crit-p0); }
.crit-flag--solid.crit-flag--p1 { background: var(--crit-p1); color: var(--surface); border-color: var(--crit-p1); }
/* three-second rule: active resuscitation/emergent flags carry a slow ring
   pulse so they surface in a peripheral scan; static under reduced motion */
.crit-flag--solid.crit-flag--p0 { animation: crit-ring-p0 2.4s var(--ease-in-out) infinite; }
.crit-flag--solid.crit-flag--p1 { animation: crit-ring-p1 2.4s var(--ease-in-out) infinite; }
@keyframes crit-ring-p0 { 50% { box-shadow: 0 0 0 5px color-mix(in oklch, var(--crit-p0) 20%, transparent); } }
@keyframes crit-ring-p1 { 50% { box-shadow: 0 0 0 5px color-mix(in oklch, var(--crit-p1) 18%, transparent); } }

/* ══ SEMANTIC BANNERS ══════════════════════════════════════════════ */
.banner {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}
.banner svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner .bd { min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.banner strong { font-size: var(--fs-sm); }
.banner p { color: var(--fg-2); }
.banner--stop {
  color: var(--crit-p1);
  border-color: color-mix(in oklch, var(--crit-p1) 38%, transparent);
  background: color-mix(in oklch, var(--crit-p1) 8%, var(--surface));
}
.banner--stop p { color: color-mix(in oklch, var(--crit-p1) 78%, var(--fg)); }
.banner--warn {
  color: var(--crit-p2);
  border-color: color-mix(in oklch, var(--crit-p2) 38%, transparent);
  background: color-mix(in oklch, var(--crit-p2) 9%, var(--surface));
}
.banner--warn p { color: color-mix(in oklch, var(--crit-p2) 76%, var(--fg)); }
.banner--ok {
  color: var(--crit-p3);
  border-color: color-mix(in oklch, var(--crit-p3) 34%, transparent);
  background: color-mix(in oklch, var(--crit-p3) 9%, var(--surface));
}
.banner--ok p { color: color-mix(in oklch, var(--crit-p3) 74%, var(--fg)); }
.banner--info {
  color: var(--accent);
  border-color: color-mix(in oklch, var(--accent) 32%, transparent);
  background: var(--accent-soft);
}
.banner--info p { color: var(--fg-2); }

/* ══ MODEL ADVISORY — never a severity colour, never blocking ══════ */
.advisory {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface-2);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.advisory > .hd {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.advisory > .hd svg { width: 14px; height: 14px; color: var(--fg-2); }
.advisory p { color: var(--fg-2); font-size: var(--fs-sm); }
.advisory ul { margin: 0; padding-left: 18px; color: var(--fg-2); font-size: var(--fs-sm); }
.advisory li + li { margin-top: var(--s-1); }
.model-note {
  font-size: var(--fs-xs);
  color: var(--muted);
  border-top: 1px dashed var(--border-strong);
  padding-top: var(--s-2);
  line-height: 1.45;
}

/* ══ SYNC STATUS ═══════════════════════════════════════════════════ */
.sync-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--muted);
}
.sync-status svg { width: 13px; height: 13px; flex: none; }
.sync-status--ok { color: var(--crit-p3); }
.sync-status--pending { color: var(--crit-p2); }
.sync-status--fail { color: var(--crit-p1); }

/* ══ TABLES ════════════════════════════════════════════════════════ */
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th, .tbl td { padding: 10px var(--s-4); text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl thead th {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); position: sticky; top: 0; z-index: 1;
}
.tbl tbody tr { transition: background var(--t-1) ease; }
.tbl tbody tr:hover, .tbl tbody tr:focus-within { background: var(--surface-2); }
.tbl tbody tr[data-selected="true"] { background: var(--accent-soft); }
.tbl .n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.tbl .shrink { width: 1%; white-space: nowrap; }
.tbl tfoot td { border-bottom: 0; border-top: 1px solid var(--border-strong); font-weight: 600; }

/* ══ FORM CONTROLS ═════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: var(--fs-xs); color: var(--fg-2); font-weight: 500; }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .err { font-size: var(--fs-xs); color: var(--crit-p1); display: none; align-items: center; gap: 4px; }
.field[data-invalid="true"] .err { display: flex; }
.field[data-invalid="true"] .input,
.field[data-invalid="true"] .select,
.field[data-invalid="true"] .textarea { border-color: var(--crit-p1); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
  transition: border-color var(--t-1) ease, box-shadow var(--t-1) ease;
}
.input:hover:not(:disabled):not(:focus),
.select:hover:not(:disabled):not(:focus),
.textarea:hover:not(:disabled):not(:focus) { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 16%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--muted); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.check { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-sm); cursor: pointer; min-height: 24px; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.check span { color: var(--fg-2); }

/* segmented filter control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; color: var(--fg-2);
  padding: 5px var(--s-3); border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 500; min-height: 28px;
}
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--elev-1); }

/* ══ TABS ══════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 10px var(--s-4); font-size: var(--fs-sm); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: 40px;
}
.tabs button { transition: color var(--t-1) ease, border-color var(--t-1) ease; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel { padding: var(--s-5); }
.tabpanel[hidden] { display: none; }
.tabpanel:not([hidden]) { animation: rise-in var(--t-2) var(--ease-out); }
@keyframes rise-in { from { opacity: 0; transform: translateY(4px); } }

/* ══ TIMELINE / JOURNEY ════════════════════════════════════════════ */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 58px 20px minmax(0, 1fr); gap: var(--s-3); padding-bottom: var(--s-5); position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item .when { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); padding-top: 2px; }
.tl-item .marker { display: flex; flex-direction: column; align-items: center; }
.tl-item .marker i {
  width: 10px; height: 10px; border-radius: var(--r-capsule);
  background: var(--surface); border: 2px solid var(--border-strong); flex: none; margin-top: 4px;
}
.tl-item[data-state="done"] .marker i { background: var(--accent); border-color: var(--accent); }
.tl-item[data-state="now"] .marker i { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-item .marker span { flex: 1; width: 2px; background: var(--border); margin-top: var(--s-1); border-radius: var(--r-capsule); }
.tl-item:last-child .marker span { display: none; }
.tl-item .what { min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.tl-item .what strong { font-size: var(--fs-sm); }
.tl-item .what p { font-size: var(--fs-xs); color: var(--muted); }

/* ══ VITALS / METRIC TILES ═════════════════════════════════════════ */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: var(--s-3); }
.tile {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  padding: var(--s-3) var(--s-4);
  display: flex; flex-direction: column; gap: 2px;
}
.tile dt { font-size: var(--fs-xs); color: var(--muted); }
.tile dd { margin: 0; font-family: var(--font-mono); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile dd small { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-body); margin-left: 3px; }
.tile .ref { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.tile[data-flag="abnormal"] { border-color: color-mix(in oklch, var(--crit-p2) 40%, transparent); background: color-mix(in oklch, var(--crit-p2) 5%, var(--surface)); }
.tile[data-flag="critical"] { border-color: color-mix(in oklch, var(--crit-p1) 45%, transparent); background: color-mix(in oklch, var(--crit-p1) 5%, var(--surface)); }
.tile[data-flag="critical"] dd { color: var(--crit-p1); }

/* ══ DIALOG ════════════════════════════════════════════════════════ */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--elev-2);
  padding: 0;
  background: var(--surface);
  color: var(--fg);
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
}
dialog::backdrop { background: color-mix(in oklch, var(--fg) 48%, transparent); }
dialog[open] { animation: dialog-in var(--t-3) var(--ease-out); }
dialog[open]::backdrop { animation: backdrop-in var(--t-3) ease; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes backdrop-in { from { opacity: 0; } }
dialog > header { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
dialog > .body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); max-height: 62vh; overflow-y: auto; }
dialog > footer { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--surface-2); display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; }
dialog.wide { width: min(880px, calc(100vw - 32px)); }

/* ══ TOAST ═════════════════════════════════════════════════════════ */
.toasts { position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 60; display: flex; flex-direction: column; gap: var(--s-2); max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--fg-deep); color: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--elev-2);
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm);
  display: flex; align-items: flex-start; gap: var(--s-2);
  animation: toast-in var(--t-3) var(--ease-out);
}
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ══ MISC ══════════════════════════════════════════════════════════ */
.kv { display: grid; grid-template-columns: minmax(120px, auto) minmax(0, 1fr); gap: var(--s-2) var(--s-4); font-size: var(--fs-sm); }
.kv dt { color: var(--muted); font-size: var(--fs-xs); align-self: center; }
.kv dd { margin: 0; }
.bedgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: var(--s-3); }
.bed {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg); padding: var(--s-3);
  display: flex; flex-direction: column; gap: var(--s-1);
  text-align: left; min-height: 92px;
  transition: border-color var(--t-1) ease, background var(--t-1) ease, box-shadow var(--t-1) ease;
}
.bed .no { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; }
.bed .who { font-size: var(--fs-xs); color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bed .st { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); margin-top: auto; }
.bed[data-status="available"] { border-style: dashed; border-color: var(--border-strong); }
.bed[data-status="available"]:hover { border-color: var(--accent); background: var(--accent-soft); cursor: pointer; }
.bed[data-status="occupied"] { background: var(--surface); box-shadow: var(--elev-1); }
.bed[data-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 18%, transparent); }

.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ══ PAGE HEADER ═══════════════════════════════════════════════════ */
.pagehead { display: flex; flex-direction: column; gap: var(--s-3); }
.pagehead .top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-5); flex-wrap: wrap; }
.pagehead .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 74ch; }
.pagehead h1 { font-size: var(--fs-xl); line-height: 1.18; }
.pagehead .lede { font-size: var(--fs-sm); color: var(--fg-2); line-height: 1.6; }
.pagehead .actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.pagehead::after { content: ''; height: 1px; background: var(--border); }
.pagehead .eyebrow { display: inline-flex; align-items: center; gap: 8px; }
.pagehead .eyebrow::before {
  content: ''; width: 14px; height: 2px; border-radius: var(--r-capsule);
  background: var(--accent); flex: none;
}

/* ══ METRIC TILE ═══════════════════════════════════════════════════ */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: var(--s-4); }
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--elev-1);
  padding: var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: 4px;
}
.metric .k { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: 6px; }
.metric .k svg { width: 14px; height: 14px; }
.metric .v {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.03em; line-height: 1.1;
}
.metric .v small { font-size: var(--fs-sm); color: var(--muted); font-family: var(--font-body); font-weight: 400; margin-left: 3px; }
.metric .sub { font-size: var(--fs-xs); color: var(--muted); }
.metric--accent { border-color: color-mix(in oklch, var(--accent) 30%, transparent); background: var(--accent-soft); }
.metric--accent .v { color: var(--accent); }
/* drill-through metrics (rendered as <a>/<button>) lift on hover */
a.metric, button.metric { cursor: pointer; text-align: left; transition: border-color var(--t-1) ease, box-shadow var(--t-2) var(--ease-out), transform var(--t-2) var(--ease-out); }
a.metric:hover, button.metric:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--elev-2); }

/* ══ BAR WITH THRESHOLD MARKER ═════════════════════════════════════ */
.bar {
  position: relative;
  height: 8px; border-radius: var(--r-capsule);
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  min-width: 92px;
}
.bar .fill { height: 100%; background: var(--accent); border-radius: var(--r-capsule); }
.bar .fill--quiet { background: var(--border-strong); }
.bar-wrap { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.bar-outer .mark {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: var(--fg-2); border-radius: var(--r-capsule);
}
.bar-wrap .cap { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.bar-outer { position: relative; }

/* ══ DONUT ═════════════════════════════════════════════════════════ */
.donut { display: flex; align-items: center; gap: var(--s-4); }
.donut svg { width: 92px; height: 92px; flex: none; transform: rotate(-90deg); }
.donut .track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.donut .arc   { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; }
.donut .mid { display: flex; flex-direction: column; gap: 2px; }
.donut .mid b { font-family: var(--font-mono); font-size: var(--fs-lg); letter-spacing: -0.02em; }
.donut .mid span { font-size: var(--fs-xs); color: var(--muted); }

/* ══ AVATAR ════════════════════════════════════════════════════════ */
.avatar {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-capsule);
  background: var(--surface-2); color: var(--fg-2);
  display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm);
  border: 1px solid var(--border);
}
.avatar--sm { width: 30px; height: 30px; font-size: var(--fs-xs); }
.avatar--accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklch, var(--accent) 26%, transparent); }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person .nm { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.person .nm b { font-size: var(--fs-sm); font-weight: 500; }
.person .nm span { font-size: var(--fs-xs); color: var(--muted); }

/* ══ STOCK / LICENCE FLAG — semantic alert, always icon + label ════ */
.sig {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-capsule);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.sig svg { width: 12px; height: 12px; flex: none; }
.sig--ok   { color: var(--crit-p3); background: color-mix(in oklch, var(--crit-p3) 11%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p3) 30%, transparent); }
.sig--warn { color: var(--crit-p2); background: color-mix(in oklch, var(--crit-p2) 11%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p2) 30%, transparent); }
.sig--stop { color: var(--crit-p1); background: color-mix(in oklch, var(--crit-p1) 11%, var(--surface)); border-color: color-mix(in oklch, var(--crit-p1) 32%, transparent); }

/* ══ AUTH ══════════════════════════════════════════════════════════ */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); min-height: 100vh; }
.auth-brand {
  background: var(--fg-deep); color: var(--surface);
  padding: var(--s-7) clamp(32px, 5vw, 72px);
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-7);
}
.auth-brand .lock { display: flex; align-items: center; gap: var(--s-3); }
.auth-brand .lock .mark {
  width: 38px; height: 38px; border-radius: var(--r-md); background: var(--accent);
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-md);
}
.auth-brand h1 { font-size: var(--fs-xl); line-height: 1.2; letter-spacing: -0.025em; max-width: 18ch; }
.auth-brand p { color: var(--border-strong); font-size: var(--fs-sm); line-height: 1.65; max-width: 46ch; }
.auth-brand .rulelist { display: flex; flex-direction: column; gap: var(--s-3); }
.auth-brand .rulelist div { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); color: var(--border-strong); }
.auth-brand .rulelist svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--accent); }
.auth-brand .rulelist b { color: var(--surface); font-weight: 500; }
.auth-form { background: var(--surface); padding: var(--s-7) clamp(24px, 4vw, 56px); display: flex; flex-direction: column; justify-content: center; gap: var(--s-5); }
.auth-form .pick { display: flex; flex-direction: column; gap: var(--s-2); }
.pickrow {
  display: flex; align-items: center; gap: var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px var(--s-3); background: var(--surface); text-align: left; width: 100%;
  min-height: 56px; transition: border-color .13s ease, background .13s ease;
}
.pickrow:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pickrow[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pickrow .nm { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.pickrow .nm b { font-size: var(--fs-sm); font-weight: 500; }
.pickrow .nm span { font-size: var(--fs-xs); color: var(--muted); }

/* ══ TRACK CARD (workflow complexity) ══════════════════════════════ */
.tracks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
.track {
  display: flex; flex-direction: column; gap: var(--s-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--elev-1);
  padding: var(--s-5); text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.track:hover { border-color: var(--border-strong); box-shadow: var(--elev-2); transform: translateY(-2px); }
.track[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--elev-2); }
.track[aria-pressed="true"] .rungs i { background: var(--accent); }
.track .rungs { display: flex; gap: 3px; align-items: flex-end; height: 18px; }
.track .rungs i { width: 8px; border-radius: 2px; background: var(--border-strong); display: block; }
.track .rungs i:nth-child(1) { height: 7px; }
.track .rungs i:nth-child(2) { height: 12px; }
.track .rungs i:nth-child(3) { height: 18px; }
.track .rungs i[data-off="1"] { background: var(--border); }
.track h3 { font-size: var(--fs-md); }
.track p { font-size: var(--fs-sm); color: var(--muted); flex: 1; line-height: 1.6; }
.track .meta { display: flex; gap: var(--s-3); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }

/* ══ RICHER EMPTY STATE ════════════════════════════════════════════ */
.emptystate { padding: var(--s-7) var(--s-5); text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.emptystate svg { width: 22px; height: 22px; margin: 0 auto var(--s-2); color: var(--border-strong); }

/* ══ DETAIL DRAWER ═════════════════════════════════════════════════ */
.drawer { position: sticky; top: 74px; }

/* ══ CHARTS ════════════════════════════════════════════════════════
   One data hue only (the accent). The recessive neutral is used solely
   for the previous-period reference series. Grid and axes stay quiet;
   values wear text tokens, never the series colour. */
.figure { margin: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.fig-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.fig-title { font-size: var(--fs-sm); font-weight: 600; letter-spacing: -0.01em; }
.fig-tools { display: flex; align-items: center; gap: var(--s-3); }
.fig-note { font-size: var(--fs-xs); color: var(--muted); }
.fig-legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--fg-2); }
.fig-legend span { display: inline-flex; align-items: center; gap: 6px; }
.fig-legend .dot { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); flex: none; }
.fig-legend .dot--quiet { background: var(--border-strong); }
.fig-body[hidden], .fig-table[hidden] { display: none; }

/* columns */
.chart-cols { display: flex; align-items: flex-end; gap: var(--s-3); height: 188px; }
.col-group { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.col-val { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; min-height: 15px; }
.col-group--now .col-val { color: var(--fg); font-weight: 600; }
.col-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.col-bar {
  flex: 1; max-width: 26px; min-height: 3px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: filter .12s ease;
}
.col-bar:hover, .col-bar:focus-visible { filter: brightness(0.92); outline: none; }
.col-bar--quiet { background: var(--border-strong); }
.col-x { font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }

/* area */
.chart-areawrap { position: relative; padding-right: 52px; }
.chart-area { width: 100%; height: 160px; overflow: visible; }
.chart-area .grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-area .fill { fill: color-mix(in oklch, var(--accent) 14%, transparent); }
.chart-area .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-area .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-area .hot { fill: transparent; }
.chart-area .hot:hover, .chart-area .hot:focus-visible { fill: color-mix(in oklch, var(--accent) 7%, transparent); outline: none; }
.chart-x { display: flex; justify-content: space-between; margin-top: 6px; padding-right: 52px; font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); }
.chart-scale {
  position: absolute; right: 0; top: 0; height: 160px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--muted); font-family: var(--font-mono); text-align: right;
}

/* shares — composition without categorical hues */
.shares { display: flex; flex-direction: column; gap: 10px; }
.share-row { display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(80px, 2fr) auto auto; gap: var(--s-3); align-items: center; }
.share-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--r-xs); }
.share-k { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-track { height: 10px; border-radius: var(--r-capsule); background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.share-fill { display: block; height: 100%; background: var(--accent); border-radius: var(--r-capsule); }
.share-v { font-size: var(--fs-sm); text-align: right; min-width: 56px; }
.share-p { font-size: var(--fs-xs); color: var(--muted); text-align: right; min-width: 48px; }

/* target meter */
.target { display: flex; flex-direction: column; gap: 6px; padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.target:last-child { border-bottom: 0; }
.target-hd { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.target-k { font-size: var(--fs-sm); }
.target-row { display: flex; align-items: center; gap: var(--s-3); }
.target-v { font-size: var(--fs-md); font-weight: 600; min-width: 68px; }
.target-v small { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; margin-left: 1px; }
.target-t { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

/* sparkline */
.spark { width: 72px; height: 20px; flex: none; overflow: visible; }
.spark .line { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark .pt { fill: var(--accent); }

/* tooltip */
.chart-tip {
  position: absolute; z-index: 70; pointer-events: none;
  background: var(--fg-deep); color: var(--surface);
  border-radius: var(--r-md); box-shadow: var(--elev-2);
  padding: 8px 10px; font-size: var(--fs-xs); line-height: 1.45;
  max-width: 240px;
}
.chart-tip b { font-weight: 600; }

/* ══ RESPONSIVE ════════════════════════════════════════════════════ */
@media (max-width: 1180px) {
  :root { --rail: 66px; }
  .rail-brand .who, .rail-link .txt, .rail-link .step,
  .rail-group > .eyebrow, .rail-switch, .rail-foot { display: none; }
  .rail-brand { justify-content: center; padding-inline: 0; }
  .rail-link { justify-content: center; padding-inline: 0; }
  .rail-group { padding-inline: var(--s-2); }
  .rail-group + .rail-group { border-top: 1px solid var(--border); padding-top: var(--s-3); }
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4, .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
}
@media (max-width: 900px) {
  .grid-2, .grid-split, .grid-4, .tracks { grid-template-columns: minmax(0, 1fr); }
  .canvas { padding: var(--s-4); }
  .topbar { padding: var(--s-3) var(--s-4); }
  .ptbar .facts { gap: var(--s-4); }
  .drawer { position: static; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky; top: 0; z-index: 25; height: auto; flex-direction: row;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); align-items: center;
  }
  .rail-brand { border-bottom: 0; border-right: 1px solid var(--border); }
  .rail-scroll { display: flex; overflow: visible; padding: 0; }
  .rail-group { display: flex; gap: var(--s-1); padding: var(--s-2); }
  .rail-group + .rail-group { border-top: 0; border-left: 1px solid var(--border); padding-top: var(--s-2); }
  .rail-link { min-width: 40px; }
  .rail-link[aria-current="page"]::before { left: 6px; right: 6px; top: auto; bottom: -2px; width: auto; height: 3px; }
  .ptbar { gap: var(--s-3); }
  .ptbar .idblock { min-width: 100%; }
  .tl-item { grid-template-columns: 48px 16px minmax(0, 1fr); }
  .toasts { right: var(--s-3); left: var(--s-3); bottom: var(--s-3); max-width: none; }
  .donut { flex-direction: column; align-items: flex-start; }
}

@media print {
  .rail, .topbar, .toasts { display: none; }
  .app { display: block; }
  body { background: var(--surface); }
  .card, .panel, .metric, .ptbar, .track { box-shadow: none; }
}

/* ══ REAL-PRODUCT SHELL — session, flow, palette, notifications ═══ */
.kbd {
  font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1;
  padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--bg); color: var(--muted); white-space: nowrap;
}
.rail-switch .chg {
  font-size: var(--fs-xs); font-weight: 500; color: var(--accent);
  text-decoration: none; margin-left: var(--s-1);
}
.rail-switch .chg:hover { text-decoration: underline; }
.rail-foot .kbd { border-color: color-mix(in oklch, var(--border) 40%, transparent); background: transparent; }

.topbar-actions { flex-wrap: wrap; }
.userchip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 3px 12px 3px 4px; border: 1px solid var(--border);
  border-radius: var(--r-capsule); background: var(--surface);
  text-decoration: none; color: inherit; max-width: 240px;
  transition: border-color var(--t-2) ease, box-shadow var(--t-2) ease;
}
.userchip:hover { border-color: var(--border-strong); box-shadow: var(--elev-1); }
.userchip .avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600;
  background: color-mix(in oklch, var(--accent) 12%, var(--surface)); color: var(--accent);
}
.userchip .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.userchip .who b { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip .who span { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userchip--off .avatar { background: var(--bg); color: var(--muted); }

.bellwrap { position: relative; display: inline-flex; }
.bell {
  position: relative; width: 34px; height: 34px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--t-2) ease, color var(--t-2) ease;
}
.bell:hover { border-color: var(--border-strong); color: var(--fg); }
.bell svg { width: 17px; height: 17px; }
.bell .badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: var(--r-capsule); background: var(--accent);
  color: var(--surface); font-family: var(--font-mono); font-size: var(--fs-xs);
  line-height: 17px; text-align: center;
}
.notifpanel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: 340px; max-width: 86vw; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--elev-2); overflow: hidden;
}
.notifpanel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
}
.notifpanel header b { font-size: var(--fs-sm); }
.notifpanel .nrow {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); text-decoration: none; color: inherit;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 55%, transparent);
  transition: background var(--t-2) ease;
}
.notifpanel .nrow:hover { background: var(--bg); }
.notifpanel .nrow svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.notifpanel .nrow .nm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notifpanel .nrow .nm b { font-size: var(--fs-sm); font-weight: 500; line-height: 1.35; }
.notifpanel .nrow .nm span { font-size: var(--fs-xs); color: var(--muted); }
.notifpanel footer { padding: var(--s-2) var(--s-3); background: var(--bg); }
.notifpanel footer a {
  display: inline-flex; gap: var(--s-2); align-items: center;
  font-size: var(--fs-xs); color: var(--muted); text-decoration: none; padding: var(--s-1) var(--s-2);
}
.notifpanel footer a:hover { color: var(--fg); }
.notifpanel footer svg { width: 14px; height: 14px; }

/* episode flow bar — sits under the topbar as product chrome */
.flowbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-2) var(--s-5); background: var(--surface);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.flowbar .ep { display: flex; flex-direction: column; line-height: 1.3; flex: none; }
.flowbar .ep .lbl { font-size: var(--fs-xs); color: var(--muted); }
.flowbar .ep b { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.fchips { display: flex; align-items: center; flex: 1; min-width: 0; overflow-x: auto; padding: 2px 0; }
.fchip {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 3px 10px; border: 1px solid var(--border); border-radius: var(--r-capsule);
  font-size: var(--fs-xs); color: var(--muted); text-decoration: none; background: var(--surface);
  transition: border-color var(--t-2) ease, color var(--t-2) ease;
}
.fchip:hover { border-color: var(--border-strong); color: var(--fg); }
.fchip .n { font-family: var(--font-mono); font-size: var(--fs-xs); }
.fchip svg { width: 12px; height: 12px; }
.fchip--done { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 35%, var(--border)); background: color-mix(in oklch, var(--accent) 6%, var(--surface)); }
.fchip--now { color: var(--fg); border-color: var(--accent); font-weight: 600; }
.fchip--here { outline: 2px solid color-mix(in oklch, var(--accent) 30%, transparent); outline-offset: 1px; }
.fjoin { width: 10px; height: 1px; background: var(--border); flex: none; }
.flowbar .act { display: flex; align-items: center; gap: var(--s-2); flex: none; margin-left: auto; }
.flowbar .act .btn svg { width: 14px; height: 14px; }
.fnow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-xs); color: var(--muted); text-decoration: none;
}
.fnow:hover { color: var(--fg); }
.fnow svg { width: 14px; height: 14px; }

/* incoming handoff */
.handoff {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-5);
  background: color-mix(in oklch, var(--accent) 6%, var(--surface));
  border-bottom: 1px solid color-mix(in oklch, var(--accent) 25%, var(--border));
}
.handoff > svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.handoff .msg { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.handoff .msg b { font-size: var(--fs-sm); }
.handoff .msg span { font-size: var(--fs-xs); color: var(--muted); line-height: 1.45; }
.handoff .btn { flex: none; }

/* command palette */
.cmdk {
  position: fixed; inset: 0; z-index: 90;
  background: color-mix(in oklch, var(--fg) 48%, transparent);
  padding: 10vh var(--s-4) 0;
}
.cmdk-box {
  width: min(620px, 100%); margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--elev-2); overflow: hidden;
  animation: dialog-in var(--t-3) var(--ease-out);
}
.cmdk-in {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
}
.cmdk-in svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.cmdk-in input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: var(--fs-md); color: var(--fg); min-width: 0;
}
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: var(--s-2); }
.cmdk-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-md);
  background: transparent; font: inherit; text-align: left; cursor: pointer; color: inherit;
}
.cmdk-item:hover, .cmdk-item[aria-selected="true"] { background: color-mix(in oklch, var(--accent) 8%, var(--surface)); }
.cmdk-item svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.cmdk-item .lbl { font-size: var(--fs-sm); flex: 1; min-width: 0; }
.cmdk-item .hint { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.cmdk-none { padding: var(--s-4); font-size: var(--fs-sm); color: var(--muted); }

@media (max-width: 1180px) {
  .topbar-actions .txt, .topbar-actions .kbd, .userchip .who { display: none; }
  .userchip { padding: 3px; }
  .flowbar .ep { display: none; }
}
@media print {
  .flowbar, .handoff, .cmdk, .notifpanel { display: none; }
}

/* ══ REDUCED MOTION ════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
