:root {
  color-scheme: light;
  --font: "Sora", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --page: #f3f5f6; --surface: #ffffff; --surface-2: #e9eef0;
  --ink: #0d1317; --ink-2: #3c4f59; --muted: #667882;
  --grid: #e2e8eb; --axis: #b6c3c9; --border: rgba(13,19,23,0.11);
  --accent: #a66a00; --accent-ink: #ffffff; --signal: #f2b544;
  --up: #1a7f37; --down: #c43c2c; --warn: #c98500; --good: #1a9e55;
  --glow: transparent;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d1317; --surface: #111a20; --surface-2: #18242c;
    --ink: #e8eef1; --ink-2: #b4c2c9; --muted: #7d8f99;
    --grid: #1c2830; --axis: #3c5664; --border: rgba(125,143,153,0.18);
    --accent: #f2b544; --accent-ink: #0d1317;
    --up: #3fb871; --down: #e8826b; --good: #3fb871; --glow: #13202a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d1317; --surface: #111a20; --surface-2: #18242c;
  --ink: #e8eef1; --ink-2: #b4c2c9; --muted: #7d8f99;
  --grid: #1c2830; --axis: #3c5664; --border: rgba(125,143,153,0.18);
  --accent: #f2b544; --accent-ink: #0d1317;
  --up: #3fb871; --down: #e8826b; --good: #3fb871; --glow: #13202a;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse 80% 50% at 50% 0%, var(--glow), transparent 70%) no-repeat, var(--page); color: var(--ink); font: 13.5px/1.5 var(--font); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
.ghost { background: none; border: 1px solid var(--border); border-radius: 2px; padding: 4px 10px; cursor: pointer; font-family: var(--mono); font-size: 12px; }
.ghost:hover { border-color: var(--accent); color: var(--accent); }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand .m-ring { stroke: var(--axis); stroke-width: 4; }
.brand .m-hex { stroke: var(--ink); stroke-width: 7; }
.brand .m-stem { stroke: var(--ink); stroke-width: 9; }
.brand .m-dot { fill: var(--signal); stroke: none; }
.top h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.top h1 span { font-weight: 300; }
.brand .back { font: 500 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); padding: 2px 7px; border-radius: 2px; }
.brand:hover .back { color: var(--accent); border-color: var(--accent); }
.tabs button { background: none; border: 0; padding: 6px 10px; border-bottom: 2px solid transparent; cursor: pointer; color: var(--ink-2); font: 500 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.runs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1 1 100%; order: 10; justify-content: flex-end; }   /* own row under the tabs */
.top a.ghost[href="/guide"] { margin-left: auto; }   /* Guide, Ask, Review, theme to the right */
.run { font: 11px var(--mono); padding: 1px 7px; border-radius: 2px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; }
.run::before { content: "●"; margin-right: 4px; color: var(--good); }
.run.err::before { color: var(--warn); }
.run.session { border-color: var(--down); color: var(--ink); }
.run.session::before { content: "⚠"; color: var(--down); }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; align-items: end; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.filters label { display: flex; flex-direction: column; font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); gap: 3px; }
.filters .toggle { flex-direction: row; align-items: center; gap: 5px; cursor: pointer; padding-bottom: 5px; }
.filters .toggle input { width: auto; }
.filters .toggle.box { border: 1px solid var(--border); border-radius: 2px; background: var(--page); padding: 5px 24px 5px 8px; }   /* Active now: boxed like the inputs, room for the × */
.filters label.partial.box { border-style: dashed; border-color: var(--axis); }
.filters select, .filters input { background: var(--page); border: 1px solid var(--border); border-radius: 2px; font: 13px var(--font); text-transform: none; letter-spacing: 0; padding: 4px 6px; width: 122px; }
/* one-click clear (×) at the top-right of a filter box, on the label row: never over a select arrow or a month picker icon */
.filters .fbox { position: relative; display: flex; }
.filters .fbox > label { flex: 1; }
.filters .clear { position: absolute; top: -5px; right: -5px; width: 24px; height: 24px; display: grid; place-content: center; padding: 0;
  background: none; border: 1px solid transparent; border-radius: 2px; color: var(--muted); font: 16px/1 var(--font); cursor: pointer; }
.filters .clear:hover { color: var(--accent); border-color: var(--accent); }
.filters .clear[hidden] { display: none; }
.filters .room { padding-right: 24px; }   /* a label as wide as its box: keep the text clear of the × */
@media (pointer: coarse) { .filters .clear { width: 32px; height: 28px; top: -10px; right: -6px; font-size: 18px; } }
.filters label.partial select, .filters label.partial input { border-style: dashed; border-color: var(--axis); }   /* Trends: not in snapshots */
#filters label.partial { text-decoration: none; }   /* the dashed box is the cue; no dotted underline on the value */
.note-hi { color: var(--accent); font-weight: 500; }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; border-top: 2px solid var(--accent); padding: 12px 14px; display: flex; flex-direction: column; }
.kpi .lbl { color: var(--muted); font: 500 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.kpi b { font-size: clamp(22px, 5.4vw, 30px); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
/* the Contacts tab's hero tile: its total, larger and tinted; two columns wide where two fit */
.kpi.hero { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-top-width: 3px; }
.kpi.hero b { font-size: clamp(30px, 7vw, 44px); }
@media (min-width: 700px) { .kpi.hero { grid-column: span 2; } }
.kpi small { color: var(--muted); font: 11px var(--mono); min-height: 1.4em; }
.kpi small .up { color: var(--up); } .kpi small .down { color: var(--down); }
.kpi-sub { margin: -8px 0 16px; font: 11px var(--mono); min-height: 1.4em; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 12px 14px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.panel h2 small { color: var(--muted); font: 400 11px var(--mono); }
.panel h2 button { margin-left: auto; font-size: 12px; }
.panel h2 .h2-pick { margin-left: auto; font: 400 11px var(--mono); color: var(--muted); display: flex; gap: 6px; align-items: center; }
.panel h2 .h2-pick select { background: var(--page); border: 1px solid var(--border); border-radius: 2px; padding: 4px 6px; font-size: 12px; }
.alt-table summary { cursor: pointer; font: 11px var(--mono); color: var(--muted); margin-top: 8px; }
.alt-table summary:hover { color: var(--accent); }
.chart { height: 360px; width: 100%; }
.chart.tall { height: 480px; }
.err-msg { color: var(--down); padding: 20px; }
/* a guest past their call budget (app.js pauseNote): one note over the page, not an error per chart */
.pause-note { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 10px 16px; background: var(--surface-2); color: var(--ink);
  border-top: 2px solid var(--accent); font-size: 14px; text-align: center; box-shadow: 0 -6px 18px rgba(0,0,0,.2); }
.pause-x { margin-left: 8px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
body.paused { padding-bottom: 9em; }   /* the footer's statements stay readable above the note (5 lines on a phone) */

.table-wrap { max-height: 360px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--muted); font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; position: sticky; top: 0; background: var(--surface); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb tbody tr { cursor: pointer; } .lb tbody tr:hover { background: var(--surface-2); }
.bar { height: 6px; background: var(--accent); border-radius: 0 3px 3px 0; min-width: 2px; }
.muted { color: var(--muted); }
.credit { margin: 4px 0 0; font: 11px var(--mono); }
.credit a { color: inherit; }
[title]:not(button):not(iframe):not(.run):not(abbr):not(.brand) { text-decoration: underline dotted var(--muted); text-underline-offset: 2px; }

.table-wrap.tall { max-height: 480px; }
th button { all: unset; cursor: pointer; white-space: nowrap; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort] button { color: var(--ink); }
th[aria-sort="descending"] button::after { content: " ▼"; } th[aria-sort="ascending"] button::after { content: " ▲"; }
td.lo { color: var(--down); font-weight: 600; } td.mid { color: var(--warn); }
tr.warn td:first-child { box-shadow: inset 3px 0 var(--down); }
.tab-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; font: 12px var(--mono); }
.tab-bar label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.tab-bar select { background: var(--page); border: 1px solid var(--border); border-radius: 2px; padding: 4px 6px; }
.tab-note { margin: 0 0 12px; font: 12px var(--mono); }
details.more { display: inline; } details.more summary { display: inline; cursor: pointer; color: var(--muted); text-decoration: underline dotted; }
details.more[open] summary { color: var(--ink-2); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,.18); overflow: auto; padding: 16px 20px; z-index: 20; transform: translateX(0); transition: transform .25s ease; }
.drawer[hidden] { display: block; transform: translateX(105%); visibility: hidden; }
.drawer .close { position: sticky; top: 0; float: right; background: var(--surface); }
.drawer h3 { margin: 0 32px 8px 0; font-size: 17px; }
.drawer h4 { margin: 18px 0 6px; font-size: 13px; color: var(--ink-2); }
.drawer .kv td:first-child { color: var(--muted); white-space: nowrap; width: 1%; }
.drawer .member { border: 1px solid var(--border); border-radius: 4px; padding: 8px 10px; margin: 10px 0; }
.drawer details summary { cursor: pointer; font-weight: 600; }
.chip { display: inline-block; font: 11px var(--mono); padding: 1px 8px; border-radius: 2px; background: var(--surface-2); margin: 0 4px 4px 0; }
.link-row { cursor: pointer; } .link-row:hover { background: var(--surface-2); }
.drawer h5 { margin: 12px 0 4px; font: 500 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.drawer table.contacts td { overflow-wrap: anywhere; }   /* long e-mails and addresses wrap inside the drawer */

/* Contacts tab */
.tab-bar input[type="search"] { background: var(--page); border: 1px solid var(--border); border-radius: 2px; padding: 5px 8px; width: min(420px, 70vw); font: 13.5px var(--font); }
.c-answer { font-size: 15px; margin: 0 0 10px; min-height: 1.5em; }
.c-answer b { color: var(--accent); }
.c-roles { margin-bottom: 12px; }
.c-roles .chip { border: 1px solid transparent; color: var(--ink-2); cursor: pointer; padding: 3px 10px; }
.c-roles .chip:hover, .c-roles .chip[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); }
#t-c-names tr.sel td { color: var(--accent); font-weight: 600; }
.c-more { margin-top: 8px; }
.grid[hidden] { display: none; }   /* .grid's display would beat the hidden attribute */
#c-found { transition: opacity .25s; }
#c-found.busy { opacity: .45; }   /* the next answer is on its way: the last one stays, dimmed (and inert) */
#c-country { max-width: 220px; }
.c-try .chip, .c-roles .chip { border: 1px solid transparent; }
.c-try .chip { color: var(--ink-2); cursor: pointer; padding: 3px 10px; margin-left: 6px; }
.c-try .chip:hover { border-color: var(--accent); color: var(--ink); }
.c-bar { width: 90px; }
#t-c-names td:last-child { width: 45%; }
#t-c-trials td[rowspan]:first-child { white-space: nowrap; }   /* the record ID (NCT…, CTIS 2024-…) */
#t-c-trials tbody:hover { background: var(--surface-2); }   /* one trial's names (rowspan) light up together */

#t-c-names .chip, #t-c-trials .chip { margin: 0 4px 2px 0; }
.st { display: inline-block; font: 11px var(--mono); padding: 1px 8px; border-radius: 9px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.st.go { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.st.stop { color: var(--down); background: color-mix(in srgb, var(--down) 14%, transparent); }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .chart.tall { height: 400px; }
  .runs { justify-content: flex-start; }
  .filters { position: static; }
  .filters label, .filters .fbox { flex: 1 1 140px; }
  .filters select, .filters input { max-width: none; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.filters[hidden] { display: none; }
.empty { display: grid; place-content: center; text-align: center; height: 100%; color: var(--muted); font: 12px/1.7 var(--mono); padding: 0 24px; }
.empty b { color: var(--accent); font-weight: 500; }
@media (max-width: 600px) { .brand .back, .top h1 span { display: none; } }
.asof { font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.chart:empty::before { content: "Loading…"; display: grid; place-content: center; height: 100%; color: var(--muted); font: 12px var(--mono); }
tr[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 600px) { .runs { display: none; } .asof { order: 5; } }   /* phones: one freshness line instead of 15 badges */
a.ghost { color: var(--ink-2); text-decoration: none; }
/* export: a download icon at the top right of every chart and its menu (app.js) */
.panel.has-export { position: relative; }
.panel.has-export h2 { padding-right: 36px; }   /* a long subtitle wraps before the corner */
.panel h2 .export { position: absolute; top: 8px; right: 10px; }
.panel h2 .export button { margin-left: 0; }
.icon-btn { width: 28px; height: 28px; display: inline-grid; place-items: center; padding: 0; background: none; border: 1px solid var(--border); border-radius: 2px; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 15px; height: 15px; }
.xp-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(300px, calc(100vw - 40px)); padding: 12px; display: grid; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.28); font: 400 13px/1.45 var(--font); color: var(--ink); }
.xp-pop[hidden] { display: none; }
.xp-pop .pitch { background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 2px; padding: 10px; display: grid; gap: 2px; }
.xp-pop .pitch span { font-size: 12px; color: var(--ink-2); }
.xp-pop .hd { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.xp-pop .tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.xp-pop .tile { position: relative; background: var(--page); border: 1px solid var(--border); border-radius: 2px; padding: 12px 6px 8px; display: grid; justify-items: center; gap: 3px;
  cursor: pointer; color: var(--ink); font: 11px var(--font); }
.xp-pop .tile:hover:not([disabled]) { border-color: var(--accent); }
.xp-pop .tile[disabled] { opacity: .45; cursor: default; }
.xp-pop .doc { width: 30px; height: 36px; border: 1.5px solid var(--ink-2); border-radius: 2px 8px 2px 2px; display: grid; place-items: end center; padding-bottom: 4px; font: 600 8.5px var(--mono); color: var(--ink-2); }
.xp-pop .tile:hover:not([disabled]) .doc { border-color: var(--accent); color: var(--accent); }
.xp-pop .tile small { color: var(--muted); font: 10.5px var(--mono); }
.xp-pop .lock { position: absolute; top: 5px; right: 5px; width: 11px; height: 11px; color: var(--accent); }
.xp-pop .cta { display: block; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 7px; border-radius: 2px; text-decoration: none; }
.xp-pop p { margin: 0; font-size: 12px; }
:is(.icon-btn, .xp-pop .tile, .xp-pop .cta):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
