:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1c1917;
  --muted: #6b645c;
  --border: #e2ded6;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fff1e8;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --err: #b91c1c;
  --err-soft: #fdecec;
  --warn: #a16207;
  --warn-soft: #fdf6e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141210; --surface: #1d1a17; --surface-2: #26221e; --text: #f2efea; --muted: #a59d93;
    --border: #36302a; --accent: #f97316; --accent-ink: #1c1917; --accent-soft: #3a2314;
    --ok: #4ade80; --ok-soft: #14301e; --err: #f87171; --err-soft: #3a1717; --warn: #facc15; --warn-soft: #33290f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141210; --surface: #1d1a17; --surface-2: #26221e; --text: #f2efea; --muted: #a59d93;
  --border: #36302a; --accent: #f97316; --accent-ink: #1c1917; --accent-soft: #3a2314;
  --ok: #4ade80; --ok-soft: #14301e; --err: #f87171; --err-soft: #3a1717; --warn: #facc15; --warn-soft: #33290f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
a { color: var(--accent); }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 32px 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 8px; }
.lead { font-size: 1.08rem; color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* En-tête */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1000; }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a, .nav-btn { color: var(--text); text-decoration: none; padding: 8px 12px; border-radius: 8px; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav-btn:hover { background: var(--surface-2); }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav a.nav-cta { background: var(--accent); color: var(--accent-ink); }
.menu-toggle, .burger { display: none; }
form.inline { display: inline; margin: 0; }
@media (max-width: 760px) {
  .burger { display: block; margin-left: auto; width: 40px; height: 40px; cursor: pointer; position: relative; }
  .burger span, .burger span::before, .burger span::after { position: absolute; left: 9px; width: 22px; height: 2px; background: var(--text); content: ""; }
  .burger span { top: 19px; } .burger span::before { top: -7px; left: 0; } .burger span::after { top: 7px; left: 0; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 12px; }
  .menu-toggle:checked ~ .nav { display: flex; }
}

.foot { border-top: 1px solid var(--border); background: var(--surface); font-size: .9rem; color: var(--muted); }
.foot .wrap { display: flex; justify-content: space-between; gap: 16px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; }

/* Boutons */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--err); border-color: var(--err); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.big { padding: 12px 22px; font-size: 1.05rem; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.linkbtn.danger { color: var(--err); }

.flash { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 20px; border: 1px solid; }
.flash ul { margin: 0; padding-left: 18px; }
.flash.ok { background: var(--ok-soft); border-color: var(--ok); }
.flash.err { background: var(--err-soft); border-color: var(--err); }
.note { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 10px 14px; border-radius: 6px; }
.empty { padding: 32px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }

/* Carte */
.carte { height: min(65vh, 560px); border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.carte-actions { margin-top: 12px; }
.popup { display: grid; gap: 4px; min-width: 180px; }
.popup .btn { margin-top: 6px; justify-content: center; color: var(--accent-ink); }
.picker { height: 320px; border-radius: var(--radius); border: 1px solid var(--border); margin: 8px 0 16px; }

/* Listes */
.filtres { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin: 16px 0 20px; }
.filtres label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.concours-card { display: grid; gap: 4px; text-decoration: none; color: var(--text); }
.concours-card:hover { border-color: var(--accent); }
.disc { display: inline-block; justify-self: start; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; padding: 2px 8px; border-radius: 99px; }
.pill { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.pill.libre { background: var(--ok-soft); color: var(--ok); }
.pill.occ { background: var(--surface-2); color: var(--muted); }
.pill.att { background: var(--warn-soft); color: var(--warn); }
.tag { font-size: .75rem; background: var(--warn-soft); color: var(--warn); padding: 1px 6px; border-radius: 4px; }
.crumbs { margin: 0 0 12px; font-size: .9rem; }

/* Fiche */
.fiche { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .fiche { grid-template-columns: 1fr; } }
.club { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.club h2 { margin-top: 0; font-size: 1rem; }
.infos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
.infos dt { color: var(--muted); }
.infos dd { margin: 0; }
@media (max-width: 520px) { .infos { grid-template-columns: 1fr; } .infos dd { margin-bottom: 8px; } }
.jours { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 16px; }
.jours a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 99px; text-decoration: none; color: var(--text); background: var(--surface); font-size: .9rem; }
.jours a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Grille des places */
.fosses { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.fosse { background: var(--surface-2); border-radius: var(--radius); padding: 12px; }
.fosse h3 { text-align: center; }
.stats { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 0 0 10px; }
.planche { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.planche header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.heure { font-size: 1.35rem; }
.postes { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.postes li { display: flex; gap: 8px; padding: 3px 0; border-top: 1px dashed var(--border); }
.postes li:first-child { border-top: 0; }
.pn { font-weight: 700; width: 26px; flex: none; color: var(--muted); }
.postes .att { color: var(--warn); }
.postes a { text-decoration: none; }
.libre-lien { color: var(--ok); font-weight: 600; }

/* Formulaires */
.form { display: grid; gap: 14px; max-width: 760px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .92rem; }
.form small { font-weight: 400; color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 620px) { .row, .row3 { grid-template-columns: 1fr; } }
.short { max-width: 260px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
fieldset.radios { border: 0; padding: 0; margin: 0; display: flex; gap: 20px; flex-wrap: wrap; }
fieldset.radios legend { font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
.hp { position: absolute; left: -9999px; }
.place-choisie { display: grid; gap: 4px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; max-width: 760px; }
.place-choisie > span:first-child { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.total { font-size: 1.1rem; margin: 0; }
.narrow { max-width: 440px; margin: 0 auto; }
.narrow .form { max-width: none; }
.confirm { max-width: 760px; }
.prose { max-width: 760px; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.podium td { background: var(--accent-soft); }
.table tr.annulee td { color: var(--muted); text-decoration: line-through; }
.table input, .table select { padding: 5px 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Gestion */
.gestion { display: grid; grid-template-columns: 210px 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .gestion { grid-template-columns: 1fr; } }
.side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; display: grid; gap: 2px; position: sticky; top: 76px; }
@media (max-width: 860px) { .side { position: static; display: flex; flex-wrap: wrap; } }
.side a { padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); font-size: .93rem; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; width: 100%; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 12px 0 20px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kpi b { display: block; font-size: 1.6rem; }
.kpi span { color: var(--muted); font-size: .85rem; }
.head-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
details.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; }
details.box summary { cursor: pointer; font-weight: 600; }

@media print {
  .top, .foot, .side, .no-print, .tabs { display: none !important; }
  body { background: #fff; color: #000; }
  .gestion { display: block; }
  .table-wrap { border: 0; }
  .planche, .fosse { break-inside: avoid; }
}
