:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #171a21;
  --muted: #5d6573;
  --line: #e1e4ea;
  --accent: #6366f1;
  --gold: #e2a713;
  --silver: #94a0b2;
  --bronze: #c0753a;
  --ok: #16a34a;
  --err: #dc2626;
  --mark: #fff3a3;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 2px 8px rgb(16 24 40 / 5%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015;
    --panel: #161920;
    --panel-2: #1d2129;
    --text: #e8eaef;
    --muted: #9aa3b2;
    --line: #2a2f39;
    --mark: #5c4d00;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1015; --panel: #161920; --panel-2: #1d2129; --text: #e8eaef; --muted: #9aa3b2;
  --line: #2a2f39; --mark: #5c4d00; --shadow: 0 1px 2px rgb(0 0 0 / 40%); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px 32px;
  max-width: 1600px;
  margin: 0 auto;
}
a { color: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0 12px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.status { display: flex; align-items: center; gap: 10px; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgb(22 163 74 / 50%); animation: pulse 2s infinite; }
.live.busy .dot { background: var(--accent); }
.live.err .dot { background: var(--err); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(22 163 74 / 45%); } 70% { box-shadow: 0 0 0 7px rgb(22 163 74 / 0%); } 100% { box-shadow: 0 0 0 0 rgb(22 163 74 / 0%); } }
.btn { font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: progress; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field.grow { flex: 1 1 260px; }
.field.small { min-width: 70px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
input, select { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { --c: var(--accent); display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip.off { background: transparent; border-color: var(--line); color: var(--muted); }
.chip.off::before { background: var(--line); }

.search-panel { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.search-panel h3 { margin: 0 0 8px; font-size: 14px; }
.search-panel .muted { color: var(--muted); font-weight: 400; }
.sr-site { --c: var(--accent); border-left: 4px solid var(--c); padding: 4px 0 4px 10px; margin: 8px 0; }
.sr-site strong { color: var(--c); }
.sr-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sr-item { font: inherit; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; text-align: left; }
.sr-item:hover { border-color: var(--c); }
.sr-item .m { color: var(--muted); }

.boxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; margin-top: 16px; }
.box { --c: var(--accent); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.box.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 45%, transparent); } }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 0; }
.box-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.box h2 { margin: 0; font-size: 17px; color: var(--c); }
.ext { text-decoration: none; color: var(--muted); padding: 0 4px; }
.ext:hover { color: var(--c); }
.box-status { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.box-status.err { color: var(--err); }
.box-desc { margin: 4px 14px 0; color: var(--muted); font-size: 12.5px; }
.box-controls { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.box-controls select { flex: 1; min-width: 0; border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.cat-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

.table-wrap { padding: 0 6px; overflow-x: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.hit td { background: var(--mark); }
.c-rank { width: 46px; }
.c-score { width: 38%; }
.model { font-weight: 600; overflow-wrap: anywhere; }
.org { font-size: 12px; color: var(--muted); }
.score { display: flex; flex-direction: column; gap: 3px; }
.score-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; font-variant-numeric: tabular-nums; }
.score-val { font-weight: 700; }
.score-extra { font-size: 11.5px; color: var(--muted); text-align: right; }
.bar { height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--c); border-radius: 3px; }

.rk { display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 7px; font-weight: 700; font-size: 12.5px; background: var(--panel-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.rk.r1 { background: var(--gold); color: #3b2a00; }
.rk.r2 { background: var(--silver); color: #fff; }
.rk.r3 { background: var(--bronze); color: #fff; }
.rk.r10 { background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent); color: var(--text); }
.legend .rk { --c: var(--accent); margin-left: 8px; }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.box-foot { padding: 8px 14px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 6px; }
.foot { color: var(--muted); font-size: 12.5px; margin-top: 20px; }
.skeleton td { color: transparent; }
.skeleton td::after { content: ""; display: block; height: 12px; border-radius: 4px; background: var(--panel-2); }

@media (max-width: 640px) {
  .field { min-width: 0; flex: 1 1 45%; }
  .field.grow { flex-basis: 100%; }
  .c-score { width: 44%; }
}
