:root {
  --bg: #0a0a0f;
  --bg-elev: #14141c;
  --bg-elev-2: #1c1c26;
  --border: #27272a;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --orange: #f97316;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent-2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand .logo {
  font-size: 22px;
  color: var(--accent);
}
.brand .name {
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
}
.brand .tag {
  color: var(--text-dim);
  font-size: 12px;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.status .dot {
  color: var(--green);
  animation: pulse 2s ease-in-out infinite;
}
.status .sep {
  color: var(--border);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.hero h1 {
  font-size: 28px;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.hero .sub {
  color: var(--text-muted);
  margin: 0 0 24px;
  max-width: 800px;
  font-size: 15px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi .lbl {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi .val {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.pane-head h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}
.controls select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.seg {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.seg.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent);
  color: var(--accent-2);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.lb-table th,
.lb-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.lb-table th {
  font-weight: 500;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-elev-2);
}
.lb-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.lb-table tbody tr:hover {
  background: var(--bg-elev-2);
}
.lb-table tbody tr:last-child td {
  border-bottom: 0;
}
.lb-table .num {
  font-family: var(--mono);
  text-align: right;
}
.lb-table .rank {
  color: var(--text-dim);
  font-family: var(--mono);
  width: 36px;
}
.lb-table .name strong {
  color: var(--text);
  font-weight: 600;
}
.velocity-up {
  color: var(--green);
}
.velocity-down {
  color: var(--text-dim);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-2);
  border: 1px solid rgba(139, 92, 246, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.q {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.3);
}
.badge.t {
  background: rgba(6, 182, 212, 0.12);
  color: var(--cyan);
  border-color: rgba(6, 182, 212, 0.3);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: rgba(139, 92, 246, 0.4);
}
.card-title {
  font-weight: 600;
  font-size: 13px;
  word-break: break-all;
  line-height: 1.35;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.card-stats {
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}
.card-stats .icn {
  color: var(--text-dim);
  margin-right: 3px;
}
.card-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.card-link {
  margin-top: auto;
  font-size: 12px;
}

.chart-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal[aria-hidden='false'] {
  display: flex;
}
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 1000px;
  width: 100%;
  padding: 28px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text);
}
.modal h2 {
  margin: 0 0 4px;
  font-size: 22px;
}
.modal .sub-meta {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 32px 16px 16px;
}

.empty {
  color: var(--text-dim);
  text-align: center;
  padding: 60px 16px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .container {
    padding: 20px 16px 48px;
  }
  .hero h1 {
    font-size: 22px;
  }
}
