/* Parsimony dashboard styles */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f4f4f2;
  --surface-3: #ebebe8;
  --border: #e0e0dc;
  --border-strong: #c9c9c3;
  --text: #1a1a18;
  --text-2: #57574f;
  --text-3: #8a8a80;
  --accent: #2f6f5e;
  --accent-2: #d97742;
  --accent-soft: #e8f0ed;
  --ok: #2f6f5e;
  --warn: #c2891f;
  --bad: #b04a3a;
  --grid: #e8e8e4;

  --c1: #2f6f5e; --c2: #d97742; --c3: #4a6fa5; --c4: #8a5a83; --c5: #b0803a;
  --c6: #5f8c6a; --c7: #a34f5e;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"], :root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a;
    --surface: #1d1f23;
    --surface-2: #24262b;
    --surface-3: #2c2f35;
    --border: #33363d;
    --border-strong: #454951;
    --text: #e9e9e6;
    --text-2: #a8aaa5;
    --text-3: #75786f;
    --accent: #67b39c;
    --accent-2: #e0895a;
    --accent-soft: #1f2f2b;
    --ok: #67b39c; --warn: #d7ab5a; --bad: #d4796a;
    --grid: #2a2d33;
    --c1: #67b39c; --c2: #e0895a; --c3: #7d9fd4; --c4: #b98cb1;
    --c5: #d0a763; --c6: #8bbd94; --c7: #d0808f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #16171a; --surface: #1d1f23; --surface-2: #24262b; --surface-3: #2c2f35;
  --border: #33363d; --border-strong: #454951;
  --text: #e9e9e6; --text-2: #a8aaa5; --text-3: #75786f;
  --accent: #67b39c; --accent-2: #e0895a; --accent-soft: #1f2f2b;
  --ok: #67b39c; --warn: #d7ab5a; --bad: #d4796a; --grid: #2a2d33;
  --c1: #67b39c; --c2: #e0895a; --c3: #7d9fd4; --c4: #b98cb1;
  --c5: #d0a763; --c6: #8bbd94; --c7: #d0808f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .9em; color: var(--text-2); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .86em; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 22px; height: 58px;
}
.brand { display: flex; align-items: baseline; gap: 9px; margin-right: 4px; }
.brand-name { font-weight: 650; font-size: 1.02rem; letter-spacing: -.02em; }
.brand-sub { font-size: .76rem; color: var(--text-3); }
nav.tabs { display: flex; gap: 2px; margin-left: auto; }
nav.tabs button {
  background: none; border: 0; padding: 7px 13px; border-radius: var(--radius-sm);
  font: inherit; font-size: .875rem; color: var(--text-2); cursor: pointer;
}
nav.tabs button:hover { background: var(--surface-2); color: var(--text); }
nav.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text-2);
  width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
  display: grid; place-items: center; font-size: .95rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

main { max-width: 1320px; margin: 0 auto; padding: 26px 20px 80px; }
.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to {opacity:1; transform:none;} }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-live { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
@media (max-width: 980px) { .g2,.g3,.g-live { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card-sub { font-size: .8rem; color: var(--text-3); margin: 2px 0 14px; line-height: 1.45; }
.section-title { margin: 30px 0 14px; display:flex; align-items:baseline; gap:12px; }
.section-title:first-child { margin-top: 0; }
.section-title .hint { font-size: .8rem; color: var(--text-3); font-weight: 400; }

/* ---------- hero ---------- */
.hero { margin-bottom: 22px; }
.hero p { max-width: 74ch; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; margin: 18px 0 4px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .055em; color: var(--text-3); }
.stat .v { font-size: 1.5rem; font-weight: 620; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .d { font-size: .78rem; color: var(--text-3); margin-top: 1px; }
.stat .v.accent { color: var(--accent); }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button.btn, select.btn {
  font: inherit; font-size: .85rem; padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .12s, border-color .12s;
}
button.btn:hover:not(:disabled) { background: var(--surface-2); }
button.btn:disabled { opacity: .42; cursor: not-allowed; }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
button.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
:root[data-theme="dark"] button.btn.primary, :root:not([data-theme="light"]) button.btn.primary { color: #10201c; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) button.btn.primary { color: #fff; } }
select.btn { padding-right: 26px; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: .74rem;
  padding: 3px 8px; border-radius: 20px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2); font-weight: 500;
}
.badge.ok { background: var(--accent-soft); color: var(--ok); border-color: transparent; }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); border-color: transparent; }

/* ---------- gene panel ---------- */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 5px; margin-top: 6px; }
.gene {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 7px; background: var(--surface-2); position: relative;
  transition: transform .18s cubic-bezier(.2,.8,.3,1), box-shadow .18s, background .3s, border-color .2s;
  cursor: pointer; overflow: hidden;
}
.gene:hover { border-color: var(--border-strong); }
.gene .gname { font-family: var(--mono); font-size: .68rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gene .gval { font-family: var(--mono); font-size: .82rem; font-weight: 600; margin-top: 1px; font-variant-numeric: tabular-nums; }
.gene.unmeasured .gval { color: var(--text-3); font-weight: 400; }
.gene.measured { background: var(--surface); border-color: var(--border-strong); }
.gene.just-measured { animation: pop .5s cubic-bezier(.2,.9,.3,1); box-shadow: 0 0 0 2px var(--accent); z-index: 2; }
@keyframes pop { 0% { transform: scale(.9); } 55% { transform: scale(1.05);} 100% { transform: scale(1);} }
.gene .bar { position: absolute; left: 0; bottom: 0; height: 2.5px; background: var(--accent); transition: width .3s; }
.gene.candidate { border-color: var(--accent); }
.gene .rank { position: absolute; top: 3px; right: 4px; font-size: .6rem; color: var(--accent); font-weight: 700; }

/* ---------- belief bars ---------- */
.belief-row { display: grid; grid-template-columns: 88px 1fr 52px; gap: 9px; align-items: center; margin-bottom: 6px; }
.belief-row .lab { font-size: .8rem; color: var(--text-2); text-align: right; font-weight: 500; }
.belief-row .track { height: 17px; background: var(--surface-2); border-radius: 4px; overflow: hidden; position: relative; }
.belief-row .fill { height: 100%; border-radius: 4px; transition: width .42s cubic-bezier(.2,.8,.3,1), background .3s; }
.belief-row .pct { font-family: var(--mono); font-size: .76rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.belief-row.truth .lab { color: var(--text); font-weight: 650; }
.belief-row.truth .lab::after { content: " ●"; color: var(--accent-2); font-size: .7em; }

/* ---------- meters / log ---------- */
.meter { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 7px; }
.meter .fill { height: 100%; background: var(--accent); transition: width .35s, background .35s; }
.meter .fill.low { background: var(--warn); }
.meter .fill.crit { background: var(--bad); }

.log { font-family: var(--mono); font-size: .76rem; max-height: 230px; overflow-y: auto; margin-top: 4px; }
.log-row { padding: 4px 7px; border-radius: 4px; display: flex; gap: 8px; align-items: baseline; }
.log-row:nth-child(odd) { background: var(--surface-2); }
.log-row .t { color: var(--text-3); min-width: 20px; }
.log-row .act { color: var(--text); }
.log-row.commit { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.log-row.commit.wrong { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .855rem; }
th, td { text-align: right; padding: 8px 11px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr.highlight td { background: var(--accent-soft); font-weight: 600; }
tr.highlight td:first-child { color: var(--accent); }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--text-3); font-size: 11px; }
.chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .series-label { fill: var(--text-2); font-size: 11.5px; font-weight: 550; }
.legend { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 9px; font-size: .79rem; color: var(--text-2); }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 100; opacity: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: .78rem;
  box-shadow: var(--shadow); transition: opacity .12s; max-width: 260px;
  color: var(--text);
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 2px; }
.tooltip .tt-row { color: var(--text-2); font-family: var(--mono); font-size: .74rem; }

/* ---------- method page ---------- */
.prose { max-width: 78ch; }
.prose h3 { margin: 26px 0 8px; }
.prose ul { margin: 0 0 1em; padding-left: 1.1em; color: var(--text-2); }
.prose li { margin-bottom: .35em; }
.formula {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 11px 14px; font-family: var(--mono);
  font-size: .82rem; margin: 12px 0; overflow-x: auto; color: var(--text);
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; font-size: .855rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--mono); font-size: .82rem; }

.notice {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: .82rem; color: var(--text-2); margin-bottom: 14px;
}
.loading { display: grid; place-items: center; min-height: 320px; color: var(--text-3); font-size: .9rem; gap: 12px; }
.spinner { width: 26px; height: 26px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.footer { margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--border); font-size: .8rem; color: var(--text-3); display:flex; flex-wrap:wrap; gap:6px 18px;}
