:root {
    --sinal-blue: #0E74BC;
    --sinal-blue-dark: #0A5A93;
    --sinal-blue-darker: #073F68;
    --sinal-gold: #FEE700;
}

body {
    background-color: #f4f6f9;
}

/* --- Navbar --- */
.navbar.bg-dark {
    background: linear-gradient(90deg, var(--sinal-blue-darker), var(--sinal-blue)) !important;
    border-bottom: 3px solid var(--sinal-gold);
}

.navbar-brand img {
    height: 32px;
    background: #fff;
    border-radius: 4px;
    padding: 2px 6px;
}

/* --- Notifications --- */
.notif-dropdown {
    width: 340px;
    max-width: 90vw;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
    overflow: hidden;
}

.notif-list {
    max-height: 360px;
    overflow-y: auto;
}

.notif-item {
    color: #212529;
    border-bottom: 1px solid #f1f3f5;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item:hover {
    background-color: #e7f2fa;
}

/* --- Sidebar (offcanvas below lg, static column from lg up) --- */
.sidebar {
    --bs-offcanvas-width: 260px;
    background-color: #f8f9fa;
}

@media (min-width: 992px) {
    .sidebar {
        min-width: 240px;
        max-width: 240px;
        min-height: calc(100vh - 59px);
        border-right: 1px solid #dee2e6;
        background-color: #f8f9fa !important;
    }
}

.sidebar .nav-link {
    color: #333;
}

.sidebar .nav-link.active {
    background-color: var(--sinal-blue);
    color: #fff;
}

.sidebar .nav-link:hover:not(.active) {
    background-color: #e7f2fa;
    color: var(--sinal-blue-darker);
}

/* --- Buttons & links --- */
.btn-primary {
    background-color: var(--sinal-blue);
    border-color: var(--sinal-blue);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--sinal-blue-dark) !important;
    border-color: var(--sinal-blue-dark) !important;
}

.btn-outline-primary {
    color: var(--sinal-blue);
    border-color: var(--sinal-blue);
}

.btn-outline-primary:hover {
    background-color: var(--sinal-blue);
    border-color: var(--sinal-blue);
}

a {
    color: var(--sinal-blue);
}

a:hover {
    color: var(--sinal-blue-darker);
}

/* --- Badges --- */
.badge.bg-primary,
.badge.bg-info {
    background-color: var(--sinal-blue) !important;
    color: #fff !important;
}

.badge.bg-warning {
    background-color: var(--sinal-gold) !important;
    color: #4a3f00 !important;
}

/* --- Cards --- */
.card-stat {
    border: none;
    border-top: 3px solid var(--sinal-gold);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

/* --- Login --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--sinal-blue), var(--sinal-blue-darker));
}

.login-card {
    width: min(400px, calc(100vw - 2rem));
    border: none;
    border-top: 4px solid var(--sinal-gold);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.login-logo {
    display: block;
    margin: 0 auto 1rem;
    max-height: 70px;
}

/* --- Mobile polish --- */
@media (max-width: 767.98px) {
    .table-responsive table {
        font-size: .85rem;
    }
}

/* --- Pretty table (Suivi Lots/Fournisseurs & similar) --- */
.table-pretty-wrap {
    border-radius: 12px;
    overflow: hidden;
}

.table-pretty-scroll {
    max-height: 72vh;
    overflow-y: auto;
}

.table-pretty {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table-pretty thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, var(--sinal-blue), var(--sinal-blue-dark));
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    padding: .75rem .85rem;
    border-bottom: none;
}

.table-pretty thead th:first-child {
    border-top-left-radius: 12px;
}

.table-pretty thead th:last-child {
    border-top-right-radius: 12px;
}

.table-pretty tbody td {
    padding: .6rem .85rem;
    vertical-align: middle;
    border-bottom: 1px solid #eef1f5;
    background-color: #fff;
}

.table-pretty tbody tr:nth-of-type(even) td {
    background-color: #f7fafd;
}

.table-pretty tbody tr:hover td {
    background-color: #e7f2fa;
}

.table-pretty tbody tr:last-child td {
    border-bottom: none;
}

.table-pretty .lot-pill {
    display: inline-block;
    background-color: #eef1f5;
    color: var(--sinal-blue-darker);
    border: 1px solid #dbe6ee;
    border-radius: 999px;
    padding: .2rem .65rem;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.table-pretty .fournisseur-name {
    font-weight: 600;
    color: #212529;
}

.table-pretty .col-muted {
    color: #6c757d;
    font-size: .85rem;
}

.table-pretty .col-strong {
    font-weight: 600;
}

.table-pretty .marge-ok { color: #157347; }
.table-pretty .marge-warn { color: #a3720a; }
.table-pretty .marge-late { color: #c0392b; }

/* Colonne calculee "Date livraison contractuelle (contrat)" (case verte du tableau source) */
.table-pretty thead th.col-calculee {
    background: linear-gradient(180deg, #a9c47f, #94b268);
    color: #1f2d10;
}

.table-pretty tbody td.col-calculee,
.table-pretty tbody tr:nth-of-type(even) td.col-calculee {
    background-color: #f2f7e9;
}

.table-pretty tbody tr:hover td.col-calculee {
    background-color: #e6efd6;
}

.table-pretty .commentaire-cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-pretty .badge-statut {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .74rem;
    font-weight: 600;
    padding: .35rem .6rem;
    border-radius: 999px;
}

.table-empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #8a94a3;
}

.table-empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: .5rem;
    color: #c3cdd8;
}

/* =====================================================================
   Tableau de bord
   ===================================================================== */

/* --- Tuiles d'indicateurs cliquables --- */
.kpi-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    height: 100%;
    padding: 1rem 1.1rem;
    background: #fff;
    border-radius: 12px;
    border-left: 4px solid var(--sinal-blue);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    text-decoration: none;
    color: inherit;
    transition: transform .15s ease, box-shadow .15s ease;
}

.kpi-tile:hover,
.kpi-tile:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,.13);
    color: inherit;
}

.kpi-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 1.35rem;
}

.kpi-body {
    min-width: 0;
}

.kpi-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-label {
    font-weight: 600;
    font-size: .9rem;
    color: #212529;
}

.kpi-hint {
    font-size: .74rem;
    color: #8a94a3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-tile--info { border-left-color: var(--sinal-blue); }
.kpi-tile--info .kpi-icon { background: #e7f2fa; color: var(--sinal-blue); }
.kpi-tile--info .kpi-value { color: var(--sinal-blue-darker); }

.kpi-tile--late { border-left-color: #c0392b; }
.kpi-tile--late .kpi-icon { background: #fdecea; color: #c0392b; }
.kpi-tile--late .kpi-value { color: #c0392b; }

.kpi-tile--warn { border-left-color: #d99a06; }
.kpi-tile--warn .kpi-icon { background: #fff6e0; color: #a3720a; }
.kpi-tile--warn .kpi-value { color: #a3720a; }

.kpi-tile--ok { border-left-color: #157347; }
.kpi-tile--ok .kpi-icon { background: #e6f4ec; color: #157347; }
.kpi-tile--ok .kpi-value { color: #157347; }

/* --- Barre de repartition des statuts --- */
.statut-bar {
    display: flex;
    height: 26px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef1f5;
}

.statut-bar--fine {
    height: 10px;
}

.statut-bar__seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
    transition: filter .15s ease;
}

.statut-bar__seg--late { background: #c0392b; }
.statut-bar__seg--warn { background: #e0a800; color: #4a3f00; }
.statut-bar__seg--ok   { background: #157347; }
.statut-bar__seg--vide { background: #ccd4de; }

.statut-bar__seg:hover { filter: brightness(1.08); }

.legende {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: #6c757d;
}

.legende__puce {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.legende__puce--late { background: #c0392b; }
.legende__puce--warn { background: #e0a800; }
.legende__puce--ok   { background: #157347; }
.legende__puce--vide { background: #ccd4de; }

/* --- Listes compactes (prochaines echeances, relances) --- */
.mini-liste {
    display: flex;
    flex-direction: column;
}

.mini-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .25rem;
    border-bottom: 1px solid #eef1f5;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    transition: background-color .12s ease;
}

.mini-item:last-child {
    border-bottom: none;
}

.mini-item:hover {
    background-color: #e7f2fa;
    color: inherit;
}

.mini-item__date {
    flex: 0 0 auto;
    width: 46px;
    text-align: center;
    background: #eef1f5;
    border-radius: 10px;
    padding: .25rem 0;
    line-height: 1.1;
}

.mini-item__jour {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sinal-blue-darker);
}

.mini-item__mois {
    display: block;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6c757d;
}

.mini-item__corps {
    flex: 1 1 auto;
    min-width: 0;
}

.mini-item__titre {
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-item__sous {
    font-size: .75rem;
    color: #8a94a3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Avancement par lot --- */
.lot-ligne {
    display: block;
    padding: .5rem .25rem .7rem;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    transition: background-color .12s ease;
}

.lot-ligne:hover {
    background-color: #f4f8fc;
    color: inherit;
}

.lot-ligne__entete {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}

/* --- Completude de la chaine logistique --- */
.maillon {
    padding: .55rem 0;
    border-bottom: 1px solid #eef1f5;
}

.maillon:last-child {
    border-bottom: none;
}

.maillon__entete {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .3rem;
}

.maillon__libelle {
    font-size: .88rem;
    font-weight: 600;
}

.maillon__compte {
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}

.maillon__jauge {
    height: 6px;
    border-radius: 999px;
    background: #eef1f5;
    overflow: hidden;
}

.maillon__jauge-remplie {
    height: 100%;
    border-radius: 999px;
}

.maillon__jauge-remplie--ok   { background: #157347; }
.maillon__jauge-remplie--warn { background: #e0a800; }
.maillon__jauge-remplie--late { background: #c0392b; }

.maillon__note {
    font-size: .72rem;
    color: #8a94a3;
    margin-top: .25rem;
}

/* --- Tableau compact du tableau de bord --- */
.table-compacte thead th {
    position: static;
    border-radius: 0 !important;
}

.table-compacte tbody td {
    padding: .5rem .85rem;
}

.ligne-cliquable {
    cursor: pointer;
}

.badge-jamais {
    display: inline-block;
    background: #fdecea;
    color: #c0392b;
    border-radius: 999px;
    padding: .1rem .55rem;
    font-size: .72rem;
    font-weight: 600;
}

/* Tableau loge en bas d'une carte : coins arrondis coherents */
.table-carte {
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    overflow: hidden;
}

/* Liste des lots : hauteur bornee pour equilibrer les deux colonnes */
.lot-liste {
    max-height: 340px;
    overflow-y: auto;
    padding-right: .25rem;
}

/* =====================================================================
   Fiche d'une ligne de suivi
   ===================================================================== */

.min-w-0 { min-width: 0; }

.fiche-entete {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.fiche-retour {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .82rem;
    text-decoration: none;
    color: #6c757d;
    margin-bottom: .25rem;
}

.fiche-retour:hover {
    color: var(--sinal-blue);
}

.fiche-contexte {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

/* --- Sections numerotees --- */
.fiche-section {
    padding: 1.1rem 1.25rem 1.25rem;
    margin-bottom: 1rem;
}

.fiche-section:last-child {
    margin-bottom: 0;
}

.fiche-section__entete {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid #eef1f5;
}

.fiche-section__num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--sinal-blue);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}

.fiche-section__sous {
    font-size: .78rem;
    color: #8a94a3;
}

/* --- Champs calcules --- */
.chip-calcule {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    font-size: .64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #5c7a2f;
    background: #f2f7e9;
    border: 1px solid #dbe8c6;
    border-radius: 999px;
    padding: .05rem .4rem;
    vertical-align: middle;
}

.champ-calcule {
    background-color: #f8faf4;
    border-color: #dbe8c6;
}

.champ-calcule:focus {
    background-color: #fff;
    border-color: #a9c47f;
    box-shadow: 0 0 0 .2rem rgba(169, 196, 127, .3);
}

.champ-calcule[readonly] {
    color: #4a5560;
    font-weight: 600;
    cursor: default;
}

/* --- Colonne de synthese --- */
@media (min-width: 1200px) {
    .fiche-synthese {
        position: sticky;
        top: 1rem;
    }
}

.synthese-statut {
    text-align: center;
    padding-bottom: .75rem;
    border-bottom: 1px solid #eef1f5;
}

.synthese-statut .badge-statut {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .82rem;
    font-weight: 600;
    padding: .45rem .85rem;
    border-radius: 999px;
}

.synthese-marges {
    padding-top: .5rem;
}

.synthese-marge {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    padding: .3rem 0;
}

.synthese-marge__libelle {
    font-size: .8rem;
    color: #6c757d;
}

.synthese-marge__valeur {
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
}

/* --- Chaine previsionnelle --- */
.chaine {
    padding-left: .15rem;
}

.chaine__etape {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}

.chaine__puce {
    flex: 0 0 auto;
    width: 11px;
    height: 11px;
    margin-top: .3rem;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--sinal-blue);
}

.chaine__puce--saisi {
    background: var(--sinal-blue);
}

.chaine__puce--fin {
    background: #157347;
    border-color: #157347;
}

.chaine__corps {
    min-width: 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: .5rem;
    flex: 1 1 auto;
}

.chaine__libelle {
    font-size: .78rem;
    color: #6c757d;
}

.chaine__date {
    font-size: .82rem;
    font-weight: 600;
    white-space: nowrap;
}

.chaine__date--fin {
    color: #157347;
}

.chaine__lien {
    margin: .1rem 0 .1rem 5px;
    padding: .1rem 0 .1rem .95rem;
    border-left: 2px dashed #ccd4de;
    font-size: .7rem;
    color: #8a94a3;
}

.chaine-reference {
    margin-top: .9rem;
    padding-top: .75rem;
    border-top: 1px solid #eef1f5;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

/* Barre d'action fixe de la fiche (mobile et tablette) */
.fiche-barre {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    gap: .5rem;
    padding: .65rem .9rem;
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 16px rgba(0,0,0,.1);
}

.fiche-barre-spacer {
    height: 72px;
}
