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

:root {
  --bg:       #080c14;
  --surface:  #0f1624;
  --surface2: #161e30;
  --border:   rgba(99,179,237,0.12);
  --accent:   #38bdf8;
  --accent2:  #818cf8;
  --accent3:  #34d399;
  --text:     #e2e8f0;
  --text-dim: #64748b;
  --text-mid: #94a3b8;
  --glow:     rgba(56,189,248,0.15);
  --font-head: 'Syne', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-head);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ───────── BACKGROUND GRID ───────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(56,189,248,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56,189,248,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
body > *:not(.bg-grid) { position: relative; z-index: 1; }

/* ───────── HEADER ───────── */
.header {
  padding: 2rem 2.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(56,189,248,0.06) 0%, transparent 100%);
}
.header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
}
.logo { display: flex; align-items: center; gap: 1rem; }
.logo-icon {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  color: var(--accent);
  background: rgba(56,189,248,0.1);
  border: 1px solid rgba(56,189,248,0.3);
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
}
h1 {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.subtitle { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }
.header-meta { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.badge {
  font-family: var(--font-mono); font-size: 0.7rem;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-mid);
}

/* ───────── STATS BAR ───────── */
.stats-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 0; flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.1rem 2.5rem;
  transition: background 0.2s;
}
.stat-item:hover { background: rgba(56,189,248,0.04); }
.stat-number {
  font-size: 1.4rem; font-weight: 800; color: var(--accent);
  font-family: var(--font-mono);
}
.stat-label { font-size: 0.7rem; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

/* ───────── MAIN ───────── */
.main {
  max-width: 1400px; margin: 0 auto;
  padding: 2rem 2rem 3rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}

/* ───────── CONTROLS ───────── */
.controls-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}
.chart-tabs { display: flex; gap: 0.4rem; }
.tab-btn {
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0.5rem 1.1rem; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer;
  transition: all 0.2s;
}
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active {
  background: rgba(56,189,248,0.12);
  border-color: var(--accent); color: var(--accent);
}
.filter-group {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim);
}
.filter-group select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0.45rem 0.8rem; border-radius: 8px; cursor: pointer;
  outline: none; transition: border-color 0.2s;
}
.filter-group select:focus { border-color: var(--accent); }

/* ───────── CARDS ───────── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  transition: box-shadow 0.3s;
}
.chart-card:hover {
  box-shadow: 0 0 0 1px rgba(56,189,248,0.15), 0 20px 60px rgba(0,0,0,0.4);
}
.main-chart-card { padding: 2rem; }
.card-header {
  display: flex; align-items: baseline;
  justify-content: space-between; flex-wrap: wrap;
  gap: 0.5rem; margin-bottom: 1.5rem;
}
.card-header h2 { font-size: 1rem; font-weight: 700; color: var(--text); }
.card-tag {
  font-family: var(--font-mono); font-size: 0.68rem;
  color: var(--accent2); letter-spacing: 0.05em;
}
.chart-wrap { position: relative; width: 100%; }
.small-chart { height: 260px; }

/* ───────── BOTTOM GRID ───────── */
.bottom-grid {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 1.5rem;
}
@media (max-width: 900px) { .bottom-grid { grid-template-columns: 1fr; } }

/* ───────── RANK TABLE ───────── */
.rank-table { display: flex; flex-direction: column; gap: 0.5rem; }
.rank-row {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.55rem 0.7rem; border-radius: 8px;
  transition: background 0.15s; cursor: default;
}
.rank-row:hover { background: rgba(56,189,248,0.05); }
.rank-num {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-dim); width: 1.4rem; text-align: right; flex-shrink: 0;
}
.rank-lang {
  font-weight: 600; font-size: 0.88rem; flex: 1; color: var(--text);
  text-transform: capitalize;
}
.rank-bar-wrap {
  flex: 2; height: 6px; background: rgba(255,255,255,0.06); border-radius: 999px; overflow: hidden;
}
.rank-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.8s cubic-bezier(.16,1,.3,1);
}
.rank-score {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--text-mid); width: 3.5rem; text-align: right; flex-shrink: 0;
}
.rank-trend {
  font-family: var(--font-mono); font-size: 0.7rem; width: 2.5rem; text-align: right; flex-shrink: 0;
}
.trend-up   { color: var(--accent3); }
.trend-down { color: #f87171; }
.trend-flat { color: var(--text-dim); }

/* ───────── FOOTER ───────── */
.footer {
  text-align: center; padding: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem; color: var(--text-dim);
  line-height: 1.8;
  background: var(--surface);
}
.footer strong { color: var(--text-mid); }
.mono { font-family: var(--font-mono); color: var(--accent); }

/* ───────── ANIMATIONS ───────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chart-card { animation: fadeUp 0.5s ease both; }
.main-chart-card { animation-delay: 0.05s; }
.bottom-grid > :nth-child(1) { animation-delay: 0.15s; }
.bottom-grid > :nth-child(2) { animation-delay: 0.25s; }

/* ───────── SCROLLBAR ───────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
