/* ULTRABENCH — components: chips, pills, buttons, inputs, tables, panels, empty states. */

/* ---------- buttons + inputs ---------- */

.btn {
  font: inherit; font-size: 12px; line-height: 1;
  padding: 7px 11px; border-radius: var(--radius-s);
  border: 1px solid var(--line-strong); background: var(--bg-inset); color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--text-faint); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06231c; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 8px; font-size: 11px; }

input[type="text"], input[type="password"], input[type="number"], select {
  font: inherit; font-size: 13px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 6px 8px; min-width: 0;
}
input::placeholder { color: var(--text-faint); }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
}
.filters label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
.filters input[type="number"] { width: 82px; }
.spacer { flex: 1 1 auto; }

/* ---------- pills + chips ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 5px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg-inset); color: var(--text-dim);
  white-space: nowrap;
}
.pill-accent { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-dim); }

.chip {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 10px; line-height: 1;
  padding: 3px 5px; border-radius: 3px;
  border: 1px solid var(--line-strong); color: var(--text-faint);
  white-space: nowrap; vertical-align: middle;
}
.chip + .chip { margin-left: 4px; }
/* trust ladder: 3 strong -> 0 muted */
.chip-t3 { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-dim); }
.chip-t2 { color: #a9d9c9; border-color: #22322e; }
.chip-t1 { color: var(--text-dim); }
.chip-t0 { color: var(--text-faint); border-style: dashed; }
/* method */
.chip-m-derived_estimate { color: var(--warn); border-color: #3a3116; border-style: dashed; letter-spacing: .04em; }
.chip-m-measured  { color: var(--accent); border-color: var(--accent-dim); }
.chip-m-vendor    { color: #a9d9c9; border-color: #22322e; }
.chip-m-aggregator{ color: var(--info); border-color: #1c2c40; }
.chip-m-community { color: var(--text-dim); }

.badge {
  display: inline-block; font-family: var(--mono); font-size: 10px; line-height: 1;
  padding: 3px 6px; border-radius: 3px; border: 1px solid var(--line-strong); color: var(--text-dim);
}
.badge-core        { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-dim); }
/* reference = published beside the index, weight 0 on purpose (it aggregates weighted rows) */
.badge-reference   { color: var(--info); border-color: #1c2c40; }
.badge-extended    { color: var(--text-dim); }
/* open weights — the one model attribute worth a badge on a public surface */
.badge-open,
.badge-open-weights { color: var(--info); border-color: #1c2c40; }
.badge-superseded  { color: var(--text-faint); }

.est { color: var(--warn); font-style: normal; }
.muted { color: var(--text-faint); }
.dash  { color: var(--text-faint); }

/* ---------- panels ---------- */

.panel {
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
}
.panel > h3 { margin-bottom: 10px; }
.panel-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--text-faint); font-size: 12px; }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.stat-row { display: flex; flex-wrap: wrap; gap: 18px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 92px; }
.stat .stat-label { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.stat .stat-value { font-family: var(--mono); font-size: 17px; }

/* ---------- tables (horizontal scroll + sticky first column) ---------- */

/* Scroll affordance shell. A wide table that runs off a phone screen must SAY so: the
   fade sits above the right edge of the scroller (it cannot scroll away, unlike a
   pseudo-element inside the scroller) and the scrollbar is forced visible on the
   platforms that hide it until touched. Both are narrow-width only — on a desktop the
   table fits and a permanent fade would be decoration that lies. */
.scroll-x { position: relative; }

@media (max-width: 860px) {
  .scroll-x::after {
    content: ""; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 34px;
    pointer-events: none; border-radius: 0 var(--radius) var(--radius) 0;
    background: linear-gradient(to right, rgba(17, 20, 26, 0), rgba(17, 20, 26, .92));
  }
  .scroll-x .table-wrap, .scroll-x .lb-wrap {
    scrollbar-width: thin; scrollbar-color: var(--accent-dim) transparent;
  }
  .scroll-x .table-wrap::-webkit-scrollbar, .scroll-x .lb-wrap::-webkit-scrollbar {
    height: 9px; -webkit-appearance: none;
  }
  .scroll-x .table-wrap::-webkit-scrollbar-track, .scroll-x .lb-wrap::-webkit-scrollbar-track {
    background: transparent;
  }
  .scroll-x .table-wrap::-webkit-scrollbar-thumb, .scroll-x .lb-wrap::-webkit-scrollbar-thumb {
    background: var(--accent-dim); border-radius: 999px;
  }
}

.table-wrap {
  overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raised);
  -webkit-overflow-scrolling: touch;
}
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.data th, table.data td {
  padding: 9px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-inset); color: var(--text-dim);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .sort-arrow { color: var(--accent); margin-left: 4px; }
table.data tbody tr:hover { background: var(--bg-inset); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 220px; }

table.data th:first-child, table.data td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--bg-raised);
}
table.data th:first-child { z-index: 3; background: var(--bg-inset); }
table.data tbody tr:hover td:first-child { background: var(--bg-inset); }
table.data tr.row-superseded td { color: var(--text-faint); }
table.data tr.row-superseded td:first-child { background: var(--bg-raised); }

/* Narrow screens: the first column stays pinned (it is the row's identity — a benchmark
   name, a quant, a GPU) and gives up width so the columns behind it are reachable
   instead of being pushed off a 390px screen entirely. */
@media (max-width: 560px) {
  table.data th, table.data td { padding: 8px 10px; }
  table.data td.wrap, table.data th.wrap { min-width: 0; max-width: 42vw; }
  table.data th:first-child, table.data td:first-child {
    position: sticky; left: 0; max-width: 42vw;
    border-right: 1px solid var(--line-strong);
  }
}

/* ---------- empty / error states ---------- */

.empty-state {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 34px 20px; text-align: center; color: var(--text-dim);
  background: var(--bg-raised);
}
.empty-state h2 { color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0 auto; max-width: 46ch; }
.error-state { border-color: #3a1c1f; }
.error-state h2 { color: var(--danger); }

.notice {
  border: 1px solid var(--line-strong); border-left: 3px solid var(--warn);
  background: var(--bg-inset); border-radius: var(--radius-s);
  padding: 8px 12px; margin-bottom: 12px; color: var(--text-dim); font-size: 12px;
}

.sparkline { display: inline-block; vertical-align: middle; }
