:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --border: #e3e6ea;
  --primary: #1f5f99;
  --primary-hover: #174b7a;
  --danger: #b42318;
  --warning-bg: #fff7e6;
  --warning-border: #f0c36d;
  --success-bg: #ecfdf3;
  --success-border: #6ce9a6;
  --error-bg: #fef3f2;
  --error-border: #fda29b;
  --info-bg: #eff6ff;
  --info-border: #93c5fd;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.75rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
p { margin: 0 0 0.75rem; }
small { font-size: 0.85em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.lead { color: var(--muted); font-size: 1.05rem; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
main.container { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }
main.narrow { max-width: 520px; }
main.narrow h1 { font-size: 1.5rem; margin-bottom: 1rem; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); letter-spacing: 0.01em; }
.brand:hover { text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1.1rem; font-size: 0.95rem; }
.site-nav a { color: var(--text); }
.nav-user { color: var(--muted); padding-left: 1rem; border-left: 1px solid var(--border); }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--text); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.875rem; padding: 1rem 0; }

/* Messages / alerts */
.messages { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.message, .alert {
  padding: 0.75rem 1rem; border-radius: var(--radius); border: 1px solid var(--info-border);
  background: var(--info-bg); margin-bottom: 0.75rem;
}
.message-success, .alert-success { background: var(--success-bg); border-color: var(--success-border); }
.message-error, .alert-error, .alert-danger { background: var(--error-bg); border-color: var(--error-border); }
.message-warning, .alert-warning { background: var(--warning-bg); border-color: var(--warning-border); }

/* Buttons */
.btn {
  display: inline-block; padding: 0.5rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; line-height: 1.3; text-decoration: none;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary, .btn-prominent { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled), .btn-prominent:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--info-bg); }
/* Secondary action next to a primary one: filled with a lighter tone of the same blue. */
.btn-secondary { background: #dce9f7; border-color: #b5cfe9; color: var(--primary-hover); }
.btn-secondary:hover:not(:disabled) { background: #c8dcf2; border-color: var(--primary); color: var(--primary-hover); text-decoration: none; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.75rem 0; }
.btn-group-vertical { flex-direction: column; align-items: stretch; }

/* Forms (also styles allauth pages) */
.form, main.narrow form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.field, form p { margin: 0 0 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.3rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid #cfd4da; border-radius: 6px; font: inherit; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(31, 95, 153, 0.35); border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: auto; margin-right: 0.4rem; }
.field input[type="checkbox"] + label, form p input[type="checkbox"] + label { display: inline; font-weight: 400; }
.help, .helptext { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }
.errorlist { list-style: none; margin: 0 0 0.5rem; padding: 0; color: var(--danger); font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
main.narrow img { display: block; margin: 0 auto 1rem; max-width: 220px; background: #fff; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* Panels (allauth account pages) */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.panel-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.badge { display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.1rem 0.45rem; border-radius: 999px; background: #eef2f6; color: var(--muted); font-weight: 600; vertical-align: middle; }
.badge-success { background: var(--success-bg); color: #027a48; }
.badge-warning { background: var(--warning-bg); color: #b54708; }

/* Cards */
.page-header { margin-bottom: 1.5rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); color: var(--text); }
.card:hover { text-decoration: none; border-color: var(--primary); }
.card h2 { margin: 0 0 0.4rem; color: var(--primary); }
.card .meta { margin: 0.5rem 0 0; font-size: 0.9rem; }
.empty-state { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); }
.breadcrumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.75rem; }

/* Release bar */
.release-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.release-switcher { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.release-switcher .label { color: var(--muted); font-size: 0.9rem; margin-right: 0.25rem; }
.chip { display: inline-block; padding: 0.25rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 0.9rem; }
.chip:hover { text-decoration: none; border-color: var(--primary); }
.chip-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip small { opacity: 0.8; margin-left: 0.2rem; }
.release-notes { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.release-notes summary { cursor: pointer; font-weight: 600; }
.notes { white-space: pre-wrap; font-family: var(--font); margin: 0.5rem 0 0; }

/* Toolbar + table */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.toolbar-left { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.toolbar-right { font-size: 0.875rem; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { background: #f0f2f5; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .col-check { width: 2.5rem; text-align: center; }
.table .files { white-space: nowrap; }
.group-row td { background: #f7f8fa; font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.instrument-label { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; margin: 0; cursor: pointer; }
.instrument-title { font-weight: 500; }
.instrument-desc { color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }

.selection-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 1rem; margin-top: 1rem; box-shadow: 0 -2px 8px rgba(16, 24, 40, 0.06);
}
.selection-info { font-weight: 600; }
.check-inline { display: inline-flex; align-items: center; font-weight: 400; margin: 0; flex: 1; }
.selection-bar .btn { margin-left: auto; }

.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: 0; }

@media (max-width: 720px) {
  .nav-user { display: none; }
  .table .num:nth-child(4) { display: none; }
}

/* Manual */
main.manual { max-width: 1040px; }
.manual-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 2rem; align-items: start; }
.toc { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; font-size: 0.92rem; }
.toc strong { display: block; margin-bottom: 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin: 0.3rem 0; }
.manual-body section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1rem; box-shadow: var(--shadow); scroll-margin-top: 1rem; }
.manual-body h2 { margin-top: 0; }
.manual-body h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }
.manual-body ol, .manual-body ul { padding-left: 1.4rem; margin: 0 0 0.75rem; }
.manual-body li { margin: 0.3rem 0; }
.manual-body li > ul { margin-top: 0.25rem; }
.manual-body code { font-family: var(--mono); font-size: 0.88em; background: #f0f2f5; border-radius: 4px; padding: 0.05rem 0.35rem; }
.manual-body .ui { font-weight: 600; }
.manual-body .note { background: var(--info-bg); border: 1px solid var(--info-border); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin: 0.75rem 0; font-size: 0.95rem; }
@media (max-width: 900px) {
  .manual-layout { grid-template-columns: 1fr; }
  .toc { position: static; }
}

/* Logo in the header */
.brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand-logo { display: block; height: 36px; width: auto; max-width: 240px; }

/* Front page text (Markdown written by administrators) */
.front-page { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.75rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.landing-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1 { font-size: 1.6rem; margin: 1.25rem 0 0.5rem; }
.markdown-body h2 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }
.markdown-body h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
.markdown-body p, .markdown-body ul, .markdown-body ol { margin: 0 0 0.85rem; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5rem; }
.markdown-body li { margin: 0.25rem 0; }
.markdown-body img { max-width: 100%; height: auto; }
.markdown-body blockquote { margin: 0 0 0.85rem; padding: 0.25rem 1rem; border-left: 4px solid var(--border); color: var(--muted); }
.markdown-body code { font-family: var(--mono); font-size: 0.88em; background: #f0f2f5; border-radius: 4px; padding: 0.05rem 0.35rem; }
.markdown-body pre { background: #f0f2f5; border-radius: var(--radius); padding: 0.75rem 1rem; overflow-x: auto; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body table { border-collapse: collapse; margin: 0 0 1rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 0.4rem 0.7rem; text-align: left; }
.markdown-body th { background: #f0f2f5; }
.markdown-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* Public data availability */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.filters fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.filters legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 0.35rem; }
.filters select { padding: 0.3rem 0.5rem; }
.filters label { font-weight: 400; margin: 0; }
.filter-actions { display: flex; gap: 0.5rem; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat-value { font-size: 1.9rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.chart-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; box-shadow: var(--shadow); min-width: 0; }
.chart-panel h2 { margin-top: 0; font-size: 1.05rem; }
.chart-wide { grid-column: 1 / -1; }
.chart { display: block; max-width: 100%; height: auto; }
.chart text { font: 12px var(--font); fill: var(--text); }
.chart .label { fill: var(--muted); }
.chart .value { font-weight: 600; }
.chart .bar { fill: var(--primary); }
.chart .bar-suppressed { fill: var(--border); }
.chart .axis { stroke: var(--border); }
.notes-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: 1.5rem; font-size: 0.95rem; }
.notes-box h2 { margin-top: 0; font-size: 1.05rem; }
.notes-box ul { padding-left: 1.3rem; margin: 0; }
.notes-box li { margin: 0.3rem 0; }

/* Instrument selection on the data availability page */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filter-instruments, .filter-imaging { flex-basis: 100%; }
.filter-imaging .check-inline { flex: 0 1 auto; margin-right: 0.5rem; }
.filter-instruments .chip { font-size: 0.85rem; padding: 0.15rem 0.6rem; }
.stat-note { color: var(--muted); font-size: 0.8rem; margin-top: 0.3rem; }
.toolbar-heading h2, .toolbar-heading .instrument-search { margin: 1.5rem 0 0.5rem; }
.instrument-search { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 400; margin: 0; }
.instrument-search input[type="search"] { width: 16rem; max-width: 100%; padding: 0.4rem 0.6rem; border: 1px solid #cfd4da; border-radius: 6px; font: inherit; background: #fff; }
.instrument-search .muted { font-size: 0.85rem; white-space: nowrap; }
.table .instrument-pick { display: inline; font-weight: 400; margin: 0; cursor: pointer; }
.table tbody tr.is-selected td { background: var(--info-bg); }
.table tbody tr.is-selected .instrument-pick { font-weight: 600; }
.selection-bar .muted { font-size: 0.9rem; }

/* Data dictionaries for visitors */
.dictionary-box { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 0.5rem; box-shadow: var(--shadow); }
.dictionary-box > div { flex: 1 1 320px; min-width: 0; }
.dictionary-box h2 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.dictionary-box p { margin-bottom: 0.5rem; }
.dictionary-box .file-list li { padding: 0.3rem 0; }
.dictionary-box .btn { white-space: nowrap; }
.table .col-dictionary { white-space: nowrap; }
@media (max-width: 720px) {
  /* The checkbox column shifts the numeric columns: keep the participant count, hide the row count. */
  #instrument-table .num:nth-child(4) { display: table-cell; }
  #instrument-table .col-rows { display: none; }
}

/* Confirmation before downloading a selection (study page) */
dialog.confirm { border: 0; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 2rem)); color: var(--text); background: var(--surface); box-shadow: 0 12px 40px rgba(16, 24, 40, 0.25); }
dialog.confirm::backdrop { background: rgba(16, 24, 40, 0.45); }
.confirm-body { padding: 1.25rem 1.5rem; }
.confirm-body h2 { margin: 0 0 0.75rem; font-size: 1.2rem; }
.confirm-list { list-style: none; margin: 0.75rem 0 1rem; padding: 0; max-height: 45vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.confirm-list li { padding: 0.4rem 0.75rem; border-bottom: 1px solid var(--border); }
.confirm-list li:last-child { border-bottom: 0; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* Sortable table headers (data availability page) */
.table th .sort-button { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.table th .sort-button:hover { color: var(--primary); }
.table th .sort-button::after { content: "↕"; opacity: 0.35; margin-left: 0.3rem; }
.table th[aria-sort="ascending"] .sort-button::after { content: "↑"; opacity: 1; }
.table th[aria-sort="descending"] .sort-button::after { content: "↓"; opacity: 1; }

/* Imaging file list page (signed in) */
.imaging-instruments { flex-basis: 100%; }
.imaging-instruments details { width: 100%; }
.imaging-instruments summary { cursor: pointer; font-weight: 500; }
.check-list-heading { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0.75rem 0 0.25rem; }
.check-list { columns: 2; column-gap: 2rem; }
.check-list .check-inline { display: flex; break-inside: avoid; margin: 0.15rem 0; }
.scans-mode { flex-basis: 100%; }
.imaging-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.imaging-layout .panel { margin-bottom: 0; }
.imaging-layout .panel h2 { font-size: 1.05rem; }
.imaging-layout .table { box-shadow: none; }
.command { background: #f0f2f5; border-radius: var(--radius); padding: 0.75rem 1rem; font-family: var(--mono); font-size: 0.9em; overflow-x: auto; margin: 0.5rem 0 0.75rem; white-space: pre-wrap; }
@media (max-width: 720px) { .check-list { columns: 1; } }

/* Imaging file list on the public data availability page */
.imaging-box .inline-download { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.imaging-box code { font-family: var(--mono); font-size: 0.9em; background: #f0f2f5; border-radius: 4px; padding: 0.05rem 0.35rem; }
