/* weli0.1/weli.css */

/* ══════════════════════════════════════
   VARIABLES — THÈME CLAIR (défaut)
══════════════════════════════════════ */
:root {
    --weli-bg-page:          #dde3ed;
    --weli-bg-card:          #f5f7fa;
    --weli-bg-header-inner:  #eaeff6;
    --weli-bg-thead:         #2d3748;
    --weli-bg-filter:        #e2e8f2;
    --weli-bg-input:         #ffffff;
    --weli-bg-hover:         #dce4f0;

    --weli-border:           #c8d3e0;
    --weli-border-input:     #b0bdd0;
    --weli-border-header:    #d0dae6;

    --weli-shadow-card:      0 2px 8px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.07);
    --weli-shadow-hover:     0 4px 16px rgba(0,0,0,0.15), 0 12px 32px rgba(0,0,0,0.10);

    --weli-text-primary:     #1a2636;
    --weli-text-secondary:   #4a5a6e;
    --weli-text-thead:       #ffffff;
    --weli-text-input:       #1e293b;

    --weli-accent:           #2563eb;
    --weli-accent-light:     rgba(37,99,235,0.18);

    --weli-btn-bg:           #eaeff6;
    --weli-btn-border:       #b0bdd0;
    --weli-btn-fg:           #334155;

    --weli-toggle-track:     #b0bdd0;
    --weli-toggle-thumb:     #ffffff;

    --weli-thead-default:    #2d3748;
    --weli-thead-emerald:    #234e52;
    --weli-thead-ocean:      #1e4d8c;
    --weli-thead-minimal-bg: #dde3ed;
    --weli-thead-minimal-fg: #334155;

    --weli-file-bg:          #eff6ff;
    --weli-file-color:       #1e40af;
    --weli-file-border:      #bfdbfe;
}

/* ══════════════════════════════════════
   VARIABLES — THÈME SOMBRE
══════════════════════════════════════ */
[data-theme="dark"],
.weli-wrapper[data-theme="dark"] {
    --weli-bg-page:          #0f172a;
    --weli-bg-card:          #1e293b;
    --weli-bg-header-inner:  #162032;
    --weli-bg-thead:         #1a2740;
    --weli-bg-filter:        #162032;
    --weli-bg-input:         #1e293b;
    --weli-bg-hover:         #243044;

    --weli-border:           #334155;
    --weli-border-input:     #475569;
    --weli-border-header:    #334155;

    --weli-shadow-card:      0 2px 8px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.3);
    --weli-shadow-hover:     0 4px 16px rgba(0,0,0,0.5), 0 12px 32px rgba(0,0,0,0.4);

    --weli-text-primary:     #f1f5f9;
    --weli-text-secondary:   #94a3b8;
    --weli-text-thead:       #e2e8f0;
    --weli-text-input:       #f1f5f9;

    --weli-accent:           #60a5fa;
    --weli-accent-light:     rgba(96,165,250,0.2);

    --weli-btn-bg:           #334155;
    --weli-btn-border:       #475569;
    --weli-btn-fg:           #94a3b8;

    --weli-toggle-track:     #60a5fa;
    --weli-toggle-thumb:     #ffffff;

    --weli-thead-default:    #1e3a5f;
    --weli-thead-emerald:    #14403e;
    --weli-thead-ocean:      #1e40af;
    --weli-thead-minimal-bg: #1e293b;
    --weli-thead-minimal-fg: #94a3b8;

    --weli-file-bg:          #1e3a5f;
    --weli-file-color:       #bfdbfe;
    --weli-file-border:      #3b82f6;
}

*, *::before, *::after { box-sizing: border-box; }

/* ══════════════════════════════════════
   TOOLBAR
══════════════════════════════════════ */
/* Tailles en em, pilotées par un seul font-size sur .weli-toolbar : 16px =
   taille actuelle (plafond, jamais plus grand qu'aujourd'hui), réduit en
   continu via clamp(cqi) selon la largeur réelle du .weli-header ambiant
   (container query, pas media query — marche aussi bien pour une weli
   imbriquée étroite qu'une weli normale en pleine page). */
.weli-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    overflow: hidden;
    gap: 0.375em;
    font-size: clamp(10px, 2.2cqi, 16px);
    /* Garde la toolbar à droite (sa position en mode large), seule ou à côté
       du titre — sans ça, space-between la recale à gauche (flex-start) dès
       qu'elle est seule sur sa ligne (mode empilé). .weli-header--toolbar-left
       remet cette marge à 0 et utilise margin-right:auto à la place (miroir). */
    margin-left: auto;
}
.weli-tool-sep {
    display: inline-block;
    width: 1px;
    height: 1.375em;
    background: var(--weli-btn-border, #cbd5e1);
    border-radius: 1px;
    flex-shrink: 0;
    margin: 0 0.125em;
}

.weli-tool-btn {
    /* Les <button> n'héritent pas du font-size du parent par défaut (police
       de contrôle de formulaire du navigateur) — sans ça, 2.125em se base
       sur cette taille fixe du navigateur, pas sur le clamp(cqi) ci-dessus. */
    font-size: inherit;
    width: 2.125em;
    height: 2.125em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--weli-btn-border);
    border-radius: 0.4375em;
    background: var(--weli-btn-bg);
    color: var(--weli-btn-fg);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    padding: 0;
    flex-shrink: 0;
}
.weli-tool-btn svg {
    width: 1em;
    height: 1em;
    stroke: currentColor;
}
.weli-tool-btn:hover {
    border-color: color-mix(in srgb, var(--weli-accent) 50%, var(--weli-btn-border));
    color: var(--weli-accent);
    background: color-mix(in srgb, var(--weli-accent) 8%, var(--weli-btn-bg));
    box-shadow: 0 0 0 3px var(--weli-accent-light);
}
.weli-tool-btn--active {
    background: var(--weli-accent) !important;
    border-color: var(--weli-accent) !important;
    color: #fff !important;
}

.weli-sel-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--weli-accent);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}
.weli-sel-count--active {
    background: color-mix(in srgb, var(--weli-accent) 12%, transparent);
    border-color: color-mix(in srgb, var(--weli-accent) 30%, transparent);
}

/* ══════════════════════════════════════
   RECHERCHE GLOBALE
══════════════════════════════════════ */
.weli-global-search-bar {
    padding: 8px 12px;
    border-bottom: 1px solid var(--weli-border);
    background: var(--weli-bg-header-inner);
}
.weli-global-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--weli-bg-input);
    border: 1px solid var(--weli-border-input);
    border-radius: 7px;
    padding: 6px 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.weli-global-search-inner:focus-within {
    border-color: var(--weli-accent);
    box-shadow: 0 0 0 3px var(--weli-accent-light);
}
.weli-global-search-icon svg {
    width: 15px;
    height: 15px;
    stroke: var(--weli-text-secondary);
    display: block;
}
.weli-global-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: var(--weli-text-primary);
    font-family: inherit;
}
.weli-global-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--weli-text-secondary);
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.weli-global-clear:hover { color: var(--weli-text-primary); }

/* ══════════════════════════════════════
   WRAPPER CARD
══════════════════════════════════════ */
.weli-wrapper {
    background: var(--weli-bg-card);
    border: 1px solid var(--weli-border);
    border-radius: 12px;
    box-shadow: var(--weli-shadow-card);
    overflow: hidden;
    margin-top: 24px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    color: var(--weli-text-primary);
    transition: box-shadow 0.25s, background 0.3s, border-color 0.3s;
    position: relative; /* contexte pour les overlays */
    /* Facteur d'échelle global de l'instance — de 1 (100%, taille actuelle)
       à 0.5 (50%) — piloté par cfg.scale et/ou le curseur de la toolbar.
       zoom (pas transform:scale) : recalcule vraiment le layout, donc tout
       le positionnement JS en pixels (tooltips, menus marble, popups...)
       reste juste sans aucun code à adapter. */
    zoom: var(--weli-scale, 1);
}
.weli-wrapper:hover {
    box-shadow: var(--weli-shadow-hover);
}
/* Quand une image de fond est définie, les th sticky doivent rester opaques */
.weli-has-bg .weli-th-title,
.weli-has-bg .weli-theadrow:hover .weli-th-title,
.weli-has-bg .weli-th-title:hover {
    background-image: none !important;
    background-color: var(--weli-bg-thead, #2d3748) !important;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.weli-header {
    display: flex;
    flex-wrap: wrap; /* bascule la toolbar sur sa propre ligne si la place manque — pas de seuil fixe, purement piloté par le contenu */
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--weli-bg-header-inner);
    border-bottom: 1px solid var(--weli-border-header);
    transition: background 0.3s, border-color 0.3s;
    container-type: inline-size; /* référence des cqi utilisés par .weli-toolbar */
}
.weli-title {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    white-space: nowrap;
    gap: 6px;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--weli-text-primary);
}
.weli-subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--weli-text-secondary);
}
.weli-actions {
    display: flex;
    gap: 8px;
}
.btn-weli {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--weli-btn-border);
    background: var(--weli-btn-bg);
    color: var(--weli-btn-fg);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.btn-weli:hover {
    border-color: var(--weli-accent);
    color: var(--weli-accent);
}

/* ══════════════════════════════════════
   ZONE SCROLLABLE
══════════════════════════════════════ */
.weli-table-container {
    max-height: 450px;
    overflow-y: auto;
    overflow-x: auto;
    /* Réserve l'espace de la scrollbar verticale même quand elle n'est pas
       affichée : depuis que les colonnes auto-fittées remplissent 100% de la
       largeur (minmax(Xpx, 1fr), voir _autoFitColumn dans weli.ui.js), sans
       ça la poignée de redimensionnement de la dernière colonne se
       retrouvait sous la scrollbar native dès qu'il y avait assez de lignes
       pour déclencher le scroll vertical — plus cliquable/double-cliquable. */
    scrollbar-gutter: stable;
    /* Empêche le scroll chaining : une fois la grille arrivée au bout de son
       propre défilement (horizontal ou vertical), le geste (molette, trackpad,
       glissé tactile) ne doit pas continuer sur la page hôte — sinon, sur une
       page où la grille n'est pas dans un cadre isolé (iframe), continuer à
       faire défiler après la limite droite/basse de la grille fait défiler la
       page elle-même par-dessous, et des éléments d'interface hors grille
       (ex: le macaron de version de l'appli hôte) sortent de l'écran. */
    overscroll-behavior: contain;
    border-top: 1px solid var(--weli-border);
    position: relative;
    transition: opacity 0.2s;
}
.weli-table-container.weli-loading {
    opacity: 0.45;
    pointer-events: none;
}

/* ══════════════════════════════════════
   TABLE (CSS Grid — remplace <table> : .weli-table est la grille, chaque
   ligne (.weli-theadrow/.weli-data-row) est une subgrid qui hérite des
   pistes de colonnes définies ici via grid-template-columns, injecté en
   JS — voir _gridTemplateColumns dans weli.render.js. Les largeurs de
   colonnes sont donc pilotées par les pistes, plus par table-layout.)
══════════════════════════════════════ */
.weli-table {
    display: grid;
    width: 100%;
    min-width: 0;
    align-content: start;
}
.weli-theadrow {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    z-index: 12;
    overflow: visible;
    position: sticky;
    top: 0;
}
.weli-tbody {
    display: contents; /* ses lignes deviennent des items directs de la grille parente */
}
.weli-data-row {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
}
.weli-cell {
    display: flex;
    flex-direction: column;
    /* stretch (défaut align-self grid) : la cellule occupe toute la hauteur
       de la ligne — indispensable pour que le hover/la sélection colorent
       toute la ligne, pas juste la hauteur du contenu. L'alignement vertical
       du contenu se fait via justify-content (posé en inline-style selon la
       propriété "valign" de la colonne), pas via align-self. */
    border-bottom: none;
    transition: background 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* autorise un item de grille à rétrécir sous son contenu intrinsèque */
}
/* Cellules à contenu riche : autoriser le retour à la ligne.
   Le max-width est posé sur .weli-richtext (le contenu), pas sur la cellule
   elle-même : sinon la cellule (grid item) reste plus étroite que sa piste
   de colonne, et l'espace restant — non couvert par le fond de .weli-cell —
   laisse transparaître le fond blanc du conteneur au lieu de la couleur de
   ligne/hover. */
.weli-cell.weli-cell-bbcode,
.weli-cell.weli-cell-textarea {
    white-space: normal;
    overflow: hidden;
}
.weli-cell.weli-cell-bbcode > .weli-richtext,
.weli-cell.weli-cell-textarea > .weli-richtext {
    max-width: 300px;
    overflow: hidden;
    /* Un token sans espace (URL, bloc de code...) plus large que max-width
       était tronqué net sans aucun indice ni moyen de voir la suite : on
       force la coupure du mot plutôt que le débordement silencieux. */
    overflow-wrap: anywhere;
}
/* Liseré horizontal entre lignes */
.weli-row-borders .weli-tbody .weli-cell {
    border-bottom: 1px solid var(--weli-border);
}
/* Liseré vertical entre colonnes */
.weli-col-borders .weli-cell,
.weli-col-borders .weli-th-title {
    border-right: 1px solid var(--weli-border);
}
.weli-col-borders .weli-data-row .weli-cell:last-child,
.weli-col-borders .weli-theadrow .weli-th-title:last-child {
    border-right: none;
}

/* Titres — la ligne d'en-tête (.weli-theadrow) est sticky dans son ensemble
   (voir plus haut), plus besoin de sticky par cellule comme avec <table>. */
.weli-th-title {
    position: relative; /* ancre .weli-col-resize-handle (position:absolute) sur SA cellule, pas sur toute la ligne sticky */
    z-index: 12;
    padding: 0;
    vertical-align: top;
    color: var(--weli-text-thead) !important;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    background: var(--weli-bg-thead, #2d3748);
    overflow: visible;
}
.weli-theadrow:hover .weli-th-title,
.weli-th-title:hover {
    color: var(--weli-text-thead) !important;
    background: var(--weli-bg-thead, #2d3748) !important;
}

/* Partie haute (label, tri, marble) */
.weli-th-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    padding: 0 10px 0 30px; /* 30px = 4+14+4(marble-zone)+8(input-padding) = texte de l'input */
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    /* Hauteur fixe : absorbe le passage en bold sans bouger la ligne de séparation */
    min-height: 36px;
    box-sizing: border-box;
}
/* Partie basse (input filtre) */
/* Filtre avec colonne gauche (sort-icon + marble) + input */
.weli-th-filter--with-marble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: 4px !important;
}
.weli-th-filter--with-marble .weli-search-input,
.weli-th-filter--with-marble .weli-date-filter-wrap {
    flex: 1 1 5ch;
    min-width: 5ch;
}
/* Sort icon dans le th-top : position absolute à gauche, hors du flux flex
   → le label peut s'aligner librement sans être décalé par l'icône.
   Largeur fixe = celle de la marble (14px) pour un alignement parfait. */
.weli-sort-icon--top {
    position: absolute;
    left: 0;
    width: 18px; /* = filter-padding(4px) + marble(14px) = zone au-dessus de la marble */
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    font-weight: 700;
    color: var(--weli-text-thead, #f1f5f9);
    text-align: center;
    line-height: 1;
    pointer-events: none;
    overflow: visible;
}
/* Macaron de tri actif : badge rond façon bouton émaillé — dégradé pour le
   volume (haut clair → bas foncé), triple ombre interne pour le relief
   (lumière en haut, ombre en bas, portée en dessous) + un cerclage brillant
   (fin liseré clair) qui referme le macaron. Thème clair : fond noir, flèche
   blanche, cerclage blanc, ombre sombre. Thème sombre : inversé (fond blanc,
   flèche noire, cerclage noir, ombre claire). */
.weli-sort-icon--top.weli-sort-active {
    /* pas de position:relative ici : la classe de base (.weli-sort-icon--top,
       plus haut) est déjà position:absolute (top:50%+translateY(-50%), le
       bon idiome de centrage vertical) — elle sert déjà de contexte de
       positionnement pour le <sup> en absolute ci-dessous. Ajouter
       position:relative ici cassait ce centrage : "top" devient alors un
       décalage relatif à la position de flux normale au lieu d'un
       positionnement absolu, désynchronisant le macaron du texte du titre. */
    left: 1px; /* décale tout le macaron de 1px vers la droite (retour utilisateur) */
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(155deg, #333 0%, #000 55%, #000 100%);
    box-shadow:
        0 0 0 1px rgba(255,255,255,.9),          /* cerclage brillant */
        inset 0 1px 1.5px rgba(255,255,255,.5),  /* relief : lumière en haut */
        inset 0 -1.5px 2px rgba(0,0,0,.6),        /* relief : ombre en bas */
        0 1px 2px rgba(0,0,0,.5);                 /* ombre portée sombre */
    font-size: 10px;
}
.weli-sort-icon--top.weli-sort-active.weli-sort-desc {
    /* le glyphe ▼ (descendant) a un centre optique légèrement différent de
       ▲ (montant) selon les fontes — décalage demandé par l'utilisateur pour
       ce cas précis uniquement (ne touche pas ▲). */
    padding-right: 2px;
}
.weli-sort-icon--top.weli-sort-active sup {
    /* le parent est en display:flex → vertical-align (comportement natif de
       <sup>) est ignoré par les items flex, et même en repositionnant via
       align-self/margin le point d'ancrage restait au coin du carré englobant,
       donc hors du cercle inscrit quel que soit l'angle. Positionnement
       absolu avec un décalage calculé pour rester dans le cercle (distance
       au centre < rayon) au lieu de compter sur le flux flex. */
    position: absolute;
    top: 4.5px;
    right: 3.5px;
    margin: 0;
    font-size: 7px;
    line-height: 1;
}
[data-theme="dark"] .weli-sort-icon--top.weli-sort-active,
.weli-wrapper[data-theme="dark"] .weli-sort-icon--top.weli-sort-active {
    color: #000;
    background: linear-gradient(155deg, #fff 0%, #f1f5f9 55%, #e2e8f0 100%);
    box-shadow:
        0 0 0 1px rgba(0,0,0,.9),                 /* cerclage noir */
        inset 0 1px 1.5px rgba(255,255,255,.9),   /* relief : lumière en haut */
        inset 0 -1.5px 2px rgba(0,0,0,.25),        /* relief : ombre en bas */
        0 1px 2px rgba(255,255,255,.5);            /* ombre portée claire */
}
/* Thème minimal : fond clair → icône inactive foncée. Le macaron actif est
   exclu (:not) : même spécificité que la règle du macaron (2 classes) et
   placée après dans le fichier, elle gagnait la cascade et écrasait la
   couleur de flèche voulue par thème (blanche en clair, noire en sombre). */
.weli-theme-minimal .weli-sort-icon--top:not(.weli-sort-active) {
    color: var(--weli-thead-minimal-fg, #334155);
}

/* Marble dans la barre de filtre */
.weli-col-marble--filter {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    opacity: 1;
    cursor: pointer;
    color: #64748b;
}
.weli-col-marble--filter:hover {
    color: #1e3a5f;
}
[data-theme="dark"] .weli-col-marble--filter {
    color: #94a3b8;
}
[data-theme="dark"] .weli-col-marble--filter:hover {
    color: #e2e8f0;
}
.weli-col-marble--filter svg {
    width: 14px;
    height: 14px;
    display: block;
}
.weli-th-filter {
    padding: 4px 8px 6px;
    background: var(--weli-bg-filter, #e2e8f2);
    border-top: 1px solid var(--weli-border);
    border-bottom: 1px solid var(--weli-border);
}
.weli-th-filter > * { width: 100%; }
/* Annuler width:100% pour les enfants directs en mode with-marble (flex layout) */
.weli-th-filter--with-marble > * { width: auto; }
.weli-th-filter--with-marble > .weli-search-input,
.weli-th-filter--with-marble > .weli-date-filter-wrap { flex: 1 1 5ch; min-width: 5ch; width: auto; }
.weli-th-filter input,
.weli-th-filter select { background: #ffffff !important; }
/* Input filtre LOV actif (value = clé FK, placeholder = libellé) :
   le placeholder doit être lisible comme une vraie valeur, pas grisé */
.weli-th-filter input:not(:placeholder-shown)::placeholder {
    color: inherit;
    opacity: 1;
}
[data-theme="dark"] .weli-th-filter input,
[data-theme="dark"] .weli-th-filter select {
    background:   #1e3a5f !important;
    color:        #e2e8f0 !important;
    border-color: #334155 !important;
}

.weli-search-input {
    display: block;
    width: 100%;
    min-width: 5ch;
    height: 28px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--weli-border-input);
    border-radius: 4px;
    box-sizing: border-box;
    background: var(--weli-bg-input);
    color: var(--weli-text-input);
    font-weight: normal;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.3s;
}
.weli-search-input:focus {
    border-color: var(--weli-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--weli-accent-light);
}

/* Lignes du corps */
.weli-tbody .weli-data-row:hover .weli-cell { background: var(--weli-bg-hover); }
.weli-tbody .weli-cell {
    padding: 10px 16px;
    vertical-align: middle;
    color: var(--weli-text-primary);
}

/* ══════════════════════════════════════
   MODES D'AFFICHAGE
══════════════════════════════════════ */
.weli-display-compact .weli-th-title {
    padding: 0;
    font-size: 13px;
}
.weli-display-compact .weli-cell {
    /* 2px de marge horizontale : en 0 pile, le texte aligné à gauche ou à
       droite touche directement le bord de la cellule. */
    padding: 0 2px;
    font-size: 13px;
}
.weli-display-compact .weli-th-top { padding: 0 10px 0 25px; } /* 25px = laisse la place au macaron (21px + cerclage) sans chevaucher le titre */
.weli-display-compact .weli-th-check-top { padding: 6px 0 3px !important; }
.weli-display-compact .weli-th-filter { padding: 3px 8px 4px; }

/* Mode light : pas de ligne de filtre/marble par colonne, pas de colonne de
   sélection (coches) — voir weli.render.js buildStructure(). L'en-tête ne
   contient donc que .weli-th-top, qui n'a plus besoin d'une hauteur fixe
   pensée pour absorber le passage en bold sans bouger une 2e ligne en
   dessous : un peu plus bas que compact, un peu moins que full. */
.weli-display-light .weli-th-top { min-height: 32px; }

/* ══════════════════════════════════════
   THÈMES DE TABLEAU
══════════════════════════════════════ */
.weli-theme-default .weli-th-title { background: var(--weli-thead-default); }
.weli-theme-emerald .weli-th-title { background: var(--weli-thead-emerald); }
.weli-theme-ocean   .weli-th-title { background: var(--weli-thead-ocean); }
.weli-theme-minimal .weli-th-title {
    background: var(--weli-thead-minimal-bg);
    color: var(--weli-thead-minimal-fg) !important;
    --weli-text-thead: var(--weli-thead-minimal-fg); /* redéfinir localement pour les enfants */
}
.weli-theme-default .weli-theadrow:hover .weli-th-title { background: var(--weli-thead-default) !important; }
.weli-theme-emerald .weli-theadrow:hover .weli-th-title { background: var(--weli-thead-emerald) !important; }
.weli-theme-ocean   .weli-theadrow:hover .weli-th-title { background: var(--weli-thead-ocean)   !important; }
/* Thèmes — couleur de fond du thead via variable locale */
.weli-theme-default { --weli-bg-thead: #2d3748; }
.weli-theme-emerald { --weli-bg-thead: #234e52; }
.weli-theme-ocean   { --weli-bg-thead: #1e4d8c; }
.weli-theme-minimal { --weli-bg-thead: var(--weli-thead-minimal-bg); }

[data-theme="dark"] .weli-theme-default ,
.weli-wrapper[data-theme="dark"] .weli-theme-default { --weli-bg-thead: #1e3a5f; }
[data-theme="dark"] .weli-theme-emerald ,
.weli-wrapper[data-theme="dark"] .weli-theme-emerald { --weli-bg-thead: #14403e; }
[data-theme="dark"] .weli-theme-ocean   ,
.weli-wrapper[data-theme="dark"] .weli-theme-ocean   { --weli-bg-thead: #1e40af; }
[data-theme="dark"] .weli-theme-minimal ,
.weli-wrapper[data-theme="dark"] .weli-theme-minimal { --weli-bg-thead: #1e293b; }

/* Protéger le fond au hover */
.weli-theadrow:hover .weli-th-title,
.weli-th-title:hover {
    background: var(--weli-bg-thead) !important;
}
.weli-theme-minimal .weli-theadrow:hover .weli-th-title {
    background: var(--weli-thead-minimal-bg) !important;
    color: var(--weli-thead-minimal-fg) !important;
}

/* ══════════════════════════════════════
   TRI
══════════════════════════════════════ */
.weli-th-sortable { cursor: pointer; user-select: none; }
/* opacity retiré sur th-sortable:hover — rendait le thead transparent sur fond d'image */
.weli-sort-icon:not(.weli-sort-icon--top) {
    display: inline-block;
    margin-left: 5px;
    font-size: 11px;
    opacity: 0.7;
}
.weli-sort-active { opacity: 1; color: var(--weli-text-thead, #f1f5f9); }
/* Macaron (.weli-sort-icon--top) exclu : même spécificité que la règle
   macaron (weli.css l.475) et placée après dans le fichier, elle gagnait la
   cascade et écrasait sa couleur par thème (via héritage, ça touchait aussi
   le <sup> qui n'a pas sa propre couleur). */
.weli-theme-minimal .weli-sort-active:not(.weli-sort-icon--top) { color: var(--weli-thead-minimal-fg, #334155); }
.weli-th-sorted .weli-th-label { font-weight: 700; }

/* ══════════════════════════════════════
   SÉLECTION DE LIGNES
══════════════════════════════════════ */
.weli-tbody .weli-row-selected .weli-cell {
    background: color-mix(in srgb, var(--weli-accent) 12%, transparent) !important;
    border-bottom-color: color-mix(in srgb, var(--weli-accent) 25%, transparent);
}
.weli-tbody .weli-row-selected:hover .weli-cell {
    background: color-mix(in srgb, var(--weli-accent) 20%, transparent) !important;
}
/* .weli-td-check (colonne figée, cf. plus bas) doit rester opaque même
   cochée : les deux règles ci-dessus mixent sur `transparent`, ce qui est
   sans conséquence pour une cellule normale (non figée) mais laisse voir
   par transparence les colonnes qui défilent dessous pour celle-ci — même
   spécificité (3 classes + !important), donc c'est l'ordre dans la feuille
   qui doit trancher : cette règle doit rester déclarée APRÈS les deux
   ci-dessus pour les gagner. Mélange sur --weli-bg-card (opaque) au lieu de
   transparent, teinte identique à l'écran. */
.weli-tbody .weli-row-selected .weli-td-check {
    background: color-mix(in srgb, var(--weli-accent) 12%, var(--weli-bg-card)) !important;
}
.weli-tbody .weli-row-selected:hover .weli-td-check {
    background: color-mix(in srgb, var(--weli-accent) 20%, var(--weli-bg-card)) !important;
}
.weli-tbody .weli-data-row { cursor: pointer; }
/* En édition groupée, le clic sur la ligne ne fait plus rien (voir le
   garde-fou editMode dans bindRowChecks) : curseur normal. */
.weli-editing .weli-tbody .weli-data-row { cursor: default; }

.weli-th-check,
.weli-td-check {
    width: 36px !important;
    min-width: 36px;
    max-width: 36px;
    text-align: center !important;
    padding: 0 !important;
    /* Colonne figée à gauche pendant le scroll horizontal de la grille (les
       autres colonnes défilent dessous) — indispensable pour garder la coche
       de sélection accessible sur une table large. z-index positionne la
       cellule au-dessus des cellules statiques qui glissent en dessous. */
    position: sticky;
    left: 0;
    z-index: 2;
    user-select: none;
    border-right: 1px solid rgba(0,0,0,.28);
    box-shadow: 1px 0 0 0 rgba(255,255,255,.6);
}
/* Fond opaque : sans lui, la cellule figée transparente laisserait voir par
   transparence les autres cellules qui défilent en dessous (elle n'a pas de
   fond propre par défaut — seul .weli-wrapper en a un). Les patterns
   row_colors et le survol de ligne (tous deux ciblant .weli-cell) restent
   prioritaires : ils s'appliquent aussi à .weli-td-check, qui les matche. */
.weli-td-check { cursor: pointer; background: var(--weli-bg-card); }
/* .weli-th-title (tout en-tête de colonne, y compris cette cellule) est déjà
   à z-index:12 — un z-index:2 laissait les EN-TÊTES des colonnes normales
   qui défilent dessous (ex. id, ts…) repasser par-dessus l'en-tête figé dès
   que leur boîte (fond + icônes en position absolue) chevauchait son
   emplacement à l'écran : le logo weli/la coche "tout cocher" disparaissaient,
   masqués par le fond opaque de la colonne censée être derrière. Seul l'en-tête
   (pas les cellules de données, jamais à z-index:12) a besoin de passer
   au-dessus de ce 12. */
.weli-th-check { z-index: 13; }
/* Checkbox native invisible — couvre toute la cellule pour le clic */
.weli-row-check,
.weli-check-all {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    z-index: 2;
}
/* Rond blanc plein derrière la coche — repère fixe et lisible sur tous les fonds */
.weli-td-check::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    /* Plafonné à la hauteur réelle de la ligne (mode compact, texte court…) :
       sans ça, un rond de taille fixe peut dépasser une ligne plus basse
       que ses 18px et empiéter visuellement sur la ligne suivante. */
    max-width: 70%;
    max-height: 70%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.15);
    transform: translate(-50%, -50%) scale(0);
    transition: transform .12s;
    z-index: 0;
}
.weli-td-check:hover::before,
.weli-row-selected .weli-td-check::before {
    transform: translate(-50%, -50%) scale(1);
}
/* SVG checkmark centré dans la cellule, par-dessus le rond blanc */
.weli-check-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 13px;
    height: 13px;
    max-width: 55%;
    max-height: 55%;
    pointer-events: none;
    z-index: 1;
}
.weli-check-poly {
    fill: transparent;
    transition: fill .12s;
}
/* Hover */
.weli-td-check:hover .weli-check-poly {
    fill: #1f2937;
}
/* Ligne sélectionnée */
.weli-row-selected .weli-check-poly {
    fill: #1f2937 !important;
}
.weli-row-selected .weli-td-check:hover .weli-check-poly {
    fill: #1f2937 !important;
}
/* ── Zone "weli" verticale dans le coin supérieur gauche ── */
.weli-th-check-top {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0 4px !important;
    overflow: hidden;
    width: 100%;
    min-height: 36px;
    box-sizing: border-box;
}
.weli-th-check-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #fff;
    border: 1.5px solid rgba(0,0,0,0.55);
    border-radius: 50%;
    cursor: default;
    user-select: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    flex-shrink: 0;
}
.weli-th-check-brand:hover {
    background: #fff;
    border-color: var(--weli-accent, #2563eb);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.weli-brand-svg {
    width: 13px;
    height: 9px;
    display: block;
    fill: #1e293b;
}

/* Cellule checkbox — le th contient weli-th-top (vide) + weli-th-filter (check-all) */
.weli-th-check {
    vertical-align: top;
    padding: 0 !important;
    width: 36px !important;
    min-width: 36px;
    max-width: 36px;
    background: var(--weli-bg-thead, #2d3748) !important;
}
/* Zone checkbox dans la partie filtre — suit le flux normal (comme les
   .weli-th-filter des autres colonnes) pour rester alignée avec elles ;
   un span invisible de 28px reproduit la hauteur d'un .weli-search-input */
.weli-th-check-filter {
    cursor: pointer;
    position: relative;
    background: var(--weli-bg-filter, #e2e8f2);
    border-top: 1px solid var(--weli-border);
    border-bottom: 1px solid var(--weli-border);
    padding: 4px 0 6px;
}
.weli-th-check-filter .weli-th-check-spacer {
    display: block;
    height: 28px;
}
/* Coche du "tout cocher" — même style que la coche de ligne (rond blanc +
   coche noire), mais visible UNIQUEMENT si la case est effectivement cochée
   (rien au survol, rien tant qu'on n'a pas cliqué) */
.weli-check-all-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    max-width: 70%;
    max-height: 70%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.15);
    transform: translate(-50%, -50%) scale(0);
    transition: transform .12s;
    pointer-events: none;
    z-index: 0;
}
.weli-check-all-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 13px;
    height: 13px;
    max-width: 55%;
    max-height: 55%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform .12s;
    pointer-events: none;
    z-index: 1;
}
.weli-check-all-poly {
    fill: #1f2937;
}
.weli-check-all:checked ~ .weli-check-all-circle,
.weli-check-all:checked ~ .weli-check-all-svg {
    transform: translate(-50%, -50%) scale(1);
}
/* Survol de la zone check-all : même comportement que les td-check */
.weli-th-check-filter:hover .weli-check-all-circle {
    transform: translate(-50%, -50%) scale(1);
}
.weli-th-check-filter:hover .weli-check-all-svg {
    transform: translate(-50%, -50%) scale(1);
}
/* layout vertical de la cellule */

/* ══════════════════════════════════════
   DIVERS
══════════════════════════════════════ */
.weli-required { color: #f87171; margin-left: 2px; }

.weli-empty {
    text-align: center;
    padding: 30px !important;
    color: var(--weli-text-secondary);
    font-style: italic;
}

.weli-error {
    color: red;
    padding: 20px;
}

/* ══════════════════════════════════════
   OVERLAY DE CHARGEMENT
══════════════════════════════════════ */
.weli-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 12px;
    animation: weli-overlay-in 0.15s ease;
}
[data-theme="dark"] .weli-overlay ,
.weli-wrapper[data-theme="dark"] .weli-overlay {
    background: rgba(15,23,42,0.5);
}
@keyframes weli-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.weli-spinner {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.18));
}
.weli-spinner-arc {
    transform-origin: 50% 50%;
    animation: weli-spin 0.6s infinite linear;
}
@keyframes weli-spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════
   MODAL COLONNES
══════════════════════════════════════ */
.weli-colmodal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: weli-overlay-in 0.15s ease;
}
.weli-colmodal {
    /* Suit le thème de la weli parente au lieu de le forcer en clair. */
    --weli-text-muted:       #94a3b8;
    background: var(--weli-bg-card);
    border: 1px solid var(--weli-border);
    border-radius: 10px;
    box-shadow: var(--weli-shadow-hover);
    width: 50vw;
    height: 50vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: weli-modal-in 0.18s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes weli-modal-in {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}
.weli-colmodal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--weli-bg-header-inner);
    border-bottom: 1px solid var(--weli-border);
    flex-shrink: 0;
}
.weli-colmodal-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--weli-text-primary);
}
.weli-colmodal-close {
    width: 28px !important;
    height: 28px !important;
    font-size: 14px;
    line-height: 1;
}
.weli-colmodal-mount {
    flex: 1;
    min-height: 0;      /* indispensable pour que flex + overflow fonctionnent */
    overflow-y: auto;   /* ascenseur sur le mount, pas sur le wrapper enfant */
    display: flex;
    flex-direction: column;
}
/* Spinner affiché pendant le chargement de la weli enfant */
.weli-distmodal-mount {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}
.weli-distmodal-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    pointer-events: none;
    z-index: 10;
}
/* Disparaît dès que le mount est peuplé (géré via JS dans openValModal) */
.weli-distmodal-spinner.hidden {
    display: none;
}
/* weli-container est l'intermédiaire entre mount et wrapper — doit aussi être flex */
.weli-distmodal-mount > .weli-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.weli-distmodal-mount .weli-wrapper {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.weli-distmodal-mount .weli-table-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto !important;
    max-height: none !important;
}

.weli-colmodal-mount .weli-wrapper {
    flex: 1;
    margin-top: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.weli-colmodal-mount .weli-table-container {
    border-top: none;
    max-height: none;   /* la hauteur est portée par .weli-colmodal-mount */
    overflow: visible;
}


.weli-tool-btn--primary {
    background: var(--weli-accent) !important;
    border-color: var(--weli-accent) !important;
    color: #fff !important;
}
.weli-tool-btn--primary:hover {
    opacity: 0.88;
    background: var(--weli-accent) !important;
}
.weli-tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.weli-tool-btn--primary:disabled:hover,
.weli-tool-btn:disabled:hover {
    opacity: 0.4;
}

/* ══════════════════════════════════════
   RENDU PAR TYPE DE COLONNE
══════════════════════════════════════ */

/* Null / vide */
.weli-null {
    color: var(--weli-text-secondary);
    font-style: italic;
    opacity: 0.55;
}

/* Booléen */
.weli-bool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}
.weli-bool--yes {
    background: color-mix(in srgb, #10b981 15%, transparent);
    color: #059669;
    border: 1.5px solid #10b981;
}
.weli-bool--no {
    background: color-mix(in srgb, #94a3b8 12%, transparent);
    color: var(--weli-text-secondary);
    border: 1.5px solid var(--weli-border);
}
[data-theme="dark"] .weli-bool--yes ,
.weli-wrapper[data-theme="dark"] .weli-bool--yes { color: #34d399; border-color: #34d399; }
[data-theme="dark"] .weli-bool--no  ,
.weli-wrapper[data-theme="dark"] .weli-bool--no  { color: #64748b; }

/* Date / Heure */
.weli-cell-date,
.weli-cell-datetime,
.weli-cell-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.weli-time {
    font-family: monospace;
    font-size: 13px;
}

/* Nombres */
.weli-cell-integer,
.weli-cell-decimal { font-variant-numeric: tabular-nums; }

/* Liens */
.weli-link {
    color: var(--weli-accent);
    text-decoration: none;
    font-size: 13px;
    border-bottom: 1px dotted color-mix(in srgb, var(--weli-accent) 50%, transparent);
    transition: border-color 0.15s;
}
.weli-link:hover { border-bottom-color: var(--weli-accent); }

/* Couleur */
.weli-cell-color { white-space: nowrap; }
.weli-color-swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--weli-border);
    vertical-align: middle;
    margin-right: 6px;
    flex-shrink: 0;
}
.weli-color-val {
    font-family: monospace;
    font-size: 12px;
    vertical-align: middle;
    color: var(--weli-text-secondary);
}

/* ══════════════════════════════════════
   RICHTEXT — TYPE TEXTAREA (TinyMCE)
══════════════════════════════════════ */

/* Mode lecture */
.weli-richtext {
    font-size: 13px;
    line-height: 1.6;
    color: var(--weli-text-primary);
}
.weli-richtext p          { margin: 0 0 6px; }
.weli-richtext ul,
.weli-richtext ol         { margin: 0 0 6px; padding-left: 18px; }
.weli-richtext li         { margin-bottom: 2px; }
.weli-richtext a:not(.weli-file-link) { color: var(--weli-accent); }
.weli-richtext strong     { font-weight: 700; }
.weli-richtext em         { font-style: italic; }

.weli-bbcode-colorpicker {
    position: absolute;
    top: 100%;
    left: auto;
    right: 0;
    z-index: 9999;
    background: var(--weli-surface, #fff);
    border: 1px solid var(--weli-border, #e5e7eb);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    min-width: 240px;
    margin-top: 4px;
}
.weli-bbcode-colorpicker-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}
.weli-bbcode-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,.15);
    cursor: pointer;
    padding: 0;
    transition: transform .1s;
}
.weli-bbcode-swatch:hover { transform: scale(1.25); border-color: var(--weli-accent, #3b82f6); }
.weli-bbcode-colorpicker-custom {
    display: flex;
    gap: 6px;
    align-items: center;
    border-top: 1px solid var(--weli-border, #e5e7eb);
    padding-top: 8px;
}
.weli-bbcode-color-native {
    width: 32px;
    height: 28px;
    padding: 1px;
    border: 1px solid var(--weli-border, #e5e7eb);
    border-radius: 4px;
    cursor: pointer;
    background: none;
}
.weli-bbcode-color-hex {
    flex: 1;
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--weli-border, #e5e7eb);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}
.weli-bbcode-color-apply {
    height: 28px;
    padding: 0 10px;
    background: var(--weli-accent, #3b82f6);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}
.weli-bbcode-color-apply:hover { opacity: .85; }


    min-width: 280px;
    padding: 4px !important;
    vertical-align: top !important;
}
.weli-tmce-field {
    width: 100%;
    min-height: 80px;
}
.weli-tmce-field:not(.tox-textarea) {
    visibility: hidden;
    height: 0;
    position: absolute;
}
/* ── Champ LOV dans la modale CRUD ──────────────────────────────────────── */
.weli-crud-input--lov {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px !important;
}
.weli-crud-input--lov:hover {
    border-color: var(--weli-accent, #3b82f6) !important;
}

/* ═══════════════════════════════════════════════════════════════════════
   Styles injectés (ex-weli.css.js) — modales, TinyMCE, menus, thèmes
   ═══════════════════════════════════════════════════════════════════════ */
.weli-th-dirty .weli-th-label {
    font-weight: 800;
    color: var(--weli-accent, #3b82f6);
    transition: color .2s;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.weli-th-dirty {
    cursor: pointer;
}

/* ── Modale TinyMCE ── */
.weli-tinymce-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    backdrop-filter: blur(3px); z-index: 2000;
    align-items: center; justify-content: center;
}
/* Menus flottants TinyMCE (dropdowns, pickers couleur, etc.)
   doivent passer au-dessus de la modale weli (z-index 2000) */
.tox.tox-tinymce-aux,
.tox-tinymce-aux,
.tox .tox-menu,
.tox .tox-collection,
.tox .tox-dialog-wrap,
.tox .tox-pop,
.tox-pop__dialog {
    z-index: 2100 !important;
}
.weli-tinymce-modal {
    --weli-bg-card:          #f5f7fa;
    --weli-bg-thead:         #2d3748;
    --weli-bg-filter:        #e2e8f2;
    --weli-bg-input:         #ffffff;
    --weli-bg-hover:         #dce4f0;
    --weli-border:           #c8d3e0;
    --weli-border-input:     #b0bdd0;
    --weli-text-primary:     #1e293b;
    --weli-text-secondary:   #475569;
    --weli-text-muted:       #94a3b8;
    --weli-accent:           #3b82f6;
    background: #fff; border-radius: 12px; width: 760px; max-width: 94vw;
    max-height: 88vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.35);
}
.weli-tinymce-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
.weli-tinymce-title { font-weight: 700; font-size: 15px; color: #1e293b; }
.weli-tinymce-body  { flex: 1; padding: 16px; overflow: visible; min-height: 0; }
.weli-tinymce-body textarea { width: 100%; box-sizing: border-box; }
.weli-tinymce-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 12px 20px; border-top: 1px solid #e2e8f0; background: #f8fafc;
}
/* ── Modale BBCode ── */
.weli-bbcode-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    backdrop-filter: blur(3px); z-index: 2000;
    align-items: center; justify-content: center;
}
.weli-bbcode-modal {
    background: #fff; border-radius: 12px; width: 680px; max-width: 94vw;
    max-height: 88vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.35); overflow: hidden;
}
.weli-bbcode-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
}
.weli-bbcode-title { font-weight: 400; font-size: 15px; color: #1e293b; }
.weli-bbcode-title strong { font-weight: 700; }
.weli-bbcode-header-actions { display: flex; gap: 6px; align-items: center; }
.weli-bbcode-help-btn { font-family: inherit; font-weight: 700; }
/* ── Panneau d'aide BBCode ── */
.weli-bbcode-help {
    border-bottom: 1px solid #e2e8f0;
    background: #fffdf5;
    padding: 12px 18px;
    max-height: 260px;
    overflow-y: auto;
}
.weli-bbcode-help-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.weli-bbcode-help-table th {
    text-align: left; padding: 4px 8px; font-size: 10.5px;
    text-transform: uppercase; letter-spacing: .03em; color: #94a3b8;
    border-bottom: 1px solid #fde68a;
}
.weli-bbcode-help-table td {
    padding: 5px 8px; vertical-align: top;
    border-bottom: 1px solid #fef3c7;
    color: #334155;
}
.weli-bbcode-help-table tr:last-child td { border-bottom: none; }
.weli-bbcode-help-table code {
    font-family: 'Cascadia Code', 'Fira Mono', monospace;
    font-size: 11px; background: #f1f5f9; color: #be185d;
    padding: 1px 5px; border-radius: 4px; white-space: nowrap;
}
.weli-bbcode-help-sep {
    background: #fef3c7 !important; font-weight: 700; color: #92400e !important;
    text-align: center;
}
.weli-bbcode-toolbar {
    display: flex; flex-wrap: wrap; gap: 4px;
    padding: 10px 16px; border-bottom: 1px solid #e2e8f0; background: #f1f5f9;
    position: relative;
}
.weli-bbcode-btn {
    border: 1px solid #cbd5e1; background: #fff; border-radius: 5px;
    padding: 3px 9px; font-size: 12px; font-weight: 700; cursor: pointer;
    color: #334155; transition: background .15s, border-color .15s;
    font-family: 'Cascadia Code', 'Fira Mono', monospace;
}
.weli-bbcode-btn:hover { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
/* ── Loupe image (BBCode [img=...|zoom]) ── */
.weli-img-zoom {
    display: inline-block;
    cursor: default;
    line-height: 0;
}
/* L'image reste inline (pas display:block) pour continuer à répondre au
   text-align hérité de la cellule (Gauche/Centre/Droite) — le line-height:0
   sur l'enveloppe ci-dessus suffit déjà à supprimer l'espace parasite sous
   l'image, sans avoir besoin de la sortir du flux inline. */
.weli-img-zoom-lens {
    display: none;
    position: fixed;
    width: 160px; height: 160px;
    border-radius: 50%;
    border: 4px solid #1a1a1a;
    outline: 2px solid #fff;
    outline-offset: -4px;
    box-shadow: 0 14px 36px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.15);
    pointer-events: none;
    z-index: 9999;
    background-repeat: no-repeat;
    background-color: #f1f5f9;
    box-sizing: border-box;
}
.weli-bbcode-body { flex: 1; padding: 16px; overflow: auto; }
.weli-bbcode-body textarea {
    width: 100%; height: 260px; box-sizing: border-box; resize: vertical;
    font-family: 'Cascadia Code', 'Fira Mono', monospace; font-size: 13px;
    border: 1px solid #cbd5e1; border-radius: 7px; padding: 10px;
    outline: none; transition: border-color .2s;
}
.weli-bbcode-body textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.weli-bbcode-area--dragover {
    border-color: #16a34a !important;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(22,163,74,.18) !important;
}
.weli-bbcode-area--dragover-doc {
    border-color: #3b82f6 !important;
    background: #eff6ff !important;
    box-shadow: 0 0 0 3px rgba(59,130,246,.18) !important;
}

/* ── Lien fichier BBCode [file=url]nom[/file] ── */
.weli-file-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 5px;
    border: 1px solid var(--weli-file-border, #bfdbfe);
    border-radius: 5px;
    background: var(--weli-file-bg, #eff6ff);
    color: var(--weli-file-color, #1e40af);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    transition: background .15s, border-color .15s, box-shadow .15s;
    max-width: 100%;
}
.weli-file-link:hover {
    filter: brightness(1.1);
    box-shadow: 0 1px 4px rgba(59,130,246,.2);
}
.weli-file-link__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: inherit;
}
[data-theme="dark"] .weli-bbcode-area--dragover-doc,
.weli-wrapper[data-theme="dark"] .weli-bbcode-area--dragover-doc {
    border-color: #60a5fa !important;
    background: #1e293b !important;
}

/* ── Modale BBCode — thème sombre ── */
[data-theme="dark"] .weli-bbcode-modal,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-modal,
.weli-wrapper[data-theme="dark"] .weli-bbcode-modal {
    background: #1e293b;
    box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
[data-theme="dark"] .weli-bbcode-header,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-header,
.weli-wrapper[data-theme="dark"] .weli-bbcode-header {
    background: #0f172a;
    border-bottom-color: #334155;
}
[data-theme="dark"] .weli-bbcode-title,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-title,
.weli-wrapper[data-theme="dark"] .weli-bbcode-title {
    color: #e2e8f0;
}
[data-theme="dark"] .weli-bbcode-toolbar,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-toolbar,
.weli-wrapper[data-theme="dark"] .weli-bbcode-toolbar {
    background: #0f172a;
    border-bottom-color: #334155;
}
[data-theme="dark"] .weli-bbcode-btn,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-btn,
.weli-wrapper[data-theme="dark"] .weli-bbcode-btn {
    background: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}
[data-theme="dark"] .weli-bbcode-btn:hover,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-btn:hover,
.weli-wrapper[data-theme="dark"] .weli-bbcode-btn:hover {
    background: #1e3a5f;
    border-color: #60a5fa;
    color: #bfdbfe;
}
[data-theme="dark"] .weli-bbcode-help,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-help,
.weli-wrapper[data-theme="dark"] .weli-bbcode-help {
    background: #1a1f2e;
    border-bottom-color: #334155;
}
[data-theme="dark"] .weli-bbcode-help-table th,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-help-table th,
.weli-wrapper[data-theme="dark"] .weli-bbcode-help-table th {
    color: #64748b;
    border-bottom-color: #334155;
}
[data-theme="dark"] .weli-bbcode-help-table td,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-help-table td,
.weli-wrapper[data-theme="dark"] .weli-bbcode-help-table td {
    color: #94a3b8;
    border-bottom-color: #1e293b;
}
[data-theme="dark"] .weli-bbcode-help-table code,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-help-table code,
.weli-wrapper[data-theme="dark"] .weli-bbcode-help-table code {
    background: #0f172a;
    color: #f472b6;
}
[data-theme="dark"] .weli-bbcode-help-sep,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-help-sep,
.weli-wrapper[data-theme="dark"] .weli-bbcode-help-sep {
    background: #292524 !important;
    color: #fbbf24 !important;
}
[data-theme="dark"] .weli-bbcode-body,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-body,
.weli-wrapper[data-theme="dark"] .weli-bbcode-body {
    background: #1e293b;
}
[data-theme="dark"] .weli-bbcode-body textarea,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-body textarea,
.weli-wrapper[data-theme="dark"] .weli-bbcode-body textarea {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}
[data-theme="dark"] .weli-bbcode-body textarea:focus,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-body textarea:focus,
.weli-wrapper[data-theme="dark"] .weli-bbcode-body textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
[data-theme="dark"] .weli-bbcode-preview,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-preview,
.weli-wrapper[data-theme="dark"] .weli-bbcode-preview {
    background: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}
[data-theme="dark"] .weli-bbcode-preview-label,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-preview-label,
.weli-wrapper[data-theme="dark"] .weli-bbcode-preview-label {
    color: #475569;
}
[data-theme="dark"] .weli-bbcode-footer,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-footer,
.weli-wrapper[data-theme="dark"] .weli-bbcode-footer {
    background: #0f172a;
    border-top-color: #334155;
}
[data-theme="dark"] .weli-bbcode-err-toast,
[data-theme="dark"].weli-bbcode-overlay .weli-bbcode-err-toast,
.weli-wrapper[data-theme="dark"] .weli-bbcode-err-toast {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
}
.weli-bbcode-preview {
    margin-top: 10px; padding: 10px 14px; background: #f8fafc;
    border: 1px solid #e2e8f0; border-radius: 7px;
    font-size: 13px; color: #334155; min-height: 36px;
    word-break: break-word;
}
.weli-bbcode-preview-label {
    font-size: 11px; font-weight: 600; color: #94a3b8;
    text-transform: uppercase; margin-bottom: 4px;
}
.weli-bbcode-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 12px 20px; border-top: 1px solid #e2e8f0; background: #f8fafc;
}
/* ── Calendrier filtre date ── */
.weli-date-filter-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.weli-date-filter-wrap .weli-search-input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 26px !important;
    min-width: 0;
    font-size: inherit;
}
/* Ligne de filtre : fond flouté semi-transparent */
.weli-th-filter {
    background: rgba(var(--weli-bg-header-rgb, 30, 41, 59), 0.72) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .weli-th-filter {
    background: rgba(15, 23, 42, 0.72) !important;
}

[data-theme="dark"] .weli-search-input {
    background: #1e3a5f !important;
    color:       #e2e8f0 !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .weli-search-input:focus {
    background:  #1e3a5f !important;
    color:       #f1f5f9 !important;
    border-color: var(--weli-accent) !important;
}
/* Assure que le th date ne compresse pas l'input */
.weli-th-filter:has(.weli-date-filter-wrap) {
    min-width: 120px;
}
.weli-cal-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    padding: 0;
    border: none;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s;
    z-index: 1;
}
.weli-cal-btn:hover { background: none; color: var(--weli-accent, #3b82f6); }
.weli-cal-btn svg { width: 14px; height: 14px; pointer-events: none; display: block; }
/* ── Calendrier — variables thème ── */
.weli-cal-popup {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 3000;
    background: var(--cal-bg, #fff);
    border: 1px solid var(--cal-border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 10px;
    min-width: 230px;
    user-select: none;
}
.weli-cal-popup.hidden { display: none; }
.weli-cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 4px;
}
.weli-cal-nav button {
    border: none; background: none; cursor: pointer;
    font-size: 16px; padding: 2px 6px; border-radius: 5px;
    color: var(--cal-nav-color, #475569);
    transition: background .15s;
}
.weli-cal-nav button:hover { background: var(--cal-hover-bg, #f1f5f9); }
.weli-cal-nav .weli-cal-title {
    flex: 1; text-align: center;
    font-size: 13px; font-weight: 700;
    color: var(--cal-title-color, #1e293b);
    cursor: pointer;
}
.weli-cal-nav .weli-cal-title:hover { color: var(--weli-accent, #3b82f6); }
.weli-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.weli-cal-grid .weli-cal-dow {
    font-size: 10px; font-weight: 700;
    text-align: center;
    color: var(--cal-dow-color, #94a3b8);
    padding: 2px 0;
}
.weli-cal-grid .weli-cal-day {
    font-size: 12px; text-align: center;
    padding: 4px 2px; border-radius: 5px;
    cursor: pointer;
    color: var(--cal-day-color, #334155);
    transition: background .1s, color .1s;
}
.weli-cal-grid .weli-cal-day:hover { background: var(--cal-day-hover-bg, #eff6ff); color: #1d4ed8; }
.weli-cal-grid .weli-cal-day.today { font-weight: 700; color: var(--weli-accent, #3b82f6); }
.weli-cal-grid .weli-cal-day.selected { background: var(--weli-accent, #3b82f6); color: #fff !important; border-radius: 5px; }
.weli-cal-grid .weli-cal-day.other-month { color: var(--cal-other-month, #cbd5e1); }
.weli-cal-grid .weli-cal-day.empty { cursor: default; }
.weli-cal-footer {
    display: flex; gap: 6px; margin-top: 8px;
}
.weli-cal-today, .weli-cal-clear {
    flex: 1; padding: 4px; font-size: 11px; text-align: center;
    background: none;
    border: 1px solid var(--cal-border, #e2e8f0);
    border-radius: 6px;
    cursor: pointer; transition: background .15s;
}
.weli-cal-today  { color: #2563eb; }
.weli-cal-today:hover  { background: #eff6ff; border-color: #93c5fd; }
.weli-cal-clear  { color: var(--cal-clear-color, #64748b); }
.weli-cal-clear:hover { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
/* Calendrier custom en édition directe de cellule */
.weli-cell-date-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    position: relative;
}
.weli-cell-date-wrap input {
    flex: 1;
    min-width: 0;
    height: 26px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid var(--weli-accent, #3b82f6);
    border-radius: 4px;
    background: var(--weli-bg-input, #fff);
    color: var(--weli-text-input, inherit);
    color-scheme: light dark;
    outline: none;
    box-shadow: 0 0 0 2px var(--weli-accent-light, rgba(59,130,246,.15));
}
.weli-cell-date-wrap .weli-cal-btn {
    flex-shrink: 0;
}
.weli-cell-date-wrap .weli-cal-popup {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 9999;
}

/* ── Calendrier mode sombre ── */
.weli-theme-dark .weli-cal-popup,
[data-theme="dark"] .weli-cal-popup {
    --cal-bg          : #1e293b;
    --cal-border      : #334155;
    --cal-nav-color   : #94a3b8;
    --cal-hover-bg    : #334155;
    --cal-title-color : #e2e8f0;
    --cal-dow-color   : #64748b;
    --cal-day-color   : #cbd5e1;
    --cal-day-hover-bg: #1e3a5f;
    --cal-other-month : #475569;
    --cal-clear-color : #94a3b8;
}
@media (prefers-color-scheme: dark) {
    .weli-cal-popup {
        --cal-bg          : #1e293b;
        --cal-border      : #334155;
        --cal-nav-color   : #94a3b8;
        --cal-hover-bg    : #334155;
        --cal-title-color : #e2e8f0;
        --cal-dow-color   : #64748b;
        --cal-day-color   : #cbd5e1;
        --cal-day-hover-bg: #1e3a5f;
        --cal-other-month : #475569;
        --cal-clear-color : #94a3b8;
    }
}
/* ── Badge cadenas colonne forbidden (editMode) ── */
.weli-th-lock {
    display: inline-block;
    margin-left: 5px;
    font-size: .8em;
    opacity: .6;
    vertical-align: middle;
    line-height: 1;
}
/* ── Modale validation / erreur ── */
.weli-valerr-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
    z-index: 3000; align-items: center; justify-content: center;
}
.weli-valerr-modal {
    background: var(--weli-modal-bg, #fff);
    border-radius: 12px; width: 460px; max-width: 94vw;
    box-shadow: var(--weli-modal-shadow);
    overflow: hidden; display: flex; flex-direction: column;
    border: 1px solid var(--weli-valerr-border, #fecaca);
}
.weli-valerr-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--weli-valerr-border, #fecaca);
    background: var(--weli-valerr-header-bg, #fef2f2);
}
.weli-valerr-header-title {
    font-weight: 700; font-size: 15px;
    color: var(--weli-valerr-title-color, #991b1b);
}
.weli-valerr-close {
    color: var(--weli-valerr-title-color, #991b1b) !important;
}
.weli-valerr-body {
    padding: 16px 20px; font-size: 14px;
    color: var(--weli-body-color, #1e293b);
    background: var(--weli-modal-bg, #fff);
}
.weli-valerr-body p {
    margin: 0 0 10px;
    color: var(--weli-secondary-color, #64748b);
}
.weli-valerr-body ul { margin: 0; padding: 0; list-style: none; }
.weli-valerr-item {
    margin: 6px 0; padding: 8px 12px;
    background: var(--weli-valerr-item-bg, #fee2e2);
    border-radius: 6px;
    border-left: 3px solid var(--weli-valerr-accent, #dc2626);
    color: var(--weli-valerr-item-color, #7f1d1d);
    font-size: 13px;
}
.weli-valerr-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
    max-height: 320px; overflow-y: auto; display: block;
}
.weli-valerr-table thead, .weli-valerr-table tbody { display: table; width: 100%; table-layout: fixed; }
.weli-valerr-table th {
    text-align: left; padding: 6px 10px; font-size: 11px;
    text-transform: uppercase; letter-spacing: .03em;
    color: var(--weli-secondary-color, #94a3b8);
    border-bottom: 1px solid var(--weli-valerr-border, #fecaca);
}
.weli-valerr-table th:first-child { width: 38%; }
.weli-valerr-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--weli-valerr-border, #fecaca);
    vertical-align: top;
}
.weli-valerr-table tr:last-child td { border-bottom: none; }
.weli-valerr-col {
    font-weight: 700;
    color: var(--weli-valerr-item-color, #7f1d1d);
}
.weli-valerr-reason {
    color: var(--weli-body-color, #1e293b);
}
.weli-valerr-value {
    font-family: 'Cascadia Code', 'Fira Mono', monospace;
    font-size: 12px;
    background: var(--weli-valerr-value-bg, #f1f5f9);
    color: var(--weli-valerr-value-color, #475569);
    padding: 1px 5px;
    border-radius: 4px;
    white-space: pre; /* préserve les espaces multiples / saisie vide visible */
}
.weli-theme-dark .weli-valerr-value,
[data-theme="dark"] .weli-valerr-value {
    --weli-valerr-value-bg: #334155;
    --weli-valerr-value-color: #cbd5e1;
}
@media (prefers-color-scheme: dark) {
    .weli-valerr-value {
        --weli-valerr-value-bg: #334155;
        --weli-valerr-value-color: #cbd5e1;
    }
}
.weli-valerr-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--weli-valerr-border, #fecaca);
    background: var(--weli-valerr-header-bg, #fef2f2);
    display: flex; justify-content: flex-end;
}
.weli-valerr-ok {
    background: var(--weli-valerr-accent, #dc2626) !important;
    border-color: var(--weli-valerr-accent, #dc2626) !important;
}
/* Mode sombre */
.weli-theme-dark .weli-valerr-modal,
[data-theme="dark"] .weli-valerr-modal {
    --weli-valerr-border    : #7f1d1d;
    --weli-valerr-header-bg : #2d1515;
    --weli-valerr-title-color: #fca5a5;
    --weli-valerr-item-bg   : #2d1515;
    --weli-valerr-item-color : #fca5a5;
    --weli-valerr-accent    : #ef4444;
    --weli-modal-bg         : #1e293b;
    --weli-body-color       : #e2e8f0;
    --weli-secondary-color  : #94a3b8;
}
@media (prefers-color-scheme: dark) {
    .weli-valerr-modal {
        --weli-valerr-border    : #7f1d1d;
        --weli-valerr-header-bg : #2d1515;
        --weli-valerr-title-color: #fca5a5;
        --weli-valerr-item-bg   : #2d1515;
        --weli-valerr-item-color : #fca5a5;
        --weli-valerr-accent    : #ef4444;
        --weli-modal-bg         : #1e293b;
        --weli-body-color       : #e2e8f0;
        --weli-secondary-color  : #94a3b8;
    }
}
/* ── Modale alerte générique (remplace alert()/confirm()) ── */
.weli-alert-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
    z-index: 6000; align-items: center; justify-content: center;
}
.weli-alert-modal {
    background: var(--weli-modal-bg, #fff);
    border-radius: 12px; width: 420px; max-width: 92vw;
    box-shadow: var(--weli-modal-shadow);
    overflow: hidden; display: flex; flex-direction: column;
    border: 1px solid var(--weli-alert-border, #e2e8f0);
}
.weli-alert-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--weli-alert-border, #e2e8f0);
    background: var(--weli-alert-header-bg, #f8fafc);
}
.weli-alert-header.weli-alert-header--error {
    border-color: var(--weli-valerr-border, #fecaca);
    background: var(--weli-valerr-header-bg, #fef2f2);
}
.weli-alert-title {
    font-weight: 700; font-size: 15px;
    color: var(--weli-alert-title-color, #1e293b);
    display: flex; align-items: center; gap: 8px;
}
.weli-alert-header--error .weli-alert-title {
    color: var(--weli-valerr-title-color, #991b1b);
}
.weli-alert-close { color: var(--weli-alert-title-color, #1e293b) !important; }
.weli-alert-header--error .weli-alert-close { color: var(--weli-valerr-title-color, #991b1b) !important; }
.weli-alert-body {
    padding: 18px 20px; font-size: 14px; line-height: 1.5;
    color: var(--weli-body-color, #1e293b);
    background: var(--weli-modal-bg, #fff);
    white-space: pre-line;
}
.weli-alert-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--weli-alert-border, #e2e8f0);
    background: var(--weli-alert-header-bg, #f8fafc);
    display: flex; justify-content: flex-end; gap: 8px;
}
.weli-alert-footer.weli-alert-footer--error {
    border-color: var(--weli-valerr-border, #fecaca);
    background: var(--weli-valerr-header-bg, #fef2f2);
}
.weli-alert-btn-cancel {
    background: var(--weli-btn-bg, #eaeff6) !important;
    border-color: var(--weli-btn-border, #b0bdd0) !important;
    color: var(--weli-btn-fg, #334155) !important;
    width: auto !important; padding: 0 16px !important; height: 34px;
}
.weli-alert-btn-ok {
    background: var(--weli-accent, #2563eb) !important;
    border-color: var(--weli-accent, #2563eb) !important;
    color: #fff !important;
    width: auto !important; padding: 0 16px !important; height: 34px;
}
.weli-alert-footer--error .weli-alert-btn-ok {
    background: var(--weli-valerr-accent, #dc2626) !important;
    border-color: var(--weli-valerr-accent, #dc2626) !important;
}
/* Mode sombre */
.weli-theme-dark .weli-alert-modal,
[data-theme="dark"] .weli-alert-modal {
    --weli-alert-border     : #334155;
    --weli-alert-header-bg  : #162032;
    --weli-alert-title-color: #f1f5f9;
    --weli-modal-bg         : #1e293b;
    --weli-body-color       : #e2e8f0;
}
@media (prefers-color-scheme: dark) {
    .weli-alert-modal {
        --weli-alert-border     : #334155;
        --weli-alert-header-bg  : #162032;
        --weli-alert-title-color: #f1f5f9;
        --weli-modal-bg         : #1e293b;
        --weli-body-color       : #e2e8f0;
    }
}
/* ── Modale aide utilisateur intégrée ── */
/* ── Infobulle d'aide contextuelle (F1) ── */
.weli-f12-tip {
    position: fixed;
    z-index: 7000;
    max-width: 280px;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 12.5px;
    line-height: 1.5;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    animation: weli-f12-fade .15s ease;
}
.weli-f12-tip-body { padding: 10px 12px; }
.weli-f12-tip-arrow {
    position: absolute;
    top: -6px;
    width: 12px; height: 12px;
    background: #1e293b;
    transform: rotate(45deg);
    border-radius: 2px;
}
@keyframes weli-f12-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.weli-help-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
    z-index: 6000; align-items: center; justify-content: center;
}
.weli-help-modal {
    background: var(--weli-modal-bg, #fff);
    border-radius: 12px; width: 560px; max-width: 92vw;
    max-height: 82vh;
    box-shadow: var(--weli-modal-shadow);
    overflow: hidden; display: flex; flex-direction: column;
    border: 1px solid var(--weli-alert-border, #e2e8f0);
}
.weli-help-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--weli-alert-border, #e2e8f0);
    background: var(--weli-alert-header-bg, #f8fafc);
    flex-shrink: 0;
}
.weli-help-title {
    font-weight: 700; font-size: 15px;
    color: var(--weli-alert-title-color, #1e293b);
}
.weli-help-close { color: var(--weli-alert-title-color, #1e293b) !important; }
.weli-help-tabs {
    display: flex; gap: 4px;
    padding: 8px 20px 0;
    border-bottom: 1px solid var(--weli-alert-border, #e2e8f0);
    background: var(--weli-alert-header-bg, #f8fafc);
    flex-shrink: 0;
}
.weli-help-tab {
    appearance: none; border: none; background: transparent; cursor: pointer;
    padding: 8px 12px; font-size: 13px; font-weight: 600;
    color: var(--weli-body-color, #64748b);
    opacity: .65;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: opacity .15s, border-color .15s, color .15s;
}
.weli-help-tab:hover { opacity: .9; }
.weli-help-tab--active {
    opacity: 1;
    color: var(--weli-accent, #2563eb);
    border-bottom-color: var(--weli-accent, #2563eb);
}
.weli-help-body {
    padding: 6px 20px 20px;
    overflow-y: auto;
    background: var(--weli-modal-bg, #fff);
    color: var(--weli-body-color, #1e293b);
}
.weli-help-section { margin-top: 18px; }
.weli-help-section h4 {
    margin: 0 0 8px; font-size: 13px; font-weight: 700;
    color: var(--weli-accent, #2563eb);
}
.weli-help-section ul { margin: 0; padding-left: 20px; }
.weli-help-section li {
    font-size: 13.5px; line-height: 1.6; margin-bottom: 6px;
    color: var(--weli-body-color, #1e293b);
}
.weli-theme-dark .weli-help-modal,
[data-theme="dark"] .weli-help-modal {
    --weli-alert-border     : #334155;
    --weli-alert-header-bg  : #162032;
    --weli-alert-title-color: #f1f5f9;
    --weli-modal-bg         : #1e293b;
    --weli-body-color       : #e2e8f0;
}
/* @media prefers-color-scheme supprimé : le thème est géré par data-theme sur .weli-wrapper */
/* ── Étoile obligatoire masquée (info donnée à la saisie) ── */
.weli-required { display: none !important; }
/* ── Badge opérateur colonne ── */
.weli-op-badge {
    font-size: 9px;
    font-weight: 700;
    color: var(--weli-text-thead, #f1f5f9);
    font-family: monospace;
    /* vertical-align:super est sans effet ici : .weli-th-top est en
       display:flex, et les items flex ignorent vertical-align (même piège
       que rencontré pour le <sup> du macaron). On relève donc le badge
       manuellement pour qu'il vienne se caler juste au-dessus, contre le
       coin haut-droit du macaron, au lieu de rester aligné au centre de la
       ligne. */
    align-self: flex-start;
    margin-top: 3px;
    vertical-align: super;
    margin-left: 2px;
    letter-spacing: 0;
    opacity: .7;
    transition: color .15s, opacity .15s;
    flex-shrink: 0;  /* ne se compresse pas quand le label grossit */
    white-space: nowrap;
}
/* Op-badge : toujours blanc sur thèmes sombres */
.weli-th-sortable:hover .weli-op-badge,
.weli-th-sorted .weli-op-badge,
.weli-th-dirty .weli-op-badge {
    color: var(--weli-text-thead, #f1f5f9);
    opacity: 1;
}
/* Thème minimal : fond clair → op-badge foncé */
.weli-theme-minimal .weli-op-badge,
.weli-theme-minimal .weli-th-sortable:hover .weli-op-badge,
.weli-theme-minimal .weli-th-sorted .weli-op-badge,
.weli-theme-minimal .weli-th-dirty .weli-op-badge {
    color: var(--weli-thead-minimal-fg, #334155);
}
/* Spacer flexible dans la toolbar (espace entre search et clearfilters) */
.weli-tool-spacer {
    flex: 1;
    min-width: 24px;
}

/* ── Bouton refresh split (auto-refresh) ── */
.weli-refresh-split {
    /* Hérite des styles visuels de weli-tool-btn */
    height: 34px;
    min-width: 80px;
    display: inline-flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--weli-btn-border);
    border-radius: 7px;
    background: var(--weli-btn-bg);
    color: var(--weli-btn-fg);
    flex-shrink: 0;
    transition: border-color 0.2s;
}
.weli-refresh-split:hover {
    border-color: color-mix(in srgb, var(--weli-accent) 50%, var(--weli-btn-border));
}
.weli-refresh-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border-right: 1px solid var(--weli-btn-border);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.weli-refresh-left:hover {
    background: color-mix(in srgb, var(--weli-accent) 8%, var(--weli-btn-bg));
    color: var(--weli-accent);
}
.weli-refresh-left svg { width: 16px; height: 16px; display: block; stroke: currentColor; }

.weli-refresh-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
    cursor: pointer;
    transition: background .15s, color .15s;
    min-width: 28px;
}
.weli-refresh-right:hover {
    background: color-mix(in srgb, var(--weli-accent) 8%, var(--weli-btn-bg));
    color: var(--weli-accent);
}

/* Clignotement jaune en pause */
@keyframes weli-blink-pause {
    0%, 100% { border-color: #f59e0b; box-shadow: 0 0 0 1px #f59e0b, 0 0 6px rgba(245,158,11,.4); }
    50%       { border-color: transparent; box-shadow: none; }
}
@keyframes weli-blink-text {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}
.weli-refresh-paused-blink {
    animation: weli-blink-pause 1.4s ease-in-out infinite;
    will-change: box-shadow;
}
.weli-refresh-paused-blink .weli-refresh-right {
    color: #f59e0b;
    animation: weli-blink-text 1.4s ease-in-out infinite;
    will-change: opacity;
}

/* ── Handle de resize de colonne ── */
.weli-col-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 20;
    /* Empêche le navigateur d'intercepter le geste pour scroller la grille
       horizontalement avant que le pointerdown/pointermove JS ne s'exécute —
       sans ça, glisser au doigt sur la poignée scrolle la table au lieu de
       redimensionner la colonne. */
    touch-action: none;
    /* Marque verticale permanente : liseré fin sur le bord droit */
    background: transparent;
    border-right: 2px solid rgba(255,255,255,0.18);
    transition: border-color .15s, background .15s;
    box-sizing: border-box;
}
.weli-col-resize-handle:hover {
    background: rgba(255,255,255,0.1);
    border-right: 2px solid var(--weli-accent, #3b82f6);
}
.weli-col-resize-handle:active {
    background: rgba(59,130,246,0.25);
    border-right: 2px solid var(--weli-accent, #3b82f6);
}
[data-theme="dark"] .weli-col-resize-handle {
    border-right-color: rgba(255,255,255,0.12);
}


.weli-tool-btn[data-action="clearfilters"] {
    border-color: var(--weli-accent, #3b82f6);
    box-shadow: 0 0 0 1px var(--weli-accent, #3b82f6),
                inset 0 0 0 1px rgba(59,130,246,.15);
}
.weli-tool-btn[data-action="clearfilters"]:hover {
    box-shadow: 0 0 0 2px var(--weli-accent, #3b82f6),
                inset 0 0 0 1px rgba(59,130,246,.2);
}

/* ── Icône de tri — couleur blanche ── */
/* Le macaron (.weli-sort-icon--top.weli-sort-active) gère sa propre couleur de
   glyphe par thème (weli.css l.474+) — exclu ici pour ne pas être écrasé par
   ce !important, sinon le glyphe reste toujours clair même en thème sombre. */
.weli-sort-icon.weli-sort-active:not(.weli-sort-icon--top) {
    color: var(--weli-text-thead, #f1f5f9) !important;
}
/* ── Drag & drop réordonnancement des colonnes ── */
.weli-th-sortable {
    user-select: none;
    touch-action: none;
    position: relative;
}
.weli-th-sortable.weli-col-dragging {
    opacity: .4;
    background: color-mix(in srgb, var(--weli-accent, #3b82f6) 10%, transparent) !important;
}
.weli-th-sortable.weli-col-drag-over-left {
    border-left: 3px solid var(--weli-accent, #3b82f6) !important;
    background: color-mix(in srgb, var(--weli-accent, #3b82f6) 8%, transparent) !important;
}
.weli-th-sortable.weli-col-drag-over-right {
    border-right: 3px solid var(--weli-accent, #3b82f6) !important;
    background: color-mix(in srgb, var(--weli-accent, #3b82f6) 8%, transparent) !important;
}
/* Flèches ▼ haut et ▲ bas — injectées en JS pour éviter le clipping */
.weli-col-drop-top-arrow {
    position: fixed;
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--weli-accent, #3b82f6);
    pointer-events: none;
    z-index: 9999;
    transform: translateX(-50%);
}
.weli-col-drop-bottom-arrow {
    position: fixed;
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid var(--weli-accent, #3b82f6);
    pointer-events: none;
    z-index: 9999;
    transform: translateX(-50%);
}
.weli-col-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    background: var(--weli-accent, #3b82f6);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    white-space: nowrap;
    opacity: .92;
    transform: translate(-50%, -120%);
}
/* ── Édition cellule directe (cell_update) ── */
.weli-cell-editable {
    cursor: pointer;
    position: relative;
}

.weli-cell-editing {
    padding: 0 !important;
    cursor: default;
}
/* La cellule en édition doit laisser déborder le popup calendrier (la cellule
   normale est overflow:hidden pour l'ellipsis). */
.weli-cell.weli-cell-editing {
    overflow: visible;
    z-index: 5;
}
.weli-cell-input {
    width: 100%; height: 100%; min-height: 28px;
    border: 2px solid var(--weli-accent, #3b82f6);
    border-radius: 4px;
    padding: 3px 6px; box-sizing: border-box;
    font: inherit;
    background: var(--weli-bg-input, #fff);
    color: var(--weli-text-input, #1e293b);
    color-scheme: light dark;
    outline: none;
}
select.weli-cell-input { cursor: pointer; }
select.weli-cell-input:disabled { cursor: wait; opacity: .6; }
.weli-cell-input--error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220,38,38,.15);
    animation: weli-cell-shake .3s ease;
}
@keyframes weli-cell-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-3px); }
    75%      { transform: translateX(3px); }
}
.weli-cell-saving {
    opacity: .5; pointer-events: none;
}
.weli-cell-saved-flash {
    animation: weli-flash .6s ease;
}
@keyframes weli-flash {
    0%   { background: #dcfce7; }
    100% { background: transparent; }
}
.weli-cell-error-flash {
    animation: weli-flash-err .6s ease;
}
@keyframes weli-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes weli-flash-err {
    0%   { background: #fee2e2; }
    100% { background: transparent; }
}
/* ── Compteur last-refresh + sablier ── */
.weli-last-refresh {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: var(--weli-text-secondary, #94a3b8);
    padding: 0 6px;
    white-space: nowrap;
    cursor: default;
}
/* Sablier SVG statique */
.weli-hourglass-svg { flex-shrink: 0; }
/* ── États des inputs de filtre en mode row-add ── */
.weli-search-input--required,
.weli-search-input--required:focus,
.weli-search-input--required:focus-visible {
    border-color: #dc2626 !important;
    background: #fff1f1 !important;
    box-shadow: 0 0 0 2px rgba(220,38,38,.25) !important;
}
.weli-search-input--lov,
.weli-search-input--lov:focus,
.weli-search-input--lov:focus-visible {
    border-color: #2563eb !important;
    background: #eff6ff !important;
    box-shadow: 0 0 0 2px rgba(37,99,235,.2) !important;
}
.weli-search-input--lov-required,
.weli-search-input--lov-required:focus,
.weli-search-input--lov-required:focus-visible {
    border-color: #dc2626 !important;
    background: #fff1f1 !important;
    box-shadow: 0 0 0 2px rgba(220,38,38,.25) !important;
}
.weli-search-input--forbidden,
.weli-search-input--forbidden:focus,
.weli-search-input--forbidden:focus-visible {
    border-color: #94a3b8 !important;
    background: #f1f5f9 !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
    cursor: not-allowed !important;
}
/* ── Champ obligatoire manquant (row-add inline) ── */
.weli-search-input--error,
.weli-search-input--error:focus,
.weli-search-input--error:focus-visible {
    border-color: #dc2626 !important;
    background: #fff1f1 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(220,38,38,.35) !important;
    animation: weli-pulse-err 2s ease infinite !important;
    will-change: box-shadow;
}
@keyframes weli-pulse-err {
    0%,100% { box-shadow: 0 0 0 2px rgba(220,38,38,.5); }
    50%     { box-shadow: 0 0 0 5px rgba(220,38,38,.18); }
}
/* ── Modale préférences (slots) ── */
.weli-prefs-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.48);
    backdrop-filter: blur(3px); z-index: 2500;
    display: none; align-items: center; justify-content: center;
}
.weli-prefs-overlay.open { display: flex; }
.weli-prefs-modal {
    background: #fff; border-radius: 14px; width: 460px; max-width: 96vw;
    max-height: 82vh; display: flex; flex-direction: column;
    box-shadow: 0 28px 72px rgba(0,0,0,.32); overflow: hidden;
}
.weli-prefs-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
    flex-shrink: 0;
}
.weli-prefs-header-title { font-weight: 700; font-size: 15px; color: #1e293b; }
.weli-prefs-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.weli-prefs-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 24px 0; }
.weli-prefs-slot {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: 8px; margin-bottom: 6px;
    background: #f8fafc; border: 1px solid #e2e8f0;
    transition: border-color .15s, background .15s;
}
.weli-prefs-slot:hover { border-color: #cbd5e1; background: #f1f5f9; }
.weli-prefs-slot.active { border-color: var(--weli-accent,#3b82f6); background: #eff6ff; }
.weli-prefs-slot-name {
    flex: 1; font-size: 13px; font-weight: 500; color: #1e293b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.weli-prefs-slot-name input {
    width: 100%; border: 1px solid var(--weli-accent,#3b82f6);
    border-radius: 5px; padding: 3px 7px; font-size: 13px;
    font-weight: 500; outline: none; background: #fff;
}
.weli-prefs-slot-date { font-size: 11px; color: #94a3b8; white-space: nowrap; flex-shrink: 0; }
.weli-prefs-slot-active-badge {
    font-size: 10px; font-weight: 700; color: var(--weli-accent,#3b82f6);
    background: #dbeafe; border-radius: 99px; padding: 1px 7px;
    white-space: nowrap; flex-shrink: 0;
}
/* ── Badge préférence active dans le titre ── */
.weli-title-pref-badge { display: none; } /* désactivé — chip dans la toolbar */
/* ── Chip préférence active dans la toolbar ── */
.weli-pref-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--weli-accent, #3b82f6);
    background: #dbeafe;
    border-radius: 99px;
    padding: 3px 8px 3px 10px;
    max-width: 180px;
    overflow: hidden;
    white-space: nowrap;
    cursor: default;
    vertical-align: middle;
    transition: background .15s;
    position: relative;
}
.weli-pref-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.weli-pref-chip-label:hover {
    text-decoration: underline dotted;
}
/* Arc de progression hold-to-save */
.weli-pref-chip-arc {
    position: absolute;
    inset: 0;
    border-radius: 99px;
    pointer-events: none;
    overflow: visible;
}
.weli-pref-chip-arc-track {
    fill: none;
    stroke: var(--weli-accent, #3b82f6);
    stroke-width: 2.5;
    stroke-linecap: round;
    opacity: 0;
    transition: opacity .1s;
    stroke-dasharray: 0 200;
    transition: stroke-dasharray .05s linear, opacity .1s;
}
.weli-pref-chip--holding .weli-pref-chip-arc-track {
    opacity: .35;
}
.weli-pref-chip--saving .weli-pref-chip-arc-track {
    opacity: 0 !important;
}
.weli-pref-chip--saved {
    background: #dcfce7 !important;
    color: #16a34a !important;
    transition: background .2s, color .2s;
}
.weli-pref-chip--saved .weli-pref-chip-x {
    color: #16a34a !important;
}
.weli-pref-chip-spinner {
    display: none;
    width: 10px; height: 10px;
    border: 1.5px solid transparent;
    border-top-color: var(--weli-accent, #3b82f6);
    border-radius: 50%;
    animation: weli-chip-spin .6s linear infinite;
    flex-shrink: 0;
}
.weli-pref-chip--saving .weli-pref-chip-spinner { display: inline-block; }
@keyframes weli-chip-spin { to { transform: rotate(360deg); } }
.weli-pref-chip-x {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
    color: var(--weli-accent, #3b82f6);
    cursor: pointer;
    border-radius: 99px;
    padding: 0 2px;
    transition: background .13s, color .13s;
}
.weli-pref-chip-x:hover {
    background: var(--weli-accent, #3b82f6);
    color: #fff;
}
.weli-prefs-slot-actions { display: flex; gap: 4px; flex-shrink: 0; }
.weli-prefs-slot-btn {
    border: none; background: none; cursor: pointer; padding: 4px 6px;
    border-radius: 5px; color: #64748b; font-size: 12px; font-weight: 600;
    transition: background .13s, color .13s; white-space: nowrap;
}
.weli-prefs-slot-btn:hover { background: #e2e8f0; color: #1e293b; }
.weli-prefs-slot-btn.load  { color: #2563eb; }
.weli-prefs-slot-btn.load:hover  { background: #dbeafe; color: #1d4ed8; }
.weli-prefs-slot-btn.del   { color: #dc2626; }
.weli-prefs-slot-btn.del:hover   { background: #fee2e2; color: #991b1b; }
.weli-prefs-footer {
    padding: 12px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc;
    display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}
.weli-prefs-new-input {
    flex: 1; border: 1px solid #cbd5e1; border-radius: 7px;
    padding: 7px 11px; font-size: 13px; outline: none;
    transition: border-color .15s;
}
.weli-prefs-new-input:focus { border-color: var(--weli-accent,#3b82f6); }
.weli-prefs-new-btn {
    border: none; border-radius: 7px; padding: 7px 14px;
    background: var(--weli-accent,#3b82f6); color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: opacity .15s; white-space: nowrap;
}
.weli-prefs-new-btn:hover { opacity: .88; }
/* ── Bouton préférences ── */
.weli-prefs-icon { width: 17px; height: 17px; display: block; pointer-events: none; }
/* ── Bouton refresh auto ── */
.weli-tool-btn[data-action="refresh"] {
    position: relative;
    clip-path: inset(0 round 7px); /* remplace overflow:hidden — compositor-friendly */
    min-width: 32px;
}
/* Jauge montante pilotée par --weli-fill (0→1) via JS */
/* transform:scaleY au lieu de height → compositor only, pas de reflow */
.weli-tool-btn[data-action="refresh"]::before,
.weli-refresh-split::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 100%;
    background: var(--weli-accent, #3b82f6);
    opacity: .22;
    border-radius: inherit;
    z-index: 0;
    transform: scaleY(var(--weli-fill, 0));
    transform-origin: bottom center;
}
.weli-tool-btn[data-action="refresh"].weli-refresh-paused::before,
.weli-refresh-split.weli-refresh-paused::before {
    opacity: .12;
}
/* Icône + texte au-dessus du fond */
.weli-tool-btn[data-action="refresh"] > *,
.weli-refresh-split > * { position: relative; z-index: 1; }
/* Compteur secondes */
.weli-refresh-counter {
    position: relative; z-index: 1;
    font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
    line-height: 1; pointer-events: none;
    min-width: 16px; text-align: center;
}
/* Rotation de l'icône SVG pendant le décompte */
.weli-tool-btn[data-action="refresh"].weli-refresh-running svg,
.weli-refresh-split.weli-refresh-running .weli-refresh-left svg {
    animation: weli-refresh-spin 2s linear infinite;
    will-change: transform;
}
.weli-tool-btn[data-action="refresh"].weli-refresh-paused svg,
.weli-refresh-split.weli-refresh-paused .weli-refresh-left svg {
    animation: weli-refresh-spin 2s linear infinite paused;
    opacity: .5;
    will-change: auto; /* libérer le layer GPU quand en pause */
}
@keyframes weli-refresh-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
/* ── Toast préférences ── */
.weli-prefs-toast {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    background: #dcfce7;
    border-radius: 999px;
    padding: 3px 12px;
    margin-left: 10px;
    vertical-align: middle;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
}
.weli-prefs-toast:empty { display: none; }
.weli-prefs-toast.show { opacity: 1; }
.weli-prefs-toast.error { background: #fee2e2; color: #991b1b; }
.weli-prefs-toast.copy  { background: #e0f2fe; color: #0369a1; }
/* ── Liseré sélection ligne ── */
.weli-row-selected .weli-cell {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.55),
                inset 0 -1px 0 rgba(0,0,0,.30);
}
/* ── Hauteur explicite (cfg.height) : forcer le wrapper en flex
       colonne pour que le table-container occupe tout l'espace restant ── */
.weli-wrapper[style*="height"] {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
}
.weli-wrapper[style*="height"] .weli-table-container {
    flex: 1 1 auto !important;
    max-height: none !important;
    min-height: 0; /* indispensable pour que flex:1 fonctionne avec overflow */
}
.weli-wrapper[style*="height"] .weli-header {
    flex: 0 0 auto;
}
/* ── Image de fond du wrapper ──
   Le header garde un fond semi-opaque par-dessus l'image pour
   rester lisible (titre, boutons toujours nets). Le tableau et
   la ligne de filtres restent transparents par défaut : c'est
   row_colors qui contrôle, ligne par ligne, l'opacité visible
   par-dessus l'image (mettre un alpha proche de 1 dans le
   pattern si on veut masquer complètement l'image à cet endroit). */
.weli-has-bg {
    background-color: transparent !important;
}
.weli-has-bg .weli-header {
    background: color-mix(in srgb, var(--weli-bg-header-inner, #eaeff6) 88%, transparent);
}
/* Fond neutre minimal sur les lignes SANS row_colors, pour qu'elles
   restent lisibles même sans configuration de couleur explicite. */
.weli-has-bg .weli-data-row:not([data-rc]) .weli-cell {
    background: color-mix(in srgb, var(--weli-bg-card, #f5f7fa) 85%, transparent);
}
/* ── Badge nombre de lignes ── */
.weli-row-count {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 2px 9px;
    margin-left: 10px;
    vertical-align: middle;
    white-space: nowrap;
    transition: background .2s, color .2s;
}
.weli-row-count:empty { display: none; }
.weli-row-count-grand {
    font-weight: 400;
    opacity: .6;
    font-size: 10px;
}

/* Badge en mode édition inline : accentué pour signaler l'état */
.weli-row-count--edit {
    background: var(--weli-accent, #3b82f6);
    color: #fff;
    border-color: transparent;
    font-weight: 700;
}

/* ── Responsive : header en deux lignes quand la weli est étroite ──
   Plus de seuil fixe ici : .weli-header a flex-wrap:wrap, .weli-title et
   .weli-toolbar ont flex-shrink:0 (règles de base ci-dessus) — dès que les
   deux ne tiennent plus naturellement côte à côte, le navigateur bascule
   la toolbar sur sa propre ligne tout seul, quelle que soit la largeur
   réelle de CETTE weli (imbriquée ou en pleine page). row-reverse
   (toolbar_position:"left", règle plus bas) n'affecte que l'ordre gauche/
   droite sur une même ligne, pas l'empilement — rien à ajouter ici. */

/* ── Marble colonne ── */
.weli-col-marble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px; height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #cbd5e1;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    cursor: pointer;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: border-color .15s, box-shadow .15s, background .15s;
    position: relative;
    z-index: 1;
    overflow: hidden;
}
.weli-col-marble svg {
    width: 9px; height: 9px;
    display: block;
    stroke: #cbd5e1;
    opacity: 0;
    transition: opacity .15s, stroke .15s;
    flex-shrink: 0;
}
.weli-col-marble:hover svg,
.weli-col-marble.active svg {
    opacity: 1;
    stroke: var(--weli-accent, #3b82f6);
}
.weli-col-marble:hover,
.weli-col-marble.active {
    border-color: var(--weli-accent, #3b82f6);
    background: #eff6ff;
    box-shadow: 0 2px 6px rgba(59,130,246,.25);
}
/* Marble LOV : fond bleu avec lettre L */
.weli-col-marble--lov {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    letter-spacing: 0;
}
.weli-col-marble--lov svg { display: none; }
.weli-col-marble--lov::after { content: 'L'; }
.weli-col-marble--lov:hover,
.weli-col-marble--lov.active {
    background: #1d4ed8;
    border-color: #1e40af;
    box-shadow: 0 2px 6px rgba(37,99,235,.4);
}
/* Marble LOV obligatoire : fond rouge */
.weli-col-marble--lov-required {
    background: #dc2626;
    border-color: #b91c1c;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    font-family: system-ui, sans-serif;
}
.weli-col-marble--lov-required svg { display: none; }
.weli-col-marble--lov-required::after { content: 'L'; }
.weli-col-marble--lov-required:hover,
.weli-col-marble--lov-required.active {
    background: #b91c1c;
    border-color: #991b1b;
    box-shadow: 0 2px 6px rgba(220,38,38,.4);
}
/* Marble colonne obligatoire sans LOV : fond rouge, pas de lettre */
.weli-col-marble--required {
    background: #dc2626;
    border-color: #b91c1c;
}
.weli-col-marble--required:hover,
.weli-col-marble--required.active {
    background: #b91c1c;
    border-color: #991b1b;
    box-shadow: 0 2px 6px rgba(220,38,38,.4);
}
.weli-col-marble--required svg { stroke: rgba(255,255,255,.7); opacity: 0; }
.weli-col-marble--required:hover svg,
.weli-col-marble--required.active svg { stroke: #fff; opacity: 1; }
/* Marble colonne interdite (update:forbidden) : fond gris */
.weli-col-marble--forbidden {
    background: #94a3b8;
    border-color: #64748b;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    font-family: system-ui, sans-serif;
}
.weli-col-marble--forbidden svg { opacity: 0.5; stroke: #fff; }
.weli-col-marble--forbidden:hover,
.weli-col-marble--forbidden.active {
    background: #64748b;
    border-color: #475569;
    box-shadow: 0 2px 6px rgba(100,116,139,.4);
}
/* Indicateur "filtre avancé actif" — petit point, cumulable avec --lov/--required
   (ceux-ci occupent tout le fond du marble, donc un point en coin reste visible) */
/* Indicateur "filtre avancé actif" — rond noir bien visible, centré dans le
   marble (signale qu'au moins une valeur/range est saisie pour cette colonne). */
.weli-col-marble--advfilter::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #000;
    box-shadow: 0 0 0 1.5px rgba(255,255,255,.9);
    z-index: 3;
}
/* ── Menu contextuel colonne ── */
.weli-colmenu {
    position: fixed;
    z-index: 4000;
    background: var(--weli-menu-bg);
    border: 1px solid var(--weli-menu-border);
    border-radius: 10px;
    box-shadow: var(--weli-menu-shadow);
    min-width: 210px;
    padding: 0;
    user-select: none;
    font-size: 13px;
    color: var(--weli-menu-color);
    overflow: hidden;
}
.weli-colmenu-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0 14px 0 0;
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
    position: relative;
}
.weli-colmenu-item:hover,
.weli-colmenu-item.hovered  { background: var(--weli-menu-hover-bg) !important; }
.weli-colmenu-item.disabled { color: var(--weli-menu-disabled); cursor: default; pointer-events: none; }
.weli-colmenu-item.active   { color: var(--weli-menu-active); font-weight: 600; }
.weli-colmenu-sep {
    height: 1px; margin: 2px 0;
    background: linear-gradient(to right, var(--weli-menu-sep-icon) 36px, var(--weli-menu-sep-body) 36px);
}
.weli-colmenu-icon {
    width: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    background: var(--weli-menu-icon-bg);
    color: var(--weli-menu-icon-color);
    padding: 9px 0;
    margin-right: 10px;
}
/* Maintenir le fond icône même au hover et disabled */
.weli-colmenu-item:hover .weli-colmenu-icon,
.weli-colmenu-item.hovered .weli-colmenu-icon,
.weli-colmenu-item.disabled .weli-colmenu-icon { background: var(--weli-menu-icon-bg); }
.weli-colmenu-label { flex: 1; padding: 9px 0; }
.weli-colmenu-arrow { margin-left: auto; opacity: .55; font-size: 10px; padding: 9px 0; }
/* ── Sous-menu ── */
.weli-colmenu-sub {
    position: fixed;
    z-index: 4001;
    background: var(--weli-menu-bg);
    border: 1px solid var(--weli-menu-border);
    border-radius: 10px;
    box-shadow: var(--weli-menu-shadow);
    min-width: 185px;
    padding: 0;
    font-size: 13px;
    color: var(--weli-menu-color);
    overflow: hidden;
}
.weli-colmenu-sub .weli-colmenu-item { padding: 0 14px 0 0; }
/* ── Valeurs distinctes ── */
.weli-colmenu-vals { max-height: 220px; overflow-y: auto; padding: 2px 0; }
.weli-colmenu-val-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px; cursor: pointer;
    font-size: 12px; color: #334155;
    transition: background .12s;
}
.weli-colmenu-val-item:hover { background: #f1f5f9; }
.weli-colmenu-loading {
    padding: 10px 16px; color: #94a3b8;
    font-size: 12px; text-align: center;
}
/* ── Modale valeurs distinctes ──
   z-index volontairement au-dessus de .weli-colfilter-overlay (4600) : ce picker
   peut être ouvert DEPUIS l'intérieur d'autres modales (filtre avancé, formulaire
   CRUD...) et doit toujours s'afficher par-dessus, jamais en dessous. */
.weli-distmodal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(3px);
    z-index: 4700;
    display: none;
    align-items: center;
    justify-content: center;
}
.weli-distmodal-overlay.open { display: flex; }
.weli-distmodal {
    /* Suit le thème de la weli parente (hérite des variables --weli-* de
       .weli-wrapper[data-theme="dark"]) plutôt que de le forcer en clair. */
    --weli-text-muted:       #94a3b8;
    background: var(--weli-bg-card);
    border-radius: 14px;
    width: 480px; max-width: 96vw;
    height: 82vh;
    display: flex; flex-direction: column;
    box-shadow: var(--weli-modal-shadow);
    overflow: hidden;
    position: relative;
}
.weli-distmodal-header {
    padding: 12px 16px 10px; border-bottom: 1px solid #e2e8f0;
    background: var(--weli-bg-header-inner, #eaeff6); flex-shrink: 0;
}
.weli-distmodal-header-top {
    display: flex; align-items: center; gap: 8px;
}
.weli-distmodal-title {
    font-weight: 700; font-size: 18px; color: var(--weli-text-primary, #1a2636);
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    margin: 0;
}
.weli-distmodal-actions {
    display: flex; gap: 4px; align-items: center; flex-shrink: 0;
}
.weli-distmodal-header-sub {
    margin-top: 3px;
}
.weli-distmodal-stats {
    font-size: 12px; color: var(--weli-text-secondary, #4a5a6e);
    font-weight: 400;
}
/* distmodal : layout géré dans weli.css */
/* Masquer le header weli interne (titre + toolbar) */
.weli-distmodal-mount .weli-header { display: none !important; }

/* Masquer le marble dans la modale valeurs possibles */
/* marble visible dans la distmodal pour accéder au menu Tri/Align/Op */
/* Highlight survol lignes dans la modale valeurs */
.weli-distmodal-mount .weli-data-row:hover .weli-cell {
    background: #eff6ff !important;
    color: var(--weli-accent, #3b82f6);
    cursor: pointer;
}
.weli-distmodal-mount .weli-data-row {
    transition: background .1s;
}

/* ── Modale filtre avancé par colonne (4 sous-listes Weli) ── */
/* Préfixe .weli-colfilter-* volontairement distinct de .weli-filtermodal-*
   (fonctionnalité différente et sans rapport : filtre texte "tous les champs"
   au niveau toolbar, cf. plus bas). */
.weli-colfilter-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(3px);
    z-index: 4600;
    display: none;
    align-items: center;
    justify-content: center;
}
.weli-colfilter-overlay.open { display: flex; }
.weli-colfilter {
    /* Suit le thème de la weli parente (hérite des variables --weli-* de
       .weli-wrapper[data-theme="dark"]) plutôt que de le forcer en clair. */
    --weli-text-muted:       #94a3b8;
    background: var(--weli-bg-card);
    border-radius: 14px;
    width: 760px; max-width: 96vw;
    height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: var(--weli-modal-shadow);
    overflow: hidden;
    position: relative;
}
.weli-colfilter-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 10px; border-bottom: 1px solid #e2e8f0;
    background: var(--weli-bg-header-inner, #eaeff6); flex-shrink: 0;
}
.weli-colfilter-title {
    font-weight: 700; font-size: 18px; color: var(--weli-text-primary, #1a2636);
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.weli-colfilter-actions {
    display: flex; gap: 6px; align-items: center; flex-shrink: 0;
}
.weli-colfilter-actions .weli-tool-btn--primary {
    display: inline-flex; align-items: center; gap: 5px;
    width: auto; padding: 0 12px; font-size: 12px; font-weight: 600;
}
.weli-colfilter-grid {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 10px;
    padding: 12px;
    overflow: hidden;
}
.weli-colfilter-panel {
    display: flex; flex-direction: column;
    min-height: 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
}
.weli-colfilter-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 10px;
    font-size: 12px; font-weight: 700; color: #475569;
    background: #eaeff6; border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.weli-colfilter-panel-mount {
    flex: 1; min-height: 0;
    overflow: hidden;
    display: flex; flex-direction: column;
    position: relative;
}
.weli-colfilter-panel-mount > .weli-container {
    flex: 1; min-height: 0;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.weli-colfilter-panel-mount .weli-wrapper {
    flex: 1; min-height: 0;
    overflow: hidden;
    display: flex; flex-direction: column;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}
.weli-colfilter-panel-mount .weli-table-container {
    flex: 1; min-height: 0;
    overflow-y: auto !important;
    max-height: none !important;
}
/* Header weli interne des mini-grilles : on garde la toolbar native mais on
   n'affiche que les actions CRUD (✚/✎/🗑), le rafraîchissement, le nettoyage
   des filtres (maison), l'export et l'import CSV — pas de titre, recherche,
   colonnes, préférences ou thème. */
.weli-colfilter-panel-mount .weli-header {
    padding: 4px 6px !important;
    background: transparent !important;
    border-bottom: 1px solid #e2e8f0 !important;
    min-height: 0 !important;
}
.weli-colfilter-panel-mount .weli-title,
.weli-colfilter-panel-mount .weli-last-refresh,
.weli-colfilter-panel-mount .weli-pref-chip,
.weli-colfilter-panel-mount .weli-tool-sep {
    display: none !important;
}
.weli-colfilter-panel-mount .weli-toolbar {
    gap: 4px;
}
.weli-colfilter-panel-mount .weli-toolbar .weli-tool-btn:not([data-action="row-add"]):not([data-action="row-edit"]):not([data-action="row-delete"]):not([data-action="refresh"]):not([data-action="clearfilters"]):not([data-action="export"]):not([data-action="import"]) {
    display: none !important;
}

/* ── Table filtres dans filtermodal ── */
.weli-filtermodal { min-width: 380px; max-width: 520px; }
.weli-filtermodal-mount { padding: 8px 0; max-height: 60vh; overflow-y: auto; }
.weli-filter-tbl { width: 100%; border-collapse: collapse; }
.weli-filter-tbl tr + tr td { border-top: 1px solid #f1f5f9; }
.weli-filter-tbl-label {
    padding: 8px 16px; font-size: 13px; font-weight: 600;
    color: #475569; white-space: nowrap; width: 40%;
}
.weli-filter-tbl-val { padding: 6px 16px 6px 8px; }
.weli-filter-input {
    width: 100%; border: 1px solid #e2e8f0; border-radius: 6px;
    padding: 5px 10px; font-size: 13px; outline: none;
    box-sizing: border-box; transition: border-color .15s;
    font-family: inherit;
}
.weli-filter-input:focus { border-color: var(--weli-accent, #3b82f6); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
/* ── Modale export CSV ── */
.weli-export-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px); z-index: 2000;
    align-items: center; justify-content: center;
}
.weli-export-modal {
    background: #fff; border-radius: 12px; width: 420px; max-width: 94vw;
    box-shadow: 0 24px 64px rgba(0,0,0,.30); overflow: hidden;
    display: flex; flex-direction: column;
}
/* ── Modale import CSV — créée en enfant de .weli-wrapper (pas de document.body),
   suit donc le thème propre de la weli via les variables --weli-* héritées. ── */
.weli-import-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    backdrop-filter: blur(3px); z-index: 2000;
    align-items: center; justify-content: center;
}
.weli-import-modal {
    background: var(--weli-bg-card); color: var(--weli-text-primary);
    border-radius: 12px; width: 460px; max-width: 94vw; max-height: 80vh;
    box-shadow: var(--weli-modal-shadow, 0 24px 64px rgba(0,0,0,.30));
    overflow: hidden; display: flex; flex-direction: column;
}
.weli-import-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--weli-border, #e2e8f0);
    font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.weli-import-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; }
.weli-import-footer {
    padding: 12px 18px; border-top: 1px solid var(--weli-border, #e2e8f0);
    display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0;
}
.weli-import-footer .weli-tool-btn {
    width: auto; height: auto; padding: 8px 14px;
    font-size: 13px; font-weight: 600; white-space: nowrap;
}
.weli-import-map-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.weli-import-map-tbl td { padding: 4px 6px; border-bottom: 1px solid var(--weli-border, #f1f5f9); }
.weli-import-errors {
    margin-top: 10px; max-height: 160px; overflow-y: auto;
    border: 1px solid rgba(220,38,38,.35); border-radius: 6px;
    background: rgba(220,38,38,.06);
}
.weli-import-error-row {
    padding: 6px 10px; font-size: 12.5px; color: #dc2626;
    border-bottom: 1px solid rgba(220,38,38,.20);
}
.weli-import-error-row:last-child { border-bottom: none; }
.weli-import-error-row.weli-import-error-more { font-style: italic; opacity: .8; }

/* ── Mode réduit : champ de saisie + weli complète en fenêtre flottante ── */
.weli-reduit-wrapper {
    display: inline-block;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    /* .weli-wrapper (carte) impose border-radius:12px + overflow:hidden : sur ce
       wrapper sans cadre, ils rognaient les angles et le bas du champ (rayon 6px)
       et coupaient son halo de focus. */
    border-radius: 0 !important;
    overflow: visible !important;
}
.weli-reduit-input {
    width: 100%; box-sizing: border-box;
    padding: 8px 12px; font-size: 14px; font-family: inherit;
    border: 1px solid var(--weli-border-input, #b0bdd0);
    border-radius: 6px;
    background: var(--weli-bg-input, #fff);
    color: var(--weli-text-input, #1e293b);
    cursor: pointer;
}
.weli-reduit-input:focus {
    outline: none;
    border-color: var(--weli-accent, #2563eb);
    box-shadow: 0 0 0 3px var(--weli-accent-light, rgba(37,99,235,.18));
}
.weli-reduit-panel {
    display: none;
    position: fixed;
    z-index: 3000;
    max-height: 70vh;
    background: var(--weli-bg-card, #fff);
    border-radius: 10px;
    box-shadow: var(--weli-modal-shadow, 0 24px 64px rgba(0,0,0,.30));
    overflow: hidden;
}
.weli-reduit-panel .weli-container { height: 100%; max-height: 70vh; overflow: auto; }
.weli-reduit-panel .weli-wrapper {
    margin: 0 !important; border: none !important;
    box-shadow: none !important; border-radius: 0 !important;
}
/* Empilement titre/toolbar + rétrécissement des boutons : entièrement géré
   par les règles de base .weli-header/.weli-title/.weli-toolbar (flex-wrap
   natif + clamp(cqi) sur .weli-header, qui est aussi le query container ici)
   — rien de spécifique à ajouter pour le panneau du mode réduit. */

/* ── Variables d'ombre et couleurs menu ── */
:root {
    --weli-menu-shadow  : 0 2px 4px rgba(0,0,0,.08),
                          0 8px 24px rgba(0,0,0,.18),
                          0 20px 48px rgba(0,0,0,.16);
    --weli-modal-shadow : 0 4px 8px rgba(0,0,0,.10),
                          0 16px 40px rgba(0,0,0,.24),
                          0 40px 96px rgba(0,0,0,.22);
    /* Menu colonnes — mode clair */
    --weli-menu-bg        : #ffffff;
    --weli-menu-border    : #e2e8f0;
    --weli-menu-color     : #1e293b;
    --weli-menu-hover-bg  : #eff6ff;
    --weli-menu-icon-bg   : #bfdbfe;
    --weli-menu-icon-color: #1d4ed8;
    --weli-menu-sep-icon  : #60a5fa;
    --weli-menu-sep-body  : #cbd5e1;
    --weli-menu-disabled  : #94a3b8;
    --weli-menu-active    : var(--weli-accent, #3b82f6);
}
/* Mode sombre */
@media (prefers-color-scheme: dark) {
    :root {
        --weli-menu-shadow    : 0 2px 4px rgba(0,0,0,.40),
                                0 8px 24px rgba(0,0,0,.55),
                                0 0 0 1px rgba(255,255,255,.08);
        --weli-modal-shadow   : 0 4px 12px rgba(0,0,0,.50),
                                0 20px 60px rgba(0,0,0,.65),
                                0 0 0 1px rgba(255,255,255,.10);
        --weli-menu-bg        : #1e293b;
        --weli-menu-border    : #334155;
        --weli-menu-color     : #e2e8f0;
        --weli-menu-hover-bg  : #1e3a5f;
        --weli-menu-icon-bg   : #1e3a5f;
        --weli-menu-icon-color: #93c5fd;
        --weli-menu-sep-icon  : #2563eb;
        --weli-menu-sep-body  : #334155;
        --weli-menu-disabled  : #475569;
        --weli-menu-active    : #93c5fd;
    }
}
/* Classe explicite dark */
.weli-theme-dark,
[data-theme="dark"] {
    --weli-menu-shadow    : 0 2px 4px rgba(0,0,0,.40),
                            0 8px 24px rgba(0,0,0,.55),
                            0 0 0 1px rgba(255,255,255,.08);
    --weli-modal-shadow   : 0 4px 12px rgba(0,0,0,.50),
                            0 20px 60px rgba(0,0,0,.65),
                            0 0 0 1px rgba(255,255,255,.10);
    --weli-menu-bg        : #1e293b;
    --weli-menu-border    : #334155;
    --weli-menu-color     : #e2e8f0;
    --weli-menu-hover-bg  : #1e3a5f;
    --weli-menu-icon-bg   : #1e3a5f;
    --weli-menu-icon-color: #93c5fd;
    --weli-menu-sep-icon  : #2563eb;
    --weli-menu-sep-body  : #334155;
    --weli-menu-disabled  : #475569;
    --weli-menu-active    : #93c5fd;
}

/* ── Icônes [div=...][/div] ─────────────────────────────────────────────── */
.weli-icon {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* icon_engager → ancre / engagement */
.weli-icon--icon_engager {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5z'/%3E%3Cpath d='M2 17l10 5 10-5'/%3E%3Cpath d='M2 12l10 5 10-5'/%3E%3C/svg%3E");
}

/* icon_prevu → horloge / planifié (marble verte) */
.weli-icon--icon_prevu {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2322c55e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
}

/* icon_valider → coche de validation */
.weli-icon--icon_valider {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2316a34a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* ── Toolbar à gauche (toolbar_position: "left") ────────────────────────── */
.weli-header--toolbar-left {
    flex-direction: row-reverse;
    justify-content: flex-start;
}
/* row-reverse inverse aussi le bord "début" du flex (à droite) — sans ça,
   space-between recale la toolbar sur ce bord dès qu'elle est seule sur sa
   ligne (mode empilé), donc à droite au lieu de rester à gauche comme en
   mode large. Une marge auto absorbe l'espace libre de façon cohérente,
   seule ou à côté du titre : la toolbar reste toujours à gauche. */
.weli-header--toolbar-left .weli-toolbar {
    margin-left: 0;
    margin-right: auto;
}

/* En miroir, le titre s'aligne à droite */
.weli-header--toolbar-left .weli-title {
    text-align: right;
}

/* ── Modale CRUD — suit le thème de la weli parente ─────────────────────── */
.weli-crud-overlay .weli-crud-modal {
    --weli-text-muted:       #94a3b8;
    background: var(--weli-bg-card);
    color: var(--weli-text-primary);
}

.weli-crud-overlay .weli-crud-modal input,
.weli-crud-overlay .weli-crud-modal textarea,
.weli-crud-overlay .weli-crud-modal select {
    background: #ffffff !important;
    color:       #1e293b !important;
    border-color: #c8d3e0 !important;
}

.weli-crud-overlay .weli-crud-label {
    color: #475569 !important;
}
/* ── Tooltip custom global (remplace les title= natifs) ── */
/* Le tooltip est dans <body> (hors .weli-wrapper) : pas d'accès aux
   variables CSS du thème. On utilise donc deux blocs hardcodés
   light / dark, basculés par la classe weli-htip--dark posée en JS. */
#weli-htip {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .15s ease, transform .15s ease;
    border-radius: 8px;
    padding: 8px 13px;
    font-size: 12px;
    font-family: inherit;
    line-height: 1.55;
    white-space: pre-wrap;
    max-width: 520px;
    word-break: break-all;
    /* ── Thème CLAIR (défaut) ── */
    background: #ffffff;
    color: #1a2636;
    border: 1px solid #c8d3e0;
    box-shadow:
        0 2px 4px  rgba(0,0,0,.10),
        0 8px 20px rgba(0,0,0,.18),
        0 20px 48px rgba(0,0,0,.22),
        0 0 0 1px  rgba(0,0,0,.06);
}
#weli-htip.weli-htip--on {
    opacity: 1;
    transform: translateY(0);
}
/* ── Thème SOMBRE ── */
#weli-htip.weli-htip--dark {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    box-shadow:
        0 2px 4px  rgba(0,0,0,.30),
        0 8px 20px rgba(0,0,0,.50),
        0 20px 48px rgba(0,0,0,.55),
        0 0 0 1px  rgba(0,0,0,.40);
}
/* ── Viewer EML ────────────────────────────────────────────────────────────── */
.weli-eml-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.weli-eml-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0,0,0,.35);
    width: 100%; max-width: 780px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.weli-eml-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.weli-eml-modal-title { font-weight: 700; font-size: 15px; color: #1e293b; }
.weli-eml-meta {
    padding: 14px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #fafbfc;
    flex-shrink: 0;
    font-size: 13px;
}
.weli-eml-subject {
    font-size: 15px; font-weight: 700; color: #0f172a;
    margin-bottom: 10px;
}
.weli-eml-fields { display: flex; flex-direction: column; gap: 3px; color: #334155; }
.weli-eml-fields div { line-height: 1.5; }
.weli-eml-label {
    display: inline-block; width: 32px;
    font-weight: 600; color: #64748b; font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em;
    margin-right: 6px;
}
.weli-eml-body {
    flex: 1; min-height: 0;
    overflow-y: auto;
    display: flex; flex-direction: column;
}
.weli-eml-iframe { width: 100%; border: none; flex: 1; min-height: 200px; display: block; }
.weli-eml-loading, .weli-eml-error, .weli-eml-empty {
    padding: 24px 20px; font-size: 13px; color: #64748b; text-align: center;
}
.weli-eml-error { color: #b91c1c; }
[data-theme="dark"].weli-eml-overlay .weli-eml-modal {
    background: #1e293b; box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
[data-theme="dark"].weli-eml-overlay .weli-eml-modal-header {
    background: #0f172a; border-bottom-color: #334155;
}
[data-theme="dark"].weli-eml-overlay .weli-eml-modal-title { color: #e2e8f0; }
[data-theme="dark"].weli-eml-overlay .weli-eml-meta {
    background: #0f172a; border-bottom-color: #334155; color: #94a3b8;
}
[data-theme="dark"].weli-eml-overlay .weli-eml-subject { color: #e2e8f0; }
[data-theme="dark"].weli-eml-overlay .weli-eml-fields { color: #cbd5e1; }

/* ══════════════════════════════════════
   ÉCHELLE (curseur de zoom toolbar)
   Popup en position:fixed, ajouté à document.body et positionné en JS
   (comme .weli-colmenu) — nécessaire pour échapper à l'overflow:hidden
   de .weli-toolbar et ne pas hériter du zoom qu'il pilote lui-même.
══════════════════════════════════════ */
.weli-scale-popup {
    position: fixed;
    z-index: 4000;
    background: var(--cal-bg, #fff);
    border: 1px solid var(--cal-border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    padding: 12px 14px;
    width: 190px;
    user-select: none;
}
.weli-scale-popup.hidden { display: none; }
.weli-scale-popup-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--weli-text-secondary, #64748b);
    margin-bottom: 8px;
}
.weli-scale-popup-value { color: var(--weli-accent, #3b82f6); font-weight: 700; }
.weli-scale-popup input[type="range"] {
    width: 100%;
    accent-color: var(--weli-accent, #3b82f6);
    cursor: pointer;
}
.weli-scale-popup-reset {
    margin-top: 8px;
    width: 100%;
    border: 1px solid var(--weli-btn-border, #cbd5e1);
    background: var(--weli-btn-bg, #f8fafc);
    color: var(--weli-btn-fg, #334155);
    border-radius: 6px;
    padding: 4px 0;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.weli-scale-popup-reset:hover {
    border-color: var(--weli-accent, #3b82f6);
    color: var(--weli-accent, #3b82f6);
}
.weli-scale-popup--dark {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.weli-scale-popup--dark .weli-scale-popup-label { color: #94a3b8; }
.weli-scale-popup--dark .weli-scale-popup-reset {
    background: #0f172a; border-color: #334155; color: #cbd5e1;
}