body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Montserrat', sans-serif;
  margin: 0;
}

[hidden] { display: none !important; }

/* Layout */
.stats-container {
  max-width: 1100px;
  margin: 100px auto 120px;
  padding: 0 16px;
}

.stats-hero {
  text-align: center;
  margin-bottom: 28px;
}

.stats-title {
  font-size: 2.75rem;
  margin: 0 0 12px;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff 30%, #b9a6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stats-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-weight: 300;
  font-size: 1.05rem;
}

/* Range */
.stats-range {
  display: flex;
  width: fit-content;
  margin: 0 auto 32px;
  padding: 4px;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
}

.stats-range button {
  padding: 8px 22px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.stats-range button:hover { color: var(--text-primary); }

.stats-range button.active {
  background: var(--accent-discord);
  color: #fff;
}

/* State */
.stats-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.stats-body { transition: opacity 0.25s ease; }
.stats-body.loading { opacity: 0.45; }

/* Summary */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stats-tile {
  transition: border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 22px;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
}

.stats-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stats-value {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stats-change {
  font-size: 0.85rem;
  font-weight: 600;
  color: #57d39b;
}

.stats-change.down { color: #ff7a7a; }
.stats-change.muted { color: var(--text-muted); font-weight: 400; }

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.stats-card {
  padding: 20px 22px 18px;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  min-width: 0;
}

.stats-card.wide { grid-column: 1 / -1; }

.stats-card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
}

/* Chart */
.stats-chart {
  position: relative;
  height: 200px;
}

.stats-card.wide .stats-chart { height: 240px; }

.stats-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.stats-chart svg { transition: opacity 0.4s ease; }

.stats-chart .grid line { stroke: rgba(255, 255, 255, 0.06); }

.stats-chart .axis text {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: 'Montserrat', sans-serif;
}

.stats-chart .line {
  fill: none;
  stroke: var(--accent-discord);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.stats-chart .bar {
  fill: var(--accent-discord);
  opacity: 0.85;
  transition: fill 0.25s ease, opacity 0.25s ease;
}

.stats-chart.hovering .bar { opacity: 0.45; }
.stats-chart.hovering .bar.hover { opacity: 1; fill: #7b86ff; }

.stats-cross,
.stats-dot,
.stats-tip {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.22s cubic-bezier(.25, .8, .25, 1), opacity 0.2s ease;
}

.stats-chart.hovering .stats-cross,
.stats-chart.hovering .stats-dot,
.stats-chart.hovering .stats-tip { opacity: 1; }

.stats-cross {
  width: 1px;
  margin-left: -0.5px;
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.25) 30%, rgba(255, 255, 255, 0.25));
}

.stats-card.wide .stats-cross { display: none; }

.stats-dot {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-discord);
  box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.2);
  box-sizing: border-box;
}

.stats-tip {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(11, 13, 19, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.stats-tip span { color: var(--text-muted); }
.stats-tip b { font-variant-numeric: tabular-nums; }

.stats-chart > .stats-empty {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.stats-chart.is-empty > .stats-empty { opacity: 1; }

.stats-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Top */
.stats-top {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-top li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.92rem;
}

.stats-top .rank {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.stats-top .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-top .count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats-top .track {
  grid-column: 2 / -1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.stats-top .fill {
  height: 100%;
  transition: width 0.7s cubic-bezier(.25, .8, .25, 1);
  background: linear-gradient(90deg, var(--accent-discord), #9b8cff);
  border-radius: 3px;
}

.stats-top .stats-empty { height: 120px; }

/* Responsive */
@media (max-width: 760px) {
  .stats-container { margin-top: 90px; }
  .stats-title { font-size: 2.1rem; }
  .stats-summary { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-value { font-size: 1.7rem; }
  .stats-chart, .stats-card.wide .stats-chart { height: 200px; }
}