/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f5f7fb;
  --bg-card:     #ffffff;
  --bg-hover:    #edf2fb;
  --border:      #d8e1f0;
  --border-light:#e9eef8;
  --text:        #1f2a44;
  --text-muted:  #637392;
  --text-dim:    #8a96ac;
  --accent:      #4c6fff;
  --accent-glow: rgba(76,111,255,0.16);
  --green:       #1f9d61;
  --green-dim:   rgba(31,157,97,0.14);
  --red:         #d6455d;
  --red-dim:     rgba(214,69,93,0.13);
  --yellow:      #b48118;
  --yellow-dim:  rgba(180,129,24,0.14);
  --purple:      #7a63d5;
  --cyan:        #299ab8;
  --orange:      #d9772f;
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --radius:      12px;
  --radius-sm:   6px;
  --shadow:      0 1px 2px rgba(31,42,68,0.04), 0 12px 30px rgba(76,111,255,0.07);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: linear-gradient(180deg, #f8faff 0%, var(--bg) 340px);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0.01em;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ── Layout ───────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ───────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,247,251,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon {
  font-size: 26px;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #ecf2ff 100%);
  border: 1px solid var(--border);
  box-shadow: 0 6px 14px rgba(76,111,255,0.08);
}
.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 1px; }

.header-nav { display: flex; gap: 4px; align-items: center; }
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-link.active {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(76,111,255,0.18);
}
.nav-external { border: 1px solid var(--border); margin-left: 8px; background: #fff; }

/* ── Hero stats ───────────────────────────────────────── */
.hero {
  padding: 40px 0 32px;
  background: linear-gradient(180deg, rgba(76,111,255,0.09) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 12px 25px rgba(76,111,255,0.1);
}
.stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 8px;
}
.stat-value.mono { font-size: 1.4rem; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }

#stat-regressions .stat-value { color: var(--green); }
#stat-regressions.has-regressions .stat-value { color: var(--red); }

/* ── Main content ─────────────────────────────────────── */
.main-content { padding: 40px 24px 80px; }
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
  position: relative;
  padding-bottom: 8px;
}
.section-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 56px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), rgba(76,111,255,0.2));
}

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.card-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }

/* ── Badges ───────────────────────────────────────────── */
.badge {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-live { background: var(--green-dim); color: var(--green); }
.badge-regression { background: var(--red-dim); color: var(--red); }
.badge-ok { background: var(--green-dim); color: var(--green); }

/* ── Regression alerts ────────────────────────────────── */
.regression-alerts {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.regression-alerts h3 { color: var(--red); font-size: 0.9rem; margin-bottom: 10px; }
.regression-alerts ul { padding-left: 18px; }
.regression-alerts li { font-size: 0.85rem; color: var(--text); margin-bottom: 4px; }

/* ── Category grid ────────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.cat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(76,111,255,0.08);
}
.cat-icon { font-size: 1.5rem; margin-bottom: 8px; }
.cat-name { font-weight: 600; font-size: 0.88rem; text-transform: capitalize; margin-bottom: 4px; }
.cat-count { font-size: 0.75rem; color: var(--text-muted); }
.cat-best { font-family: var(--mono); font-size: 0.8rem; color: var(--green); margin-top: 6px; }

/* ── Charts ───────────────────────────────────────────── */
.chart-card { }
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.tall { height: 420px; }

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar label { font-size: 0.82rem; color: var(--text-muted); }
.search-input, .select-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 14px;
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus, .select-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76,111,255,0.14);
}
.search-input { min-width: 220px; }
.select-input.wide { min-width: 280px; }

/* ── Filter chips ─────────────────────────────────────── */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: capitalize;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(76,111,255,0.25);
}

/* ── Benchmark table ──────────────────────────────────── */
.bench-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.bench-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.bench-table thead th {
  padding: 12px 16px;
  background: #f4f7fe;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.bench-table thead th.sortable { cursor: pointer; user-select: none; }
.bench-table thead th.sortable:hover { color: var(--text); }
.bench-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}
.bench-table tbody tr:hover { background: #f7f9ff; }
.bench-table tbody tr:last-child { border-bottom: none; }
.bench-table td { padding: 12px 16px; vertical-align: middle; }
.bench-name { font-family: var(--mono); font-weight: 500; color: var(--text); }
.bench-cat {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.bench-score { font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--text); }
.bench-unit { color: var(--text-muted); font-size: 0.75rem; }
.change-pos { color: var(--green); font-family: var(--mono); font-weight: 600; }
.change-neg { color: var(--red); font-family: var(--mono); font-weight: 600; }
.change-neutral { color: var(--text-muted); font-family: var(--mono); }

/* ── Sparkline canvas ─────────────────────────────────── */
.sparkline { display: inline-block; }

/* ── Trend stats ──────────────────────────────────────── */
.trend-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.trend-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.trend-stat-val { font-size: 1.5rem; font-weight: 700; font-family: var(--mono); color: var(--text); }
.trend-stat-lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Run history ──────────────────────────────────────── */
.runs-list { display: flex; flex-direction: column; gap: 12px; }
.run-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.run-item:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(76,111,255,0.08);
  transform: translateY(-1px);
}
.run-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.run-dot.error { background: var(--red); }
.run-meta { flex: 1; min-width: 0; }
.run-ref { font-family: var(--mono); font-weight: 600; font-size: 0.9rem; }
.run-sha { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }
.run-ts { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.run-type { padding: 2px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; background: var(--yellow-dim); color: var(--yellow); text-transform: uppercase; }
.run-count { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }

/* ── Footer ───────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.footer-updated { font-family: var(--mono); font-size: 0.75rem; }

/* ── Category colours ─────────────────────────────────── */
.cat-arithmetic { border-top: 3px solid var(--accent); }
.cat-bitwise    { border-top: 3px solid var(--purple); }
.cat-stack      { border-top: 3px solid var(--green); }
.cat-memory     { border-top: 3px solid var(--cyan); }
.cat-crypto     { border-top: 3px solid var(--orange); }
.cat-calls      { border-top: 3px solid var(--yellow); }
.cat-other      { border-top: 3px solid var(--text-muted); }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #eef3fc; }
::-webkit-scrollbar-thumb { background: #c7d3ea; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a7b6d4; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { height: auto; padding: 12px 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .toolbar { gap: 8px; }
  .chart-wrap { height: 240px; }
  .run-item { flex-wrap: wrap; gap: 10px; }
}

/* ── Loading skeleton ─────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  display: inline-block;
}
