:root {
    /* Sidebar — élément de marque, sombre dans les deux thèmes */
    --side-bg: #16181d;
    --side-bg-2: #1c1f26;
    --side-text: #e9e4d6;
    --side-muted: #9b9585;
    --side-line: #2c313b;

    /* Accents or USCM */
    --gold: #e8b62c;
    --gold-deep: #b8891a;
    --gold-soft: rgba(232, 182, 44, .14);

    /* Contenu — thème clair par défaut */
    --bg: #f4f1e8;
    --bg-2: #efeadd;
    --panel: #ffffff;
    --panel-2: #faf7ef;
    --text: #1b1d21;
    --muted: #6d6656;
    --line: #e6dfcf;
    --accent: #b8891a;

    /* Sémantique statuts */
    --ok: #1f9d57;      --ok-bg: #e7f6ec;
    --warn: #c9861f;    --warn-bg: #fbf1dc;
    --crit: #cf4038;    --crit-bg: #fbe8e6;

    --radius: 16px;
    --shadow: 0 10px 30px rgba(20, 22, 26, .10);
    --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f1115;
      --bg-2: #141821;
      --panel: #191c22;
      --panel-2: #1f232b;
      --text: #ecebf0;
      --muted: #9a9488;
      --line: #2a2f38;
      --accent: #e8b62c;
      --ok: #43c07f;     --ok-bg: #14281d;
      --warn: #e0a53a;   --warn-bg: #2c2412;
      --crit: #e46a62;   --crit-bg: #2e1817;
      --shadow: 0 12px 34px rgba(0, 0, 0, .38);
    }
  }
  :root[data-theme="dark"] {
    --bg: #0f1115; --bg-2: #141821; --panel: #191c22; --panel-2: #1f232b;
    --text: #ecebf0; --muted: #9a9488; --line: #2a2f38; --accent: #e8b62c;
    --ok: #43c07f; --ok-bg: #14281d; --warn: #e0a53a; --warn-bg: #2c2412;
    --crit: #e46a62; --crit-bg: #2e1817; --shadow: 0 12px 34px rgba(0,0,0,.38);
  }
  :root[data-theme="light"] {
    --bg: #f4f1e8; --bg-2: #efeadd; --panel: #ffffff; --panel-2: #faf7ef;
    --text: #1b1d21; --muted: #6d6656; --line: #e6dfcf; --accent: #b8891a;
    --ok: #1f9d57; --ok-bg: #e7f6ec; --warn: #c9861f; --warn-bg: #fbf1dc;
    --crit: #cf4038; --crit-bg: #fbe8e6; --shadow: 0 10px 30px rgba(20,22,26,.10);
  }

  * { box-sizing: border-box; }
  body {
    margin: 0; font-family: var(--font); color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }
  canvas#dust { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .85; }

  /* Badge de marque (logo), réutilisé dans .topbar (admin) et sur le portail public. */
  .brand-badge {
    width: 46px; height: 46px; flex: 0 0 auto; border-radius: 13px;
    display: grid; place-items: center; font-size: 24px;
    background: radial-gradient(120% 120% at 30% 20%, #2a2d35, #14161b);
    border: 1px solid var(--side-line);
    box-shadow: inset 0 0 0 1px rgba(232,182,44,.18), 0 6px 16px rgba(0,0,0,.4);
  }

  /* ---------- Portail public (sans menu latéral) ---------- */
  .toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
  .eyebrow { font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 800; }
  .toolbar h2 { margin: 6px 0 3px; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.01em; text-wrap: balance; }
  .toolbar .sub { margin: 0; color: var(--muted); font-size: .95rem; }
  .userbox {
    display: flex; align-items: center; gap: 12px; font-size: .86rem;
    background: var(--panel); border: 1px solid var(--line);
    padding: 8px 8px 8px 14px; border-radius: 999px; box-shadow: var(--shadow);
  }
  .userbox .who { font-weight: 700; }
  .userbox a { color: var(--muted); text-decoration: none; }
  .theme-toggle { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: .95rem; }

  .page { display: none; animation: rise .28s ease both; }
  .page.active { display: block; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @media (prefers-reduced-motion: reduce) { .page { animation: none; } }

  /* Stat cards */
  .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
  .stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
  .stat .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  .stat .v { font-size: 1.7rem; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
  .stat .d { font-size: .78rem; color: var(--muted); margin-top: 2px; }
  .stat.accent .v { color: var(--accent); }

  /* Module tiles — plaque en relief, effet métal éclairé par un spot jaune/noir */
  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; }
  .tile {
    position: relative; overflow: hidden;
    border-radius: 16px; padding: 22px 16px 18px;
    background:
      radial-gradient(circle at 28% 18%, rgba(232, 182, 44, .4) 0%, rgba(232, 182, 44, .1) 28%, rgba(0, 0, 0, .6) 68%, rgba(0, 0, 0, .85) 100%),
      repeating-linear-gradient(100deg, rgba(255, 255, 255, .035) 0px, rgba(255, 255, 255, .035) 1px, transparent 1px, transparent 4px),
      linear-gradient(160deg, #3a3f4a 0%, #20242c 45%, #0c0d0f 100%);
    box-shadow:
      0 6px 0 0 #050506,
      0 10px 18px rgba(0, 0, 0, .5),
      inset 0 1px 0 rgba(255, 255, 255, .12),
      inset 0 -1px 0 rgba(0, 0, 0, .5);
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
    cursor: pointer; text-decoration: none; color: inherit;
    transition: transform .16s ease, box-shadow .16s ease;
  }
  .tile:hover { transform: translateY(2px); box-shadow: 0 3px 0 0 #050506, 0 6px 12px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -1px 0 rgba(0, 0, 0, .5); }
  .tile-medallion {
    width: 96px; height: 96px; border-radius: 50%; margin: 0 auto; flex-shrink: 0;
    background: radial-gradient(circle at 30% 24%, #e8c878, #6b5a30 40%, #12151a 78%);
    box-shadow: inset 0 3px 4px rgba(255, 236, 180, .25), inset 0 -6px 9px rgba(0, 0, 0, .6), 0 4px 8px rgba(0, 0, 0, .5);
    display: flex; align-items: center; justify-content: center; font-size: 38px;
  }
  .tile h3 { margin: 2px 0 0; font-size: 1.02rem; color: #ecebf0; }
  .tile p { margin: 0; color: #a8a296; font-size: .85rem; line-height: 1.5; }
  .tile .go { margin-top: 6px; font-weight: 800; color: var(--accent); font-size: .88rem; }

  .banner {
    margin-top: 18px; display: flex; gap: 14px; align-items: flex-start;
    background: var(--panel-2); border: 1px dashed var(--accent);
    border-radius: 14px; padding: 15px 18px; font-size: .9rem; line-height: 1.55; color: var(--text);
  }
  .banner .bi { font-size: 20px; }
  .banner b { color: var(--accent); }

  /* Panels */
  .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
  .panel + .panel { margin-top: 16px; }
  .panel h3 { margin: 0 0 4px; font-size: 1.12rem; }
  .panel .hint { margin: 0 0 14px; color: var(--muted); font-size: .88rem; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

  .gen-card { border-radius: 14px; padding: 18px; border: 2px solid transparent; }
  .gen-card.now { background: color-mix(in srgb, #3b82f6 12%, var(--panel)); border-color: color-mix(in srgb, #3b82f6 55%, transparent); }
  .gen-card.past { background: color-mix(in srgb, var(--gold) 14%, var(--panel)); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
  .badge { display: inline-block; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 4px 9px; border-radius: 999px; background: var(--gold-soft); color: var(--accent); }
  .gen-card h4 { margin: 10px 0 6px; font-size: 1rem; }
  .gen-card p { margin: 0 0 14px; color: var(--muted); font-size: .86rem; line-height: 1.5; }

  .btn { font: inherit; font-weight: 700; border: 0; border-radius: 11px; padding: 12px 16px; cursor: pointer; width: 100%; }
  .btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #201802; box-shadow: 0 6px 16px rgba(184,137,26,.35); }
  .btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); width: auto; padding: 9px 14px; }
  select { width: 100%; font: inherit; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); margin-bottom: 10px; }

  .latest { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
  .latest span { font-weight: 600; color: var(--muted); }
  .latest strong { font-size: clamp(1.4rem, 3.4vw, 2rem); font-variant-numeric: tabular-nums; letter-spacing: .04em; }

  .list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
  .hrow { display: grid; grid-template-columns: 1.1fr .9fr .8fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
  .hrow + .hrow { margin-top: 8px; }
  .hrow strong { font-variant-numeric: tabular-nums; letter-spacing: .03em; }
  .hrow small { color: var(--muted); }
  .icon-btn { border: 1px solid var(--line); background: var(--panel); color: var(--crit); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; }

  /* Chips */
  .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
  .chip { font: inherit; font-size: .82rem; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; }
  .chip.on { background: var(--gold-soft); color: var(--accent); border-color: color-mix(in srgb, var(--gold) 45%, transparent); font-weight: 700; }

  /* Inscriptions table */
  .table-wrap { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; min-width: 640px; }
  th, td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; }
  th { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
  tbody tr:hover { background: var(--panel-2); }
  td .name { font-weight: 700; }
  td .meta { color: var(--muted); font-size: .8rem; }
  .pill { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
  .pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .pill.ok { color: var(--ok); background: var(--ok-bg); }
  .pill.warn { color: var(--warn); background: var(--warn-bg); }
  .pill.crit { color: var(--crit); background: var(--crit-bg); }
  .cat { font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }

  .mini-note { font-size: .82rem; color: var(--muted); margin-top: 12px; }

  .attend { display: flex; align-items: center; gap: 11px; padding: 10px 13px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 8px; font-weight: 600; cursor: pointer; }
  .attend input { width: 18px; height: 18px; accent-color: var(--accent); }
  .spark { width: 100%; height: 120px; display: block; margin: 4px 0 6px; }

  @media (max-width: 1000px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
  }
  @media (max-width: 760px) {
    .hrow { grid-template-columns: 1fr auto; }
  }


/* ===================== Administration & Connexion ===================== */
.wrap { max-width: 1000px; margin: 0 auto; padding: 28px clamp(16px,3vw,32px) 56px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:22px; }
.topbar .brand-badge { width:42px; height:42px; font-size:22px; }
.topbar-left { display:flex; align-items:center; gap:12px; }
.topbar h1 { margin:0; font-size:1.25rem; }
.topbar .sub { margin:0; color:var(--muted); font-size:.82rem; }
.topbar-right { display:flex; align-items:center; gap:10px; font-size:.86rem; color:var(--muted); }
.topbar-right a { color:var(--accent); text-decoration:none; font-weight:700; }
.topbar-right a:hover { text-decoration:underline; }

.link-btn { display:inline-flex; align-items:center; gap:8px; text-decoration:none; }

.form-grid { display:grid; grid-template-columns:110px 1fr; gap:12px 16px; align-items:center; }
.form-grid label { font-weight:700; font-size:.9rem; color:var(--text); }
.form-grid .full { grid-column:1 / -1; }
input[type=text], input[type=url], input[type=email], input[type=password],
input[type=number], input[type=date], input[type=file], textarea {
  width:100%; font:inherit; padding:11px 12px; border-radius:11px;
  border:1px solid var(--line); background:var(--panel-2); color:var(--text);
}
textarea { min-height:64px; resize:vertical; }
input[type=checkbox] { width:auto; accent-color:var(--accent); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline:2px solid var(--accent); outline-offset:2px;
}
.help { color:var(--muted); font-size:.8rem; margin:2px 0 0; }

.btn.danger { background:var(--crit-bg); color:var(--crit); border:1px solid color-mix(in srgb, var(--crit) 40%, transparent); }
.btn.small { padding:7px 11px; font-size:.82rem; width:auto; }
.row-actions { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }

.flash { padding:12px 15px; border-radius:12px; margin-bottom:16px; font-weight:600; }
.flash.ok { background:var(--ok-bg); color:var(--ok); border:1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.flash.err { background:var(--crit-bg); color:var(--crit); border:1px solid color-mix(in srgb, var(--crit) 40%, transparent); }

.admin-table { width:100%; border-collapse:collapse; }
.admin-table th, .admin-table td { padding:11px 12px; border-bottom:1px solid var(--line); text-align:left; font-size:.9rem; vertical-align:middle; }
.admin-table th { font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); }
.admin-table .em { font-size:1.3rem; }
.admin-table .muted { color:var(--muted); font-size:.82rem; word-break:break-all; }
.tag { display:inline-block; font-size:.72rem; font-weight:700; padding:3px 8px; border-radius:999px; background:var(--panel-2); border:1px solid var(--line); }
.tag.off { color:var(--crit); }
.tag.on { color:var(--ok); }

/* Sélecteur de colonnes (ex. liste des adhérents) */
.colpicker { position:relative; }
.colpicker-count { display:inline-grid; place-items:center; min-width:18px; height:18px; padding:0 5px; border-radius:999px; background:var(--gold-soft); color:var(--accent); font-size:.72rem; font-weight:800; }
.colpicker-panel {
  position:absolute; top:calc(100% + 8px); right:0; z-index:20; width:300px; max-height:420px; overflow-y:auto;
  background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); padding:14px;
  opacity:0; transform:translateY(-6px) scale(.98); pointer-events:none; transition:opacity .14s ease, transform .14s ease;
}
.colpicker.open .colpicker-panel { opacity:1; transform:none; pointer-events:auto; }
.colpicker-panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.colpicker-panel-head strong { font-size:.82rem; }
.colpicker-reset { background:none; border:0; color:var(--muted); font-size:.78rem; cursor:pointer; text-decoration:underline; padding:0; }
.colpicker-reset:hover { color:var(--accent); }
.colgroup + .colgroup { margin-top:14px; padding-top:12px; border-top:1px solid var(--line); }
.colgroup-title { font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); margin-bottom:8px; }
.colrow { display:flex; align-items:center; gap:9px; padding:6px 4px; border-radius:8px; }
.colrow:hover { background:var(--panel-2); }
.colrow input { accent-color:var(--accent); width:16px; height:16px; flex-shrink:0; }
.colrow label { font-size:.87rem; cursor:pointer; flex:1; }
.col-hidden { display:none; }
@media (max-width:640px) { .colpicker-panel { position:fixed; inset:auto 12px 12px 12px; width:auto; top:auto; } }

/* Connexion */
.login-wrap { min-height:100vh; display:grid; place-items:center; padding:24px; }
.login-card { width:100%; max-width:400px; background:var(--panel); border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow); padding:30px; }
.login-card .logo { width:76px; height:76px; object-fit:contain; display:block; margin:0 auto 12px; }
.login-card h1 { margin:0 0 4px; text-align:center; font-size:1.3rem; }
.login-card .sub { margin:0 0 18px; text-align:center; color:var(--muted); font-size:.9rem; }
.login-card label { display:block; font-weight:700; font-size:.85rem; margin:10px 0 4px; }
.login-card .btn { margin-top:16px; }
.password-field { position:relative; }
.password-field input { padding-right:44px; }
.password-field .toggle { position:absolute; right:6px; top:8px; background:none; border:0; font-size:18px; cursor:pointer; color:var(--muted); }
.forgot { text-align:right; margin:8px 0 0; }
.forgot a { color:var(--accent); font-size:.85rem; font-weight:700; text-decoration:none; }
.back-link { display:inline-block; margin-top:16px; color:var(--muted); text-decoration:none; font-weight:700; font-size:.85rem; }

@media (max-width:640px) {
  .form-grid { grid-template-columns:1fr; }
  .form-grid label { margin-bottom:-6px; }
  .admin-table thead { display:none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display:block; width:100%; }
  .admin-table tr { border:1px solid var(--line); border-radius:12px; margin-bottom:12px; padding:6px; }
  .admin-table td { border:0; padding:7px 10px; }
}

/* Connexion — thème Scoring Pro (fond noir + particules dorées + silhouette Bonne-Mère) */
body.login-body{margin:0;min-height:100vh;min-height:100dvh;width:100%;background-color:#000;background-image:radial-gradient(circle at top,#2a2a2a 0%,#141414 55%,#000000 100%);background-repeat:no-repeat;background-attachment:fixed;position:relative;overflow-x:hidden}
.login-body::before{content:"";position:absolute;bottom:-40px;right:-30px;width:300px;height:880px;background-image:url('../img/bonne-mere.png');background-size:contain;background-repeat:no-repeat;background-position:bottom right;opacity:.28;pointer-events:none;z-index:0;filter:drop-shadow(0 0 30px rgba(240,209,32,.12))}
.login-body .login-wrap{position:relative;z-index:1}
.login-body .login-card{backdrop-filter:blur(22px)}
#gold-particles{position:fixed;inset:0;z-index:0;pointer-events:none}
@media(max-width:600px){.login-body::before{width:170px;height:500px;opacity:.2}}
