body.stats-page {
  --st-border: rgba(248, 197, 149, 0.2);
  --st-border-soft: rgba(248, 210, 176, 0.14);
  --st-bg-1: rgba(11, 5, 4, 0.74);
  --st-bg-2: rgba(7, 3, 2, 0.7);
  --st-soft: rgba(240, 220, 198, 0.84);
}

body.stats-page .stats-main {
  padding-top: 20px;
  padding-bottom: 26px;
  width: min(1920px, calc(100% - 26px));
}

body.stats-page .card {
  border-radius: 16px;
  border: 1px solid var(--st-border-soft);
  background:
    linear-gradient(164deg, rgba(255, 132, 48, 0.04), rgba(0, 0, 0, 0.25) 40%, rgba(0, 0, 0, 0.3)),
    var(--st-bg-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 221, 190, 0.11),
    0 12px 28px rgba(0, 0, 0, 0.27);
}

body.stats-page .card h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.stats-page .status-line {
  margin-top: 8px;
}

body.stats-page .title-with-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

body.stats-page .timeline-select {
  width: 150px;
  flex: 0 0 auto;
}

body.stats-page .stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  grid-auto-flow: row;
  margin-top: 16px;
}

body.stats-page .card-full {
  grid-column: 1 / -1;
}

body.stats-page .card-span2 {
  grid-column: span 2;
  min-width: 500px;
}

body.stats-page .card-table {
  overflow: auto;
  max-height: 380px;
  border-radius: 10px;
  border: 1px solid var(--st-border);
  width: 100%;
  display: block;
  background: rgba(0, 0, 0, 0.24);
  position: relative;
  isolation: isolate;
}

/* Leaderboard: afficher ~10 lignes avant scroll */
body.stats-page #players-table-wrap {
  max-height: 520px;
}

body.stats-page .stat-table {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: #eee7de;
  table-layout: fixed;
}

body.stats-page .stat-table th,
body.stats-page .stat-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 223, 195, 0.1);
}

body.stats-page .stat-table th {
  text-align: left;
  background-color: #1a0f0b;
  background-image: linear-gradient(135deg, #2a1912, #1a0f0b 65%);
  color: #f9f0e7;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 0 rgba(255, 223, 195, 0.2);
}

body.stats-page .stat-table td {
  background: rgba(255, 255, 255, 0.01);
  position: relative;
  z-index: 1;
}

body.stats-page .stat-table tr:nth-child(even) td {
  background: rgba(255, 189, 134, 0.04);
}

body.stats-page .stat-table tr:hover td {
  background: rgba(255, 171, 94, 0.08);
}

body.stats-page .stat-table th.sortable {
  cursor: pointer;
}

body.stats-page .stat-table th.sortable:hover {
  background: linear-gradient(135deg, rgba(255, 205, 156, 0.28), rgba(20, 13, 10, 0.95));
}

body.stats-page .filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 14px;
}

body.stats-page .filter-row .lt-label {
  min-width: 180px;
}

body.stats-page .filter-row .stats-inline-check {
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 2px 2px;
}

body.stats-page .lt-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--st-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #f0e7de;
  line-height: 1.3;
}

body.stats-page .lt-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: #d89a55;
  flex: 0 0 auto;
}

body.stats-page .lt-checkbox span {
  display: inline-block;
  color: #e8d8ca;
}

body.stats-page .filter-row input,
body.stats-page .filter-row select {
  width: 100%;
}

body.stats-page .filter-row .btn {
  align-self: flex-end;
  min-width: 124px;
}

body.stats-page .small-hint {
  font-size: 12px;
  color: #b4c0cf;
  margin-top: -6px;
}

body.stats-page .chart-box {
  height: 360px;
}

body.stats-page .chart-box canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

body.stats-page .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12px;
}

body.stats-page .tag.low {
  background: rgba(30, 255, 0, 0.12);
  color: #1eff00;
}

body.stats-page .tag.mid {
  background: rgba(255, 255, 255, 0.1);
  color: #e6e9f0;
}

body.stats-page .tag.high {
  background: rgba(255, 64, 64, 0.12);
  color: #ff5c5c;
}

body.stats-page .tag.warn {
  background: rgba(255, 128, 0, 0.12);
  color: #ffae42;
}

/* Présence par jour */
body.stats-page #tbl-attendance th:nth-child(1),
body.stats-page #tbl-attendance td:nth-child(1) {
  width: 110px;
}

body.stats-page #tbl-attendance th:nth-child(2),
body.stats-page #tbl-attendance td:nth-child(2) {
  min-width: 240px;
}

body.stats-page #tbl-attendance th:nth-child(3),
body.stats-page #tbl-attendance td:nth-child(3) {
  width: 70px;
}

body.stats-page #tbl-attendance th:nth-child(4),
body.stats-page #tbl-attendance td:nth-child(4) {
  width: 70px;
}

@media (max-width: 900px) {
  body.stats-page .stats-main {
    width: calc(100% - 14px);
  }

  body.stats-page .card-full {
    grid-column: 1 / -1;
  }

  body.stats-page .card-span2 {
    grid-column: 1 / -1;
    min-width: auto;
  }

  body.stats-page .filter-row .stats-inline-check {
    min-width: 100%;
  }
}
