/* Portail En vol ! — accès aux quatre jeux et statistiques des parties (admin).
   Couleurs en variables : thème clair par défaut, sombre selon le système ou data-theme. Séries : une couleur par
   marque (palette catégorielle validée, ordre fixe : SVR, Actual, Sodebo, Gitana) ; tailles de voiles : gamme ordinale
   d'un seul bleu ; états des parties : couleurs d'état, toujours avec un libellé. */
:root {
  color-scheme: light;
  --plane: #f9f9f7; --surface: #fcfcfb; --raised: #ffffff;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11, 11, 11, 0.10); --hover: rgba(11, 11, 11, 0.04);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;          /* SVR, Actual, Sodebo, Gitana */
  --mark: #52514e;                                                    /* série unique sans marque */
  --o1: #86b6ef; --o2: #3987e5; --o3: #1c5cab; --o4: #0d366b;          /* gamme ordinale (voiles) */
  --q0: #f0efec; --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec; --q4: #3987e5; --q5: #256abf; --q6: #184f95; --q7: #0d366b;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b; --good-text: #006300;
  --navy: #071a2e; --navy-ink: #e8f4ff; --accent: #2a78d6;
  --text: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane: #0d0d0d; --surface: #1a1a19; --raised: #222220;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --hover: rgba(255, 255, 255, 0.05);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --mark: #c3c2b7;
    --o1: #9ec5f4; --o2: #5598e7; --o3: #256abf; --o4: #184f95;
    --q0: #383835; --q1: #104281; --q2: #184f95; --q3: #1c5cab; --q4: #256abf; --q5: #3987e5; --q6: #6da7ec; --q7: #b7d3f6;
    --good-text: #0ca30c; --accent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane: #0d0d0d; --surface: #1a1a19; --raised: #222220;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --hover: rgba(255, 255, 255, 0.05);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --mark: #c3c2b7;
  --o1: #9ec5f4; --o2: #5598e7; --o3: #256abf; --o4: #184f95;
  --q0: #383835; --q1: #104281; --q2: #184f95; --q3: #1c5cab; --q4: #256abf; --q5: #3987e5; --q6: #6da7ec; --q7: #b7d3f6;
  --good-text: #0ca30c; --accent: #3987e5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--plane); }
body { font-family: var(--text); color: var(--ink); background: var(--plane); font-size: 15px; line-height: 1.45; min-height: 100vh; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* --- en-tête --- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--navy); color: var(--navy-ink); }
.mark { display: flex; align-items: baseline; gap: 10px; text-decoration: none; white-space: nowrap; }
.mark b { font-family: var(--cond); font-weight: 800; font-style: italic; font-size: 26px; letter-spacing: 0.5px; text-transform: uppercase; }
.mark b em { color: #f7b500; font-style: italic; }
.mark span { font-family: var(--cond); font-weight: 600; font-size: 15px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.7; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs a { padding: 8px 12px; border-radius: 6px; text-decoration: none; font-weight: 500; white-space: nowrap; color: rgba(232, 244, 255, 0.72); }
.tabs a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tabs a.on { background: rgba(255, 255, 255, 0.14); color: #fff; }
.account { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 14px; }
.account img { width: 28px; height: 28px; border-radius: 50%; }
.account .who { opacity: 0.8; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--ring);
  background: var(--raised); color: var(--ink); text-decoration: none; font-weight: 500; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.top .btn { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.2); }
.top .btn:hover { background: rgba(255, 255, 255, 0.18); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 4px 8px; }

.banner { padding: 10px 24px; background: #fff4d6; color: #5a4300; font-size: 14px; }
:root[data-theme="dark"] .banner { background: #3a2f12; color: #f3dfa7; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .banner { background: #3a2f12; color: #f3dfa7; } }

/* --- filtres : une rangée au-dessus de tout ce qu'ils règlent --- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 24px; border-bottom: 1px solid var(--grid);
  background: var(--surface); position: sticky; top: 56px; z-index: 10; }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.filters select { padding: 6px 28px 6px 10px; border-radius: 8px; border: 1px solid var(--ring); background: var(--raised); font-size: 14px; }
.filters .count { margin-left: auto; font-size: 13px; color: var(--muted); }

/* --- contenu --- */
main { padding: 24px; max-width: 1440px; margin: 0 auto; }
main.loading { opacity: 0.55; transition: opacity .2s; }
h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.lede { color: var(--ink-2); margin-bottom: 20px; max-width: 760px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }
.grid.games { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 18px 18px 16px; min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .tiles + .grid, .tiles + .card, .grid + .grid { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head .tools { display: flex; gap: 6px; flex-shrink: 0; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

/* chiffres */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.tile .detail { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tile.hero .value { font-size: 48px; line-height: 1.05; }

/* légende */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 1px; }

/* graphiques (SVG) */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--text); font-size: 12px; fill: var(--muted); }
.chart .tick { font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit:focus { fill: var(--hover); outline: none; }
.chart .cell:hover, .chart .cell:focus { stroke: var(--ink); stroke-width: 1.5; outline: none; }
.chart .seg:hover, .chart .seg:focus { filter: brightness(1.1); outline: none; }
.chart .inlabel { font-size: 12px; font-weight: 600; }
.chart .vlabel { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }

/* info-bulle : la valeur d'abord, le nom ensuite */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--raised); color: var(--ink); border: 1px solid var(--ring);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); min-width: 140px; max-width: 280px; }
.tip .t { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 8px; }
.tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 48px; }
.tip .row span { color: var(--ink-2); }
.tip .key { width: 12px; height: 2px; border-radius: 1px; display: inline-block; flex-shrink: 0; }

/* tableaux */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--ink); }
td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
td { white-space: nowrap; }   /* les tableaux défilent horizontalement plutôt que de s'étirer en hauteur */
tbody tr.clickable { cursor: pointer; } tbody tr.clickable:hover { background: var(--hover); }
tbody tr.sel { background: var(--hover); }
.dataview { margin-top: 12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--ring); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.meter { display: inline-block; vertical-align: middle; width: 56px; height: 6px; border-radius: 3px; background: var(--q0); margin-left: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--mark); }

/* jeux */
.game { display: flex; flex-direction: column; gap: 12px; }
.game-head { display: flex; align-items: center; gap: 12px; }
.game-head img { width: 56px; height: 56px; border-radius: 12px; }
.game-head h2 { font-size: 17px; }
.game-head a.url { font-size: 13px; color: var(--ink-2); text-decoration: none; }
.game-head a.url:hover { text-decoration: underline; }
.game .qr { display: flex; gap: 14px; align-items: center; }
.game .qr img { width: 112px; height: 112px; background: #fff; border-radius: 8px; padding: 6px; border: 1px solid var(--ring); }
.game .qr .facts { font-size: 13px; color: var(--ink-2); display: grid; gap: 3px; }
.game .qr .facts b { color: var(--ink); font-weight: 600; }
.game .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.status { font-size: 12px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }

/* détail d'une partie */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); z-index: 40; background: var(--surface);
  border-left: 1px solid var(--ring); box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18); overflow-y: auto; padding: 20px 22px 40px; }
.drawer .close { position: sticky; top: 0; float: right; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 18px; margin: 14px 0 18px; }
.kv div { font-size: 13px; color: var(--ink-2); }
.kv b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; }
details.raw summary { cursor: pointer; color: var(--ink-2); font-size: 13px; margin-top: 18px; }
details.raw pre { font-size: 11px; background: var(--plane); padding: 10px; border-radius: 8px; overflow-x: auto; margin-top: 8px; }

/* connexion */
.gate { max-width: 520px; margin: 48px auto; text-align: center; }
.gate p { color: var(--ink-2); margin: 10px 0 18px; }

@media (max-width: 760px) {
  .top { padding: 0 12px; gap: 12px; }
  .mark span { display: none; }
  .account .who { display: none; }
  .filters { padding: 10px 12px; top: 56px; }
  main { padding: 16px 12px; }
  .grid.two { grid-template-columns: 1fr; }
  .tile.hero .value { font-size: 40px; }
}
@media (forced-colors: active) { .legend i, .swatch, .pill i { forced-color-adjust: none; } }
