:root {
  --bg: #0c0e11;
  --panel: #14181d;
  --panel-2: #191e24;
  --line: #242b33;
  --line-soft: #1c222a;
  --text: #e7ebf0;
  --text-dim: #97a3b1;
  --text-faint: #6b7784;
  --accent: #4da3ff;
  --good: #3fb96a;
  --mid: #d0a12b;
  --bad: #c8503f;
  --row: 27px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.page-scroll { overflow: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.no-js .js-only { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 52px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  white-space: nowrap;
}

.brand h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand .sub {
  font-size: 11px;
  color: var(--text-faint);
}

.bar .spacer { flex: 1 1 auto; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  height: 30px;
}

.field:focus-within { border-color: var(--accent); }

.field input,
.field select {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  outline: 0;
  height: 100%;
}

.field input { width: 190px; }
.field select { cursor: pointer; }
.field select option { background: var(--panel-2); }

.field .icon { color: var(--text-faint); font-size: 12px; }

.btn {
  height: 30px;
  padding: 0 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #364150; color: var(--text); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn.accent { color: var(--text); border-color: #33465c; }
.btn.accent[aria-pressed="true"] { background: #14304d; border-color: var(--accent); color: #9fccff; }

.chips { display: flex; gap: 5px; align-items: center; }

.chip {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
}

.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.chip[aria-pressed="true"] { color: var(--text); border-color: #3d4956; background: #1f262e; }
.chip.off { opacity: 0.38; }

/* ---------- table ---------- */

.table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-variant-numeric: tabular-nums;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line-soft);
  padding: 0 8px;
  height: 46px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
}

.grid thead th .th-in { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.grid thead th .th-sub { font-size: 9px; color: var(--text-faint); font-weight: 400; }
.grid thead th a { color: inherit; }
.grid thead th:hover { color: var(--text); }
.grid thead th.sorted { color: var(--accent); }
.grid thead th .arrow { font-size: 9px; }

.grid tbody td {
  padding: 0 8px;
  height: var(--row);
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
}

.grid tbody tr:hover td { background-color: #171d24; }
.grid tbody tr.hidden { display: none; }

.c-rank, .c-model, .c-lab { text-align: left !important; }

th.c-rank, td.c-rank { position: sticky; left: 0; z-index: 2; width: 42px; color: var(--text-faint); }
th.c-model, td.c-model { position: sticky; left: 42px; z-index: 2; min-width: 196px; max-width: 240px; }
th.c-rank, th.c-model { z-index: 4; }
td.c-rank, td.c-model { background: var(--bg); }
.grid tbody tr:hover td.c-rank, .grid tbody tr:hover td.c-model { background: #171d24; }
td.c-model { border-right: 1px solid var(--line); }
th.c-model { border-right: 1px solid var(--line); }

.model-name { display: flex; align-items: center; gap: 7px; }
.model-name .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.model-name .nm { overflow: hidden; text-overflow: ellipsis; max-width: 158px; }

.tag {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--text-faint);
  line-height: 1.3;
}
.tag.open { color: #7fcf9b; border-color: #2c4a37; }

.c-lab { color: var(--text-dim); font-size: 11px; max-width: 104px; overflow: hidden; text-overflow: ellipsis; }

td.score { position: relative; }
td.score .v { position: relative; z-index: 1; }
td.score .fill {
  position: absolute;
  inset: 1px 0;
  z-index: 0;
  border-radius: 2px;
}
td.empty { color: #3d454e; }

.flag {
  font-size: 9px;
  margin-left: 3px;
  color: var(--mid);
  vertical-align: 1px;
}
.flag.stale { color: #c8503f; }

td.c-comp { font-weight: 600; }
td.c-comp .cov { font-size: 9px; color: var(--text-faint); font-weight: 400; margin-left: 4px; }

/* ---------- status bar ---------- */

.status {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-faint);
}

.status .src { display: inline-flex; align-items: center; gap: 5px; }
.status .sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.status .sdot.stale { background: var(--mid); }
.status .sdot.failed { background: var(--bad); }

/* ---------- weights panel ---------- */

.panel {
  position: absolute;
  top: 52px;
  right: 16px;
  width: 320px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  z-index: 20;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.panel[hidden] { display: none; }
.panel h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.panel p { margin: 0 0 12px; font-size: 11px; color: var(--text-faint); line-height: 1.5; }

.wrow { display: grid; grid-template-columns: 1fr 84px 30px; align-items: center; gap: 8px; margin-bottom: 7px; }
.wrow label { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow input[type="range"] { width: 100%; accent-color: var(--accent); }
.wrow .val { font-size: 11px; color: var(--text-faint); text-align: right; }

/* ---------- detail pages ---------- */

.doc {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.doc h1 { font-size: 24px; margin: 0 0 6px; font-weight: 600; }
.doc h2 { font-size: 14px; margin: 26px 0 8px; font-weight: 600; color: var(--text); }
.doc p { color: var(--text-dim); line-height: 1.65; margin: 0 0 10px; max-width: 70ch; }
.doc .meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 20px; }
.doc .pill { font-size: 11px; border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; color: var(--text-dim); }
.doc table { border-collapse: collapse; width: 100%; margin-top: 8px; font-variant-numeric: tabular-nums; }
.doc table th { text-align: left; font-size: 11px; color: var(--text-faint); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.doc table td { padding: 5px 10px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.doc table td.num, .doc table th.num { text-align: right; }
.doc .back { font-size: 12px; }
