/* =====================================================================
   Gestion des techniciens — feuille de style
   Meme construction que celle du CRM Batiment, mais avec sa propre
   identite — anthracite et bleu eau — pour qu'on ne confonde pas les
   deux applications. Concue pour le telephone d'abord : un manager
   remplit l'agenda depuis un chantier, souvent d'une seule main.
   ===================================================================== */

/* ---- Jetons de couleur --------------------------------------------- */
:root {
    /* Anthracite — la couleur d'une membrane d'etancheite : en-tete,
       menus actifs, boutons principaux. */
    --brand-900: #101418;
    --brand-800: #171c22;
    --brand-700: #222a32;
    --brand-600: #3a4653;

    /* Bleu eau : les actions, le jour d'aujourd'hui, les liens.
       --accent-text est la nuance qui reste lisible en texte. */
    --accent:      #0284c7;
    --accent-dark: #0369a1;
    --accent-soft: #e0f2fe;
    --accent-text: #0369a1;

    --bg:          #f3f4f6;
    --surface:     #ffffff;
    --surface-2:   #f9fafb;
    --border:      #e5e7eb;
    --border-2:    #d1d5db;

    --text:        #111827;
    --text-muted:  #6b7280;
    --text-faint:  #9ca3af;

    --green:  #16a34a;  --green-soft:  #dcfce7;
    --red:    #dc2626;  --red-soft:    #fee2e2;
    --amber:  #d97706;  --amber-soft:  #fef3c7;
    --blue:   #2563eb;  --blue-soft:   #dbeafe;
    --violet: #7c3aed;  --violet-soft: #ede9fe;

    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 2px rgba(16, 20, 24, .06);
    --shadow:    0 2px 8px rgba(16, 20, 24, .08);
    --shadow-lg: 0 12px 32px rgba(16, 20, 24, .16);

    --header-h: 58px;
    --nav-h:    62px;

    /* Zones sures de l'iPhone : encoche / Dynamic Island en haut, barre
       d'accueil en bas. Nulles ailleurs. Indispensables sur l'ecran
       d'accueil, ou la page passe SOUS la barre d'etat
       (apple-mobile-web-app-status-bar-style = black-translucent). */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --sidebar-w: 236px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---- Base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p  { margin: 0 0 .75rem; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent); }

img { max-width: 100%; }

/* L'attribut hidden ne pose qu'un display:none, que la moindre règle
   explicite annule. Cette ligne lui redonne le dernier mot. */
[hidden] { display: none !important; }

/* ---- Icônes --------------------------------------------------------
   Les SVG sont écrits sans width/height : sans cette règle ils
   s'afficheraient à leur taille par défaut de 300x150 px. La taille
   suit celle du texte environnant ; les contextes ci-dessous ajustent. */
.ico {
    width: 1.15em; height: 1.15em;
    flex: 0 0 auto;
    vertical-align: -.15em;
}

.header__action .ico      { width: 20px; height: 20px; }
.page-head .ico           { width: 18px; height: 18px; }
.card__head > .ico        { width: 17px; height: 17px; color: var(--text-muted); }
.badge .ico               { width: 12px; height: 12px; }
.filters .ico             { width: 14px; height: 14px; }

/* Cible tactile confortable, gants compris */
button, input, select, textarea { font: inherit; color: inherit; }

/* =====================================================================
   Structure
   ===================================================================== */

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---- En-tete ------------------------------------------------------- */
.header {
    position: sticky; top: 0; z-index: 50;
    height: calc(var(--header-h) + var(--safe-top));
    display: flex; align-items: center; gap: .6rem;
    padding: var(--safe-top) .85rem 0;
    background: var(--brand-700);
    color: #fff;
    box-shadow: var(--shadow);
}

.header__brand {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 700; letter-spacing: -.01em; color: #fff;
    white-space: nowrap;
}
.header__brand img { width: 26px; height: 26px; border-radius: 6px; }
.header__brand span { display: none; }

.header__spacer { flex: 1; }

.header__action {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 0; border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #fff; cursor: pointer;
    transition: background .15s;
}
.header__action:hover { background: rgba(255, 255, 255, .22); }

.badge-dot {
    position: absolute; top: 5px; right: 5px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px;
    background: var(--accent);
    color: #fff; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ---- Corps --------------------------------------------------------- */
.body { flex: 1; display: flex; min-height: 0; }

.sidebar { display: none; }

.main {
    flex: 1; min-width: 0;
    padding: 1rem .85rem calc(var(--nav-h) + var(--safe-bottom) + 1.4rem);
}

/* ---- Navigation basse (mobile) ------------------------------------- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    height: calc(var(--nav-h) + var(--safe-bottom));
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
/* Entree « Plus » : ouvre les pages absentes de la barre du bas
   (Depenses, Corps de metier, Techniciens, Export...), inaccessibles
   sur telephone puisque la barre laterale y est masquee. */
.tabbar__more { flex: 1; display: flex; min-width: 0; }
.tabbar__more > summary {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    font-size: .68rem; font-weight: 600;
    color: var(--text-faint);
    cursor: pointer;
    list-style: none;
}
.tabbar__more > summary::-webkit-details-marker { display: none; }
.tabbar__more > summary .ico { width: 21px; height: 21px; stroke: var(--text-faint); }
.tabbar__more[open] > summary,
.tabbar__more[open] > summary .ico { color: var(--accent-text); stroke: var(--accent-text); }

.more-sheet {
    position: fixed; left: 0; right: 0;
    bottom: calc(var(--nav-h) + var(--safe-bottom));
    z-index: 59;
    display: flex; flex-direction: column;
    max-height: 62vh; overflow-y: auto;
    padding: .5rem .5rem .7rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 28px rgba(16, 20, 24, .18);
}
.more-sheet__label {
    padding: .55rem .7rem .3rem;
    font-size: .66rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-faint);
}
.more-sheet a {
    display: flex; align-items: center; gap: .65rem;
    min-height: 46px;
    padding: 0 .7rem;
    border-radius: var(--radius-sm);
    font-size: .92rem; font-weight: 600;
    color: var(--text);
}
.more-sheet a.is-active { background: var(--brand-700); color: #fff; }
.more-sheet a.is-active .ico { stroke: #fff; }
.more-sheet a .ico { width: 18px; height: 18px; stroke: var(--text-faint); }
.more-sheet__count {
    margin-left: auto;
    min-width: 20px; padding: 0 .35rem;
    border-radius: 999px;
    background: var(--accent); color: #fff;
    font-size: .7rem; line-height: 20px; text-align: center;
}

/* Six entrees sur un ecran de 375 px : chaque libelle doit pouvoir
   retrecir plutot que de pousser la barre hors de l'ecran. */
.tabbar__label {
    max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    /* « Interventions » et « Commissions » doivent tenir en entier dans
       leur cinquieme d'ecran : un corps un peu plus petit, resserre. */
    font-size: .62rem; letter-spacing: -.01em;
}
/* L'administrateur a une case de plus : sur les telephones les plus
   etroits, « Interventions » a besoin d'un demi-point de moins. */
.tabbar--six .tabbar__label { font-size: .58rem; }

.tabbar a {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    font-size: .68rem; font-weight: 600;
    color: var(--text-faint);
}
.tabbar a.is-active { color: var(--accent-text); }
.tabbar a.is-active .ico { stroke: var(--accent-text); }
.tabbar .ico { width: 21px; height: 21px; stroke: var(--text-faint); }

/* =====================================================================
   Composants
   ===================================================================== */

/* ---- Cartes -------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: .85rem;
    overflow: hidden;
}
.card__head {
    display: flex; align-items: center; gap: .6rem;
    padding: .8rem .9rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card__head h2, .card__head h3 { flex: 1; min-width: 0; }
.card__body { padding: .9rem; }
.card__body--flush { padding: 0; }

/* ---- Titre de page ------------------------------------------------- */
.page-head {
    display: flex; align-items: flex-start; gap: .7rem;
    margin-bottom: .9rem;
}
.page-head__text { flex: 1; min-width: 0; }
.page-head p { margin: .15rem 0 0; color: var(--text-muted); font-size: .85rem; }

/* ---- Statistiques -------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .6rem;
    margin-bottom: .9rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem .8rem;
    box-shadow: var(--shadow-sm);
}
.stat__label {
    font-size: .7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-faint);
    display: block; margin-bottom: .3rem;
}
.stat__value { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; }
.stat__hint  { font-size: .74rem; color: var(--text-muted); margin-top: .15rem; }

.stat--accent { border-left: 3px solid var(--accent); }
.stat--green  { border-left: 3px solid var(--green); }
.stat--blue   { border-left: 3px solid var(--blue); }
.stat--red    { border-left: 3px solid var(--red); }

.stat__value--green { color: var(--green); }
.stat__value--red   { color: var(--red); }

/* ---- Pastilles ----------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .18rem .5rem;
    border-radius: 999px;
    font-size: .72rem; font-weight: 650; line-height: 1.4;
    white-space: nowrap;
}
.badge--soft { background: var(--surface-2); color: var(--text-muted); }
.badge--green  { background: var(--green-soft);  color: #15803d; }
.badge--red    { background: var(--red-soft);    color: #b91c1c; }
.badge--amber  { background: var(--amber-soft);  color: #b45309; }
.badge--blue   { background: var(--blue-soft);   color: #1d4ed8; }
.badge--violet { background: var(--violet-soft); color: #6d28d9; }

.badge__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---- Boutons ------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 42px;
    padding: .5rem .95rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 650;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
    text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }

.btn--primary { background: var(--brand-700); color: #fff; }
.btn--primary:hover { background: var(--brand-800); color: #fff; }

.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-dark); color: #fff; }

.btn--ghost { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }

.btn--danger { background: var(--red-soft); color: #b91c1c; }
.btn--danger:hover { background: #fecaca; color: #991b1b; }

.btn--sm { min-height: 34px; padding: .3rem .65rem; font-size: .8rem; }
.btn--block { width: 100%; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---- Formulaires --------------------------------------------------- */
.field { margin-bottom: .85rem; }
.field > label {
    display: block;
    margin-bottom: .3rem;
    font-size: .8rem; font-weight: 650; color: var(--text-muted);
}
.field__hint { font-size: .75rem; color: var(--text-faint); margin-top: .25rem; }
.field__error { font-size: .78rem; color: var(--red); margin-top: .25rem; font-weight: 600; }

/* Sur iPhone, les champs date/heure imposent leur largeur native et
   debordent de leur conteneur : on neutralise l'habillage systeme et on
   autorise le retrecissement. */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    max-width: 100%;
}
/* Un enfant de grille ne retrecit pas sous sa taille intrinseque
   sans cette regle : c'est ce qui faisait deborder la ligne. */
.field, .field-row > * { min-width: 0; }

.input, .select, .textarea {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: .55rem .7rem;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 16px;              /* 16px : evite le zoom automatique sur iPhone */
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: 0;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, .2);
}
.input--error { border-color: var(--red); }
.textarea { min-height: 86px; resize: vertical; line-height: 1.5; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .7rem center;
    padding-right: 2rem;
}

.field-row { display: grid; gap: .65rem; grid-template-columns: 1fr; }

/* Groupe de boutons radio en pastilles : saisie rapide au pouce */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips input { position: absolute; opacity: 0; width: 0; height: 0; }
.chips label {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem .8rem;
    border: 1.5px solid var(--border-2);
    border-radius: 999px;
    font-size: .84rem; font-weight: 600;
    background: var(--surface);
    cursor: pointer;
    transition: all .12s;
    user-select: none;
}
.chips input:checked + label {
    border-color: var(--chip-color, var(--brand-700));
    background: var(--chip-color, var(--brand-700));
    color: #fff;
}
.chips input:focus-visible + label { box-shadow: 0 0 0 3px rgba(2, 132, 199, .3); }

/* ---- Listes ------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }

/* ---- Tableaux (desktop) -------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th {
    position: sticky; top: 0;
    padding: .6rem .7rem;
    text-align: left; font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

/* Tableaux sur telephone : de la place perdue en marges rendait le
   contenu a l'etroit et poussait les colonnes hors de la carte. */
@media (max-width: 640px) {
    .table { font-size: .8rem; }
    .table th, .table td { padding: .45rem .4rem; }
    .table th { font-size: .64rem; letter-spacing: .02em; }
    /* La premiere colonne peut revenir a la ligne — entre les mots, pas
       entre les lettres. Elle garde une largeur minimale : un tableau
       trop large pour l'ecran defile de cote au lieu de l'ecraser. */
    .table td:first-child, .table th:first-child {
        min-width: 9rem;
        white-space: normal; word-break: normal; overflow-wrap: anywhere;
    }
    .table td.num, .table th.num { white-space: nowrap; }
}

/* Ligne de total : la somme doit se verifier d'un coup d'oeil */
.table tfoot th {
    border-top: 2px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: .85rem;
}
.table td {
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }

/* ---- Messages ------------------------------------------------------ */
.alert {
    display: flex; gap: .55rem; align-items: flex-start;
    padding: .7rem .85rem;
    border-radius: var(--radius-sm);
    font-size: .87rem;
    margin-bottom: .8rem;
    border: 1px solid transparent;
}
.alert--success { background: var(--green-soft); color: #14532d; border-color: #bbf7d0; }
.alert--error   { background: var(--red-soft);   color: #7f1d1d; border-color: #fecaca; }
.alert--warning { background: var(--amber-soft); color: #78350f; border-color: #fde68a; }
.alert--info    { background: var(--blue-soft);  color: #1e3a8a; border-color: #bfdbfe; }
.alert .ico { width: 18px; height: 18px; margin-top: 1px; }

.empty {
    padding: 2.2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.empty .ico { width: 38px; height: 38px; stroke: var(--border-2); margin-bottom: .6rem; }
.empty p { margin: 0 0 .2rem; font-weight: 600; color: var(--text); }
.empty span { font-size: .85rem; }

/* ---- Barre de filtres ---------------------------------------------- */
.filters {
    display: flex; gap: .45rem;
    overflow-x: auto;
    padding-bottom: .3rem;
    margin-bottom: .8rem;
    scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filters a {
    flex-shrink: 0;
    padding: .4rem .8rem;
    border: 1px solid var(--border-2);
    border-radius: 999px;
    background: var(--surface);
    font-size: .82rem; font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.filters a.is-active {
    background: var(--brand-700); border-color: var(--brand-700); color: #fff;
}

/* ---- Bandeau de fiche -----------------------------------------------
   Le nom du technicien et ses chiffres doivent se lire d'un coup
   d'œil : fond sombre, texte blanc, liseré à sa couleur d'agenda. */
.hero {
    background: var(--brand-700);            /* couleur unie, sans degrade */
    border-left: 5px solid var(--hero-color, var(--accent));
    border-radius: var(--radius-lg);
    padding: .95rem 1rem 1.05rem;
    margin-bottom: .85rem;
    box-shadow: var(--shadow);
    color: #fff;
}
.hero__top { display: flex; align-items: flex-start; gap: .65rem; }
.hero__back {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
}
.hero__back:hover { background: rgba(255, 255, 255, .26); color: #fff; }
.hero__title { flex: 1; min-width: 0; }
.hero h1 {
    color: #fff; font-size: 1.3rem;
    letter-spacing: -.015em; word-break: break-word;
}
.hero__sub {
    display: flex; flex-wrap: wrap; gap: .25rem .85rem;
    margin-top: .35rem;
    font-size: .82rem; font-weight: 600;
}
.hero__sub span { display: inline-flex; align-items: center; gap: .3rem; color: #fff; opacity: .95; }

.hero__facts {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .9rem;
    margin: .85rem 0 0; padding-top: .75rem;
    border-top: 1px solid rgba(255, 255, 255, .18);
}
.hero__facts > div { min-width: 0; }
.hero__facts dt {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; opacity: .68;
}
.hero__facts dd {
    margin: .12rem 0 0; font-size: .9rem; font-weight: 650;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hero__facts a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* Barre d'actions immédiates sous le bandeau */
.quick-bar { display: flex; gap: .5rem; margin-bottom: .85rem; }
.quick-bar .btn { flex: 1; }

/* Carte « prochaine étape » : ce qu'il reste à faire, mis en avant */
.next-step { border-color: var(--accent); border-width: 1.5px; }
.next-step .card__head { background: var(--accent-soft); }
.next-step .card__head h2 { color: var(--accent-text); }
.next-step__hint { font-size: .85rem; color: var(--text-muted); margin-bottom: .7rem; }

.done-note {
    display: flex; align-items: center; gap: .6rem;
    padding: .8rem .9rem;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: .87rem;
    margin-bottom: .85rem;
}

@media (min-width: 640px) {
    .hero__facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .hero h1 { font-size: 1.5rem; }
}

/* ---- Detail / fiche ------------------------------------------------ */
.detail-list { margin: 0; }
.detail-list > div {
    display: flex; gap: .8rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--border);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt {
    flex-shrink: 0; width: 42%;
    font-size: .82rem; color: var(--text-muted); font-weight: 600;
}
.detail-list dd { flex: 1; margin: 0; font-size: .88rem; font-weight: 550; word-break: break-word; }

/* Champ « aller a une date » de la barre du planning */
.planning-date { display: flex; }
.planning-date .input {
    width: auto; min-height: 32px;
    padding: .25rem .45rem;
    font-size: .8rem;
}

/* Bandeau de la semaine, vue « jour » du planning */
.bandeau {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: .75rem;
}
.bandeau__jour {
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    padding: .4rem .1rem .3rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}
.bandeau__jour:hover { border-color: var(--accent); }
.bandeau__nom {
    font-size: .65rem; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: .02em;
}
.bandeau__num { font-size: 1rem; font-weight: 700; line-height: 1.1; }
/* La pastille garde sa place meme vide : les sept cases restent alignees.
   Le chiffre est centre par flex : cale a gauche, il debordait de l'arrondi. */
.bandeau__pastille {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 3px;
    border-radius: 999px;
    font-size: .62rem; font-weight: 700; line-height: 1;
    color: transparent;
}
.bandeau__pastille:not(:empty) { background: var(--brand-700); color: #fff; }
.bandeau__jour--aujourdhui {
    background: var(--accent-soft); border-color: var(--accent);
}
.bandeau__jour--aujourdhui .bandeau__num { color: var(--accent-text); }
.bandeau__jour--actif {
    background: var(--brand-700); border-color: var(--brand-700);
}
.bandeau__jour--actif .bandeau__nom,
.bandeau__jour--actif .bandeau__num { color: #fff; }
.bandeau__jour--actif .bandeau__pastille:not(:empty) {
    background: #fff; color: var(--brand-700);
}

/* ---- Agenda mensuel -------------------------------------------------- */
.agenda {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: .85rem;
}
.agenda__jour {
    padding: .4rem .3rem;
    background: var(--surface-2);
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-faint); text-align: center;
}
.agenda__case {
    display: flex; flex-direction: column; gap: 2px;
    min-height: 92px;
    padding: .25rem .25rem .35rem;
    background: var(--surface);
}
.agenda__case--weekend { background: var(--surface-2); }
.agenda__case--hors    { opacity: .45; }
.agenda__case--aujourdhui { background: var(--accent-soft); }

.agenda__date {
    align-self: flex-start;
    min-width: 22px; padding: 1px 5px;
    border-radius: 999px;
    font-size: .74rem; font-weight: 700;
    color: var(--text-muted); text-align: center;
}
.agenda__date:hover { background: var(--surface-2); color: var(--text); }
.agenda__case--aujourdhui .agenda__date { background: var(--accent); color: #fff; }

.agenda__item {
    display: flex; flex-direction: column; gap: 0;
    padding: 2px 4px;
    border-left: 3px solid var(--status-color, var(--border-2));
    border-radius: 3px;
    background: var(--surface-2);
    font-size: .66rem; line-height: 1.25;
    color: var(--text);
    overflow: hidden;
}
.agenda__item:hover { background: var(--border); color: var(--text); }
.agenda__heure  { font-weight: 700; color: var(--text-muted); }
.agenda__client { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Le technicien ressort en gras : c'est lui qu'on cherche d'abord du regard */
.agenda__tech {
    font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--brand-700);
}
.agenda__plus {
    padding: 1px 4px;
    font-size: .64rem; font-weight: 600;
    color: var(--text-faint);
}

/* La semaine dispose de sept colonnes pour une seule ligne : les cases
   respirent, et rien n'y est tronque. */
/* La colonne d'une journee ne s'interpose pas dans la grille : ses deux
   enfants — en-tete et case — s'y placent directement. */
.agenda__col { display: contents; }
.agenda--semaine .agenda__case { min-height: 200px; padding: .35rem .3rem .5rem; }
.agenda--semaine .agenda__item  { font-size: .68rem; padding: 3px 5px; }
.agenda__jour--aujourdhui { color: var(--accent-text); background: var(--accent-soft); }
.agenda__jour strong { display: block; font-size: .95rem; color: var(--text); }
.agenda__jour--aujourdhui strong { color: var(--accent-text); }
a.agenda__jour:hover { background: var(--border); color: var(--text); }
a.agenda__jour:hover strong { color: var(--text); }

/* Sur telephone la grille reste lisible en reduisant le detail */
@media (max-width: 640px) {
    /* Sept colonnes sur un telephone deviennent illisibles : la semaine
       s'empile, chaque journee gardant son en-tete au-dessus de sa case. */
    .agenda--semaine { grid-template-columns: 1fr; gap: 0; }
    .agenda__col     { display: block; border-bottom: 1px solid var(--border); }
    .agenda--semaine .agenda__jour {
        display: flex; align-items: baseline; gap: .35rem;
        text-align: left; padding: .45rem .7rem;
    }
    .agenda--semaine .agenda__jour strong { display: inline; font-size: .88rem; }
    .agenda--semaine .agenda__case { min-height: 0; padding: .3rem .5rem .5rem; }
    /* Une journee vide n'a pas besoin d'occuper de la hauteur */
    .agenda--semaine .agenda__case:empty { display: none; }
    .agenda--semaine .agenda__heure { display: inline; }
    .agenda--semaine .agenda__item  { font-size: .74rem; }

    .agenda__case { min-height: 62px; padding: .2rem .15rem; }
    .agenda__heure { display: none; }
    .agenda__tech  { font-size: .58rem; }
    .agenda__item { font-size: .6rem; padding: 1px 3px; }
    .agenda__jour { font-size: .6rem; }
}

/* ---- Priorites du tableau de bord ----------------------------------- */
.priorites {
    display: grid; gap: .5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: .85rem;
}
.priorite {
    display: flex; flex-direction: column; gap: .1rem;
    padding: .7rem .8rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--border-2);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform .12s, box-shadow .12s;
}
.priorite:hover { transform: translateY(-1px); box-shadow: var(--shadow); color: var(--text); }
.priorite__nb {
    font-size: 1.6rem; font-weight: 800; line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--brand-700);
}
.priorite__label {
    display: flex; align-items: center; gap: .35rem;
    font-size: .84rem; font-weight: 650;
}
.priorite__label .ico { width: 15px; height: 15px; }
.priorite__hint { font-size: .7rem; color: var(--text-faint); }

/* Rien ne peut avancer sans technicien : cette case passe devant. */
.priorite--alerte { border-left-color: var(--red); }
.priorite--alerte .priorite__nb { color: var(--red); }
.priorite--jour { border-left-color: var(--accent); }
.priorite--jour .priorite__nb { color: var(--accent-text); }

@media (min-width: 700px) {
    .priorites { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---- Divers -------------------------------------------------------- */
.muted   { color: var(--text-muted); }
.faint   { color: var(--text-faint); }
.small   { font-size: .8rem; }
.tiny    { font-size: .73rem; }
.strong  { font-weight: 700; }
.num     { font-variant-numeric: tabular-nums; }
.right   { text-align: right; }
.center  { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.hide { display: none !important; }
.divider { height: 1px; background: var(--border); margin: .9rem 0; }

.copy-field { display: flex; gap: .4rem; }
.copy-field input {
    flex: 1; min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .78rem;
}

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* =====================================================================
   Ecrans larges
   ===================================================================== */
@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .field-row { grid-template-columns: 1fr 1fr; }
    .field-row--3 { grid-template-columns: repeat(3, 1fr); }
    .header__brand span { display: inline; }
    .main { padding: 1.25rem 1.25rem calc(var(--nav-h) + var(--safe-bottom) + 1.5rem); }
    h1 { font-size: 1.5rem; }
}

@media (min-width: 1000px) {
    .tabbar { display: none; }
    .more-sheet { display: none; }
    .main { padding: 1.5rem 1.75rem 2.5rem; max-width: 1400px; }

    .sidebar {
        display: flex; flex-direction: column;
        width: var(--sidebar-w); flex-shrink: 0;
        padding: .9rem .7rem;
        background: var(--surface);
        border-right: 1px solid var(--border);
        position: sticky; top: calc(var(--header-h) + var(--safe-top));
        height: calc(100vh - var(--header-h) - var(--safe-top));
        overflow-y: auto;
    }
    .sidebar__group + .sidebar__group { margin-top: 1.1rem; }
    .sidebar__label {
        padding: 0 .6rem .35rem;
        font-size: .68rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: .06em; color: var(--text-faint);
    }
    .sidebar a {
        display: flex; align-items: center; gap: .6rem;
        padding: .52rem .6rem;
        border-radius: var(--radius-sm);
        font-size: .875rem; font-weight: 600;
        color: var(--text-muted);
    }
    .sidebar a:hover { background: var(--surface-2); color: var(--text); }
    .sidebar a.is-active { background: var(--brand-700); color: #fff; }
    .sidebar a.is-active .ico { stroke: #fff; }
    .sidebar .ico { width: 18px; height: 18px; stroke: var(--text-faint); }
    .sidebar a:hover .ico { stroke: var(--text-muted); }
    .sidebar__count {
        margin-left: auto;
        background: var(--accent); color: #fff;
        font-size: .68rem; font-weight: 700;
        padding: .05rem .4rem; border-radius: 999px;
    }

    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; align-items: start; }
    .grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: .85rem; align-items: start; }
}

/* =====================================================================
   Impression
   ===================================================================== */
@media print {
    .header, .sidebar, .tabbar, .btn, .filters { display: none !important; }
    .main { padding: 0; }
    .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
    body { background: #fff; font-size: 11pt; }
}

/* =====================================================================
   Mode sombre — suit le reglage du telephone
   ===================================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #0d0f12;
        --surface:   #16191e;
        --surface-2: #1d2127;
        --border:    #2a2f37;
        --border-2:  #3b424d;

        --text:       #e5e7eb;
        --text-muted: #9ca3af;
        --text-faint: #6b7280;

        /* Sur fond sombre l'anthracite s'eclaircit, sinon l'en-tete et
           les boutons se fondraient dans la page. */
        --brand-800: #3a4450;
        --brand-700: #2b333d;
        --brand-600: #4b5563;

        --accent-soft: #0b2536;
        --accent-text: #7dd3fc;

        --green-soft:  #052e16;
        --red-soft:    #3f1212;
        --amber-soft:  #3a2609;
        --blue-soft:   #10254d;
        --violet-soft: #2a1a4d;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow:    0 2px 8px rgba(0, 0, 0, .45);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);
    }
    .alert--success { color: #86efac; border-color: #14532d; }
    .alert--error   { color: #fca5a5; border-color: #7f1d1d; }
    .alert--warning { color: #fcd34d; border-color: #78350f; }
    .alert--info    { color: #93c5fd; border-color: #1e3a8a; }
    .badge--green { color: #86efac; } .badge--red { color: #fca5a5; }
    .badge--amber { color: #fcd34d; } .badge--blue { color: #93c5fd; }
    .badge--violet { color: #c4b5fd; }
}

/* =====================================================================
   Gestion des techniciens
   ===================================================================== */

/* ---- Page de connexion ---------------------------------------------- */
.guest {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: calc(var(--safe-top) + 1.25rem) 1.25rem calc(var(--safe-bottom) + 1.25rem);
    background: linear-gradient(160deg, #2c353f 0%, #101418 55%, #222a32 100%);
}
.guest__box { width: 100%; max-width: 430px; }
.guest__brand { text-align: center; margin-bottom: 1.4rem; color: #fff; }
.guest__brand img { width: 58px; height: 58px; border-radius: 14px; margin-bottom: .6rem; }
.guest__brand h1 { font-size: 1.3rem; }
.guest__brand p { color: rgba(255, 255, 255, .7); font-size: .88rem; margin: .25rem 0 0; }
.guest .card { margin-bottom: 1rem; }
.guest__foot { text-align: center; color: rgba(255, 255, 255, .65); font-size: .84rem; }
.guest__foot a { color: #fff; text-decoration: underline; }

/* ---- En-tete : qui est connecte -------------------------------------- */
.header__user {
    display: inline-flex; align-items: center; gap: .4rem;
    max-width: 46vw;
    font-size: .82rem; font-weight: 600; opacity: .92;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- WhatsApp --------------------------------------------------------
   Vert sombre de WhatsApp : le vert vif de la marque ne laisse pas lire
   un texte blanc. */
.btn--wa { background: #128c7e; color: #fff; }
.btn--wa:hover { background: #0e7468; color: #fff; }
/* Message deja ouvert : le bouton s'efface sans disparaitre */
.btn--wa-done { background: var(--surface); border-color: #128c7e; color: #128c7e; }
.btn--wa-done:hover { background: var(--surface-2); color: #0e7468; }

/* ---- Lignes de personnes ---------------------------------------------
   Une pastille de couleur, un nom, une ligne de details, puis a droite
   un montant et des actions. */
.person {
    display: flex; align-items: center; gap: .7rem;
    padding: .7rem .9rem;
}
.person__dot {
    flex: 0 0 auto;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--border-2);
}
.person__main { flex: 1; min-width: 0; }
.person__name { font-weight: 650; font-size: .93rem; color: var(--text); word-break: break-word; }
a.person__name:hover { color: var(--accent-text); }
.person__meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem;
    margin-top: .2rem;
    font-size: .78rem; color: var(--text-muted);
}
.person__amount {
    flex-shrink: 0;
    font-weight: 700; font-size: .92rem;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.person__actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.person__actions form { margin: 0; }

/* Sur telephone, les actions passent sous le nom au lieu de l'ecraser */
@media (max-width: 640px) {
    .person--wrap { flex-wrap: wrap; }
    .person--wrap .person__actions { flex-basis: 100%; justify-content: flex-end; }
}

.tech-link { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); }
.tech-link:hover { color: var(--accent-text); }

/* ---- Agenda : la case entiere ouvre la journee ------------------------ */
a.agenda__case { color: var(--text); transition: box-shadow .12s; }
a.agenda__case:hover { color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.agenda__tete { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
/* Nombre de techniciens du jour : lisible meme quand les noms sont tronques */
.agenda__compte {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px;
    background: var(--brand-700); color: #fff;
    font-size: .62rem; font-weight: 700; line-height: 1;
    letter-spacing: 0;
}
.agenda__jour .agenda__compte { margin-left: .3rem; vertical-align: 2px; }

/* Vue semaine : les sept en-tetes sur une ligne, les sept cases dessous.
   Sans ces deux regles, en-tete et case d'un meme jour se suivraient
   cote a cote dans la grille. Sur telephone, ou chaque jour s'empile,
   elles sont sans effet. */
.agenda--semaine .agenda__jour { grid-row: 1; }
.agenda--semaine .agenda__case { grid-row: 2; }
.agenda__item .agenda__tech { color: var(--text); }

/* ---- Envoi groupe ----------------------------------------------------- */
.queue__fin {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    background: var(--green-soft); color: #14532d;
    font-size: .87rem; font-weight: 600;
}
.person.is-sent .person__name { color: var(--text-muted); }
.badge--btn { border: 0; cursor: pointer; font-family: inherit; }

/* Apercu d'un message, replie par defaut */
.apercu-msg { margin-top: .35rem; }
.apercu-msg > summary {
    display: inline-block;
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    cursor: pointer;
}
.apercu-msg > summary:hover { color: var(--text); }
.apercu-msg pre {
    margin: .4rem 0 0; padding: .6rem .7rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2);
    font: inherit; font-size: .82rem; line-height: 1.45;
    white-space: pre-wrap; word-break: break-word;
}

/* ---- Comptes des managers -------------------------------------------- */
.manager { display: flex; flex-direction: column; gap: .55rem; padding: .85rem .9rem; }
.manager form { margin: 0; }
.manager code, .field__hint code {
    padding: .05rem .3rem; border-radius: 4px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: .92em;
}

/* ---- Case a cocher accompagnee d'un texte ----------------------------- */
.check {
    display: flex; align-items: flex-start; gap: .55rem;
    margin-bottom: .85rem;
    font-size: .85rem; cursor: pointer;
}
.check input { flex: 0 0 auto; width: 18px; height: 18px; margin: .1rem 0 0; }
.check small { display: block; margin-top: .1rem; font-size: .75rem; color: var(--text-faint); }

/* Ligne a plusieurs etages (nom, details, apercu) : tout s'aligne en haut */
.person--top { align-items: flex-start; }
.person--top .person__dot { margin-top: .42rem; }

@media (prefers-color-scheme: dark) {
    .queue__fin { color: #86efac; }
    .btn--wa-done { color: #5eead4; border-color: #5eead4; }
    .btn--wa-done:hover { color: #99f6e4; }

    /* L'anthracite sert de couleur de texte en mode clair ; sur fond
       sombre il serait illisible. */
    .priorite__nb { color: var(--text); }
    .priorite--alerte .priorite__nb { color: #f87171; }
    .priorite--jour .priorite__nb { color: var(--accent-text); }
}
