:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #637083;
  --rule: #e3e7ec;
  --rule-strong: #cfd6de;
  --accent: #1d5c8f;
  --accent-dark: #164a74;
  --accent-soft: #e8f1f8;
  --bar: #5b93c2;
  --note-bg: #fff8e8;
  --note-rule: #f0cf86;
  --error-bg: #fdecec;
  --error-rule: #eba3a3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 620; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-bottom: 64px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* --- top bar ---------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--rule); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); }
.topbar-note { font-size: 13px; color: var(--muted); }

/* --- cards, buttons, alerts ------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-top: 20px;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f7f9fb; text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: 13px; }

.alert { border-radius: 8px; padding: 12px 16px; margin-top: 16px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert li + li { margin-top: 4px; }
.alert-note { background: var(--note-bg); border: 1px solid var(--note-rule); }
.alert-error { background: var(--error-bg); border: 1px solid var(--error-rule); white-space: pre-line; }

/* --- upload page ------------------------------------------------------- */
.intro { padding: 36px 0 4px; max-width: 760px; }
.intro p { color: var(--muted); font-size: 16px; margin: 10px 0 0; }

.form { padding: 26px 28px; }
.step + .step { margin-top: 26px; }
.step h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-num {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700;
}

.dropzone {
  display: flex; align-items: center; justify-content: center;
  min-height: 132px; padding: 18px;
  border: 1.5px dashed var(--rule-strong); border-radius: var(--radius);
  background: #fafbfc; cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dz-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.dz-empty strong { color: var(--ink); font-weight: 600; }
.dz-file { display: flex; align-items: center; gap: 12px; text-align: left; }
.dz-file > span:nth-child(2) { display: flex; flex-direction: column; }
.link { color: var(--accent); font-weight: 550; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.model-select {
  width: 100%; min-height: 44px; padding: 9px 38px 9px 12px;
  border: 1.5px solid var(--rule-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.model-select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 26px; }
.progress { margin-top: 18px; }
.progress-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar { height: 8px; background: var(--rule); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .25s ease; }

.panels summary { cursor: pointer; font-weight: 600; }
.panels p { margin: 10px 0; }
.channel-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 14px 0 0; padding: 0; }
.channel-list li { padding: 5px 10px; border: 1px solid var(--rule); border-radius: 999px; background: #fafbfc; font-size: 13px; }

/* --- tables ------------------------------------------------------------ */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; font-size: 12px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1.5px solid var(--rule-strong); white-space: nowrap;
}
.table td { padding: 6px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tbody tr:hover td { background: #f7f9fb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-col { width: 190px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inline-bar { display: inline-block; width: 110px; height: 7px; background: #edf1f5; border-radius: 99px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.inline-bar > span { display: block; height: 100%; background: var(--bar); border-radius: 99px; max-width: 100%; }
.bar-text { display: inline-block; min-width: 46px; text-align: right; font-size: 13px; }
.indent { padding-left: calc(var(--level) * 16px); }

/* --- report ------------------------------------------------------------ */
.report-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-top: 28px; }
.back { font-size: 14px; }
.report-head h1 { margin-top: 6px; }
.meta { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.meta span + span::before { content: "·"; margin: 0 8px; color: var(--rule-strong); }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 20px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: flex; flex-direction: column; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.phenotype { font-weight: 550; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type="search"] { font: inherit; font-size: 14px; padding: 7px 11px; min-width: 280px; border: 1px solid var(--rule-strong); border-radius: 8px; }
.toolbar input[type="search"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

.population-path { font-weight: 550; }
.population-table tr.empty td { color: #9aa5b1; }
.population-table tr.empty .inline-bar { opacity: .4; }
.cell-type { color: var(--muted); max-width: 260px; }
.population-table tr.hidden { display: none; }

.pending { text-align: center; padding: 48px 24px; margin-top: 40px; }
.pending h1 { font-size: 22px; }
.pending .alert { text-align: left; }

@media (max-width: 720px) {
  .topbar-note { display: none; }
  .bar-col { width: auto; }
  .inline-bar { width: 60px; }
  .toolbar input[type="search"] { min-width: 0; width: 100%; }
}

@media print {
  .topbar, .downloads, .toolbar, .back { display: none !important; }
  body { background: #fff; }
  .card, .tile { box-shadow: none; }
  .population-table tr.hidden { display: table-row; }
}
