/* Clinician Webapp — clean clinical theme.
   Brand tokens vendored from the shared LP suite design tokens (clients/brand/BRAND.md
   — the violet "lp" identity). The clinician surface expresses violet as a professional
   accent (nav highlight, active tab, primary buttons) over neutral tables. */

/* The `hidden` attribute must always win. Elements with an explicit `display`
   (e.g. .synthetic-banner { display:flex }) otherwise override the UA
   `[hidden]{display:none}` (equal specificity, later in source), so setting
   `.hidden = true` in JS silently does nothing (the banner-dismiss bug). This
   global reset makes `hidden` authoritative everywhere. */
[hidden] { display: none !important; }

:root {
  --primary: #722ED1;
  --primary-deep: #5924A3;
  --tint: #ede9fe;
  --accent: #5924A3;
  --surface: #f1f1f7;
  --ink: #1f2430;
  --positive: #16a34a;
  --amber: #d97706;
  --error: #dc2626;
  --grey: #94a3b8;
  --violet: #8b5cf6;
  --card: #ffffff;
  --line: #e5e7eb;
  --muted: #6b7280;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 36, 48, 0.04), 0 4px 12px rgba(31, 36, 48, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h3.sub { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 16px 0 8px; }

/* Top bar -------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; background: var(--card);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: block;
}
.brand .mark img { display: block; width: 100%; height: 100%; }
.brand-title { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-thin { font-weight: 400; color: var(--accent); }
.brand-sub { color: var(--muted); font-size: 11px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-btn {
  border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
}
.nav-btn:hover { background: var(--surface); color: var(--ink); }
.nav-btn.active { background: var(--tint); color: var(--primary-deep); }
.topright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 12px; color: var(--muted); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--positive); animation: pulse 2s infinite; }
.live.mock .live-dot { background: var(--amber); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Layout --------------------------------------------------------------- */
#app { max-width: 1180px; margin: 0 auto; padding: 20px 22px 60px; display: flex; flex-direction: column; gap: 16px; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.small { font-size: 11px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.linkback { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; font-size: 13px; align-self: flex-start; }
.err-card h2 { color: var(--error); }

/* Buttons & inputs ----------------------------------------------------- */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); }
.btn-ghost { background: var(--surface); }
.btn-block { width: 100%; margin-top: 4px; }
/* "Sign in with Google" — a white/bordered secondary variant of .btn (SSO-light,
   jds 2026-07-16). Sits under the primary Sign in button on the login card. */
.btn-google { background: #fff; color: var(--ink); border-color: var(--line); font-weight: 600; }
.btn-google:hover { border-color: var(--primary); background: var(--surface); }
.btn-mini { padding: 4px 9px; font-size: 11px; font-weight: 600; }
.inp, .sel, .search { font-size: 13px; color: var(--ink); padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; font-family: inherit; }
.sel { cursor: pointer; }
.search { max-width: 280px; }
.ctl { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); min-width: 120px; }
.form-err { color: var(--error); font-size: 12px; margin: 6px 0; }

/* Login ---------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
/* Language selector — shared by the post-auth topbar and the pre-auth login card. */
.lang-select { font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: inherit; cursor: pointer; }
.login-lang { align-self: flex-end; margin-bottom: 2px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .mark { flex: 0 0 auto; width: 30px; height: 30px; display: block; }
.login-brand .mark img { display: block; width: 100%; height: 100%; }
.login-sub { color: var(--muted); margin: 0 0 6px; font-size: 13px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
/* Synthetic-data banner (persistent, shows on login + app) */
.synthetic-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 7px 22px; font-size: 13px; color: #92400e;
  background: #fef3c7; border-bottom: 1px solid var(--amber);
}
.synthetic-banner__x {
  border: none; background: transparent; color: #92400e; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 4px;
}
.synthetic-banner__x:hover { color: var(--error); }

.demo-creds { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.demo-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.demo-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; text-align: left; }
.demo-chip:hover { border-color: var(--accent); }
.demo-chip b { font-size: 12px; }
.demo-chip span { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.login-foot { font-size: 10px; color: var(--muted); margin: 4px 0 0; }
.login-link { align-self: flex-start; background: none; border: 0; padding: 0; margin: 2px 0 0; font-size: 12px; color: var(--primary); cursor: pointer; text-decoration: underline; }
.login-link:hover { opacity: 0.8; }

/* Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.tbl.compact td, table.tbl.compact th { padding: 6px 8px; }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--surface); }
.subj-id { font-weight: 600; }
.subj-meta { font-size: 10px; color: var(--muted); }
.instr { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* Chips ---------------------------------------------------------------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #fff; }
.chip.complete { background: var(--positive); }
.chip.due { background: var(--amber); }
.chip.overdue { background: var(--error); }
.chip.pending { background: var(--grey); }
.chip.role { background: var(--accent); }
.chip.sev-mild { background: var(--positive); }
.chip.sev-moderate { background: var(--amber); }
.chip.sev-severe { background: var(--error); }
.chip.arm { background: var(--ink); }
.chip.arm-rtsa { background: var(--accent); }
.chip.arm-tsa { background: var(--primary); }
.chip.warn { background: var(--amber); margin-left: 4px; } /* provisional-scoring flag (TG10, rem/g) */
.pill-soft { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }

/* Patient identity card ------------------------------------------------ */
.id-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.id-name { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.id-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.id-contact { display: flex; flex-direction: column; gap: 2px; text-align: right; }

/* eCRF ----------------------------------------------------------------- */
.ecrf-controls { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.ecrf-controls .ctl .sel { min-width: 180px; }
.ecrf-controls .muted { flex: 1; min-width: 180px; }
.ecrf-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.ecrf-field { display: flex; flex-direction: column; gap: 4px; }
.ecrf-field.wide { grid-column: 1 / -1; }
.ecrf-lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.ecrf-lbl .req { color: var(--error); font-style: normal; }
.ecrf-lbl .unit { color: var(--grey); font-weight: 400; font-style: normal; }
.ecrf-help { font-size: 10px; color: var(--grey); }
.ecrf-actions { margin-top: 14px; }
.ecrf-list { display: flex; flex-direction: column; gap: 8px; }
.ecrf-rec { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.ecrf-rec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ecrf-rec-body { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.kv { font-size: 12px; }
.kv i { color: var(--muted); font-style: normal; }

/* Matrix --------------------------------------------------------------- */
.matrix-wrap { overflow-x: auto; }
.matrix { border-collapse: separate; border-spacing: 4px; }
.matrix th { font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 6px; text-align: center; white-space: nowrap; }
.matrix th.row-h, .matrix td.row-h { text-align: left; }
.matrix td.row-h { white-space: nowrap; font-size: 12px; padding-right: 10px; }
.matrix td { width: 56px; height: 34px; }
.tile { width: 100%; height: 100%; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.tile.complete { background: var(--positive); }
.tile.due { background: var(--amber); }
.tile.overdue { background: var(--error); }
.tile.pending { background: var(--grey); opacity: 0.4; }
/* Expected-but-uncaptured cell: violet inner ring flags the missing data. */
.tile.missing { box-shadow: inset 0 0 0 2px var(--violet); }
/* Outstanding-tasks column: red count per subject, the monitor's chase list. */
.matrix th.out-h { text-align: right; padding-right: 8px; }
.matrix td.out-cell { text-align: right; padding-right: 8px; width: auto; }
.out-count { font-weight: 700; font-size: 12px; color: var(--muted); }
.out-count.has { color: var(--error); }
.matrix.filter-outstanding tr.no-outstanding { display: none; }
.only-outstanding {
  display: inline-flex; align-items: center; gap: 4px; margin-left: auto;
  font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--muted); cursor: pointer;
}
.only-outstanding input { accent-color: var(--primary); cursor: pointer; }
.legend { display: inline-flex; gap: 10px; font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.legend i { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-style: normal; }
.legend i::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.legend .l-complete::before { background: var(--positive); }
.legend .l-due::before { background: var(--amber); }
.legend .l-overdue::before { background: var(--error); }
.legend .l-pending::before { background: var(--grey); }

/* Honest fill meter: neutral track, opaque fill (width=magnitude, color=valence) */
.scorecell { display: flex; align-items: center; gap: 9px; }
.scorebar {
  position: relative; width: 72px; height: 8px; border-radius: 999px; flex: 0 0 auto;
  overflow: hidden; background: var(--track, #e5e7eb);
}
.scorebar__fill {
  display: block; height: 100%; border-radius: 999px;
}
.scorecell__val { font-variant-numeric: tabular-nums; }

/* Stats ---------------------------------------------------------------- */
.stats { display: flex; gap: 26px; flex-wrap: wrap; }
.stat { text-align: left; }
.stat-n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Admin ---------------------------------------------------------------- */
.admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.admin-form .inp, .admin-form .sel { width: auto; flex: 1; min-width: 130px; }
.admin-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.invite-box { margin: 10px 0; padding: 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--tint); }
.invite-head { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.invite-link { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-link code { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; word-break: break-all; }

/* Toast ---------------------------------------------------------------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); z-index: 50; opacity: 0; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; }
  .id-contact { text-align: left; }
}

/* =====================================================================
   Patient cohort grid (viewPatients — Tabulator-based)
   ===================================================================== */

/* Full-width override — applied only when the grid is active */
.view-grid #app {
  max-width: none;
  padding-left: 16px;
  padding-right: 16px;
}

/* Page wrapper */
.grid-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Controls row above the table */
.grid-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.grid-search { max-width: 240px; }
.grid-chk-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.grid-chk-label input { accent-color: var(--primary); cursor: pointer; }
.grid-legend { margin-left: auto; }

/* Patient name card — identity compacted into one frozen column (jds 2026-07-03) */
.pcard { display: flex; flex-direction: column; gap: 1px; line-height: 1.3; padding: 2px 0; }
.pcard-flex { flex: 1; }
.pcard-name { font-weight: 650; font-size: 13px; color: var(--ink); }
.pcard-sub { font-size: 11px; color: var(--muted); }
.pcard-meta { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); flex-wrap: nowrap; overflow: hidden; }
.pcard-meta .chip { font-size: 9.5px; padding: 1px 7px; }
.pcard-name .chip { font-size: 9px; padding: 1px 7px; vertical-align: middle; margin-left: 2px; } /* cohort chip rides the name line (jds 2026-07-03) */
.pcard-id { font-family: ui-monospace, Menlo, monospace; font-size: 9.5px; opacity: 0.75; color: var(--muted); }
.pcard-tag { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0 6px; font-size: 9px; white-space: nowrap; }
.pcard-meta .cbtn { padding: 1px 6px; }

/* Completion dial — event-labeled chain (Claude-Design "Progress dial" grammar,
   jds 2026-07-03): thick-bordered state nodes, solid connectors between
   resolved visits, gray dotted into the future, purple ring on the due node. */
.mdial { display: inline-flex; align-items: flex-start; }
.mdial-u { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; min-width: 34px; }
.mdial-l { font-size: 8.5px; font-weight: 650; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.mdial-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 8px; color: #fff; border: 2px solid #565b66; box-sizing: border-box; }
.mdial-n svg { display: block; }
/* due ring retired — the vivid-yellow UNDERLAY (below) replaces it */
/* Connectors TOUCH the boxes: negative margins run the line under the node
   edges; nodes sit above (z-index) with opaque backgrounds. */
.mdial-c { width: 14px; margin-left: -6px; margin-right: -6px; border-top: 2.5px solid #565b66; margin-top: 24px; flex: none; z-index: 0; } /* visible line halved: net gap 26->14 shrinks center-to-center pitch uniformly (jds 2026-07-03) */
.mdial-c.dot { border-top-color: #cdd2dc; } /* light-gray SOLID (dotted retired, jds 2026-07-03) */
.mdial-c.gap { border-top-style: dotted; } /* chain BREAK (hidden items skipped) — dotted, color from the full chain's connector into the right item (jds 2026-07-03) */
.mdial-n, .rdial-v { position: relative; z-index: 1; }
/* Unfinalized shapes: SOLID outlines (dotted retired, jds 2026-07-03) */

/* Result-card dial values (jds 2026-07-03): SAME pastel conventions as the
   state plates — data chips are pastel done-green with plain black values
   (heat-tint retired); the pitch may exceed the default when a wide value
   would otherwise overlap (min-width units, auto growth, connector net gap
   keeps a sliver of daylight between chips). */
.rdial-u { min-width: 38px; width: auto; }
.rdial-v {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 24px; padding: 0 3px; box-sizing: border-box;
  background: #00703c; border: 2px solid #565b66; border-radius: 8px; /* completed stroke = connector dark */
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; font-weight: 400;
  color: #fff; /* white on guide-sign green (sign-standard contrast) */
}

.rdial-fut { border-color: #cdd2dc; color: var(--grey); font-weight: 500; background: var(--surface); } /* stroke = connector gray */
.rdial-v.rdial-due { background: #ff8200; color: #1f2430; } /* due-awaiting chip: pastel orange plate */

/* Style-enhanced Next-PROM cell: state word over a date pill */
.npx { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2; }
.npx-word { font-size: 8.5px; font-weight: 800; letter-spacing: 0.08em; }
.npx-due .npx-word { color: var(--primary); }
.npx-soon .npx-word { color: var(--amber); }
.npx-date { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 1px 7px; }
.npx-due .npx-date { border-color: var(--primary); font-weight: 700; }
.npx-done { font-size: 11px; color: var(--muted); }
.npx-win { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; } /* collection window under the date (jds 2026-07-03) */

/* Progress bar in the grid (used by Tabulator HTML formatter) */
.grid-progress { display: flex; align-items: center; gap: 6px; }
.grid-progbar { width: 44px; height: 6px; }
.grid-progress-txt { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* PROM score cell inside the grid (used by Tabulator HTML formatter) */
.grid-score {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.grid-score__bar {
  display: inline-block;
  width: calc(var(--frac, 0) * 32px);
  max-width: 32px;
  min-width: 2px;
  height: 6px;
  border-radius: 999px;
  background: hsl(var(--hue, 60) 70% 45%);
  vertical-align: middle;
}

/* Ledger data-update rows (jds 2026-07-03, per the ledger-delta mock).
   ONE text line tall (26px) — overriding the grid's uniform 64px row height;
   the v6 virtual scroller measures real heights so mixed heights are safe
   (verified by deep-scroll probe). */
.tab-wrap.tabulator .tabulator-row.upd-row { height: 26px !important; min-height: 26px; }
.tab-wrap.tabulator .tabulator-row.upd-row .tabulator-cell {
  height: 25px !important; padding-top: 1px !important; padding-bottom: 1px !important;
}
.tab-wrap.tabulator .tabulator-row.upd-row,
.tab-wrap.tabulator .tabulator-row.upd-row.tabulator-row-even { background: #f6f3fd; }
.tab-wrap.tabulator .tabulator-row.upd-row .tabulator-cell.tabulator-frozen.tabulator-frozen-left { background: #efe9fb; }
.upd-label { font-size: 11.5px; color: var(--primary-deep); font-weight: 650; padding-left: 14px; }
.upd-date { font-family: ui-monospace, Menlo, monospace; font-size: 10px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.upd-val { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: #3b2b70; background: #ece4fa; border-radius: 6px; padding: 1px 7px; }

/* Directory section headers w/ popup-form buttons (jds 2026-07-03) */
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.admin-head h2 { margin: 0; }

/* Add-clinical-data modal (jds 2026-07-03) */
.adddata-card { width: min(680px, 92vw); max-height: 84vh; overflow-y: auto; }
.adddata-visit { max-width: 240px; margin: 6px 0 2px; }
.adddata-section { margin: 10px 0 2px; }
.adddata-section h3 { font-size: 12.5px; margin: 0 0 6px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.adddata-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 14px; }
.adddata-fldhead { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.adddata-fldhead .corr-chk { width: 13px; height: 13px; accent-color: #ff8200; }
.adddata-locked .inp[disabled], .adddata-locked .sel[disabled] { background: var(--surface); color: var(--muted); }
.adddata-prep { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
/* Correction submit: road-sign orange (matches the due convention) */
.btn-correction { background: #ff8200; border-color: #ff8200; color: #1f2430; font-weight: 700; }
.btn-correction[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-correction:hover:not([disabled]) { background: #f07600; border-color: #f07600; }



/* Read-only Study details (jds 2026-07-03): builder chrome minus editing */
.sb-locked .sb-add, .sb-locked .sb-remove { display: none; }
.sb-locked input[disabled], .sb-locked select[disabled] { opacity: 1; color: var(--ink); background: var(--surface); cursor: default; }

/* Patients roster sheet (jds 2026-07-03): registry skin + selection */
.roster-spacer { flex: 1; }
.roster-tick { color: #00703c; font-weight: 800; }
.roster-flag { color: #c1121c; font-weight: 700; } /* positive comorbidity flag */
.roster-mail { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
.tab-wrap.tabulator .tabulator-row.tabulator-selected,
.tab-wrap.tabulator .tabulator-row.tabulator-selected.tabulator-row-even { background: #f2edfe; }
.tab-wrap.tabulator .tabulator-row.tabulator-selected .tabulator-cell.tabulator-frozen.tabulator-frozen-left { background: #e9e2fb; }
.tab-wrap.tabulator .tabulator-cell.roster-chk input { width: 14px; height: 14px; accent-color: var(--primary); }
/* Select-all header checkbox must share the row checkboxes' column axis (jds 2026-07-10):
   body cells carry padding:3px 8px + hozAlign center, but the header col-content defaults
   to 4px padding and the global header rule forces text-align:left — together those shifted
   the title checkbox left of the row checkboxes. Re-center it and match the body H-padding. */
.tab-wrap.tabulator .tabulator-header .tabulator-col.roster-chk .tabulator-col-content { padding: 4px 8px; }
.tab-wrap.tabulator .tabulator-header .tabulator-col.roster-chk .tabulator-col-title { text-align: center; }
.tab-wrap.tabulator .tabulator-header .tabulator-col.roster-chk input { width: 14px; height: 14px; accent-color: var(--primary); }

/* Editable-ledger roster (jds 2026-07-16): per-row actions + the two modals */
.tab-wrap.tabulator .tabulator-cell.roster-act { display: flex; align-items: center; justify-content: center; gap: 3px; }
.tab-wrap.tabulator .tabulator-cell.roster-act .cbtn { padding: 2px 5px; }
/* Cell editability color coding (jds 2026-07-17). Two tones, not a rainbow:
   editable cells stay white and grow a violet tint + pencil cue on hover;
   non-editable cells (locked-for-you OR fixed-by-design) share one soft gray
   wash — the tooltip carries the reason. Alpha washes so the selection /
   hover / zebra states underneath still read. */
.tab-wrap.tabulator .tabulator-cell.cell-locked,
.tab-wrap.tabulator .tabulator-cell.cell-fixed {
  background-color: rgba(31, 36, 48, 0.035);
  color: var(--muted);
}
.tab-wrap.tabulator .tabulator-cell.cell-edit { cursor: cell; position: relative; }
@media (hover:hover) and (pointer:fine) {
  .tab-wrap.tabulator .tabulator-row.tabulator-selectable:hover .tabulator-cell.cell-edit:hover {
    background-color: #efe9fb; /* the upd-row violet family */
    box-shadow: inset 0 0 0 1px var(--primary);
  }
  .tab-wrap.tabulator .tabulator-cell.cell-edit:hover::after {
    content: "✎";
    position: absolute; top: 2px; right: 4px;
    font-size: 10px; color: var(--primary);
    opacity: 0.65; pointer-events: none;
  }
}

/* Pinned-details composer (jds 2026-07-17): per-section disclosures of pin
   chips + a drag-rearrangeable pinned-order list. */
.pin-sections { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.pin-section { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.pin-section summary { cursor: pointer; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.pin-chipflow { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 2px 4px; }
.pin-chip.active { background: var(--tint); border-color: var(--primary); color: var(--primary-deep); font-weight: 600; }
.pin-order { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.pin-order-item {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px; cursor: grab;
}
.pin-order-item.dragging { opacity: 0.45; }
.pin-order-item.dragover { border-color: var(--primary); box-shadow: 0 -2px 0 var(--primary); }
.pin-order-lbl { flex: 1; }
.pin-grip { color: var(--muted); font-size: 11px; letter-spacing: -2px; cursor: grab; }
.pin-remove { font-size: 16px; }
.pin-order-empty { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }

/* Soft-guardrail suggestion chips (in-use tags) — jds 2026-07-17 */
.pedit-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 5px; }
.pedit-chip {
  appearance: none; cursor: pointer; font: inherit; font-size: 11.5px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 10px;
}
.pedit-chip:hover { background: var(--tint); border-color: var(--primary); color: var(--primary-deep); }
.pedit-attrs { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; }
.pedit-attr-row { display: flex; gap: 6px; align-items: center; }
.pedit-attr-row .pedit-attr-key { flex: 0 1 170px; }
.pedit-attr-row .pedit-attr-val { flex: 1; min-width: 90px; }
.phist-body { margin-top: 8px; }
.phist-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.phist-table th, .phist-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.phist-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.phist-table td { overflow-wrap: anywhere; }
.phist-when { white-space: nowrap; color: var(--muted); }
.phist-empty { padding: 10px 2px; }

/* Column picker dropdown */
.col-picker-wrap { position: relative; }
.col-picker-btn {
  font-size: 12px; padding: 6px 11px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 1px 2px rgba(31, 36, 48, 0.06); /* lift off the page bg (jds 2026-07-03) */
}
.col-picker-btn:hover { border-color: var(--primary); }
.col-picker-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px 0;
  min-width: 160px;
}
.col-picker-menu.open { display: block; }
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.col-picker-item:hover { background: var(--surface); }
.col-picker-item input { accent-color: var(--primary); cursor: pointer; }

/* Edit mode controls */
.edit-mode-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.edit-mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.edit-mode-bar__label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.edit-sel { width: auto; min-width: 110px; font-size: 12px; padding: 5px 8px; }
.edit-save-btn { font-size: 12px; padding: 6px 14px; }

/* Tabulator container */
.tab-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- Tabulator LP violet theme overrides ---- */

/* Header */
.tabulator .tabulator-header {
  background: var(--card);
  border-bottom: 2px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tabulator .tabulator-header .tabulator-col {
  background: var(--card);
  border-right: 1px solid var(--line);
}
.tabulator .tabulator-header .tabulator-col:hover {
  background: var(--surface);
}
/* Column group headers */
.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-title {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
/* Sort arrows use lp violet */
.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title::after {
  color: var(--primary);
}
/* Frozen column separator */
.tabulator .tabulator-frozen.tabulator-frozen-right,
.tabulator .tabulator-frozen {
  border-right: 2px solid var(--line);
}
/* Active sort highlight */
.tabulator .tabulator-header .tabulator-col[aria-sort="ascending"] .tabulator-col-title,
.tabulator .tabulator-header .tabulator-col[aria-sort="descending"] .tabulator-col-title {
  color: var(--primary-deep);
}

/* Rows */
.tabulator .tabulator-row {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.tabulator .tabulator-row:nth-child(even) {
  background: #fafafe;
}
.tabulator .tabulator-row:hover,
.tabulator .tabulator-row.tabulator-row-even:hover {
  background: var(--tint) !important;
}
.tabulator .tabulator-row .tabulator-cell {
  border-right: 1px solid var(--line);
  /* Compact rows (jds: the old 6px vertical padding read as double-spacing). */
  padding: 3px 8px;
  vertical-align: middle;
}
/* Frozen cell (Patient name) */
.tabulator .tabulator-row .tabulator-cell.tabulator-frozen {
  background: inherit;
  border-right: 2px solid var(--line);
  font-weight: 600;
}

/* Header filter inputs */
.tabulator .tabulator-header .tabulator-header-filter input {
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
  color: var(--ink);
  background: var(--surface);
  width: 100%;
}
.tabulator .tabulator-header .tabulator-header-filter input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Placeholder */
.tabulator .tabulator-placeholder {
  color: var(--muted);
  font-size: 13px;
  padding: 40px;
}

/* Edit cells — highlight with amber left border */
.tabulator .tabulator-row .tabulator-cell.ecrf-edit-cell {
  background: #fffbf0;
  border-left: 2px solid var(--amber);
}
.tabulator .tabulator-row .tabulator-cell.ecrf-edit-cell:focus-within,
.tabulator .tabulator-row .tabulator-cell.tabulator-editing {
  background: #fff9e6;
  box-shadow: inset 0 0 0 2px var(--amber);
}

/* Dirty rows (have unsaved edits) */
.tabulator .tabulator-row.row-dirty {
  background: #fffdf0 !important;
}
.tabulator .tabulator-row.row-dirty .tabulator-cell:first-child {
  border-left: 3px solid var(--amber);
}

/* ---- Legacy grid-empty used elsewhere ---- */
.grid-empty { padding: 32px; text-align: center; }

/* Inspector panel — right-side slide-in drawer */
.inspector {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(460px, 92vw);
  overflow-y: auto;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -4px 0 24px rgba(31, 36, 48, 0.12);
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.inspector.open { transform: translateX(0); }

.inspector-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgba(31, 36, 48, 0.28);
}
.inspector-backdrop.open { display: block; }

.insp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.insp-title { flex: 1; min-width: 0; }
.insp-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.insp-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.insp-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
  flex: 0 0 auto;
}
.insp-close:hover { color: var(--error); }

.insp-body { padding: 14px 18px 32px; display: flex; flex-direction: column; gap: 4px; }

.insp-section-head {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.insp-visit {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--surface);
}
.insp-visit-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.insp-instr {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  font-size: 12px;
}
.insp-instr-name {
  width: 40px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex: 0 0 auto;
}

.insp-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.insp-kv span { color: var(--muted); }
.insp-kv b { font-variant-numeric: tabular-nums; }

.insp-actions { margin-top: 16px; }

/* =====================================================================
   Study Health Dashboard (#/dashboard)
   ===================================================================== */

/* Two-column layout for completion + workload cards side-by-side */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 820px) { .dash-row { grid-template-columns: 1fr; } }

/* Two-col inside a card (enrolment breakdown) */
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}
@media (max-width: 600px) { .dash-two-col { grid-template-columns: 1fr; } }

/* Horizontal bar breakdown (by centre / by arm) */
.dash-breakdown-row {
  display: grid;
  grid-template-columns: 110px 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.dash-breakdown-label {
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-breakdown-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
  color: var(--ink);
}
.dash-hbar {
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}
.dash-hbar__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Per-visit completion bars */
.dash-visit-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.dash-visit-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 36px;
  align-items: center;
  gap: 8px;
}
.dash-visit-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-visit-bar-wrap { flex: 1; }
.dash-visit-pct { text-align: right; font-variant-numeric: tabular-nums; }

/* Overdue subject list */
.dash-overdue-list { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.dash-overdue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.dash-overdue-row:last-child { border-bottom: none; }
.dash-overdue-name { font-size: 13px; font-weight: 600; }

/* PROM summary grid */
.dash-prom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 4px;
}
.dash-prom-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-prom-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.dash-prom-name {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.dash-prom-mean {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.dash-prom-overall-bar { margin: 0; }
.dash-prom-bar { width: 100%; height: 8px; }
.dash-prom-trend { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.dash-prom-trend-row {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  align-items: center;
  gap: 6px;
}
.dash-prom-visit { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-prom-val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ─── Insights Hub (Design 14) ─────────────────────────────────── */
.ins-hub {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}

/* Section nav */
.ins-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 72px;
}
.ins-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 11px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.ins-nav-btn:hover:not(:disabled) { background: var(--surface); }
.ins-nav-btn.active { background: var(--tint); }
.ins-nav-btn:disabled { opacity: 0.55; cursor: default; }
.ins-nav-title { font-size: 12px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.ins-nav-btn.active .ins-nav-title { color: var(--primary-deep); }
.ins-nav-q { font-size: 10px; color: var(--muted); line-height: 1.3; }
.ins-coming-chip {
  font-size: 9px;
  background: var(--line);
  color: var(--muted);
  border-radius: 4px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

/* Content pane */
.ins-content { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ins-section-wrap { display: flex; flex-direction: column; gap: 14px; }

/* Shared envelope strip */
.ins-envelope {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  background: var(--tint);
  border-radius: 8px;
  font-size: 11px;
  color: var(--muted);
}
.ins-env-label { font-weight: 600; color: var(--primary-deep); }
.ins-env-item { }
.ins-env-suppress { color: var(--amber); }

/* Tables */
.ins-tbl { width: 100%; }
.ins-tbl th { font-weight: 600; }
.ins-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Distribution block (descriptive) */
.ins-dist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 10px; }
.ins-dist-block { display: flex; flex-direction: column; gap: 4px; }
.ins-dist-name { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 2px; }
.ins-dist-row { display: grid; grid-template-columns: 90px 1fr 72px; align-items: center; gap: 6px; font-size: 12px; }
.ins-dist-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ins-dist-bar-wrap { }
.ins-dist-bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.ins-dist-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s; }
.ins-dist-pct { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }

/* Contrast cards (associational + causal) */
.ins-contrast-card { margin-bottom: 0; }
.ins-contrast-header { margin-bottom: 8px; }
.ins-contrast-q { font-size: 13px; font-weight: 600; color: var(--ink); }
.ins-contrast-body { display: flex; flex-direction: column; gap: 6px; }
.ins-est { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary-deep); }
.ins-est-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-right: 4px; }
.ins-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* Refutations (causal) */
.ins-refutations { margin-top: 10px; }
.ins-refut-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 4px; }
.ins-refut-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }

/* Caution / note banners */
.ins-note {
  padding: 9px 13px;
  background: #fef9c3;
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}
.ins-caveat {
  font-size: 11px;
  color: var(--muted);
  padding: 7px 10px;
  background: var(--surface);
  border-radius: 6px;
  border-left: 2px solid var(--line);
}
.ins-caveat-list { display: flex; flex-direction: column; gap: 4px; }

/* Cox HR */
.ins-cox { margin-top: 10px; font-size: 13px; }

/* Survival SVG */
.ins-km-wrap { margin: 8px 0 12px; }
.ins-km-svg { width: 100%; max-width: 520px; display: block; }

/* Cohort-similarity network (last_viz / CSX) */
.ins-net-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ins-net-demo {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #722ED1;
  background: #f3f0ff;
  border: 1px solid #ddd6fe;
  border-radius: 999px;
  padding: 2px 10px;
}
.ins-net-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}
.ins-net-anchor {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.ins-net-meta {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
}

/* Scale controls (sample / min edge weight / max link dims) + filter chips */
.ins-net-scale,
.ins-net-filterrow {
  margin: 0 0 10px;
}
.ins-net-num {
  width: 68px;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.ins-net-filterfeat { min-width: 130px; }
.ins-net-filterval {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-width: 150px;
}
.ins-net-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ins-net-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef2ff;
  color: var(--ink);
}
.ins-net-chip-x {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  padding: 0 2px;
}
.ins-net-chip-x:hover { color: #ef4444; }
.ins-net-banner {
  font-size: 12.5px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 0 0 10px;
}
.ins-net-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 2px 0 10px;
}
.ins-net-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.ins-net-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
}
.ins-net-wrap {
  position: relative;
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fbfcfe;
}
.ins-net-svg { width: 100%; display: block; }

/* Re-layout / control buttons */
.ins-net-btn,
.ins-net-clear {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.ins-net-btn:hover,
.ins-net-clear:hover { background: #f1f5f9; }

/* Link-by multi-select (clinical link-feature checklist) */
.ins-net-linkwrap { position: relative; display: inline-block; }
.ins-net-linkmenu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.ins-net-linkmenu[hidden] { display: none; }
.ins-net-linkopt {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink);
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.ins-net-linkopt:hover { background: #f1f5f9; }
.ins-net-linktype { margin-left: auto; }
.ins-net-linkfoot {
  display: flex;
  justify-content: flex-end;
  padding: 6px 4px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

/* Explainer strip */
.ins-net-explainer {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 2px 0 8px;
}

/* Clickable community legend chips */
.ins-net-leg-comm { cursor: pointer; padding: 1px 6px; border-radius: 999px; }
.ins-net-leg-comm:hover { background: #eef2ff; }
.ins-net-leg-comm.is-active {
  background: #eef2ff;
  outline: 1px solid #c7d2fe;
  color: var(--ink);
}
.ins-net-legend-group { opacity: 0.85; }

/* Body: graph stage + detail card side-by-side */
.ins-net-body { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.ins-net-stage { position: relative; flex: 1 1 480px; min-width: 320px; }

/* "computing layout…" state */
.ins-net-wrap.is-computing::after {
  content: "computing layout…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  background: rgba(251, 252, 254, 0.72);
  z-index: 3;
}

/* Node / edge interaction states */
.ins-net-node { cursor: pointer; transition: opacity 0.12s ease; }
.ins-net-node.is-on { stroke: #1f2430; stroke-width: 1.6; }
.ins-net-node.is-dim { opacity: 0.16; }
.ins-net-edge { transition: opacity 0.12s ease; }
.ins-net-edge.is-on { stroke: #4338ca; stroke-opacity: 0.9 !important; }
.ins-net-edge.is-dim { opacity: 0.08; }
.ins-net-edge-hit { cursor: pointer; }
.ins-net-label { pointer-events: none; }
.ins-net-label.is-dim { opacity: 0.15; }

/* Tooltip */
.ins-net-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  max-width: 320px;
  font-size: 12px;
  line-height: 1.35;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.94);
  border-radius: 6px;
  padding: 5px 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
}

/* Detail card */
.ins-net-detail {
  flex: 0 1 280px;
  min-width: 240px;
  display: none;
}
.ins-net-detail.is-open {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}
.ins-net-detail-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.ins-net-detail-head strong { flex: 1; word-break: break-word; }
.ins-net-detail-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto;
}
.ins-net-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0 0 8px;
  font-size: 13px;
}
.ins-net-dl dt { color: var(--muted); }
.ins-net-dl dd { margin: 0; }
.ins-net-detail-neigh { font-size: 12px; }
.ins-net-detail-pair {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px;
}
.ins-net-conn {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
.ins-net-conn td {
  padding: 3px 6px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}
.ins-net-conn-feat { color: var(--muted); white-space: nowrap; }
.ins-net-conn-val { font-weight: 600; word-break: break-word; }

/* Predictive */
/* (re-uses .stats / .stat defined globally) */

/* Coming-soon placeholder */
.ins-coming {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 240px;
  padding: 40px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}
.ins-coming-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.ins-coming-q { font-size: 14px; color: var(--muted); }
.ins-coming-note {
  font-size: 12px;
  color: var(--muted);
  max-width: 380px;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
}

/* Generic inline chart (trajectories / forest / SPC / benchmark / scatter) */
.ins-chart-wrap { margin: 8px 0 4px; }
.ins-chart-svg { width: 100%; max-width: 580px; display: block; }

/* Parameters & configuration panel */
.ins-cfg {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 0;
}
.ins-cfg-summary {
  cursor: pointer;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-deep);
  list-style: none;
}
.ins-cfg-summary::-webkit-details-marker { display: none; }
.ins-cfg-summary::before { content: "▸ "; color: var(--muted); }
.ins-cfg[open] .ins-cfg-summary::before { content: "▾ "; }
.ins-cfg-body {
  padding: 4px 16px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.ins-cfg-group { display: flex; flex-direction: column; gap: 3px; }
.ins-cfg-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 8px;
}
.ins-cfg-demo { border-left: 3px solid var(--amber); padding-left: 12px; }
.ins-cfg-synth { font-size: 9px; }
.ins-cfg-note { font-size: 11px; color: var(--muted); margin-bottom: 6px; font-style: italic; }
.ins-cfg-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; font-size: 12px; align-items: baseline; }
.ins-cfg-k { color: var(--muted); }
.ins-cfg-v { color: var(--ink); }
.ins-cfg-v.mono { font-family: ui-monospace, Menlo, monospace; }

/* Phenotype cluster cards */
.ins-cluster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ins-cluster-card { margin-bottom: 0; }
.ins-cluster-head { display: flex; align-items: center; gap: 10px; }
.ins-cluster-dot {
  width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.ins-cluster-label { font-size: 13px; font-weight: 600; color: var(--ink); }

/* Evidence / guideline cards */
.ins-ev-grid { display: flex; flex-direction: column; gap: 12px; }
.ins-ev-card { margin-bottom: 0; }
.ins-ev-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ins-ev-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.ins-ev-rec { font-size: 13px; color: var(--ink); margin-top: 6px; line-height: 1.45; }
.ins-ev-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.ins-ev-link { font-size: 12px; font-weight: 600; color: var(--primary); text-decoration: none; }
.ins-ev-link:hover { text-decoration: underline; }

/* ❓ Help overlay — Design 16 Path B ----------------------------------------
   Dim layer fills the full viewport (fixed). Spotlight ring outlines the target
   element with a bright glow. Caption card floats nearby with step text +
   navigation. All z-indices are above the topbar (z-index:10).
   --------------------------------------------------------------------------- */

/* Full-viewport dim + interaction shield */
.hlp-dim {
  position: fixed;
  inset: 0;
  z-index: 900;
  /* Semi-transparent dark veil — pointer-events on so clicks on the dim close */
  background: rgba(15, 18, 30, 0.55);
  /* No pointer-events blocking by default; card + ring handle their own */
}

/* Spotlight ring — a bright outlined box drawn over the target element */
.hlp-ring {
  position: fixed;
  z-index: 901;
  border-radius: 8px;
  border: 2.5px solid var(--primary);
  box-shadow:
    0 0 0 4px rgba(114, 46, 209, 0.18),
    0 0 24px 6px rgba(114, 46, 209, 0.28);
  pointer-events: none;
  /* Smooth repositioning between steps */
  transition: top 0.18s ease, left 0.18s ease, width 0.18s ease, height 0.18s ease;
  background: rgba(114, 46, 209, 0.04);
}

/* Caption card */
.hlp-card {
  position: fixed;
  z-index: 902;
  width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(15, 18, 30, 0.22), 0 1px 4px rgba(15, 18, 30, 0.10);
  padding: 16px 18px 14px;
  font-family: inherit;
  color: var(--ink);
  transition: top 0.18s ease, left 0.18s ease;
  /* prevent the card itself from closing the tour when clicked */
  pointer-events: auto;
}

/* Step counter "Step N of M" */
.hlp-counter {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
  margin-bottom: 8px;
}

/* Step explanation text */
.hlp-text {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

/* "Element not visible" skip note */
.hlp-skip-note {
  display: none;
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 8px;
}

/* Navigation row */
.hlp-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Shared button base */
.hlp-btn {
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  transition: background 0.1s, border-color 0.1s;
}
.hlp-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.hlp-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

/* "Next →" / "Done ✓" gets the primary colour */
.hlp-btn-next {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  margin-left: auto;
}
.hlp-btn-next:hover:not(:disabled) {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: #fff;
}

/* Close button — subtle */
.hlp-btn-close {
  background: none;
  border-color: var(--line);
  color: var(--muted);
}
.hlp-btn-close:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--muted);
}
.ins-ev-cite { margin-top: 6px; font-style: italic; }

/* --- Onboarding view (Design 17) --------------------------------------- */
.onb-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 0; }
.onb-header { margin-bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.onb-header h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); }
.onb-section { display: flex; flex-direction: column; gap: 10px; padding: 16px 0; }
.onb-section h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--ink); }
.onb-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.onb-row .sel { flex: 1; min-width: 200px; }
.onb-divider { display: flex; align-items: center; gap: 12px; padding: 8px 0; color: var(--muted); font-size: 12px; }
.onb-divider::before, .onb-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.onb-locked-org { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--ink); flex-wrap: wrap; }

/* --- Distributions section + delivery-log panel (ported from portal-staff) --- */
.dist-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Delivery-log panel. Class selectors reused verbatim from portal-staff; the
   ids that mount these are dist-* namespaced in index.html. --fg mapped to the
   clinician's --ink foreground token; no new accent colors introduced. */
.outbox-backdrop {
  position: fixed; inset: 0; z-index: 210;
  background: rgba(31, 36, 48, 0.35);
}
.outbox-backdrop[hidden] { display: none; }
.outbox-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 220;
  width: min(680px, 100vw);
  background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -4px 0 24px rgba(31,36,48,0.14);
  display: flex; flex-direction: column;
}
.outbox-panel[hidden] { display: none; }
.outbox-inner { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.outbox-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px 14px; border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.outbox-devnote {
  display: block; margin-top: 4px; font-size: 11px; color: var(--amber); font-weight: 400;
}
.outbox-head-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.outbox-tabs {
  display: flex; gap: 4px; padding: 8px 20px 0; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.outbox-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: 8px 12px; font: inherit; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.outbox-tab:hover { color: var(--ink); }
.outbox-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.outbox-body { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }
.outbox-row {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px;
  margin-bottom: 8px; font-size: 13px; line-height: 1.55;
}
.outbox-row-meta {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  margin-bottom: 4px;
}
.outbox-to { font-weight: 600; }
.outbox-kind { font-size: 11px; padding: 1px 7px; border-radius: 12px; background: var(--surface); color: var(--muted); }
.outbox-instr { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.outbox-status-ok  { font-size: 11px; color: var(--positive); font-weight: 600; }
.outbox-status-err { font-size: 11px; color: var(--error); font-weight: 600; }
.outbox-sent-at { font-size: 11px; color: var(--muted); margin-left: auto; }
.outbox-subject { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.outbox-preview { font-size: 12px; color: var(--muted); white-space: pre-wrap; word-break: break-all; }
.outbox-empty { padding: 24px 0; text-align: center; color: var(--muted); font-size: 13px; }

/* Monitoring redesign — patients-table with derived per-timepoint status cells */
.mon-table th.mon-tp, .mon-table td.mon-tp { text-align: center; }
.mon-table th.mon-next-h { white-space: nowrap; }
.mon-chip {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; color: #fff;
}
/* Completion-matrix cell: a colour-filled square carrying the state's
   symbol (check/x/calendar-event/exclamation-circle/zzz). The word rides on
   the tooltip; the legend spells the mapping out. */
.mon-sq {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; color: #fff; vertical-align: middle;
}
.mon-sq svg { display: block; }
/* Per-row contact buttons (mail/link icons inline with the label). */
.cbtn { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cbtn svg { flex: 0 0 auto; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 11px; color: var(--muted); }
.legend-item .mon-sq { width: 17px; height: 17px; border-radius: 5px; }
.legend-item .mon-sq svg { width: 11px; height: 11px; }
/* Brighter state palette (jds 2026-07-03): soon=orange, due=yellow w/ BLACK
   symbol, future=open light card (result-dial treatment). */
/* ROAD-SIGN state system (jds 2026-07-03): MUTCD-style hues — already
   colorblind-vetted; glyph color per sign standard (white on green/red,
   black on yellow/orange). */
.mon-complete { background: #00703c; color: #fff; }     /* guide-sign green */
.mon-due      { background: #ff8200; color: #1f2430; }  /* work-zone orange (exclamation) */
.mon-soon     { background: #ffcd00; color: #1f2430; }  /* warning yellow (diamond) */
.mon-missed   { background: #c1121c; color: #fff; }     /* stop-sign red */
.mon-future   { background: var(--surface); color: #9ca3af; }
/* future nodes: outer stroke = the light-gray connector color */
.mdial-n.mon-future { border-color: #cdd2dc; }
.mon-sq.mon-future  { border: 1px solid #cdd2dc; }
.mdial-n.mon-soon, .mon-sq.mon-soon { color: #1f2430; }
.mon-id   { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; }
.mon-surg { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
.mon-next { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }
.mon-next.act { font-weight: 700; color: var(--accent); }
.mon-legend { display: flex; gap: 6px; align-items: center; padding: 4px 0 12px; }
.mon-sent { color: var(--positive) !important; border-color: var(--positive) !important; }
.mon-pt-link { color: var(--ink); text-decoration: none; }
.mon-pt-link:hover { color: var(--accent); text-decoration: underline; }
/* Patients spreadsheet filter bar */
.grid-filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; font-size: 12.5px; }
.grid-filters label { display: flex; gap: 5px; align-items: center; }
.grid-filters-item { display: flex; gap: 5px; align-items: center; } /* non-<label> filter entries (Status menu — a label would forward clicks into the checkboxes) */
.grid-filter-lbl { color: var(--muted); font-weight: 600; }
.grid-filter { border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; font-size: 12px; background: #fff; }
.grid-filter-note { color: var(--muted); font-size: 11px; margin-left: auto; }
/* Title row: the study dropdown IS the page title (jds) — "All studies" or one
   study. Big, borderless-until-hover select so it reads as a heading that
   happens to be choosable; the muted caption carries the metadata beside it. */
.grid-title-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 2px 0 4px; }
.study-title-select {
  appearance: none; -webkit-appearance: none;
  font-size: 21px; font-weight: 750; letter-spacing: -0.01em; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  padding: 2px 30px 3px 8px; margin-left: -8px; cursor: pointer; max-width: 60vw;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.study-title-select:hover, .study-title-select:focus-visible {
  border-color: var(--line); background-color: var(--surface);
}
.study-title-static { font-size: 21px; font-weight: 750; letter-spacing: -0.01em; color: var(--ink); }
.grid-caption { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.grid-caption-sub { color: var(--muted); opacity: .8; }
/* Add-patient modal — two-column field grid (addp-* namespaced). */
.addp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.addp-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px 14px; }
/* Combined Add-patients modal (jds 2026-07-17): mode segment spacing */
.addp2-seg { margin: 6px 0 12px; }
.addp2-seg .seg { padding: 6px 14px; cursor: pointer; font-size: 13px; }
@media (max-width: 640px) { .addp-grid, .addp-grid3 { grid-template-columns: 1fr; } }

/* --- Survey kiosk mode ---------------------------------------------------- */
/* Login opt-in */
.kiosk-opt { display: flex; align-items: center; gap: 7px; margin: 8px 0 2px; font-size: 13px; cursor: pointer; }
/* Setup */
.kiosk-setup .kiosk-inst-list { display: flex; flex-direction: column; gap: 6px; }
.kiosk-inst { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
/* Shell — big-touch, patient-facing */
body.kiosk-mode .topbar, body.kiosk-mode .synthetic-banner { display: none !important; }
.kiosk-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--surface), #fff); padding: 24px; position: relative;
}
.kiosk-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 40px 44px; max-width: 720px; width: 100%;
  display: flex; flex-direction: column; gap: 18px; text-align: center;
}
.kiosk-card.kiosk-form { text-align: left; max-height: 92vh; overflow-y: auto; }
.kiosk-brand { display: flex; justify-content: center; }
.kiosk-title { font-size: 34px; margin: 0; letter-spacing: -0.02em; }
.kiosk-title-sm { font-size: 22px; margin: 0 0 4px; }
.kiosk-sub { color: var(--muted); font-size: 16px; margin: -8px 0 0; }
.kiosk-lead { font-size: 17px; line-height: 1.55; margin: 0; }
.kiosk-start { font-size: 19px; padding: 16px 22px; border-radius: 12px; }
.kiosk-q { margin: 10px 0 4px; }
.kiosk-q-text { font-size: 16.5px; font-weight: 600; margin-bottom: 8px; }
.kiosk-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.kiosk-opt-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: 10px;
  padding: 12px 16px; font-size: 15.5px; cursor: pointer; min-width: 84px;
}
.kiosk-opt-btn.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.kiosk-num { max-width: 140px; font-size: 17px; padding: 10px; }
.kiosk-submit { font-size: 18px; padding: 14px 20px; margin-top: 10px; }
.kiosk-receipt {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 16px;
}
.kiosk-receipt-lbl { color: var(--muted); font-size: 14px; }
.kiosk-receipt-code { font-size: 40px; letter-spacing: 0.08em; font-family: ui-monospace, Menlo, monospace; }
.kiosk-exit {
  position: absolute; top: 10px; right: 12px; border: none; background: none;
  color: var(--muted); font-size: 11.5px; cursor: pointer; opacity: 0.55; padding: 6px;
}
.kiosk-exit:hover { opacity: 1; }
/* Staff inbox */
.kiosk-inbox-list { display: flex; flex-direction: column; gap: 10px; }
.kiosk-inbox-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.kiosk-inbox-code { font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.kiosk-inbox-meta { font-size: 13.5px; }
.kiosk-inbox-attach { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Help — icon-only round "?" in the topbar; the title/aria-label carry the
   words ("Help — guided tour of this page") for hover + screen readers. */
.btn-help {
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  font-size: 15px; font-weight: 750; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.btn-help:hover { background: var(--surface); border-color: var(--accent); }
/* Study cell tag in the cross-study grid. */
.grid-study-tag {
  display: inline-block; font-size: 11px; font-weight: 600; color: var(--accent);
  background: rgba(114, 46, 209, 0.10); border-radius: 6px;
  padding: 1px 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Studies-landing header: Queries launcher sits LEFT, in-flow (jds 2026-07-04). */
.gridf-left { display: flex; align-items: center; gap: 8px; }
.gridf-left #gapq-launcher { position: static; box-shadow: none; }
/* Privileged frozen first column: study title stacked over its lifecycle +
   Details controls, the Studies analog of the Registry .pcard cell. */
.col-study-priv { white-space: normal; }
.study-cell { display: flex; flex-direction: column; gap: 5px; padding: 3px 0; line-height: 1.3; }
.study-title { font-weight: 650; font-size: 13px; color: var(--ink); }
.study-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.study-controls .gaplock-cell { gap: 6px; }
/* Inspector read-only banner (multi-study mode: capture needs a single study). */
.insp-readonly-hint {
  background: rgba(217, 119, 6, 0.10); border: 1px solid rgba(217, 119, 6, 0.35);
  color: var(--amber); border-radius: 8px; padding: 8px 11px; font-size: 12px; margin-bottom: 12px; font-weight: 600;
}
.mon-surg-col, td.mon-surg-col { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }

/* --- Shared centered modal (CSV import + Save cohort). Each instance mounts
   its OWN backdrop element (the dist-* delivery-panel pattern) with csvimp-*/
   coh-* namespaced ids, so stacking never collides with the inspector drawer
   (z 59/60) or the delivery log (z 210/220). --- */
.modal-backdrop { position: fixed; inset: 0; z-index: 230; background: rgba(31, 36, 48, 0.35); }
.modal-card {
  /* Anchored near the TOP (fixed just below the header bar) rather than
     vertically centered, with a pronounced cast so it lifts off the page
     (jds 2026-07-03). */
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 240;
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 116px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 24px 60px -12px rgba(31, 36, 48, 0.4), 0 6px 20px rgba(31, 36, 48, 0.18), 0 0 0 1px rgba(31, 36, 48, 0.04);
  padding: 18px 20px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { appearance: none; background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.modal-x:hover { color: var(--ink); background: var(--surface); }
.modal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.modal-actions-spacer { flex: 1; }
/* CSV placeholder hint: lighter than the muted tone (jds 2026-07-17) */
.csvimp-text::placeholder { color: #c3c8d1; }

/* CSV patient import modal (requirement 6) */
.csvimp-text {
  width: 100%; min-height: 130px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--ink); padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.csvimp-result { margin-top: 12px; }
.csvimp-result:empty { display: none; }
.csvimp-summary { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.csvimp-err { color: var(--error); font-weight: 600; }
.csvimp-errtable { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.csvimp-errtable th, .csvimp-errtable td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.csvimp-errtable th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.csvimp-warns { margin-top: 8px; }

/* Save-cohort modal (requirement 7) — minimal AND-ed criteria builder rows */
.coh-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.coh-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.coh-row .sel { width: auto; }
.coh-row .inp { flex: 1; min-width: 70px; }
.coh-row .coh-attr-key { flex: 0 1 170px; }

/* Study Builder (lite) — create a real study from an in-browser design ------ */
.sb-builder { display: flex; flex-direction: column; gap: 16px; }
.sb-card > p { margin: -6px 0 12px; }
.sb-card h2 .sb-req { color: var(--primary-deep); font-weight: 700; }
.sb-card h2 .sb-opt { font-weight: 400; }
.sb-meta-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .sb-meta-grid { grid-template-columns: 1fr; } }

/* Repeating-group scaffolding shared by arms / visits / options */
.sb-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sb-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.sb-field { display: flex; flex-direction: column; gap: 3px; min-width: 90px; }
.sb-field .sb-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.sb-grow { flex: 1 1 auto; min-width: 140px; }
.sb-add { align-self: flex-start; }
.sb-remove { color: var(--muted); flex: 0 0 auto; }
.sb-remove:hover { color: var(--error); border-color: var(--error); }
.sb-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; padding-bottom: 7px; }
.sb-check input { width: 15px; height: 15px; accent-color: var(--primary); }

/* Arm rows: id + label side by side */
.sb-arm-row .sb-arm-id { flex: 0 1 160px; }
.sb-arm-row .sb-arm-label { flex: 1 1 200px; }

/* Visit rows: name grows, the four numeric controls stay compact */
.sb-visit-row { padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.sb-visit-name-fld { flex: 1 1 200px; }
.sb-visit-row .sb-visit-time, .sb-visit-row .sb-visit-wminus, .sb-visit-row .sb-visit-wplus { width: 82px; }
.sb-visit-row .sb-visit-unit { width: 96px; }

/* Forms + fields nesting */
.sb-forms { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.sb-unmapped-note { color: var(--accent) !important; font-style: italic; }
.sb-form-card { border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 12px; padding: 14px; background: #fff; }
.sb-form-head { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.sb-key-fld { flex: 0 1 180px; }
.sb-fields { display: flex; flex-direction: column; gap: 10px; margin: 0 0 10px; }
.sb-field-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.sb-field-top { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.sb-field-top .sb-field-type { min-width: 150px; }
.sb-field-sub:empty { display: none; }
.sb-field-sub { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.sb-sub-head { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.sb-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.sb-opt-row .sb-opt-value { flex: 0 1 140px; }
.sb-opt-row .sb-opt-label { flex: 1 1 180px; }
.sb-num-block .sb-field { min-width: 80px; }
.sb-num-block .sb-field-min, .sb-num-block .sb-field-max { width: 96px; }
.sb-num-block .sb-field-unit { width: 120px; }

/* Invalid-field marker (client-side validation) */
.sb-invalid { border-color: var(--error) !important; box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12); }

/* Submit bar + success panel */
.sb-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.sb-result { display: flex; flex-direction: column; gap: 16px; }
.sb-success { border-color: var(--positive); border-left: 3px solid var(--positive); }
.sb-success-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.sb-success-head h2 { margin: 0; color: var(--positive); }
.sb-check-mark { width: 24px; height: 24px; border-radius: 50%; background: var(--positive); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.sb-success-line { font-size: 15px; font-weight: 600; color: var(--ink); margin: 4px 0 8px; }
.sb-success-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ===== Instrument Library (the form-builder) ===============================
   Author custom scored instruments + the Field→Concept Mapper. Reuses the
   sb-* field-editor styles; il-* covers the library layout, cards, detail
   panel, editor/preview split, and the concept-mapper coverage panels. */
.il-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .il-kpis { grid-template-columns: repeat(2, 1fr); } }
.il-kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.il-kpi-v { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.il-kpi-l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.il-kpi-d { margin-top: 4px; }

.il-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.il-search { flex: 1; max-width: 420px; }

.il-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .il-layout { grid-template-columns: 1fr; } }
.il-cards { display: flex; flex-direction: column; gap: 10px; }
.il-empty { padding: 24px; }
.il-card { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; }
.il-card:hover { border-color: var(--primary); }
.il-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--tint); }
.il-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--tint); color: var(--primary-deep); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.il-body { flex: 1; min-width: 0; }
.il-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.il-badge { font-size: 10px; }
.il-sub { margin-top: 2px; }
.il-card-actions { flex: 0 0 auto; }

.il-detail { background: var(--card); border: 1px solid var(--primary); border-radius: var(--radius); box-shadow: 0 0 0 3px var(--tint); padding: 16px; position: sticky; top: 12px; }
.il-detail-empty { padding: 24px 8px; text-align: center; }
.il-detail-head { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.il-detail-head h3 { margin: 0; }
.il-detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.il-meta-l { text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; font-weight: 700; }
.il-meta-v { font-weight: 600; }
.il-detail-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* editor / preview split */
.il-editor-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .il-editor-layout { grid-template-columns: 1fr; } }
.il-editor-col { display: flex; flex-direction: column; gap: 16px; }
.il-preview-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 12px; }
.il-shared { margin-top: 8px; }

.il-score-row { align-items: center; }
.il-concept-cell { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.il-concept-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.il-inline { font-size: 12px; padding: 4px 6px; }
.il-bound { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--primary-deep); font-weight: 600; }
.il-map-btn { border-color: var(--primary); color: var(--primary-deep); background: var(--tint); }

/* live preview */
.il-preview-body { display: flex; flex-direction: column; gap: 12px; }
.il-preview-item { display: flex; flex-direction: column; gap: 4px; }
.il-preview-q { font-size: 13px; font-weight: 600; }
.il-req-star { color: var(--error); }
.il-multi { display: flex; flex-direction: column; gap: 4px; }
.il-total { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; }

/* coverage panels */
.il-coverage { display: flex; flex-direction: column; gap: 12px; }
.il-cov-panel { }
.il-cov-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.il-cov-table td { padding: 4px 6px; border-bottom: 1px solid var(--surface); }
.il-cov-count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.il-cov-count.ok { color: var(--positive); }
.il-cov-count.warn { color: var(--amber); }
.il-cov-note { margin-top: 4px; }

/* concept-picker modal (clinician idiom) */
.il-cp-card { max-width: 460px; width: 92vw; }
.il-cp-scope { margin-bottom: 8px; }
.cp-results { list-style: none; margin: 10px 0 6px; padding: 0; max-height: 300px; overflow: auto; }
.cp-item { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.cp-item:hover { border-color: var(--primary); background: var(--surface); }
.cp-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cp-name { font-weight: 600; }
.cp-empty { padding: 12px; }
.il-weight { width: 80px; }
.il-attach { margin: 4px 0 10px; }
.il-attach-row { display: flex; gap: 8px; align-items: center; }
.il-attach-row select { flex: 1; }

/* Patient-card contact actions (Contact column folded in — jds 2026-07-03) */
.pcard-actions { display: flex; gap: 4px; margin-top: 1px; }
.pcard-actions .cbtn { font-size: 10px; padding: 2px 7px; }

/* Sticky group-header titles (jds 2026-07-03): a spanning header's text pins
   to the visible edge (just right of the frozen Patient column) while its
   group is scrolled through, then slides away with the group's right edge —
   the classic sticky-section-label pattern, horizontal edition. Works because
   Tabulator's header scrolls via native scrollLeft (verified). */
/* .tab-wrap prefix beats tabulator.min.css on specificity (our sheet loads
   FIRST, so equal-specificity rules lose the cascade). */
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group,
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group > .tabulator-col-content,
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols {
  overflow: visible; /* an overflow:hidden ancestor disables position:sticky — incl. the
                        nested-children wrapper, so EVERY group tier's title sticks */
}
/* Full-specificity beat of tabulator.min.css's `width:100%` title rule — a
   sticky element with no slack inside its parent cannot travel. */
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group > .tabulator-col-content > .tabulator-col-title-holder > .tabulator-col-title {
  position: sticky;
  left: 238px; /* frozen Patient col (230) + breathing room */
  display: inline-block;
  width: max-content;
  max-width: none;
  overflow: visible;
}

/* All header text left-aligned (jds 2026-07-03 — pairs with sticky titles) */
.tab-wrap.tabulator .tabulator-header .tabulator-col .tabulator-col-title { text-align: left; }
.tab-wrap.tabulator .tabulator-header .tabulator-col { text-align: left; }

/* Studies-in-view stacked selector (mock §2b: one row object per study) */
.ssel { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.ssel-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px; flex-wrap: wrap; }
.ssel-row.off { opacity: 0.55; }
.ssel-row input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.ssel-name { font-weight: 650; font-size: 13px; cursor: pointer; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ssel-name:hover { color: var(--primary); }
.ssel-chips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
/* Visit chips follow the seg's selected/unselected grammar (jds 2026-07-03):
   OFF = white pill w/ hairline + ink text, ON = filled violet w/ white text. */
.ssel-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 1px 9px; font-size: 10.5px; font-weight: 650; color: var(--ink); cursor: pointer; user-select: none; }
.ssel-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.ssel-chip:hover { border-color: var(--primary); }
.ssel-div { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.ssel-chip.dyn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.ssel-note { font-size: 10.5px; color: var(--muted); }

/* "Not included" card (instrument not collected at this visit) */
.rdial-v.rdial-na { border-color: #cdd2dc; color: var(--grey); background: var(--card); } /* stroke = connector gray; OPAQUE plate so the connector line is occluded behind the ⊘ chip (jds 2026-07-17) */

/* Cap-height (leading-trimmed) centering: the value box hugs cap-height→
   baseline, so an "8" gets equal space above and below regardless of the
   font's descender allowance. (CSS text-box, née leading-trim.) */
.rdial-v .rv { display: block; text-box: trim-both cap alphabetic; }


/* Earliest-unfinished marker (jds 2026-07-03, replaces the yellow due-glow
   underlay in every dial style): a BLUE OUTER STROKE ringing the node just
   outside its own dark/gray stroke. */
.mdial-u { position: relative; }
.mdial-u.t-cur > .mdial-n, .mdial-u.t-cur > .rdial-v { box-shadow: 0 0 0 2px #3b82f6; }

/* Missed, data-value dials: card-shaped like its neighbors; progress COLORS */
.rdial-v.rdial-miss { background: #c1121c; color: #fff; }

/* Study scope picker (jds 2026-07-03): indicator button + dropdown popup */
.scope-bar { position: relative; margin: 8px 0 2px; }
.scope-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; font-size: 14px; font-weight: 700; color: var(--ink);
  cursor: pointer; font-family: inherit;
}
.scope-btn:hover { border-color: var(--primary); }
/* Same caret as the Site/Status/Sections menu buttons (jds 2026-07-03):
   ink-colored, inline-text size — not the old muted mini-glyph. */
/* Caret matches its own text 1:1, exactly like the Sections button's inline
   "▾" (a fixed 12px next to the 14px title read as a different, smaller
   glyph — jds 2026-07-03). */
.scope-btn-chev { color: var(--ink); font-size: inherit; font-weight: inherit; }
.scope-btn-static { cursor: default; }
.scope-btn-static:hover { border-color: var(--line); }
.scopepop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 380px; max-width: 560px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(31, 36, 48, 0.16);
  padding: 10px 12px; display: flex; flex-direction: column; gap: 9px;
}
.scopepop-opts { display: flex; flex-direction: column; gap: 2px; }
.scopepop-opt {
  text-align: left; background: none; border: none; border-radius: 8px;
  padding: 6px 9px; font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; font-family: inherit;; white-space: nowrap; max-width: min(88vw, 860px); overflow: hidden; text-overflow: ellipsis; }
.scopepop-opt:hover { background: var(--surface); }
.scopepop-opt.on { background: var(--tint); color: var(--primary-deep); }
.scopepop-dyn { display: flex; gap: 6px; }
.scopepop-dyn .ssel-chip[disabled] { opacity: 0.45; cursor: not-allowed; }
.scopepop-div { border-top: 1px solid var(--line); }
.scopepop-chips { display: flex; gap: 4px; flex-wrap: wrap; }

/* Dial/Flat display-mode segmented toggle */
.seg-wrap { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-wrap .seg { border: none; border-radius: 0; background: var(--card); display: inline-flex; align-items: center; gap: 5px; }
.seg-ic { display: inline-flex; }
.seg-ic svg { display: block; }
.seg-wrap .seg.seg-on { background: var(--primary); color: #fff; }

/* ============================================================= *
 *  MODERN GRID SKIN (jds 2026-07-03) — integrate the spreadsheet
 *  with the product aesthetic: card container, no cell grid-lines,
 *  hairline row dividers, soft frozen-edge shadow, violet accents.
 *  (.tab-wrap.tabulator compound = beats vendored css regardless of
 *  load order — same trick as the sticky-header rules.)
 * ============================================================= */
/* Outer ALL-DIRECTIONS cast (jds 2026-07-03): a zero-offset ambient halo on
   top of the usual downward key shadow, so every edge of the card lifts off
   the page — not just the bottom. */
.tab-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
  box-shadow: 0 0 0 1px rgba(31, 36, 48, 0.03), 0 0 16px rgba(31, 36, 48, 0.09), 0 6px 22px -6px rgba(31, 36, 48, 0.12); }
.tab-wrap.tabulator { background: #fff; border: none; font-size: 13px; }

/* Chrome tint (frozen-tint design-export, option 1 "neutral gray" — jds
   2026-07-03, supersedes the option-3 violet wash from earlier today):
   header + frozen Patient column share one OPAQUE neutral chrome (#f6f6f7);
   body stripes #fff/#f7f7f9. Hovers: body #f0f0f3, chrome #eaeaee (darker
   than BOTH stripe tones). Hairlines sit
   just darker than the chrome so they stay visible. */
.tab-wrap.tabulator .tabulator-header { background: #f6f6f7; border-bottom: 1px solid var(--line); color: var(--ink); }
.tab-wrap.tabulator .tabulator-header .tabulator-col { background: transparent; border-right: 1px solid #e7e7eb; }
/* FROZEN header cells must stay OPAQUE: they overlay the horizontally-scrolling
   columns, and the transparent header-col rule above let the scrolled titles
   show through underneath the frozen Patient/actions columns (jds 2026-07-17). */
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-frozen { background: #f6f6f7; z-index: 11; }
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group { border-right: 1px solid #e7e7eb; }
.tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols { border-top: 1px solid #e7e7eb; }
.tab-wrap.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input {
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px; background: var(--surface);
  font-family: inherit; font-size: 12px;
}
@media (hover:hover) and (pointer:fine) {
  .tab-wrap.tabulator .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover { background: #f0f0f2; }
}

/* Body: no vertical grid-lines; hairline row dividers; no zebra; violet hover */
.tab-wrap.tabulator .tabulator-tableholder .tabulator-table { color: var(--ink); }
.tab-wrap.tabulator .tabulator-row { background: #fff; border-bottom: 1px solid #f1f2f6; }
/* Alternating rows (frozen-tint export, jds 2026-07-03): even rows dip one
   step; the frozen chrome dips in lockstep so the stripe crosses the seam. */
.tab-wrap.tabulator .tabulator-row.tabulator-row-even { background: #f7f7f9; }
.tab-wrap.tabulator .tabulator-row.tabulator-row-even .tabulator-cell.tabulator-frozen.tabulator-frozen-left { background: #f0f0f2; }
.tab-wrap.tabulator .tabulator-row .tabulator-cell { border-right: 1px solid #f1f2f6; }
/* Cell content centers VERTICALLY in the fixed 64px row (jds 2026-07-03) */
.tab-wrap.tabulator .tabulator-row .tabulator-cell { display: inline-flex; align-items: center; }
@media (hover:hover) and (pointer:fine) {
  .tab-wrap.tabulator .tabulator-row.tabulator-selectable:hover { background: #f0f0f3; cursor: pointer; }
  /* frozen cell bg is opaque (must scroll over data) so it needs its own hover tone */
  .tab-wrap.tabulator .tabulator-row.tabulator-selectable:hover .tabulator-cell.tabulator-frozen.tabulator-frozen-left { background: #eaeaee; }
}

/* Frozen Patient column: hairline only — side shadow removed from body cells
   too (jds 2026-07-03; header lost its shadow earlier the same day) */
.tab-wrap.tabulator .tabulator-row .tabulator-cell.tabulator-frozen.tabulator-frozen-left {
  border-right: 1px solid var(--line);
  box-shadow: none;
  background: #f6f6f7; /* chrome — opaque: sticky cells scroll over data */
}
/* Patient HEADER: no side shadow (jds 2026-07-03) — border only */
.tab-wrap.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left {
  border-right: 1px solid var(--line);
  box-shadow: none;
  background: #f6f6f7;
}

/* ALL left-frozen cells share the chrome tint (jds 2026-07-17): the Patients
   roster freezes THREE columns (checkbox · Patient · actions) but Tabulator
   marks only the LAST one .tabulator-frozen-left, so the -left-scoped tints
   above painted just one of the three there (the Registry's single frozen
   column masked the gap). State tints mirror the -left set exactly. */
.tab-wrap.tabulator .tabulator-row .tabulator-cell.tabulator-frozen { background: #f6f6f7; }
.tab-wrap.tabulator .tabulator-row.tabulator-row-even .tabulator-cell.tabulator-frozen { background: #f0f0f2; }
.tab-wrap.tabulator .tabulator-row.upd-row .tabulator-cell.tabulator-frozen { background: #efe9fb; }
.tab-wrap.tabulator .tabulator-row.tabulator-selected .tabulator-cell.tabulator-frozen { background: #e9e2fb; }
@media (hover:hover) and (pointer:fine) {
  .tab-wrap.tabulator .tabulator-row.tabulator-selectable:hover .tabulator-cell.tabulator-frozen { background: #eaeaee; }
}

/* Group-boundary rails in the body: one subtle rule at each top-level seam */
.tab-wrap.tabulator .tabulator-row .tabulator-cell.col-visit:last-of-type { border-right: none; }

/* Scope display-filters: on the page under the selector, not in the popup */
.scope-bar { display: flex; flex-direction: column; gap: 7px; }
.scope-boxes { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; } /* the three annotated boxes on one line (jds 2026-07-03) */
.scope-bar-row { position: relative; }
.scopefilters-dyn { display: flex; gap: 6px; align-items: center; }
.scopefilters-dyn .seg[disabled],
.scopefilters-dyn .ssel-chip[disabled] { opacity: 0.45; cursor: not-allowed; }
.scopefilters-chips { display: flex; gap: 4px; flex-wrap: wrap; }
/* Fieldset-style grouping box around the visit chips (jds 2026-07-03): border-
   only rounded box, label riding ON the top border just right of the corner. */
.chipbox {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 10px 8px; margin: 0; min-width: 0;
  display: inline-block; align-self: flex-start;
}
.chipbox-lbl {
  font-size: 9.5px; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); padding: 0 5px; margin-left: 2px;
}

/* User tile + account menu (live-pill and Sign-out button retired) */
.topright { position: relative; }
.usertile {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 5px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); cursor: pointer; user-select: none;
}
.usertile:hover { border-color: var(--primary); }
.usertile-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--tint); color: var(--primary-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; letter-spacing: 0.02em;
}
.usertile-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.usertile-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.usertile-role { font-size: 10.5px; color: var(--muted); }
.usertile-chev { font-size: 15px; font-weight: 700; color: var(--ink); margin-left: 2px; } /* big, evident caret (jds 2026-07-03) */
.usermenu {
  position: absolute; top: calc(100% + 6px); right: 44px; z-index: 80;
  min-width: 160px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(31, 36, 48, 0.16);
  display: flex; flex-direction: column; padding: 5px;
}
.usermenu-item {
  text-align: left; background: none; border: none; border-radius: 7px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; color: var(--ink);
  cursor: pointer; font-family: inherit;
}
.usermenu-item:hover { background: var(--surface); }
#um-signout { color: var(--error); }

/* Account settings (#/settings) — change-password + MFA cards (jds 2026-07-16). */
.settings-view { display: flex; flex-direction: column; gap: 16px; align-items: stretch; }
.settings-view .card { max-width: 480px; }
.mfa-body { display: flex; flex-direction: column; gap: 10px; }
.mfa-secret {
  display: inline-block; font-family: ui-monospace, monospace; font-size: 15px;
  letter-spacing: 2px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; word-break: break-all;
}
.mfa-qr { display: block; margin: 4px 0 10px; border: 1px solid var(--line); border-radius: 8px; }

/* Patient (frozen) header: same treatment as the group headers, and left
   padding aligned with the pcard content below (jds 2026-07-03) */
.tab-wrap.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left .tabulator-col-title {
  color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  padding-left: 8px;
}
.tab-wrap.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left .tabulator-header-filter { padding-left: 4px; box-sizing: border-box; }
.tab-wrap.tabulator .tabulator-row .tabulator-cell.tabulator-frozen-left { padding-left: 8px; }

/* Frozen header shadow to match the body cells' (and avoid clipping) */
.tab-wrap.tabulator .tabulator-header { overflow: visible; }
.tab-wrap.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left { z-index: 12; }

/* ---------------------------------------------------------------------------
   "Report an issue" feedback (js/feedback.js). Mounted on <body>, outside #app,
   so it survives an app-state crash. Class-based only. Fixed bottom-right.
   (The gap-queries launcher also uses bottom-right, but it's disabled by default
   now — LAST_QUERIES_ENABLED off — so the corner is free. If queries is ever
   re-enabled, revisit this to avoid the overlap.)
   --------------------------------------------------------------------------- */
.fb-btn{
  position:fixed; right:16px; bottom:16px; z-index:9000;
  font:inherit; font-size:13px; font-weight:600;
  padding:8px 14px; min-height:36px;
  color:#fff; background:var(--primary,#722ED1);
  border:1px solid var(--primary-deep,#5924A3); border-radius:999px;
  box-shadow:var(--shadow,0 4px 12px rgba(31,36,48,.18)); cursor:pointer; opacity:.92;
}
.fb-btn:hover{opacity:1;}
.fb-btn:focus-visible{outline:3px solid var(--accent,#5924A3); outline-offset:2px;}

.fb-backdrop{
  position:fixed; inset:0; z-index:9001;
  display:flex; align-items:center; justify-content:center; padding:16px;
  background:rgba(31,36,48,.45);
}
.fb-modal{
  width:100%; max-width:440px; box-sizing:border-box;
  background:var(--card,#fff); color:var(--ink,#1f2430);
  border:1px solid var(--line,#e5e7eb); border-radius:var(--radius,12px);
  padding:20px; box-shadow:0 10px 40px rgba(31,36,48,.30);
}
.fb-modal__title{margin:0 0 6px; font-size:19px;}
.fb-modal__hint{margin:0 0 12px; font-size:13px; color:var(--muted,#6b7280);}
.fb-textarea{
  width:100%; box-sizing:border-box; font:inherit; font-size:15px;
  padding:10px; border:1px solid var(--line,#e5e7eb);
  border-radius:8px; resize:vertical; color:var(--ink,#1f2430); background:#fff;
}
.fb-textarea:focus-visible{outline:2px solid var(--accent,#5924A3); outline-offset:1px;}
.fb-modal__status{margin:8px 0 0; min-height:1.2em; font-size:13px; color:var(--muted,#6b7280);}
.fb-actions{display:flex; gap:8px; justify-content:flex-end; margin-top:14px;}
.fb-btn-cancel,.fb-btn-submit{
  font:inherit; font-size:14px; font-weight:600; min-height:40px;
  padding:8px 16px; border-radius:8px; cursor:pointer;
}
.fb-btn-cancel{background:transparent; color:var(--ink,#1f2430); border:1px solid var(--line,#e5e7eb);}
.fb-btn-submit{background:var(--primary,#722ED1); color:#fff; border:1px solid var(--primary-deep,#5924A3);}
.fb-btn-submit[disabled]{opacity:.6; cursor:default;}
.fb-btn-cancel:focus-visible,.fb-btn-submit:focus-visible{outline:3px solid var(--accent,#5924A3); outline-offset:2px;}
