/* ═══════════════════════════════════════════════════════════
   DTISoft — Tiers Detail Panel
   ═══════════════════════════════════════════════════════════ */

/* ── Overlay & Panel ──────────────────────────────────────── */
.td-overlay {
    /* 9600 = fiche tiers empilée par-dessus toute fiche document (F6). Au-dessus
       de la fiche transfert (.tr-overlay = 9500) comme la fiche article (.ad-overlay
       = 9600) — cohérence des « fiches empilées » ; l'ordre DOM départage à z égal
       (article ⇄ tiers). Avant : 8000 → derrière un transfert. (corrigé 2026-08-11) */
    position: fixed; inset: 0; z-index: 9600;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    animation: tdFadeIn .15s ease-out;
}
@keyframes tdFadeIn { from { opacity: 0; } }
.td-panel {
    position: relative;
    width: 96vw; max-width: 1200px; height: 92vh;
    background: #f0f0f0; border-radius: 6px;
    box-shadow: 0 12px 48px rgba(0,0,0,.35);
    display: flex; flex-direction: column;
    animation: tdSlideIn .2s ease-out; overflow: hidden;
}
@keyframes tdSlideIn { from { transform: translateY(16px); opacity: 0; } }

/* ── Header ───────────────────────────────────────────────── */
.td-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--gray-100);
    border-bottom: 1px solid var(--gray-300); flex-shrink: 0;
}
.td-header-title {
    font-size: 15px; font-weight: 700; color: var(--gray-800);
    flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.td-header-alias { color: var(--primary); }
.td-badge-disabled {
    font-size: 10px; font-weight: 700; color: #fff; background: #dc2626;
    padding: 2px 8px; border-radius: 3px;
}
.td-hdr-btn {
    background: none; border: 1px solid var(--gray-300); border-radius: 3px;
    cursor: pointer; padding: 4px 8px; color: var(--gray-500);
    font-size: 16px; display: flex; align-items: center; gap: 4px;
}
.td-hdr-btn:hover { background: var(--gray-200); color: var(--gray-700); }
.td-pj-cnt { font-size: 11px; font-weight: 600; }
/* ── Bouton PRPs (bons de préparation en cours) + son badge ──────────
   Même pastille rouge que le badge Back-Orders de la fiche document, pour
   que les deux écrans se lisent pareil. `position: relative` est repris
   du bouton lui-même : le badge se pose à cheval sur son coin. */
.td-prp-btn { position: relative; font-size: 13px; font-weight: 600; }
.td-prp-btn i { color: #7c3aed; font-size: 15px; }
.td-prp-btn:hover { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.td-prp-badge {
    position: absolute; top: -7px; right: -7px;
    min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
    background: #dc2626; color: #fff; border-radius: 9px;
    font-size: 10px; font-weight: 700; line-height: 18px; text-align: center;
    border: 2px solid var(--white); box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
/* Popup PRPs : panneau plus petit que la fiche tiers (liste courte —
   22 bons au maximum pour un client, mesuré). */
.td-prp-panel { width: 92vw; max-width: 1040px; height: auto; max-height: 80vh; }
/* Tableau calqué sur celui du popup Back-Orders de la fiche document
   (en-têtes collants en capitales, n° de doc en chasse fixe, montant en
   ambre) pour que les deux écrans se lisent de la même façon. */
.td-prp-tbl { width: 100%; border-collapse: collapse; font-size: 12px; background: var(--white); }
.td-prp-tbl th {
    position: sticky; top: 0; z-index: 1;
    background: #f1f5f9; color: #475569;
    font-size: 11px; font-weight: 600; text-align: left;
    text-transform: uppercase; letter-spacing: .03em;
    padding: 6px 10px; border-bottom: 1px solid #e2e8f0; white-space: nowrap;
}
.td-prp-tbl td { padding: 5px 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.td-prp-tbl tbody tr { cursor: pointer; }
.td-prp-tbl tbody tr:hover td { background: #f5f3ff; }
.td-prp-tbl .td-r { text-align: right; font-variant-numeric: tabular-nums; }
.td-prp-ref { font-family: Consolas, monospace; color: #0f172a; font-weight: 600; }
.td-prp-lib { color: #334155; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.td-prp-mut { color: #94a3b8; font-weight: 400; font-style: italic; }
.td-prp-mnt { font-weight: 700; color: #b45309; }
.td-prp-foot {
    padding: 10px 16px; border-top: 1px solid var(--gray-200);
    background: #fafafa; font-size: 12px; color: #334155;
}
.td-prp-foot b { color: #b45309; }
/* Le corps défile, le pied reste visible. */
.td-prp-panel .td-body { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.td-prp-panel .td-body > .td-prp-tbl { display: table; }
.td-prp-panel .td-body { overflow: auto; }
.td-save-btn {
    background: #2563eb; color: var(--white) !important;
    border-color: #2563eb; font-weight: 600;
    transition: background .15s ease;
}
.td-save-btn:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.td-save-btn i { margin-right: 4px; }
/* État "Sauvé" : grisé, désactivé tant que pas de modifs */
.td-save-btn:disabled, .td-save-btn-saved {
    background: #f3f4f6 !important; color: #6b7280 !important;
    border-color: #d1d5db; cursor: default;
}
.td-save-btn-saved i { color: #6b7280; }
.td-close-btn {
    background: none; border: none; cursor: pointer;
    font-size: 18px; color: var(--gray-500); padding: 4px 8px; border-radius: 3px;
}
.td-close-btn:hover { background: var(--gray-200); color: var(--gray-800); }

/* ── Role checkboxes ──────────────────────────────────────── */
.td-roles {
    display: flex; gap: 18px; padding: 8px 14px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0; margin-bottom: 0;
}
.td-role-cb {
    display: flex; align-items: center; gap: 5px;
    font-size: 13px; color: var(--gray-700); cursor: default;
}
.td-role-cb input[type="checkbox"] { margin: 0; cursor: pointer; width: 14px; height: 14px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.td-tabs {
    display: flex; gap: 0; flex-wrap: wrap;   /* wrap : tous les onglets restent visibles (Mémo/Historique n'étaient pas vus quand ça débordait) */
    background: var(--gray-100); border-bottom: 1px solid var(--gray-300);
    padding: 0 10px; flex-shrink: 0;
    margin-top: 4px;
}
.td-tab {
    padding: 7px 14px; font-size: 13px; font-weight: 500;
    color: var(--gray-600); cursor: pointer; white-space: nowrap;
    border: 1px solid transparent; border-bottom: none;
    margin-bottom: -1px; border-radius: 4px 4px 0 0;
}
.td-tab:hover { color: var(--gray-800); background: rgba(255,255,255,.4); }
.td-tab.active {
    color: var(--gray-800); font-weight: 600;
    background: #f0f0f0; border-color: var(--gray-300);
}

/* ── Tab content ──────────────────────────────────────────── */
.td-body { flex: 1; overflow-y: auto; background: #f0f0f0; }
.td-tab-content { display: none; padding: 12px 14px; }
.td-tab-content.active { display: block; }

/* ── Two-column layout ────────────────────────────────────── */
.td-two-col {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0 14px; align-items: start;
}
.td-col { min-width: 0; }

/* ── Fieldset groups ──────────────────────────────────────── */
.td-grp {
    border: 1px solid var(--gray-300); border-radius: 3px;
    padding: 8px 10px 10px; margin: 0 0 10px;
    background: #f7f7f7;
}
.td-grp legend {
    font-size: 12px; font-weight: 600; color: var(--gray-600);
    padding: 0 5px;
}

/* ── Aperçu chiffré du tiers (tuiles CA / docs ouverts) ── */
.td-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 7px; }
.td-stat {
    background: #fff; border: 1px solid var(--gray-300); border-radius: 5px;
    padding: 7px 8px; text-align: center; min-width: 0;
}
.td-stat-val { font-size: 16px; font-weight: 700; color: var(--blue-dark, #1e3a5f); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; }
.td-stat-lbl { font-size: 10.5px; color: var(--gray-600); margin-top: 3px; line-height: 1.2; }
.td-stat-sub { font-size: 10px; color: var(--gray-400); margin-top: 1px; }
.td-stat--link { cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s; }
.td-stat--link:hover { background: #eff6ff; border-color: var(--blue-light, #93c5fd); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.td-stat--link:focus-visible { outline: 2px solid var(--blue-light, #93c5fd); outline-offset: 1px; }
.td-stats-load, .td-stats-empty { color: var(--gray-400); font-size: 12px; padding: 6px 2px; }
/* B58 (C-tiers, 2026-10-28) : petite mention sous un chiffre (CA négatif : « plus de notes de crédit que de factures »). */
.td-stat-note { font-size: 9.5px; line-height: 1.2; color: #b45309; margin-top: 2px; }
/* B38 / D26 / D58 (C-tiers, 2026-10-28) : fenêtre « ouvrir la liste » d'une tuile qui additionne plusieurs journaux.
   Calque transparent enfant direct de <body> (classe « -overlay » : DTIOverlay le voit au premier plan — Échap ne ferme
   que lui), au-dessus de la fiche tiers (9600). */
.td-statmenu-overlay { position: fixed; inset: 0; z-index: 9610; background: transparent; }
.td-statmenu {
    position: fixed; min-width: 300px; max-width: min(460px, calc(100vw - 16px));
    background: var(--white, #fff); border: 1px solid var(--gray-300, #cbd5e1); border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 6px; font-size: 12px; color: var(--gray-700, #334155);
}
.td-statmenu-titre { font-weight: 600; padding: 4px 6px 6px; color: var(--blue-dark, #1e3a5f); }
.td-statmenu-item {
    display: grid; grid-template-columns: 46px 1fr auto auto; gap: 8px; align-items: baseline;
    width: 100%; text-align: left; background: none; border: 0; border-radius: 4px;
    padding: 6px; cursor: pointer; font: inherit; color: inherit;
}
.td-statmenu-item:hover:not(:disabled), .td-statmenu-item:focus-visible { background: #eff6ff; outline: none; }
.td-statmenu-item:disabled { cursor: default; opacity: .55; }
.td-statmenu-code { font-weight: 700; }
.td-statmenu-lib { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-600, #475569); }
.td-statmenu-nb, .td-statmenu-mt { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.td-statmenu-mt { min-width: 92px; font-weight: 600; }
.td-statmenu-total { border-top: 1px solid var(--gray-200, #e2e8f0); margin-top: 4px; padding: 6px 6px 2px; font-weight: 600; text-align: right; }
.td-statmenu-note, .td-statmenu-vide { padding: 2px 6px 4px; font-size: 10.5px; color: var(--gray-500, #64748b); }

/* ── Field rows ───────────────────────────────────────────── */
.td-fld {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 4px;
}
.td-fld-lbl {
    width: 160px; min-width: 160px; flex-shrink: 0;
    font-size: 13px; color: var(--gray-600); text-align: right;
}
.td-fld-inp {
    flex: 1; min-width: 0;
    font-size: 13px; padding: 3px 5px; height: 24px;
    border: 1px solid var(--gray-300); border-radius: 2px;
    background: var(--white); color: var(--gray-800);
    font-family: inherit;
}
.td-fld-inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
/* Search-style input */
.td-fld-search { position: relative; flex: 1; min-width: 0; display: flex; }
.td-search-icon {
    position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
    font-size: 11px; color: var(--gray-400); pointer-events: none;
}
.td-fld-search-inp { padding-left: 22px !important; }

/* Autocomplete dropdown */
.td-ac-wrap { position: relative; }
.td-ac-list {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    z-index: 100; background: var(--white);
    border: 1px solid var(--gray-300); border-top: none;
    border-radius: 0 0 3px 3px;
    max-height: 180px; overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.td-ac-item {
    padding: 5px 8px; font-size: 12px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.td-ac-item:hover { background: var(--blue-pale); }
.td-ac-nom { color: var(--gray-400); }
/* Localité : champs CP + nom en recherche (loupe + place pour l'icône) */
.td-loc-wrap { display: flex; }
.td-loc-wrap .td-loc-input { width: 100%; padding-right: 20px !important; }
.td-loc-chevron { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 10px; pointer-events: none; }
.td-ac-taken { color: #dc2626 !important; font-weight: 600; cursor: default !important; }
.td-ac-taken:hover { background: #fef2f2 !important; }
.td-ac-ok { color: #16a34a !important; font-weight: 600; cursor: default !important; }
.td-ac-ok:hover { background: #f0fdf4 !important; }
.td-ac-similar { color: var(--gray-400); font-size: 11px; }
.td-fld-inp[readonly] { background: var(--gray-50); color: var(--gray-500); cursor: not-allowed; }

/* Liaison avec Horus (2026-10-13) : mention en lecture seule sous « Réf. comptable » (onglets Client et Fournisseur).
   Texte libre, pas un champ : il passe à la ligne au lieu d'être coupé. */
.td-horus-lien { align-items: baseline; }
.td-horus-lien-txt { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.35; padding: 3px 0 2px; overflow-wrap: anywhere; }
.td-horus-lien-txt i { font-size: 11px; margin-right: 3px; }
.td-horus-lien--ok .td-horus-lien-txt { color: #166534; }
.td-horus-lien--warn .td-horus-lien-txt { color: #b45309; font-weight: 600; }
.td-horus-lien--off .td-horus-lien-txt { color: var(--gray-500); }

/* Contacts toolbar */
.td-contacts-toolbar {
    display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
}
.td-new-contact-btn {
    padding: 3px 10px; font-size: 11px; cursor: pointer;
    border: 1px solid var(--gray-300); border-radius: 3px;
    background: var(--white); color: var(--gray-700);
}
.td-new-contact-btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.td-new-contact-btn i { margin-right: 4px; }

/* Show disabled contacts toggle */
.td-show-disabled-cb {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--gray-600); cursor: pointer;
    user-select: none;
}
.td-show-disabled-cb input { cursor: pointer; }
.td-row-disabled td { color: var(--gray-400); font-style: italic; }

/* Alertes tab */
.td-alertes-list { display: flex; flex-direction: column; gap: 8px; }
.td-alerte-row {
    border: 1px solid var(--gray-200); border-radius: 4px;
    padding: 8px 10px; background: var(--white);
}
.td-alerte-new { border-color: #86efac; background: #f0fdf4; }
.td-alerte-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 6px;
}
.td-alerte-num { font-weight: 700; font-size: 12px; color: var(--gray-700); min-width: 30px; }
.td-alerte-del {
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: var(--gray-400); font-size: 12px; padding: 2px 4px;
}
.td-alerte-del:hover { color: #dc2626; }
.td-alerte-msg {
    width: 100%; resize: vertical; border: 1px solid var(--gray-200);
    border-radius: 3px; padding: 6px 8px; font-size: 12px;
    font-family: inherit; line-height: 1.5;
}
.td-alerte-msg:focus { outline: none; border-color: var(--primary); }
.td-alerte-meta { font-size: 10px; color: var(--gray-400); margin-top: 4px; }

.td-fld-duo { display: flex; gap: 4px; flex: 1; min-width: 0; }
.td-fld-short { max-width: 70px; flex: 0 0 70px; }

/* Select dropdown */
.td-fld-sel-input {
    flex: 1; min-width: 0;
    font-size: 13px; padding: 2px 4px; height: 24px;
    border: 1px solid var(--gray-300); border-radius: 2px;
    background: var(--white); color: var(--gray-800);
    font-family: inherit; cursor: pointer;
}
.td-fld-sel-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.td-fld-sel-input.td-fld-short { max-width: 70px; flex: 0 0 70px; }

/* Checkbox field */
.td-fld-chk .td-fld-lbl { visibility: hidden; }
.td-chk-label {
    display: flex; align-items: center; gap: 5px;
    font-size: 13px; color: var(--gray-700); cursor: default;
}
.td-chk-label input[type="checkbox"] { margin: 0; cursor: pointer; width: 14px; height: 14px; }

/* ── Historique filter toolbar ─────────────────────────────── */
.td-hist-toolbar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    padding: 8px 10px; margin-bottom: 8px;
    background: var(--white); border: 1px solid var(--gray-300);
    border-radius: 3px;
}
.td-hist-filter {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; font-weight: 600; color: var(--gray-700);
    cursor: pointer; user-select: none; white-space: nowrap;
}
.td-hist-filter input[type="checkbox"] { margin: 0; cursor: pointer; width: 13px; height: 13px; }
.td-hist-cnt { font-weight: 400; color: var(--gray-400); }
.td-hist-sep {
    width: 1px; height: 18px; background: var(--gray-300);
    align-self: center;
}
.td-hist-closed { color: var(--gray-500); font-weight: 500; }

/* ── Historique column filters ─────────────────────────────── */
.td-hist-filter-row td {
    padding: 3px 3px; background: var(--gray-50);
    border-bottom: 2px solid var(--gray-300);
}
.td-hist-flt {
    width: 100%; box-sizing: border-box;
    font-size: 11px; padding: 2px 4px; height: 20px;
    border: 1px solid var(--gray-300); border-radius: 2px;
    background: var(--white); color: var(--gray-700);
    font-family: inherit;
}
.td-hist-flt::placeholder { color: var(--gray-300); }
.td-hist-flt:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

/* ── Sub-grids ────────────────────────────────────────────── */
.td-grid-wrap { overflow: auto; max-height: calc(100vh - 320px); position: relative; }
.td-grid {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.td-grid th {
    background: var(--gray-100); padding: 6px 8px;
    text-align: left; font-weight: 600; color: var(--gray-600);
    border: 1px solid var(--gray-300); white-space: nowrap;
    position: sticky; top: 0; z-index: 2;
}
.td-hist-filter-row td {
    position: sticky; top: 29px; z-index: 2;
    background: var(--white);
}
.td-grid td {
    padding: 5px 8px; border: 1px solid var(--gray-200);
    white-space: nowrap; color: var(--gray-700);
    background: var(--white);
}
.td-grid tbody tr:hover td { background: #e8f0fe; }
/* Sélection clavier/souris dans l'onglet Historique (= ad-hi-row dans fiche article) */
.td-hist-row { cursor: pointer; outline: none; }
.td-hist-row.td-hist-selected td { background: #dbeafe; }
.td-hist-row:focus td { background: #dbeafe; }
.td-grid .text-right  { text-align: right; }
.td-grid .text-center { text-align: center; }
.td-grid tfoot td {
    position: sticky; bottom: 0; z-index: 2;
}
.td-grid-total td {
    font-weight: 700; background: var(--gray-100) !important;
    border-top: 2px solid var(--gray-300);
}
.td-grid-empty {
    text-align: center; padding: 40px; color: var(--gray-400); font-size: 14px;
}
.td-grid-count { font-size: 12px; color: var(--gray-500); padding: 6px 0; }

/* ── Notes textarea ───────────────────────────────────────── */
.td-textarea {
    width: 100%; min-height: 300px; padding: 10px;
    font-size: 14px; font-family: inherit; color: var(--gray-700);
    background: var(--white); border: 1px solid var(--gray-300);
    border-radius: 2px; resize: vertical;
}
/* Onglet « Mémo » : rappel de l'effet post-it sur les documents */
.td-memo-hint {
    display: flex; align-items: center; gap: 6px;
    margin: 2px 0 8px; padding: 6px 10px;
    background: #fef9c3; border: 1px solid #fde68a; border-radius: 6px;
    font-size: 12px; color: #854d0e;
}
.td-memo-hint i { color: #ca8a04; }

/* ── Footer ───────────────────────────────────────────────── */
.td-footer {
    display: flex; align-items: center; gap: 18px;
    padding: 7px 14px; border-top: 1px solid var(--gray-300);
    background: var(--gray-100); font-size: 12px; color: var(--gray-500);
    flex-shrink: 0;
}
.td-footer-solde {
    margin-left: auto; font-weight: 700; font-size: 13px; color: var(--gray-800);
}

/* ── Loading ──────────────────────────────────────────────── */
.td-loading {
    display: flex; align-items: center; justify-content: center;
    height: 200px; color: var(--gray-400); gap: 8px; font-size: 14px;
}

/* ── Statut badges reuse ──────────────────────────────────── */
.td-grid .doc-statut { font-size: 11px; padding: 1px 6px; }

/* ═══════════════════════════════════════════════════════════
   Popup — Échéancier comptable
   ═══════════════════════════════════════════════════════════ */
.td-ech-popup {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 530px; max-height: 85vh; overflow-y: auto;
    background: #f0f0f0; border: 2px solid var(--gray-400);
    border-radius: 4px; box-shadow: 0 8px 32px rgba(0,0,0,.3);
    animation: tdSlideIn .15s ease-out;
}
.td-ech-header {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; font-size: 14px; font-weight: 700;
    color: var(--gray-700); background: var(--gray-200);
    border-bottom: 1px solid var(--gray-300);
}
.td-ech-header i { color: var(--primary); }
.td-ech-source {
    font-size: 10px; font-weight: 500; color: var(--gray-400);
    margin-left: 4px;
}
.td-ech-close {
    margin-left: auto; background: none; border: none;
    cursor: pointer; font-size: 16px; color: var(--gray-500);
    padding: 2px 6px; border-radius: 3px;
}
.td-ech-close:hover { background: var(--gray-300); }
.td-ech-info {
    padding: 10px 14px; font-size: 13px; color: var(--gray-600);
    border-bottom: 1px solid var(--gray-300); line-height: 1.5;
}
.td-ech-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.td-ech-table td {
    padding: 4px 14px; color: var(--gray-700);
}
.td-ech-table td:last-child {
    text-align: right; font-family: 'Cascadia Mono', 'Consolas', monospace;
    min-width: 90px;
}
.td-ech-section td {
    padding-top: 12px; font-weight: 700; color: var(--gray-500);
    border-bottom: 1px solid var(--gray-300);
    font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.td-ech-total td {
    font-weight: 700; color: var(--gray-800);
    border-top: 1px solid var(--gray-300);
}
.td-ech-highlight td {
    font-weight: 700; color: var(--gray-900);
    background: #fef08a;
}
.td-ech-footer {
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--gray-300);
}
.td-ech-ok, .td-ech-detail-btn {
    padding: 6px 20px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--gray-400); border-radius: 3px;
    background: var(--gray-200); cursor: pointer;
    color: var(--gray-700);
}
.td-ech-ok:hover, .td-ech-detail-btn:hover { background: var(--gray-300); }
.td-ech-detail-btn { margin-right: auto; }
.td-ech-detail-btn i { margin-right: 4px; }

/* ── Detail grid inside popup ─────────────────────────────── */
.td-ech-detail-wrap {
    border-top: 1px solid var(--gray-300);
    max-height: 250px; overflow-y: auto;
}
.td-ech-detail-grid {
    width: 100%; border-collapse: collapse; font-size: 12px;
}
.td-ech-detail-grid th {
    background: var(--gray-200); padding: 5px 8px;
    text-align: left; font-weight: 600; color: var(--gray-600);
    border-bottom: 1px solid var(--gray-300); white-space: nowrap;
    position: sticky; top: 0;
}
.td-ech-detail-grid td {
    padding: 4px 8px; border-bottom: 1px solid var(--gray-200);
    white-space: nowrap; color: var(--gray-700);
}
.td-ech-detail-grid .text-right { text-align: right; }
.td-ech-detail-grid tbody tr:hover td { background: #e8f0fe; }
/* Row states */
.td-row-paid td    { background: #f0fdf4; }
.td-row-paid:hover td    { background: #dcfce7 !important; }
.td-row-matched td { background: #f0fdf4; }
.td-row-matched:hover td { background: #dcfce7 !important; }
.td-row-due td     { background: #fef2f2; }
.td-row-due:hover td     { background: #fecaca !important; }
.td-row-pending td { background: var(--white); }

/* Status icons */
.td-ic-paid    { color: #16a34a; }
.td-ic-matched { color: #16a34a; }
.td-ic-due     { color: #dc2626; }
.td-ic-pending { color: var(--gray-400); }

/* ═══════════════════════════════════════════════════════════
   Popup — Pièces jointes
   ═══════════════════════════════════════════════════════════ */
.td-pj-popup {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 530px; max-height: 70vh;
    background: #f0f0f0; border: 2px solid var(--gray-400);
    border-radius: 4px; box-shadow: 0 8px 32px rgba(0,0,0,.3);
    display: flex; flex-direction: column;
    animation: tdSlideIn .15s ease-out;
}
.td-pj-header {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; font-size: 14px; font-weight: 700;
    color: var(--gray-700); background: var(--gray-200);
    border-bottom: 1px solid var(--gray-300); flex-shrink: 0;
}
.td-pj-header i.fa-paperclip { color: var(--gray-500); }
.td-pj-grid-wrap {
    flex: 1; overflow-y: auto; min-height: 80px;
}
.td-pj-grid {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.td-pj-grid th {
    background: var(--gray-100); padding: 6px 10px;
    text-align: left; font-weight: 600; color: var(--gray-600);
    border-bottom: 1px solid var(--gray-300); white-space: nowrap;
    position: sticky; top: 0;
}
.td-pj-grid td {
    padding: 5px 10px; border-bottom: 1px solid var(--gray-200);
    white-space: nowrap; color: var(--gray-700);
    background: var(--white);
}
.td-pj-grid tbody tr:hover td { background: #e8f0fe; }
.td-pj-grid .text-right { text-align: right; }
.td-pj-file-icon { color: var(--gray-400); margin-right: 4px; }
.td-pj-actions { white-space: nowrap; text-align: center; }
.td-pj-action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 3px;
    color: var(--gray-500); text-decoration: none;
    transition: background .15s, color .15s;
}
.td-pj-action:hover { background: var(--gray-100); color: var(--primary); }
.td-pj-empty {
    text-align: center; padding: 30px; color: var(--gray-400);
    font-style: italic;
}
.td-pj-count {
    font-size: 12px; color: var(--gray-500); margin-right: auto;
}

/* ── Bouton « Vérifier TVA » + popup VIES ──────────────── */
.td-vies-btn {
    margin-top: 4px; padding: 4px 10px;
    border: 1px solid #2563eb; background: #fff; color: #2563eb;
    border-radius: 3px; font-size: 11px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px;
}
.td-vies-btn:hover:not(:disabled) { background: #eff6ff; }
.td-vies-btn:disabled { opacity: 0.5; cursor: default; }

.td-vies-overlay {
    position: fixed; inset: 0; z-index: 10500;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
}
.td-vies-box {
    background: #fff; border-radius: 8px;
    box-shadow: 0 12px 50px rgba(0,0,0,.35);
    width: 440px; max-width: 92%;
    padding: 18px 22px;
    text-align: center;
}
.td-vies-box-wide { width: 540px; }
.td-vies-icon { font-size: 40px; margin-bottom: 6px; }
.td-vies-title { font-size: 16px; font-weight: 700; color: #065f46; margin-bottom: 12px; }
.td-vies-msg { font-size: 13px; color: #374151; margin-bottom: 14px; white-space: pre-line; }
.td-vies-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
    margin-bottom: 14px; text-align: left;
}
.td-vies-table td {
    padding: 4px 8px; border-bottom: 1px solid #f3f4f6;
}
.td-vies-table td:first-child {
    color: #6b7280; width: 110px; font-weight: 600;
}
.td-vies-question { font-size: 12px; color: #374151; margin-bottom: 12px; }
.td-vies-foot { display: flex; justify-content: flex-end; gap: 8px; }
.td-vies-cancel {
    padding: 6px 14px; border: 1px solid #d1d5db; background: #fff; color: #374151;
    border-radius: 4px; cursor: pointer; font-size: 13px;
}
.td-vies-cancel:hover { background: #f3f4f6; }
.td-vies-apply {
    padding: 6px 14px; border: 1px solid #16a34a; background: #16a34a; color: #fff;
    border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px;
}
.td-vies-apply:hover { background: #15803d; border-color: #15803d; }
.td-vies-ok {
    padding: 6px 22px; border: 1px solid #2563eb; background: #2563eb; color: #fff;
    border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.td-vies-ok:hover { background: #1d4ed8; }

/* ── Bloc Profil entreprise (BCE) ─────────────────────── */
.td-bce-block {
    margin-top: 10px; padding: 10px 12px;
    background: #f0f9ff; border: 1px solid #bfdbfe; border-radius: 4px;
}
/* Variantes selon situation juridique (riskLevel renvoyé par BCE) */
.td-bce-block.td-bce-risk-green  { background: #f0fdf4; border-color: #bbf7d0; }
.td-bce-block.td-bce-risk-orange { background: #fff7ed; border-color: #fed7aa; }
.td-bce-block.td-bce-risk-red    { background: #fef2f2; border-color: #fca5a5; }
.td-bce-block.td-bce-risk-gray   { background: #f9fafb; border-color: #e5e7eb; }

.td-bce-title {
    font-size: 12px; font-weight: 700; color: #1e40af;
    margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.td-bce-title i { color: #3b82f6; }
.td-bce-meta {
    margin-left: auto; font-size: 10px; font-style: italic;
    color: #6b7280; font-weight: 400;
}
.td-bce-block.td-bce-risk-green  .td-bce-title { color: #166534; }
.td-bce-block.td-bce-risk-green  .td-bce-title i { color: #16a34a; }
.td-bce-block.td-bce-risk-orange .td-bce-title { color: #9a3412; }
.td-bce-block.td-bce-risk-orange .td-bce-title i { color: #ea580c; }
.td-bce-block.td-bce-risk-red    .td-bce-title { color: #7f1d1d; }
.td-bce-block.td-bce-risk-red    .td-bce-title i { color: #dc2626; }
.td-bce-block.td-bce-risk-gray   .td-bce-title { color: #374151; }
.td-bce-block.td-bce-risk-gray   .td-bce-title i { color: #6b7280; }

/* Lien « Voir sur BCE » — kbopub, nouvel onglet. Posé APRÈS `.td-bce-meta`
   (qui porte `margin-left:auto`) : il se colle donc au bord droit du titre.
   `flex:0 0 auto` l'empêche d'être écrasé par une méta longue
   (« Données BCE du 12/07/2026 (24 j) · vérifié le 05/08/2026 »). */
.td-bce-lien {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
    margin-left: 8px; padding: 2px 8px;
    border: 1px solid #bfdbfe; border-radius: 3px;
    background: #fff; color: #1d4ed8;
    font-size: 11px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.td-bce-lien:hover { background: #dbeafe; border-color: #93c5fd; color: #1e3a8a; }
/* Le libellé du titre change de couleur selon le risque ; le lien, non — il
   pointe vers la même fiche que la situation soit saine ou critique, et un
   bouton rouge se lirait comme une alerte de plus.
   ⚠️ Sélecteur long OBLIGATOIRE. Les 4 variantes de risque ciblent l'icône via
      `.td-bce-block.td-bce-risk-X .td-bce-title i`, soit (0,3,1) : elles
      repeindraient l'icône du lien. Ici `a.td-bce-lien` ajoute un sélecteur de
      type, d'où (0,3,2) — STRICTEMENT supérieur, donc gagnant quel que soit
      l'ordre des règles dans le fichier (un simple départage par position
      casserait au premier réagencement). */
.td-bce-block .td-bce-title a.td-bce-lien i { color: inherit; font-size: 10px; }
.td-bce-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.td-bce-table td { padding: 3px 6px; vertical-align: top; }
.td-bce-table td:first-child {
    color: #6b7280; width: 130px; font-weight: 600; white-space: nowrap;
}
.td-bce-nace {
    display: inline-block; font-family: monospace;
    background: #dbeafe; color: #1e40af;
    padding: 1px 6px; border-radius: 3px; font-size: 11px;
    margin-right: 6px;
}
.td-bce-nace-sec { background: #f3f4f6; color: #4b5563; }

/* ── Doublons possibles (création de tiers) ────────────────
   Bloc ambre inséré sous le champ « Nom » (modèle .td-bce-block) pendant
   la saisie + popup modale à la sauvegarde (.td-vies-overlay + .td-dbl-box).
   Construit en DOM (textContent) côté JS. */
.td-dbl-block {
    margin: 2px 0 8px; padding: 8px 10px;
    background: #fffbeb; border: 1px solid #f59e0b; border-radius: 4px;
}
.td-dbl-block.td-dbl-weak { border-color: #fcd34d; }
.td-dbl-title {
    font-size: 12px; font-weight: 700; color: #92400e;
    margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.td-dbl-title i { color: #f59e0b; }
.td-dbl-meta {
    margin-left: auto; font-size: 10px; font-style: italic;
    color: #a16207; font-weight: 400; white-space: nowrap;
}
.td-dbl-list { display: flex; flex-direction: column; gap: 4px; }
.td-dbl-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px;
    padding: 4px 8px; background: #fff;
    border: 1px solid #fde68a; border-radius: 3px;
    font-size: 12px; color: #374151; text-align: left;
}
.td-dbl-item.td-dbl-fort { border-color: #f59e0b; }
.td-dbl-item.td-dbl-disabled { opacity: .7; background: #f9fafb; }
.td-dbl-alias { font-weight: 700; color: #1f2937; white-space: nowrap; }
.td-dbl-nom { color: #374151; }
.td-dbl-nom2 { color: #6b7280; font-style: italic; }
.td-dbl-motif {
    display: inline-block; padding: 1px 7px; border-radius: 9px;
    font-size: 10.5px; font-weight: 600; white-space: nowrap;
    background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
}
.td-dbl-motif.td-dbl-motif-fort { background: #fbbf24; color: #78350f; border-color: #f59e0b; }
.td-dbl-motif.td-dbl-motif-off  { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.td-dbl-loc { color: #6b7280; font-size: 11px; white-space: nowrap; }
/* Groupe des contrôles de droite d'une ligne candidat ([« Appliquer … » |
   « ✓ … reprise(s) »] + « Ouvrir »), posé par buildDoublonRow : poussé à
   droite en bloc et insécable → ses membres passent à la ligne ENSEMBLE et
   restent alignés à droite (sans le groupe, « Ouvrir » seul en débord
   retombait à gauche). À l'intérieur, les margin-left:auto individuels sont
   sans effet (pas d'espace libre dans un inline-flex ajusté au contenu). */
.td-dbl-actions {
    margin-left: auto; display: inline-flex; align-items: center;
    gap: 6px; white-space: nowrap;
}
.td-dbl-open {
    margin-left: auto; padding: 2px 8px;
    border: 1px solid #d97706; background: #fff; color: #b45309;
    border-radius: 3px; font-size: 11px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.td-dbl-open:hover { background: #fef3c7; }
.td-dbl-open i { font-size: 10px; }
.td-dbl-more { margin-top: 5px; font-size: 11px; font-style: italic; color: #a16207; }

/* Popup à la sauvegarde (409 code 'doublons') */
.td-dbl-box .td-vies-title { color: #92400e; }
.td-dbl-box .td-dbl-list {
    max-height: 50vh; overflow-y: auto; margin-bottom: 12px;
}
.td-dbl-box .td-dbl-item { border-color: #fde68a; }
.td-dbl-box .td-dbl-item.td-dbl-fort { border-color: #f59e0b; background: #fffbeb; }
.td-dbl-force {
    padding: 6px 14px; border: 1px solid #d97706; background: #d97706; color: #fff;
    border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px;
}
.td-dbl-force:hover { background: #b45309; border-color: #b45309; }

/* ── « Même foyer » (création de tiers, 2026-08-26) ─────────────
   Bloc bleu inséré sous le champ « Adresse » (même gabarit que .td-dbl-block)
   pour les tiers à l'adresse EXACTEMENT identique ; sous une ligne, la
   proposition verte « Conditions plus avantageuses … » + bouton « Appliquer ».
   Réutilise .td-dbl-list / .td-dbl-item / .td-dbl-open. 100 % DOM côté JS. */
.td-foyer-block {
    margin: 2px 0 8px; padding: 8px 10px;
    background: #eff6ff; border: 1px solid #3b82f6; border-radius: 4px;
}
.td-foyer-title {
    font-size: 12px; font-weight: 700; color: #1e3a8a;
    margin-bottom: 6px; display: flex; align-items: center; gap: 6px;
}
.td-foyer-title i { color: #3b82f6; }
.td-foyer-meta {
    margin-left: auto; font-size: 10px; font-style: italic;
    color: #1d4ed8; font-weight: 400; white-space: nowrap;
}
.td-foyer-block .td-dbl-item { border-color: #bfdbfe; }
.td-foyer-block .td-dbl-item.td-dbl-disabled { background: #f8fafc; }
.td-foyer-block .td-dbl-open { border-color: #2563eb; color: #1d4ed8; }
.td-foyer-block .td-dbl-open:hover { background: #dbeafe; }
.td-foyer-more { margin-top: 5px; font-size: 11px; font-style: italic; color: #1d4ed8; }
/* Pill « même adresse » / « conditions plus avantageuses » (bloc ambre ET popup 409) */
.td-dbl-motif.td-dbl-motif-foyer { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
/* Conditions du candidat (« · catégorie C5 · famille C5 ») */
.td-dbl-cond { color: #1e40af; font-size: 11px; white-space: nowrap; }
/* Entrée = ligne candidat (la ligne verte de proposition qui suivait a été
   retirée le 2026-08-26 : le bouton « Appliquer catégorie et famille » de la
   ligne suffit) */
.td-foyer-entry { display: flex; flex-direction: column; gap: 0; }
.td-foyer-apply {
    margin-left: auto; padding: 2px 9px;
    border: 1px solid #059669; background: #059669; color: #fff;
    border-radius: 3px; font-size: 11px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.td-foyer-apply:hover { background: #047857; border-color: #047857; }
/* Inactif pendant le POST de sauvegarde (valeurs non envoyées sinon) */
.td-foyer-apply:disabled { opacity: .55; cursor: not-allowed; }
.td-foyer-apply:disabled:hover { background: #059669; border-color: #059669; }
.td-foyer-apply i { font-size: 10px; }
.td-foyer-applied {
    margin-left: auto; padding: 2px 8px; white-space: nowrap;
    font-size: 11px; font-weight: 600; color: #047857;
    background: #d1fae5; border: 1px solid #6ee7b7; border-radius: 3px;
}
/* Bouton « Appliquer catégorie et famille » (ou « … catégorie » / « … famille »
   si le candidat n'a qu'un GUID) DANS la ligne candidat (blocs bleu ET ambre,
   motif foyer), juste avant « Ouvrir » dans le groupe .td-dbl-actions : même
   palette verte, padding réduit ; l'état « ✓ … reprise(s) » le remplace.
   L'alignement à droite est porté par le groupe (cf. .td-dbl-actions), d'où
   margin-left:0 ici. La ligne est en flex-wrap:wrap → le groupe entier passe
   à la ligne sur les lignes chargées.
   État disabled hérité de .td-foyer-apply:disabled ; ligne désactivée
   (.td-dbl-disabled → opacity .7) inchangée. */
.td-dbl-item .td-foyer-apply-both {
    margin-left: 0; padding: 1px 7px; font-size: 10.5px;
}
.td-dbl-item .td-foyer-applied-both {
    margin-left: 0; padding: 1px 7px; font-size: 10.5px;
}

/* Couleur d'alerte (jaune/rouge) dans l'onglet Alertes */
.td-alerte-couleur { padding: 3px 6px; border: 1px solid var(--gray-300); border-radius: 4px; font-size: 12px; margin-right: 6px; }
