/* =========================================================================
   Thème web — Pure Minimalist (Jaune / Or d'origine de la JCMCI)
   Palette : Fond Slate-50 (#F8FAFC) · Surfaces Blanc Pur (#FFFFFF)
   Accent : Or JCMCI (#E9B24D) · Micro-bordures raffinées · Typographie nette
   Slide-Over Drawer sur PC pour formulaires et détails (ne masque jamais le menu)
   ========================================================================= */

:root {
  /* Surfaces & Fonds */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-subtle: #F1F5F9;
  --surface-hover: #F8FAFC;

  /* Typographie & Couleurs de texte */
  --text: #0F172A;              /* Slate 900 */
  --text-2: #334155;            /* Slate 700 */
  --text-muted: #64748B;        /* Slate 500 */
  --divider: #E2E8F0;           /* Slate 200 */
  --border-subtle: #F1F5F9;

  /* Accent & Identité : Le Jaune / Or d'origine de la JCMCI */
  --primary: #E9B24D;           /* Or / Jaune historique */
  --primary-hover: #DCA038;
  --primary-dark: #B45309;
  --primary-text: #1E293B;      /* Texte sombre lisible sur fond or */
  --primary-light: #FFFBEB;     /* Fond pastel ambre/or très doux */
  --primary-border: #FDE68A;

  --accent: #E9B24D;
  --accent-dark: #DCA038;
  --accent-light: #FFFBEB;
  --accent-border: #FDE68A;
  --accent-text: #92400E;

  /* États sémantiques */
  --success: #10B981;
  --success-bg: #ECFDF5;
  --success-text: #065F46;

  --danger: #EF4444;
  --danger-bg: #FEF2F2;
  --danger-text: #991B1B;

  --warning: #F59E0B;
  --warning-bg: #FFFBEB;
  --warning-text: #92400E;

  --info: #0EA5E9;
  --info-bg: #F0F9FF;
  --info-text: #075985;

  /* Rayons d'arrondi */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 9999px;

  /* Espacements */
  --sp: 16px;
  --sidebar-w: 260px;

  /* Ombres ultra-subtiles & précises */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.09), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .font-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}
a { color: #B45309; text-decoration: none; }

/* ----------------------------- Layout ---------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #FFFFFF;
  color: var(--text);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 130;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--divider);
}

.sidebar .brand .logo {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--primary-text);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex: 0 0 38px;
  box-shadow: 0 2px 8px rgba(233, 178, 77, 0.35);
}

.sidebar .brand .logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: contain;
  flex: 0 0 44px;
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.sidebar .brand .t1 {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
}

.sidebar .brand .t2 {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.nav {
  padding: 16px 12px;
  overflow-y: auto;
  flex: 1;
}

.nav .section {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 14px 12px 6px;
}

.nav a.lien1, .nav .grp > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: all 0.15s ease;
  user-select: none;
}

.nav a.lien1 .material-symbols-rounded, .nav .grp > summary .material-symbols-rounded {
  font-size: 20px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.nav a.lien1:hover, .nav .grp > summary:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav a.lien1:hover .material-symbols-rounded, .nav .grp > summary:hover .material-symbols-rounded {
  color: var(--text);
}

.nav a.lien1.active {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
}

.nav a.lien1.active .material-symbols-rounded {
  color: #D97706;
}

/* Groupes dépliables du menu */
.nav .grp { margin-bottom: 2px; }
.nav .grp > summary { cursor: pointer; list-style: none; }
.nav .grp > summary::-webkit-details-marker { display: none; }
.nav .grp > summary::after {
  content: "expand_more";
  font-family: "Material Symbols Rounded";
  margin-left: auto;
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.nav .grp[open] > summary::after { transform: rotate(180deg); }
.nav .grp[open] > summary { color: var(--text); }

.nav .grp > a {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 42px;
  font-size: 13px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 1px;
}

.nav .grp > a:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav .grp > a.active {
  background: var(--accent-light);
  color: var(--accent-text);
  font-weight: 600;
}

.sidebar .foot {
  padding: 14px 16px;
  border-top: 1px solid var(--divider);
  background: #FFFFFF;
}

/* ----------------------------- Main & Topbar --------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--divider);
}

.topbar .burger {
  display: none;
  background: none;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  color: var(--text-2);
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  place-items: center;
  font-size: 20px;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar .spacer { flex: 1; }

.topbar .who {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.3;
}

.topbar .who b {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.topbar .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: #B45309;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.content {
  padding: 28px 32px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
}

.content.spa-chargement { opacity: 0.45; pointer-events: none; transition: opacity 0.12s; }

/* Barre de progression de navigation SPA */
.spa-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0;
  z-index: 300;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(233, 178, 77, 0.5);
  opacity: 0;
  transition: opacity 0.2s;
}
.spa-bar.actif {
  opacity: 1;
  width: 90%;
  transition: width 2.2s cubic-bezier(0.1, 0.6, 0.2, 1), opacity 0.2s;
}

/* ---------------------------- Bottom nav (mobile) ---------------------- */
.bottomnav { display: none; }

/* ------------------------------ Cards ---------------------------------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  overflow: hidden;
}

.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.section-title {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 8px 0 14px;
}

/* Stat cards (dashboard) */
.stat-hero {
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-xl);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow);
}

.stat-hero .ic-wrap {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--accent-light);
  color: #B45309;
  display: grid;
  place-items: center;
  font-size: 28px;
  flex: 0 0 56px;
  border: 1px solid var(--accent-border);
}

.stat-hero .v {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-hero .l {
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  margin-top: 4px;
}

.stat-mini {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-mini:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.stat-mini .ic-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.stat-mini .l {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-mini .v {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  letter-spacing: -0.01em;
}

/* Quick actions */
.qa-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.qa {
  background: var(--surface);
  border: 1px solid var(--divider);
  cursor: pointer;
  border-radius: var(--r-lg);
  padding: 18px 12px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
  transition: all 0.15s ease;
}

.qa:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--accent-text);
  border-color: var(--accent-border);
}

.qa .ic {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  font-size: 22px;
  transition: transform 0.15s ease;
}
.qa:hover .ic {
  transform: scale(1.05);
}

/* ------------------------------ Buttons -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 9px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  background: var(--accent);
  color: var(--primary-text);
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.15);
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn .material-symbols-rounded { font-size: 18px; }

.btn.primary { background: var(--accent); color: var(--primary-text); }
.btn.ghost {
  background: #FFFFFF;
  color: var(--text-2);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.btn.ghost:hover {
  background: var(--surface-subtle);
  color: var(--text);
  border-color: #CBD5E1;
}

.btn.danger {
  background: var(--danger);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(239, 68, 68, 0.2);
}
.btn.danger:hover { background: #DC2626; }

.btn.sm, .btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-sm.primary, .btn.primary.sm {
  background: var(--accent);
  color: var(--primary-text);
  border-color: transparent;
}
.btn-sm.primary:hover, .btn.primary.sm:hover {
  background: var(--accent-dark);
}
.btn-sm.ghost, .btn.ghost.sm {
  background: #FFFFFF;
  color: var(--text-2);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
}
.btn-sm.ghost:hover, .btn.ghost.sm:hover {
  background: var(--surface-subtle);
  color: var(--text);
  border-color: #CBD5E1;
}
.btn.sm .material-symbols-rounded, .btn-sm .material-symbols-rounded {
  font-size: 16px;
}

.icon-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  transition: all 0.12s ease;
}
.icon-btn:hover { background: var(--surface-subtle); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ------------------------------ Forms ---------------------------------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 7px;
}

.input, select.input, textarea.input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 42px;
  padding: 0 14px;
  border: 1px solid #CBD5E1;
  border-radius: var(--r-sm);
  background: #FFFFFF;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select.input {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

textarea.input {
  height: auto;
  min-height: 96px;
  padding: 10px 14px;
  resize: vertical;
}

.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 178, 77, 0.22);
}

.page-panel .form-row,
.modal .form-row,
.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.form-row > * { min-width: 0; max-width: 100%; }
.form-row .field { margin-bottom: 0; }
.field { min-width: 0; max-width: 100%; margin-bottom: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* ----------------- Boutons de Catégories (Présence) ------------------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

button.cat-btn,
.cat-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 12px !important;
  background: #FFFFFF !important;
  border: 1px solid var(--divider) !important;
  border-radius: var(--r-md) !important;
  color: var(--text-2) !important;
  font-family: inherit !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  box-shadow: var(--shadow-xs) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  user-select: none !important;
  text-align: left !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  outline: none !important;
  box-sizing: border-box !important;
}

button.cat-btn:hover,
.cat-btn:hover {
  background: var(--accent-light) !important;
  border-color: var(--accent-border) !important;
  color: var(--accent-text) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm) !important;
}

.cat-btn .cat-ic {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex: 0 0 26px;
  transition: all 0.15s ease;
}

.cat-btn:hover .cat-ic {
  background: #FFFFFF;
  color: #D97706;
}

.cat-btn .cat-ic .material-symbols-rounded {
  font-size: 16px;
}

.cat-btn .n {
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-btn.a-selection {
  border-color: var(--accent) !important;
  background: var(--accent-light) !important;
  color: var(--accent-text) !important;
  font-weight: 600 !important;
}

/* ----------------------- Barre d'outils ultra-compacte ----------------- */
/* Tout est aligné sur la même ligne que la recherche (au maximum 2 lignes).
   Le bouton Ajouter est TOUJOURS au coin supérieur droit (margin-left: auto). */
.toolbar {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: space-between !important;
  flex-wrap: nowrap !important;
  gap: 8px 12px !important;
  margin-bottom: 12px;
  background: #FFFFFF;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--divider);
  box-shadow: var(--shadow-xs);
  min-height: 48px;
  box-sizing: border-box;
}

.toolbar-left {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 6px 8px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

.toolbar-search,
.toolbar .search {
  position: relative !important;
  width: 180px !important;
  min-width: 140px !important;
  max-width: 210px !important;
  flex: 0 0 auto !important;
}

.toolbar-search .material-symbols-rounded,
.toolbar .search .material-symbols-rounded {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.toolbar-search input,
.toolbar .search input {
  width: 100% !important;
  height: 32px !important;
  padding: 0 10px 0 32px !important;
  font-size: 12.5px !important;
  border: 1px solid #CBD5E1 !important;
  border-radius: var(--r-sm) !important;
  background: #F8FAFC !important;
  color: var(--text) !important;
  box-sizing: border-box !important;
  transition: all 0.15s ease;
}

.toolbar-search input:focus,
.toolbar .search input:focus {
  background: #FFFFFF !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(233, 178, 77, 0.25) !important;
  outline: none !important;
}

.toolbar-filters {
  display: contents !important;
}

/* IMPORTANT : Aucun select / filtre ne prend 100% de la largeur ! */
.toolbar select.filtre,
.toolbar .filtre,
.toolbar select,
.toolbar-filters select,
.toolbar-left select {
  display: inline-block !important;
  width: auto !important;
  max-width: 130px !important;
  min-width: 75px !important;
  height: 32px !important;
  padding: 0 20px 0 8px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--text-2) !important;
  border: 1px solid #CBD5E1 !important;
  border-radius: var(--r-sm) !important;
  background: #F8FAFC url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='%2364748B'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 5px center !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  cursor: pointer !important;
  box-sizing: border-box !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  flex: 0 0 auto !important;
  transition: all 0.15s ease;
}

.toolbar select.filtre:hover,
.toolbar .filtre:hover,
.toolbar select:hover {
  background-color: #FFFFFF !important;
  border-color: #94A3B8 !important;
  color: var(--text) !important;
}

.toolbar select.filtre.active,
.toolbar .filtre.active {
  background-color: var(--accent-light) !important;
  border-color: var(--accent-border) !important;
  color: var(--accent-text) !important;
  font-weight: 600 !important;
}

.toolbar-actions {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
  flex: 0 0 auto !important;
  align-self: flex-start !important;
}

/* Boutons dans la barre d'outils : TOUJOURS compacts et JAMAIS 100% de large ! */
.toolbar .btn,
.toolbar-actions .btn {
  display: inline-flex !important;
  width: auto !important;
  height: 32px !important;
  padding: 0 12px !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  border-radius: var(--r-sm) !important;
  white-space: nowrap !important;
  flex: 0 0 auto !important;
}

.toolbar-actions .btn.primary,
.toolbar .btn.primary {
  background: var(--accent) !important;
  color: var(--primary-text) !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.2) !important;
}

.toolbar-actions .btn.ghost,
.toolbar .btn.ghost {
  background: #FFFFFF !important;
  color: var(--text-2) !important;
  border: 1px solid #CBD5E1 !important;
}

.toolbar-actions .btn.ghost:hover,
.toolbar .btn.ghost:hover {
  background: #F8FAFC !important;
  color: var(--text) !important;
  border-color: #94A3B8 !important;
}

@media (max-width: 900px) {
  /* Sur mobile / tablette : au maximum 2 lignes garanties */
  .toolbar {
    flex-wrap: wrap !important;
    padding: 8px 10px;
    gap: 6px;
  }
  .toolbar-left {
    width: 100% !important;
  }
  .toolbar-search,
  .toolbar .search {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 140px !important;
  }
  .toolbar-filters {
    display: inline-flex !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .toolbar-filters::-webkit-scrollbar {
    height: 3px;
  }
  .toolbar-actions {
    width: 100% !important;
    justify-content: flex-end !important;
  }
}

/* ----------------------- Tableaux de données -------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--divider);
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #FFFFFF;
  text-align: left;
}

table.data th {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 20px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}

table.data td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text);
  font-size: 13.5px;
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background 0.1s ease; }
table.data tbody tr:hover td { background: var(--surface-hover); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.row-actions .icon-btn:hover {
  background: var(--surface-subtle);
  border-color: var(--divider);
  color: var(--text);
}
.row-actions .icon-btn.danger:hover {
  background: var(--danger-bg);
  border-color: #FECACA;
  color: var(--danger);
}

/* Chips / badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: #F1F5F9;
  color: var(--text-2);
  white-space: nowrap;
  border: 1px solid transparent;
}
.chip.ok { background: var(--success-bg); color: var(--success-text); border-color: #A7F3D0; }
.chip.no { background: var(--danger-bg); color: var(--danger-text); border-color: #FECACA; }
.chip.warn { background: var(--warning-bg); color: var(--warning-text); border-color: #FDE68A; }
.chip.info { background: var(--info-bg); color: var(--info-text); border-color: #BAE6FD; }
.chip.accent { background: var(--accent-light); color: var(--accent-text); border-color: var(--accent-border); }

/* Avatar initiales et photos de membre */
.ava {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  background: var(--accent-light);
  color: var(--accent-text);
  border: 1px solid var(--accent-border);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 600;
  font-size: 12px;
  flex: 0 0 36px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  align-self: center !important;
  line-height: 1;
}
.ava img {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  object-position: center !important;
  border-radius: 50% !important;
  display: block !important;
  flex: 0 0 100% !important;
}
.ava.clic {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ava.clic:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.ava.neutral {
  background: #F3F4F6 !important;
  color: #374151 !important;
  border-color: #E5E7EB !important;
}
[data-theme="dark"] .ava.neutral {
  background: #374151 !important;
  color: #F3F4F6 !important;
  border-color: #4B5563 !important;
}
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person b { color: var(--text); font-weight: 600; font-size: 13.5px; }
.cell-person small { color: var(--text-muted); display: block; font-size: 12px; }

.thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  object-fit: cover;
  display: inline-block;
  vertical-align: middle;
  background: var(--surface-subtle);
  border: 1px solid var(--divider);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.thumb:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.thumb.ph {
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
}
.thumb.ph .material-symbols-rounded { font-size: 20px; }

/* ------------------------------ Tabs ----------------------------------- */
.tabs { display: none !important; }
.tabs-legacy {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 20px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.tabs-legacy button {
  background: none;
  border: 0;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s ease;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tabs-legacy button:hover {
  color: var(--text);
  background: var(--surface-subtle);
}
.tabs-legacy button.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: var(--accent-light);
}
.tabpane { display: none; }
.tabpane.active { display: block; }

/* ------------------------------ Modal ---------------------------------- */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 160;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-back.open { display: flex; }

.modal {
  background: #FFFFFF;
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--divider);
  animation: pop 0.18s ease;
}
.modal.lg { max-width: 840px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.modal header {
  display: flex;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--divider);
}
.modal header h3 { margin: 0; font-size: 16.5px; font-weight: 600; color: var(--text); }
.modal .body { padding: 22px; }
.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--divider);
  background: #F8FAFC;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ------------------------------ Misc & Helpers ------------------------- */
.muted { color: var(--text-muted); }
.center { text-align: center; }

/* État vide moderne */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 56px 24px;
  background: #FFFFFF;
  border-radius: var(--r-lg);
  border: 1px dashed var(--divider);
  margin: 12px 0;
}
.empty .empty-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--r-xl);
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  color: var(--text-muted);
  border: 1px solid var(--divider);
}
.empty .material-symbols-rounded {
  font-size: 24px;
  color: var(--text-2);
}
.empty .empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.empty .empty-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid var(--divider);
  border-top-color: var(--accent);
  border-radius: var(--r-pill);
  animation: spin 0.7s linear infinite;
  margin: 36px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h2 { font-size: 20px; margin: 0; font-weight: 600; }
.page-head .spacer { flex: 1; }

pre.msg-out, textarea.msg-out {
  background: #0F172A;
  color: #E2E8F0;
  padding: 16px;
  border-radius: var(--r-md);
  white-space: pre-wrap;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  max-height: 420px;
  overflow: auto;
}
textarea.msg-out {
  width: 100%;
  box-sizing: border-box;
  min-height: 220px;
  resize: vertical;
  border: 1px solid #334155;
  line-height: 1.5;
}
textarea.msg-out:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* Aperçu / upload photo */
.photo-preview {
  width: 120px;
  height: 120px;
  min-width: 120px;
  min-height: 120px;
  max-width: 120px;
  max-height: 120px;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  border: 1px solid var(--divider);
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 10px;
}
.photo-preview.rond {
  border-radius: 50% !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.photo-preview img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  display: block;
}
.photo-preview.rond img {
  border-radius: 50% !important;
}
.photo-preview .muted { font-size: 12px; }

/* ------------------- Panneau formulaire & détail (Slide-Over) ----------- */
.page-back {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.page-back.open {
  opacity: 1;
  pointer-events: auto;
}

.page-panel {
  width: 100%;
  max-width: 760px;
  height: 100%;
  background: #FFFFFF;
  box-shadow: -8px 0 35px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--divider);
}

.page-back.open .page-panel {
  transform: translateX(0);
}

@media (min-width: 901px) {
  /* Sur PC : la barre de menu latérale gauche reste 100% visible et interactive ! */
  .page-back {
    left: var(--sidebar-w) !important;
    width: calc(100vw - var(--sidebar-w)) !important;
    background: rgba(15, 23, 42, 0.25) !important;
  }
  .page-panel {
    width: 720px !important;
    max-width: calc(100vw - var(--sidebar-w) - 30px) !important;
  }
  .page-panel.page-panel-lg {
    width: 980px !important;
    max-width: calc(100vw - var(--sidebar-w) - 30px) !important;
  }
  .modal-back {
    left: var(--sidebar-w) !important;
    width: calc(100vw - var(--sidebar-w)) !important;
    background: rgba(15, 23, 42, 0.25) !important;
  }
}

.page-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: #FFFFFF;
  color: var(--text);
  border-bottom: 1px solid var(--divider);
  flex: 0 0 auto;
}

.page-h-txt h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page-h-txt p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.page-h .close-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  border: 1px solid var(--divider);
  background: #F8FAFC;
  color: var(--text-2);
}
.page-h .close-btn:hover {
  background: #F1F5F9;
  color: var(--text);
}

.page-body {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #FFFFFF;
}

.page-inner {
  max-width: 100%;
  padding: 24px;
}

.page-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--divider);
  background: #F8FAFC;
  flex: 0 0 auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* Sélecteur de membres (picker) */
.picker {
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #FFFFFF;
}
.picker-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  background: #F8FAFC;
}
.picker-liste { max-height: 48vh; overflow-y: auto; }
.picker-groupe-lab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #F1F5F9;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  position: sticky;
  top: 0;
  cursor: pointer;
}
.picker-groupe-lab input { width: 16px; height: 16px; accent-color: var(--accent); }
.picker-groupe-lab b { flex: 1; }
.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background 0.1s ease;
}
.picker-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.picker-item .ava.sm, .ava.sm {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  flex: 0 0 28px !important;
  aspect-ratio: 1 / 1 !important;
  font-size: 11px !important;
  border-radius: 50% !important;
}
.picker-item:hover { background: var(--surface-subtle); }
.picker-item.actif { background: var(--accent-light); }
.select-trigger {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
}
.select-trigger span:first-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-txt b { font-size: 13px; color: var(--text); }
.picker-txt small { display: block; color: var(--text-muted); font-size: 11.5px; }
.picker-saisie { display: flex; gap: 8px; padding: 6px 16px 10px 52px; }
.picker-saisie .input { max-width: 90px; padding: 6px 8px; }

/* Panneaux de détail */
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.detail-head .dh-photo {
  width: 68px !important;
  height: 68px !important;
  min-width: 68px !important;
  min-height: 68px !important;
  max-width: 68px !important;
  max-height: 68px !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  flex: 0 0 68px !important;
  background-color: var(--surface-subtle);
  border: 2px solid var(--divider);
  overflow: hidden !important;
  box-sizing: border-box !important;
}
.detail-head .dh-photo.clic {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.detail-head .dh-photo.clic:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  border-color: var(--accent);
}
.detail-head .dh-photo.clic .dh-photo-zoom {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  opacity: 0;
  transition: opacity 0.16s ease;
  border-radius: inherit;
}
.detail-head .dh-photo.clic .dh-photo-zoom .material-symbols-rounded {
  font-size: 24px;
}
.detail-head .dh-photo.clic:hover .dh-photo-zoom {
  opacity: 1;
}
.detail-head .dh-photo.ph {
  display: grid;
  place-items: center;
  color: #B45309;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
}
.detail-head .dh-photo.ph .material-symbols-rounded { font-size: 32px; }
.detail-head h3 { margin: 0; font-size: 19px; font-weight: 600; color: var(--text); }
.detail-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.info-item .v { font-size: 13.5px; font-weight: 500; color: var(--text); }

.bar { height: 6px; border-radius: var(--r-pill); background: #F1F5F9; overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-pill); transition: width 0.3s ease; }

.person-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.person-row:last-child { border-bottom: 0; }
.person-row b { font-size: 13.5px; color: var(--text); }
.person-row small { display: block; color: var(--text-muted); font-size: 12px; }

/* Toasts de notification */
#toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  animation: pop 0.18s ease;
  max-width: 90vw;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.toast.ok { background: #065F46; border-color: #059669; }
.toast.err { background: #991B1B; border-color: #DC2626; }

/* Lightbox / visionneuse d'image plein écran */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.18s ease;
  cursor: zoom-out;
}
.lightbox.open {
  opacity: 1;
}
.lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  cursor: default;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox.open img {
  transform: scale(1);
}
.lightbox .ferme {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 26px;
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  z-index: 10;
}
.lightbox .ferme:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
}

/* ----------------------- Configuration des Rôles & Accès -------------- */
.role-cfg-box {
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 24px;
}

.role-cfg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 18px;
}

.role-cfg-select-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.role-cfg-select-wrap label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.role-sec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.role-sec-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.role-sec-card:hover {
  border-color: #CBD5E1;
  background: #F8FAFC;
  transform: translateY(-1px);
}

.role-sec-card.actif {
  border-color: var(--accent);
  background: var(--accent-light);
}

.role-sec-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin-top: 2px;
  cursor: pointer;
  flex: 0 0 18px;
}

.role-sec-card .sec-ic {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
  display: grid;
  place-items: center;
  color: var(--text-2);
  flex: 0 0 32px;
}

.role-sec-card.actif .sec-ic {
  background: #FFFFFF;
  color: #D97706;
}

.role-sec-card .sec-txt {
  flex: 1 1 auto;
  min-width: 0;
}

.role-sec-card .sec-txt b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.role-sec-card .sec-txt small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.role-cfg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

.matrice-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--divider);
  background: #FFFFFF;
  box-shadow: var(--shadow-xs);
  margin-top: 16px;
}

/* ---------------- Toggle Switch & Sous-formulaires intégrés ---------------- */
.switch-block {
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  background: #FFFFFF;
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.switch-block.active {
  border-color: var(--accent-border);
  box-shadow: 0 2px 8px rgba(233, 178, 77, 0.12);
}
.switch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  background: #F8FAFC;
  transition: background 0.15s ease;
}
.switch-block.active .switch-header {
  background: var(--accent-light);
  border-bottom: 1px solid var(--accent-border);
}
.switch-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.switch-title .material-symbols-rounded {
  font-size: 20px;
  color: #B45309;
}
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #CBD5E1;
  border-radius: 999px;
  transition: background-color 0.2s ease;
}
.switch-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.switch-toggle input:checked + .switch-slider {
  background-color: var(--accent);
}
.switch-toggle input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch-subform {
  padding: 14px;
  background: #FFFFFF;
  display: none;
}
.switch-block.active .switch-subform {
  display: block;
}

/* Section multi-lignes Parcours académiques */
.parcours-section {
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  background: #F8FAFC;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.parcours-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.parcours-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.parcours-section-title .material-symbols-rounded {
  font-size: 20px;
  color: #B45309;
}
.parcours-row-card {
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
  box-shadow: var(--shadow-xs);
}
.parcours-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.parcours-row-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #B45309;
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* ------------------------------ Responsive ----------------------------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 80;
    display: none;
  }
  .scrim.open { display: block; }
  .topbar { padding: 12px 18px; }
  .topbar .burger { display: grid; }
  .content { padding: 18px 16px 90px; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .qa-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .qa { font-size: 10.5px; padding: 14px 8px; }

  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 70;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--divider);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.04);
    padding: 6px 4px;
    justify-content: space-around;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 0;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    transition: color 0.15s ease;
  }
  .bottomnav a .material-symbols-rounded { font-size: 22px; }
  .bottomnav a.active { color: #B45309; }
  .bottomnav a:nth-child(n+6) { display: none !important; }

  .page-panel { max-width: 100%; border-left: 0; }

  .modal-back { align-items: flex-end; padding: 0; }
  .modal, .modal.lg {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: sheet 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal header { position: relative; padding-top: 24px; flex: 0 0 auto; }
  .modal header::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: var(--r-pill);
    background: #CBD5E1;
  }
  .modal .body { overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
  .modal footer { flex: 0 0 auto; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .modal footer .btn { flex: 1; }
}

@media (max-width: 560px) {
  .qa-grid { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
}

/* ---------------- Sélecteur de jours (Hebdomadaire) & Cadence ---------------- */
.cadence-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media (max-width: 640px) {
  .cadence-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.cadence-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--divider);
  background: #FFFFFF;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
}
.cadence-pill .material-symbols-rounded {
  font-size: 20px;
  color: var(--text-muted);
  transition: color 0.16s ease;
}
.cadence-pill:hover {
  border-color: var(--accent-border);
  background: #FFFBEB;
  color: var(--text);
}
.cadence-pill.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: #92400E;
  box-shadow: 0 2px 6px rgba(233, 178, 77, 0.2);
}
.cadence-pill.active .material-symbols-rounded {
  color: #D97706;
}

.days-picker-card {
  border: 1.5px solid var(--accent-border);
  border-radius: var(--r-md);
  background: #FFFDF7;
  padding: 14px;
  margin-top: 4px;
  animation: subformFade 0.18s ease;
}
.days-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.days-picker-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.days-picker-title .material-symbols-rounded {
  font-size: 18px;
  color: #D97706;
}
.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
@media (max-width: 640px) {
  .days-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--divider);
  background: #FFFFFF;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  transition: all 0.15s ease;
}
.day-pill:hover {
  border-color: var(--accent-border);
  background: #FFFBEB;
  transform: translateY(-1px);
}
.day-pill .day-short {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.day-pill .day-full {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.day-pill .day-check {
  font-size: 16px;
  color: #CBD5E1;
  transition: all 0.15s ease;
}
.day-pill.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--primary-text);
  box-shadow: 0 3px 8px rgba(233, 178, 77, 0.32);
}
.day-pill.selected .day-full {
  color: #451A03;
  font-weight: 600;
}
.day-pill.selected .day-check {
  color: var(--primary-text);
}

/* ---------------- Couverture Évangélisation (Chambres & Classes) ---------------- */
.annee-scolaire-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: all 0.15s ease;
}
.annee-scolaire-btn:hover {
  border-color: var(--accent);
  background: #FFFDF7;
  color: #B45309;
}
.annee-scolaire-btn .material-symbols-rounded {
  font-size: 18px;
  color: var(--text-muted);
}
.annee-scolaire-btn:hover .material-symbols-rounded {
  color: #D97706;
}

.couverture-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.couverture-switch {
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--divider);
  padding: 3px;
  border-radius: var(--r-sm);
  gap: 4px;
}
.couverture-switch-btn {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--r-xs);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.couverture-switch-btn:hover {
  color: var(--text);
}
.couverture-switch-btn.active {
  background: #FFFFFF;
  color: #B45309;
  box-shadow: var(--shadow-xs);
}
.couverture-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.couverture-kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 12px;
}
.couverture-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-xs);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.couverture-kpi-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.couverture-kpi-lbl {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.couverture-section {
  background: #FFFFFF;
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.couverture-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.couverture-section-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.couverture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.tile-cell {
  background: #FFFFFF;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-sm);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  transition: all 0.14s ease;
  min-height: 62px;
  position: relative;
  text-align: center;
}
.tile-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.tile-cell .tile-nom {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.tile-cell .tile-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  line-height: 1.2;
}
/* Statuts des tuiles */
.tile-cell.statut-non-visitee {
  border-color: #E2E8F0;
  background: #FAFBFD;
}
.tile-cell.statut-non-visitee .tile-nom {
  color: var(--text-2);
}
.tile-cell.statut-non-visitee .tile-badge {
  background: #F1F5F9;
  color: var(--text-muted);
}
.tile-cell.statut-non-visitee:hover {
  border-color: #CBD5E1;
  background: #FFFFFF;
}
.tile-cell.statut-visitee-1 {
  border-color: #86EFAC;
  background: #F0FDF4;
}
.tile-cell.statut-visitee-1 .tile-nom {
  color: #14532D;
}
.tile-cell.statut-visitee-1 .tile-badge {
  background: #DCFCE7;
  color: #15803D;
  font-weight: 700;
}
.tile-cell.statut-visitee-multi {
  border-color: var(--accent-border);
  background: #FFFBEB;
}
.tile-cell.statut-visitee-multi .tile-nom {
  color: #78350F;
}
.tile-cell.statut-visitee-multi .tile-badge {
  background: var(--accent);
  color: var(--primary-text);
  font-weight: 700;
}

@media (max-width: 520px) {
  .page-panel .form-row,
  .modal .form-row,
  .form-row {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px;
  }
}
