:root {
  --bg: #0a0a0a;
  --bg-elev: #121214;
  --bg-elev-2: #1a1a1f;
  --fg: #e6e6ec;
  --muted: #8a8a95;
  --accent: #00ff9f;
  --accent-dim: #00cc7f;
  --warn: #ffcc4d;
  --danger: #ff5470;
  --border: #2a2a32;
  --score-green: #00e88f;
  --score-yellow: #ffcc4d;
  --score-red: #ff5470;
  --code-font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ui-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--ui-font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px; flex: 1; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(10,10,10,0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { color: var(--accent); font-size: 22px; font-weight: 700; }
.brand-name { font-weight: 700; letter-spacing: 0.5px; font-family: var(--code-font); }
.tagline { color: var(--muted); font-size: 13px; }
.nav { display: flex; gap: 18px; }
.nav a {
  color: var(--fg); padding: 6px 10px; border-radius: 6px;
  font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--bg-elev); text-decoration: none; }
.nav a.active { color: var(--accent); background: rgba(0,255,159,0.06); }

/* Hero */
.hero { margin-bottom: 28px; }
.hero h1 { font-size: 30px; line-height: 1.15; margin: 0 0 8px; }
.hero .lede { color: var(--muted); max-width: 760px; margin: 0; }
.hero .scan-meta { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* Controls */
.controls {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 18px;
}
.controls input[type="text"] {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; min-width: 220px;
  font-family: var(--ui-font); outline: none;
}
.controls input[type="text"]:focus { border-color: var(--accent); }
.controls select {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg);
  padding: 8px 12px; border-radius: 8px; font-size: 14px;
  font-family: var(--ui-font); cursor: pointer; outline: none;
}
.controls select:focus { border-color: var(--accent); }
.controls label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.controls input[type="range"] { width: 100px; accent-color: var(--accent); }
.min-score-val { color: var(--accent); font-weight: 600; font-family: var(--code-font); font-size: 13px; }

/* Table */
.lb-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.lb-table thead th {
  text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border);
  color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.5px; cursor: pointer; user-select: none; white-space: nowrap;
}
.lb-table thead th:hover { color: var(--fg); }
.lb-table thead th.sorted { color: var(--accent); }
.lb-table thead th .sort-arrow { font-size: 10px; margin-left: 4px; }
.lb-table tbody tr {
  border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s;
}
.lb-table tbody tr:hover { background: var(--bg-elev); }
.lb-table tbody td { padding: 10px 12px; }
.lb-table .rank { color: var(--muted); font-family: var(--code-font); width: 40px; }
.lb-table .tool-name { font-weight: 600; }
.lb-table .tool-desc { color: var(--muted); font-size: 12px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-table .source-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px;
  font-weight: 600; font-family: var(--code-font); text-transform: uppercase;
}
.source-npm { background: rgba(203,56,55,0.15); color: #ff6b6b; }
.source-brew { background: rgba(255,183,77,0.15); color: #ffcc4d; }
.source-pypi { background: rgba(0,133,202,0.15); color: #5bb8f5; }

/* Score badges */
.score-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; padding: 3px 8px; border-radius: 6px;
  font-weight: 700; font-family: var(--code-font); font-size: 13px;
  text-align: center;
}
.score-green { background: rgba(0,232,143,0.12); color: var(--score-green); }
.score-yellow { background: rgba(255,204,77,0.12); color: var(--score-yellow); }
.score-red { background: rgba(255,84,112,0.12); color: var(--score-red); }

.grade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 32px; border-radius: 8px;
  font-weight: 800; font-family: var(--code-font); font-size: 15px;
}
.grade-a { background: rgba(0,232,143,0.15); color: var(--score-green); }
.grade-b { background: rgba(0,180,216,0.15); color: #5bb8f5; }
.grade-c { background: rgba(255,204,77,0.15); color: var(--score-yellow); }
.grade-d { background: rgba(255,152,0,0.15); color: #ff9800; }
.grade-f { background: rgba(255,84,112,0.15); color: var(--score-red); }

/* Mini score */
.mini-score { font-family: var(--code-font); font-size: 12px; font-weight: 500; }

/* Pagination */
.pagination {
  display: flex; justify-content: center; gap: 8px; margin-top: 20px;
}
.pagination button {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--fg);
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
  font-family: var(--ui-font);
}
.pagination button:hover { border-color: var(--accent); }
.pagination button.active { background: rgba(0,255,159,0.1); border-color: var(--accent); color: var(--accent); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Detail view */
.detail-back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.detail-back:hover { color: var(--fg); text-decoration: none; }

.detail-header {
  display: flex; align-items: flex-start; gap: 24px; margin-bottom: 32px;
}
.detail-grade-big {
  width: 80px; height: 80px; border-radius: 16px; display: flex;
  align-items: center; justify-content: center; font-size: 36px;
  font-weight: 900; font-family: var(--code-font); flex-shrink: 0;
}
.detail-info h1 { margin: 0 0 4px; font-size: 28px; }
.detail-info .detail-meta { color: var(--muted); font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; }
.detail-info .detail-meta a { color: var(--accent); }
.detail-total { font-size: 22px; font-weight: 700; font-family: var(--code-font); margin-top: 8px; }

/* Axis cards */
.axes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.axis-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; position: relative;
}
.axis-card .axis-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.axis-card .axis-name { font-weight: 600; font-size: 15px; }
.axis-card .axis-bar-track {
  width: 100%; height: 8px; background: var(--bg-elev-2); border-radius: 4px; overflow: hidden;
  margin-bottom: 10px;
}
.axis-card .axis-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.axis-card .evidence {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  background: var(--bg-elev-2); padding: 10px 12px; border-radius: 8px; margin-top: 8px;
}
.axis-card .fix-hint {
  font-size: 12px; color: var(--warn); margin-top: 8px;
  padding: 8px 12px; background: rgba(255,204,77,0.06); border-radius: 8px;
}

.share-btn {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--accent);
  padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 14px;
  font-weight: 600; font-family: var(--ui-font); transition: all 0.15s;
}
.share-btn:hover { background: rgba(0,255,159,0.08); border-color: var(--accent); }

/* Stats page */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; text-align: center;
}
.stat-card .stat-value {
  font-size: 36px; font-weight: 800; font-family: var(--code-font);
  color: var(--accent); margin-bottom: 4px;
}
.stat-card .stat-label { color: var(--muted); font-size: 13px; }

.dist-chart { margin-bottom: 32px; }
.dist-chart h3 { margin: 0 0 16px; font-size: 18px; }
.dist-bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; }
.dist-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.dist-bar {
  width: 100%; max-width: 60px; border-radius: 6px 6px 0 0;
  transition: height 0.4s ease; min-height: 4px;
}
.dist-bar-label { font-size: 12px; font-weight: 600; margin-top: 6px; font-family: var(--code-font); }
.dist-bar-count { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-family: var(--code-font); }

.worst-axis-card {
  background: rgba(255,84,112,0.06); border: 1px solid rgba(255,84,112,0.2);
  border-radius: 12px; padding: 20px; margin-bottom: 24px;
}
.worst-axis-card h3 { margin: 0 0 8px; color: var(--danger); font-size: 16px; }
.worst-axis-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* Loading */
.loading {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.spinner {
  display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h3 { color: var(--fg); margin-bottom: 8px; }

/* Footer */
.footer {
  padding: 20px 24px; border-top: 1px solid var(--border);
  text-align: center; color: var(--muted); font-size: 13px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }

/* Responsive */
@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 8px; text-align: center; }
  .controls { flex-direction: column; }
  .controls input[type="text"] { min-width: unset; width: 100%; }
  .detail-header { flex-direction: column; align-items: center; text-align: center; }
  .axes-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .lb-table { font-size: 12px; }
  .lb-table thead th, .lb-table tbody td { padding: 8px 6px; }
  .lb-table .tool-desc { display: none; }
}
