/* =========================
   VARIABLES
========================= */

:root {
    --accent:       #1e293b;
    --accent-light: #94a3b8;
    --accent-bg:    #f8fafc;
    --accent-hover: #0f172a;
    --surface:      #f8fafc;
    --border:       #e2e8f0;
    --text-muted:   #64748b;
    --font-family:  system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-size:    1rem;
}


/* =========================
   GLOBAL
========================= */

html, body {
    height: 100%;
    margin: 0;
    background: var(--surface);
    font-family: var(--font-family);
    font-size: var(--font-size);
}

#dashboard {
    display: flex;
    height: 100vh;
    overflow: hidden;
}


/* =========================
   SIDEBAR
========================= */

#sidebar {
    width: 220px;
    height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    overflow: hidden;
    flex-shrink: 0;
}

#sidebar.collapsed {
    width: 60px;
}

/* ── Sidebar two-panel system ── */

/* Conteneur des deux panneaux — remplit le reste sous le logo */
.sidebar-panels-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.sidebar-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: inherit;
}

#sidebarPanelGeneral {
    transform: translateX(0);
    opacity: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

#sidebarPanelContextual {
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.panel-contextual #sidebarPanelGeneral {
    transform: translateX(-30%);
    opacity: 0;
    pointer-events: none;
}

#sidebar.panel-contextual #sidebarPanelContextual {
    transform: translateX(0);
}

/* Collapsed mode : panels restent fonctionnels */
#sidebar.collapsed .sidebar-panel {
    overflow: visible;
}

/* Header du panneau contextuel */
.sidebar-panel-header {
    padding: 8px 8px 4px;
    flex-shrink: 0;
}

.sidebar-back-panel-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.8);
    font-size: 0.82rem;
    font-weight: 500;
    padding: 7px 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-back-panel-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar-back-panel-btn i {
    font-size: 0.9rem;
    flex-shrink: 0;
}

#sidebar.collapsed .sidebar-back-panel-btn {
    justify-content: center;
    padding: 7px;
    background: transparent;
}

#sidebar.collapsed .sidebar-back-panel-btn span {
    display: none;
}

/* Dark mode */
.dark .sidebar-back-panel-btn {
    background: rgba(255,255,255,0.06);
}

.dark .sidebar-back-panel-btn:hover {
    background: rgba(255,255,255,0.12);
}

/* Bouton retour vers le panneau contextuel */
#sidebarReturnContextual {
    display: none;
    align-items: center;
    gap: 7px;
    width: calc(100% - 16px);
    margin: 6px 8px 2px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px;
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

#sidebar.has-contextual:not(.panel-contextual) #sidebarReturnContextual {
    display: flex;
}

#sidebarReturnContextual:hover {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

#sidebarReturnContextual .sidebar-return-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.7;
}

#sidebarReturnContextual i:first-child {
    font-size: 0.88rem;
    flex-shrink: 0;
}

#sidebar.collapsed #sidebarReturnContextual {
    width: calc(100% - 12px);
    margin: 6px 6px 2px;
    padding: 6px;
    justify-content: center;
}

#sidebar.collapsed #sidebarReturnContextual span,
#sidebar.collapsed #sidebarReturnContextual .sidebar-return-arrow {
    display: none;
}

/* ── Logo header ── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 6px;
    flex-shrink: 0;
}
.sidebar-logo-img {
    height: 36px;
    width: auto;
    display: block;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
}
.sidebar-logo-text {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffffff 0%, #7dd3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}
#sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 12px 6px;
    gap: 0;
}
#sidebar.collapsed .sidebar-logo-img {
    height: 32px;
}
#sidebar.collapsed .sidebar-logo-text {
    display: none;
}
.mobile-sidebar-logo-img {
    height: 36px;
    width: auto;
    display: block;
    filter: brightness(0) invert(1);
}

#sidebar h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 3px;
    transition: all 0.3s;
}

#sidebar.collapsed h4 span {
    display: none;
}

#sidebar.collapsed h4 i {
    font-size: 1.5rem;
}

#sidebar a {
    color: white;
    text-decoration: none;
    padding: 12px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s, justify-content 0.3s;
    position: relative;
}

#sidebar a i {
    margin-right: 8px;
    transition: margin 0.3s;
}

#sidebar.collapsed a span {
    display: none;
}

#sidebar.collapsed a {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

#sidebar.collapsed a i {
    margin-right: 0;
    font-size: 1.3rem;
}

#sidebar a:hover {
    background: rgba(255,255,255,0.12);
}

/* Tooltip sidebar collapsed */

#sidebar.collapsed a:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-hover);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 2000;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}


/* =========================
   TOPBAR
========================= */

nav.navbar {
    box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,.04);
    border-bottom: none !important;
    background: var(--surface) !important;
    min-height: 52px;
}


/* =========================
   MAIN CONTENT
========================= */

#mainContent {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#mainScroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: clip;
    min-width: 0;
}

.main-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}


/* =========================
   TOOLBAR
========================= */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 3px;
}

/* Groupe « libellé + petit bouton d'action » (ex : nom de site + Partager) */
.btn-inline-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}


/* =========================
   NAV TABS MODERNES
========================= */

.nav-tabs {

    display: flex;
    flex-wrap: nowrap;

    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;

    gap: 6px;
    padding: 6px;

    background: var(--accent-bg);
    border-radius: 12px;
    border-bottom: none;
}

/* scrollbar invisible */

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.nav-tabs .nav-item {
    flex: 0 0 auto;
}

.nav-tabs .nav-link {

    border: none;
    border-radius: 10px;

    padding: 8px 16px;

    color: var(--accent-hover);
    font-weight: 500;

    white-space: nowrap;

    transition: all 0.2s ease;
}

/* hover */

.nav-tabs .nav-link:hover {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    color: var(--accent-hover);
}

/* actif */

.nav-tabs .nav-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}


/* =========================
   CARDS
========================= */

.card-custom {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
    border: 1px solid var(--border);
}


/* =========================
   TITRES DE SECTIONS
========================= */

/* Titre dans la toolbar d'un tableau ou bloc */
.toolbar h5, .toolbar h6 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-hover);
    letter-spacing: -0.01em;
    margin: 0;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
    line-height: 1.3;
}

.toolbar h5 i, .toolbar h6 i {
    color: var(--accent);
    font-size: 1rem;
    margin-right: 0;
}

/* Titres dans card-body (Logo, Description…) */
.card-body h5.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card-body h5.card-title i {
    color: var(--accent);
}

/* Titres de blocs notes/documents */
h5.mb-0 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-hover);
    padding-left: 10px;
    border-left: 3px solid var(--accent);
}

h5.mb-0 i {
    color: var(--accent);
}


/* =========================
   TABLE STYLE
========================= */

.tab-css {

    border-collapse: separate;
    border-spacing: 0;

    border-radius: 10px;
    overflow: hidden;

    box-shadow: 0 2px 8px rgba(0,0,0,0.1);

    font-size: 0.875rem;
}


/* FILTRES */

.tab-css thead tr:first-child th {
    background: color-mix(in srgb, var(--accent-bg) 75%, #e5e7eb);
    color: var(--text-muted);

    font-weight: 500;

    border: 0;
    border-bottom: 1px solid var(--border);

    padding: 5px 8px;
}


/* TITRES */

.tab-css thead tr:last-child th {
    background: color-mix(in srgb, var(--accent-bg) 45%, #cbd5e1);
    color: var(--accent-hover);

    font-weight: 700;
    font-size: 0.76rem;
    text-transform: uppercase !important;
    letter-spacing: 0.06em;

    border: 1px solid var(--border);
    border-bottom: 2px solid var(--accent);

    padding: 8px 8px;
    text-align: center;
}

/* Inputs de filtre dans le thead */
.tab-css thead tr:first-child th input.form-control {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--accent-hover);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tab-css thead tr:first-child th input.form-control:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
    outline: none;
}


/* 3. LE STYLE DES VARIABLES ($rep_, $cou_, etc.) */
.tab-css thead tr th span {
    text-transform: none !important;
    display: block;          /* Force le passage à la ligne */
    font-weight: 400;        /* Moins gras que le titre */
    font-size: 0.85em;       /* Un peu plus petit pour le style */
    color: var(--accent-hover);          /* Un gris foncé légèrement différent */
    padding: 0px;
    margin: 0px;
}

/* BODY */

.tab-css tbody tr {
    transition: all 0.2s ease;
}

.tab-css tbody tr:nth-child(even) {
    background-color: color-mix(in srgb, var(--accent-bg) 55%, #ffffff);
}

.tab-css tbody td {

    vertical-align: middle;
    padding: 6px 4px;

    text-align: center;

    border-bottom: 1px solid var(--border);
}


/* HOVER */

.tab-css tbody tr:hover td {
    background-color: var(--accent-bg) !important;
}


/* =========================
   PAGINATION DATATABLES
========================= */

.dataTables_paginate .page-link,
.tab-css_paginate .page-link {
    background-color: var(--accent-bg) !important;
    color: var(--accent-hover) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    padding: 0.25rem 0.55rem !important;
    min-width: 30px;
    font-size: 0.85rem;
    transition: background 0.15s, color 0.15s;
}

.dataTables_paginate .page-item.active .page-link,
.tab-css_paginate .page-item.active .page-link {
    background-color: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
    font-weight: 600;
}

.dataTables_paginate .page-item:not(.active) .page-link:hover,
.tab-css_paginate .page-item:not(.active) .page-link:hover {
    background-color: var(--accent-light) !important;
    color: #fff !important;
    border-color: var(--accent-light) !important;
}

.dataTables_paginate .page-item.disabled .page-link,
.tab-css_paginate .page-item.disabled .page-link {
    background-color: var(--accent-bg) !important;
    color: var(--border) !important;
    border-color: var(--border) !important;
    opacity: 0.6;
}

.dark .dataTables_paginate .page-link,
.dark .tab-css_paginate .page-link {
    background-color: #1f2937 !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

.dark .dataTables_paginate .page-item.active .page-link,
.dark .tab-css_paginate .page-item.active .page-link {
    background-color: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
}

.dark .dataTables_paginate .page-item:not(.active) .page-link:hover,
.dark .tab-css_paginate .page-item:not(.active) .page-link:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
    border-color: #475569 !important;
}

.dark .dataTables_paginate .page-item.disabled .page-link,
.dark .tab-css_paginate .page-item.disabled .page-link {
    background-color: #111827 !important;
    color: #374151 !important;
    border-color: #1f2937 !important;
}


/* =========================
   DATATABLES FOOTER
========================= */

.dataTables_wrapper .d-flex.mt-2 {
    flex-wrap: wrap;
}


/* =========================
   SIDEBAR LIEN ACTIF
========================= */

#sidebar a.active {
    background: rgba(255,255,255,0.12);
    border-left: 3px solid var(--accent-light);
    padding-left: 9px;
}

#sidebar.collapsed a.active {
    border-left: 3px solid var(--accent-light);
    padding-left: calc(0.75rem - 3px);
}

.sidebar-group-toggle.active {
    background: rgba(255,255,255,0.12);
    border-left: 3px solid var(--accent-light);
    padding-left: 9px;
}

#sidebar.collapsed .sidebar-group-toggle.active {
    border-left: 3px solid var(--accent-light);
    padding-left: calc(0.75rem - 3px);
}


/* =========================
   SIDEBAR CATEGORIES (top-level accordion)
========================= */

.sidebar-category {
  display: flex;
  flex-direction: column;
}

.sidebar-category-toggle {
  background: none;
  border: none;
  color: #fff;
  text-decoration: none;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  gap: 8px;
}

.sidebar-category-toggle:hover {
  background: rgba(255,255,255,0.1);
}

.sidebar-category-toggle i:first-child {
  flex-shrink: 0;
  font-size: 1.05rem;
  opacity: 0.85;
}

.sidebar-category-chevron {
  flex-shrink: 0;
  font-size: 0.7rem;
  margin-left: auto;
  transition: transform 0.25s;
  opacity: 0.5;
}

.sidebar-category-toggle--static .sidebar-category-chevron {
  margin-left: auto;
}

.sidebar-category-drop {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
  background: rgba(0,0,0,0.1);
  border-radius: 0 0 8px 8px;
  margin-bottom: 2px;
}

.sidebar-category-drop.open {
  grid-template-rows: 1fr;
}

.cat-drop-inner {
  overflow: hidden;
  min-height: 0;
}

/* Indent groups inside a category */
.sidebar-category-drop .sidebar-group {
  margin-left: 2px;
}

.sidebar-category-drop .sidebar-group-toggle {
  font-size: 0.88rem;
  font-weight: 400;
  padding: 9px 12px 9px 18px;
}

.sidebar-category-drop .sidebar-group-toggle.active {
  padding-left: 15px;
}

.sidebar-category-drop .sidebar-group-toggle i:first-child {
  font-size: 0.9rem;
}

.sidebar-category-drop .sidebar-group-addlink {
  font-size: 0.8rem;
}

/* Direct links inside a category (Todos, Facturation) */
.sidebar-category-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 9px 18px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.sidebar-category-link i {
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-category-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-category-link.active {
  background: rgba(255,255,255,0.12);
  border-left: 3px solid var(--accent-light);
  padding-left: 15px;
  color: #fff;
}

/* ── Collapsed sidebar ── */
#sidebar.collapsed .sidebar-category-toggle span,
#sidebar.collapsed .sidebar-category-toggle .sidebar-category-chevron {
  display: none;
}

#sidebar.collapsed .sidebar-category-toggle {
  justify-content: center;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  gap: 0;
}

#sidebar.collapsed .sidebar-category-toggle i:first-child {
  font-size: 1.3rem;
}

#sidebar.collapsed .sidebar-category-drop {
  display: none;
}

/* Tooltip for category toggle in collapsed mode */
#sidebar.collapsed .sidebar-category-toggle {
  position: relative;
}

#sidebar.collapsed .sidebar-category-toggle:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-hover);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 2000;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  pointer-events: none;
}


/* =========================
   SIDEBAR ACCORDION GROUPES
========================= */

.sidebar-group {
    display: flex;
    flex-direction: column;
}

/* Ligne header = toggle + bouton + */
.sidebar-group-header {
    display: flex;
    align-items: stretch;
}

.sidebar-group-header .sidebar-group-toggle {
    flex: 1;
    min-width: 0;
}

/* Bouton + (lien rapide vers la liste) */
.sidebar-group-addlink {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    color: rgba(255,255,255,0.35);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.sidebar-group-addlink:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

#sidebar.collapsed .sidebar-group-addlink {
    display: none;
}


/* Séparateur */
.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 6px 10px;
    flex-shrink: 0;
}

/* Items statiques (Bibliothèque) */
.sidebar-static-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background 0.15s;
    font-size: 0.85rem;
    white-space: nowrap;
}

.sidebar-static-item i {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-static-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-static-item.active {
    background: rgba(255,255,255,0.12);
    border-left: 3px solid var(--accent-light);
    padding-left: 9px;
    color: #fff;
}

.sidebar-group-toggle {
    background: none;
    border: none;
    color: white;
    text-decoration: none;
    padding: 12px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.2s;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    gap: 8px;
}

.sidebar-group-toggle:hover {
    background: rgba(255,255,255,0.12);
}

.sidebar-group-toggle i:first-child {
    flex-shrink: 0;
    font-size: 1rem;
}

.sidebar-group-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sidebar-group-toggle .sidebar-chevron {
    flex-shrink: 0;
    font-size: 0.75rem;
    transition: transform 0.25s;
    margin-left: auto;
}

/* Bibliothèque : pas de badge → le chevron prend la droite (déjà auto par défaut) */
.sidebar-group-toggle--static .sidebar-chevron {
    margin-left: auto;
}

#sidebar.collapsed .sidebar-group-toggle span,
#sidebar.collapsed .sidebar-group-toggle .sidebar-chevron {
    display: none;
}

#sidebar.collapsed .sidebar-group-toggle {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    gap: 0;
}

#sidebar.collapsed .sidebar-group-toggle i:first-child {
    font-size: 1.3rem;
}

/* Tooltip collapsed pour les boutons groupe */
#sidebar.collapsed .sidebar-group-toggle:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-hover);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 2000;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

#sidebar.collapsed .sidebar-group-toggle {
    position: relative;
}

.sidebar-group-drop {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s ease;
    background: rgba(0,0,0,0.18);
    border-radius: 0 0 8px 8px;
}

.sidebar-group-drop.open {
    grid-template-rows: 1fr;
}

.group-drop-inner {
    overflow: hidden;
    min-height: 0;
}

#sidebar.collapsed .sidebar-group-drop {
    display: none;
}

.sidebar-search-box {
    padding: 6px 10px 4px;
}

.sidebar-search-input {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 0.8rem;
    padding: 5px 9px;
    outline: none;
    transition: border-color 0.2s;
}

.sidebar-search-input::placeholder {
    color: rgba(255,255,255,0.35);
}

.sidebar-search-input:focus {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.12);
}

.sidebar-group-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar-group-list::-webkit-scrollbar {
    width: 4px;
}

.sidebar-group-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.sidebar-group-item {
    display: flex;
    flex-direction: column;
    padding: 5px 12px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background 0.15s;
    font-size: 0.8rem;
}

.sidebar-group-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-group-item-nom {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-group-item-sub {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-group-empty {
    padding: 8px 12px;
    color: rgba(255,255,255,0.35);
    font-size: 0.78rem;
    font-style: italic;
}

.sidebar-group-showall {
    display: block;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: #fff;
    padding: 7px;
    text-decoration: none;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    margin: 6px 6px 2px;
    transition: background 0.15s;
    letter-spacing: 0.02em;
}

.sidebar-group-showall:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Mobile accordion list */
.mobile-acc-list {
    max-height: 200px;
    overflow-y: auto;
}

.mobile-acc-list a {
    display: block;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-acc-list a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.mobile-acc-list .sidebar-group-item {
    margin: 1px 0;
}

.mobile-cat-toggle {
    background: none;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
}

.mobile-acc-toggle {
    background: none;
    border: none;
}

/* =========================
   SIDEBAR SUB-NAV
========================= */

#sidebarSubNav {
    flex: 1;
}

#sidebarSubNav .sidebar-back-btn {
    color: rgba(255,255,255,0.5);
    font-size: 0.8rem;
    padding: 6px 12px 6px 24px;
}

#sidebarSubNav .sidebar-back-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.12);
}

#sidebar.collapsed #sidebarSubNav .sidebar-back-btn {
    padding-left: 0.75rem;
    justify-content: center;
}

.sidebar-subnav-title {
    color: rgba(255,255,255,0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 8px 12px 4px;
    white-space: nowrap;
}

#sidebar.collapsed .sidebar-subnav-title {
    display: none;
}

#sidebarSubNav a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 8px 12px 8px 24px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    font-size: 0.875rem;
    transition: background 0.2s;
    position: relative;
}

#sidebarSubNav a i {
    margin-right: 8px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

#sidebarSubNav a:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

#sidebarSubNav a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left: 3px solid var(--accent-light);
    padding-left: 21px;
}

#sidebar.collapsed #sidebarSubNav a {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

#sidebar.collapsed #sidebarSubNav a i {
    margin-right: 0;
    font-size: 1.1rem;
}

#sidebar.collapsed #sidebarSubNav a span {
    display: none;
}

#sidebar.collapsed #sidebarSubNav a.active {
    padding-left: calc(0.75rem - 3px);
}

#sidebar.collapsed #sidebarSubNav a:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-hover);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 2000;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* Barre navigation mobile horizontale */
#mobileSecNav {
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface) !important;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
#mobileSecNav::-webkit-scrollbar {
    display: none;
}
#mobileSecNav .mobile-sec-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
}


/* =========================
   NORMALISATION GLOBALE CARDS
========================= */

/* Toute .card dans le contenu principal hérite du style card-custom */
#mainContent .card {
    border-radius: 14px !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04) !important;
}

/* Bouton primaire aligné sur la palette */
.btn-primary {
    background-color: var(--accent) !important;
    border-color: var(--accent-hover) !important;
    color: var(--accent-text, #fff) !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--accent-hover) !important;
    border-color: var(--accent-hover) !important;
    color: var(--accent-hover-text, #fff) !important;
}

/* En-têtes de page h4 */
.main-scroll h4, .p-3 > h4, .p-4 > h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-hover);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}

.main-scroll h4 i, .p-3 > h4 i, .p-4 > h4 i {
    color: var(--accent);
    font-size: 1.1rem;
}


/* =========================
   ACCUEIL (home-page, hero, cards, kpi, shortcuts)
========================= */

.home-page {
    min-height: 100%;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 12%, transparent), transparent 28%),
        linear-gradient(180deg, var(--surface) 0%, var(--accent-bg) 100%);
}

.home-hero {
    border: 1px solid var(--border);
    border-radius: 24px;
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%);
    color: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    position: relative;
}

.home-hero-deco {
    position: absolute;
    right: -1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 5rem;
    opacity: 0.08;
    pointer-events: none;
    line-height: 1;
}

.home-card {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.hero-title {
    font-size: clamp(1.2rem, 1.5vw, 1.6rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
}

.hero-date {
    font-size: 0.8rem;
    opacity: 0.65;
    letter-spacing: 0.05em;
}

.hero-tagline {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* Mini stats dans le hero (accueil direction) */
.hero-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.hero-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border-radius: 14px;
    padding: 0.5rem 1rem;
    min-width: 80px;
}
.hero-stat-count {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}
.hero-stat-label {
    font-size: 0.72rem;
    opacity: 0.75;
    text-align: center;
}

.kpi-card {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff, var(--accent-bg));
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.1);
    color: inherit;
}

.kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.kpi-count {
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
}

.kpi-arrow {
    opacity: 0;
    transition: opacity 0.18s, transform 0.18s;
    transform: translateX(-4px);
}

.kpi-card:hover .kpi-arrow {
    opacity: 0.4;
    transform: translateX(0);
}

.shortcut-btn {
    min-height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.18s ease;
    background: #fff;
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
}

.shortcut-btn:hover {
    border-color: var(--accent-light);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.07);
}

.result-empty {
    padding: 1rem;
    border: 1px dashed var(--accent-light);
    border-radius: 16px;
    background: var(--accent-bg);
    color: var(--text-muted);
    text-align: center;
}

.template-stat {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 0.9rem 1rem;
    background: var(--accent-bg);
    height: 100%;
}

.template-stat-value {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--accent-hover);
}

.template-type-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: #fff;
    font-size: 0.85rem;
    color: var(--accent-hover);
}

.simple-list {
    display: grid;
    gap: 0.55rem;
}

.simple-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--accent-bg);
    color: inherit;
    text-decoration: none;
    transition: all 0.15s ease;
}

.simple-list-item:hover {
    border-color: var(--accent-light);
    background: #fff;
    transform: translateX(2px);
}

.simple-list-title {
    font-weight: 600;
    color: var(--accent-hover);
    font-size: 0.92rem;
}

.simple-list-meta {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.level-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}

.level-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.level-count {
    min-width: 2.2rem;
    text-align: right;
    font-weight: 700;
    color: var(--accent-hover);
}

.statut-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
    flex-shrink: 0;
}

.statut-en_cours  { background: color-mix(in srgb, #3b82f6 15%, transparent); color: #1d4ed8; }
.statut-termine   { background: color-mix(in srgb, #10b981 15%, transparent); color: #059669; }
.statut-archive   { background: color-mix(in srgb, #6b7280 15%, transparent); color: #374151; }

/* Nav tabs dans les cards accueil */
.act-tabs .nav-link {
    font-size: 0.85rem;
    padding: 0.35rem 0.8rem;
    border-radius: 10px;
    color: var(--text-muted);
    border: none;
}

.act-tabs .nav-link.active {
    background: var(--accent-bg);
    color: var(--accent-hover);
    font-weight: 600;
}

/* Search card */
.search-card .form-control,
.search-card .btn {
    min-height: 50px;
}

.search-card .form-control:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
    border-color: var(--accent-light);
}

/* Dark mode — accueil */
html.dark .home-page {
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 16%, transparent), transparent 28%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
}

html.dark .home-card,
html.dark .kpi-card,
html.dark .shortcut-btn,
html.dark .template-type-chip,
html.dark .simple-list-item {
    background: #1f2937;
    color: #e2e8f0;
    border-color: #334155;
}

html.dark .kpi-card:hover,
html.dark .simple-list-item:hover,
html.dark .shortcut-btn:hover {
    background: #243147;
    border-color: var(--accent-light);
}

html.dark .template-stat,
html.dark .result-empty {
    background: #111827;
    border-color: #334155;
    color: #94a3b8;
}

html.dark .simple-list-title,
html.dark .template-stat-value,
html.dark .level-count {
    color: #f8fafc;
}

html.dark .simple-list-meta {
    color: #94a3b8;
}

html.dark .btn-outline-secondary {
    color: #94a3b8;
    border-color: #334155;
}
html.dark .btn-outline-secondary:hover {
    background: #1f2937;
    color: #f1f5f9;
    border-color: #475569;
}

html.dark .level-row {
    border-bottom-color: #334155;
}

html.dark .act-tabs .nav-link.active {
    background: #111827;
    color: #f1f5f9;
}

html.dark .statut-en_cours { background: color-mix(in srgb, #3b82f6 20%, transparent); color: #93c5fd; }
html.dark .statut-termine  { background: color-mix(in srgb, #10b981 20%, transparent); color: #6ee7b7; }
html.dark .statut-archive  { background: color-mix(in srgb, #6b7280 20%, transparent); color: #9ca3af; }

@media (max-width: 767.98px) {
    .home-page { padding: 0.5rem !important; }
    .home-card  { padding: 0.75rem !important; }
    .home-hero  { padding: 0.75rem 1rem !important; }
    .kpi-card   { padding: 0.5rem 0.75rem !important; }
    .home-page .row { --bs-gutter-x: 0.5rem; --bs-gutter-y: 0.5rem; }
    .home-page .mb-4 { margin-bottom: 0.75rem !important; }
    .home-page .mb-3 { margin-bottom: 0.5rem !important; }
}


/* =========================
   PROFIL UTILISATEUR
========================= */

.profile-stat {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 1rem;
    height: 100%;
}
.profile-stat-label {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    margin-bottom: .25rem;
}
.profile-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-hover);
}
.profile-hero {
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%) !important;
    color: #fff;
    overflow: hidden;
}
.profile-avatar {
    width: 68px;
    height: 68px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.12);
    font-size: 1.7rem;
    flex-shrink: 0;
}


/* =========================
   DATATABLES EMPTY STATE
========================= */

td.dataTables_empty {
    padding: 2.5rem 1rem !important;
    color: var(--text-muted) !important;
    font-style: italic;
    font-size: .9rem;
}

.dataTables_processing {
    background: color-mix(in srgb, #ffffff 92%, var(--accent-bg)) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.08) !important;
    padding: 1rem 2rem !important;
    font-size: .9rem;
    color: var(--accent-hover);
}


/* =========================
   RESPONSIVE
========================= */

@media (max-width: 768px) {

    .dataTables_wrapper .length-menu,
    .dataTables_wrapper .info-center,
    .dataTables_wrapper .pagination-end {

        flex-basis: 100%;
        text-align: center;

        margin: 5px 0;
    }

}


/* =========================
   TABLE → CARDS MOBILE
========================= */

@media (max-width: 767.98px) {

    .table-responsive {
        overflow: visible !important;
    }

    /* Reset complet des bordures Bootstrap */
    table.tab-css,
    table.tab-css thead,
    table.tab-css tbody,
    table.tab-css tfoot,
    table.tab-css tr,
    table.tab-css th,
    table.tab-css td {
        border: none !important;
        border-color: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        background: transparent !important;
    }

    table.tab-css thead {
        display: none !important;
    }

    /* ── Card de base (sans logo) : colonne unique ── */
    table.tab-css tbody tr {
        display: block !important;
        background: #fff !important;
        border-radius: 12px !important;
        margin-bottom: 0.75rem;
        border: 1px solid var(--border) !important;
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
        overflow: hidden;
    }

    table.tab-css tbody td {
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        padding: 10px 16px !important;
        border-bottom: 1px solid var(--border) !important;
        font-size: 0.93rem;
        color: var(--accent-hover);
        line-height: 1.4;
        text-align: left !important;
        background: transparent !important;
    }

    /* Colonnes masquées par DataTables : ne pas laisser flex écraser le display:none inline */
    table.tab-css tbody td[style*="display: none"],
    table.tab-css tbody td[style*="display:none"] {
        display: none !important;
    }

    table.tab-css tbody td:last-child {
        border-bottom: none !important;
    }

    /* ── Card avec logo : grille 2 colonnes (détection CSS :has()) ──
       S'applique quand la 1ère td contient une img, span.text-muted ou div.entity-logo-frame */
    table.tab-css tbody tr:has(td:first-child img),
    table.tab-css tbody tr:has(td:first-child span.text-muted),
    table.tab-css tbody tr:has(td:first-child div.entity-logo-frame) {
        display: grid !important;
        grid-template-columns: 80px 1fr;
    }

    table.tab-css tbody tr:has(td:first-child img) td:first-child,
    table.tab-css tbody tr:has(td:first-child span.text-muted) td:first-child,
    table.tab-css tbody tr:has(td:first-child div.entity-logo-frame) td:first-child {
        grid-column: 1;
        grid-row: 1 / 99;
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: var(--accent-bg) !important;
        border-right: 1px solid var(--border) !important;
        border-bottom: none !important;
        padding: 12px 6px !important;
        overflow: hidden;
    }

    table.tab-css tbody tr:has(td:first-child img) td:first-child .entity-logo-frame,
    table.tab-css tbody tr:has(td:first-child span.text-muted) td:first-child .entity-logo-frame,
    table.tab-css tbody tr:has(td:first-child div.entity-logo-frame) td:first-child .entity-logo-frame {
        width: 58px;
        height: 44px;
        border-radius: 10px;
        flex-shrink: 0;
    }

    table.tab-css tbody tr:has(td:first-child img) td:not(:first-child),
    table.tab-css tbody tr:has(td:first-child span.text-muted) td:not(:first-child),
    table.tab-css tbody tr:has(td:first-child div.entity-logo-frame) td:not(:first-child) {
        grid-column: 2;
    }

    /* ── Labels (data-label injecté par dtMobileCards) ── */
    table.tab-css tbody td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        display: block;
        font-size: 0.63rem;
        font-weight: 700;
        color: var(--accent-hover);
        text-transform: uppercase;
        letter-spacing: 0.07em;
        margin-bottom: 3px;
    }

    /* Pas de label sur la cellule logo */
    table.tab-css tbody tr:has(td:first-child img) td:first-child::before,
    table.tab-css tbody tr:has(td:first-child span.text-muted) td:first-child::before,
    table.tab-css tbody tr:has(td:first-child div.entity-logo-frame) td:first-child::before {
        display: none !important;
    }

    /* Liens : pas de soulignement */
    table.tab-css tbody td a {
        text-decoration: none !important;
        display: block;
        width: 100%;
    }

    /* Boutons : pleine largeur par défaut */
    table.tab-css tbody td .btn {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        font-size: 0.9rem;
        padding: 7px 10px;
        border-radius: 8px;
        margin: 2px 0;
        text-decoration: none !important;
    }

    /* Colonne Actions (dernière cellule) : boutons inline côte-à-côte */
    table.tab-css tbody td:last-child {
        flex-direction: row !important;
        justify-content: center;
        gap: 4px;
        flex-wrap: wrap;
    }
    table.tab-css tbody td:last-child .btn {
        width: auto;
        flex: 0 0 auto;
        display: inline-flex;
    }

    /* Cellule combinée (ex : nom + petit bouton « Partager ») : garder les
       boutons compacts et alignés au lieu de les empiler en pleine largeur. */
    table.tab-css tbody td .btn-inline-group {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        flex-wrap: nowrap;
        width: 100%;
    }
    table.tab-css tbody td .btn-inline-group .btn {
        width: auto;
        flex: 0 1 auto;
        display: inline-flex;
        margin: 0;
        min-width: 0;
    }
    table.tab-css tbody td .btn-inline-group .btn-manage-shares {
        flex: 0 0 auto;   /* le bouton partager reste petit */
    }

    /* Désactiver hover / zèbre */
    table.tab-css tbody tr:hover td {
        background-color: transparent !important;
    }

    table.tab-css tbody tr:nth-child(even) {
        background-color: var(--surface) !important;
    }

    /* Empty state */
    table.tab-css td.dataTables_empty {
        grid-column: 1 / -1 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        padding: 2rem !important;
        font-size: 0.95rem;
        border: none !important;
    }

}

/* =========================
   THEME PICKER
========================= */

.theme-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent-hover);
}

.theme-swatch:hover {
    border-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.theme-swatch.active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
}

.theme-swatch-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-swatch-label {
    flex-grow: 1;
}

.theme-swatch-check {
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 1.1rem;
}

.theme-swatch.active .theme-swatch-check {
    opacity: 1;
}

/* =========================
   DARK MODE
========================= */

.dark {
    color: #e2e8f0;
    background: #0f172a;
}

.dark body {
    background: var(--surface);
    color: #e2e8f0;
}

.dark #mainContent,
.dark .main-scroll,
.dark .toolbar,
.dark .tab-content,
.dark .card-custom,
.dark .card,
.dark .profile-stat,
.dark .profile-hero,
.dark .theme-swatch {
    background: #111827;
}

.dark .profile-hero {
    background: linear-gradient(135deg, var(--accent-hover) 0%, var(--accent) 100%) !important;
    border-color: #334155 !important;
}

.dark #sidebar {
    background: linear-gradient(180deg, #111827 0%, #1f2937 100%);
    color: #cbd5e1;
}

.dark .sidebar-logo {
    border-bottom-color: rgba(255,255,255,0.07);
}

.dark .sidebar-divider {
    background: rgba(255,255,255,0.07);
}

.dark #sidebar a,
.dark #sidebarSubNav a {
    color: #cbd5e1;
}

.dark #sidebar a:hover,
.dark #sidebarSubNav a:hover {
    background: rgba(255,255,255,0.10);
}

.dark nav.navbar {
    background: #111827 !important;
    color: #cbd5e1;
}

.dark .card-custom,
.dark .card {
    background: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .tab-css {
    background: #0f172a;
    border-color: #334155;
}

.dark .tab-css thead tr:first-child th,
.dark .tab-css thead tr:last-child th {
    background: #111827;
    color: #cbd5e1;
    border-color: #334155;
}

.dark .tab-css tbody tr:nth-child(odd) {
    background-color: #111827;
}

.dark .tab-css tbody tr:nth-child(even) {
    background-color: #0f172a;
}

.dark .tab-css tbody tr:hover td {
    background-color: #1e293b !important;
}

.dark .tab-css tbody td {
    border-bottom-color: #334155;
    color: #e2e8f0;
}

.dark h1,
.dark h2,
.dark h3,
.dark h4,
.dark h5,
.dark h6 {
    color: #f8fafc;
}

.dark .text-muted,
.dark .form-label,
.dark .form-text {
    color: #94a3b8 !important;
}

.dark .btn-light {
    background: #243147;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .form-control,
.dark .form-select,
.dark .form-range {
    background: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}

.dark .form-control:focus,
.dark .form-select:focus,
.dark .form-range:focus {
    background: #1f2937;
    border-color: var(--accent-light);
    color: #e2e8f0;
}

.dark .form-select option {
    background: #1f2937;
    color: #e2e8f0;
}

.dark .theme-swatch {
    border-color: #334155;
    color: #cbd5e1;
}

.dark .theme-swatch:hover {
    background: #14203b;
}

.dark .theme-swatch.active {
    background: #0f172a;
    border-color: var(--accent);
    color: var(--accent);
}

@supports (color: color-mix(in srgb, white 50%, black)) {
    .dark .tab-css tbody tr:hover td {
        background-color: color-mix(in srgb, var(--accent) 18%, #0f172a) !important;
    }

    .dark .theme-swatch:hover {
        background: color-mix(in srgb, var(--accent) 14%, #111827);
    }
}

/* ── Dark mode — variables Bootstrap ──────────────────────────────────── */
html.dark {
    --bs-border-color:         #334155;
    --bs-border-color-translucent: rgba(255,255,255,0.1);
    --bs-body-bg:              #111827;
    --bs-body-color:           #e2e8f0;
    --bs-secondary-bg:         #1f2937;
    --bs-tertiary-bg:          #0f172a;
    --bs-light-rgb:            31,41,55;
}

/* ── Fond blanc → fond sombre ─────────────────────────────────────────── */
.dark .bg-white,
.dark .bg-light {
    background-color: #1f2937 !important;
    color: #e2e8f0;
}

/* ── List group ───────────────────────────────────────────────────────── */
.dark .list-group-item {
    background-color: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}
.dark .list-group-item a,
.dark .list-group-item strong {
    color: #e2e8f0;
}
.dark .list-group-item-action:hover,
.dark .list-group-item-action:focus {
    background-color: #243147;
    color: #f1f5f9;
}

/* ── Modals ───────────────────────────────────────────────────────────── */
.dark .modal-content {
    background-color: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
}
.dark .modal-header,
.dark .modal-footer {
    border-color: #334155;
}
.dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ── Accordion ────────────────────────────────────────────────────────── */
.dark .accordion-item {
    background-color: #1f2937;
    border-color: #334155;
}
.dark .accordion-button {
    background-color: #243147;
    color: #e2e8f0;
    box-shadow: inset 0 -1px 0 #334155;
}
.dark .accordion-button:not(.collapsed) {
    background-color: #1a2d45;
    color: #f1f5f9;
}
.dark .accordion-button::after {
    filter: invert(1);
}
.dark .accordion-body {
    background-color: #1f2937;
    color: #e2e8f0;
}

/* ── Dropdown ─────────────────────────────────────────────────────────── */
.dark .dropdown-menu {
    background-color: #1f2937;
    border-color: #334155;
}
.dark .dropdown-item {
    color: #e2e8f0;
}
.dark .dropdown-item:hover,
.dark .dropdown-item:focus {
    background-color: #243147;
    color: #f1f5f9;
}
.dark .dropdown-divider {
    border-color: #334155;
}

/* ── Tables Bootstrap ─────────────────────────────────────────────────── */
.dark .table {
    --bs-table-bg:              #1f2937;
    --bs-table-striped-bg:      #111827;
    --bs-table-hover-bg:        #243147;
    --bs-table-border-color:    #334155;
    color: #e2e8f0;
    border-color: #334155;
}
.dark .table > :not(caption) > * > * {
    background-color: var(--bs-table-bg);
    border-bottom-color: #334155;
}
.dark .table-bordered > :not(caption) > * {
    border-color: #334155;
}

/* ── Input group ──────────────────────────────────────────────────────── */
.dark .input-group-text {
    background-color: #243147;
    border-color: #334155;
    color: #e2e8f0;
}

/* ── Nav tabs ─────────────────────────────────────────────────────────── */
.dark .nav-tabs {
    border-bottom-color: #334155;
}
.dark .nav-tabs .nav-link {
    color: #94a3b8;
}
.dark .nav-tabs .nav-link:hover {
    border-color: #334155 #334155 transparent;
    color: #e2e8f0;
}
.dark .nav-tabs .nav-link.active {
    background-color: #1f2937;
    border-color: #334155 #334155 #1f2937;
    color: #f1f5f9;
}

/* ── Bordures génériques Bootstrap ───────────────────────────────────── */
.dark .border,
.dark .border-top,
.dark .border-end,
.dark .border-bottom,
.dark .border-start {
    border-color: #334155 !important;
}

/* ── Badges Bootstrap résiduels ───────────────────────────────────────── */
.dark .badge.bg-secondary { background-color: #334155 !important; }
.dark .badge.bg-light     { background-color: #243147 !important; color: #e2e8f0 !important; }

/* ── Popover / Tooltip ────────────────────────────────────────────────── */
.dark .popover {
    background-color: #1f2937;
    border-color: #334155;
}
.dark .popover-header {
    background-color: #243147;
    border-bottom-color: #334155;
    color: #f1f5f9;
}
.dark .popover-body {
    color: #e2e8f0;
}

/* ── Popover cadenas sidebar (suit le thème via --accent) ─────────────── */
.sidebar-popover.popover {
  --bs-popover-bg: var(--accent);
  --bs-popover-border-color: rgba(255,255,255,0.18);
  --bs-popover-body-color: rgba(255,255,255,0.92);
  background-color: var(--accent) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  max-width: 220px;
  font-size: 0.8rem;
}
.sidebar-popover .popover-body {
  color: rgba(255,255,255,0.92) !important;
  padding: 8px 14px;
  letter-spacing: 0.01em;
  line-height: 1.5;
}
/* Flèche — placement droite (desktop sidebar) */
.sidebar-popover.bs-popover-end .popover-arrow::before,
.sidebar-popover.bs-popover-auto[data-popper-placement^=right] .popover-arrow::before {
  border-right-color: rgba(255,255,255,0.18);
}
.sidebar-popover.bs-popover-end .popover-arrow::after,
.sidebar-popover.bs-popover-auto[data-popper-placement^=right] .popover-arrow::after {
  border-right-color: var(--accent);
}
/* Flèche — placement basse (mobile auto) */
.sidebar-popover.bs-popover-bottom .popover-arrow::before,
.sidebar-popover.bs-popover-auto[data-popper-placement^=bottom] .popover-arrow::before {
  border-bottom-color: rgba(255,255,255,0.18);
}
.sidebar-popover.bs-popover-bottom .popover-arrow::after,
.sidebar-popover.bs-popover-auto[data-popper-placement^=bottom] .popover-arrow::after {
  border-bottom-color: var(--accent);
}
/* Flèche — placement haute */
.sidebar-popover.bs-popover-top .popover-arrow::before,
.sidebar-popover.bs-popover-auto[data-popper-placement^=top] .popover-arrow::before {
  border-top-color: rgba(255,255,255,0.18);
}
.sidebar-popover.bs-popover-top .popover-arrow::after,
.sidebar-popover.bs-popover-auto[data-popper-placement^=top] .popover-arrow::after {
  border-top-color: var(--accent);
}
/* Flèche — placement gauche */
.sidebar-popover.bs-popover-start .popover-arrow::before,
.sidebar-popover.bs-popover-auto[data-popper-placement^=left] .popover-arrow::before {
  border-left-color: rgba(255,255,255,0.18);
}
.sidebar-popover.bs-popover-start .popover-arrow::after,
.sidebar-popover.bs-popover-auto[data-popper-placement^=left] .popover-arrow::after {
  border-left-color: var(--accent);
}

/* ── Progress bar ─────────────────────────────────────────────────────── */
.dark .progress {
    background-color: #243147;
}

/* ── Alert ────────────────────────────────────────────────────────────── */
.dark .alert {
    border-color: #334155;
}

/* ── Pagination (Bootstrap, hors DataTables) ──────────────────────────── */
.dark .page-link {
    background-color: #1f2937;
    border-color: #334155;
    color: #94a3b8;
}
.dark .page-item.active .page-link {
    background-color: var(--accent);
    border-color: var(--accent);
}
.dark .page-item.disabled .page-link {
    background-color: #111827;
    border-color: #334155;
    color: #475569;
}

/* ── Offcanvas mobile sidebar ─────────────────────────────────────────── */
.dark .offcanvas {
    background-color: #111827;
    border-color: #334155;
}
.dark .hr,
.dark hr {
    border-color: #334155;
    opacity: 1;
}

/* ── Tables → cards mobiles en dark mode ──────────────────────────────── */
@media (max-width: 767.98px) {
    .dark table.tab-css tbody tr {
        background: #1f2937 !important;
        border-color: #334155 !important;
    }
    .dark table.tab-css tbody tr:nth-child(even) {
        background-color: #111827 !important;
    }
    .dark table.tab-css tbody td {
        color: #e2e8f0 !important;
        border-bottom-color: #334155 !important;
    }
    .dark table.tab-css tbody tr:has(td:first-child img) td:first-child,
    .dark table.tab-css tbody tr:has(td:first-child span.text-muted) td:first-child {
        background: #111827 !important;
        border-right-color: #334155 !important;
    }
}

/* ── Section locked dark mode ─────────────────────────────────────────── */
.dark .section-locked {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}
.dark .section-locked .section-locked-label { color: #cbd5e1; }
.dark .section-locked .section-locked-hint  { color: #64748b; }

/* ── Hierarchy block dark mode ────────────────────────────────────────── */
.dark .hierarchy-block {
    background: #1e293b;
    border-color: #334155;
}

/* =========================
   ENTITY UI HELPERS
========================= */

.entity-logo-frame {
    width: 70px;
    height: 50px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin: auto;
}

.entity-logo-frame img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.gallery-thumbstrip {
    overflow-x: auto;
    flex-wrap: nowrap;
    min-height: 74px;
    background: color-mix(in srgb, var(--accent-hover) 72%, #000000);
    border-top: 1px solid rgba(255,255,255,.12);
}

.apercu-frame {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
}

.mobile-section-nav {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--surface) !important;
}

.mobile-section-nav::-webkit-scrollbar {
    display: none;
}


.dark .entity-logo-frame {
    background: #111827;
    border-color: #334155;
}

.dark .apercu-frame {
    background: #111827;
    border-color: #334155;
}

.dark .gallery-thumbstrip {
    background: color-mix(in srgb, var(--accent-hover) 50%, #000000);
    border-top-color: #334155;
}

/* =========================
   TOPBAR THEMED
========================= */

nav.topbar {
    background: var(--surface);
    border-color: var(--border) !important;
    color: var(--accent-hover);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.btn-nav-toggle {
    background: var(--accent-bg);
    border: 1px solid var(--border);
    color: var(--accent-hover);
    border-radius: 6px;
    line-height: 1;
}
.btn-nav-toggle:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    border-color: var(--accent-light);
    color: var(--accent-hover);
}

.dark .btn-nav-toggle {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}
.dark .btn-nav-toggle:hover {
    background: #2d3f5a;
    border-color: #475569;
    color: #f1f5f9;
}

#pushToggleBtn.push-active {
    color: var(--accent);
    border-color: var(--accent-light);
}

.dark nav.topbar {
    background: #111827;
    border-color: #1f2937 !important;
    color: #cbd5e1;
}

.dark nav.topbar .nav-link,
.dark nav.topbar .dropdown-toggle {
    color: #cbd5e1 !important;
}

.topbar-dropdown {
    background: var(--surface);
    border-color: var(--border);
}
.topbar-dropdown .dropdown-item {
    color: var(--accent-hover);
}
.topbar-dropdown .dropdown-item:hover {
    background: var(--accent-bg);
}
.topbar-dropdown .dropdown-divider {
    border-color: var(--border);
}

.dark .topbar-dropdown {
    background: #1f2937;
    border-color: #334155;
}
.dark .topbar-dropdown .dropdown-item {
    color: #e2e8f0;
}
.dark .topbar-dropdown .dropdown-item:hover {
    background: #243147;
}
.dark .topbar-dropdown .dropdown-divider {
    border-color: #334155;
}

/* =========================
   MOBILE SIDEBAR THEMED
========================= */

.mobile-sidebar {
    background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
    color: rgba(255,255,255,0.85);
}
.mobile-sidebar-header {
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
}
.mobile-sidebar .offcanvas-title {
    color: #fff;
}
.mobile-sidebar-close {
    filter: invert(1) grayscale(1) brightness(2);
}
.mobile-sidebar-input {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.15);
}
.mobile-sidebar-input::placeholder {
    color: rgba(255,255,255,0.4);
}
.mobile-sidebar-input:focus {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
    box-shadow: none;
}
.mobile-sidebar-divider {
    border-color: rgba(255,255,255,0.12) !important;
}
.mobile-sidebar .sidebar-group-showall,
.mobile-sidebar .nav-link {
    color: rgba(255,255,255,0.80) !important;
}
.mobile-sidebar .nav-link:hover,
.mobile-sidebar .mobile-acc-toggle:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.12);
}

/* =========================
   SECTION LABEL (titre section majuscule)
========================= */

.section-label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 700;
}

/* =========================
   BTN XS (micro boutons)
========================= */

.btn-xs {
    padding: 0.15rem 0.35rem;
    font-size: 0.72rem;
    line-height: 1.3;
    border-radius: 0.2rem;
}

/* =========================
   BTN ACCENT (theme-aware)
========================= */

.btn-accent {
    background: var(--accent);
    color: var(--accent-text, #fff);
    border-color: var(--accent);
}
.btn-accent:hover,
.btn-accent:focus,
.btn-accent:active {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-hover-text, #fff);
}
.btn-accent:disabled {
    background: var(--accent-light);
    border-color: var(--accent-light);
    color: var(--accent-text, #fff);
    opacity: 0.65;
}

/* =========================
   LOGO FRAME MOBILE
========================= */

@media (max-width: 575px) {
    .entity-logo-frame {
        width: 44px;
        height: 34px;
        border-radius: 10px;
        flex-shrink: 0;
    }
    .entity-logo-frame img {
        max-width: 85%;
        max-height: 85%;
    }
}

/* =========================
   GESTION MÉDIAS
========================= */

.media-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--accent-light);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    background: var(--accent-bg);
    color: #64748b;
}
.media-upload-zone:hover,
.media-upload-zone.drag-over {
    background: #e8edf2;
    border-color: var(--accent);
}

.media-preview-queue {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.media-preview-queue:empty { display: none; }

.media-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    background: #e2e8f0;
    flex-shrink: 0;
}
.media-preview-item img,
.media-preview-item video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.media-preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.38);
    transition: background 0.3s;
}
.media-preview-item.done .media-preview-overlay { background: rgba(0,0,0,0); }
.media-preview-item.error .media-preview-overlay { background: rgba(180,0,0,0.45); }

.media-spinner {
    width: 26px; height: 26px;
    border: 3px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: media-spin 0.7s linear infinite;
}
@keyframes media-spin { to { transform: rotate(360deg); } }

.media-check-icon {
    font-size: 22px;
    animation: media-pop 0.3s ease;
}
@keyframes media-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.media-progress-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255,255,255,0.25);
}
.media-progress-fill {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.2s;
}
.media-preview-item.done .media-progress-bar { display: none; }

.media-camera-preview {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    display: none;
    background: #000;
    border-radius: 8px;
}
.media-camera-preview.active { display: block; }

.media-record-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 13px;
    color: #dc2626;
    font-weight: 600;
}
.media-record-indicator.active { display: flex; }
.media-record-dot {
    width: 8px; height: 8px;
    background: #dc2626;
    border-radius: 50%;
    animation: media-pulse 1s ease-in-out infinite;
}
@keyframes media-pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
}
.media-gallery-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    background: #e2e8f0;
    cursor: pointer;
}
.media-gallery-item img,
.media-gallery-item video {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.media-gallery-item .media-del-btn {
    position: absolute;
    top: 3px; right: 3px;
    width: 24px; height: 24px;
    padding: 0;
    border-radius: 50%;
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}
.media-gallery-item:hover .media-del-btn { opacity: 1; }
.media-gallery-item .media-play-icon {
    position: absolute;
    inset: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.media-gallery-empty {
    grid-column: 1 / -1;
    padding: 24px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* =========================
   NOTES WIDGET
========================= */

.notes-list {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.note-bubble {
    background: var(--accent-bg);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    transition: background 0.15s;
}
.note-bubble:hover { background: #edf0f4; }

.note-bubble p {
    margin: 0 0 5px;
    white-space: pre-wrap;
    line-height: 1.45;
    color: #1e293b;
}

.note-bubble-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #94a3b8;
    gap: 6px;
}

.note-bubble-actions {
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.note-bubble:hover .note-bubble-actions { opacity: 1; }

.notes-compose textarea {
    resize: none;
    font-size: 13px;
}

.note-voice-btn.listening {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #fff !important;
    animation: media-pulse 1s ease-in-out infinite;
}

/* ── Statut dot ── */
.statut-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
}
.statut-dot::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--border);
}
.statut-dot.actif::before    { background: var(--accent); }
.statut-dot.actif            { color: var(--accent); }
.statut-dot.en_cours::before { background: var(--accent); }
.statut-dot.en_cours         { color: var(--accent); }
.statut-dot.termine::before  { background: var(--accent-light); }
.statut-dot.archive::before  { background: var(--border); }

/* ── Type label ── */
.type-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Count label ── */
.count-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.count-label.done {
    color: var(--accent);
    font-weight: 500;
}

.note-voice-btn.voice-ready {
    background: #16a34a !important;
    border-color: #16a34a !important;
    color: #fff !important;
}

/* =========================
   SECTION LOCKED (partages)
========================= */

.section-locked {
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 2.5rem 1rem;
    text-align: center;
    color: #64748b;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.section-locked .section-locked-icon {
    font-size: 2rem;
    color: #94a3b8;
    display: block;
}

.section-locked .section-locked-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
}

.section-locked .section-locked-hint {
    font-size: 0.82rem;
    color: #94a3b8;
}

/* =========================
   HIERARCHY MODAL (sites/zones/equipements)
========================= */

.hierarchy-block {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    transition: border-color 0.15s;
}

.hierarchy-block:focus-within {
    border-color: #94a3b8;
}

.hierarchy-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.hierarchy-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.hierarchy-arrow {
    text-align: center;
    line-height: 1;
    margin: 0.15rem 0;
    color: #cbd5e1;
    font-size: 1.1rem;
}

/* ── Profil access icon (admin only) ── */
.mobile-sidebar a.d-flex { width: 100%; }

.sidebar-access-icon {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.65rem;
  opacity: 0.5;
  color: rgba(255,255,255,0.9);
  transition: opacity 0.15s;
  cursor: pointer;
}
.sidebar-access-icon:hover,
.sidebar-access-icon:focus { opacity: 1; outline: none; }
#sidebar.collapsed .sidebar-access-icon { display: none; }

.page-access-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  margin-top: -0.35rem;
}
.page-access-hint .hint-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}
.page-access-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  line-height: 1.6;
}

/* ── Logo upload zone (mon-entite) ──────────────────────────────────────────── */
.logo-upload-zone {
  position: relative; width: 100%; max-width: 260px; height: 150px;
  border: 2px dashed #dee2e6; border-radius: .625rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: border-color .2s, background .2s; background: #f8f9fa;
}
.logo-upload-zone:hover, .logo-upload-zone.drag-over { border-color: var(--accent-color, #0d6efd); background: rgba(13,110,253,.04); }
.logo-preview-img { max-width: 100%; max-height: 100%; object-fit: contain; padding: .75rem; }
.logo-upload-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  opacity: 0; transition: opacity .2s;
}
.logo-upload-zone:hover .logo-upload-overlay { opacity: 1; }
.logo-upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.theme-card { cursor: pointer; text-align: center; padding: .5rem; border: 2px solid transparent; border-radius: 10px; transition: .15s; }
.theme-card.selected, .theme-card:hover { border-color: var(--accent-color, #e94560); background: rgba(0,0,0,.03); }
.theme-preview { width: 80px; height: 50px; border-radius: 6px; margin: 0 auto .4rem; border: 1px solid #dee2e6; }
.theme-clair   { background: linear-gradient(135deg, #f8f9fa 60%, #e94560 60%); }
.theme-sombre  { background: linear-gradient(135deg, #0f0f1a 60%, #e94560 60%); }
.theme-minimal { background: linear-gradient(135deg, #ffffff 60%, #333 60%); }
.theme-label   { font-size: .8rem; font-weight: 600; color: var(--bs-body-color); }

/* Dashboard widget drag & drop */
.widget-ghost { opacity: .4; background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 8px; }
[data-widget] { transition: opacity .15s; }

/* ═══════════════════════════════════════════════════════════════════════════
   VISUAL POLISH — Skeletons, Empty states, Animations, Badges
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── A. Skeleton loaders ─────────────────────────────────────────────────── */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.4s infinite linear;
  border-radius: 6px;
  display: block;
}
.skeleton-text  { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-title { height: 20px; margin-bottom: 12px; width: 60%; border-radius: 4px; }
.skeleton-kpi   { height: 72px; border-radius: 12px; }
.skeleton-row   { height: 40px; margin-bottom: 6px; border-radius: 6px; }
.skeleton-card  { height: 120px; border-radius: 12px; }
[data-theme="dark"] .skeleton,
body.dark-mode   .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #273549 50%, #1e293b 75%);
  background-size: 800px 100%;
}

/* ── B. Empty states ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5rem 1.5rem; text-align: center; color: var(--text-muted);
}
.empty-state svg { margin-bottom: 1rem; opacity: .55; }
.empty-state .empty-title { font-size: .95rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-muted); }
.empty-state .empty-sub   { font-size: .82rem; margin-bottom: 1rem; }

/* ── C. Micro-animations ────────────────────────────────────────────────────*/
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
.animate-fadeInUp  { animation: fadeInUp  .3s ease both; }
.animate-fadeIn    { animation: fadeIn    .25s ease both; }
.animate-scaleIn   { animation: scaleIn   .25s ease both; }

/* Stagger pour les listes */
.stagger-list > *:nth-child(1)  { animation-delay: .03s; }
.stagger-list > *:nth-child(2)  { animation-delay: .06s; }
.stagger-list > *:nth-child(3)  { animation-delay: .09s; }
.stagger-list > *:nth-child(4)  { animation-delay: .12s; }
.stagger-list > *:nth-child(5)  { animation-delay: .15s; }
.stagger-list > *:nth-child(6)  { animation-delay: .18s; }
.stagger-list > *:nth-child(n+7){ animation-delay: .20s; }

/* Hover cards amélioré */
.card, .kpi-card, .home-card {
  transition: box-shadow .2s ease, transform .18s ease !important;
}
.card:hover, .kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.10) !important;
}

/* Boutons — micro feedback */
.btn { transition: transform .12s ease, box-shadow .12s ease, background .15s ease !important; }
.btn:active { transform: scale(.97) !important; }

/* ── D. Badges statuts unifiés ───────────────────────────────────────────── */
.badge-statut {
  display: inline-flex; align-items: center; gap: .28rem;
  padding: .22em .6em; border-radius: 999px; font-size: .73rem; font-weight: 600;
  white-space: nowrap; line-height: 1.4;
}
/* Affaires */
.bs-prospect       { background:#f1f5f9; color:#475569; }
.bs-contact        { background:#dbeafe; color:#1d4ed8; }
.bs-devis_envoye   { background:#e0f2fe; color:#0369a1; }
.bs-en_negociation { background:#fef9c3; color:#854d0e; }
.bs-en_cours       { background:#dcfce7; color:#15803d; }
.bs-envoye         { background:#e0e7ff; color:#4338ca; }
.bs-signe          { background:#d1fae5; color:#065f46; }
.bs-refuse         { background:#fee2e2; color:#b91c1c; }
.bs-annule         { background:#f3f4f6; color:#6b7280; }
.bs-termine        { background:#ede9fe; color:#6d28d9; }
.bs-archive        { background:#f3f4f6; color:#9ca3af; }
/* Devis */
.bs-brouillon      { background:#f1f5f9; color:#475569; }
.bs-accepte        { background:#dcfce7; color:#15803d; }
/* Demandes */
.bs-ouvert         { background:#dbeafe; color:#1d4ed8; }
.bs-ferme          { background:#f3f4f6; color:#6b7280; }
.bs-en_attente     { background:#fef9c3; color:#854d0e; }
.bs-resolu         { background:#dcfce7; color:#15803d; }
/* Maintenance / stock */
.bs-planifie       { background:#e0f2fe; color:#0369a1; }
.bs-realise        { background:#dcfce7; color:#15803d; }
.bs-en_retard      { background:#fee2e2; color:#b91c1c; }
.bs-actif          { background:#dcfce7; color:#15803d; }
.bs-inactif        { background:#f3f4f6; color:#9ca3af; }

/* ── Login split-screen (page /connexion) ───────────────────────────────── */
.login-split {
  min-height: 100vh; display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-split-left {
  background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3rem 2.5rem; position: relative; overflow: hidden;
}
.login-split-left::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 60%, rgba(99,102,241,.25) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 20%, rgba(16,185,129,.15) 0%, transparent 50%);
}
.login-split-left > * { position: relative; z-index: 1; }
.login-split-right {
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 2rem; background: #f8fafc;
}
.login-form-box {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 16px; padding: 2.5rem 2rem;
  box-shadow: 0 4px 32px rgba(0,0,0,.08);
  animation: scaleIn .3s ease both;
}
@media (max-width: 768px) {
  .login-split { grid-template-columns: 1fr; }
  .login-split-left { display: none; }
  .login-split-right {
    min-height: 100vh;
    background: linear-gradient(175deg, #0f172a 0%, #1e3a5f 38%, #f8fafc 38%);
    align-items: flex-start;
    padding: 3.5rem 1rem 2rem;
  }
  .login-form-box { margin: 0 auto; }
  .login-mobile-logo { display: block !important; }
}
