/* Statistics view */

#view-stats {
  max-width: 1300px;
  margin: 0 auto;
}

#stats-summary { color: var(--text-secondary); }

.stats-host { display: flex; flex-direction: column; gap: 22px; }
.stats-loading,
.stats-error {
  padding: 60px 12px;
  text-align: center;
  color: var(--text-secondary);
}
.stats-error { color: #b94a48; }

.stat-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 18px 18px;
}
.stat-section-title {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--text-primary);
}
.stat-section-subtitle {
  margin: -6px 0 12px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Tile grid for headline numbers */
.stat-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat-tile {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.stat-tile-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.stat-tile-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Progress bars (completeness, precision) */
.stat-bars { display: flex; flex-direction: column; gap: 6px; }
.stat-bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 120px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.stat-bar-label { color: var(--text-primary); }
.stat-bar-track {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.stat-bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
}
.stat-bar-val { color: var(--text-muted); text-align: right; }

/* Chart card grid */
.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
.stat-chart-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px 12px;
  min-height: 100px;
}
.stat-chart-card.stat-wide { grid-column: 1 / -1; }
.stat-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.stat-svg {
  width: 100%;
  height: auto;
  display: block;
  font-size: 10px;
}

/* D3 axis styling */
.stat-axis path,
.stat-axis line { stroke: var(--border-color); }
.stat-axis text { fill: var(--text-muted); font-size: 10px; }

.stat-bar { fill: var(--accent); }
.stat-bar:hover { fill: var(--accent); filter: brightness(1.1); }

.stat-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2px;
}
.stat-dot { fill: var(--accent); }

.stat-hbar-label { fill: var(--text-primary); font-size: 11px; }
.stat-hbar-val   { fill: var(--text-muted);   font-size: 11px; }
.stat-empty-svg  { fill: var(--text-muted);   font-size: 12px; }

/* Mini-leaderboard grid for given names */
.stat-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.stat-mini-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
}
.stat-mini-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
  font-size: 13px;
}
.stat-mini-list,
.stat-list {
  list-style: decimal inside;
  margin: 0;
  padding: 0;
  font-size: 13px;
}
.stat-mini-list li,
.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px dashed var(--border-color);
}
.stat-mini-list li:last-child,
.stat-list li:last-child { border-bottom: 0; }
.stat-mini-c {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.stat-empty { color: var(--text-muted); font-style: italic; }
.stat-list-wrap { margin-top: 4px; }

.stat-link {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  text-align: left;
  font-size: inherit;
}
.stat-link:hover { text-decoration: underline; }

.stat-big-pct {
  font-size: 42px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-top: 6px;
}
.stat-big-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 680px) {
  .stat-bar-row {
    grid-template-columns: 110px 1fr 90px;
    font-size: 12px;
  }
  .stat-card-grid {
    grid-template-columns: 1fr;
  }
}
