#stats-main {
  padding: 20px 16px 40px;
  width: 100%;
  max-width: 900px;
  min-width: 0;
  margin: 0 auto;
  box-sizing: border-box;
}

#stats-main h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin: 26px 0 10px;
}

/* --- Carte globale --- */

.overall-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.overall-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

#stats-main .overall-title {
  margin: 0 0 4px;
}

.overall-count {
  font-size: 14px;
  color: var(--text-muted);
}

.overall-pct {
  font-size: 40px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* --- Barres --- */

.stat-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .3s ease;
}

.stat-bar-fill--shiny {
  background: var(--shiny);
}

.stat-bar-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-bar-line-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-bar-line-count {
  font-variant-numeric: tabular-nums;
}

/* --- Bascule Résumé / Tableau --- */

.stats-view-toggle {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

/* --- Tuiles --- */

.stat-group-hint {
  margin: -6px 0 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}

button.stat-tile {
  cursor: pointer;
}

button.stat-tile:hover {
  border-color: var(--border-strong);
}

button.stat-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-tile.is-complete {
  border-color: var(--owned);
}

.stat-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.stat-tile-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-tile-chevron {
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
}

.stat-tile-pct {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-tile.is-complete .stat-tile-pct {
  color: var(--owned);
}

.stat-tile-count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-bottom: 8px;
}

.stat-tile-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: auto;
}

.stat-tile-bars .stat-bar {
  height: 5px;
  border: 0;
}

/* --- Fiche détail par région --- */

.detail-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.region-row {
  display: grid;
  grid-template-columns: 76px 1fr 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.region-row--single {
  grid-template-columns: 76px 1fr;
}

.region-row--head {
  border-top: 0;
  padding-top: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}

#detail-sheet-rows:has(.region-row--single) .region-row--head {
  grid-template-columns: 76px 1fr;
}

.region-row-name {
  font-size: 13px;
  font-weight: 600;
}

.region-cell-top {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

.region-cell-count {
  font-size: 11px;
  color: var(--text-faint);
}

.region-cell .stat-bar {
  height: 5px;
  border: 0;
}

/* --- Tableau heatmap --- */

.table-toolbar {
  display: flex;
  justify-content: center;
  margin: 18px 0 12px;
}

.heatmap-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.heatmap {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.heatmap th {
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 4px;
  white-space: nowrap;
}

.heatmap thead th {
  font-size: 11px;
}

.heatmap-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  color: var(--text);
}

.heatmap-corner {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
}

.heatmap-cell {
  min-width: 34px;
  height: 30px;
  text-align: center;
  border-radius: 6px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) calc(var(--heat, 0%) * .7), var(--surface-alt));
}

.heatmap-cell.is-complete {
  background: var(--owned);
  color: #0b2418;
  font-weight: 700;
}

.heatmap-cell.is-empty {
  background: transparent;
  color: var(--text-faint);
}

.heatmap-cell.heatmap-total {
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.heatmap-legend {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}
