/* ===================================================================
   features.css — per-tab styling for the redesign
   ===================================================================

   Loads after app.css. One section per tab, added as each phase converts
   one. Everything reads from tokens.css; no colour literals.

   These sections RESTYLE the existing markup rather than replacing it.
   script.js addresses this page by id, class and data-attribute and is
   not being restructured, so the class names below are the ones already
   in index.html — .cc-kpi, .cc-cap-fill, .cc-conf-chip and the rest. The
   canvas and the current markup happen to agree on structure in the
   places that matter (a five-cell KPI band, a label/track/fill/count/pct
   capture row), which is why this is mostly a repaint.
   =================================================================== */

/* ═══ Referral Capture (#tab-compliance) ═══════════════════════════ */

.cc-page:not(.tab-panel-hidden) {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--ink);
}

/* ── Title bar ───────────────────────────────────────────────────── */
.cc-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  background: transparent;
}
.cc-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.cc-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-2);
}
.cc-titlebar-actions { display: flex; gap: 8px; }

/* Ghost + primary buttons, matched to .srx-btn so the tab agrees with the
   shared component set without needing its markup changed. */
.cc-ghost-btn,
.cc-primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.cc-ghost-btn {
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
}
.cc-ghost-btn:hover { background: var(--surface-3); }
.cc-primary-btn {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.cc-primary-btn:hover:not(:disabled) { background: var(--accent-strong); }
.cc-primary-btn:disabled,
.cc-ghost-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--ink-3);
}
.cc-ghost-icon, .cc-btn-icon { font-size: 12px; line-height: 1; }

/* ── Toolbar: upload strip + filters ─────────────────────────────── */
.cc-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.cc-toolbar-left,
.cc-toolbar-right {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.cc-toolbar-right { margin-left: auto; }
.cc-toolbar-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border);
}

/* The claims drop zone. Dashed, per the canvas, so it reads as a target
   rather than as another button. Visible only to users the server's
   allowlist admits — see /api/session_status.can_upload_claims. */
.cc-upload {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 11px;
  border: 1px dashed var(--border-dash);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.cc-upload:hover {
  border-color: var(--accent-border);
  background: var(--accent-tint);
}
.cc-upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border-soft);
  color: var(--accent-ink);
  font-size: 14px;
}
.cc-upload:hover .cc-upload-icon { background: var(--surface); }
.cc-upload-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* Both of these carried light-on-dark literals (#e7ecf3) in the old
   stylesheet, which vanish against a white card — colour has to be
   re-stated here, not just size. */
.cc-upload-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.cc-upload-sub {
  font-size: 12px;
  color: var(--ink-3);
  max-width: none;
}
.cc-upload-clear {
  display: none;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
.cc-upload.has-file .cc-upload-clear { display: block; }
.cc-upload-clear:hover { color: var(--red); border-color: var(--red); }

/* ── Fields ──────────────────────────────────────────────────────── */
.cc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cc-field > label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cc-input,
.cc-select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.cc-input:focus,
.cc-select:focus { border-color: var(--accent-border); }
.cc-select { cursor: pointer; }
.cc-select-wrap { position: relative; display: flex; }
.cc-filter-status {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}
.cc-filter-status:empty { display: none; }

/* ── KPI band ────────────────────────────────────────────────────── */
/* One card divided into five, rather than five cards — the canvas reads
   these as a single strip and the hairlines keep the row scannable. */
.cc-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  /* visible, not hidden: the Total Claims tooltip hangs out of the strip. Every
     cell is transparent and only this element paints, so there is nothing for a
     clip to tidy up at the rounded corners anyway. */
  overflow: visible;
}
.cc-kpi {
  padding: 16px 18px;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: transparent;
  border-radius: 0;
  min-width: 0;
}
.cc-kpi:first-child { border-left: 0; }
.cc-kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.cc-kpi-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
  /* The tooltip's anchor sits inside this label, so this must not clip either.
     The ellipsis it used to pair with never applied anyway — text-overflow does
     nothing on an inline-flex box — and these labels are fixed, short strings. */
  overflow: visible;
}
/* The per-card glyphs were carrying the colour story in the old design.
   The canvas uses one accent and lets the numbers do the work. */
.cc-kpi-icon { display: none; }
.cc-kpi-body {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.cc-kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cc-kpi-sub,
.cc-kpi-scope {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}
/* Only the two money/outcome cards keep an accent; the rest read neutral
   so the accent still means something. */
.cc-val-green, .cc-val-green2 { color: var(--accent-ink); }
.cc-val-amber { color: var(--ink); }
.cc-kpi-accent-green, .cc-kpi-accent-green2, .cc-kpi-accent-amber { background: transparent; }

/* The KPI tooltip predates the shared .srx-tip; give it the same look. */
.cc-kpi-info-wrap { position: relative; display: inline-flex; }
.cc-kpi-info {
  width: 16px;
  height: 16px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-4);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
  text-transform: none;
  letter-spacing: 0;
}
.cc-kpi-info-wrap:hover .cc-kpi-info,
.cc-kpi-info-wrap:focus-within .cc-kpi-info {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.cc-kpi-tip {
  display: none;
  position: absolute;
  top: 24px;
  left: -6px;
  /* style.css anchors this ABOVE the icon and fades it with opacity/visibility.
     This one hangs below and toggles `display`, so the legacy anchor and fade
     have to be cleared or the box is stretched between the two and stays
     transparent. */
  bottom: auto;
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 30;
  width: 240px;
  max-width: none;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px var(--shadow);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
  white-space: normal;
  /* Legacy centred a one-line tip; this one wraps, and prose reads left. */
  text-align: left;
}
/* Legacy draws a dark navy arrow under the tip it anchored above the icon. */
.cc-kpi-tip::after { content: none; }
.cc-kpi-info-wrap:hover .cc-kpi-tip,
.cc-kpi-info-wrap:focus-within .cc-kpi-tip { display: block; }

/* ── "How claims were captured" ──────────────────────────────────── */
.cc-capture-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.cc-capture-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.cc-capture-titles { display: flex; flex-direction: column; gap: 3px; }
.cc-capture-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.cc-capture-hint { font-size: 12.5px; color: var(--ink-3); }
.cc-capture-badge {
  padding: 4px 9px;
  border: 1px solid var(--accent-border-soft);
  border-radius: var(--r-sm);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.cc-capture-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 40px;
}
.cc-cap-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  margin: 0 -8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.cc-cap-row:hover { background: var(--surface-3); }
.cc-cap-row.match-method-row-active { background: var(--accent-tint); }
.cc-cap-name {
  width: 132px;
  flex: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.cc-cap-track {
  flex: 1;
  min-width: 0;
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
}
.cc-cap-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.25s ease;
}
.cc-cap-count {
  width: 26px;
  flex: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.cc-cap-pct {
  width: 46px;
  flex: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

/* ── Confidence chips ────────────────────────────────────────────── */
.cc-confidence-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.cc-confidence-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.cc-conf-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.cc-conf-chip:hover { border-color: var(--accent-border); color: var(--ink); }
.cc-conf-chip.cc-conf-chip-active {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 500;
}
.cc-conf-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
/* One dot colour per confidence tier — the only place the tier is named
   without words, so it has to stay distinguishable. */
.cc-conf-chip-exact .cc-conf-dot { background: var(--accent-strong); }
.cc-conf-chip-manual .cc-conf-dot { background: var(--amber); }
.cc-conf-chip-nomatch .cc-conf-dot { background: var(--red); }
.cc-conf-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 500;
}
/* The count echoes its tier's colour, which is worth keeping — but the old
   hues were picked for a dark ground and land at 1.7:1 on a white chip.
   These are the same three tiers in their readable inks. The selectors are
   two-class deep only to out-specify the legacy rules in style.css. */
.cc-conf-chip-exact .cc-conf-count { color: var(--accent-ink); }
.cc-conf-chip-manual .cc-conf-count { color: var(--amber-ink); }
.cc-conf-chip-nomatch .cc-conf-count { color: var(--red); }

/* ── Results bar ─────────────────────────────────────────────────── */
.cc-results-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 0;
}
.cc-results-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* The wrapper carried the field's own background, border and padding in the
   old design; here the <input> is the field, so the wrapper is reset to a
   bare positioning context for the icon. */
.cc-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 280px;
  min-width: 220px;
  max-width: 460px;
  gap: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.cc-search:focus-within { border: 0; }
.cc-search-icon {
  position: absolute;
  left: 11px;
  font-size: 12px;
  color: var(--ink-4);
  pointer-events: none;
}
.cc-search input {
  width: 100%;
  height: 34px;
  padding: 0 11px 0 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.cc-search input:focus { border-color: var(--accent-border); }
/* style.css still sets a near-white placeholder for the old dark-only UI, which
   is invisible in the field's light background. */
.cc-search input::placeholder { color: var(--ink-4); opacity: 1; }
.cc-results-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
/* Two-class to out-specify `.cc-results-right .status-text` in style.css.
   setStatus() now toggles .is-error rather than writing an inline colour. */
.status-text,
.cc-results-right .status-text { font-size: 12.5px; color: var(--ink-3); }
.status-text.is-error,
.cc-results-right .status-text.is-error { color: var(--red); }
.cc-filter-status.is-error { color: var(--red); }
.cc-pagination { display: flex; align-items: center; gap: 4px; }
.cc-pagination button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.cc-pagination button:hover:not(:disabled) {
  background: var(--surface-3);
  color: var(--ink);
}
.cc-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.cc-pagination #pageInfo {
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* ── Claims table ────────────────────────────────────────────────── */
.cc-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow-x: auto;
}
.cc-page #dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cc-page #dataTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.cc-page #dataTable tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  vertical-align: middle;
  white-space: nowrap;
}
.cc-page #dataTable tbody tr { background: var(--surface); }
.cc-page #dataTable tbody tr:nth-child(even) { background: var(--zebra); }
.cc-page #dataTable tbody tr:hover { background: var(--surface-3); }
.cc-page #dataTable tbody tr:last-child td { border-bottom: 0; }
.cc-page .clickable-row { cursor: pointer; }

/* The old row tints painted whole rows red/green, which made the table
   hard to read once most rows had a verdict. The canvas carries the same
   information in a single dot at the start of the row instead. */
.cc-page #dataTable tbody tr.row-rules-passed,
.cc-page #dataTable tbody tr.row-rules-failed,
.cc-page #dataTable tbody tr.pr-row-exact,
.cc-page #dataTable tbody tr.pr-row-manual-check,
.cc-page #dataTable tbody tr.pr-row-no-match { background: inherit; }
.cc-page #dataTable tbody tr.pr-row-exact:nth-child(even),
.cc-page #dataTable tbody tr.pr-row-manual-check:nth-child(even),
.cc-page #dataTable tbody tr.pr-row-no-match:nth-child(even) { background: var(--zebra); }
.cc-page #dataTable tbody tr:hover { background: var(--surface-3); }

/* The old design carried the tier as a 3px bar down the row's left edge.
   The dot below replaces it, so drop the bar rather than showing both. */
.cc-page #dataTable tbody tr.pr-row-exact,
.cc-page #dataTable tbody tr.pr-row-manual-check,
.cc-page #dataTable tbody tr.pr-row-no-match { border-left: 0; }

.cc-page #dataTable tbody td:first-child { position: relative; padding-left: 24px; }
.cc-page #dataTable tbody tr[class*="pr-row-"] td:first-child::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-5);
}
.cc-page #dataTable tbody tr.pr-row-exact td:first-child::before { background: var(--accent-strong); }
.cc-page #dataTable tbody tr.pr-row-manual-check td:first-child::before { background: var(--amber); }
.cc-page #dataTable tbody tr.pr-row-no-match td:first-child::before { background: var(--red); }

/* Gate verdict cells keep their words but drop the block fills. */
.cc-page .rv-cell-passed { color: var(--accent-ink); font-weight: 500; background: none; }
.cc-page .rv-cell-failed { color: var(--red); font-weight: 500; background: none; }
.cc-page .rv-cell-skipped { color: var(--ink-4); background: none; }

/* Numeric-ish columns read better in mono. Applied by the renderer. */
.cc-page #dataTable td.is-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--ink-2);
}

/* Empty state sits inside the table card, replacing the rows. */
.cc-table-wrap .srx-empty { border-top: 1px solid var(--line-soft); }

/* ═══ Analytics (#tab-analytics) ═══════════════════════════════════ */
/* Six sub-views over 17 chart cards. Chart.js keeps rendering the 11
   canvas charts exactly as before — only its colours moved, into
   tokens.css, read via SRx.chartTheme(). Everything below is card
   chrome, filters and tables around them, plus the two cohort-triangle
   heatmaps, which were already hand-rolled DOM and so restyle here. */

/* ── Filter bar ──────────────────────────────────────────────────── */
/* A card, because it now holds a statement as well as controls: the range
   being filtered on, named in full on the left, and the ways to change it on
   the right. */
.an-filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
/* The bar is hidden on tabs it does not filter (UDS). An author `display`
   beats the UA's [hidden] rule, so this has to say so explicitly. */
.an-filterbar[hidden] { display: none; }
.an-range-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* The answer to "what am I looking at", so it carries the weight of a heading
   — this bar is the only place the resolved range is written out. */
.an-range-value {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
/* Custom sits at the right end of the bar, so its popover hangs from that
   edge — anchored left it would run off the page. */
.an-filterbar .cc-datepop { left: auto; right: 0; }

/* Presets are a segmented control: one track, no per-button borders, so they
   read as five settings of one control rather than five separate buttons. */
.an-preset-group {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.an-preset {
  height: 28px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.an-preset:hover { color: var(--ink); }
.an-preset.is-active {
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}
/* Custom is a preset too, but it lives outside the track: it opens the
   popover, so it needs an edge of its own to read as a button. */
.an-custom-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-color: var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}
.an-custom-btn:hover { background: var(--bg); color: var(--ink); }
.an-custom-btn.is-active {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}
/* Inside the popover the caption stacks above the two date inputs. */
.an-custom-range { display: block; }
/* ── Sub-tabs ────────────────────────────────────────────────────── */
/* The canvas runs these as an underlined switcher rather than pills —
   the same treatment as the header tabs, one level down. */
.an-subtab-row {
  /* Legacy sets margin-top here; the canvas hangs the row off the top of the
     panel and spaces below it instead. */
  margin-top: 0;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.an-subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.an-subtab {
  position: relative;
  height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
/* No background on hover — the canvas moves colour only, so the row stays a
   line of labels rather than a strip of buttons. */
.an-subtab:hover { background: transparent; color: var(--ink); }
.an-subtab.is-active {
  color: var(--ink);
  font-weight: 600;
  /* Legacy leaves a green wash and border here; the underline below is
     the redesign's active marker, so clear both. */
  background: transparent;
  border-color: transparent;
}
/* Full-width underline sitting on the row's bottom rule, as on the canvas. */
.an-subtab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

/* ── Panels, headers, KPIs ───────────────────────────────────────── */
.an-panel { display: flex; flex-direction: column; gap: 14px; }
.an-panel[hidden] { display: none; }
/* No panel title or scope line — the active sub-tab already names the view,
   and the date range is on the filter button. What is left is the occasional
   control (the Group by toggle), which hangs off the right on its own margin. */
.an-panel-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.an-panel-empty {
  padding: 48px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.an-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.an-kpi {
  padding: 14px 16px;
  border-left: 1px solid var(--line-soft);
  background: transparent;
}
.an-kpi:first-child { border-left: 0; }
.an-kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.an-kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Granularity + row-count toggles reuse the segmented-control look. */
.an-gran-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.an-gran-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.an-gran {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.an-gran.is-active {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 500;
}
/* Same again for the per-view Rows/Apply strip. */
.an-secondary-toolbar {
  padding: 0;
  background: transparent;
  border: 0;
}

/* ── Chart cards ─────────────────────────────────────────────────── */
.an-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 14px;
}
.an-chart-grid-single { grid-template-columns: 1fr; }
/* Fixed column count for sections that know their own shape. auto-fit above
   packs as many 440px columns as the width allows, which turns a four-card
   section into 3 + 1 on a wide screen — a ragged last row that reads as a
   missing chart. A section can ask for the grid it was designed around
   instead; four cards at cols:2 give two even rows.
   minmax(0, 1fr) rather than a 440px floor so the columns still shrink; the
   900px rule below collapses them to one when that stops being readable. */
.an-chart-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.an-chart-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .an-chart-grid-cols-2,
  .an-chart-grid-cols-3 { grid-template-columns: 1fr; }
}
.an-chart-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.an-chart-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px 12px;
}
.an-chart-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.an-chart-header-aside {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
/* "Show top" in a chart-card header. The caption matches the other small
   uppercase labels; the select is the standard one, shrunk to header height. */
.an-topn-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.an-topn-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}
.an-topn-field .cc-select {
  height: 28px;
  padding: 0 26px 0 8px;
  font-size: 12.5px;
}
.an-csv-btn {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.an-csv-btn:hover { background: var(--surface-3); color: var(--ink); }
.an-chart-canvas-wrap {
  position: relative;
  height: 320px;
  padding: 0 18px 18px;
}
.an-chart-message {
  margin: 0;
  padding: 0 18px 14px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.an-chart-message:empty { display: none; }

/* ── Data tables inside cards ────────────────────────────────────── */
.an-table-wrap { overflow-x: auto; }
.an-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.an-data-table thead th {
  position: sticky;
  top: 0;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.an-data-table tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  white-space: nowrap;
}
/* The base row colour is stated explicitly because style.css carries a
   bare `tbody tr:nth-child(odd)` rule that paints every odd row in the
   app near-black — styling only the even rows leaves the odd ones dark
   with dark text on top. Deleted along with style.css in the last phase. */
.an-data-table tbody tr { background: var(--surface); }
.an-data-table tbody tr:nth-child(even) { background: var(--zebra); }
.an-data-table tbody tr:hover { background: var(--surface-3); }
.an-data-table tbody tr:last-child td { border-bottom: 0; }
.an-empty-cell {
  padding: 32px 14px !important;
  text-align: center;
  color: var(--ink-3);
}

/* "Hide Medication" side panel on the dose-changes card. */
.an-dose-layout { display: flex; gap: 0; min-width: 0; }
.an-dose-layout .an-table-wrap { flex: 1; min-width: 0; }
.an-dose-hide-panel {
  width: 210px;
  flex: none;
  padding: 14px;
  border-left: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.an-dose-hide-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.an-dose-hide-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.an-dose-hide-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.an-dose-hide-item input { accent-color: var(--accent); margin: 2px 0 0; }
.an-dose-hide-empty { font-size: 12.5px; color: var(--ink-3); }
.an-dose-hide-apply {
  width: 100%;
  height: 30px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* ── UDS cohort triangle ─────────────────────────────────────────── */
/* Already hand-rolled DOM rather than a canvas, so it restyles here to
   match the canvas's heatmap: one accent ramp, mono figures, and a
   hatched "not started yet" state for cells beyond a cohort's window. */
.an-recap-card { display: flex; flex-direction: column; gap: 0; }
.an-recap-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.an-recap-kpi {
  padding: 14px 18px;
  border-left: 1px solid var(--line-soft);
}
.an-recap-kpi:first-child { border-left: 0; }
.an-recap-kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.an-recap-kpi-value {
  font-size: 21px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.an-recap-kpi-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.an-recap-modes { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-3); border-radius: var(--r-md); }
.an-recap-mode {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.an-recap-mode.is-active {
  background: var(--seg-active);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow-sm);
}

.an-recap-rowhead,
.an-recap-offset-head { white-space: nowrap; }
/* The cohort label. style.css still paints this near-white on a dark navy
   block for the old dark-only UI; on a light card that is white on white. */
.an-recap-rowhead {
  background: var(--surface);
  color: var(--ink);
}
.an-recap-num,
.an-recap-rate { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.an-recap-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  color: var(--ink);
  /* A hairline of the card surface between fills, so adjacent shades stay
     separable. Legacy hardcodes #0f1a30 here, which draws a dark box around
     every cell in both themes now that the card is not navy. */
  box-shadow: inset 0 0 0 1px var(--surface);
}
/* Ink for a shaded cell. The ramp climbs AWAY from a pale surface in light mode
   and TOWARDS a bright accent in dark, so the step where text has to flip is
   not the same in the two themes — the middle step is the one that differs, and
   it reads its colour from a token defined per theme below. */
:root { --recap-ink-mid: var(--on-accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --recap-ink-mid: var(--ink); }
}
:root[data-theme="dark"] { --recap-ink-mid: var(--ink); }

.an-recap-cell[data-bin="0"],
.an-recap-cell[data-bin="1"] { color: var(--ink); }
.an-recap-cell[data-bin="2"] { color: var(--recap-ink-mid); }
.an-recap-cell[data-bin="3"],
.an-recap-cell[data-bin="4"] {
  color: var(--on-accent);
  font-weight: 600;
}
/* A real zero: someone was due and nobody came back. Legacy prints it in
   near-white, which vanishes on a light card. */
.an-recap-cell.is-zero { color: var(--ink-4); }
/* Beyond a cohort's window there is no number to show — hatch it rather
   than printing a zero that would read as "nobody came back". The class the
   renderer emits is `is-blank`; this rule used to say `is-future` and so never
   matched, leaving the legacy white-on-white hatch in place. */
.an-recap-cell.is-blank {
  background-image: repeating-linear-gradient(135deg,
    var(--surface-3) 0, var(--surface-3) 5px,
    var(--surface-2) 5px, var(--surface-2) 10px);
  box-shadow: none;
}
.an-recap-chip {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--accent-border-soft);
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 500;
}
.an-recap-late { color: var(--amber-ink); }
.an-recap-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink-3);
}
.an-recap-legend-scale { display: inline-flex; gap: 3px; }
.an-recap-swatch { width: 18px; height: 10px; border-radius: 2px; }
.an-recap-sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }

/* ── Sections ────────────────────────────────────────────────────── */
.an-section { display: flex; flex-direction: column; gap: 12px; }
.an-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.an-section-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ═══ Patient Recall (#tab-patient-recall) ═════════════════════════ */
/* Master-detail: a filtered list on the left, the selected patient's
   chart and call log on the right. The detail pane is built from
   template literals in script.js, so its classes are styled here but
   never appear in index.html. */

.prc-page:not(.tab-panel-hidden) {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--ink);
}

/* ── Filter bar ──────────────────────────────────────────────────── */
.prc-filterbar {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.prc-filter-row,
.prc-filter-row-2 {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.prc-filter-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.prc-filter-group { display: flex; align-items: center; gap: 8px; }
.prc-filter-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.prc-hide-slot[hidden] { display: none; }

/* Segmented controls, matched to .srx-seg. */
.prc-segment {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-3);
  border: 0;
  border-radius: var(--r-md);
}
.prc-seg-btn {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.prc-seg-btn:hover { color: var(--ink); }
.prc-seg-btn.is-active {
  background: var(--seg-active);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow-sm);
}

.prc-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 360px;
  margin-left: auto;
  padding: 0;
  background: transparent;
  border: 0;
}
.prc-search-icon {
  position: absolute;
  left: 11px;
  font-size: 13px;
  color: var(--ink-4);
  pointer-events: none;
}
.prc-search-input {
  width: 100%;
  height: 34px;
  padding: 0 11px 0 30px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.prc-search-input:focus { border-color: var(--accent-border); }
/* The redesign restyled these inputs but not their placeholders, so style.css's
   originals still applied — rgba(231, 236, 243, 0.35), a near-white picked for
   the old dark surface. Over the light --surface they land on #F7F8FB: 1.06:1,
   which is not faint, it is invisible. "search patient name…" simply was not
   there.
   .pr-search is the same bug mirrored: a hardcoded #475569 that reads fine on
   white (7.58:1) and fails on the dark surface (2.26:1). A literal can only
   ever be right for one theme, which is the whole argument for the token.

   opacity:1 because Firefox dims placeholders by default, which would undo a
   token chosen to pass on its own. */
.prc-search-input::placeholder,
.pr-search::placeholder,
.int-input::placeholder {
  color: var(--ink-4);
  opacity: 1;
}
.prc-select { min-width: 160px; }
.prc-status-error { color: var(--red); }

/* ── Split layout ────────────────────────────────────────────────── */
.prc-split {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  .prc-split { grid-template-columns: 1fr; }
}

.prc-list-pane,
.prc-detail-pane {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.prc-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
}
.prc-list-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.prc-list-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }

/* Sortable column head above the card list. */
.prc-list-colhead {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 84px 76px 84px;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.prc-col-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.prc-col-sort:hover { color: var(--ink); }
.prc-sort-ind { font-size: 10px; color: var(--ink-4); margin-left: 2px; }
.prc-col-sort.is-sorted .prc-sort-ind { color: var(--accent-ink); }

.prc-cards { max-height: 620px; overflow-y: auto; }
.prc-card {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 84px 76px 84px;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}
.prc-card:hover { background: var(--surface-3); }
.prc-card.is-active,
.prc-card.is-selected {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
}
/* Legacy tints the selected row's name teal (#7ff0cf), which is a dark-mode
   colour and disappears on the accent tint. */
.prc-card.is-active .prc-card-fullname,
.prc-card.is-selected .prc-card-fullname { color: var(--accent-ink-2); }
.prc-card-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prc-card-fullname {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prc-card-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.prc-card-cell,
.prc-card-mrn {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}
.prc-card-status { font-size: 12px; color: var(--ink-2); }

.prc-empty,
.prc-detail-empty {
  padding: 48px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
}

/* ── Badges ──────────────────────────────────────────────────────── */
/* One tier per colour: overdue is the only one that should read as
   urgent, so it is the only red. */
.prc-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.prc-badge-overdue { background: var(--red-tint); border-color: var(--red); color: var(--red); }
.prc-badge-upcoming { background: var(--amber-tint); border-color: var(--amber); color: var(--amber-ink); }
.prc-badge-never { background: var(--surface-3); border-color: var(--border-2); color: var(--ink-2); }
.prc-badge-logged,
.prc-badge-new {
  background: var(--accent-tint);
  border-color: var(--accent-border-soft);
  color: var(--accent-ink);
}
.prc-badge-awv, .prc-badge-ths { background: var(--surface-3); color: var(--ink-2); }
.prc-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
}
.prc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

/* ── Detail pane ─────────────────────────────────────────────────── */
.prc-detail-body { padding: 0; }
.prc-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.prc-detail-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prc-detail-name {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.prc-detail-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-3);
}
.prc-detail-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.prc-cta,
.prc-ghost-btn,
.prc-cancel-btn,
.prc-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.prc-cta {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.prc-cta:hover { background: var(--accent-strong); }
.prc-ghost-btn:hover,
.prc-cancel-btn:hover,
.prc-copy-btn:hover { background: var(--surface-3); }
.prc-copy-btn { height: 24px; padding: 0 8px; font-size: 11.5px; }

.prc-section { padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.prc-section:last-child { border-bottom: 0; }
.prc-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.prc-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 20px;
}
.prc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prc-field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.prc-field-value { font-size: 13px; color: var(--ink); }
.prc-field-value-copy { display: flex; align-items: center; gap: 8px; }
.prc-date { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.prc-soon { color: var(--amber-ink); font-weight: 500; }

/* Status banner above the detail body. */
.prc-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.prc-banner-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: currentColor; }
.prc-banner-main { font-weight: 500; }
.prc-banner-note { color: var(--ink-3); font-size: 12.5px; }
.prc-banner-overdue { background: var(--red-tint); color: var(--red); }
.prc-banner-upcoming { background: var(--amber-tint); color: var(--amber-ink); }
.prc-banner-never { background: var(--surface-2); color: var(--ink-2); }

/* ── Call history ────────────────────────────────────────────────── */
.prc-calls { display: flex; flex-direction: column; gap: 2px; }
.prc-call {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
}
 /* Legacy paints these rows with a 2%-white overlay, which is a dark-mode
    device: over a white card it is invisible, and it inverts the row in
    dark. Rows are flat; hover does the work. */
.prc-call { background: transparent; }
.prc-call:hover { background: var(--surface-3); }
.prc-call-time { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.prc-call-dir {
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.prc-call-in { background: var(--accent-tint); color: var(--accent-ink); }
.prc-call-out { background: var(--surface-3); color: var(--ink-2); }
.prc-call-result { color: var(--ink); }
.prc-call-staff { color: var(--ink-3); }
.prc-call-dur { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
/* Pushed right, so the row reads direction/time/duration on the left and
   who handled it on the right. Putting the auto margin on the duration
   instead would drag the outcome across with it. */
.prc-call-staff { margin-left: auto; }
.prc-calls-empty,
.prc-calls-loading,
.prc-logs-empty,
.prc-logs-loading { font-size: 12.5px; color: var(--ink-3); padding: 6px 0; }
.prc-calls-note { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.prc-calls-sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }
.prc-calls-toggle,
.prc-logs-toggle {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 0;
}
.prc-calls-toggle:hover,
.prc-logs-toggle:hover { text-decoration: underline; }
.prc-calls-rest[hidden], .prc-logs-history[hidden] { display: none; }

/* ── Outreach log ────────────────────────────────────────────────── */
.prc-log-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.prc-log-item:last-child { border-bottom: 0; }
.prc-log-outcome { font-weight: 500; color: var(--ink); }
.prc-log-by { color: var(--ink-3); }
.prc-log-time { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-left: auto; }
.prc-log-note { flex-basis: 100%; color: var(--ink-2); line-height: 1.5; }
.prc-log-edit {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.prc-last-log { font-size: 12.5px; color: var(--ink-3); }

.prc-outcome-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.prc-outcome-tag {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.prc-outcome-tag:hover { border-color: var(--accent-border); color: var(--ink); }
.prc-outcome-tag.is-selected {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 500;
}
.prc-outcome-tag:disabled { opacity: 0.5; cursor: not-allowed; }
/* The JS has always supported a note field and reset/export buttons whose
   markup had been removed; the redesign puts them back, so they need a
   style. See prcSaveOutcome / prcReset / prcExport in script.js. */
.prc-notes {
  width: 100%;
  min-height: 76px;
  padding: 11px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
.prc-notes:focus { border-color: var(--accent-border); }
.prc-outcome-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.prc-outcome-hint { font-size: 12.5px; color: var(--ink-3); }
.prc-outcome-error { font-size: 12.5px; color: var(--red); }
.prc-outcome-error:empty { display: none; }
.prc-filter-actions { display: flex; gap: 8px; margin-left: auto; }
.prc-filter-arrow { color: var(--ink-4); }
.prc-schedule-section[hidden] { display: none; }

.prc-correct-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--amber);
  border-radius: var(--r-md);
  background: var(--amber-tint);
  color: var(--amber-ink);
  font-size: 12.5px;
}
.prc-correct-text { flex: 1; min-width: 0; }

/* ── Busy / skeleton buffers ─────────────────────────────────────── */
.prc-busy {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 16px 18px;
  background: var(--surface);
}
.prc-busy[hidden] { display: none; }
.prc-busy-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.prc-busy-spinner {
  width: 13px;
  height: 13px;
  flex: none;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: prc-spin 0.7s linear infinite;
}
@keyframes prc-spin { to { transform: rotate(360deg); } }
.prc-skel-row,
.prc-skel-block {
  height: 34px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
}
.prc-skel-title { height: 22px; width: 55%; }
.prc-skel-sub { height: 14px; width: 35%; }
.prc-skel-wide { height: 88px; }
.prc-skel-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px; }
.prc-skel-grid .prc-skel-block { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) {
  .prc-busy-spinner { animation: none; }
}

/* Stragglers the class diff turned up. */
/* Two-class to match `.prc-field-value.prc-accent` in style.css. */
.prc-accent,
.prc-field-value.prc-accent { color: var(--accent-ink); font-weight: 500; }
.prc-dot-amber { background: var(--amber); }
.prc-select-wrap { position: relative; display: flex; }
.prc-copy-btn.is-copied {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
}
/* The outcome already recorded for this patient — shown selected but not
   re-submittable, so it reads as state rather than as a choice. */
.prc-outcome-tag.is-current {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 500;
}
.prc-list-pane.is-busy, .prc-detail-pane.is-busy { pointer-events: none; }

/* ═══ Rule Engine modal (#ruleEngineOverlay) ═══════════════════════ */
/* Opened by clicking a row in the Referral Capture table. Its markup is
   built by the pr* code that also backed the retired Pipeline Results
   tab, hence the two class prefixes. */

.rule-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  backdrop-filter: blur(3px);
}
.rule-overlay.visible { display: flex; }
.rule-modal {
  display: flex;
  flex-direction: column;
  width: min(1400px, 96vw);
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 24px 64px var(--shadow);
  overflow: hidden;
}
.rule-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.rule-modal-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.rule-modal-close {
  width: 30px;
  height: 30px;
  margin-left: auto;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.rule-modal-close:hover { background: var(--surface-3); color: var(--ink); }
.rule-modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  overflow: hidden;
}
@media (max-width: 1000px) { .rule-modal-body { grid-template-columns: 1fr; } }
/* Both panes state a background: legacy paints the left one
   rgba(15,23,42,0.4), a dark wash that greys out the whole pane. */
.rule-modal-left,
.rule-modal-right { padding: 18px; overflow-y: auto; min-width: 0; }
.rule-modal-left { background: var(--surface); border-right: 1px solid var(--line-soft); }
.rule-modal-right { border-left: 1px solid var(--line-soft); background: var(--surface-2); }
.rule-pane-heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}

/* ── Gate pipeline ───────────────────────────────────────────────── */
.rule-gates { display: flex; flex-direction: column; gap: 8px; }
.rule-gate {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.rule-gate-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rule-gate-number {
  width: 20px;
  height: 20px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.rule-gate-icon { flex: none; font-size: 13px; }
.rule-gate-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.rule-gate-desc, .rule-gate-msg { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }
.rule-gate-msg { margin-top: 3px; }
.rule-gate-connector { width: 1px; height: 8px; margin-left: 23px; background: var(--border); }
.rule-gate-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rule-loading, .rule-empty, .rule-error,
.rule-referrals-loading, .rule-referrals-empty, .rule-referrals-error {
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 8px 0;
}
.rule-error, .rule-referrals-error { color: var(--red); }

/* ── Status pills ────────────────────────────────────────────────── */
.rule-status-pill,
.rule-spec-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
}
.rule-status-pill-icon, .rule-spec-pill-icon { font-size: 10px; }
.rule-status-pill-yes,
.rule-spec-match-yes {
  background: var(--accent-tint);
  border-color: var(--accent-border-soft);
  color: var(--accent-ink);
}
.rule-status-pill-no,
.rule-spec-match-no { background: var(--red-tint); border-color: var(--red); color: var(--red); }
.rule-status-pill-warn { background: var(--amber-tint); border-color: var(--amber); color: var(--amber-ink); }
.rule-status-pill-unknown { background: var(--surface-3); color: var(--ink-3); }

/* ── Evidence cards ──────────────────────────────────────────────── */
.rule-info-grid,
.pr-evidence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.rule-info-card,
.pr-evidence-card {
  padding: 12px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
}
.rule-info-card-wide, .pr-evidence-card-wide { grid-column: 1 / -1; }
.rule-info-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.rule-info-card-icon { font-size: 12px; color: var(--ink-3); }
.rule-info-card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.rule-info-card-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
}
.rule-info-card-body { display: flex; flex-direction: column; gap: 8px; }
.rule-info-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-info-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}
.rule-info-value { font-size: 13px; color: var(--ink); word-break: break-word; }
.rule-info-muted { color: var(--ink-3); }
.pr-evidence-empty { font-size: 12.5px; color: var(--ink-3); }

/* ── Referrals table ─────────────────────────────────────────────── */
.rule-referrals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.rule-referrals-table thead th {
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
.rule-referrals-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}
.rule-referrals-table tbody tr { background: var(--surface); }
.rule-referrals-row-match,
.rule-referrals-row-engine-match { background: var(--accent-tint); }
.rule-referrals-match-cell { font-weight: 500; color: var(--accent-ink); }
.rule-referrals-date { font-family: var(--font-mono); white-space: nowrap; }

/* ── Link banner ─────────────────────────────────────────────────── */
.pr-link-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  margin-bottom: 12px;
  border: 1px solid var(--accent-border-soft);
  border-radius: var(--r-md);
  background: var(--accent-tint);
  font-size: 12.5px;
  color: var(--ink);
}
.pr-link-banner-caution, .pr-link-banner-warn {
  border-color: var(--amber);
  background: var(--amber-tint);
  color: var(--amber-ink);
}
.pr-link-banner-icon { flex: none; font-size: 14px; }
.pr-link-banner-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.pr-link-banner-value { font-weight: 500; }
.pr-link-banner-sep { color: var(--ink-5); }
.pr-link-banner-note, .pr-link-sub { font-size: 12px; color: var(--ink-3); }
.pr-link-banner-med { font-weight: 500; }
.pr-link-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pr-link-parties { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-link-party { display: flex; flex-direction: column; gap: 1px; }
.pr-link-name { font-weight: 500; color: var(--ink); }
.pr-link-role { font-size: 11px; color: var(--ink-3); }
.pr-link-arrow { color: var(--ink-4); }

/* ── Review panel ────────────────────────────────────────────────── */
.pr-review-gates { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.pr-gate-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.pr-gate-icon { flex: none; }
.pr-gate-info { min-width: 0; }
.pr-gate-info-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pr-gate-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.pr-gate-detail { font-size: 12px; color: var(--ink-3); }
.pr-review-footer { display: flex; flex-direction: column; gap: 12px; }
.pr-review-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.pr-review-notes,
.pr-review-input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  resize: vertical;
}
.pr-review-notes:focus, .pr-review-input:focus { border-color: var(--accent-border); }
.pr-review-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-review-audit { font-size: 12px; color: var(--ink-3); }
.pr-review-overall { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-manual-decision { display: flex; flex-direction: column; gap: 8px; }

.pr-toggle-group, .pr-review-toggle-group {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.pr-toggle-btn {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.pr-toggle-btn.is-active {
  background: var(--seg-active);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow-sm);
}

/* ── Shared pills / badges used by the modal ─────────────────────── */
.pr-badge, .pr-pill, .pr-row-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pr-badge-medication, .pr-pill-medication,
.pr-badge-frontera, .pr-pill-frontera,
.pr-badge-doctor-specialty, .pr-pill-doctor-specialty,
.pr-pill-conf-exact, .pr-row-pill-identity {
  background: var(--accent-tint);
  border-color: var(--accent-border-soft);
  color: var(--accent-ink);
}
.pr-badge-specialty-only, .pr-pill-specialty-only,
.pr-badge-doctor-only, .pr-pill-doctor-only,
.pr-pill-conf-manual, .pr-row-pill-specialty {
  background: var(--amber-tint);
  border-color: var(--amber);
  color: var(--amber-ink);
}
.pr-badge-uncaptured, .pr-pill-uncaptured, .pr-pill-conf-nomatch {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--red);
}
.pr-badge-unknown { background: var(--surface-3); color: var(--ink-3); }
.pr-badge-med-pill { font-family: var(--font-mono); font-size: 11px; }
.pr-pill-label { color: var(--ink-3); }
.pr-pill-value, .pr-pill-total { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
.pr-heading { font-size: 15px; font-weight: 600; color: var(--ink); margin: 0 0 10px; }
.pr-meta, .pr-timestamp { font-size: 12px; color: var(--ink-3); }
.pr-timestamp-label { font-weight: 500; }
.pr-summary-row, .pr-confidence-row, .pr-controls, .pr-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pr-header-left, .pr-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-header-right { margin-left: auto; }

/* ── Referral Capture: the canvas's single-card layout ───────────── */
/* No page heading — the tab bar names the view. The claims drop zone is
   its own strip, and the filter controls live in the table card's header
   rather than in a separate toolbar above it. */

.cc-upload-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border: 1px dashed var(--border-dash);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.cc-strip-spacer { flex: 1; min-width: 8px; }

.cc-tablecard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  /* visible, not hidden: the Fill-date popover hangs below the strip. */
  overflow: visible;
}
.cc-filterstrip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.cc-strip-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Fill-date popover */
.cc-datemenu { position: relative; }
.cc-datebtn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.cc-datebtn:hover { background: var(--bg); }
/* --ink-5 is the dimmest ink and lands at 2.6:1 here; the caret is
   small but it is the only affordance on the button. */
.cc-caret { color: var(--ink-4); font-size: 10px; }
.cc-datepop {
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 30;
  width: 296px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px var(--shadow);
}
.cc-pop-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.cc-pop-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.cc-pop-presets button {
  height: 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.cc-pop-presets button:hover { border-color: var(--accent-border); color: var(--ink); }
.cc-pop-presets button.is-active {
  border-color: var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 500;
}
.cc-pop-range { display: flex; align-items: center; gap: 6px; }
.cc-pop-range .cc-input { flex: 1; min-width: 0; }
.cc-pop-dash { color: var(--ink-5); font-size: 12px; }
.cc-pop-done {
  width: 100%;
  height: 34px;
  margin-top: 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.cc-pop-done:hover { background: var(--bg); }

.cc-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.cc-icon-btn:hover { background: var(--surface-3); color: var(--ink); }

/* Confidence tiers as one segmented track. */
.cc-conf-track {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.cc-conf-track .cc-conf-chip {
  height: 28px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
}
.cc-conf-track .cc-conf-chip:hover { background: var(--surface-2); color: var(--ink); }
.cc-conf-track .cc-conf-chip.cc-conf-chip-active {
  background: var(--seg-active);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow-sm);
}

/* Collapses entirely when it has nothing to say — otherwise an empty strip
   with a top border hangs off the bottom of the table. */
.cc-card-footer { display: none; }
.cc-card-footer:has(> :not(:empty):not([hidden])) {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.cc-card-footer .cc-subtitle,
.cc-card-footer .cc-filter-status { margin: 0; font-size: 12px; color: var(--ink-3); }

/* The results bar and table now sit INSIDE .cc-tablecard, so they lose the
   borders and radii they had as standalone blocks. */
.cc-tablecard .cc-results-bar {
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 14px 18px;
}
.cc-tablecard .cc-table-wrap {
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* ── AI Scribe: the "Ask AI" pane ────────────────────────────────── */
/* A third column of the visit grid, as in the design — not an overlay.
   The assistant is meant to be read beside the note being written, and a
   floating panel parks itself over the note's own actions. */
/* The assistant floats over the page's right margin rather than taking a
   grid column, so the chart rail and the note keep their widths exactly as
   they are with it closed. It sits where the button is, opening upward from
   it — the button is what it replaces.

   Rendered OUTSIDE .scr-visit for the same reason as the button: that
   element carries `animation: scr-rise ... both`, and an animation touching
   `transform` makes its element the containing block for position:fixed
   descendants, which would park this at the bottom of a 3000px-tall panel
   instead of the viewport. */
.scr-visit-grid.no-rail { grid-template-columns: minmax(0, 1fr); }

/* Brings the collapsed rail back. */
.scr-rail-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.scr-rail-open:hover { background: var(--surface-3); color: var(--ink); }

/* The assistant's docked width — read by the pane and by the gutter
   .scr-visit reserves for it, so the two can never disagree. */
.scr-page { --ask-w: 340px; }

.scr-ask-pane {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--ask-w);
  /* Top-aligned with the work column's first row ("Recording") rather than
     floating near the bottom. The offset depends on how tall the visit head
     renders, so scrAlignAskPane() measures it and writes --ask-top; the
     fallback here is the common case. */
  top: var(--ask-top, 244px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 44px var(--shadow);
  overflow: hidden;
}

/* The assistant docks into the right margin rather than floating over the
   note, so while it is open the visit reserves that gutter.

   .scr-visit sits inside .app-main (max-width 1480px, 24px padding) and is
   itself capped at 1320px. Pinned left, its right edge lands at
   `24px + width` below a 1480px viewport and at `50vw - 716px + width` above
   it, while the pane's left edge is always `100vw - 24px - --ask-w`. Solving
   each case for "visit right edge + gutter <= pane left edge" gives the two
   calcs below; min() picks whichever binds, and they cross at exactly 1480px
   so no media query is needed. The gutter is oversized because 100vw counts
   the scrollbar and the layout does not — what is left over after that is
   still ~32px, on top of the visit's own 24px of padding. */
.scr-visit.has-ask {
  max-width: min(1320px,
                 calc(50vw + 660px - var(--ask-w)),
                 calc(100vw - var(--ask-w) - 80px));
  margin-left: 0;
  margin-right: auto;
}

/* The chart rail is reference material and the note is the work, so once the
   gutter starts biting it is the rail that gives up width first. Scoped past
   .no-rail, which is the rail-closed single-column case, and past .is-capture,
   which has no rail at all — matching it there would reserve 300px for a
   column that does not exist and squeeze the note into the wrong track. */
@media (max-width: 1599px) {
  .scr-visit.has-ask .scr-visit-grid:not(.no-rail):not(.is-capture) {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

/* Under ~1360px even that leaves the note too narrow to read, so the
   assistant goes back to overlaying the corner and the visit keeps its full
   width. There is genuinely no room for both at this size. */
@media (max-width: 1359px) {
  .scr-visit.has-ask { max-width: 1320px; margin-left: auto; margin-right: auto; }
  .scr-ask-pane {
    width: min(var(--ask-w), calc(100vw - 48px));
    top: auto;
    max-height: min(560px, calc(100vh - 120px));
  }
}
@media (max-width: 720px) {
  .scr-ask-pane { right: 12px; left: 12px; bottom: 12px; width: auto; }
}

.scr-ask-pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
  flex: none;
}
.scr-ask-pane-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 700;
}
.scr-ask-pane-id { display: flex; flex-direction: column; min-width: 0; }
.scr-ask-pane-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.scr-ask-pane-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scr-ask-pane-close {
  width: 28px;
  height: 28px;
  margin-left: auto;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.scr-ask-pane-close:hover { background: var(--surface-3); color: var(--ink); }
/* The body is the rail tab's own markup; inside the pane it scrolls itself. */
.scr-ask-pane .scr-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;   /* the log scrolls, not the whole body */
  padding: 14px;
}

/* The log absorbs the pane's extra height so the composer stays pinned to the
   bottom. Its 46vh cap was for the old in-rail placement; in here the pane's
   own height is the cap. */
.scr-ask-pane .scr-ask-log {
  flex: 1;
  min-height: 0;
  max-height: none;
}

/* The button exists only while the pane is closed. */
.scr-ask-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--shadow);
}
.scr-ask-fab:hover { filter: brightness(0.96); }
.scr-ask-fab-mark { font-size: 15px; line-height: 1; }
@media (max-width: 720px) {
  .scr-ask-fab { right: 12px; bottom: 12px; }
}
  .scr-ask-fab { right: 12px; bottom: 12px; }
}

/* The per-view Rows/Apply strip reads left-aligned in the canvas; the
   shared .cc-toolbar-right pushes its contents right, which left a wide
   empty card. */
.an-secondary-toolbar .cc-toolbar-right { margin-left: 0; }
.an-secondary-toolbar { justify-content: flex-start; }

/* Inside the segmented track the chips sit on --surface-3, a step darker
   than the --surface these inks were picked against — 4.47:1, a hair under
   AA. The -2 variants clear it. */
.cc-conf-track .cc-conf-chip-exact .cc-conf-count { color: var(--accent-ink-2); }
.cc-conf-track .cc-conf-chip-manual .cc-conf-count { color: var(--amber-ink-2); }

/* ═══ Rule engine modal — claim detail ══════════════════════════════
   The reviewer's question is "is this claim capturable, and why". The layout
   answers it top-down: who the claim is for and the verdict (header), the
   facts it rests on, the evidence, then the decision bar. Every colour comes
   from tokens.css, so dark mode needs no second set of rules. */

/* ── Header ── */
.re-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.re-head-id { min-width: 0; }
.re-head-nameline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.re-head-name {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.re-head-meta {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.re-head-eyebrow {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-5);
}
.re-head-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.re-elig {
  padding: 4px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.re-elig-yes {
  background: var(--accent-tint);
  border-color: var(--accent-border);
  color: var(--accent-ink-2);
}
.re-elig-no {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--red);
}
.re-head-rules { font-size: 12px; color: var(--ink-3); }
.re-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.re-close:hover { background: var(--surface-3); color: var(--ink); }

/* ── Body: two columns, only the left scrolls ──
   .re-body is the frame and does NOT scroll — it hands its height to the two
   columns. The left one owns the scrollbar; the right one is sized by its
   content and stays where it is. min-height:0 on both is what actually lets a
   flex/grid child shrink below its content and scroll: without it the column
   grows to fit and the modal scrolls as a whole again. */
.re-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: stretch;
  background: var(--bg);
  padding: 16px;
  overflow: hidden;
}
.re-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Room for the last card's shadow and a little breathing space at the end
     of the scroll, so the referrals table does not end flush at the edge. */
  padding-right: 4px;
  padding-bottom: 4px;
}
.re-side {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Fixed in the sense that matters — it does not move with the evidence. It
     still scrolls internally if the viewport is short enough that the rules
     plus the decision cannot fit, which beats putting Save out of reach. */
  overflow-y: auto;
}

/* Below the split the columns stack, so the whole body scrolls as one and the
   review sits after the evidence rather than beside it.
   Flex column, NOT a one-column grid: .re-body takes a definite height from
   its flex parent, so grid rows divide that height between them and anything
   taller spills over the row below — the referrals table was drawing straight
   through the review panel. Flex items size to their content instead, and the
   container scrolls. */
@media (max-width: 1100px) {
  .re-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
  }
  .re-main, .re-side {
    overflow: visible;
    min-height: 0;
    flex: 0 0 auto;
  }
}

/* ── Facts: patient / prescriber / claim ── */
/* Two cards, since the patient's identity lives in the header rather than in a
   card of its own. auto-fit rather than a hardcoded 2 so the Frontera variant,
   which drops a card, does not leave a gap where one used to be. */
.re-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
@media (max-width: 860px) {
  .re-facts { grid-template-columns: 1fr; }
}
.re-fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  min-width: 0;
}
.re-fact-title {
  margin: 0;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.re-fact-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
/* The label/value pairs reuse .rule-info-field from the old cards; only the
   label's typography changes, so the fill code stays untouched. */
.re-fact-body .rule-info-label,
.re-check-body .rule-info-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-5);
}
.re-fact-body .rule-info-value { font-size: 13px; color: var(--ink); }

/* ── Panels (match checks, referrals, review) ── */
.re-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.re-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.re-panel-title {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.re-panel-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-3);
}
.re-panel-body { padding: 0; }

/* ── One match check ── */
.re-check { border-bottom: 1px solid var(--line-soft); position: relative; }
.re-check:last-child { border-bottom: 0; }
/* State rail. A 3px edge reads at a glance down a stack of checks in a way a
   coloured icon alone does not. */
.re-check::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--border-2);
}
.re-check[data-state="pass"]::before { background: var(--accent); }
.re-check[data-state="warn"]::before { background: var(--amber); }
.re-check[data-state="fail"]::before { background: var(--red); }
.re-check-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px 11px 17px;
  flex-wrap: wrap;
}
.re-check-mark {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  background: var(--surface-3);
  color: var(--ink-5);
}
.re-check[data-state="pass"] .re-check-mark {
  background: var(--accent-tint-2); color: var(--accent-ink-2);
}
.re-check[data-state="warn"] .re-check-mark {
  background: var(--amber-tint); color: var(--amber-ink-2);
}
.re-check[data-state="fail"] .re-check-mark {
  background: var(--red-tint); color: var(--red);
}
.re-check-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.re-check-body { padding: 0 14px 13px 17px; }
/* Evidence fields sit in a 4-up grid — the mock's shape, and it keeps a long
   provider name from stretching the row. Applied to every check body, not just
   the ones carrying .rule-info-card-fields: the identity and medication bodies
   are plain .pr-link-body and would otherwise stack their fields in a single
   column while the specialty check beside them sits in four. */
.re-check-body {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 18px;
  align-content: start;
}
@media (max-width: 900px) {
  .re-check-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Banners and empty-state text span the whole row rather than taking one
   column's width. */
.re-check-body > .pr-link-banner,
.re-check-body > .rule-referrals-loading,
.re-check-body > p { grid-column: 1 / -1; }

/* ── Tag: how it matched ── */
.re-tag {
  padding: 2.5px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.re-tag-yes {
  background: var(--accent-tint); border-color: var(--accent-border-soft);
  color: var(--accent-ink-2);
}
.re-tag-warn {
  background: var(--amber-tint); border-color: var(--amber); color: var(--amber-ink-2);
}
.re-tag-no {
  background: var(--red-tint); border-color: var(--red); color: var(--red);
}
.re-tag-unknown {
  background: var(--surface-3); border-color: var(--border); color: var(--ink-4);
}

/* ── PASS / FAIL read-out on a check ──
   Looks like the segmented control it mirrors, but it is not a control: the
   gate rows and the decision bar own the editing. Rendered as a span pair so
   it is not focusable and cannot be clicked. */
.re-state {
  margin-left: auto;
  display: inline-flex;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-3);
  flex-shrink: 0;
}
.re-state-half {
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-5);
}
.re-state[data-value="pass"] .re-state-pass {
  background: var(--surface); color: var(--accent-ink-2);
}
.re-state[data-value="fail"] .re-state-fail {
  background: var(--surface); color: var(--red);
}

/* ── Rule engine review (side column) ── */
/* style.css still carries `#prReviewPanel { flex: 1 }` from the layout where
   this panel filled the right column and a footer pinned to its bottom. Left
   alone it grows to eat the column and shoves the decision panel to the floor,
   leaving a hand's width of nothing between the rules and the verdict they
   lead to. Both sit at the top now, as one unit. */
.re-review { margin: 0; }
.re-side > #prReviewPanel { flex: 0 0 auto; }
.re-side { justify-content: flex-start; }
/* No longer sticky: the column itself no longer scrolls, so pinning a panel
   inside it does nothing except fight the column's own layout. */
.re-side .pr-review-gates {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
}
.re-side .pr-gate-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
}
.re-side .pr-gate-card:last-child { border-bottom: 0; }
.re-side .pr-gate-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  background: var(--accent-tint-2);
  color: var(--accent-ink-2);
}
.re-side .pr-gate-card[data-status="failed"] .pr-gate-icon {
  background: var(--red-tint); color: var(--red);
}
.re-side .pr-gate-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.re-side .pr-gate-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.re-side .pr-gate-detail { font-size: 11.5px; color: var(--ink-3); }

/* ── Segmented PASS / FAIL control ── */
.re-seg {
  margin-left: auto;
  display: inline-flex;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-3);
  flex-shrink: 0;
}
.re-seg .pr-toggle-btn {
  padding: 4px 11px;
  border: 0;
  background: transparent;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-5);
  cursor: pointer;
}
.re-seg-sm .pr-toggle-btn { padding: 3px 10px; font-size: 10px; }
.re-seg .pr-toggle-btn.active { background: var(--surface); }
.re-seg .pr-toggle-pass.active { color: var(--accent-ink-2); }
.re-seg .pr-toggle-fail.active { color: var(--red); }
.re-seg .pr-toggle-btn:hover:not(.active) { color: var(--ink-2); }

/* ── Referrals table ── */
.re-ref-table { width: 100%; border-collapse: collapse; }
.re-ref-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-5);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.re-ref-table td {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-soft);
}
.re-ref-table tbody tr:last-child td { border-bottom: 0; }
.re-ref-table .rule-referrals-date { font-variant-numeric: tabular-nums; color: var(--ink-3); }
.re-ref-table .re-ref-to { color: var(--ink); font-weight: 550; }
.re-ref-table .re-ref-spec { display: flex; align-items: center; gap: 8px; }
/* The referral the claim rests on. Tinted row plus a named marker — the tint
   alone would be the only thing saying it, and colour cannot be the only
   carrier of something this load-bearing. */
.re-ref-table tr.rule-referrals-row-engine-match td { background: var(--accent-tint); }
.re-thisclaim {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--accent-border);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-ink-2);
  white-space: nowrap;
}

/* ── Decision panel ──
   A column now, not a bar across the bottom: it lives under the rules in the
   review column, at ~380px, where a single row of controls would not fit. The
   order is the order of the decision — what the verdict is, why, then commit. */
.re-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 13px 14px;
  background: var(--surface);
  flex-shrink: 0;
}
.re-foot-group {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.re-foot-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.re-foot-group .re-seg { margin-left: 0; }
.re-foot-input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
}
.re-foot-input::placeholder { color: var(--ink-5); }
.re-foot-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.re-foot-status { min-width: 0; }
.re-foot-audit, .re-foot-error { margin: 0; font-size: 11.5px; }
.re-foot-audit { color: var(--ink-3); }
.re-foot-error { color: var(--red); font-weight: 600; }
.re-save {
  width: 100%;
  padding: 9px 16px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.re-save:hover { background: var(--accent-strong); }
.re-save:disabled { opacity: 0.55; cursor: not-allowed; }

/* The gate detail inherits .pr-gate-detail from the old card design, which
   paints it as a tinted chip. In a list of four rules that reads as four
   coloured pills competing with the rule names; here it is a quiet second
   line, so the chip treatment is unset rather than overridden piecemeal. */
.re-side .pr-gate-detail {
  background: none;
  border: 0;
  padding: 0;
  border-radius: 0;
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
}
/* Second line under a field's value (an NPI, a specialty, "by <clinician>"). */
.rule-info-sub { font-size: 11px; color: var(--ink-4); }

/* ── Fail state ──
   A failing claim has to be readable as failing before any of the words are.
   The rule rows that broke get the tint and the rail; the ones that passed
   stay plain, so the eye lands on the exceptions rather than on a wall of
   uniformly-coloured rows. */
.re-head-rules-bad { color: var(--red); font-weight: 600; }
.re-panel-count-bad { color: var(--red); font-weight: 600; }

.re-side .pr-gate-card[data-status="failed"] {
  background: var(--red-tint);
  box-shadow: inset 3px 0 0 var(--red);
}
.re-side .pr-gate-card[data-status="failed"] .pr-gate-detail { color: var(--red); }

/* A check's alert: what is wrong, and what it means for capture. */
.re-alert {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  padding: 9px 12px;
  border: 1px solid;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.45;
}
.re-alert-bad {
  background: var(--red-tint);
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
  color: var(--red);
}
.re-alert-warn {
  background: var(--amber-tint);
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
  color: var(--amber-ink-2);
}

/* The "!" a check wears when it needs a human. Set as text from JS so a tick
   cannot survive into a failed state; these only supply the colour. */
.re-check[data-state="fail"] .re-check-mark,
.re-check[data-state="warn"] .re-check-mark { font-weight: 700; }

/* ── Check titles need to read as titles ──
   "Doctor and location", "Specialty", "Medication" sat on the same flat ground
   as the evidence under them, so the three checks ran together into one list
   of fields and the names were lost in it. Giving the header row its own band
   and a rule beneath makes each check a titled block: the eye finds the three
   names first, then reads into whichever one it wants.

   The band is deliberately quiet — a tint, not a box. These titles are
   wayfinding inside a check, one level below the panel heading ("MATCH
   CHECKS"), and must not compete with it. */
.re-check + .re-check { border-top: 1px solid var(--border); }
.re-check-head {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.re-check-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.005em;
}
/* The state rail runs the full height of the check, header band included, so
   a check reads as one block rather than a band with a body loosely below. */
.re-check-body { padding-top: 13px; }

/* Field labels step down from the title rather than sitting at the same
   weight — the label says what a value IS, the title says what the check is. */
.re-check-body .rule-info-label { color: var(--ink-5); }
.re-check-body .rule-info-value { font-size: 13px; color: var(--ink); }

/* ── Match checks as separate cards ──
   Previously three rows inside one bordered panel, which read as a single long
   list of fields with names scattered through it. The checks are independent
   tracks — a claim can match on one and miss the others — so each gets its own
   card, and the gap between them does the separating that a divider could not. */
.re-checks { display: block; }
.re-checks-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 2px 9px;
}
.re-checks-list { display: flex; flex-direction: column; gap: 10px; }

.re-checks .re-check {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
/* The shared-panel rules no longer apply: no divider between siblings, and the
   rail is the card's own left edge. */
.re-checks .re-check + .re-check { border-top: 1px solid var(--border); }
.re-checks .re-check::before { border-radius: var(--r-md) 0 0 var(--r-md); }
.re-checks .re-check:last-child { border-bottom: 1px solid var(--border); }

/* A failed or unverified check is tinted whole, so which of the three needs
   attention is answerable from the shape of the stack alone. */
.re-checks .re-check[data-state="fail"] { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.re-checks .re-check[data-state="warn"] { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.re-checks .re-check[data-state="fail"] .re-check-head { background: var(--red-tint); }
.re-checks .re-check[data-state="warn"] .re-check-head { background: var(--amber-tint); }

/* rulePatientSummary holds the facts grid and the evidence panels as siblings.
   It is a single child of .re-main, so .re-main's gap never applies between
   them — without this the "Match checks" heading sits flush against the bottom
   of the Patient card. */
.rule-patient-summary { display: flex; flex-direction: column; gap: 18px; }

/* ═══ Patient Registration (#tab-registration) ═════════════════════ */
/*
   The paper New Patient Packet on screen. Two modes share these styles:

   - Desk mode: staff sees a normal tab, laid out like the other tabs.
   - Kiosk mode: <html data-kiosk="on"> — the patient holds the tablet. The
     page goes near-full-bleed, controls grow to >=44px touch targets, and the
     app chrome is hidden (that part is the `hidden` attribute on #appHeader,
     not CSS, so [hidden]{display:none!important} in app.css wins).

   Tokens only, no colour literals — scripts/check_contrast.py resolves this
   file against tokens.css in both themes and fails CI on a WCAG-AA miss.
*/

/* The :not() guard is required: without it this flex beats .tab-panel-hidden
   and the panel renders while "hidden". Same trick as .cc-page above. */
.reg-page:not(.tab-panel-hidden) {
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--ink);
}

.reg-app {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Title bar ───────────────────────────────────────────────────── */
.reg-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reg-title {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.reg-subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
  max-width: 76ch;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.reg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}

.reg-card + .reg-card { margin-top: 0; }

.reg-section-title {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── Progress rail ───────────────────────────────────────────────── */
.reg-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.reg-progress-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-4);
}

.reg-progress-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--border-2);
  flex: none;
}

.reg-progress-step.is-done .reg-progress-dot { background: var(--accent); }
.reg-progress-step.is-current .reg-progress-dot {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.reg-progress-step.is-current { color: var(--ink); font-weight: 600; }
.reg-progress-step.is-done { color: var(--ink-3); }

.reg-progress-sep {
  width: 14px;
  height: 1px;
  background: var(--border-2);
  flex: none;
}

/* ── Field grid ──────────────────────────────────────────────────── */
.reg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}

.reg-grid--wide { grid-template-columns: 1fr; }

.reg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.reg-field--full { grid-column: 1 / -1; }

.reg-field > label,
.reg-fieldset-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  line-height: 1.4;
}

.reg-required-mark {
  color: var(--red);
  margin-left: 3px;
}

.reg-input,
.reg-select,
.reg-textarea {
  height: 36px;
  padding: 0 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  width: 100%;
  box-sizing: border-box;
}

.reg-textarea {
  height: auto;
  min-height: 84px;
  padding: 9px 10px;
  line-height: 1.5;
  resize: vertical;
}

.reg-input:focus,
.reg-select:focus,
.reg-textarea:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.reg-input.is-invalid,
.reg-select.is-invalid,
.reg-textarea.is-invalid {
  border-color: var(--red);
}

.reg-note {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-4);
}

.reg-error {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--red);
}

.reg-computed {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px dashed var(--border-dash);
  border-radius: var(--r-md);
}

/* ── Choice controls ─────────────────────────────────────────────── */
.reg-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reg-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-pill);
  cursor: pointer;
  user-select: none;
}

.reg-choice:hover { border-color: var(--accent-border-soft); }

/* A lone chip inside a .reg-field would otherwise be stretched to the column
   width by the field's `align-items: stretch`, turning a checkbox into a
   full-width bar. Chips inside .reg-choices are laid out by that flex row and
   are unaffected. */
.reg-field > .reg-choice { align-self: flex-start; }

.reg-choice input { margin: 0; flex: none; }

.reg-choice.is-selected {
  background: var(--accent-tint);
  border-color: var(--accent-border);
  color: var(--accent-ink);
  font-weight: 550;
}

/* YES / NO rows — the paper form's two-box idiom. */
.reg-yesno-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.reg-yesno-row:last-child { border-bottom: 0; }

.reg-yesno-label {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  flex: 1 1 auto;
  min-width: 0;
}

.reg-yesno-controls {
  display: flex;
  gap: 6px;
  flex: none;
}

.reg-yesno-btn {
  min-width: 52px;
  height: 32px;
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  cursor: pointer;
}

.reg-yesno-btn:hover { border-color: var(--accent-border-soft); }

.reg-yesno-btn.is-selected {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

/* ── Medical-history grid: condition x (patient | family) ────────── */
.reg-hx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* style.css (the legacy sheet, being deleted incrementally) styles bare `thead`
   and `th, td` selectors from the old dark theme, so they reach any table added
   since. Two of them have to be undone here:

     thead tr { background: rgba(15,23,42,.98) }  -> a near-black bar behind our
                                                     own dark header text
     th, td   { white-space: nowrap }             -> condition labels could not
                                                     wrap on a narrow tablet

   Worth noting check_contrast.py did NOT catch the first one: it resolves the
   token pairs the stylesheets declare, and this was an inherited literal. */
.reg-hx-table thead,
.reg-hx-table thead tr {
  background: transparent;
  position: static;
}

.reg-hx-table th,
.reg-hx-table td {
  white-space: normal;
}

.reg-hx-table th {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 0 8px 9px;
  border-bottom: 1px solid var(--border);
}

.reg-hx-table th:not(:first-child) { text-align: center; width: 128px; }

.reg-hx-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
}

.reg-hx-table td:not(:first-child) { text-align: center; }

.reg-hx-table tbody tr:nth-child(even) { background: var(--zebra); }

/* ── Prose (consent text, policy text) ───────────────────────────── */
.reg-prose {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
  max-width: 82ch;
}

.reg-prose h4 {
  margin: 18px 0 6px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink);
}

.reg-prose h4:first-child { margin-top: 0; }

.reg-prose p { margin: 0 0 10px; }

/* A long read-only policy block gets its own scroll area so the buttons
   below it stay reachable without a page-length scroll. */
.reg-prose--scroll {
  max-height: 340px;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* ── Consent block: prose + its initial box ──────────────────────── */
.reg-consent-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}

.reg-consent-block:last-of-type { border-bottom: 0; }

.reg-consent-initial {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.reg-consent-initial label {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.reg-initials-input {
  width: 84px;
  height: 36px;
  padding: 0 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
}

.reg-initials-input:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.reg-initials-input.is-invalid { border-color: var(--red); }

/* ── Signature pad ───────────────────────────────────────────────── */
.reg-sig {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reg-sig-pad {
  position: relative;
  height: 132px;
  background: var(--surface);
  border: 1px dashed var(--border-dash);
  border-radius: var(--r-md);
  /* The pad captures pointer strokes, so the browser must not treat a drag as
     a scroll or a double-tap as a zoom. */
  touch-action: none;
  cursor: crosshair;
  overflow: hidden;
}

.reg-sig-pad.is-signed { border-style: solid; border-color: var(--accent-border); }
.reg-sig-pad.is-invalid { border-color: var(--red); }

.reg-sig-pad canvas { display: block; width: 100%; height: 100%; }

.reg-sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--ink-4);
  pointer-events: none;
}

.reg-sig-pad.is-signed .reg-sig-placeholder { display: none; }

.reg-sig-baseline {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 30px;
  height: 1px;
  background: var(--border-2);
  pointer-events: none;
}

.reg-sig-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.reg-sig-caption {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── Buttons / action bar ────────────────────────────────────────── */
.reg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.reg-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.reg-btn {
  height: 36px;
  padding: 0 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  cursor: pointer;
}

.reg-btn:hover:not(:disabled) { border-color: var(--accent-border-soft); }

.reg-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.reg-btn--primary {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 600;
}

.reg-btn--primary:hover:not(:disabled) { background: var(--accent-strong); }

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

/* Filing a packet into the EHR. Deliberately NOT styled like --primary: it
   creates a patient record that cannot be deleted and attaches documents that
   cannot be removed, so it must not look like the safe default action. The
   preview button (write flags off) uses --primary instead. */
.reg-btn--danger {
  background: var(--danger, #b3261e);
  border-color: var(--danger-strong, #8c1d18);
  color: #fff;
  font-weight: 600;
}

.reg-btn--danger:hover:not(:disabled) { background: var(--danger-strong, #8c1d18); }

/* ── The patient's own review of their answers ───────────────────── */
.reg-review-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Two columns on a desk screen, one on a tablet held in portrait. A label and
   its value must never separate across the fold — a value sitting under the
   wrong question is worse than a narrow layout. */
.reg-review-list {
  display: grid;
  grid-template-columns: minmax(140px, 40%) 1fr;
  gap: 6px 16px;
  margin: 10px 0 0;
}

.reg-review-list dt {
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.45;
}

.reg-review-list dd {
  margin: 0;
  font-size: 15px;      /* larger than the label: this is what they are checking */
  line-height: 1.45;
  word-break: break-word;
}

/* A blank answer is stated, not left empty — an empty cell on a review screen
   reads as "nothing to check here", which is how a missed question gets signed
   for. Muted and italic so it is clearly not something they typed. */
.reg-review-blank {
  color: var(--ink-3);
  font-style: italic;
}

@media (max-width: 620px) {
  .reg-review-list { grid-template-columns: 1fr; gap: 2px; }
  .reg-review-list dd { margin-bottom: 10px; }
}

/* ── Status / banner ─────────────────────────────────────────────── */
.reg-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
}

.reg-banner--warn {
  background: var(--amber-tint);
  border-color: var(--amber);
  color: var(--amber-ink);
}

.reg-banner--error {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--ink);
}

.reg-banner--ok {
  background: var(--accent-tint);
  border-color: var(--accent-border);
  color: var(--accent-ink);
}

.reg-error-summary {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink);
}

.reg-error-summary button {
  font: inherit;
  color: var(--accent-ink);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.reg-save-state {
  font-size: 11.5px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* ── Kiosk mode ──────────────────────────────────────────────────── */
/* The patient is holding the tablet. Wider canvas, bigger targets, and no way
   back into the app from here (the nav is hidden and showTab() is a no-op). */
:root[data-kiosk="on"] .app-main {
  max-width: 900px;
  padding: 20px 16px 48px;
}

:root[data-kiosk="on"] .app-footer,
:root[data-kiosk="on"] .user-menu { display: none; }

:root[data-kiosk="on"] .reg-input,
:root[data-kiosk="on"] .reg-select,
:root[data-kiosk="on"] .reg-btn,
:root[data-kiosk="on"] .reg-initials-input {
  height: 46px;
  font-size: 15px;
}

:root[data-kiosk="on"] .reg-yesno-btn {
  min-width: 68px;
  height: 44px;
  font-size: 13.5px;
}

:root[data-kiosk="on"] .reg-choice {
  padding: 11px 16px;
  font-size: 14.5px;
}

:root[data-kiosk="on"] .reg-title { font-size: 22px; }

:root[data-kiosk="on"] .reg-sig-pad { height: 168px; }

:root[data-kiosk="on"] .reg-hx-table { font-size: 14px; }
:root[data-kiosk="on"] .reg-hx-table td { padding: 10px 8px; }

/* The kiosk's own header, standing in for the hidden app header. */
.reg-kiosk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.reg-kiosk-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.reg-kiosk-brand img { height: 26px; width: auto; }

.reg-kiosk-step {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* The exit affordance is deliberately quiet: a patient should not stumble into
   it, and it asks for a staff password before it does anything. */
.reg-kiosk-exit {
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-5);
  background: none;
  border: 0;
  padding: 6px 8px;
  cursor: pointer;
}

.reg-kiosk-exit:hover { color: var(--ink-3); }

/* Idle overlay — bounds how long an unattended tablet sits on a live session. */
.reg-idle-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.reg-idle-card {
  max-width: 420px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 26px;
}

.reg-idle-card h3 { margin: 0 0 8px; font-size: 17px; color: var(--ink); }
.reg-idle-card p { margin: 0 0 18px; font-size: 13px; line-height: 1.55; color: var(--ink-3); }

/* ── Narrow screens: a tablet in portrait is the primary target ───── */
@media (max-width: 720px) {
  .reg-grid { grid-template-columns: 1fr; }

  .reg-yesno-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .reg-yesno-controls { justify-content: flex-start; }

  /* The 19x2 history grid does not fit two columns of YES/NO at this width.
     The table header repeats as a row label instead of scrolling sideways. */
  .reg-hx-table th:not(:first-child) { width: auto; }
  .reg-hx-table { font-size: 12.5px; }

  .reg-consent-initial { justify-content: flex-start; }

  .reg-actions { flex-direction: column-reverse; align-items: stretch; }
  .reg-actions-right { margin-left: 0; }
  .reg-actions-right .reg-btn { flex: 1 1 auto; }
}
