/* =========================================================================
   SURELOVA — feuille de style principale (mobile-first)
   ========================================================================= */

:root {
    --vivest-rose: #E0004D;
    --vivest-rose-fonce: #B0003D;
    --al-navy: #003F7A;
    --al-navy-clair: #2E7DB8;

    --fond: #F5F6F8;
    --surface: #FFFFFF;
    --bordure: #E2E5EA;
    --texte: #1C2430;
    --texte-doux: #5A6472;
    --ok: #1E9E5A;
    --alerte: #C0392B;
    --attention: #E67E22;

    --rayon: 12px;
    --rayon-sm: 8px;
    --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
    --hauteur-nav: 64px;
    --largeur-sidebar: 232px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--al-navy); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* --- Structure ------------------------------------------------------- */

.app {
    min-height: 100vh;
    padding-bottom: calc(var(--hauteur-nav) + env(safe-area-inset-bottom));
}

.contenu {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

.entete {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--bordure);
}
.entete .logo { height: 26px; width: auto; }
.entete .titre-page { font-weight: 600; font-size: 1.05rem; }
.entete .spacer { flex: 1; }

.badge-role {
    font-size: .72rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    background: #EEF2F7;
    color: var(--texte-doux);
    text-decoration: none;
}

/* --- Navigation basse (mobile) -------------------------------------- */

.nav-basse {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 30;
    display: flex;
    height: calc(var(--hauteur-nav) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--bordure);
}
.nav-basse a {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    text-decoration: none;
    color: var(--texte-doux);
    font-size: .66rem;
}
.nav-basse a.actif { color: var(--vivest-rose); }
.nav-basse a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-basse svg { width: 22px; height: 22px; flex: none; }

/* --- Sidebar (desktop) --------------------------------------------- */

.nav-laterale { display: none; }

/* --- Cartes -------------------------------------------------------- */

.carte {
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    box-shadow: var(--ombre);
    padding: 1rem;
    margin-bottom: .85rem;
}
.carte h2:first-child, .carte h3:first-child { margin-top: 0; }
.carte-palier { border-color: #F0A202; background: #FFF8EE; text-align: center; }

.grille {
    display: grid;
    gap: .85rem;
    grid-template-columns: 1fr;
}
.grille.deux { grid-template-columns: 1fr 1fr; }
.grille.trois { grid-template-columns: repeat(3, 1fr); }

.stat {
    display: block;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    padding: .9rem 1rem;
    text-decoration: none;
    color: inherit;
}
.stat .valeur { font-size: 1.5rem; font-weight: 700; color: var(--al-navy); }
.stat .libelle { font-size: .8rem; color: var(--texte-doux); }
.stat.alerte .valeur { color: var(--alerte); }
.stat.attention .valeur { color: var(--attention); }

/* --- Jauge budget ------------------------------------------------- */

.jauge {
    height: 12px;
    border-radius: 999px;
    background: #EEF2F7;
    overflow: hidden;
    margin: .5rem 0 .35rem;
}
.jauge > span { display: block; height: 100%; background: var(--al-navy-clair); }
.jauge > span.depasse { background: var(--alerte); }

/* Jauge annuelle « Budget / Engagé » agrandie (page Budget) */
.jauge-grande { height: 20px; margin: .6rem 0 .5rem; }

/* Mini-graphe « engagé par mois » (page Budget) : double barre par mois,
   budget (repère) à côté de l'engagé (performance), même code couleur que
   la jauge simple (bleu = dans le budget, rouge = dépassé). */
.graph-mois {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
    height: 120px;
    padding-top: 1rem;
}
.mois-barre {
    flex: 1;
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
}
.mois-paire {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 100%;
}
.mois-tige { width: 8px; border-radius: 2px 2px 0 0; min-height: 2px; }
.mois-budget { background: var(--bordure); }
.mois-engage { background: var(--al-navy-clair); }
.mois-engage.depasse { background: var(--alerte); }
.mois-barre label {
    position: absolute;
    bottom: -1.3rem;
    font-size: .68rem;
    color: var(--texte-doux);
}
.mois-legende { display: inline-flex; align-items: center; gap: .3rem; margin-right: 1rem; }
.mois-puce { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* --- Listes / lignes -------------------------------------------- */

.liste-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--bordure);
    text-decoration: none;
    color: inherit;
}
.liste-item:last-child { border-bottom: 0; }
.liste-item .principal { flex: 1; min-width: 0; }
.liste-item .principal strong { display: block; }
.liste-item .principal small { color: var(--texte-doux); }
.liste-item .fin { text-align: right; white-space: nowrap; font-size: .85rem; }

/* Barre d'actions sous un bon de commande, regroupée par sujet (numéro/dates,
   bon, quitus, quitus supplémentaire, suppression) plutôt qu'une rangée
   plate de boutons — chaque groupe a son propre fond pour que les actions
   liées entre elles se repèrent d'un coup d'œil (piège rencontré le
   06/11/2026 : des icônes seules, identiques entre « voir le bon » et « voir
   le quitus », n'étaient distinguées que par un aria-label invisible). */
.actions-bc {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
}
.groupe-actions-bc {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    background: var(--fond);
    border-radius: var(--rayon-sm);
    padding: .2rem .3rem;
}
.titre-groupe-bc {
    font-size: .75rem;
    font-weight: 600;
    color: var(--texte-doux);
    margin-right: .05rem;
    white-space: nowrap;
}
.actions-bc .btn { padding: .3rem .55rem; font-size: .8rem; min-height: 34px; }

/* Notes libres de la fiche projet (onglet Notes) */
.note-item {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--bordure);
}
.note-item:last-child { border-bottom: 0; }
.note-item input[type="checkbox"] { width: 22px; height: 22px; margin: .1rem 0 0; flex: none; }
.note-item .note-case { font-size: 1.1rem; line-height: 1; margin-top: .1rem; flex: none; }
.note-item .note-corps { flex: 1; min-width: 0; }
.note-item .note-texte { margin: 0 0 .2rem; white-space: pre-wrap; overflow-wrap: break-word; }
.note-item.fait .note-texte { text-decoration: line-through; color: var(--texte-doux); }

/* Avatar utilisateur : photo si définie, sinon initiales sur fond coloré. */
.avatar-cercle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    color: #fff;
    font-weight: 700;
    flex: none;
}
.avatar-cercle.avatar-grand { width: 96px; height: 96px; font-size: 2rem; }
.avatar-cercle.avatar-petit { width: 36px; height: 36px; font-size: .85rem; }

/* Camembert de partage entre entreprises (page d'un lot) : dégradé conique
   CSS pur, aucune lib graphique. */
.camembert-bloc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}
.camembert {
    flex: none;
    width: 140px;
    height: 140px;
    border-radius: 50%;
}
.camembert-legende { width: 100%; }
.camembert-item.liste-item { gap: .6rem; }
.camembert-puce {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
@media (min-width: 560px) {
    .camembert-bloc { flex-direction: row; align-items: flex-start; }
}

.groupe-titre {
    margin: 1.25rem 0 .35rem;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--texte-doux);
}

/* En-tête d'un lot dans la fiche de travaux : badge coloré + entreprise nette */
.entete-lot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 1.5rem 0 .45rem;
}
.badge-lot {
    flex: none;
    display: inline-flex;
    align-items: center;
    padding: .22rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
}
.nom-entreprise { font-size: 1rem; font-weight: 700; letter-spacing: 0; }
.liste-item .nom-entreprise { display: block; }
.bloc-lot {
    border-left: 4px solid var(--bordure);
    padding-left: .5rem;
    margin-left: .1rem;
}

/* --- Pastilles de statut --------------------------------------- */

.pastille {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .12rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.pastille.pale { color: var(--texte); background: #EEF2F7; }

.puce { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.motif-relogement { color: var(--alerte); font-weight: 600; }
.motif-retard { color: var(--attention); font-weight: 600; }

/* --- Formulaires --------------------------------------------- */

.champ { margin-bottom: .9rem; }
.champ label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .3rem;
    color: var(--texte-doux);
}
.champ input, .champ select, .champ textarea {
    width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    font-size: 16px;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    background: var(--surface);
    color: var(--texte);
}
.champ textarea { min-height: 90px; resize: vertical; }
.champ input[type="checkbox"], .champ input[type="radio"] {
    width: auto; min-height: 0; margin-right: .4rem; transform: scale(1.2);
}
.champ input[type="color"] { padding: .2rem; height: 44px; }
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: 2px solid var(--al-navy-clair);
    outline-offset: 1px;
    border-color: var(--al-navy-clair);
}
.champ .aide { font-size: .78rem; color: var(--texte-doux); margin-top: .25rem; }

/* Quantité +/- : saisie à une main sur le terrain, sans repasser par le clavier
   pour les incréments/décréments d'une unité. */
.quantite-stepper { display: flex; align-items: stretch; gap: .4rem; }
.quantite-stepper input {
    flex: 1;
    text-align: center;
    min-width: 0;
}
.quantite-stepper button {
    flex: none;
    width: 44px;
    min-height: 44px;
    font-size: 1.3rem;
    line-height: 1;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    background: var(--surface);
    color: var(--al-navy);
    cursor: pointer;
}
.quantite-stepper button:active { background: var(--fond); }

.champs-deux { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }

/* Sélecteur de prestation BPU avec recherche (fiche de travaux) */
.bpu-select { position: relative; }
.bpu-select input[type="text"]:disabled { background: #F5F6F8; color: var(--texte-doux); }
.bpu-liste {
    position: absolute;
    z-index: 60;
    left: 0; right: 0; top: calc(100% + 4px);
    max-height: 280px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    box-shadow: var(--ombre);
}
.bpu-groupe {
    position: sticky;
    top: 0;
    padding: .4rem .7rem .3rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--texte-doux);
    background: #F5F6F8;
}
.bpu-item { padding: .6rem .7rem; font-size: .9rem; border-bottom: 1px solid var(--bordure); cursor: pointer; }
.bpu-item:last-child { border-bottom: 0; }
.bpu-item:hover, .bpu-item.actif { background: #EEF2F7; }
.bpu-item small { display: block; color: var(--texte-doux); font-size: .78rem; margin-top: .1rem; }
.bpu-vide { padding: .9rem .7rem; text-align: center; color: var(--texte-doux); font-size: .85rem; }

fieldset {
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    padding: .8rem;
    margin: 0 0 1rem;
}
fieldset legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }

/* Cases à cocher en grille (diagnostics / labels) */
.cases-grille { display: grid; grid-template-columns: 1fr; gap: .55rem; }
.case-ligne {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    font-size: .92rem;
    line-height: 1.35;
    cursor: pointer;
}
.case-ligne input[type="checkbox"] { width: 22px; height: 22px; margin-top: .05rem; flex: none; }
@media (min-width: 560px) {
    .cases-grille { grid-template-columns: 1fr 1fr; }
}
/* Case avec une date de passage associée (labels élec/nettoyage) : occupe
   toute la largeur pour ne pas écraser le champ date dans une colonne étroite. */
.case-avec-date { grid-column: 1 / -1; }

/* Récap des cases sur la fiche projet */
.cases-etat { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
.case-etat {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .55rem;
    border-radius: 999px;
    font-size: .82rem;
    border: 1px solid var(--bordure);
}
.case-etat.ok { color: var(--ok); border-color: currentColor; font-weight: 600; }
.case-etat.ko { color: var(--texte-doux); }
.case-etat.na { color: var(--texte-doux); font-style: italic; border-style: dashed; }

/* --- Boutons ------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--rayon-sm);
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    background: #EEF2F7;
    color: var(--texte);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .8rem;
    margin: 1rem 0;
}
.pagination a.desactive { opacity: .4; pointer-events: none; }
.btn-primaire { background: var(--vivest-rose); color: #fff; }
.btn-primaire:hover { background: var(--vivest-rose-fonce); }
.btn-marine { background: var(--al-navy); color: #fff; }
.btn-fantome { background: transparent; border-color: var(--bordure); }
.btn-danger { background: transparent; border-color: var(--alerte); color: var(--alerte); }
.btn-bloc { width: 100%; }
.btn-sm { min-height: 36px; padding: .3rem .7rem; font-size: .85rem; }

.barre-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: 1rem;
}
.barre-actions .spacer { flex: 1; }

/* --- Fenêtre modale (formulaires « Données de base ») ------------- */

.modale {
    padding: 0;
    border: 0;
    border-radius: var(--rayon);
    box-shadow: 0 12px 44px rgba(10, 20, 40, .3);
    background: var(--surface);
    color: var(--texte);
    width: min(560px, 100%);
    max-width: 100%;
    max-height: 92vh;
    overflow: hidden;
}
.modale::backdrop { background: rgba(10, 20, 40, .45); }

.modale-panneau { display: flex; flex-direction: column; max-height: 92vh; }

.modale-tete {
    flex: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--bordure);
}
.modale-tete h3 { margin: 0; flex: 1; font-size: 1.05rem; }
.modale-fermer {
    flex: none;
    width: 40px; height: 40px;
    border: 0;
    background: transparent;
    font-size: 1.7rem; line-height: 1;
    color: var(--texte-doux);
    cursor: pointer;
    border-radius: var(--rayon-sm);
}
.modale-fermer:hover { background: #EEF2F7; }

.modale-corps { padding: 1rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Plein écran sur mobile : plus lisible et pouce accessible. */
@media (max-width: 560px) {
    .modale {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }
    .modale-panneau { max-height: 100%; height: 100%; }
}

/* --- Photos ----------------------------------------------------- */

.photo-grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
    gap: .4rem;
}
.photo-vignette {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    border-radius: var(--rayon-sm);
    background: #EEF2F7 center / cover no-repeat;
    overflow: hidden;
}
.photo-vignette span {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: .18rem .35rem;
    font-size: .68rem;
    line-height: 1.2;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, .68));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-sources { display: grid; gap: .5rem; margin: .3rem 0 .8rem; }
.photo-sources label { cursor: pointer; }

.photo-apercus { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.photo-apercus .apercu {
    position: relative;
    width: 72px; height: 72px;
    border-radius: var(--rayon-sm);
    overflow: hidden;
    background: #EEF2F7;
}
.photo-apercus .apercu img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-apercus .apercu button {
    position: absolute;
    top: 2px; right: 2px;
    width: 20px; height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(28, 36, 48, .82);
    color: #fff;
    font-size: .9rem;
    line-height: 1;
    cursor: pointer;
}

/* Visionneuse plein écran : navigation précédente / suivante */
.photo-visionneuse { position: relative; }
.photo-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(28, 36, 48, .55);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-nav:hover:not(:disabled) { background: rgba(28, 36, 48, .78); }
.photo-nav:disabled { opacity: 0; pointer-events: none; }
.photo-nav-prec { left: .4rem; }
.photo-nav-suiv { right: .4rem; }

/* Lien discret (upload / remplacement de fichier) */
.lien-discret { color: var(--al-navy); cursor: pointer; text-decoration: underline; }

@media (min-width: 560px) {
    .photo-grille { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* --- Calendrier de la semaine (tableau de bord) ------------------- */

.semaine { display: flex; flex-direction: column; gap: .6rem; }
.jour-semaine {
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    padding: .6rem .7rem;
}
.jour-semaine.aujourdhui { border-color: var(--vivest-rose); background: #FFF7F9; }
.jour-semaine.passe { opacity: .6; }
.jour-entete {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: .3rem;
    font-size: .85rem;
}
.jour-vide { margin: 0; color: var(--texte-doux); font-size: .82rem; }
.jour-item {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .4rem 0;
    border-top: 1px solid var(--bordure);
}
.jour-item:first-of-type { border-top: 0; }
.jour-heure { flex: none; font-weight: 700; font-size: .82rem; color: var(--al-navy); min-width: 2.6rem; }
.jour-item-corps { flex: 1; min-width: 0; }
.jour-item-corps strong { display: block; font-size: .9rem; }
.jour-item-corps a { text-decoration: none; color: inherit; }
.jour-item-corps small { display: block; color: var(--texte-doux); }
.jour-item form { flex: none; }

@media (min-width: 900px) {
    .semaine { flex-direction: row; }
    .jour-semaine { flex: 1; min-width: 0; }
}

/* --- Avancement -------------------------------------------------- */
/* Ex-stepper de statut, fusionné dans la frise chronologique unique
   (.chrono ci-dessous) : plus qu'un seul indicateur d'avancement par projet. */

.alertes { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.alerte-chip {
    font-size: .78rem;
    font-weight: 600;
    padding: .22rem .6rem;
    border-radius: 999px;
    border: 1px solid currentColor;
}
.alerte-chip.rouge { color: var(--alerte); }
.alerte-chip.attention { color: var(--attention); }
.alerte-chip.neutre { color: var(--texte-doux); }

/* --- Chronologie (frise des dates) ---------------------- */

.chrono {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: .3rem;
}
.chrono::-webkit-scrollbar { display: none; }
.chrono-col { flex: 0 0 100px; text-align: center; }
.chrono-rail { position: relative; height: 18px; }
.chrono-rail::before {
    content: '';
    position: absolute;
    top: 8px; left: 0; width: 100%; height: 2px;
    background: #CBD2DB; /* un peu plus visible que --bordure : la ligne reste lisible sur les étapes à venir */
}
.chrono-col:last-child .chrono-rail::before { width: 50%; }
.chrono-col:first-child .chrono-rail::before { left: 50%; width: 50%; }
.chrono-dot {
    position: absolute;
    top: 3px; left: 50%;
    transform: translateX(-50%);
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid #CBD2DB;
}
.chrono-col.passe .chrono-rail::before { background: var(--al-navy); }
.chrono-col.passe .chrono-dot { background: var(--al-navy); border-color: var(--al-navy); }
.chrono-col.prevu .chrono-dot { border-color: var(--al-navy-clair); }
.chrono-col.alerte .chrono-dot { background: var(--alerte); border-color: var(--alerte); }
/* Étape courante du cycle de statut (fusion avec l'ancien stepper) */
.chrono-col.actif .chrono-rail::before { background: var(--vivest-rose); }
.chrono-col.actif .chrono-dot {
    width: 14px; height: 14px; top: 2px;
    background: var(--vivest-rose);
    border-color: var(--vivest-rose);
    box-shadow: 0 0 0 3px #FDE8EF;
}
.chrono-col.actif .chrono-txt strong { color: var(--vivest-rose); }
.chrono-txt { margin-top: .3rem; padding: 0 .2rem; }
/* Libellé forcé sur une seule ligne (tronqué avec … si trop long) : sa
   hauteur est alors identique dans toutes les colonnes, donc la date qui
   suit démarre toujours à la même hauteur — pas de décalage colonne à colonne. */
.chrono-txt strong {
    display: block;
    font-size: .72rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chrono-txt span {
    display: block;
    font-size: .72rem;
    color: var(--texte-doux);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chrono-col.attente .chrono-txt { opacity: .6; }
.chrono-col.attente .chrono-dot { background: var(--surface); }

/* --- Contacts ------------------------------------------- */

.etiq { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-doux); margin: 0 0 .2rem; }
.contact-bloc { padding: .6rem 0; border-bottom: 1px solid var(--bordure); }
.contact-bloc:last-child { border-bottom: 0; }
.contact-bloc p { margin: 0 0 .2rem; }

/* --- Onglets (barre horizontale défilable) ---------------- */

.onglets {
    display: flex;
    gap: .35rem;
    margin-bottom: .8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.onglets::-webkit-scrollbar { display: none; }
.onglets a {
    flex: none;
    padding: .45rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--bordure);
    background: var(--surface);
    color: var(--texte-doux);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}
.onglets a.actif {
    background: var(--al-navy);
    border-color: var(--al-navy);
    color: #fff;
}

/* Sous-onglets à l'intérieur d'une carte (ex. fiche de travaux : en attente
   / en cours / terminés) — même look que .onglets, en boutons plutôt que
   des liens (bascule en JS, pas de navigation). */
.sous-onglets {
    display: flex;
    gap: .35rem;
    margin-bottom: .8rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.sous-onglets::-webkit-scrollbar { display: none; }
.onglet-travaux {
    flex: none;
    padding: .4rem .75rem;
    border-radius: 999px;
    border: 1px solid var(--bordure);
    background: var(--surface);
    color: var(--texte-doux);
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    min-height: 36px;
    cursor: pointer;
}
.onglet-travaux.actif {
    background: var(--al-navy);
    border-color: var(--al-navy);
    color: #fff;
}
.onglet-travaux .compte-onglet { opacity: .75; }
.onglet-travaux.actif .compte-onglet { display: none; }

/* --- Filtres ---------------------------------------------- */

.filtres {
    display: grid;
    grid-template-columns: 1fr;
    gap: .6rem;
    margin-bottom: 1rem;
}
.filtres input, .filtres select { min-height: 44px; }

/* --- Tableaux (desktop) --------------------------------- */

.tableau-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tableau th, table.tableau td {
    text-align: left;
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--bordure);
    white-space: nowrap;
}
table.tableau th { color: var(--texte-doux); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
table.tableau tr:hover td { background: #FAFBFC; }
table.tableau td.num, table.tableau th.num { text-align: right; }

/* --- Fiche de travaux : tableau prestations ------------------------ */

table.tableau-travaux td { white-space: normal; vertical-align: top; }
table.tableau-travaux td small { color: var(--texte-doux); }
table.tableau-travaux tfoot th,
table.tableau-travaux tfoot td {
    border-top: 2px solid var(--bordure);
    border-bottom: 0;
    background: #FAFBFC;
    white-space: nowrap;
}
table.tableau-travaux tfoot .ligne-bc td { border-top: 0; padding-top: .2rem; }

/* Saisie du n° de bon de commande sous chaque sous-total de lot */
.form-bc {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    white-space: normal;
}
.form-bc label { margin: 0; font-size: .8rem; font-weight: 600; color: var(--texte-doux); }
.form-bc input {
    flex: 1 1 11rem;
    min-height: 38px;
    padding: .4rem .6rem;
    border: 1px solid var(--bordure);
    border-radius: var(--rayon-sm);
    background: var(--surface);
    font-size: 15px;
}
.form-bc button { flex: none; }

.total-fiche {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-top: .8rem;
    padding-top: .7rem;
    border-top: 2px solid var(--al-navy);
    font-size: 1.02rem;
}

/* Sur mobile, le tableau prestations bascule en blocs empilés. */
@media (max-width: 640px) {
    table.tableau-travaux,
    table.tableau-travaux tbody,
    table.tableau-travaux tr,
    table.tableau-travaux td {
        display: block;
        width: 100%;
    }
    table.tableau-travaux thead { position: absolute; left: -9999px; }
    table.tableau-travaux tr {
        border: 1px solid var(--bordure);
        border-radius: var(--rayon-sm);
        margin-bottom: .6rem;
        padding: .25rem 0;
    }
    table.tableau-travaux td {
        border: 0;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: .3rem .7rem;
        text-align: right;
    }
    table.tableau-travaux td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--texte-doux);
        text-align: left;
    }
    table.tableau-travaux td[data-label="Nature"] { flex-direction: column; text-align: left; }
    table.tableau-travaux td[data-label="Nature"]::before { content: none; }
    table.tableau-travaux td:not([data-label]) { justify-content: flex-end; }
    table.tableau-travaux tfoot { display: block; }
    table.tableau-travaux tfoot tr { border: 0; background: transparent; }
    table.tableau-travaux tfoot th,
    table.tableau-travaux tfoot td {
        display: block;
        text-align: left;
        white-space: normal;
        border: 0;
        background: transparent;
        padding: .15rem .7rem;
    }
    table.tableau-travaux tfoot th { padding-top: .5rem; border-top: 2px solid var(--bordure); }
}

/* --- Messages flash ----------------------------------- */

.flash-zone { margin-bottom: 1rem; }
.flash {
    padding: .7rem .9rem;
    border-radius: var(--rayon-sm);
    margin-bottom: .5rem;
    font-size: .92rem;
    border: 1px solid;
}
.flash.succes { background: #E9F7EF; border-color: #B7E4C7; color: #14713D; }
.flash.erreur { background: #FDECEA; border-color: #F5C6C0; color: #A32B1C; }
.flash.info { background: #EAF2FB; border-color: #C5DCF2; color: #1B4F8A; }

/* 🎉 Confettis (clôture d'un projet) — CSS pur, pas de lib */
.confettis-zone { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti {
    position: absolute;
    top: -12px;
    width: 8px;
    height: 14px;
    opacity: .9;
    animation: confetti-chute linear forwards;
}
@keyframes confetti-chute {
    to { transform: translateY(105vh) rotate(540deg); opacity: .4; }
}

/* --- Connexion --------------------------------------- */

.page-connexion {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(160deg, #fff, var(--fond));
}
.page-connexion .boite {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--bordure);
    border-radius: var(--rayon);
    box-shadow: var(--ombre);
    padding: 1.5rem;
    text-align: center;
}
.page-connexion .logo { height: 44px; margin-bottom: 1rem; }
.page-connexion form { text-align: left; margin-top: 1rem; }

.vide {
    text-align: center;
    color: var(--texte-doux);
    padding: 2rem 1rem;
}
.vide svg { width: 40px; height: 40px; opacity: .4; margin-bottom: .5rem; }

.entrefilet { color: var(--texte-doux); font-size: .85rem; }
.tag-hm { font-size: .7rem; color: var(--attention); border: 1px solid currentColor; border-radius: 4px; padding: 0 .3rem; }

/* =========================================================================
   Desktop
   ========================================================================= */

@media (min-width: 900px) {
    .app {
        padding-bottom: 0;
        padding-left: var(--largeur-sidebar);
    }
    .nav-basse { display: none; }

    .nav-laterale {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0; bottom: 0; left: 0;
        width: var(--largeur-sidebar);
        background: var(--surface);
        border-right: 1px solid var(--bordure);
        padding: 1rem .75rem;
        z-index: 40;
    }
    .nav-laterale .marque {
        display: flex; align-items: center; gap: .5rem;
        padding: .25rem .5rem 1rem;
    }
    .nav-laterale .marque img { height: 30px; }
    .nav-laterale a {
        display: flex; align-items: center; gap: .7rem;
        padding: .6rem .65rem;
        border-radius: var(--rayon-sm);
        text-decoration: none;
        color: var(--texte-doux);
        font-weight: 600;
        font-size: .92rem;
    }
    .nav-laterale a svg { width: 20px; height: 20px; }
    .nav-laterale a:hover { background: var(--fond); color: var(--texte); }
    .nav-laterale a.actif { background: #FDE8EF; color: var(--vivest-rose); }
    .nav-laterale .bas { margin-top: auto; }

    .contenu { padding: 1.5rem 2rem; max-width: 1100px; }
    .entete { position: static; background: transparent; border-bottom: 0; padding: 1.5rem 2rem 0; }
    .entete .logo { display: none; }

    .grille.deux { grid-template-columns: 1fr 1fr; }
    .grille.trois { grid-template-columns: repeat(3, 1fr); }
    .filtres { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; }
}

@media (max-width: 560px) {
    .champs-deux { grid-template-columns: 1fr; }
    .grille.deux { grid-template-columns: 1fr; }
    .grille.trois { gap: .5rem; }
    .grille.trois .stat { padding: .6rem .5rem; }
    .grille.trois .stat .valeur { font-size: 1.25rem; }
    .grille.trois .stat .libelle { font-size: .7rem; }
}
