/* ── tokens ─────────────────────────────────────────────────────────────── */
:root {
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #161a21;
  --text-2: #4b5462;
  --text-3: #7a8392;

  --accent: #3b5bdb;
  --accent-hover: #3249b8;
  --accent-soft: #eef1fd;
  --accent-text: #2f48b0;

  --up: #1c64c8;       --up-soft: #e6f0fc;
  --down: #c2410c;     --down-soft: #fdeee6;
  --flat: #6b7280;     --flat-soft: #eef0f3;

  --ok: #15803d;       --ok-soft: #e7f6ec;
  --warn: #b45309;     --warn-soft: #fdf3e2;
  --bad: #c62828;      --bad-soft: #fdecec;

  --band-strong: #15803d;   --band-strong-bg: #e7f6ec;
  --band-moderate: #1d4ed8; --band-moderate-bg: #e8effd;
  --band-weak: #b45309;     --band-weak-bg: #fdf3e2;
  --band-none: #6b7280;     --band-none-bg: #eef0f3;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --focus: 0 0 0 3px rgba(59, 91, 219, .28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c212a;
    --surface-3: #252b36;
    --border: #2a303b;
    --border-strong: #3a4250;
    --text: #e8ebf0;
    --text-2: #aeb6c3;
    --text-3: #7e8796;

    --accent: #6e8cf5;
    --accent-hover: #8aa2f7;
    --accent-soft: #1d2540;
    --accent-text: #a7b8fa;

    --up: #6ea8fe;     --up-soft: #16263f;
    --down: #fb923c;   --down-soft: #3a2316;
    --flat: #9aa3b1;   --flat-soft: #232934;

    --ok: #4ade80;     --ok-soft: #12291b;
    --warn: #fbbf24;   --warn-soft: #33270f;
    --bad: #f87171;    --bad-soft: #3a1717;

    --band-strong: #4ade80;   --band-strong-bg: #12291b;
    --band-moderate: #93b4fd; --band-moderate-bg: #18233e;
    --band-weak: #fbbf24;     --band-weak-bg: #33270f;
    --band-none: #9aa3b1;     --band-none-bg: #232934;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    --focus: 0 0 0 3px rgba(110, 140, 245, .35);
  }
}

/* ── base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 var(--font); font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.warn-text { color: var(--warn); }
.boot, .loading { display: grid; place-items: center; padding: 64px 0; }
[hidden] { display: none !important; }

/* ── top bar ────────────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { flex: none; display: block; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav-link { padding: 7px 12px; border-radius: 7px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 6px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-size: 11.5px; font-weight: 650; flex: none; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.account-id { display: flex; gap: 14px; align-items: center; }

/* ── page layout ────────────────────────────────────────────────────────── */
.main { outline: none; }
.page { max-width: 1440px; margin: 0 auto; padding: 28px 24px 64px; display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 72ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 6px 0; }
.section-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.split-main { padding: 20px; }
.split-side .card { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.sticky { position: sticky; top: 76px; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 650; display: grid; place-items: center; }

/* ── buttons & inputs ───────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; text-decoration: none !important; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-text { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; width: 28px; height: 28px; border-radius: 6px; color: var(--text-3); font-size: 18px; line-height: 1; cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 550; cursor: pointer; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--text-3); }
.hint-ok { color: var(--ok); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input.search { max-width: 420px; }
.inline-check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* ── notices / empty / toast ────────────────────────────────────────────── */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.notice-error { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-title { font-size: 16px; font-weight: 600; }
.empty p { color: var(--text-2); max-width: 52ch; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-weight: 500; transition: opacity .18s, transform .18s; z-index: 100; max-width: min(560px, calc(100vw - 32px)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--bad); color: #fff; }
.toast-success { background: var(--ok); color: #fff; }

.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .toast { transition: none; } }

/* ── modal ──────────────────────────────────────────────────────────────── */
.modal { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal-wide { width: min(980px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(10, 14, 20, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 20px; overflow: auto; max-height: calc(100vh - 190px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ── tables ─────────────────────────────────────────────────────────────── */
.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table th:first-child { border-top-left-radius: var(--radius); }
.table th:last-child { border-top-right-radius: var(--radius); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 4px; }
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--surface-2); }
.strong-link { font-weight: 600; color: var(--text); }
.progress { position: relative; display: flex; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 120px; }
.progress-done { background: var(--accent); transition: width .4s; }
.progress-failed { background: var(--bad); transition: width .4s; }
.progress-label { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* ── tags & chips ───────────────────────────────────────────────────────── */
.server-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 550; color: var(--text); }
.server-pill-base { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.source-tag, .role-tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 550; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.source-moonbase { background: var(--accent-soft); color: var(--accent-text); }
.role-admin { background: var(--accent-soft); color: var(--accent-text); }
.base-tag { display: inline-flex; height: 18px; align-items: center; padding: 0 6px; border-radius: 4px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.band { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.band-strong { color: var(--band-strong); background: var(--band-strong-bg); }
.band-moderate { color: var(--band-moderate); background: var(--band-moderate-bg); }
.band-weak { color: var(--band-weak); background: var(--band-weak-bg); }
.band-not-viable { color: var(--band-none); background: var(--band-none-bg); }
.delta { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta-up { color: var(--up); background: var(--up-soft); }
.delta-down { color: var(--down); background: var(--down-soft); }
.delta-flat { color: var(--flat); background: var(--flat-soft); }
.conf { font-size: 11.5px; color: var(--text-3); }
.conf-high { color: var(--ok); }
.conf-low { color: var(--warn); }
.override-tag { font-size: 11px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 1px 5px; }
.band-change { font-size: 11px; font-weight: 650; color: var(--down); }

/* ── picker ─────────────────────────────────────────────────────────────── */
.picker { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { background: none; border: 0; padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 550; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.search-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 8px; }
.search-row input.search { max-width: none; }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 460px; overflow-y: auto; }
.pick-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.pick-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--surface-2); }
.pick-row input { margin-top: 2px; }
.pick-text { flex: 1; min-width: 0; }
.pick-title { font-weight: 550; }
.pick-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-meta { flex: none; }
.pick-empty { padding: 28px 16px; text-align: center; color: var(--text-2); }
.pick-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; gap: 8px; }

/* Moonbase feed */
.feed-filters { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.feed-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.feed-score { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; color: var(--accent-text); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px; }
.feed-money { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.id-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); }
@media (max-width: 720px) { .feed-filters { grid-template-columns: 1fr 1fr; } .id-row { grid-template-columns: 1fr; } }

/* ── new comparison side panel ──────────────────────────────────────────── */
.server-choices { display: flex; flex-direction: column; gap: 6px; }
.server-choice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.server-choice.is-baseline { border-color: var(--accent); background: var(--accent-soft); }
.server-check { display: flex; gap: 10px; align-items: center; min-width: 0; cursor: pointer; }
.server-choice-text { display: flex; flex-direction: column; min-width: 0; }
.server-choice-name { font-weight: 600; }
.server-choice-url { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.baseline-radio { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.is-baseline .baseline-radio { color: var(--accent-text); font-weight: 600; }
.tray-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.tray-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 7px 8px 7px 10px; background: var(--surface-2); border-radius: 7px; }
.tray-text { min-width: 0; }
.tray-title { font-size: 13px; font-weight: 550; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tray-sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-empty { font-size: 13px; color: var(--text-3); padding: 10px; text-align: center; border: 1px dashed var(--border-strong); border-radius: 7px; }
.run-count { display: flex; align-items: baseline; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.run-count-num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.run-count-label { font-size: 12.5px; color: var(--text-2); }

/* ── comparison view ────────────────────────────────────────────────────── */
.status-strip { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.status-counts { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.status-count strong { font-variant-numeric: tabular-nums; color: var(--text); }
.status-count.is-failed strong { color: var(--bad); }
.status-count.is-running strong { color: var(--accent-text); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.summary-card { padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.summary-base { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.summary-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.summary-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-stat { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.summary-big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary-unit { font-size: 12.5px; color: var(--text-2); }
.summary-metrics { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.summary-foot { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.matrix-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.seg { background: none; border: 0; height: 30px; padding: 0 12px; border-radius: 6px; font-weight: 550; color: var(--text-2); cursor: pointer; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.metric-select { width: auto; height: 30px; border: 0; background: transparent; font-weight: 550; color: var(--text-2); padding: 0 8px; cursor: pointer; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.matrix-card { overflow: hidden; }
.matrix-scroll { overflow-x: auto; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; }
.matrix th, .matrix td { border-bottom: 1px solid var(--border); padding: 12px 14px; text-align: left; vertical-align: top; }
.matrix thead th { background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); position: sticky; top: 0; }
.matrix tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.matrix tfoot td { background: var(--surface-2); border-bottom: 0; }
.col-research { min-width: 280px; max-width: 420px; position: sticky; left: 0; background: var(--surface); z-index: 1; border-right: 1px solid var(--border); }
thead .col-research, tfoot .col-research { background: var(--surface-2); z-index: 2; }
.col-server { min-width: 170px; }
.th-server { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.matrix .is-baseline { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.matrix thead .is-baseline { background: var(--accent-soft); color: var(--accent-text); }
.research-link { font-weight: 600; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.research-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-done { display: flex; flex-direction: column; gap: 5px; }
.cell-main { display: flex; align-items: baseline; gap: 6px; }
.cell-val { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cell-of { font-size: 12px; color: var(--text-3); }
.cell-main .delta { align-self: center; }
.cell-sub { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 20px; }
.cell-time { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cell-state { font-size: 12.5px; font-weight: 550; }
.cell-state.is-queued { color: var(--text-3); }
.cell-state.is-failed { color: var(--bad); }
.cell-running { display: flex; gap: 8px; align-items: flex-start; }
.cell-status { font-size: 12px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 220px; }
.cell-error { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.foot-val { font-weight: 650; font-variant-numeric: tabular-nums; }

/* ── research detail ────────────────────────────────────────────────────── */
.detail-card { overflow: hidden; }
.detail-scroll { overflow-x: auto; }
.dgrid { display: grid; border-bottom: 1px solid var(--border); width: 100%; }
.dgrid > * { min-width: 0; overflow-wrap: anywhere; }
.dgrid > * { padding: 12px 14px; }
.dgrid-label { font-weight: 550; color: var(--text-2); position: sticky; left: 0; background: var(--surface); z-index: 1; border-right: 1px solid var(--border); }
.dgrid-overview { background: var(--surface-2); }
.dgrid-overview .dgrid-label { background: var(--surface-2); }
.dcol-head { display: flex; flex-direction: column; gap: 6px; }
.dcol-head.is-baseline, .dcell.is-baseline { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.dcol-name { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.dcol-index { display: flex; align-items: baseline; gap: 8px; min-height: 36px; }
.dcol-big { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dcol-index .delta { align-self: center; }
.dcol-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.detail-section-label { padding: 18px 14px 8px; background: var(--surface); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); border-bottom: 1px solid var(--border); position: sticky; left: 0; }
.dim-toggle { overflow-wrap: normal; display: flex; align-items: center; gap: 8px; border: 0; border-right: 1px solid var(--border); text-align: left; cursor: pointer; font: inherit; font-weight: 550; color: var(--text); }
.dim-toggle:hover { background: var(--surface-2); }
.chev { display: inline-block; transition: transform .15s; color: var(--text-3); font-size: 16px; line-height: 1; }
.is-open .chev { transform: rotate(90deg); }
.weight { white-space: nowrap; margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.dcell { min-width: 0; }
.score-line { display: flex; align-items: center; gap: 10px; }
.score-bar { flex: 1; max-width: 140px; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.score-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.score-num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 20px; }
.dcell-tags { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.dgrid-evidence { background: var(--surface-2); }
.dgrid-evidence .dgrid-label { background: var(--surface-2); }
.evidence { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.evidence-summary { color: var(--text); }
.figures { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.figures dt { color: var(--text-3); text-transform: capitalize; }
.figures dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.ref-list { margin: 0; padding-left: 18px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.payload-card { padding: 0; }
.payload-card summary { padding: 14px 16px; cursor: pointer; font-weight: 550; color: var(--text-2); }
.code-block { margin: 0; padding: 16px; background: var(--surface-2); border-top: 1px solid var(--border); font: 12.5px/1.55 var(--mono); overflow: auto; max-height: 520px; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 0 0 var(--radius) var(--radius); }
.modal .code-block { border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ── servers ────────────────────────────────────────────────────────────── */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.server-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.server-card.is-archived { opacity: .65; }
.server-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.server-card-head .mono { overflow-wrap: anywhere; margin-top: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.server-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.test-result { font-size: 12.5px; }
.test-result:empty { display: none; }
.test-result.is-ok { color: var(--ok); }
.test-result.is-bad { color: var(--bad); }

/* ── login ──────────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 650; }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  /* minmax(0, …): a 1fr track won't shrink below its widest unbreakable child (nowrap subtitles). */
  .split { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 0 16px; gap: 12px; }
  .user-name { display: none; }
  .brand > span { display: none; }
  .page { padding: 20px 16px 48px; }
  h1 { font-size: 19px; }
  .search-row { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .col-research { min-width: 200px; }
  .split-main, .split-side .card { padding: 16px; }
  input.search { max-width: none; }
}
