:root {
  --bg: #0b0d10;
  --bg-soft: #111419;
  --bg-card: #14181f;
  --line: #232a34;
  --line-soft: #1a2029;
  --text: #e6ebf2;
  --text-dim: #96a1b1;
  --text-faint: #6a7686;
  --accent: #6ee7a8;
  --accent-dim: #1f4d36;
  --warn: #f0b357;
  --danger: #f2707c;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(110, 231, 168, 0.07), transparent 60%),
    radial-gradient(700px 400px at 92% 0%, rgba(88, 130, 255, 0.06), transparent 65%);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 16, 0.78);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 14px; }

.mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(160deg, var(--accent-dim), #0e141a);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  font-size: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 650;
}

.topbar p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

.pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill-ok { color: var(--accent); border-color: var(--accent-dim); background: rgba(110, 231, 168, 0.07); }
.pill-bad { color: var(--danger); border-color: #4a2530; background: rgba(242, 112, 124, 0.07); }

/* ---------- layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 28px 40px;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 20px 40px -30px #000;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: span 2; }
.field > span:first-child {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 600;
}

input[type="text"], input[type="password"], input[type="search"], input[type="number"], select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
select { font-family: var(--sans); font-size: 13px; cursor: pointer; }

input:focus, select:focus {
  border-color: #33513f;
  box-shadow: 0 0 0 3px rgba(110, 231, 168, 0.08);
}

.with-btn { display: flex; gap: 6px; }
.ghost-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 9px;
  width: 38px;
  cursor: pointer;
  font-size: 13px;
}
.ghost-btn:hover { color: var(--text); border-color: #2e3742; }

.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 7px; }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.chk input { accent-color: var(--accent); margin: 0; }

.field-checks { grid-column: span 2; }
.field-checks > span:first-child { margin-bottom: 0; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

button.primary, button.secondary {
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.06s, filter 0.15s;
}
button.primary {
  background: linear-gradient(180deg, #7ff0b6, #50c98d);
  color: #06120c;
  border-color: #4fbd85;
}
button.primary:hover { filter: brightness(1.06); }
button.primary:active { transform: translateY(1px); }
button.secondary {
  background: var(--bg-soft);
  color: var(--text-dim);
  border-color: var(--line);
}
button.secondary:hover:not(:disabled) { color: var(--text); border-color: #2e3742; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--text-faint); margin-left: auto; }

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

.status { margin-top: 16px; border-radius: 12px; padding: 12px 14px; font-size: 13px; border: 1px solid var(--line); }
.status.err { border-color: #4a2530; background: rgba(242, 112, 124, 0.06); color: #ffd2d7; }
.status.info { border-color: var(--accent-dim); background: rgba(110, 231, 168, 0.06); color: #cdf7e0; }
.status pre {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-all;
}
.status .title { font-weight: 650; letter-spacing: 0.01em; }

/* ---------- stats ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
}
.stat .k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 600;
}
.stat .v {
  font-family: var(--mono);
  font-size: 17px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat .v.accent { color: var(--accent); }

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
}
.toolbar #search { flex: 1 1 240px; }
.toolbar select { width: auto; flex: 0 0 auto; }
.toolbar .spacer { flex: 1 1 auto; }
.toolbar .box {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 6px 10px;
  border-radius: 8px;
}
.rate { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-faint); }
.rate input { width: 92px; }

.count { font-size: 12px; color: var(--text-faint); margin: 0 0 10px 2px; font-family: var(--mono); }

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

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  max-height: 70vh;
  background: var(--bg-card);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #101520;
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  font-weight: 650;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th.num { text-align: right; }
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-dim); }
thead th.active { color: var(--accent); }

tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
tbody tr.row { cursor: pointer; }
tbody tr.row:hover td { background: #161b23; }
tbody tr.expanded td { background: #161c25; }
tbody td.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.model-id { font-family: var(--mono); font-size: 12.5px; color: var(--text); word-break: break-all; }
.model-name { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.provider { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.ctx { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.p-free { color: var(--accent); font-weight: 600; }
.p-none { color: var(--text-faint); }
.p-hi { color: var(--warn); }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--text-faint);
  margin: 0 3px 3px 0;
  white-space: nowrap;
  text-transform: lowercase;
}
.tag.free { color: var(--accent); border-color: var(--accent-dim); background: rgba(110, 231, 168, 0.07); }
.tag.vision { color: #9db8ff; border-color: #2c3a5c; }
.tag.tools { color: #d3b3ff; border-color: #3c2f52; }
.tag.reasoning { color: #ffcf8f; border-color: #4a3a22; }
.tag.tier { color: var(--warn); border-color: #4a3a22; }

tr.detail td { background: #0e1319; padding: 0; }
.detail-inner {
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 22px;
  font-size: 12px;
  color: var(--text-dim);
}
.detail-inner h4 {
  margin: 0 0 5px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.detail-inner p { margin: 0 0 4px; line-height: 1.5; }
.detail-inner code { font-family: var(--mono); color: var(--text); font-size: 11.5px; }
.detail-inner .tier-list { font-family: var(--mono); font-size: 11.5px; line-height: 1.7; }
.detail-inner .full { grid-column: 1 / -1; }

footer {
  border-top: 1px solid var(--line);
  padding: 16px 28px 28px;
  font-size: 11.5px;
  color: var(--text-faint);
  max-width: 1500px;
  margin: 0 auto;
  width: 100%;
  line-height: 1.6;
}
footer code { font-family: var(--mono); color: var(--text-dim); }

@media (max-width: 780px) {
  main { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .field-wide, .field-checks { grid-column: span 1; }
  .hint { margin-left: 0; }
}

.assume {
  color: var(--warn);
  font-size: 10px;
  margin-left: 4px;
  cursor: help;
}
tr.row .sub { font-size: 10.5px; }

/* ---------- model testing ---------- */

.testbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-dim);
  border-radius: 12px;
  margin-bottom: 10px;
}

.testbar .rate select { width: auto; padding: 5px 8px; }

.cost-note {
  margin: 0 0 12px 2px;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.55;
}
.cost-note strong { color: var(--warn); font-weight: 600; }

.test-progress { font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: nowrap; }

th.col-check, td.col-check { width: 34px; text-align: center; padding-left: 10px; padding-right: 0; }
th.col-status, td.col-status { width: 96px; white-space: nowrap; }

td.col-check input { accent-color: var(--accent); cursor: pointer; }

.t-none { color: var(--text-faint); font-family: var(--mono); font-size: 11px; }
.t-run {
  display: inline-flex; align-items: center; gap: 5px;
  color: #9db8ff; font-family: var(--mono); font-size: 11px;
}
.t-run::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.t-ok {
  color: var(--accent); font-family: var(--mono); font-size: 11.5px;
  background: rgba(110, 231, 168, 0.08);
  border: 1px solid var(--accent-dim);
  padding: 1px 6px; border-radius: 5px;
}
.t-fail {
  color: var(--danger); font-family: var(--mono); font-size: 11.5px;
  background: rgba(242, 112, 124, 0.08);
  border: 1px solid #4a2530;
  padding: 1px 6px; border-radius: 5px;
  cursor: help;
}
.t-warn {
  color: var(--warn); font-family: var(--mono); font-size: 11.5px;
  border: 1px solid #4a3a22; padding: 1px 6px; border-radius: 5px; cursor: help;
}

tr.row.selected td { background: rgba(110, 231, 168, 0.045); }
.detail-inner .probe-err {
  font-family: var(--mono); font-size: 11.5px; color: #ffd2d7;
  background: rgba(242, 112, 124, 0.06);
  border: 1px solid #4a2530; border-radius: 8px; padding: 8px 10px;
  white-space: pre-wrap; word-break: break-word;
}

.col-status { cursor: pointer; }
.mini-test {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-dim);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 5px;
  padding: 1px 7px;
  cursor: pointer;
}
.mini-test:hover { color: var(--accent); border-color: var(--accent-dim); background: rgba(110, 231, 168, 0.06); }
