/* ═══════════════════════════════════════════════════════════
   DTISoft — Audit Historique Popup
   ═══════════════════════════════════════════════════════════ */
.au-overlay {
    /* 10600 : au-dessus des fiches (ad/td 9600) et du drill-down stock (ad-popup 10001)
       d'où l'audit peut être ouvert, sous la visionneuse de PJ (fx 11800). Était 9000
       → l'audit s'ouvrait DERRIÈRE la fiche article / le drill-down. */
    position: fixed; inset: 0; z-index: 10600;
    background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center;
}
.au-panel {
    background: var(--white); border-radius: 6px;
    width: 85%; height: 84%;
    box-shadow: 0 12px 48px rgba(0,0,0,.3);
    display: flex; flex-direction: column; overflow: hidden;
}
.au-loading { padding: 40px; text-align: center; font-size: 14px; color: var(--gray-500); }

/* Header */
.au-header {
    padding: 8px 14px; display: flex; align-items: center; gap: 10px;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.au-title {
    font-weight: 700; font-size: 14px; flex: 1;
    display: flex; align-items: center; gap: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.au-title .au-sub { font-weight: 400; color: var(--gray-500); font-size: 12px; margin-left: 6px; }
.au-count { font-size: 11px; color: var(--gray-500); font-weight: 400; }
.au-close-btn { border: none; background: none; cursor: pointer; font-size: 16px; color: var(--gray-500); padding: 2px 6px; }
.au-close-btn:hover { color: var(--gray-800); }

/* Filters bar */
.au-filters {
    padding: 6px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
}
.au-filters input[type=text], .au-filters input[type=date] {
    border: 1px solid var(--gray-300); border-radius: 3px; padding: 3px 6px;
    font-size: 12px; height: 24px; box-sizing: border-box;
}
.au-filters label { display: flex; align-items: center; gap: 4px; color: var(--gray-600); }

/* Table — width:auto + table-layout:fixed pour activer le scroll horizontal
   dès que la somme des colonnes dépasse le wrapper */
.au-grid-wrap { flex: 1; overflow: auto; }

/* ── Panneau du HAUT : l'historique DTI (diffs) ──────────────────────
   Occupe toute la hauteur tant que l'archive est masquée ; l'archive
   est `hidden`, donc RETIRÉE du flux flex — sans quoi elle volerait la
   moitié de l'espace alors qu'elle n'affiche rien. */
.au-diff-wrap { flex: 1; overflow: auto; min-height: 0; }
.au-diff-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.au-diff-tbl thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--gray-100); color: var(--gray-700);
    text-align: left; padding: 6px 10px; font-weight: 600;
    border-bottom: 1px solid var(--gray-300); white-space: nowrap;
}
.au-diff-tbl td { padding: 5px 10px; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
.au-diff-tbl tbody tr:hover td { background: var(--blue-pale); }
.au-diff-dt { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--gray-600); }
/* La colonne « Changement » : UN CHAMP PAR LIGNE, aligné en colonnes.
   Le séparateur « || » d'origine venait d'un GROUP_CONCAT SQL et rendait
   illisible une ligne créée portant une douzaine de champs. */
.au-diff-chg { color: var(--gray-800); line-height: 1.45; }
.au-diff-ctx {
    display: inline-block; background: var(--gray-100); color: var(--gray-600);
    border-radius: 3px; padding: 1px 7px; margin-bottom: 4px; font-size: 11px;
    font-weight: 600; white-space: nowrap;
}
/* Renvoi vers le classeur d'origine d'un import. Vert « Excel » plutôt que
   la couleur des liens : ce n'est pas une navigation dans l'application, on
   sort vers un document. N'apparaît QUE si le fichier est encore archivé. */
.au-src {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid #bbf7d0; background: #f0fdf4; color: #166534;
    border-radius: 4px; padding: 2px 8px; margin: 0 0 5px 4px;
    font-size: 11px; font-weight: 600; cursor: pointer; max-width: 100%;
}
.au-src:hover { background: #dcfce7; border-color: #86efac; }
.au-src i { color: #16a34a; }
/* Le nom du fichier peut faire 120 caractères : il s'abrège plutôt que
   d'élargir la colonne « Changement ». */
.au-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-src-l { color: #15803d; font-weight: 400; }
/* Tags de la colonne Action. La palette reprend celle de l'archive
   (`.au-action-*`, l. ~158) pour que les deux panneaux se lisent pareil.
   ⚠️ Ces règles manquaient : le panneau émettait `.au-act-20` etc. sans
   qu'aucune ne soit définie — les tags s'affichaient en texte nu. */
.au-act {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
    background: var(--gray-100); color: var(--gray-600);
}
.au-act-20 { background: #dcfce7; color: #15803d; }   /* Création      */
.au-act-21 { background: #dbeafe; color: #1d4ed8; }   /* Modification  */
.au-act-22 { background: #fee2e2; color: #b91c1c; }   /* Suppression   */
.au-act-23 { background: #ffedd5; color: #c2410c; }   /* Chgt statut   */
.au-act-24 { background: #ede9fe; color: #6d28d9; }   /* Import tarif  */
.au-act-25 { background: #f1f5f9; color: #475569; }   /* Désactivation */
.au-act-26 { background: #fef9c3; color: #a16207; }   /* Dépréciation  */
.au-act-27 { background: #ccfbf1; color: #0f766e; }   /* Création auto système */

.au-chg { list-style: none; margin: 0; padding: 0; }
/* ⚠️ Colonnes en `max-content` et non en `1fr` : avec des fractions, la
   flèche et la nouvelle valeur étaient rejetées à l'extrême droite de la
   cellule, très loin de l'ancienne valeur — l'œil ne faisait plus le lien.
   `justify-content: start` empêche la ligne de s'étirer sur toute la largeur. */
.au-chg-l {
    display: grid;
    grid-template-columns: minmax(105px, max-content) minmax(50px, max-content) max-content max-content;
    justify-content: start; gap: 0 10px; align-items: baseline; padding: 1px 0;
}
/* Le nom du champ s'efface derrière les valeurs : c'est le changement qui
   compte, pas l'étiquette. */
.au-chg-f { color: var(--gray-500); font-size: 11.5px; }
.au-chg-av { color: var(--gray-500); text-decoration: line-through; text-decoration-color: var(--gray-300); }
.au-chg-fl { color: var(--gray-400); font-size: 11px; }
/* La couleur DIT quelque chose, elle n'est pas décorative :
   vert = la valeur augmente · rouge = elle diminue · neutre = ni l'un ni
   l'autre (texte non comparable, ou passage depuis/vers du vide).
   Une nouvelle valeur est donc SANS couleur par défaut. */
.au-chg-ap { color: var(--gray-800); font-weight: 600; }
.au-chg-hausse { color: #15803d; }
.au-chg-baisse { color: #b91c1c; }
.au-chg-vide { color: var(--gray-400); font-style: italic; font-size: 11px; text-decoration: none; }
.au-chg-resume { color: #b45309; font-weight: 600; grid-column: 2 / -1; }
/* Repli des champs au-delà des 3 premiers. */
.au-chg-plus {
    margin-top: 3px; padding: 1px 8px 1px 4px;
    background: none; border: 0; border-radius: 3px;
    color: var(--blue-mid); font-size: 11px; font-weight: 600; cursor: pointer;
}
.au-chg-plus:hover { background: var(--blue-pale); }
.au-chg-plus i { font-size: 9px; margin-right: 3px; }
.au-chg-sup[hidden] { display: none; }
/* Import de masse : volontairement en retrait — c'est une ligne de résumé,
   pas une saisie humaine. */
.au-diff-import td { background: #fbfaf5; color: var(--gray-500); font-style: italic; }
.au-diff-note { padding: 6px 12px; font-size: 11px; color: #b91c1c; }
.au-vide { padding: 34px; text-align: center; color: var(--gray-500); font-size: 13px; }
.au-vide i { color: var(--blue-mid); margin-right: 6px; }
.au-vide-note { margin-top: 6px; font-size: 11.5px; color: var(--gray-400); }

/* ── Séparateur + archive DPIFac ─────────────────────────────────────
   `flex: 0 0 auto` sur la case : elle ne doit jamais s'étirer. */
.au-arch-toggle {
    flex: 0 0 auto; display: flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-top: 2px solid var(--gray-300);
    background: var(--gray-50); font-size: 12px; font-weight: 600;
    color: var(--gray-700); cursor: pointer; user-select: none;
}
.au-arch-toggle input { cursor: pointer; }
.au-arch-note { font-weight: 400; color: var(--gray-500); font-size: 11.5px; }
/* ⚠️ Base FIXE (`flex: 0 0 …`) et non `flex: 1 1 45%`.
   Avec `flex-grow: 1` des deux côtés et une base de 0 pour `.au-diff-wrap`,
   l'archive partait de 45 % PUIS se partageait à égalité tout l'espace
   restant : elle dépassait la moitié de la fenêtre (signalé par
   l'utilisateur). Ici elle vaut exactement `--au-arch-h`, et le panneau du
   haut prend le reste. La variable est posée sur `.au-panel` par le module
   (défaut 40 %, ajustable à la poignée, mémorisée). */
.au-arch {
    flex: 0 0 var(--au-arch-h, 40%);
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.au-arch[hidden] { display: none; }

/* Poignée de redimensionnement, juste au-dessus du séparateur.
   6 px de haut mais une zone de saisie élargie par `::before` : une cible de
   6 px est pénible à attraper à la souris. */
.au-arch-grip {
    flex: 0 0 auto; position: relative; height: 6px; cursor: ns-resize;
    background: var(--gray-100); border-top: 1px solid var(--gray-200);
}
.au-arch-grip[hidden] { display: none; }
.au-arch-grip::before {
    content: ''; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px;
}
/* Le trait central : sans repère visuel, rien n'indique que c'est saisissable. */
.au-arch-grip::after {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 46px; height: 2px; margin: -1px 0 0 -23px; border-radius: 2px;
    background: var(--gray-400);
}
.au-arch-grip:hover { background: var(--gray-200); }
.au-arch-grip:hover::after, .au-arch-grip-on::after { background: var(--primary, #2563eb); }
/* Pendant le glissement, le curseur ne doit pas sélectionner le texte des
   deux tableaux qu'il survole. */
.au-arch-grip-on { background: var(--gray-200); }
body:has(.au-arch-grip-on) { user-select: none; cursor: ns-resize; }
.au-table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.au-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--gray-100); color: var(--gray-700);
    text-align: left; padding: 6px 8px; font-weight: 600;
    border-bottom: 1px solid var(--gray-300); white-space: nowrap;
    position: -webkit-sticky; position: sticky;
    box-sizing: border-box;
}
.au-table th { position: relative; }
.au-table tbody td {
    padding: 4px 8px; border-bottom: 1px solid var(--gray-100);
    vertical-align: top; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    box-sizing: border-box;
}
.au-table tbody tr { cursor: pointer; }
.au-table tbody tr:hover { background: #f8fafc; }
.au-table tbody tr.au-row-selected { background: #dbeafe; }
.au-table tbody tr.au-row-selected:hover { background: #bfdbfe; }
.au-table th.text-right, .au-table td.text-right { text-align: right; }

/* Resize handle on every header */
.au-th-resize {
    position: absolute; right: 0; top: 0; height: 100%; width: 6px;
    cursor: col-resize; user-select: none;
}
.au-th-resize:hover { background: rgba(59, 130, 246, .25); }
.au-table tbody td.au-detail { white-space: normal; word-break: break-word; max-width: 600px; line-height: 1.6; }
.au-detail-pair { display: inline-flex; align-items: center; gap: 3px; margin: 0 6px 2px 0; padding: 1px 6px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 3px; font-size: 11px; }
.au-detail-key { color: var(--gray-500); font-weight: 600; }
.au-detail-val { color: var(--gray-800); font-family: monospace; }
.au-detail-raw { font-family: monospace; font-size: 11px; color: var(--gray-500); }
.au-table .au-action-ins { color: #16a34a; font-weight: 600; }
.au-table .au-action-upd { color: #2563eb; font-weight: 600; }
.au-table .au-action-del { color: #dc2626; font-weight: 600; }
.au-table .au-action-stt { color: #ea580c; font-weight: 600; }
.au-table .au-action-other { color: var(--gray-500); }

.au-empty { padding: 40px; text-align: center; color: var(--gray-400); font-size: 13px; }
.au-error { padding: 30px; text-align: center; color: #dc2626; font-size: 13px; }

/* Status bar */
.au-status {
    padding: 4px 14px; border-top: 1px solid var(--gray-200);
    background: var(--gray-50); font-size: 11px; color: var(--gray-500);
    display: flex; gap: 12px; align-items: center;
}

/* Action buttons in filters bar */
.au-revert-btn {
    border: 1px solid var(--gray-300); background: var(--white);
    border-radius: 4px; padding: 4px 12px; cursor: pointer;
    font-size: 12px; color: var(--gray-700); display: inline-flex;
    align-items: center; gap: 6px;
}
.au-revert-btn:hover:not(:disabled) {
    background: #fef3c7; border-color: #f59e0b; color: #b45309;
}
.au-revert-btn:disabled {
    opacity: .45; cursor: not-allowed;
}
