/* DataRugby — feuille de style */
:root {
  --bg: #0b0e14;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #18202f 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 0%, #161a26 0%, transparent 55%);
  --panel: #141925;
  --panel-2: #1a2030;
  --panel-3: #212a3d;
  --border: #283142;
  --border-soft: #1e2533;
  --text: #e8eef7;
  --muted: #8a96ab;
  --muted-2: #5f6b80;
  --accent: #d4002a;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --good: #2ec27e;
  --bad: #f0506e;
  --warn: #f5a524;
  --gold: #f7c948;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 100px; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}
a { color: inherit; }
::selection { background: var(--accent-soft); }
.sp { height: 22px; }

/* ---------- En-tête ---------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; text-decoration: none; }
.brand .ball { font-size: 30px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.5)); }
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -.3px; font-weight: 800; }
.brand .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* navigation entre pages */
.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  font-size: 14px; color: var(--muted); text-decoration: none; padding: 8px 15px;
  border-radius: 999px; font-weight: 600; white-space: nowrap; transition: .15s;
}
.topnav a:hover { color: var(--text); background: var(--panel); }
.topnav a.active {
  color: var(--text); background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* sélecteur de championnat */
.switch { display: inline-flex; background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px; gap: 4px; }
.switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 8px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
  transition: .18s; letter-spacing: .2px; display: flex; align-items: center; gap: 8px;
}
.switch button .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .55; }
.switch button.active { color: #fff; box-shadow: var(--shadow); }
.switch button.active.top14 { background: linear-gradient(135deg, #e11d3a, #9c0020); }
.switch button.active.prod2 { background: linear-gradient(135deg, #12a155, #0a6b39); }
.switch button.active .dot { opacity: 1; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 30px 22px 80px; }
section { margin-top: 46px; }
section:first-of-type { margin-top: 0; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.section-head h2 { font-size: 22px; margin: 0; letter-spacing: -.4px; font-weight: 800; }
.section-head h2::before {
  content: ""; display: inline-block; width: 4px; height: 19px; border-radius: 3px;
  background: var(--accent); margin-right: 12px; vertical-align: -2px;
}
.section-head .hint { color: var(--muted); font-size: 13px; }

/* ---------- Bandeau d'intro de championnat ---------- */
.league-hero {
  display: flex; align-items: center; gap: 18px; padding: 22px 26px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background:
    linear-gradient(120deg, var(--accent-soft), transparent 55%),
    var(--panel);
  box-shadow: var(--shadow); margin-bottom: 26px;
}
.league-hero .badge {
  width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center;
  font-size: 30px; background: color-mix(in srgb, var(--accent) 22%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.league-hero h2 { margin: 0; font-size: 26px; letter-spacing: -.6px; }
.league-hero p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.league-hero .meta-pill {
  margin-left: auto; text-align: right; font-size: 12px; color: var(--muted);
}
.league-hero .meta-pill a { color: color-mix(in srgb, var(--accent) 70%, var(--text)); text-decoration: none; font-weight: 600; }

/* ---------- Cartes KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 16px 15px; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent); opacity: .85; }
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.kpi .main { display: flex; align-items: center; gap: 11px; margin-top: 11px; }
.kpi .main img, .kpi .main .mono-badge { width: 40px; height: 40px; object-fit: contain; flex: none; }
.kpi .val { font-size: 18px; font-weight: 800; letter-spacing: -.3px; line-height: 1.15; }
.kpi .val small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }

/* ---------- Tables ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: right; padding: 13px 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted); font-weight: 700; background: var(--panel-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
thead th.left { text-align: left; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th .arr { opacity: .4; font-size: 9px; margin-left: 3px; }
thead th.sorted .arr { opacity: 1; color: var(--accent); }
thead th small { font-weight: 500; opacity: .7; font-size: 9.5px; }
tbody td { padding: 11px 10px; text-align: right; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
td.left, th.left { text-align: left; }
.club-cell { display: flex; align-items: center; gap: 11px; min-width: 175px; }
.club-cell img, .club-cell .mono-badge { width: 26px; height: 26px; object-fit: contain; flex: none; }
.club-cell .nm { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.pts-strong { font-weight: 800; font-size: 15px; }
.pos { color: var(--good); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }
td.nm, .nm { font-weight: 600; }

/* rang + zone */
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  font-weight: 800; font-size: 13px; background: var(--panel-3); }
tr.zone-champ td:first-child .rank { background: linear-gradient(135deg, var(--gold), #c79100); color: #2a2000; }
tr.zone-phase td:first-child .rank { background: color-mix(in srgb, var(--good) 30%, var(--panel-3)); color: #d7ffe9; }
tr.zone-barrage td:first-child .rank { background: color-mix(in srgb, var(--warn) 32%, var(--panel-3)); color: #fff0d4; }
tr.zone-releg td:first-child .rank { background: color-mix(in srgb, var(--bad) 36%, var(--panel-3)); color: #ffe2e8; }
tr.zone-champ { box-shadow: inset 3px 0 0 var(--gold); }
tr.zone-phase { box-shadow: inset 3px 0 0 var(--good); }
tr.zone-barrage { box-shadow: inset 3px 0 0 var(--warn); }
tr.zone-releg { box-shadow: inset 3px 0 0 var(--bad); }

/* mini-barre dans une cellule */
.bar-cell { position: relative; min-width: 120px; }
.bar { height: 7px; border-radius: 4px; background: var(--accent); opacity: .85; }
.bar-track { background: var(--panel-3); border-radius: 4px; overflow: hidden; }

/* légende de zones */
.legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 16px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border-soft); background: var(--panel-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Graphiques ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px 14px; box-shadow: var(--shadow); }
.chart-card h3 { margin: 0 0 2px; font-size: 15px; }
.chart-card .csub { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.chart-card svg { width: 100%; height: auto; display: block; overflow: visible; }
.axis-label { fill: var(--muted-2); font-size: 10px; }
.grid-line { stroke: var(--border-soft); stroke-width: 1; }
.median-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; }
.bar-val { fill: var(--text); font-size: 10px; font-weight: 700; }

/* ---------- Cartes clubs ---------- */
.club-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.club-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: .18s; }
.club-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); }
.club-card .top { display: flex; align-items: center; gap: 12px; }
.club-card .top img, .club-card .top .mono-badge { width: 44px; height: 44px; object-fit: contain; flex: none; }
.club-card .top .nm { font-weight: 700; font-size: 15px; line-height: 1.2; }
.club-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 12.5px; }
.club-card dt { color: var(--muted); }
.club-card dd { margin: 0; text-align: right; font-weight: 600; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: color-mix(in srgb, var(--accent) 75%, var(--text)); letter-spacing: .3px; }

/* monogramme de secours (logo manquant) */
.mono-badge { border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  background: var(--panel-3); color: var(--muted); }

/* ---------- Arbitres ---------- */
.ref-intro { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; max-width: 780px; }
.ref-intro b { color: var(--text); }
.sub-h { font-size: 16px; margin: 26px 0 12px; font-weight: 700; letter-spacing: -.2px; }
.sub-h::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 9px; vertical-align: 2px; }
.ref-note { color: var(--muted-2); font-size: 12px; margin: 0 0 12px; max-width: 820px; line-height: 1.5; }
.ref-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }
.team-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 14px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; min-width: 220px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a96ab' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.team-select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.team-select:focus { outline: 2px solid var(--accent-soft); }
.team-ref-head { display: flex; align-items: center; gap: 4px; padding: 4px 2px 2px; }
.team-ref-head .nm { font-weight: 700; }
.winbar { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.winbar .num { min-width: 36px; text-align: right; font-weight: 700; }
.winbar .bar-track { flex: 1; }
.bar-card { background: var(--warn); }
.vnd { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.vnd b { font-weight: 800; }
.vnd .pos { color: var(--good); }
.vnd .neg { color: var(--bad); }
.vnd .zer { color: var(--muted); }
.muted-cell { color: var(--muted-2); }
.loc-m { color: var(--muted-2); font-weight: 500; font-size: 11px; margin-left: 3px; }
.poste { font-size: 11px; color: var(--muted); }

/* ---------- Sélecteur de saison ---------- */
.season-wrap { display: flex; align-items: center; }
.season-select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 30px 8px 14px; font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; appearance: none; letter-spacing: .2px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238a96ab' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.season-select:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.season-select:focus { outline: 2px solid var(--accent-soft); }

/* ---------- État de chargement ---------- */
.loading { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 15px; }
.loading.err { color: var(--bad); }
.hero-season { font-size: 14px; font-weight: 700; color: var(--muted); vertical-align: middle;
  background: var(--panel-2); border: 1px solid var(--border); padding: 2px 10px; border-radius: 999px; margin-left: 6px; }

/* ---------- Détail arbitre ---------- */
.ref-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; cursor: pointer;
  color: color-mix(in srgb, var(--accent) 78%, var(--text)); text-align: left; }
.ref-link:hover { text-decoration: underline; }
.ref-detail:not(:empty) { margin-top: 22px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius); padding: 18px 18px 8px; background: color-mix(in srgb, var(--accent-soft) 40%, var(--panel)); }
.ref-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ref-detail-head .sub-h { margin: 0; }
.ref-close { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); cursor: pointer;
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 600; }
.ref-close:hover { color: var(--text); border-color: var(--accent); }

.match-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
details.match { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
details.match > summary { list-style: none; cursor: pointer; display: grid;
  grid-template-columns: 42px 1fr auto 1fr; align-items: center; gap: 10px; padding: 11px 14px; }
details.match > summary::-webkit-details-marker { display: none; }
details.match > summary:hover { background: var(--panel-2); }
details.match[open] > summary { background: var(--panel-2); border-bottom: 1px solid var(--border-soft); }
.match-j { font-size: 12px; font-weight: 800; color: var(--muted); }
.match-team { display: flex; align-items: center; gap: 9px; min-width: 0; }
.match-team img, .match-team .mono-badge { width: 24px; height: 24px; object-fit: contain; flex: none; }
.match-team .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-team.away { justify-content: flex-end; }
.match-team.win .nm { color: var(--text); }
.match-team:not(.win) .nm { color: var(--muted); }
.match-score { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px; white-space: nowrap; }
.match-score i { color: var(--muted-2); margin: 0 3px; font-style: normal; }

.match-body { padding: 14px 16px 16px; }
.match-cards { display: flex; flex-wrap: wrap; gap: 8px 26px; margin-bottom: 14px; font-size: 13px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
.match-cards .nm { font-weight: 700; }
.match-cards .cards { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

.stat-compare { display: flex; flex-direction: column; gap: 9px; }
.stat-row { display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 12px; font-size: 12.5px; }
.stat-row .sv { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row .sv.left { text-align: right; }
.stat-row .sv.right { text-align: left; }
.smid { display: flex; flex-direction: column; gap: 4px; }
.smid .st { text-align: center; color: var(--muted); font-size: 11.5px; }
.sbar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--panel-3); }
.sbar i { display: block; height: 100%; }
.sbar i.l { background: var(--accent); opacity: .85; }
.sbar i.r { background: color-mix(in srgb, var(--text) 30%, var(--panel-3)); }

/* ---------- Liens équipe / arbitre ---------- */
.team-link { color: inherit; text-decoration: none; }
.team-link:hover { color: color-mix(in srgb, var(--accent) 80%, var(--text)); text-decoration: underline; }
a.ref-link { text-decoration: none; }

/* ---------- Pages équipe / arbitre ---------- */
.team-badge { background: color-mix(in srgb, var(--accent) 15%, var(--panel-2)) !important; padding: 5px; }
.team-badge img, .team-badge .mono-badge { width: 46px; height: 46px; object-fit: contain; }
.season-jump { color: color-mix(in srgb, var(--accent) 75%, var(--text)); text-decoration: none; font-weight: 700; }
.season-jump:hover { text-decoration: underline; }
sup { font-size: .7em; }

.season-block { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px;
  overflow: hidden; background: var(--panel); }
.season-block > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; font-weight: 700; }
.season-block > summary::-webkit-details-marker { display: none; }
.season-block > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.season-block[open] > summary::before { transform: rotate(90deg); }
.season-block > summary:hover { background: var(--panel-2); }
.season-block .sb-count { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 13px; }
.season-block .match-list, .season-block .team-results { padding: 10px 12px 12px; }

.team-results { display: flex; flex-direction: column; gap: 4px; }
.tr-row { display: grid; grid-template-columns: 38px 24px 1fr auto 28px 1.1fr; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px; font-size: 13px; }
.tr-row:hover { background: var(--panel-2); }
.tr-row.win { box-shadow: inset 3px 0 0 var(--good); }
.tr-row.loss { box-shadow: inset 3px 0 0 var(--bad); }
.tr-row.draw { box-shadow: inset 3px 0 0 var(--muted-2); }
.tr-opp { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tr-opp img, .tr-opp .mono-badge { width: 22px; height: 22px; object-fit: contain; flex: none; }
.tr-score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-score i { color: var(--muted-2); font-style: normal; margin: 0 2px; }
.tr-res { font-weight: 800; text-align: center; }
.tr-res.win { color: var(--good); } .tr-res.loss { color: var(--bad); } .tr-res.draw { color: var(--muted); }
.tr-ref { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc { text-align: center; }
@media (max-width: 620px) {
  .tr-row { grid-template-columns: 32px 22px 1fr auto 26px; }
  .tr-ref { display: none; }
}

/* ---------- Pied de page ---------- */
footer { max-width: 1180px; margin: 0 auto; padding: 30px 22px 60px; color: var(--muted-2); font-size: 12.5px;
  border-top: 1px solid var(--border-soft); }
footer a { color: var(--muted); }
footer .disc { margin-top: 8px; max-width: 820px; line-height: 1.6; }

@media (max-width: 820px) {
  .charts { grid-template-columns: 1fr; }
  .brand h1 { font-size: 17px; }
  .topnav a { padding: 7px 12px; font-size: 13px; }
}
@media (max-width: 520px) {
  .switch button { padding: 8px 13px; font-size: 13px; }
  .league-hero .meta-pill { display: none; }
}
