:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #16202e;
  --muted: #6b7787;
  --primary: #2c5fd6;
  --primary-dark: #1f47a8;
  --primary-soft: #e8effd;
  --danger: #d64545;
  --danger-soft: #fdeaea;
  --success: #1f9d63;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 60, .05), 0 8px 24px rgba(16, 32, 60, .06);
}

/* ---------- thème sombre : suit le réglage système, forçable via data-theme ---------- */
:root[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #17202c;
  --surface-2: #1d2733;
  --border: #2b3648;
  --text: #e8edf6;
  --muted: #97a3b5;
  --primary: #7498ff;
  --primary-dark: #9bb4ff;
  --primary-soft: #21304f;
  --danger: #ff8080;
  --danger-soft: #3a2429;
  --success: #4cc98a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c;
    --surface: #17202c;
    --surface-2: #1d2733;
    --border: #2b3648;
    --text: #e8edf6;
    --muted: #97a3b5;
    --primary: #7498ff;
    --primary-dark: #9bb4ff;
    --primary-soft: #21304f;
    --danger: #ff8080;
    --danger-soft: #3a2429;
    --success: #4cc98a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
/* Surbrillances codées en dur en thème clair : neutralisées en sombre. */
:root[data-theme="dark"] .cal-day:hover { background: var(--surface-2); }
:root[data-theme="dark"] .cal-day.in-range { border-color: #31446f; }
:root[data-theme="dark"] .badge.off { background: var(--surface-2); }
:root[data-theme="dark"] .notice.info { border-color: #31446f; background: var(--primary-soft); color: #c3d3f7; }
:root[data-theme="dark"] .notice.warn { border-color: #5c4a1e; background: #332a12; color: #e8cf95; }
:root[data-theme="dark"] .notice code { background: rgba(255, 255, 255, .08); }
:root[data-theme="dark"] .btn-danger { border-color: #5a3131; }
:root[data-theme="dark"] .btn-danger:hover { background: #4a2626; }
:root[data-theme="dark"] .danger-zone { border-color: #5a3131; }
:root[data-theme="dark"] .field label,
:root[data-theme="dark"] .activities-field legend { color: var(--text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cal-day:hover { background: var(--surface-2); }
  :root:not([data-theme="light"]) .cal-day.in-range { border-color: #31446f; }
  :root:not([data-theme="light"]) .badge.off { background: var(--surface-2); }
  :root:not([data-theme="light"]) .notice.info { border-color: #31446f; background: var(--primary-soft); color: #c3d3f7; }
  :root:not([data-theme="light"]) .notice.warn { border-color: #5c4a1e; background: #332a12; color: #e8cf95; }
  :root:not([data-theme="light"]) .notice code { background: rgba(255, 255, 255, .08); }
  :root:not([data-theme="light"]) .btn-danger { border-color: #5a3131; }
  :root:not([data-theme="light"]) .btn-danger:hover { background: #4a2626; }
  :root:not([data-theme="light"]) .danger-zone { border-color: #5a3131; }
  :root:not([data-theme="light"]) .field label,
  :root:not([data-theme="light"]) .activities-field legend { color: var(--text); }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1 { font-size: 1.55rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .9rem; }
h3 { font-size: .98rem; margin: 1.1rem 0 .6rem; }
p { margin: 0 0 .8rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------- barre de navigation ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 1.6rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: var(--muted); font-size: .74rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: .9rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }

.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }

.hero { margin-bottom: 20px; }
.hero p { color: var(--muted); max-width: 70ch; }

/* ---------- cartes & grilles ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}
.layout-admin { grid-template-columns: minmax(300px, 1fr) minmax(0, 1.6fr); }

@media (max-width: 980px) {
  .layout, .layout-admin { grid-template-columns: 1fr; }
}

/* ---------- calendrier ---------- */
.calendar-card { padding-bottom: 14px; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.cal-title { display: flex; align-items: center; gap: 8px; }
.cal-title h2 { margin: 0; font-size: 1.15rem; min-width: 190px; text-align: center; text-transform: capitalize; }
.cal-actions { display: flex; gap: 8px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.cal-dow {
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 2px 0;
}
.cal-day {
  min-height: 88px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 6px;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day:hover { border-color: var(--primary); background: #fbfcff; }
.cal-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.cal-day.out { opacity: .38; }
.cal-day.weekend .daynum { color: var(--primary); }
.cal-day.in-range { background: var(--primary-soft); border-color: #c7d8fa; }
.cal-day.sel-edge { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day.today .daynum {
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 0 7px;
}
.cal-day.busy { border-left: 3px solid var(--muted); }
.daynum { font-size: .82rem; font-weight: 700; }
.daynum-wrap { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.day-free { font-size: .68rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.chip {
  font-size: .64rem;
  font-weight: 700;
  color: #fff;
  padding: 1px 6px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.more { background: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.hint { font-size: .78rem; color: var(--muted); margin: 12px 0 0; }

/* ---------- formulaires ---------- */
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text); }
.req { color: var(--danger); }

input[type="text"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  font: inherit;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(44, 95, 214, .14);
}
input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}
textarea { resize: vertical; }

.activities-field { border: 0; padding: 0; margin: 0 0 14px; }
.activities-field legend { font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; padding: 0; }
.activities-list { display: flex; flex-direction: column; gap: 6px; }

.activity-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}
.activity-option:hover { border-color: var(--primary); }
.activity-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.activity-option input { margin: 3px 0 0; accent-color: var(--primary); }
.activity-option .dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
.activity-option .info { display: flex; flex-direction: column; min-width: 0; }
.activity-option .name { font-weight: 600; font-size: .88rem; }
.activity-option .meta { font-size: .74rem; color: var(--muted); }
.activity-option.disabled { opacity: .5; cursor: not-allowed; }

.range-info {
  font-size: .84rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--muted);
  margin-bottom: 14px;
}
.range-info strong { color: var(--text); }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-icon { width: 34px; height: 34px; padding: 0; font-size: 1.1rem; line-height: 1; }
.btn-danger { background: var(--danger-soft); border-color: #f2cccc; color: var(--danger); }
.btn-danger:hover { background: #f9dbdb; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: .8rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- mes inscriptions ---------- */
.my-signups { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 4px; }
.my-signups-list { display: flex; flex-direction: column; gap: 8px; }
.mini-signup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--surface-2);
}
.mini-signup .t { font-weight: 600; font-size: .86rem; }
.mini-signup .d { font-size: .76rem; color: var(--muted); }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: .95rem;
  padding: 4px 6px;
  border-radius: 7px;
}
.icon-btn:hover { background: var(--danger-soft); }

/* ---------- filtres / onglets / planning ---------- */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.filters .field { margin: 0; }
.filters-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  border: 0;
  background: transparent;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  font-size: .88rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .82rem;
}
.stat strong { display: block; font-size: 1.15rem; }

.day-block { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.day-block > header {
  background: var(--surface-2);
  padding: 9px 13px;
  font-weight: 700;
  font-size: .88rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.day-block .day-body { padding: 10px 13px; display: flex; flex-direction: column; gap: 8px; }
.act-line { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: .86rem; }
.act-line .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.act-line .who { color: var(--muted); }
.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .78rem;
}

table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:hover { background: var(--surface-2); }
.cell-activity { display: inline-flex; align-items: center; gap: 7px; }
.cell-activity .dot { width: 10px; height: 10px; border-radius: 50%; }

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* ---------- administration des activités ---------- */
.activity-card {
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.activity-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.activity-card h3 { margin: 0 0 2px; }
.activity-card .desc { color: var(--muted); font-size: .83rem; margin: 2px 0 0; }
.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.badge.off { background: #eee; color: var(--muted); }
.activity-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }

/* ---------- notifications ---------- */
.toasts {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 11px 14px;
  font-size: .86rem;
  animation: slide-in .18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- administration ---------- */
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.admin-head h1 { margin-bottom: .2rem; }
.admin-head p { margin: 0; }

.notice {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: .86rem;
  background: var(--surface-2);
}
.notice.info { border-color: #c7d8fa; background: var(--primary-soft); color: #23407f; }
.notice.warn { border-color: #f0d9a8; background: #fdf7e7; color: #7a5a12; }
.notice code {
  background: rgba(0, 0, 0, .06);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: .85em;
}

.tab-panel { margin-top: 4px; }
.tab-panel[hidden] { display: none; }

.panel-details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--surface-2);
}
.panel-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
}
.panel-details[open] > summary { margin-bottom: 12px; }
.add-form { margin-top: 6px; }

.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 720px; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.bulk-bar .count { font-size: .85rem; font-weight: 600; }
.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .85rem;
  font-weight: 600;
}
.check-inline input { accent-color: var(--primary); }

th.sel-col, td.sel-col { width: 34px; text-align: center; }
td input, td select { padding: 6px 8px; font-size: .84rem; }
td input[type="checkbox"] { width: auto; accent-color: var(--primary); }
tr.editing { background: var(--primary-soft); }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.upcoming {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.upcoming .day {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upcoming .day header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  font-size: .85rem;
  text-transform: capitalize;
}
.vol-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.vol-chips .pill { border-left-width: 3px; border-left-style: solid; }

.danger-zone {
  border: 1px solid #f2cccc;
  background: var(--danger-soft);
  border-radius: 12px;
  padding: 14px;
}
.danger-zone h3 { margin-top: 0; }

.login-wrap { max-width: 420px; margin: 6vh auto 0; }

/* ---------- pied de page ---------- */
.footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 30px; }
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  font-size: .8rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .cal-day { min-height: 62px; padding: 4px; }
  .cal-title h2 { min-width: 0; font-size: 1rem; }
  .field-row { grid-template-columns: 1fr; }
  .footer-inner { justify-content: center; text-align: center; }
}
