/* ============================================================================
   Verity · components.css — the component vocabulary.
   Every interactive component ships default · hover · focus · active ·
   disabled · loading · error. Half a state matrix is not a component.
   ========================================================================== */

/* ── Brand mark. Shared by the console shell and the landing pages. ────── */
.brand { display: flex; align-items: center; gap: var(--s-2); font-weight: 700;
  letter-spacing: -0.02em; font-size: var(--t-h4); color: var(--ink-on-chrome);
  text-decoration: none; flex: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex: none;
  background: var(--brand-fill); color: #fff;
  font-size: 15px; font-weight: 700; font-family: var(--font-mono);
}
.brand:hover { color: #fff; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
  min-width: 0;
}
.card-head {
  padding: var(--card-pad) var(--card-pad) var(--s-3);
  display: flex; align-items: flex-start; gap: var(--s-3); flex-wrap: wrap;
}
.card-head + .card-body { padding-top: 0; }
.card-title { font-size: var(--t-h4); font-weight: 600; min-width: 0; }
.card-sub { font-size: var(--t-meta); color: var(--ink-3); margin-top: 2px; }
.card-body { padding: var(--card-pad); min-width: 0; }
.card-foot {
  padding: var(--s-3) var(--card-pad);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: var(--t-meta); color: var(--ink-3);
}
.card-actions { margin-left: auto; display: flex; gap: var(--s-2); flex: none; }
.card.is-flat { box-shadow: none; }
.card.is-sunk { background: var(--surface-2); box-shadow: none; }

.section-title {
  font-size: var(--t-h3); font-weight: 600; letter-spacing: -0.005em;
  display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap;
}
.section-title .count { font-family: var(--font-mono); font-size: var(--t-body);
  color: var(--ink-3); font-weight: 500; }

/* ── Button ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--control-h); min-width: var(--control-h);
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--t-body); font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background var(--d-hover) var(--ease-out),
              border-color var(--d-hover) var(--ease-out),
              color var(--d-hover) var(--ease-out),
              transform var(--d-press) var(--ease-out);
}
.btn:active { transform: scale(.97); }
.btn .ic { margin: 0 -2px; }

.btn-primary { background: var(--brand-fill); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-ink); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--line-control); color: var(--ink); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-danger { background: var(--st-critical-fill); color: #fff; }
.btn-danger:hover { filter: brightness(.92); color: #fff; }

.btn-sm { height: var(--control-h); padding: 0 var(--s-3); font-size: var(--t-meta); }
[data-density='dense'] .btn-sm { height: 26px; }
.btn-lg { height: 46px; padding: 0 var(--s-6); font-size: var(--t-body-lg); }
.btn-block { width: 100%; }

.btn[disabled], .btn[aria-disabled='true'] {
  opacity: .55; cursor: not-allowed; pointer-events: none;
}
.btn.is-loading { pointer-events: none; position: relative; color: transparent; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
  color: var(--brand-ink);
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* A disabled control loses its border, not its contrast. */
.btn-locked {
  background: var(--surface-2); color: var(--ink-3);
  border-color: var(--line); cursor: not-allowed;
}
.btn-locked:hover { background: var(--surface-2); color: var(--ink-3); }

/* ── Form controls ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.label { font-size: var(--t-meta); font-weight: 600; color: var(--ink-2); }
.hint { font-size: var(--t-meta); color: var(--ink-3); }
.input, .select, .textarea {
  height: var(--control-h); padding: 0 var(--s-3);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-control); border-radius: var(--r-sm);
  font-size: var(--t-body); width: 100%;
  transition: border-color var(--d-hover) var(--ease-out), box-shadow var(--d-hover) var(--ease-out);
}
.textarea { height: auto; min-height: 84px; padding: var(--s-3); line-height: var(--lh-prose); resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  border-color: var(--brand); outline-offset: 0;
}
.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--surface-3); border-color: transparent; color: var(--ink-3); cursor: not-allowed;
}
.input.is-error, .textarea.is-error { border-color: var(--st-critical-fill); }
.error-text { font-size: var(--t-meta); color: var(--st-overdue); display: flex; gap: var(--s-1); align-items: center; }
.select { appearance: none; padding-right: var(--s-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.check { display: inline-flex; align-items: flex-start; gap: var(--s-2); cursor: pointer;
  font-size: var(--t-body); min-height: var(--tap); padding: var(--s-1) 0; }
.check input { width: 18px; height: 18px; accent-color: var(--brand-fill); flex: none; margin-top: 1px; }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px; height: 22px; border-radius: var(--r-full);
  background: var(--line-strong); position: relative; flex: none;
  transition: background var(--d-hover) var(--ease-out);
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: var(--e-1);
  transition: transform var(--d-pop) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--brand-fill); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--brand-ring); outline-offset: 2px; }

/* Segmented control — the handover's two views live here. */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: var(--r-md); border: 1px solid var(--line);
}
.seg-btn {
  height: 30px; padding: 0 var(--s-4); border-radius: var(--r-sm);
  font-size: var(--t-meta); font-weight: 600; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: var(--s-2);
  transition: background var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out);
}
.seg-btn:hover { color: var(--ink); }
.seg-btn[aria-selected='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--e-1); }

/* ── Status chip. Icon + text label + colour, always. Never colour alone. ── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px 0 6px;
  border-radius: var(--r-full);
  font-size: var(--t-micro); font-weight: 600; line-height: 1;
  white-space: nowrap; flex: none;
  border: 1px solid transparent;
}
.chip .ic { width: 13px; height: 13px; flex: none; }
.chip-normal   { color: var(--st-normal);   background: var(--st-normal-fill);   border-color: var(--st-normal-line); }
.chip-watch    { color: var(--st-watch);    background: var(--st-watch-fill);    border-color: var(--st-watch-line); }
.chip-elevated { color: var(--st-elevated); background: var(--st-elevated-fill); border-color: var(--st-elevated-line); }
.chip-urgent   { color: var(--st-urgent);   background: var(--st-urgent-fill);   border-color: var(--st-urgent-line); }
/* The only inverted chip. In greyscale it is the one dark rectangle on the
   page; under any colour-vision deficiency it is the one inverted block. */
.chip-critical { color: var(--st-critical); background: var(--st-critical-fill); border-color: var(--st-critical-line); }
.chip-overdue  { color: var(--st-overdue);  background: var(--hatch-overdue);    border-color: var(--st-overdue-line); }
.chip-resolved { color: var(--st-resolved); background: var(--st-resolved-fill); border-color: var(--st-resolved-line); }
.chip-info     { color: var(--st-info);     background: var(--st-info-fill);     border-color: var(--st-info-line); }
.chip-draft    { color: var(--st-draft);    background: var(--st-draft-fill);    border-color: var(--st-draft-line);
                 border-style: dashed; }
.chip-lg { height: 26px; font-size: var(--t-meta); padding: 0 10px 0 8px; }
.chip-lg .ic { width: 15px; height: 15px; }

/* A plain count badge, not a status. */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-full); background: var(--surface-3); color: var(--ink-2);
  font-family: var(--font-mono); font-size: var(--t-micro); font-weight: 600;
}

/* ── SIGNATURE 1 · Resident identity chip ────────────────────────────────
   The resident is the primary key. One object, four sizes, drawn identically
   in tables, search, citations, timelines, the drawer, print and the phone. */
.res {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-width: 0; text-decoration: none; color: inherit;
}
.res-avatar {
  border-radius: var(--r-full); flex: none;
  display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand);
  font-weight: 700; letter-spacing: .01em;
  border: 1px solid var(--brand-line);
  width: 32px; height: 32px; font-size: var(--t-meta);
}
.res-id { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.res-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-sub {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--t-micro); color: var(--ink-3); white-space: nowrap;
}
.res-room, .res-nhs { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.res-dot { opacity: .55; }
.res-flags { display: inline-flex; gap: 3px; margin-left: 2px; }
.res-flag {
  width: 14px; height: 14px; border-radius: 3px; display: grid; place-items: center;
  background: var(--st-urgent-fill); color: var(--st-urgent); flex: none;
}
.res-flag .ic { width: 10px; height: 10px; }
.res-flag.is-critical { background: var(--st-critical-fill); color: #fff; }

.res-xs .res-avatar { width: 20px; height: 20px; font-size: 9px; }
.res-xs .res-sub { display: none; }
.res-sm .res-avatar { width: 26px; height: 26px; font-size: var(--t-micro); }
.res-lg .res-avatar { width: 48px; height: 48px; font-size: var(--t-h4); }
.res-lg .res-name { font-size: var(--t-h3); }
.res-lg .res-sub { font-size: var(--t-meta); }

a.res:hover .res-name { text-decoration: underline; text-underline-offset: 2px; }
.res.is-restricted .res-nhs { letter-spacing: .08em; }
.res.is-inactive { opacity: .7; }
.res.is-deceased .res-name::after { content: ''; }

/* ── SIGNATURE 2 · Risk score with direction of risk ─────────────────────
   Waterlow high = bad. Braden LOW = bad. A nurse must never have to remember
   which way a scale runs, so the object always says. */
.risk {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); min-width: 0;
}
.risk-value {
  font-family: var(--font-mono); font-size: var(--t-h2); font-weight: 600;
  line-height: 1; flex: none; min-width: 42px; text-align: center;
}
.risk-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.risk-tool { font-size: var(--t-meta); font-weight: 600; color: var(--ink-2); }
.risk-dir {
  font-size: var(--t-micro); color: var(--ink-3);
  display: flex; align-items: center; gap: 4px;
}
.risk-dir .ic { width: 11px; height: 11px; }
.risk-scale { height: 4px; border-radius: 2px; background: var(--surface-3); position: relative;
  margin-top: 2px; overflow: hidden; }
.risk-scale-fill { position: absolute; inset: 0 auto 0 0; border-radius: 2px; }
.risk.is-normal   .risk-value, .risk.is-normal   .risk-scale-fill { color: var(--st-normal);   background-color: var(--st-normal); }
.risk.is-watch    .risk-value, .risk.is-watch    .risk-scale-fill { color: var(--st-watch);    background-color: var(--st-watch); }
.risk.is-elevated .risk-value, .risk.is-elevated .risk-scale-fill { color: var(--st-elevated); background-color: var(--st-elevated); }
.risk.is-urgent   .risk-value, .risk.is-urgent   .risk-scale-fill { color: var(--st-urgent);   background-color: var(--st-urgent); }
.risk.is-critical .risk-value, .risk.is-critical .risk-scale-fill { color: var(--st-critical-fill); background-color: var(--st-critical-fill); }
.risk .risk-value { background: none; }
.risk.is-stale { border-style: dashed; }

/* ── SIGNATURE 3 · NEWS2 aggregate tile ──────────────────────────────────── */
.news2 { display: flex; flex-direction: column; gap: var(--s-3); }
.news2-top { display: flex; align-items: center; gap: var(--s-4); }
.news2-agg {
  width: 76px; height: 76px; border-radius: var(--r-lg); flex: none;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--t-metric); font-weight: 600;
  border: 2px solid;
}
.news2.is-normal   .news2-agg { color: var(--st-normal);   background: var(--st-normal-fill);   border-color: var(--st-normal-line); }
.news2.is-watch    .news2-agg { color: var(--st-watch);    background: var(--st-watch-fill);    border-color: var(--st-watch-line); }
.news2.is-urgent   .news2-agg { color: var(--st-urgent);   background: var(--st-urgent-fill);   border-color: var(--st-urgent-line); }
.news2.is-critical .news2-agg { color: #fff; background: var(--st-critical-fill); border-color: var(--st-critical-fill); }
.news2-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: var(--s-2); }
.news2-cell {
  padding: var(--s-2); border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.news2-cell.scored-1 { border-color: var(--st-elevated-line); background: var(--st-elevated-fill); }
.news2-cell.scored-2 { border-color: var(--st-urgent-line);   background: var(--st-urgent-fill); }
.news2-cell.scored-3 { border-color: var(--st-critical-fill); background: var(--st-urgent-fill); box-shadow: inset 0 -3px 0 var(--st-critical-fill); }
.news2-k { font-size: var(--t-micro); color: var(--ink-3); font-weight: 600; }
.news2-v { font-family: var(--font-mono); font-size: var(--t-h4); font-weight: 600; }
.news2-s { font-size: var(--t-micro); color: var(--ink-3); font-family: var(--font-mono); }

/* ── SIGNATURE 4 · Evidence citation chip ────────────────────────────────
   The product's argument compressed into 18 pixels. Mono, small, NOT link-blue. */
.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 17px; padding: 0 4px; margin: 0 1px;
  border-radius: 4px; vertical-align: 1px;
  background: var(--brand-wash); color: var(--brand);
  border: 1px solid var(--brand-line);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out);
}
.cite:hover, .cite:focus-visible { background: var(--brand-fill); color: var(--brand-ink); border-color: var(--brand-fill); }
.cite.is-active { background: var(--brand-fill); color: var(--brand-ink); border-color: var(--brand-fill); }

/* ── SIGNATURE 5 · Provenance stamp ──────────────────────────────────────
   The human is the author; the AI is metadata. Never collapsible. */
.prov {
  border-top: 1px solid var(--line);
  padding: var(--s-3) 0 0;
  font-size: var(--t-meta); color: var(--ink-3); line-height: var(--lh-prose);
  display: flex; gap: var(--s-2); align-items: flex-start;
}
.prov .ic { flex: none; margin-top: 2px; color: var(--st-draft); }
.prov strong { color: var(--ink-2); font-weight: 600; }
.prov-key { color: var(--ink-2); font-weight: 600; }

/* ── SIGNATURE 6 · Handover card ─────────────────────────────────────────── */
.ho-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.ho-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--card-pad);
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.ho-body { padding: var(--card-pad); }
.ho-text { line-height: var(--lh-prose); color: var(--ink-2); }
.ho-tasks { margin-top: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.ho-task {
  display: flex; align-items: flex-start; gap: var(--s-2);
  font-size: var(--t-meta); color: var(--ink-2);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
}
.ho-task .ic { flex: none; margin-top: 1px; color: var(--ink-3); }
/* Severity as a top band, never a side stripe. */
.ho-card.tone-critical { box-shadow: inset 0 3px 0 var(--st-critical-fill); }
.ho-card.tone-urgent   { box-shadow: inset 0 3px 0 var(--st-urgent); }
.ho-card.tone-elevated { box-shadow: inset 0 3px 0 var(--st-elevated); }
.ho-card.tone-watch    { box-shadow: inset 0 3px 0 var(--st-watch); }

/* ── SIGNATURE 7 · Quality-statement chip ────────────────────────────────── */
.qs {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 7px 0 5px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: var(--t-micro); color: var(--ink-2); text-decoration: none;
  white-space: nowrap; flex: none;
}
.qs-code {
  font-family: var(--font-mono); font-weight: 700; font-size: 10px;
  padding: 1px 3px; border-radius: 3px; background: var(--surface-3); color: var(--ink-2);
}
.qs-S .qs-code { background: #ffe6d7; color: #972a00; }
.qs-E .qs-code { background: #e0f4ff; color: #246099; }
.qs-C .qs-code { background: #f3f2ff; color: #5b558b; }
.qs-R .qs-code { background: #dbfafb; color: #007378; }
.qs-W .qs-code { background: #dffae3; color: #1f6f38; }
[data-theme='dark'] .qs-S .qs-code { background: #462314; color: #e7784b; }
[data-theme='dark'] .qs-E .qs-code { background: #192d41; color: #6aaaea; }
[data-theme='dark'] .qs-C .qs-code { background: #29273b; color: #a6a2d9; }
[data-theme='dark'] .qs-R .qs-code { background: #073234; color: #51bfc5; }
[data-theme='dark'] .qs-W .qs-code { background: #15331c; color: #62bb78; }
a.qs:hover { border-color: var(--line-control); color: var(--ink); }
.qs-n { font-family: var(--font-mono); color: var(--ink-3); }

/* ── SIGNATURE 8 · Offline commit button ─────────────────────────────────── */
.commit { position: relative; }
.commit.is-queued { background: var(--st-elevated-fill); color: var(--st-elevated);
  border-color: var(--st-elevated-line); }
.commit.is-queued:hover { background: var(--st-elevated-fill); color: var(--st-elevated); }
.queue-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px 0 7px; border-radius: var(--r-full);
  background: var(--st-elevated-fill); color: var(--st-elevated);
  border: 1px solid var(--st-elevated-line);
  font-size: var(--t-micro); font-weight: 600; white-space: nowrap;
}
.queue-chip.is-clear { background: var(--st-resolved-fill); color: var(--st-resolved);
  border-color: var(--st-resolved-line); }
.queue-chip .ic { width: 13px; height: 13px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto; overscroll-behavior-x: contain;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.table { font-size: var(--t-body); }
[data-density='dense'] .table { font-size: var(--t-dense); }
.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  font-size: var(--t-micro); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
  padding: var(--s-3) var(--s-4); white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
.table td {
  padding: 0 var(--s-4); height: var(--row-h);
  border-bottom: 1px solid var(--line); color: var(--ink-2); vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--d-hover) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .table tbody tr:hover td { background: var(--surface-3); }
}
.table tbody tr.is-selected td { background: var(--brand-wash); }
/* Overdue rows get a top band and a hatch, never a side stripe. */
.table tbody tr.is-overdue td:first-child { box-shadow: inset 0 3px 0 var(--st-overdue); }
.table .strong { color: var(--ink); font-weight: 500; }
.table-sort { display: inline-flex; align-items: center; gap: 3px; color: inherit;
  font: inherit; text-transform: inherit; letter-spacing: inherit; }
.table-sort:hover { color: var(--ink); }
.row-expand { padding: var(--s-4) !important; height: auto !important; background: var(--surface-2); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-4); font-size: var(--t-meta); }
.dl dt { color: var(--ink-3); font-weight: 600; }
.dl dd { color: var(--ink-2); }

/* ── KPI tile. Deliberately not a hero metric — always carries context. ─── */
.kpi { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--card-pad); }
.kpi-label { font-size: var(--t-meta); color: var(--ink-3); font-weight: 600; }
.kpi-value { font-family: var(--font-mono); font-size: var(--t-h1); font-weight: 600;
  line-height: 1; color: var(--ink); display: flex; align-items: baseline; gap: var(--s-2); }
.kpi-unit { font-size: var(--t-body); color: var(--ink-3); font-weight: 500; font-family: var(--font-ui); }
.kpi-foot { font-size: var(--t-meta); color: var(--ink-3); display: flex; align-items: center; gap: var(--s-2); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono);
  font-size: var(--t-meta); font-weight: 600; }
.delta .ic { width: 12px; height: 12px; }
.delta.is-bad  { color: var(--st-urgent); }
.delta.is-good { color: var(--st-resolved); }
.delta.is-flat { color: var(--ink-3); }

/* ── Timeline ────────────────────────────────────────────────────────────── */
.tl { display: flex; flex-direction: column; }
.tl-day {
  position: sticky; top: calc(var(--topbar-h) + var(--pageheader-h) - 8px);
  z-index: 1; padding: var(--s-3) 0 var(--s-2);
  background: linear-gradient(var(--canvas) 70%, transparent);
  font-size: var(--t-meta); font-weight: 600; color: var(--ink-3);
  display: flex; align-items: baseline; gap: var(--s-3);
}
.tl-day .count { font-family: var(--font-mono); font-weight: 500; }
.tl-item {
  display: grid; grid-template-columns: 58px 26px minmax(0, 1fr);
  gap: var(--s-3); align-items: start;
  padding: var(--s-2) var(--s-3) var(--s-2) 0;
  border-radius: var(--r-sm);
  scroll-margin-top: 140px;
}
.tl-time { font-family: var(--font-mono); font-size: var(--t-meta); color: var(--ink-3);
  text-align: right; padding-top: 3px; font-variant-numeric: tabular-nums; }
.tl-mark {
  width: 26px; height: 26px; border-radius: var(--r-full);
  display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--ink-3); border: 1px solid var(--line);
}
.tl-mark .ic { width: 13px; height: 13px; }
.tl-body { min-width: 0; padding-top: 2px; }
.tl-title { font-weight: 600; color: var(--ink); font-size: var(--t-body); }
.tl-text { color: var(--ink-2); line-height: var(--lh-prose); }
.tl-meta { font-size: var(--t-micro); color: var(--ink-3); margin-top: 3px;
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tl-item.is-narrative .tl-mark { background: var(--surface); border-color: var(--line-strong); color: var(--ink-2); }
.tl-item.tone-urgent   .tl-mark { background: var(--st-urgent-fill); border-color: var(--st-urgent-line); color: var(--st-urgent); }
.tl-item.tone-critical .tl-mark { background: var(--st-critical-fill); border-color: var(--st-critical-fill); color: #fff; }
.tl-item.tone-elevated .tl-mark { background: var(--st-elevated-fill); border-color: var(--st-elevated-line); color: var(--st-elevated); }
.tl-item.tone-info     .tl-mark { background: var(--st-info-fill); border-color: var(--st-info-line); color: var(--st-info); }
/* The deep-link target from a citation. */
.tl-item.is-target {
  background: var(--brand-wash);
  box-shadow: 0 0 0 2px var(--brand-ring);
  animation: pulseIn 600ms var(--ease-out);
}
@keyframes pulseIn { 0% { box-shadow: 0 0 0 6px transparent; } 40% { box-shadow: 0 0 0 6px var(--brand-line); } }
.tl.is-focused .tl-item:not(.is-target):not(.is-neighbour) { opacity: .35; }
.tl-flag {
  margin-top: var(--s-2); padding: var(--s-2) var(--s-3);
  background: var(--st-elevated-fill); border: 1px solid var(--st-elevated-line);
  border-radius: var(--r-sm); font-size: var(--t-meta); color: var(--st-elevated);
  display: flex; gap: var(--s-2); align-items: flex-start;
}
.tl-flag .ic { flex: none; margin-top: 1px; }

/* Return path from a citation — this is what makes people brave enough to click. */
.backbar {
  position: sticky; top: var(--topbar-h); z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--gutter);
  background: var(--brand-wash); border-bottom: 1px solid var(--brand-line);
  font-size: var(--t-meta); color: var(--ink-2);
}

/* ── The AI answer component ─────────────────────────────────────────────── */
.ask-shell { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--gutter); align-items: start; }
@media (max-width: 1023px) { .ask-shell { grid-template-columns: minmax(0, 1fr); } }

.ask-scope {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--card-pad);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: var(--t-meta); color: var(--ink-2);
}
.ask-scope .ic { color: var(--ink-3); }

.ask-input-row { display: flex; gap: var(--s-2); align-items: stretch; }
.ask-input {
  flex: 1 1 auto; height: 46px; padding: 0 var(--s-4);
  font-size: var(--t-body-lg);
  border: 1px solid var(--line-control); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
}
.ask-input:focus-visible { border-color: var(--brand); }
.ask-suggest { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.ask-group-label { font-size: var(--t-micro); font-weight: 600; color: var(--ink-3);
  letter-spacing: .05em; text-transform: uppercase; width: 100%; margin-top: var(--s-2); }
.ask-chip {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: var(--t-meta); color: var(--ink-2); text-align: left;
  transition: border-color var(--d-hover) var(--ease-out), background var(--d-hover) var(--ease-out);
}
.ask-chip:hover { border-color: var(--brand); color: var(--ink); background: var(--brand-wash); }
.ask-chip:active { transform: scale(.98); }

/* The retrieval funnel. This is what separates a retrieval system from a
   chatbot, so it is one of only three places motion earns its place. */
.funnel { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--card-pad); }
.funnel-step {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-meta); color: var(--ink-3);
  opacity: 0; transform: translateY(4px);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out), color 260ms var(--ease-out);
}
.funnel-step.is-on { opacity: 1; transform: none; }
.funnel-step.is-done { color: var(--ink-2); }
.funnel-num { font-family: var(--font-mono); font-weight: 600; color: var(--brand);
  min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }
.funnel-bar { height: 3px; border-radius: 2px; background: var(--surface-3); flex: 1 1 auto; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--brand); width: 0;
  transition: width 400ms var(--ease-out); }

.answer { line-height: var(--lh-prose); color: var(--ink-2); }
.answer h3 { font-size: var(--t-h4); color: var(--ink); margin-bottom: var(--s-2); }
.answer p { margin-bottom: var(--s-4); }
.answer strong { color: var(--ink); font-weight: 600; }
/* Every paragraph carries a source count; unsourced prose is marked as such. */
.answer-para { position: relative; padding-left: var(--s-6); }
.answer-para::before {
  content: ''; position: absolute; left: 0; top: 4px; bottom: var(--s-4);
  width: 2px; border-radius: 1px; background: var(--brand-line);
}
.answer-para.no-source::before { background: var(--line-strong); }
.src-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-micro); color: var(--ink-3); font-weight: 600;
  margin-top: calc(var(--s-2) * -1); margin-bottom: var(--s-4);
  padding-left: var(--s-6);
}
.unsourced {
  text-decoration: underline; text-decoration-style: dotted;
  text-decoration-color: var(--ink-3); text-underline-offset: 3px; cursor: help;
}

.finding {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--card-pad); background: var(--surface);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.finding-n {
  font-family: var(--font-mono); font-weight: 700; font-size: var(--t-meta);
  color: var(--brand); flex: none;
}
.finding-title { font-weight: 600; color: var(--ink); font-size: var(--t-body-lg); line-height: var(--lh-tight); }

/* Evidence panel. */
.ev-panel { position: sticky; top: calc(var(--topbar-h) + var(--s-4)); }
.ev-list { display: flex; flex-direction: column; gap: var(--s-3); max-height: 68vh;
  overflow: hidden auto; padding: var(--s-1); }
.ev-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-3); background: var(--surface); scroll-margin: var(--s-3);
  transition: border-color var(--d-hover) var(--ease-out), box-shadow var(--d-hover) var(--ease-out);
}
.ev-card.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-line); }
.ev-head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.ev-n {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  min-width: 19px; height: 17px; padding: 0 4px; border-radius: 4px;
  background: var(--brand-wash); color: var(--brand); border: 1px solid var(--brand-line);
  display: grid; place-items: center; flex: none;
}
.ev-ref { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--ink-3); }
.ev-text { font-size: var(--t-meta); color: var(--ink-2); line-height: var(--lh-prose); }
.ev-foot { margin-top: var(--s-2); display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-micro); color: var(--ink-3); flex-wrap: wrap; }
.ev-open { display: inline-flex; align-items: center; gap: 3px; color: var(--brand);
  font-weight: 600; text-decoration: none; }
.ev-open:hover { text-decoration: underline; }

/* Abstention. Slate, not red — refusing to answer is correct behaviour. */
.abstain {
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); padding: var(--card-pad);
}
.abstain-head { display: flex; align-items: center; gap: var(--s-2); font-weight: 600;
  color: var(--ink); font-size: var(--t-body-lg); margin-bottom: var(--s-3); }
.abstain-head .ic { color: var(--ink-3); }
.abstain-quote {
  border-left: 2px solid var(--line-strong); padding-left: var(--s-3);
  color: var(--ink); font-weight: 600; margin: var(--s-3) 0;
}

/* DRAFT → REVIEWED → COMMITTED */
.draft-band {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--card-pad);
  background: var(--st-draft-fill); border: 1px dashed var(--st-draft-line);
  border-radius: var(--r-md); color: var(--st-draft); font-size: var(--t-meta);
}
.draft-band .ic { flex: none; }
.diff-pane { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: var(--s-3); }
@media (max-width: 900px) { .diff-pane { grid-template-columns: minmax(0,1fr); } }
.diff-col { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.diff-head { padding: var(--s-2) var(--s-3); background: var(--surface-2);
  border-bottom: 1px solid var(--line); font-size: var(--t-micro);
  font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.diff-body { padding: var(--s-3); font-size: var(--t-meta); line-height: var(--lh-prose); color: var(--ink-2); }
.diff-sent { display: block; padding: 2px 0; }
.diff-sent.is-changed { background: var(--st-elevated-fill); }
.diff-sent.is-removed { background: var(--st-overdue-fill); text-decoration: line-through; opacity: .8; }

/* ── Empty state. Names the action that fills it, never "No data". ──────── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-12) var(--s-6); text-align: center; color: var(--ink-3);
}
.empty-ic { width: 40px; height: 40px; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--surface-3); color: var(--ink-3); }
.empty-title { font-size: var(--t-h4); font-weight: 600; color: var(--ink-2); }
.empty p { max-width: 46ch; font-size: var(--t-body); }

/* ── Skeleton, in the shape of the content. Never a spinner in a panel. ─── */
.sk { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-xs); }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 11px; margin-bottom: var(--s-2); }
.sk-row { height: var(--row-h); margin-bottom: 1px; border-radius: 0; }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2); max-width: 380px; }
.toast {
  background: var(--chrome); color: var(--ink-on-chrome);
  border: 1px solid var(--chrome-line); border-radius: var(--r-md);
  box-shadow: var(--e-3); padding: var(--s-3) var(--s-4);
  font-size: var(--t-meta); line-height: var(--lh-ui);
  transition: transform var(--d-pop) var(--ease-out), opacity var(--d-pop) var(--ease-out);
}
@starting-style { .toast { transform: translateY(8px); opacity: 0; } }
.toast.is-leaving { transform: translateY(8px); opacity: 0; }
.toast-title { font-weight: 600; color: #fff; margin-bottom: 4px; display: flex; align-items: center; gap: var(--s-2); }
.toast ul { margin-top: var(--s-2); display: flex; flex-direction: column; gap: 3px; }
.toast li { color: var(--ink-on-chrome-2); }
.toast a { color: var(--brand-ring); }

/* ── Modal · a last resort. Prefer the drawer, then inline. ─────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: rgba(12,14,19,.55); display: grid; place-items: center; padding: var(--s-4); }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e-3);
  width: min(560px, 100%); max-height: 88vh; overflow: hidden auto;
  border: 1px solid var(--line);
  animation: modalIn var(--d-modal) var(--ease-out);
}
@keyframes modalIn { from { transform: scale(.97); opacity: 0; } }
.modal-head { padding: var(--card-pad); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s-3); }
.modal-body { padding: var(--card-pad); }
.modal-foot { padding: var(--s-3) var(--card-pad); border-top: 1px solid var(--line);
  background: var(--surface-2); display: flex; justify-content: flex-end; gap: var(--s-2); }

/* ── Command palette. Opens instantly — no animation on a keyboard action. ── */
.palette-backdrop { position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(12,14,19,.5); padding-top: 12vh; display: flex; justify-content: center; }
.palette { width: min(620px, calc(100% - 32px)); height: fit-content;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--e-3); overflow: hidden; }
.palette-input { width: 100%; height: 52px; padding: 0 var(--s-4); border: none;
  border-bottom: 1px solid var(--line); font-size: var(--t-body-lg); background: transparent; color: var(--ink); }
.palette-list { max-height: 380px; overflow: auto; padding: var(--s-2); }
.palette-item { display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); width: 100%;
  text-align: left; text-decoration: none; color: var(--ink-2); font-size: var(--t-body); }
.palette-item[aria-selected='true'] { background: var(--brand-wash); color: var(--ink); }
.palette-item .kbd { margin-left: auto; background: var(--surface-3); border-color: var(--line);
  color: var(--ink-3); }
.palette-group { padding: var(--s-3) var(--s-3) var(--s-1); font-size: var(--t-micro);
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: var(--s-3) var(--s-4); font-size: var(--t-body); font-weight: 600;
  color: var(--ink-3); white-space: nowrap; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color var(--d-hover) var(--ease-out);
}
.tab:hover { color: var(--ink-2); }
.tab[aria-selected='true'] { color: var(--brand); border-bottom-color: var(--brand); }

/* ── Critical information banner ─────────────────────────────────────────── */
.critbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-3) var(--card-pad);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.critbar-label { font-size: var(--t-micro); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3); margin-right: var(--s-2); }

/* ── Alert row ───────────────────────────────────────────────────────────── */
.alert-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--card-pad); border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: background var(--d-hover) var(--ease-out);
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--surface-3); }
.alert-main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.alert-title { font-weight: 600; color: var(--ink); line-height: var(--lh-tight); }
.alert-detail { font-size: var(--t-meta); color: var(--ink-3); line-height: var(--lh-ui); }
.alert-row.is-critical { background: var(--st-urgent-fill); }
.alert-row.is-critical:hover { background: var(--st-urgent-fill); filter: brightness(.98); }

/* ── Definition rows used across detail screens ──────────────────────────── */
.rows { display: flex; flex-direction: column; }
.drow {
  display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr);
  gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--line);
  font-size: var(--t-body);
}
.drow:last-child { border-bottom: none; }
.drow dt { color: var(--ink-3); font-weight: 600; font-size: var(--t-meta); }
.drow dd { color: var(--ink-2); min-width: 0; }
/* Narrow cards stack rather than squeezing the value into nine pixels. */
.card-body, .drawer-body { container-type: inline-size; }
@container (max-width: 380px) {
  .drow { grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }
}
@media (max-width: 599px) { .drow { grid-template-columns: minmax(0,1fr); gap: var(--s-1); } }

/* ── Quote — a resident's own words, used verbatim ───────────────────────── */
.quote {
  border-left: 3px solid var(--brand-line); padding: var(--s-2) 0 var(--s-2) var(--s-4);
  color: var(--ink); font-size: var(--t-body-lg); line-height: var(--lh-prose);
}
.quote-attr { display: block; margin-top: var(--s-2); font-size: var(--t-meta);
  color: var(--ink-3); font-style: normal; }

/* ── Body map ────────────────────────────────────────────────────────────── */
.bodymap { position: relative; width: 100%; max-width: 260px; margin: 0 auto; }
.bodymap svg { width: 100%; height: auto; }
.bm-pin {
  position: absolute; width: 24px; height: 24px; margin: -12px 0 0 -12px;
  border-radius: var(--r-full); border: 2px solid var(--surface);
  display: grid; place-items: center; cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  box-shadow: var(--e-2);
  transition: transform var(--d-press) var(--ease-out);
}
.bm-pin:hover { transform: scale(1.14); }
.bm-pin.is-urgent   { background: var(--st-urgent);   color: #fff; }
.bm-pin.is-critical { background: var(--st-critical-fill); color: #fff; }
.bm-pin.is-elevated { background: var(--st-elevated); color: #fff; }
.bm-pin.is-resolved { background: var(--st-resolved); color: #fff; }

/* ── MAR grid. Scrolls in its own container with a frozen medication column
   even on a phone. A MAR that stacks is not a MAR. ─────────────────────── */
.mar-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); }
.mar { min-width: 620px; }
.mar th, .mar td { border-bottom: 1px solid var(--line); }
.mar th { background: var(--surface-2); padding: var(--s-2) var(--s-3);
  font-size: var(--t-micro); text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 600; white-space: nowrap; }
.mar td { padding: var(--s-2) var(--s-3); height: 60px; }
.mar .mar-med { position: sticky; left: 0; background: var(--surface); z-index: 1;
  min-width: 210px; box-shadow: 1px 0 0 var(--line); }
.mar th.mar-med { background: var(--surface-2); z-index: 3; }
.mar-name { font-weight: 600; color: var(--ink); }
.mar-dose { font-family: var(--font-mono); font-size: var(--t-micro); color: var(--ink-3); }
.mar-cell {
  width: 100%; height: 44px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-family: var(--font-mono); font-size: var(--t-meta); color: var(--ink-3);
  transition: border-color var(--d-hover) var(--ease-out);
}
.mar-cell:hover { border-color: var(--line-control); }
.mar-cell .code { font-size: var(--t-h4); font-weight: 600; line-height: 1; }
.mar-cell .who { font-size: 9px; }
.mar-cell.st-resolved { background: var(--st-resolved-fill); border-color: var(--st-resolved-line); color: var(--st-resolved); }
.mar-cell.st-elevated { background: var(--st-elevated-fill); border-color: var(--st-elevated-line); color: var(--st-elevated); }
.mar-cell.st-urgent   { background: var(--st-urgent-fill);   border-color: var(--st-urgent-line);   color: var(--st-urgent); }
.mar-cell.st-overdue  { background: var(--hatch-overdue);    border-color: var(--st-overdue-line);  color: var(--st-overdue); }
.mar-cell.st-info     { background: var(--st-info-fill);     border-color: var(--st-info-line);     color: var(--st-info); }
.mar-cell.st-watch    { background: var(--st-watch-fill);    border-color: var(--st-watch-line);    color: var(--st-watch); }
.mar-cell.st-normal   { background: var(--surface-2); }
.mar-empty { color: var(--ink-3); text-align: center; opacity: .4; }

/* ── Progress / meter ────────────────────────────────────────────────────── */
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.meter.is-urgent span   { background: var(--st-urgent); }
.meter.is-critical span { background: var(--st-critical-fill); }
.meter.is-resolved span { background: var(--st-resolved); }
.meter.is-elevated span { background: var(--st-elevated); }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.tip {
  position: fixed; z-index: var(--z-tooltip);
  background: var(--chrome); color: var(--ink-on-chrome);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: var(--t-micro); max-width: 280px; line-height: var(--lh-ui);
  box-shadow: var(--e-2); pointer-events: none;
  transition: opacity var(--d-pop) var(--ease-out), transform var(--d-pop) var(--ease-out);
}
@starting-style { .tip { opacity: 0; transform: scale(.97); } }

/* ── Menu / popover. Scales from its trigger, never from centre. ─────────── */
.menu {
  position: absolute; z-index: var(--z-dropdown);
  min-width: 200px; padding: var(--s-2);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--e-2);
  transform-origin: var(--menu-origin, top left);
  animation: menuIn var(--d-pop) var(--ease-out);
}
@keyframes menuIn { from { transform: scale(.97); opacity: 0; } }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm);
  font-size: var(--t-body); color: var(--ink-2); text-align: left; text-decoration: none;
}
.menu-item:hover { background: var(--surface-3); color: var(--ink); }
.menu-item[aria-current='true'] { color: var(--brand); font-weight: 600; }
.menu-sep { height: 1px; background: var(--line); margin: var(--s-2) 0; }
.menu-label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--t-micro);
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }

/* ── Notes ───────────────────────────────────────────────────────────────── */
.note-box {
  padding: var(--s-3) var(--card-pad); border-radius: var(--r-md);
  font-size: var(--t-meta); line-height: var(--lh-prose);
  display: flex; gap: var(--s-3); align-items: flex-start;
}
.note-box .ic { flex: none; margin-top: 2px; }
.note-info     { background: var(--st-info-fill);     border: 1px solid var(--st-info-line);     color: var(--st-info); }
.note-elevated { background: var(--st-elevated-fill); border: 1px solid var(--st-elevated-line); color: var(--st-elevated); }
.note-urgent   { background: var(--st-urgent-fill);   border: 1px solid var(--st-urgent-line);   color: var(--st-urgent); }
.note-critical { background: var(--st-critical-fill); border: 1px solid var(--st-critical-fill); color: #fff; }
.note-draft    { background: var(--st-draft-fill);    border: 1px dashed var(--st-draft-line);   color: var(--st-draft); }
.note-box strong { color: inherit; font-weight: 700; }

/* ── Charts ──────────────────────────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-3);
  font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .series { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; }
.chart .band { opacity: .5; }
.spark { display: inline-block; vertical-align: middle; }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--t-micro); color: var(--ink-3); }
.legend-key { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

/* ── Heat matrix (CQC evidence coverage) ─────────────────────────────────── */
.heat { border-collapse: separate; border-spacing: 2px; }
.heat td, .heat th { padding: 0; }
.heat-cell {
  width: 34px; height: 26px; border-radius: var(--r-xs);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--t-micro); font-weight: 600;
  cursor: default;
}
.heat-0 { background: var(--hatch-gap); color: var(--ink-3); border: 1px dashed var(--line-strong); }
.heat-1 { background: var(--heat-1); color: var(--ink); }
.heat-2 { background: var(--heat-2); color: var(--ink); }
.heat-3 { background: var(--heat-3); color: var(--ink); }
.heat-4 { background: var(--heat-4); color: var(--ink-inv); }
.heat-5 { background: var(--heat-5); color: var(--ink-inv); }
[data-theme='dark'] .heat-1, [data-theme='dark'] .heat-2, [data-theme='dark'] .heat-3 { color: var(--ink); }
[data-theme='dark'] .heat-4, [data-theme='dark'] .heat-5 { color: var(--ink); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--line); }
.pill-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.scroll-x { overflow-x: auto; overscroll-behavior-x: contain; }
