body {
    font-size: 0.9rem;
    background-color: #f8f9fa;
}
.navbar-brand {
    font-weight: bold;
}

/* Barre principale : entrées en icônes seules ; pastilles bot entre menu et bloc utilisateur */
.csa-nav-icon-link {
    line-height: 1;
}

/*
 * Couleur des icônes / liens du menu : doit rester lisible sur la barre primary (navbar-dark),
 * indépendamment des styles du contenu (ex. rubrique Messages : liens, table-dark, etc.).
 * Seuls les <a class="nav-link"> sont concernés — pas les <span> désactivés ni le bloc nom.
 */
.navbar.navbar-dark.bg-primary #navMain a.nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
}
.navbar.navbar-dark.bg-primary #navMain a.nav-link:hover,
.navbar.navbar-dark.bg-primary #navMain a.nav-link:focus {
    color: #fff !important;
}

/*
 * Titre « CSA Web » + badge version : couleur et police fixes.
 * Les e-mails HTML peuvent encore imposer une font au body (règles résiduelles, @font-face, etc.) :
 * le texte du brand hériterait alors d’une autre famille que le reste de l’app — pas les .bi (icônes).
 */
.navbar.navbar-dark.bg-primary > .container-fluid > .navbar-brand,
.navbar.navbar-dark.bg-primary > .container-fluid > .navbar-brand .badge {
    font-family: var(
        --bs-font-sans-serif,
        var(
            --bs-body-font-family,
            system-ui,
            -apple-system,
            "Segoe UI",
            Roboto,
            "Helvetica Neue",
            "Noto Sans",
            "Liberation Sans",
            Arial,
            sans-serif
        )
    ) !important;
}
.navbar.navbar-dark.bg-primary > .container-fluid > .navbar-brand {
    color: #fff !important;
}
.navbar.navbar-dark.bg-primary > .container-fluid > .navbar-brand:hover,
.navbar.navbar-dark.bg-primary > .container-fluid > .navbar-brand:focus {
    color: #fff !important;
}

.csa-bot-pills-center {
    min-width: 0;
}
.csa-status-pill {
    cursor: default;
    user-select: none;
    /* Zone de survol plus large que le point seul (infobulle native au survol) */
    min-width: 1.75rem;
    min-height: 1.75rem;
}
@media (min-width: 992px) {
    #navMain .navbar-collapse > .d-flex {
        min-height: 2.5rem;
    }
}
.card {
    transition: transform 0.15s;
}
.card:hover {
    transform: translateY(-2px);
}

/* Accueil : contenu des cartes au-dessus du calque stretched-link (::after z-index 1) */
.home-dash-card .card-body > :not(.stretched-link) {
    position: relative;
    z-index: 2;
    pointer-events: none;
}
.home-dash-card .card-body > .stretched-link {
    z-index: 1;
}
.table td, .table th {
    vertical-align: middle;
}
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modal-body .form-label {
    font-size: 0.85rem;
}
.badge {
    font-size: 0.75rem;
}

/* ---- Colonnes triables ---- */
.sortable-th {
    user-select: none;
    white-space: nowrap;
}
.sortable-th:hover {
    background-color: rgba(0,0,0,.25);
}
.sort-icon {
    font-size: 0.7rem;
}
/* Colonne actuellement triée (icône + soulignement discret) */
table.sortable-table thead th.sort-column-active {
    box-shadow: inset 0 -3px 0 rgba(255, 193, 7, 0.95);
}
table.sortable-table thead th.sort-column-active .sort-icon {
    filter: drop-shadow(0 0 2px rgba(255, 193, 7, 0.6));
}

/* ---- Barre de recherche ---- */
.search-bar {
    max-width: 350px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .table-responsive .table { font-size: 0.8rem; }
    .btn-sm { font-size: 0.7rem; padding: 0.2rem 0.4rem; }
    h2 { font-size: 1.3rem; }
    .search-bar { max-width: 100%; }
}

/* ---- Onglets ---- */
.nav-tabs .nav-link {
    font-size: 0.85rem;
}
.nav-tabs .nav-link.active {
    font-weight: bold;
}

/* ---- Filtre Système (classe sur #tachesTable, sans inline-style sur les lignes) ---- */
#tachesTable.hide-system tbody tr[data-is-system="1"] { display: none; }

/* ---- Surbrillance bleue au survol (leads + tâches + messages) ---- */
#leadsTable.table-hover > tbody > tr:hover > td,
#leadsTable.table-hover > tbody > tr:hover > th,
#tachesTable.table-hover > tbody > tr:hover > td,
#tachesTable.table-hover > tbody > tr:hover > th,
#msgTable.table-hover > tbody > tr:hover > td,
#msgTable.table-hover > tbody > tr:hover > th {
    background-color: rgba(13, 110, 253, 0.14) !important;
    color: inherit;
}

/* ---- Messages : détail (fond / texte alignés sur le thème, comme le reste de l’app) ---- */
#msgTable .msg-detail-panel {
    color: var(--bs-body-color);
    background-color: var(--bs-secondary-bg, var(--bs-gray-100));
}
#msgTable .msg-detail-html {
    color: var(--bs-body-color);
}
#msgTable .msg-detail-html a {
    color: var(--bs-link-color);
}

/* ---- Leads : favoris (même fond que messages importants) ---- */
#leadsTable > tbody > tr[data-lead-favori="1"] > td {
    background-color: #ffe5e5 !important;
}
#leadsTable.table-hover > tbody > tr[data-lead-favori="1"]:hover > td {
    background-color: #ffd6d6 !important;
}

/* Leads : colonnes erreur / avertissement (discret, lisible) */
#leadsTable th.lead-severity-th {
    width: 1.9rem;
    font-weight: 500;
    vertical-align: middle;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
}
#leadsTable th.lead-severity-th .lead-severity-th-icon {
    font-size: 0.7rem;
    line-height: 1;
    opacity: 0.75;
}
#leadsTable td.lead-severity-td {
    width: 1.9rem;
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    vertical-align: middle;
}
#leadsTable .lead-severity-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 999px;
    font-size: 0.65rem;
    line-height: 1;
    box-sizing: border-box;
}
#leadsTable .lead-severity-mark--error {
    color: #b02a37;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.2);
}
#leadsTable .lead-severity-mark--warning {
    color: #b45309;
    background: rgba(255, 193, 7, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.28);
}
#leadsTable .lead-pay-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    vertical-align: middle;
}
#leadsTable .lead-pay-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    font-size: 0.95rem;
    line-height: 1;
}
#leadsTable .lead-severity-empty {
    font-size: 0.65rem;
    color: var(--bs-secondary-color, #6c757d);
    opacity: 0.35;
    user-select: none;
}

/* Ruban de statut : indique qu’une info-bulle date d’obtention est dispo (survol) */
.lead-ribbon-stat--dated {
    cursor: help;
}

/* Fiche lead : ref. ID SA (contraste fiable thèmes clair / sombre) */
.lead-detail-id-sa {
    display: inline-block;
    position: relative;
    top: -0.04em;
    max-width: 100%;
    font-size: 0.52em;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
    padding: 0.18em 0.5em;
    border-radius: 0.3rem;
    /* Texte fort sur fond légèrement teinté (plus « clair sur clair ») */
    color: var(--bs-emphasis-color, #212529);
    background-color: var(--bs-secondary-bg, #e9ecef);
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.2));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
    word-break: break-all;
}

/* ID SA / interne à côté du badge statut : même ligne flex, sans décalage ni taille relative au H2 */
.lead-detail-hero > .lead-detail-id-sa {
    top: 0;
    align-self: center;
    font-size: 0.8125rem;
    line-height: 1.2;
    padding: 0.28rem 0.5rem;
}

.lead-detail-hero > .lead-detail-hero__statut {
    align-self: center;
    display: inline-flex;
    align-items: center;
}

/* Mini-pavé + libellé (liste + en-tête fiche) */
#leadsTable .lead-pipeline-statut-compact,
.lead-detail-hero .lead-pipeline-statut-compact {
    vertical-align: middle;
}
/* Statut pipeline 2 (Intéressé) : violet foncé — tranche net avec le statut 1 (info/bleu) */
.bg-csa-statut-2 {
    background-color: #4c1d95 !important; /* ~violet-900 / purple foncé */
    color: #fff !important;
}
/* Ruban fiche lead : pastille d’une étape déjà franchie (même teinte, atténuée) */
.bg-csa-statut-2.bg-opacity-25 {
    background-color: rgba(76, 29, 149, 0.22) !important;
    color: inherit !important;
}
#leadsTable .lead-pipeline-statut-compact__num,
.lead-detail-hero .lead-pipeline-statut-compact__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.3rem;
    padding: 0 0.28rem;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    border-radius: 0.28rem;
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
#leadsTable .lead-pipeline-statut-compact__label,
.lead-detail-hero .lead-pipeline-statut-compact__label {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.15;
    color: var(--bs-body-color, #212529);
}
/* En-tête fiche : légèrement plus lisible qu’en tableau */
.lead-detail-hero__statut .lead-pipeline-statut-compact__num {
    min-width: 1.45rem;
    height: 1.4rem;
    font-size: 0.75rem;
}
.lead-detail-hero__statut .lead-pipeline-statut-compact__label {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Fiche lead : séparateur entre bloc favori+pack et boutons message / WhatsApp / mail */
.lead-detail-hero-actions .lead-detail-hero-actions-sep {
    flex-shrink: 0;
    align-self: stretch;
    width: 1px;
    min-height: 1.35rem;
    margin: 0.15rem 0.45rem;
    background-color: var(--bs-border-color, #dee2e6);
    opacity: 0.7;
}

/* ---- Tâches : importantes (même fond que messages/leads importants) ---- */
#tachesTable > tbody > tr.tache-row-important > td {
    background-color: #ffe5e5 !important;
}
#tachesTable.table-hover > tbody > tr.tache-row-important:hover > td {
    background-color: #ffd6d6 !important;
}

/* ---- Tâches : bouton « message » quand un tag correspond à un modèle WhatsApp (priorité sur le thème Bootstrap) ---- */
button.tache-open-msg-btn.tache-wa-tpl-matched {
    background-color: #b02a37 !important;
    border: 1px solid #842029 !important;
    color: #fff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
button.tache-open-msg-btn.tache-wa-tpl-matched:hover {
    background-color: #9c2530 !important;
    border-color: #6f1d24 !important;
    color: #fff !important;
}

/* Bandeau : délégués en délégation / suppléance dans le filtre (liste + options si le navigateur les colore) */
#navMain select[name="delegate_filter"] option.csa-delegation-delegate-option {
    background-color: #b91c1c !important;
    color: #fff !important;
    font-weight: 700;
}

/* Flash messages : hors flux (pas de saut de mise en page quand le bandeau apparaît / disparaît) */
.csa-flash-toast-stack {
    position: fixed;
    z-index: 1065; /* au-dessus du contenu et de la navbar sticky ; sous l’alerte inactivité (9999) */
    top: max(4.75rem, calc(env(safe-area-inset-top, 0px) + 4.25rem));
    inset-inline-end: 0.75rem;
    max-width: min(22rem, calc(100vw - 1.25rem));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    pointer-events: none;
}
.csa-flash-toast-stack .csa-flash-toast {
    pointer-events: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Fiche lead — Historique : frise compacte (sans cartes), léger raffinement */
.lead-hist-timeline {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    margin-left: 0.15rem;
    padding-top: 0.15rem;
    padding-bottom: 0.25rem;
}

.lead-hist-stat-pill {
    flex-shrink: 0;
    z-index: 1;
}

.lead-hist-row .lead-hist-one-line {
    row-gap: 0.25rem;
}

.lead-hist-row .lead-hist-date {
    font-variant-numeric: tabular-nums;
    min-width: 9rem;
    font-size: 0.8125rem;
}

.lead-hist-row .badge {
    font-weight: 500;
    letter-spacing: 0.01em;
}

.csa-prop-fold-toggle .csa-prop-fold-chevron {
    transition: transform .15s ease;
}
.csa-prop-fold-toggle:not(.collapsed) .csa-prop-fold-chevron {
    transform: rotate(90deg);
}
.csa-prop-step {
    display: inline-block;
    border-radius: 999px;
    padding: 0.28rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    color: #fff !important;
    border: 2px solid transparent;
    opacity: 0.28 !important;
}
.csa-prop-step.is-current {
    opacity: 1 !important;
    font-size: 1rem;
    padding: 0.45rem 0.95rem;
    border-color: #111 !important;
    box-shadow: 0 0 0 3px #111 !important;
}
.csa-prop-step-mark {
    display: inline-block;
    margin-right: 0.3rem;
    font-size: 1.2rem;
    line-height: 1;
    vertical-align: -0.05em;
}
.csa-inscription-frame {
    position: relative;
    border: 4px solid #14532d !important;
    background: #f0fdf4 !important;
    box-shadow: 0 0 0 6px #22c55e !important;
    color: #052e16 !important;
}
details.csa-prop-step-resume {
    border: 2px solid #1e3a8a !important;
    border-radius: 8px;
    background: #fff !important;
    color: #0f172a !important;
}
details.csa-prop-step-resume > summary {
    cursor: pointer;
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    background: #dbeafe !important;
    color: #0f172a !important;
}
details.csa-prop-step-resume .csa-prop-step-resume-body {
    padding: 0.65rem 0.75rem 0.75rem;
    color: #0f172a !important;
    background: #fff !important;
}
.csa-inscription-stamp {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #14532d !important;
    color: #fff !important;
    font-weight: 800;
    letter-spacing: 0.06em;
    border: 3px solid #052e16 !important;
}
