html.demo {
  --banner-h: 40px;
}
@media (max-width: 767px) {
  html.demo {
    --banner-h: 56px;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --sidebar-w: var(--sidebar-rail-w);
  }
}
@media (min-width: 1024px) {
  html.replie {
    --sidebar-w: var(--sidebar-rail-w);
  }
}

/* ---------- Bandeau de démonstration ---------- */
.bandeau-demo {
  position: sticky;
  top: 0;
  z-index: var(--z-demo);
  min-height: var(--banner-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
}
.bandeau-demo .ico {
  flex: none;
}

/* ---------- Coquille ---------- */
.app {
  min-height: calc(100vh - var(--banner-h));
}
.sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  top: var(--banner-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: 72px;
  padding: 0 var(--sp-4) 0 var(--sp-5);
  flex: none;
}
.sidebar nav {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  display: grid;
  align-content: start;
  gap: var(--sp-1);
}
.nav-groupe {
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--h-md);
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--text);
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  translate: 0 -50%;
  width: 3px;
  height: 20px;
  border-radius: 2px;
  background: var(--brand);
  animation: glisse-trait var(--dur-base) var(--ease-standard);
}
@keyframes glisse-trait {
  from {
    transform: translateY(-14px);
    opacity: 0;
  }
}
.nav-item .ico {
  color: var(--text-2);
}
.nav-item[aria-current="page"] .ico {
  color: var(--brand-text);
}
.sidebar-pied {
  flex: none;
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}
.compte-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 52px;
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-md);
  background: none;
  text-align: left;
}
.compte-btn:hover {
  background: var(--surface-2);
}
.compte-btn .qui {
  min-width: 0;
  display: grid;
  line-height: 1.3;
}
.compte-btn .qui strong {
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compte-btn .qui span {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.principal {
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--banner-h));
}
.topbar {
  display: none;
}
.contenu {
  max-width: calc(var(--content-max) + 96px);
  margin-inline: auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-8);
}
@media (min-width: 1440px) {
  .contenu {
    padding-inline: var(--sp-7);
  }
}
.contenu-large {
  max-width: none;
}
.entete-page {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}
.entete-page > div:first-child {
  flex: 1 1 420px;
  min-width: 0;
}
.entete-page > .secret-ligne {
  flex: none;
}
.entete-page p {
  margin-top: var(--sp-1);
  color: var(--text-2);
  max-width: 68ch;
}
.section {
  margin-top: var(--sp-8);
}
.section > h2 {
  margin-bottom: var(--sp-4);
}
.pile {
  display: grid;
  gap: var(--sp-4);
}
.pile-3 {
  display: grid;
  gap: var(--sp-3);
}
.pile-5 {
  display: grid;
  gap: var(--sp-5);
}
.etroit {
  max-width: 720px;
}

/* Rail (tablette) et repliée */
@media (min-width: 768px) and (max-width: 1023px), (min-width: 1024px) {
  html.replie .sidebar-tete .logo-texte,
  html.replie .nav-item .libelle,
  html.replie .nav-groupe,
  html.replie .compte-btn .qui,
  html.replie .compte-btn .ico-fin {
    display: none;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar-tete .logo-texte,
  .nav-item .libelle,
  .nav-groupe,
  .compte-btn .qui,
  .compte-btn .ico-fin,
  .btn-replier {
    display: none;
  }
  .sidebar-tete {
    padding: 0;
    justify-content: center;
  }
  .contenu {
    padding-inline: var(--sp-5);
  }
}
@media (min-width: 768px) and (max-width: 1023px), (min-width: 1024px) {
  html.replie .sidebar-tete {
    padding: 0;
    justify-content: center;
    flex-direction: column;
    height: auto;
    padding-block: var(--sp-4);
  }
}
.nav-item[data-tip]:hover::after,
.nav-item[data-tip]:focus-visible::after {
  display: none;
}
@media (min-width: 768px) and (max-width: 1023px) {
  .nav-item[data-tip]:hover::after,
  .nav-item[data-tip]:focus-visible::after {
    display: block;
  }
}
.nav-item[data-tip]::after {
  content: attr(data-tip);
  position: fixed;
  left: calc(var(--sidebar-rail-w) - 4px);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: var(--z-toast);
  display: none;
}
html.replie .nav-item[data-tip]:hover::after,
html.replie .nav-item[data-tip]:focus-visible::after {
  display: block;
}

/* Mobile : barre haute et tiroir */
@media (max-width: 767px) {
  .principal {
    margin-left: 0;
  }
  .topbar {
    position: sticky;
    top: var(--banner-h);
    z-index: var(--z-topbar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    height: var(--topbar-h);
    padding: 0 var(--sp-2);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
  }
  .sidebar {
    top: 0;
    width: min(84vw, 320px);
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 250ms var(--ease-out),
      visibility 250ms;
    box-shadow: none;
  }
  .sidebar.ouvert {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-pop);
  }
  .sidebar .btn-replier {
    display: none;
  }
  .voile-tiroir {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-drawer) - 1);
    background: var(--overlay);
    animation: apparait var(--dur-base) var(--ease-out);
  }
  .contenu {
    padding: var(--sp-5) var(--sp-4) var(--sp-7);
  }
  .sidebar-tete {
    height: 64px;
  }
}
@media (min-width: 768px) {
  .voile-tiroir {
    display: none;
  }
}

/* ---------- Logo ---------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.logo img {
  max-height: 40px;
  max-width: 160px;
  object-fit: contain;
}
.logo .logo-img {
  display: block;
  height: 32px;
  width: auto;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
}
.logo .logo-fonce,
.logo .logo-picto:not(.logo-picto-seul) {
  display: none;
}
:root[data-theme="dark"] .logo .logo-clair {
  display: none;
}
:root[data-theme="dark"] .logo .logo-fonce {
  display: block;
}
.logo .logo-picto {
  height: 32px;
  width: 32px;
}
@media (min-width: 768px) {
  html.replie .sidebar-tete .logo .logo-complet {
    display: none;
  }
  html.replie .sidebar-tete .logo .logo-picto {
    display: block;
  }
}
.logo-marque {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 22%;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1;
}
:root[data-theme="dark"] .logo-marque {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.logo-marque b {
  font-weight: 500;
  color: var(--brand);
}
.logo-texte {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logo-texte b {
  font-weight: 500;
  color: var(--brand-text);
}
.logo-blanc {
  color: #fff;
}
.logo-blanc .logo-texte b {
  color: var(--brand);
}
.logo-blanc .logo-marque {
  background: rgb(255 255 255 / 12%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 25%);
}

/* ---------- Bannière (repli CSS ou image configurable) ---------- */
.banniere {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(60% 80% at 100% 100%, rgb(62 111 183 / 35%), transparent 70%),
    radial-gradient(rgb(255 255 255 / 6%) 2px, transparent 2px) 0 0 / 24px 24px,
    #0a1828;
  background-color: var(--ink);
}
.banniere::before {
  /* Vagues de la charte, en repli sans image */
  content: "";
  position: absolute;
  z-index: -1;
  left: 5%;
  right: -5%;
  bottom: -28%;
  height: 60%;
  background: var(--brand);
  opacity: 0.16;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  filter: blur(1px);
}
.banniere::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(90deg, rgb(10 24 40 / 85%), rgb(10 24 40 / 35%));
}
.banniere-image {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--banner-focal, 70% 40%);
}
.banniere .surtitre {
  font-size: var(--fs-sm);
  opacity: 0.85;
}
.accueil-banniere {
  min-height: 240px;
  padding: var(--sp-7) var(--sp-6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-3);
  border-radius: var(--r-xl);
}
.accueil-banniere h1 {
  font-size: var(--fs-display);
  line-height: 1.1;
}
.accueil-banniere p {
  font-size: var(--fs-body);
  opacity: 0.9;
}
@media (max-width: 767px) {
  .accueil-banniere {
    min-height: 160px;
    padding: var(--sp-5) var(--sp-4);
    border-radius: var(--r-lg);
  }
}
.champ-banniere {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 640px;
  min-height: 56px;
  margin-top: var(--sp-2);
  padding: 5px 5px 5px var(--sp-5);
  border-radius: var(--r-pill);
  background: rgb(10 24 40 / 72%);
  border: 1px solid rgb(255 255 255 / 30%);
  box-shadow: 0 8px 40px rgb(0 0 0 / 35%);
  backdrop-filter: blur(8px);
}
.champ-banniere:focus-within {
  border-color: #fff;
}
.champ-banniere input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: #fff;
  min-height: 44px;
}
.champ-banniere input::placeholder {
  color: rgb(255 255 255 / 78%);
}
.champ-banniere input:focus-visible {
  outline: none;
}
.champ-banniere .btn {
  flex: none;
}

/* ---------- Grille de modules ---------- */
.grille-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
}
.carte-module {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-height: 168px;
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  color: var(--text);
  text-decoration: none;
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}
.carte-module:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.carte-module p {
  color: var(--text-2);
  font-size: var(--fs-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.carte-module .pied {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--link);
}
.carte-module .pied .ico {
  transition: transform var(--dur-base) var(--ease-out);
}
.carte-module:hover .pied .ico {
  transform: translateX(4px);
}
.carte-module .badge {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
}
.carte-module.entree {
  animation: entree-carte 240ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
@keyframes entree-carte {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .carte-module.entree {
    animation: none;
  }
  .nav-item[aria-current="page"]::before {
    animation: none;
  }
}
.carte-squelette {
  min-height: 168px;
  border-radius: var(--r-lg);
}

/* ---------- Connexion ---------- */
.connexion {
  display: grid;
  grid-template-columns: minmax(480px, 46%) 1fr;
  min-height: calc(100vh - var(--banner-h));
}
.connexion-form {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: var(--sp-7) var(--sp-5);
  background: var(--surface);
}
.connexion-form .contenu-form {
  width: min(380px, 100%);
  display: grid;
  gap: var(--sp-5);
}
.connexion-form h1 {
  font-size: 2rem;
}
.connexion-form form {
  display: grid;
  gap: var(--sp-4);
}
.connexion-form .signature {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.separateur-ou {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.separateur-ou::before,
.separateur-ou::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}
.lien-oublie {
  justify-self: end;
  font-size: var(--fs-sm);
  min-height: 24px;
}
.connexion-banniere {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--sp-7) var(--sp-7) 0;
  min-height: 100%;
}
.connexion-banniere .tagline {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: 1.1;
  letter-spacing: -0.01em;
  max-width: 14em;
  margin-top: auto;
  padding-bottom: var(--sp-7);
  animation: entre-banniere var(--dur-reveal) var(--ease-out);
}
@keyframes entre-banniere {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
}
.bande-confiance {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  align-items: center;
  min-height: 52px;
  margin: 0 calc(-1 * var(--sp-7));
  padding: var(--sp-3) var(--sp-7);
  background: rgb(10 24 40 / 55%);
  border-top: 1px solid rgb(255 255 255 / 14%);
  font-size: var(--fs-sm);
}
.bande-confiance li {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
@media (max-width: 767px) {
  .connexion {
    grid-template-columns: 1fr;
    grid-template-rows: 160px 1fr;
  }
  .connexion-banniere {
    order: -1;
    padding: var(--sp-5) var(--sp-4);
    min-height: 160px;
  }
  .connexion-banniere .tagline,
  .bande-confiance {
    display: none;
  }
  .connexion-form {
    align-content: start;
    padding-top: var(--sp-6);
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .connexion {
    grid-template-columns: minmax(400px, 50%) 1fr;
  }
  .connexion-banniere {
    padding-inline: var(--sp-5);
  }
  .bande-confiance {
    margin-inline: calc(-1 * var(--sp-5));
    padding-inline: var(--sp-5);
  }
}
.page-centree {
  min-height: calc(100vh - var(--banner-h));
  display: grid;
  place-items: center;
  padding: var(--sp-5);
}
.page-centree .carte {
  width: min(460px, 100%);
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-6);
}

/* ---------- Back-office ---------- */
.admin {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}
.sous-nav {
  position: sticky;
  top: calc(var(--banner-h) + var(--sp-5));
  display: grid;
  gap: var(--sp-1);
}
.sous-nav h2 {
  font-family: var(--font-text);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  padding: var(--sp-4) var(--sp-3) var(--sp-1);
}
.sous-nav h2:first-child {
  padding-top: 0;
}
.sous-nav a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
}
.sous-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sous-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
}
@media (max-width: 899px) {
  .admin {
    grid-template-columns: 1fr;
    gap: var(--sp-4);
  }
  .sous-nav {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border);
  }
  .sous-nav h2 {
    display: none;
  }
  .sous-nav a {
    white-space: nowrap;
    border-radius: var(--r-pill);
  }
}
.form-bloc {
  display: grid;
  gap: var(--sp-5);
  max-width: 720px;
}
.form-bloc + .form-bloc {
  margin-top: var(--sp-7);
}
.form-bloc > h2 {
  font-size: var(--fs-h2);
}
.avec-barre {
  padding-bottom: 96px;
}

/* Matrice de droits */
.matrice-cadre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: auto;
  max-height: 70vh;
}
.matrice {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: var(--fs-sm);
}
.matrice th,
.matrice td {
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}
.matrice thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  min-width: 132px;
  font-size: var(--fs-xs);
}
.matrice tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 240px;
  text-align: left;
  background: var(--surface);
  font-weight: 500;
}
.matrice thead th:first-child {
  left: 0;
  z-index: 3;
  text-align: left;
}
.matrice tr.groupe th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: var(--fs-xs);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.matrice .interrupteur {
  justify-content: center;
}
.matrice .interrupteur .etat-texte {
  display: none;
}
.role-tete {
  display: grid;
  gap: 2px;
  justify-items: center;
}
.role-tete .btn {
  --btn-h: 28px;
  min-height: 28px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-xs);
}
.liste-droits {
  display: grid;
  gap: var(--sp-2);
}
.liste-droits .ligne {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

/* Utilisateurs en cartes (mobile) */
@media (max-width: 767px) {
  .tableau.en-cartes thead {
    display: none;
  }
  .tableau.en-cartes,
  .tableau.en-cartes tbody,
  .tableau.en-cartes tr,
  .tableau.en-cartes td {
    display: block;
  }
  .tableau.en-cartes tr {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    position: relative;
  }
  .tableau.en-cartes td {
    height: auto;
    border: 0;
    padding: var(--sp-1) 0;
  }
  .tableau.en-cartes td[data-libelle]::before {
    content: attr(data-libelle) " : ";
    color: var(--text-3);
    font-size: var(--fs-xs);
  }
  .tableau.en-cartes td.col-actions {
    position: absolute;
    top: var(--sp-2);
    right: var(--sp-2);
    width: auto;
  }
  .tableau.en-cartes td[data-libelle=""]::before {
    content: none;
  }
}
.matrice-mobile {
  display: none;
}
@media (max-width: 767px) {
  .matrice-bureau {
    display: none;
  }
  .matrice-mobile {
    display: grid;
    gap: var(--sp-4);
  }
}

.connexion-form h1 + p {
  margin-top: var(--sp-2);
}
@media (min-width: 768px) {
  .logo-banniere {
    display: none;
  }
}
@media (max-width: 767px) {
  .logo-form {
    display: none;
  }
}
.btn-sso {
  gap: var(--sp-3);
}
.logo-sso {
  width: 18px;
  height: 18px;
  flex: none;
}
