:root {
  --sidebar-width: 264px;
  --sidebar-collapsed-width: 72px;
  --sidebar-bg: #2d1c10;
  --sidebar-bg-2: #150d07;
  --sidebar-text: #d8c9b3;
  --sidebar-text-muted: #96805f;
  --sidebar-active-bg: rgba(240, 147, 43, .18);
  --accent: #f0932b;
  --accent-rgb: 240, 147, 43;
  --accent-dark: #cf7412;
  --accent-light: #ffb35c;
  --success: #24a866;
  --success-rgb: 36, 168, 102;
  --content-bg: #f5f2ec;
  --card-bg: #ffffff;
  --border: #e7e1d6;
  --text: #291f16;
  --text-muted: #766a5a;
  --topbar-bg: #ffffff;
  --shadow: 0 1px 2px rgba(41, 26, 12, .06), 0 2px 6px rgba(41, 26, 12, .05);
  --shadow-md: 0 8px 24px rgba(41, 26, 12, .12);
  --shadow-accent: 0 10px 24px -6px rgba(var(--accent-rgb), .38);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--content-bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Motion (disabled entirely for users who ask for it) -------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Sidebar ------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1030;
  box-shadow: 4px 0 20px rgba(0, 0, 0, .18);
  transition: transform .25s var(--ease), width .25s var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 1.25rem 1.25rem 1rem;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent) 60%, var(--accent-dark));
  box-shadow: 0 4px 12px -2px rgba(var(--accent-rgb), .55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .2s var(--ease);
}
.sidebar-brand:hover .sidebar-brand-icon { transform: rotate(-6deg) scale(1.06); }

.sidebar-brand-icon svg { width: 20px; height: 20px; color: #1a1108; }

.sidebar-brand-text { line-height: 1.15; }
.sidebar-brand-text .name { font-weight: 700; font-size: 1.05rem; color: #fff; display: block; }
.sidebar-brand-text .tagline { font-size: .72rem; color: var(--sidebar-text-muted); letter-spacing: .04em; text-transform: uppercase; }

.sidebar-tenant {
  margin: .25rem 1.25rem 1rem;
  padding: .55rem .75rem;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
  border-left: 3px solid var(--accent);
}
.sidebar-tenant .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sidebar-text-muted); }
.sidebar-tenant .value { font-size: .85rem; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Version cliquable (SuperAdmin : ouvre le selecteur d'organisation #tenantModal). */
button.sidebar-tenant {
  display: block;
  width: calc(100% - 2.5rem);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
button.sidebar-tenant:hover { background: rgba(255, 255, 255, .09); transform: translateY(-1px); }

/* Meme cadre visuel que .sidebar-tenant, en <button> cliquable (ouvre le
   selecteur de campagne) quand l'utilisateur a le droit de la changer -
   sinon rendu en simple <div> non interactive (cf. _Layout.cshtml). */
.sidebar-campagne {
  display: block;
  width: calc(100% - 2.5rem);
  margin: .75rem 1.25rem 0;
  padding: .55rem .75rem;
  border-radius: .6rem;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
  border-left: 3px solid #22c55e;
  text-align: left;
  cursor: default;
}
button.sidebar-campagne { cursor: pointer; transition: background-color .15s var(--ease), transform .15s var(--ease); }
button.sidebar-campagne:hover { background: rgba(255, 255, 255, .09); transform: translateY(-1px); }
.sidebar-campagne .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--sidebar-text-muted); }
.sidebar-campagne .value { font-size: .85rem; color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-tenant-logo {
  display: block;
  box-sizing: border-box;
  /* Deborde des paddings horizontaux de .sidebar-tenant (.75rem de chaque
     cote) pour occuper toute la largeur du menu, pas seulement celle
     disponible a l'interieur du cadre "Tenant actif". */
  width: calc(100% + 1.5rem);
  margin: .5rem -.75rem 0;
  height: auto;
  border-radius: .35rem;
  background: #fff;
  padding: .4rem .6rem;
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: .25rem .75rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 999px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.nav-group { animation: fadeIn .4s var(--ease) both; }
.nav-group + .nav-group { margin-top: 1.1rem; }

.nav-group-title {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  padding: 0 .6rem;
  margin-bottom: .4rem;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .6rem;
  border-radius: .55rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .89rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin-bottom: .15rem;
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease), border-color .15s var(--ease);
}

.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; transition: opacity .15s ease, transform .15s var(--ease); }

.sidebar-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  transform: translateX(3px);
}
.sidebar-link:hover svg { opacity: 1; transform: scale(1.08); }

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .12);
}
.sidebar-link.active svg { opacity: 1; color: var(--accent-light); }

.sidebar-link.disabled {
  cursor: default;
  opacity: .5;
  pointer-events: none;
}

.soon-badge {
  margin-left: auto;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: .1rem .45rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.sidebar-footer {
  padding: .9rem 1.25rem;
  font-size: .72rem;
  color: var(--sidebar-text-muted);
  border-top: 1px solid rgba(255, 255, 255, .06);
}

/* --- Main / topbar --------------------------------------------------- */

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left .25s var(--ease);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: .3rem;
  color: var(--text);
  cursor: pointer;
  border-radius: .4rem;
  transition: background-color .15s ease, transform .15s ease;
}
.sidebar-toggle:hover { background: var(--content-bg); transform: scale(1.06); }
.sidebar-toggle svg { width: 22px; height: 22px; }

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  flex: 1 1 auto;
}

.topbar-tenant-badge {
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: rgba(var(--accent-rgb), .12);
  border: 1px solid rgba(var(--accent-rgb), .22);
  border-radius: 999px;
  padding: .3rem .7rem;
  white-space: nowrap;
  transition: background-color .15s ease;
}

.user-menu { position: relative; }

.user-chip {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: none;
  border: none;
  padding: .3rem .4rem;
  border-radius: .6rem;
  cursor: pointer;
  transition: background-color .15s ease;
}
.user-chip:hover { background: var(--content-bg); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
  color: #1a1108;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px -2px rgba(var(--accent-rgb), .55);
  transition: transform .15s var(--ease);
}
.user-chip:hover .user-avatar { transform: scale(1.06); }

.user-name { font-size: .87rem; font-weight: 600; color: var(--text); }

.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: .7rem;
  box-shadow: var(--shadow-md);
  padding: .4rem;
  animation: fadeInUp .16s var(--ease) both;
}
.dropdown-item {
  border-radius: .45rem;
  padding: .5rem .65rem;
  font-size: .88rem;
  transition: background-color .12s ease;
}
.dropdown-item:hover, .dropdown-item:focus { background-color: rgba(var(--accent-rgb), .1); color: var(--text); }

.content {
  padding: 1.5rem;
  flex: 1 1 auto;
}

.content-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: .9rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  /* "backwards" et NON "both" : avec "both", la derniere image-cle de fadeInUp
     (transform: translateY(0)) reste appliquee apres l'animation, ce qui fait de
     chaque carte un contexte d'empilement. Le menu d'un select recherchable
     (.ss-menu, z-index 1050) reste alors prisonnier de la carte du filtre et la
     carte suivante (le tableau) le recouvre. Sans delai, "backwards" est
     visuellement identique ; l'etat final est celui de la feuille de style
     (transform: none). */
  animation: fadeInUp .35s var(--ease) backwards;
  transition: box-shadow .2s ease;
}

/* --- Table / form polish --------------------------------------------- */

.content-card .table { margin-bottom: 0; }
.content-card table thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  font-weight: 700;
}
.content-card table td { vertical-align: middle; }
.content-card table tbody tr { transition: background-color .15s ease; }
.content-card table tbody tr:hover { background-color: rgba(var(--accent-rgb), .055); }

.btn {
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px -2px rgba(var(--accent-rgb), .5);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-accent);
}
.btn-outline-primary { color: var(--accent-dark); border-color: var(--accent); }
.btn-outline-primary:hover { background-color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

.btn-outline-secondary:hover, .btn-outline-danger:hover, .btn-outline-success:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Anneau de focus assorti a la palette (remplace le bleu par defaut de site.css) */
.form-control:focus, .form-select:focus, .form-check-input:focus,
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(var(--accent-rgb), .25) !important;
}

.form-control, .form-select {
  transition: border-color .15s ease, box-shadow .15s ease;
}

/* --- Select rechercables (wwwroot/js/searchable-select.js) ------------ */

.ss-wrap { position: relative; }
.ss-native { display: none !important; }
.ss-input { cursor: text; }
.ss-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  margin: .25rem 0 0;
  padding: .25rem 0;
  max-height: 15rem;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: .6rem;
  box-shadow: var(--shadow-md);
  list-style: none;
}
.ss-option {
  padding: .45rem .85rem;
  cursor: pointer;
  font-size: .95rem;
}
.ss-option:hover, .ss-option.ss-active { background: rgba(var(--accent-rgb), .12); }
.ss-option.ss-selected { font-weight: 600; color: var(--accent-dark); }
.ss-empty { padding: .45rem .85rem; color: var(--text-muted); font-style: italic; }

/* --- Alerts ------------------------------------------------------------ */

.alert {
  border: 1px solid transparent;
  border-radius: .7rem;
  /* "backwards" (pas "both") : meme raison que .content-card - evite un contexte
     d'empilement permanent qui recouvrirait un menu deroulant ouvert plus haut. */
  animation: fadeInUp .3s var(--ease) backwards;
}
.alert-success { background: rgba(var(--success-rgb), .12); border-color: rgba(var(--success-rgb), .25); color: #16653f; }
.alert-danger { background: rgba(220, 53, 69, .1); border-color: rgba(220, 53, 69, .22); }
.alert-warning { background: rgba(var(--accent-rgb), .14); border-color: rgba(var(--accent-rgb), .28); color: #7a4a0c; }

/* --- Dashboard stat cards --------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: .9rem;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  display: block;
  animation: fadeInUp .4s var(--ease) both;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s ease;
}
.stat-grid .stat-card:nth-child(1) { animation-delay: .02s; }
.stat-grid .stat-card:nth-child(2) { animation-delay: .08s; }
.stat-grid .stat-card:nth-child(3) { animation-delay: .14s; }
.stat-grid .stat-card:nth-child(4) { animation-delay: .2s; }

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), .35);
  color: inherit;
}

.stat-card .icon {
  width: 40px;
  height: 40px;
  border-radius: .65rem;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), .18), rgba(var(--accent-rgb), .08));
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .75rem;
  transition: transform .2s var(--ease), background .2s ease;
}
.stat-card:hover .icon { transform: scale(1.1) rotate(-4deg); background: linear-gradient(135deg, rgba(var(--accent-rgb), .3), rgba(var(--accent-rgb), .14)); }
.stat-card .icon svg { width: 20px; height: 20px; }
.stat-card .label { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.stat-card .hint { font-size: .78rem; color: var(--text-muted); margin-top: .15rem; }

/* --- Menu "Accès rapide" en tuiles (bas du tableau de bord, Views/Home/_Lanceur.cshtml)
   --tile-color est pose par groupe (style inline). Animation en "backwards" (pas
   "both") : aucun transform ne doit rester applique apres l'animation, sinon le
   survol (translateY) serait ignore et un contexte d'empilement permanent cree. */

.launcher-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .75rem; margin-bottom: 1rem; }
/* Bouton "Retour à l'accès rapide" en tete de l'index des fonctionnalites du menu en tuiles (_Layout.cshtml). */
.btn-retour-acces-rapide { display: inline-flex; align-items: center; gap: .3rem; margin-bottom: 1rem; }
.btn-retour-acces-rapide svg { width: 16px; height: 16px; }
.launcher-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.launcher-subtitle { font-size: .85rem; color: var(--text-muted); margin: 0; }

.launcher-group + .launcher-group { margin-top: 1.4rem; }
.launcher-group-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 .65rem;
}
.launcher-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tile-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-color) 22%, transparent);
}

.launcher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; }

.launcher-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .85rem 1.5rem .85rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: .9rem;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 600;
  overflow: hidden;
  animation: fadeInUp .35s var(--ease) backwards;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s ease;
}
.launcher-tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tile-color);
  opacity: 0;
  transition: opacity .2s ease;
}
.launcher-tile:hover,
.launcher-tile:focus-visible {
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--tile-color) 45%, var(--border));
}
.launcher-tile:hover::before,
.launcher-tile:focus-visible::before { opacity: 1; }
.launcher-tile:focus-visible { outline: 2px solid var(--tile-color); outline-offset: 2px; }

.launcher-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: .7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tile-color);
  background: color-mix(in srgb, var(--tile-color) 13%, transparent);
  transition: transform .2s var(--ease), background-color .2s ease, color .2s ease;
}
.launcher-icon svg { width: 22px; height: 22px; }
.launcher-tile:hover .launcher-icon,
.launcher-tile:focus-visible .launcher-icon { background: var(--tile-color); color: #fff; transform: scale(1.06) rotate(-4deg); }

.launcher-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.25;
  /* Mot unique long ("Approvisionnements") : cesure plutot que debordement. */
  hyphens: auto;
  overflow-wrap: break-word;
}
.launcher-arrow {
  position: absolute;
  right: .55rem;
  top: calc(50% - 8px);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--tile-color);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .2s ease, transform .2s var(--ease);
}
.launcher-tile:hover .launcher-arrow,
.launcher-tile:focus-visible .launcher-arrow { opacity: 1; transform: none; }

@media (max-width: 575.98px) {
  .launcher-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* --- Actions de ligne des pages Index : menu deroulant "Actions" -----
   (.row-actions, cf. wwwroot/js/site.js pour le positionnement "fixed" qui
   evite que le menu soit coupe par .table-responsive). Masque quand aucune
   action n'est autorisee pour la ligne (habilitations). */

.row-actions { display: inline-block; }
.row-actions:not(:has(.dropdown-item)) { display: none; }
.row-actions-toggle { display: inline-flex; align-items: center; gap: .35rem; }
.row-actions-toggle svg { width: 16px; height: 16px; }
.row-actions .dropdown-menu {
  /* Fondu d'opacite seul : l'animation generique .dropdown-menu (fadeInUp,
     "both") garde un transform qui ecraserait le translate() calcule par
     Popper (une animation l'emporte sur le style inline) - le menu,
     positionne en "fixed", se retrouverait en haut a gauche de l'ecran. */
  animation: fadeIn .16s ease both;
  min-width: 11rem;
  padding: .35rem;
  font-size: .875rem;
  border: 1px solid var(--border);
  border-radius: .65rem;
  box-shadow: var(--shadow-md);
}
.row-actions .dropdown-item { border-radius: .4rem; padding: .42rem .75rem; }
.row-actions .dropdown-item:hover,
.row-actions .dropdown-item:focus { background: rgba(var(--accent-rgb), .1); color: var(--text); }
.row-actions .dropdown-item:active { background: rgba(var(--accent-rgb), .2); color: var(--text); }
.row-actions .dropdown-item.text-danger:hover,
.row-actions .dropdown-item.text-danger:focus { background: rgba(220, 53, 69, .08); color: #b02a37 !important; }
.row-actions form { margin: 0; }
.row-actions-danger:not(:first-child) { border-top: 1px solid var(--border); margin-top: .3rem; padding-top: .3rem; }

/* --- Graphes du tableau de bord (Chart.js, wwwroot/js/dashboard-charts.js) */

.chart-wrap { position: relative; height: 260px; }
.chart-wrap-wide { height: 300px; }

/* --- Overlay for mobile sidebar --------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 5, .45);
  backdrop-filter: blur(1px);
  z-index: 1025;
  animation: fadeIn .2s ease both;
}

/* --- Menu lateral reduit (ecran large, js/sidebar-toggle.js) ---------- */
/* Icones seules : libelles, titres de groupe, cadres campagne/organisation
   et pied masques ; le libelle reste disponible en infobulle (title). */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
  body.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed-width); }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .sidebar-brand-text,
  body.sidebar-collapsed .nav-group-title,
  body.sidebar-collapsed .sidebar-link span,
  body.sidebar-collapsed .sidebar-campagne,
  body.sidebar-collapsed .sidebar-tenant,
  body.sidebar-collapsed .sidebar-footer { display: none; }
  body.sidebar-collapsed .sidebar-nav { padding-left: .5rem; padding-right: .5rem; }
  body.sidebar-collapsed .nav-group + .nav-group {
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  body.sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }
  body.sidebar-collapsed .sidebar-link:hover { transform: none; }
}

/* Etiquette flottante du mode reduit (creee par js/sidebar-toggle.js,
   position fixe calculee sur l'icone survolee, masquee via l'attribut
   hidden - le fondu d'apparition rejoue a chaque affichage). */
.sidebar-flyout {
  position: fixed;
  z-index: 1080;
  transform: translate(0, -50%);
  pointer-events: none;
  padding: .5rem .85rem;
  border-radius: .5rem;
  background: var(--sidebar-bg-2);
  border-left: 3px solid var(--accent);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  animation: sidebarFlyoutIn .12s var(--ease);
}
@keyframes sidebarFlyoutIn {
  from { opacity: 0; transform: translate(-6px, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}
.sidebar-flyout::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--accent);
}
.sidebar-flyout.active { color: var(--accent-light); }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .app-main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; align-items: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* Voile de chargement (form-loader.js) : bloque les clics pendant l'envoi
   d'un formulaire ou le chargement d'un rapport. */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(41, 31, 22, .35);
  cursor: progress;
}
.page-loader[hidden] {
  display: none;
}
.page-loader-box {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-radius: .75rem;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-weight: 500;
}
.page-loader-box .spinner-border {
  color: var(--accent);
}

/* Assistant support (2026-09-30) : bulle flottante + panneau de guide des
   fonctionnalites de l'Acces rapide (assistant.js, Views/Assistant/_Contenu).
   z-index sous les modales Bootstrap (1055) et le voile de chargement (2000). */
.assistant-toggle {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  width: 3.25rem;
  height: 3.25rem;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow-accent);
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s var(--ease);
}
.assistant-toggle:hover { background: var(--accent-dark); transform: translateY(-2px); }
.assistant-toggle:focus-visible { outline: 3px solid rgba(var(--accent-rgb), .45); outline-offset: 2px; }
.assistant-toggle.ouvert { background: var(--accent-dark); }
.assistant-toggle svg { width: 1.5rem; height: 1.5rem; }

.assistant-panel {
  position: fixed;
  right: 1.25rem;
  bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 1040;
  width: 24rem;
  max-width: calc(100vw - 2rem);
  max-height: min(34rem, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  border-radius: .9rem;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.assistant-panel[hidden] { display: none; }

.assistant-entete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1rem;
  color: #fff;
  background: linear-gradient(160deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
}
.assistant-titre { font-weight: 600; }
.assistant-sous-titre { font-size: .8rem; color: var(--sidebar-text); }

.assistant-corps {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  font-size: .9rem;
}
.assistant-chargement { color: var(--text-muted); }
.assistant-intro {
  margin-bottom: .75rem;
  padding: .6rem .75rem;
  border-radius: .6rem;
  background: rgba(var(--accent-rgb), .1);
}
.assistant-page { margin-bottom: .6rem; font-size: .85rem; }
.assistant-page-label { color: var(--text-muted); margin-right: .25rem; }
.assistant-recherche { margin-bottom: .75rem; }

.assistant-groupe { margin-bottom: .6rem; }
.assistant-groupe-titre {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .5rem 0 .25rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
}
.assistant-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .4rem .5rem;
  border: none;
  border-radius: .5rem;
  background: none;
  color: var(--text);
  text-align: left;
}
.assistant-item:hover, .assistant-item:focus-visible { background: rgba(var(--accent-rgb), .1); outline: none; }
.assistant-item[hidden], .assistant-groupe[hidden] { display: none; }
.assistant-item-icone {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .45rem;
  color: var(--tile-color, var(--accent));
  background: color-mix(in srgb, var(--tile-color, var(--accent)) 14%, transparent);
}
.assistant-item-icone svg { width: 1.1rem; height: 1.1rem; }

.assistant-lien {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-dark);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.assistant-retour { margin-bottom: .75rem; font-size: .85rem; }
.assistant-fiche-titre {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: .6rem;
}
.assistant-fiche h4 {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  margin: .9rem 0 .35rem;
}
.assistant-fiche ol, .assistant-fiche ul { padding-left: 1.2rem; margin-bottom: .75rem; }
.assistant-fiche li { margin-bottom: .3rem; }

@media (max-width: 575.98px) {
  .assistant-toggle { right: 1rem; }
  .assistant-panel { right: 1rem; left: 1rem; width: auto; max-width: none; }
}
@media print {
  .assistant-toggle, .assistant-panel { display: none !important; }
}
/* Cloche des operations en attente de validation (2026-09-30) :
   notifications.js, Views/Notifications/_EnAttente.cshtml. */
.notif-bouton { position: relative; color: var(--text-muted); }
.notif-bouton svg { width: 20px; height: 20px; }
.notif-cloche.notif-active .notif-bouton { color: var(--accent-dark); }
.notif-pastille {
  position: absolute;
  top: -.1rem;
  right: -.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 .3rem;
  border-radius: .6rem;
  background: #d9480f;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
  box-shadow: 0 0 0 2px var(--topbar-bg);
}
.notif-pastille[hidden] { display: none; }
.notif-menu { width: 20rem; max-width: calc(100vw - 2rem); padding: .4rem 0; }
.notif-entete {
  padding: .35rem 1rem .5rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: .25rem;
}
.notif-vide { padding: .5rem 1rem; color: var(--text-muted); font-size: .9rem; }
.notif-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 1rem; }
.notif-libelle { flex: 1 1 auto; white-space: normal; }
/* Fournisseurs/Index : bloc de statistiques (2026-10-03). Barres = part du
   total, une seule teinte (grandeur, pas d'identite) ; textes en encre
   normale/attenuee, jamais dans la couleur de la barre. */
.fournisseur-stats-entete { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.fournisseur-stats-titre { font-size: 1rem; font-weight: 600; margin: 0; }
.fournisseur-stats-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem 1.5rem; }
.fournisseur-stats-dimension h3 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  margin: 0 0 .4rem;
}
.fournisseur-stats-liste { list-style: none; margin: 0; padding: 0; max-height: 11rem; overflow-y: auto; }
.fournisseur-stats-liste li { margin-bottom: .45rem; }
.fournisseur-stats-ligne { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; }
.fournisseur-stats-libelle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fournisseur-stats-nombre { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.fournisseur-stats-nombre .text-muted { font-weight: 400; }
.fournisseur-stats-barre { height: 4px; margin-top: .2rem; border-radius: 2px; background: var(--border); overflow: hidden; }
.fournisseur-stats-barre span { display: block; height: 100%; border-radius: 2px; background: var(--accent); }

/* Legende des cartes Leaflet (Fournisseurs/CarteMembres). */
.carte-legende {
  padding: .5rem .7rem;
  border-radius: .4rem;
  background: rgba(255, 255, 255, .95);
  box-shadow: var(--shadow);
  font-size: .8rem;
  color: var(--text);
}
.carte-legende-ligne { display: flex; align-items: center; gap: .45rem; line-height: 1.6; }
.carte-legende-point { width: .75rem; height: .75rem; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: 0 0 auto; }
.carte-legende-nombre { margin-left: auto; padding-left: .6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
/* Tableau de bord : tuile "Stock actuel" (2026-10-03) - pastille = couleur
   du produit (meme que dans les graphes), valeur et detail en encre normale. */
.stock-actuel li { display: grid; grid-template-columns: auto 1fr auto; column-gap: .55rem; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.stock-actuel li:last-child { border-bottom: none; }
.stock-actuel-pastille { width: .7rem; height: .7rem; border-radius: 50%; align-self: center; }
.stock-actuel-produit { font-weight: 600; }
.stock-actuel-valeur { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.stock-actuel-detail { grid-column: 2 / 4; font-size: .8rem; }