:root {
  /* CLARIFY palette: white surfaces, greens taken from the logo gradient (#00a4a6 -> #5bb04f -> #8bbb2c).
     Interactive greens are darkened for WCAG AA contrast with white text. */
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f4f8f5; --border: #e2ebe5;
  --text: #1d2b24; --muted: #5f6f66; --accent: #1f8a4c; --accent-hover: #186f3d; --accent-text: #ffffff;
  --accent-soft: #e9f6ee; --accent-bright: #5bb04f; --teal: #00a4a6; --lime: #8bbb2c;
  --ok: #1f7a3f; --ok-bg: #e7f5ec; --warn: #8a5a00; --warn-bg: #fff4dc;
  --bad: #c0362c; --bad-bg: #fdeceb; --info-bg: #e9f6ee;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 40, 24, .04), 0 2px 8px rgba(16, 40, 24, .05);
  /* chart series (validated: lightness, chroma, CVD, normal vision on white; aqua needs labels: direct labels + table) */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; color: var(--accent); }
.brand-logo { height: 58px; width: auto; display: block; }
.brand-divider { width: 1px; height: 38px; background: var(--border); }
.badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; background: var(--info-bg); color: var(--accent); }

.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--accent-bright), var(--lime)); }
.identity { flex: 1; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.node-name { font-weight: 600; }
.did { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 6px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; }
.tabs button { border: 1.5px solid transparent; border-radius: 8px; background: none; color: var(--muted);
  padding: 6px 12px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--accent); background: var(--surface-2); }
.tabs button.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.view { max-width: 1180px; margin: 0 auto; padding: 20px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; min-width: 0; }
.card h2 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.card .sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 650; color: var(--accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
td.actions-cell { white-space: nowrap; text-align: right; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--accent); }

button { font: inherit; border-radius: 8px; padding: 6px 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:not(.primary):not(.danger):hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
button.ghost { background: none; }
button.small { padding: 3px 9px; font-size: 12.5px; }
button + button { margin-left: 6px; }

label { display: block; font-weight: 550; margin: 10px 0 4px; }
input, select { font: inherit; width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 160px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox input { width: auto; }

.log { background: #f6faf7; color: #1d2b24; border: 1px solid var(--border); border-radius: 8px; padding: 12px; height: 360px; overflow: auto;
  white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.claims { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); padding: 12px 0; }
.note { background: var(--info-bg); border-radius: 8px; padding: 10px 12px; font-size: 13px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, var(--accent-soft), var(--bg) 60%); }
.login-logos { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 4px; }
.login-logo { height: 90px; width: auto; max-width: 45%; object-fit: contain; }
.login-card .brand { justify-content: center; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 6px; }
.login-card button { margin-top: 10px; }

.dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  max-width: 440px; padding: 18px; }
.dialog::backdrop { background: rgba(0, 0, 0, .35); }
.dialog h3 { margin: 0 0 8px; }
.dialog .actions { display: flex; justify-content: flex-end; margin-top: 16px; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; padding: 10px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 5; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .brand-logo { height: 42px; }
  .brand-divider { height: 28px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .identity { order: 3; flex-basis: 100%; }
  .view { padding: 16px; }
  .tabs { padding: 6px 8px; }
}
.card.inner { box-shadow: none; background: var(--surface-2); margin-top: 10px; }
.card.inner table th, .card.inner table td { border-color: var(--border); }
.participant-row { align-items: center; margin-bottom: 6px; }
.participant-row label.checkbox { margin: 0; }
.preview { max-height: 360px; overflow: auto; margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.data-panel:empty { display: none; }
.data-panel { margin-top: 8px; }
label.checkbox.perm { margin: 0 10px 0 0; display: inline-flex; font-weight: 500; }
.use-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.member-training { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; white-space: nowrap; }
.data-dialog { width: min(1100px, 95vw); max-width: none; max-height: 88vh; padding: 0; display: none; }
.data-dialog[open] { display: flex; flex-direction: column; }
.data-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 8px; }
.data-head h3 { margin: 0 0 2px; }
.data-body { overflow: auto; padding: 0 18px; min-height: 120px; flex: 1; }
.data-table { overflow: visible; }
.data-table table { font-size: 12.5px; }
.data-table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.data-table td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.data-actions { gap: 8px; align-items: center; padding: 12px 18px 16px; border-top: 1px solid var(--border); margin-top: 8px; flex-wrap: wrap; }
.credential-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.credential-toggle::after { content: " ▾"; }
.credential-toggle[aria-expanded="true"]::after { content: " ▴"; }
tr.member-detail > td { background: var(--surface-2); padding: 8px 12px 12px; }
tr.member-detail table { background: var(--surface); }
.choice-list { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.profile-editor { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.audit-filters { align-items: flex-end; }
.nowrap { white-space: nowrap; }

/* federated training progress */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; flex-wrap: wrap; }
.stepper li { flex: 1; min-width: 110px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); color: var(--muted);
  font-size: 12.5px; font-weight: 550; border: 1.5px solid transparent; }
.stepper li::before { content: "○ "; }
.stepper li.done { color: var(--ok); background: var(--ok-bg); }
.stepper li.done::before { content: "✓ "; }
.stepper li.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stepper li.active::before { content: "● "; }
.stepper li.failed { color: var(--bad); background: var(--bad-bg); }
.stepper li.failed::before { content: "✕ "; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.participant-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; }
.charts { margin-top: 12px; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.chart-plot { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 11.5px; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 6px 8px; font-size: 12px; min-width: 150px; z-index: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text); margin-bottom: 4px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-table summary, .job-log summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.job-log { margin-top: 12px; }
.omop { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.omop .claims { flex-basis: 100%; }
.omop-editor { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.mapping-table table { font-size: 12px; width: 100%; table-layout: fixed; }
.mapping-table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mapping-table td { vertical-align: top; overflow-wrap: anywhere; }
/* OMOP mapping: source, description, table, field, vocabulary, status, notes */
.mapping-table:not(.profile-table) th:nth-child(1) { width: 15%; } .mapping-table:not(.profile-table) th:nth-child(2) { width: 15%; }
.mapping-table:not(.profile-table) th:nth-child(3) { width: 14%; } .mapping-table:not(.profile-table) th:nth-child(4) { width: 15%; }
.mapping-table:not(.profile-table) th:nth-child(5) { width: 10%; } .mapping-table:not(.profile-table) th:nth-child(6) { width: 11%; }
.mapping-table:not(.profile-table) th:nth-child(7) { width: 20%; }
.mapping-table td .pill { white-space: nowrap; }
/* profile: field, type, complete, distinct, values, hint */
.profile-table th:nth-child(1) { width: 18%; } .profile-table th:nth-child(2) { width: 11%; } .profile-table th:nth-child(3) { width: 8%; }
.profile-table th:nth-child(4) { width: 7%; } .profile-table th:nth-child(5) { width: 34%; } .profile-table th:nth-child(6) { width: 22%; }
.data-dialog { width: min(1280px, 96vw); }
.section-title { font-size: 14px; margin: 12px 0 6px; }
.match { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: grid; gap: 6px; }
.warn-text { color: var(--warn); }
.omop-downloads { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.omop-downloads.hidden { display: none; }
