:root {
    --brand: #0f3d5e;
    --brand-2: #1b6a9c;
    --accent: #f2a900;
    --orange: #fd7e14;
    --bottom-nav-h: 62px;
}

body { background: #f4f6f9; -webkit-tap-highlight-color: transparent; }
.bg-brand { background: var(--brand) !important; }
.text-brand { color: var(--brand) !important; }
.btn-brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.bg-guest { background: linear-gradient(160deg, var(--brand), var(--brand-2)); }
.brand-mark { display: inline-flex; width: 56px; height: 56px; border-radius: 16px; align-items: center; justify-content: center; background: var(--brand); color: #fff; font-size: 1.6rem; }
.text-bg-orange { background: var(--orange) !important; color: #fff !important; }

/* Barre de navigation basse (mobile) */
@media (max-width: 767.98px) {
    body.has-bottom-nav { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
}
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid #dee2e6; display: flex;
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6c757d; text-decoration: none; font-size: .72rem; }
.bottom-nav a i { font-size: 1.35rem; line-height: 1.1; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }

/* Cartes */
.card { border: 0; box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08); }
.card-header { background: #fff; font-weight: 600; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; font-weight: 600; }

/* Onglets statut (scroll horizontal) */
.statut-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; scrollbar-width: thin; }
.statut-tabs .btn { white-space: nowrap; flex: 0 0 auto; }

/* Groupes de la liste */
.groupe-entete { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .8rem; border-radius: .5rem; background: #e9eef4; margin: 1.2rem 0 .5rem; flex-wrap: wrap; }
.groupe-entete.retard { background: #fde2e1; color: #842029; }
.groupe-entete .titre { font-weight: 600; }

.tache-card { display: block; color: inherit; text-decoration: none; border-left: 4px solid transparent; transition: transform .08s ease; }
.tache-card:active { transform: scale(.995); }
.tache-card.urgence-danger { border-left-color: var(--bs-danger); }
.tache-card.urgence-orange { border-left-color: var(--orange); }
.tache-card.urgence-warning { border-left-color: var(--bs-warning); }
.tache-card.urgence-success { border-left-color: var(--bs-success); }
.tache-card .numero { font-size: .75rem; color: #6c757d; }
.statut-badge { font-weight: 500; }

/* Stepper */
.stepper { display: flex; gap: 0; overflow-x: auto; padding: .25rem 0 .5rem; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper .step { flex: 1 0 auto; min-width: 86px; text-align: center; position: relative; font-size: .72rem; color: #adb5bd; }
.stepper .step .pastille { width: 30px; height: 30px; margin: 0 auto .25rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #e9ecef; color: #adb5bd; position: relative; z-index: 1; }
.stepper .step::before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 3px; background: #e9ecef; }
.stepper .step:first-child::before { display: none; }
.stepper .step.fait { color: #198754; }
.stepper .step.fait .pastille { background: #198754; color: #fff; }
.stepper .step.fait::before, .stepper .step.courant::before { background: #198754; }
.stepper .step.courant { color: var(--brand); font-weight: 600; }
.stepper .step.courant .pastille { background: var(--accent); color: #212529; box-shadow: 0 0 0 4px rgba(242, 169, 0, .25); }

/* Photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.photo-grid .photo { position: relative; aspect-ratio: 1; border-radius: .5rem; overflow: hidden; background: #e9ecef; }
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .photo .suppr { position: absolute; top: 4px; right: 4px; padding: 0 .35rem; line-height: 1.4; }
.photo-grid .photo.envoi { display: flex; align-items: center; justify-content: center; }
.btn-photo { border: 2px dashed #adb5bd; aspect-ratio: 1; border-radius: .5rem; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6c757d; background: #fff; cursor: pointer; font-size: .8rem; }
.btn-photo i { font-size: 1.6rem; }

/* Lignes de travaux */
.ligne-row { border: 1px solid #e9ecef; border-radius: .5rem; padding: .6rem; margin-bottom: .5rem; background: #fff; }
.ligne-row .form-control, .ligne-row .form-select { font-size: .92rem; }
.totaux { font-variant-numeric: tabular-nums; }

/* Chrono */
.chrono { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* Accordéon fiche tâche */
.accordion-button { font-weight: 600; }
.accordion-button:not(.collapsed) { background: #eef3f8; color: var(--brand); }
.accordion-item { border: 0; margin-bottom: .6rem; border-radius: .5rem !important; overflow: hidden; box-shadow: 0 1px 3px rgba(16, 24, 40, .08); }

.historique .item { border-left: 2px solid #dee2e6; padding: 0 0 .8rem .8rem; position: relative; }
.historique .item::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #adb5bd; }

.checklist .form-check-input { width: 1.3em; height: 1.3em; }
.checklist .fait label { text-decoration: line-through; color: #6c757d; }

.sticky-actions { position: sticky; bottom: calc(var(--bottom-nav-h) + .5rem); z-index: 5; }
@media (min-width: 768px) { .sticky-actions { bottom: 1rem; } }

[x-cloak] { display: none !important; }

/* Signature tactile (bon d'intervention) */
.signature-pad { position: relative; border: 2px dashed #adb5bd; border-radius: .5rem; background: #fff; }
.signature-pad canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.signature-pad .ligne-base { position: absolute; left: 8%; right: 8%; bottom: 48px; border-bottom: 1px solid #dee2e6; pointer-events: none; }
.signature-pad .invite { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #adb5bd; font-size: .85rem; pointer-events: none; }
@media (min-width: 768px) { .signature-pad canvas { height: 260px; } }
.text-pre-line { white-space: pre-line; }

/* Schémas additionnels */
.photo-grid .photo .completer { position: absolute; top: 4px; left: 4px; padding: 0 .35rem; line-height: 1.4; }
.schema-vignette { background: #fff !important; border: 1px solid #dee2e6; }
.schema-vignette img { object-fit: contain !important; }
.schema-vignette .legende { position: absolute; left: 0; right: 0; bottom: 0; padding: .1rem .3rem; font-size: .7rem; line-height: 1.2; background: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schema-zone { display: flex; justify-content: center; align-items: flex-start; min-height: 220px; background: #f1f3f5; border-radius: .5rem; padding: .5rem; }
.schema-papier { position: relative; box-shadow: 0 1px 4px rgba(0,0,0,.18); background: #fff; }
.schema-papier canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.schema-dessin { touch-action: none; cursor: crosshair; }
.schema-dessin.outil-texte { cursor: text; }
.schema-dessin.outil-gomme { cursor: cell; }
.schema-couleur { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #adb5bd; padding: 0; }
.schema-couleur.active { box-shadow: 0 0 0 2px #0b1f3a; transform: scale(1.1); }
.schema-epaisseur { display: inline-block; width: 18px; background: currentColor; border-radius: 2px; vertical-align: middle; }
.schema-editeur .modal-body { overscroll-behavior: contain; }

/* v3.0.1 — sélection multiple (admin) */
.selection-barre { position: sticky; top: 3.6rem; z-index: 1010; box-shadow: 0 .25rem .75rem rgba(0,0,0,.06); }
.sel-case { width: 1.35rem; height: 1.35rem; margin-top: .15rem; position: relative; z-index: 3; cursor: pointer; }
@media (max-width: 767.98px) { .selection-barre { top: 3.4rem; } }
.tache-card .sel-case { margin-right: .5rem; }
.min-w-0 { min-width: 0; } /* utilisée par les listes (troncature des textes longs) */

/* v3.1 — couleur de nature : Urgence (rouge) / Tâche (bleu) ; la couleur de société viendra en v3.2 (pastille) */
.tache-card { border-top: 3px solid var(--nature, transparent); }
.badge.nature-urgence { background: var(--couleur-urgence, #dc3545); color: #fff; }
.badge.nature-tache { background: var(--couleur-tache, #0d6efd); color: #fff; }
.navbar .nav-urgence { color: #ffb3b8 !important; font-weight: 600; }
.navbar .nav-urgence.active, .navbar .nav-urgence:hover { color: #fff !important; background: rgba(220, 53, 69, .55); border-radius: .375rem; }
.bottom-nav a.bottom-urgence { color: #dc3545; }
.bottom-nav a.bottom-urgence.active { color: #b02a37; }
.bottom-nav a.bottom-urgence .badge { font-size: .62rem; vertical-align: top; }
.stepper-urgence .step.courant .pastille { background: #dc3545; border-color: #dc3545; }
.stepper .step.sous-etape { font-size: .68rem; opacity: .9; }
.stepper .step.sous-etape .pastille { font-size: .8rem; }

/* v3.2 — pastille de la société (initiales) : distincte du bandeau / bord de nature (Urgence rouge, Tâche bleu) */
.pastille-societe { display: inline-flex; align-items: center; justify-content: center; min-width: 1.9em; height: 1.35em; padding: 0 .3em;
    border-radius: 999px; color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .02em; line-height: 1; vertical-align: middle; flex: 0 0 auto; }
.paiement-etat { font-size: .72rem; }

/* v3.4 — tableau de bord : lignes compactes avec bord de nature (Urgence rouge / Tâche bleu), blocs défilants */
.tdb-ligne { border-left: 4px solid var(--couleur-tache, #0d6efd); }
.tdb-ligne.nature-urgence { border-left-color: var(--couleur-urgence, #dc3545); }
.tdb-defile { max-height: 26rem; overflow-y: auto; }
