/* ===========================================================================
   COSTAS Expertises — feuille de style (Phase 5B — UX)
   Charte sobre et professionnelle, lisible sur mobile, tablette et PC.
   Objectifs : cohérence visuelle, lisibilité, responsive tactile,
   états (chargement/erreur/vide/succès) et accessibilité.
   NB : tous les noms de classes historiques sont conservés.
   =========================================================================== */

/* ----- Jetons de design (couleurs, espacements, typo, ombres) ----- */
:root {
  /* Couleurs de marque */
  --bleu:        #0f3d57;
  --bleu-clair:  #1d5e83;
  --bleu-pale:   #eef4fb;   /* fonds d'éléments actifs */
  --accent:      #1d9a6c;   /* vert d'action (boutons primaires) */
  --accent-fonce:#178a5f;

  /* Couleurs d'état */
  --vert:        #178a5f;
  --vert-bg:     #e6f7ef;
  --rouge:       #c0392b;
  --rouge-bg:    #fdecea;
  --orange:      #b8791a;
  --orange-bg:   #fff4e0;

  /* Neutres */
  --gris-bg:     #f4f6f8;   /* fond d'application */
  --blanc:       #ffffff;   /* surfaces (cartes) */
  --gris-bord:   #d9e0e6;
  /* Mesuré le 17/07 : #d9e0e6 sur blanc = 1,33:1 -> INVISIBLE. Le texte de
     COSTAS était conforme (5,51:1) ; c'était l'ARCHITECTURE qui n'existait pas :
     carte sur fond 1,08:1, bloc stat sur carte 1,05:1. Aucun FOND ne peut
     corriger ça (le max atteignable est 1,23:1) -> il faut des TRAITS.
     Ulysse : bandeau 6,57:1, libellés 14:1 sur gris. On s'aligne. */
  --bord-fort:   #7d8d9a;   /* 3,42:1 sur blanc — norme UI pour un contour */
  --bord-moyen:  #a9b6c1;   /* 2,07:1 — séparateurs internes */
  --fiche-bg:    #e8ecf0;   /* fond des écrans « fiche » */
  --ligne-alt:   #f5f8fa;   /* lignes alternées (avec bordures, pas seul) */
  --gris-bord-2: #eef2f5;   /* séparateurs légers */
  --gris-txt:    #5a6b78;   /* texte secondaire (contraste AA sur blanc) */
  --txt:         #1f2d36;   /* texte principal */

  /* Rayons / ombres / espacements */
  --radius:      10px;
  --radius-sm:   8px;
  --radius-pill: 999px;
  --ombre:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --ombre-md:    0 4px 12px rgba(15,61,87,.10);
  --ombre-lg:    0 10px 30px rgba(15,61,87,.16);
  --tap:         44px;      /* cible tactile minimale */
  --header-h:    56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gris-bg);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===========================================================================
   Écran d'amorçage (boot) — avec petit indicateur d'activité
   =========================================================================== */
.boot {
  min-height: 60vh; padding: 40px; text-align: center; color: var(--gris-txt);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.boot::before {
  content: ""; width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--gris-bord); border-top-color: var(--bleu);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   Connexion
   =========================================================================== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--blanc); border-radius: var(--radius); box-shadow: var(--ombre-md);
  width: 100%; max-width: 380px; padding: 32px 28px;
}
.login-logo { text-align: center; margin-bottom: 6px; }
.login-logo b { color: var(--bleu); font-size: 1.6rem; letter-spacing: .5px; }
.login-sub { text-align: center; color: var(--gris-txt); font-size: .85rem; margin-bottom: 24px; }

/* ===========================================================================
   En-tête de l'application + navigation principale
   =========================================================================== */
.app-header {
  background: var(--bleu); color: #fff; padding: 0 20px; min-height: var(--header-h);
  display: flex; align-items: center; gap: 8px;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
  padding-top: env(safe-area-inset-top);
}
.app-header .brand { font-weight: 800; letter-spacing: 1px; font-size: 1.05rem; }
.app-header .user {
  font-size: .8rem; opacity: .9; display: flex; align-items: center; gap: 10px;
  margin-left: auto; white-space: nowrap;
}
.app-header .user .email { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* Navigation principale (Accueil / Dossiers) — barre haute sur grand écran */
.app-nav { display: flex; gap: 4px; margin-left: 18px; }
.nav-btn {
  background: none; border: none; cursor: pointer; color: #fff; opacity: .75;
  font-weight: 500; font-size: .95rem; padding: 6px 10px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  border-bottom: 2px solid transparent;
}
.nav-btn:hover { opacity: 1; background: rgba(255,255,255,.08); }
.nav-btn.actif { opacity: 1; font-weight: 700; border-bottom-color: #fff; }
.nav-btn .ico { font-size: 1.05rem; line-height: 1; }
.nav-btn .lbl { display: inline; }

/* ===========================================================================
   Conteneur, barre d'outils, titres
   =========================================================================== */
.container { max-width: 1000px; margin: 0 auto; padding: 20px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; font-size: 1.25rem; color: var(--bleu); line-height: 1.25; }
h3 { color: var(--bleu); }

/* Fil d'Ariane / lien retour */
a.back, .back {
  color: var(--bleu-clair); font-size: .9rem; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 4px; min-height: 36px;
}
a.back:hover, .back:hover { text-decoration: underline; }
a.back::before, .back::before { content: "‹"; font-size: 1.2rem; line-height: 1; }

/* ===========================================================================
   Champs de formulaire
   =========================================================================== */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--gris-txt); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--bord-fort);
  border-radius: var(--radius-sm); font-size: .95rem; background: #fff; font-family: inherit;
  color: var(--txt); min-height: var(--tap);
}
textarea { min-height: 96px; resize: vertical; }
/* Cases à cocher / boutons radio : taille naturelle (sinon étirés par la règle ci-dessus). */
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; margin: 0 6px 0 0; vertical-align: middle; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--bleu-clair); box-shadow: 0 0 0 3px rgba(29,94,131,.12);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .col { flex: 1; min-width: 160px; }

/* ===========================================================================
   Boutons (cibles tactiles ≥ 44px)
   =========================================================================== */
button { font-family: inherit; cursor: pointer; border: none; border-radius: var(--radius-sm); font-size: .92rem; font-weight: 600; padding: 11px 16px; min-height: var(--tap); transition: background .12s, box-shadow .12s, transform .04s; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover:not(:disabled) { background: var(--accent-fonce); }
.btn-sec { background: #eef2f5; color: var(--bleu); }
.btn-sec:hover:not(:disabled) { background: #e2e9ee; }
.btn-danger { background: var(--rouge-bg); color: var(--rouge); }
.btn-danger:hover:not(:disabled) { background: #f9d9d4; }
/* Bouton-lien : bleu par défaut (lisible sur les cartes blanches).
   La variante blanche est réservée à l'en-tête (fond bleu) ci-dessous. */
.btn-link { background: none; color: var(--bleu-clair); opacity: 1; padding: 6px 8px; min-height: 36px; }
.btn-link:hover { opacity: 1; text-decoration: underline; }
.app-header .btn-link { color: #fff; opacity: .85; }
.app-header .btn-link:hover { opacity: 1; }
/* Boutons de suppression « ✕ » : zone tactile élargie malgré le padding:0 inline
   (sélecteur d'attribut sur le title, !important nécessaire face au style inline). */
button[title^="Supprimer"] { padding: 6px 10px !important; min-height: 32px !important; }

/* ===========================================================================
   Cartes, listes de dossiers, paires clé/valeur
   =========================================================================== */
/* Une carte blanche sur fond blanc à 1,08:1 ne délimite rien : on lui donne un trait. */
.card { background: #fff; border: 1px solid var(--bord-moyen); border-radius: var(--radius); box-shadow: var(--ombre); padding: 16px 18px; margin-bottom: 14px; }
/* Hiérarchie visuelle des cartes : titre (h3 ou <strong> direct) souligné et espacé. */
.card h3 { font-size: 1.02rem; border-bottom: 2px solid var(--gris-bord-2); padding-bottom: 7px; margin-bottom: 12px; }
.card > strong { display: block; color: var(--bleu); font-size: .95rem; border-bottom: 2px solid var(--gris-bord-2); padding-bottom: 6px; margin-bottom: 8px; }
.dossier-item { display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: background .1s, box-shadow .1s, transform .05s; gap: 12px; }
.dossier-item:hover { background: #fafcfd; box-shadow: var(--ombre-md); }
.dossier-item:active { transform: scale(.997); }
.dossier-ref { font-weight: 700; color: var(--bleu); }
.dossier-meta { color: var(--gris-txt); font-size: .85rem; margin-top: 2px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--gris-bord-2); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--gris-txt); font-size: .85rem; }
.kv .v { font-weight: 600; text-align: right; }
.montant { font-size: 1.05rem; }

/* ===========================================================================
   Badges de statut
   =========================================================================== */
.badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.badge.ouvert { background: #e8f4fd; color: #1d6fa5; }
.badge.expertise { background: var(--orange-bg); color: var(--orange); }
.badge.negociation { background: #fde9e7; color: var(--rouge); }
.badge.accord { background: var(--vert-bg); color: var(--vert); }
.badge.clos { background: #eceff1; color: var(--gris-txt); }
.badge.perdu { background: #f0e6e6; color: #8a4a44; }

/* ===========================================================================
   Statistiques / synthèse chiffrage
   =========================================================================== */
.chiffrage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.stat { background: #f7fafc; border: 1px solid var(--bord-moyen); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat .label { font-size: .72rem; color: var(--gris-txt); text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 1.15rem; font-weight: 700; color: var(--bleu); margin-top: 4px; }

/* ===========================================================================
   Onglets de la fiche dossier (barre déroulante sur mobile)
   =========================================================================== */
.tabbar {
  display: flex; flex-wrap: wrap; gap: 6px;
  border-bottom: 2px solid var(--gris-bord); margin-bottom: 14px;
}
.tab-btn {
  padding: 9px 14px; border: none; border-bottom: 3px solid transparent;
  background: transparent; cursor: pointer; font-size: .95rem; font-weight: 500;
  color: var(--gris-txt); border-radius: 8px 8px 0 0; margin-bottom: -2px; white-space: nowrap;
}
.tab-btn:hover { color: var(--bleu); background: #f3f7fb; }
/* Onglet actif : fond bleu plein + texte blanc -> repérage immédiat de l'onglet courant. */
.tab-btn.actif { color: #fff; font-weight: 700; border-bottom-color: var(--bleu); background: var(--bleu); }
.tab-btn.actif:hover { color: #fff; background: var(--bleu-clair); }

/* Sous-onglets (2e niveau) : style « pilule » plus léger que les macro-onglets. */
/* ===========================================================================
   MODALE — « un petit bouton Modifier qui ouvre une fenêtre » (Armen, 17/07).
   Principe : l'écran AFFICHE, la modale ÉDITE. Fini les champs de saisie
   partout : on lit un dossier bien plus souvent qu'on ne le modifie.
   =========================================================================== */
.modale-fond {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 61, 87, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 14px; overflow-y: auto;
}
.modale {
  background: #fff; border-radius: 10px; box-shadow: var(--ombre-lg);
  width: 100%; max-width: 520px; overflow: hidden; margin: auto 0;
}
.modale-tete {
  background: var(--bleu); color: #fff; padding: 9px 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.modale-tete b { font-size: .95rem; font-weight: 700; }
.modale-fermer {
  background: none; border: none; color: #fff; font-size: 1.3rem; line-height: 1;
  padding: 2px 6px; min-height: 0; cursor: pointer; opacity: .85;
}
.modale-fermer:hover { opacity: 1; }
.modale-corps { padding: 12px 16px 16px; max-height: 70vh; overflow-y: auto; }
.modale-corps label:first-child { margin-top: 0; }
.modale-pied {
  padding: 10px 16px; border-top: 1px solid var(--gris-bord); background: var(--gris-bg);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
/* Petit bouton « Modifier » discret, dans un bandeau de carte. */
.btn-modif {
  background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35);
  font-size: .68rem; font-weight: 600; padding: 2px 8px; min-height: 0;
  border-radius: 4px; white-space: nowrap;
}
.btn-modif:hover { background: rgba(255,255,255,.3); }
@media (max-width: 640px) { .modale-fond { padding: 0; } .modale { max-width: none; border-radius: 0; min-height: 100vh; } }

/* ===========================================================================
   INTERVENANTS — modèle « colonnes » validé le 17/07/2026.
   Une colonne = UNE personne (l'assuré, ou un tiers) + ses satellites
   (son assureur, son courtier, son syndic, son expert, son représentant).
   Armen : « un syndic, un courtier, un assureur est systématiquement
   rattaché à 1 personne morale ou physique ». Ce n'est pas une liste, c'est
   un arbre -> le rattachement se LIT, il ne se déduit pas.
   Pas de camps « assuré / adversaires » comme Ulysse : il n'y a pas toujours
   d'adversaire, et l'assuré peut être lésé ET responsable.
   =========================================================================== */
.iv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; align-items: start; }
.iv-col { border: 1px solid var(--bord-fort); border-radius: 5px; overflow: hidden; background: #fff; }
/* Bandeau plein : le nom ET le rôle, lisibles à un mètre. */
.iv-tete { padding: 5px 9px; font-size: .84rem; font-weight: 700; color: #fff;
  display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.iv-tete .role { font-weight: 400; opacity: .85; font-size: .66rem; letter-spacing: .06em; }
.iv-corps { padding: 5px 9px; font-size: .78rem; }
.iv-presence { display: flex; gap: 3px; flex-wrap: wrap; padding: 5px 9px; border-bottom: 1px solid var(--gris-bord); }
.iv-pz { font-size: .68rem; padding: 2px 7px; border-radius: 3px; cursor: pointer; border: 1px solid transparent; background: #fff; font-family: inherit; }
/* Satellite : une ligne, cliquable pour éditer. */
.iv-sat { padding: 4px 9px; font-size: .78rem; border-bottom: 1px solid var(--gris-bord-2);
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px; cursor: pointer; }
.iv-sat:last-child { border-bottom: none; }
.iv-sat:hover { background: var(--bleu-pale); }
.iv-sat .meta { color: var(--gris-txt); font-size: .72rem; white-space: nowrap; }
.iv-sat-nom { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iv-sat-fin { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* Croix de suppression : discrète au repos, franche au survol de la ligne. */
.iv-x { background: none; border: none; color: var(--gris-txt); font-size: .8rem; line-height: 1;
  padding: 2px 4px; min-height: 0; opacity: 0; cursor: pointer; }
.iv-sat:hover .iv-x { opacity: .6; }
.iv-x:hover { opacity: 1 !important; color: var(--rouge); }
@media (hover: none) { .iv-x { opacity: .5; } }   /* tablette : toujours visible */
/* Les satellites appartiennent visiblement à leur colonne : léger décalage. */
.iv-col .iv-sat { padding-left: 16px; border-left: 3px solid var(--gris-bord-2); }
.iv-col .iv-sat:hover { border-left-color: var(--bleu-clair); }
.iv-pastille { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; flex: 0 0 9px; }
/* Panneau d'édition déplié sous la carte. */
.iv-edit { border-top: 1px solid var(--bord-fort); background: var(--gris-bg); padding: 7px 9px; }
.iv-edit label { margin: 5px 0 2px; font-size: .72rem; }
.iv-edit input, .iv-edit select { min-height: 32px; padding: 4px 8px; font-size: .82rem; }
.iv-mail { color: inherit; text-decoration: none; opacity: .75; }
.iv-mail:hover { opacity: 1; }

/* ===========================================================================
   STYLE « FICHE » — repris d'Ulysse (17/07/2026)
   Un écran = un bandeau de titre plein + des blocs encadrés + des libellés
   alignés à droite contre leur champ. C'est ce rythme vertical qui rend
   Ulysse lisible, pas la couleur.
   =========================================================================== */
.ecran { border: 1px solid var(--bord-fort); border-radius: 8px; overflow: hidden; background: var(--fiche-bg); margin-bottom: 14px; }
/* Bandeau : 11,50:1. Tu sais toujours quel écran tu regardes, même du coin de l'œil. */
.ecran-titre { background: var(--bleu); color: #fff; padding: 7px 14px; font-size: .88rem; font-weight: 700; letter-spacing: .02em; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ecran-titre .sous { font-weight: 400; opacity: .85; font-size: .78rem; }
.ecran-corps { padding: 12px; }

/* Groupe encadré + titre sur le trait (le fieldset/legend d'Ulysse). */
.bloc { border: 1px solid var(--bord-fort); border-radius: 5px; background: #fff; padding: 6px 12px 12px; margin: 0 0 10px; }
.bloc:last-child { margin-bottom: 0; }
.bloc > legend { font-size: .68rem; font-weight: 700; color: var(--bleu); padding: 0 6px; letter-spacing: .06em; text-transform: uppercase; }

/* Grille libellé/champ : le libellé colle à droite, contre son champ.
   L'œil descend une colonne au lieu de balayer la page. */
.fgrid { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 5px 10px; align-items: center; }
.fgrid > label { text-align: right; margin: 0; font-size: .8rem; font-weight: 400; color: var(--txt); text-transform: none; }
.fgrid > .champ { min-width: 0; }
.fgrid input, .fgrid select, .fgrid textarea { min-height: 32px; padding: 5px 8px; font-size: .84rem; }
.fgrid textarea { min-height: 64px; }
@media (max-width: 700px) {
  .fgrid { grid-template-columns: 1fr; gap: 2px; }
  .fgrid > label { text-align: left; font-size: .76rem; color: var(--gris-txt); }
  .fgrid input, .fgrid select, .fgrid textarea { min-height: var(--tap); }
}

/* Boutons radio en ligne (« Type de risque : ○ Immeuble ○ Habitation… ») */
.radios { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.radios label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: .82rem;
  font-weight: 400; color: var(--txt); text-transform: none; cursor: pointer; }

/* Tableau « déclaré / vérifié » : l'écart saute aux yeux ou n'existe pas. */
table.dv { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.dv th { background: var(--bleu); color: #fff; padding: 5px 8px; text-align: left; font-weight: 600; white-space: nowrap; }
table.dv th.r, table.dv td.r { text-align: right; }
table.dv td { padding: 4px 8px; border-bottom: 1px solid var(--gris-bord); }
table.dv tbody tr:nth-child(even) { background: var(--ligne-alt); }
table.dv input, table.dv select { min-height: 30px; padding: 3px 7px; font-size: .84rem; }
.ecart-ok   { color: var(--gris-txt); }
.ecart-alerte { background: var(--rouge-bg); color: var(--rouge); font-weight: 700; }

/* ===========================================================================
   NAVIGATION DU DOSSIER — colonne verticale plate (17/07/2026).
   Tout est visible en permanence, une destination = un clic.
   La verticale est gratuite ; l'horizontale ne l'est pas (10 colonnes à lire
   dans le chiffrage). D'où la colonne plutôt que des onglets en haut.
   =========================================================================== */
.dossier-layout { display: flex; gap: 16px; align-items: flex-start; }
.dossier-nav {
  width: 192px; flex: 0 0 192px; background: var(--bleu);
  border-radius: 10px; padding: 8px 0; position: sticky; top: 12px;
}
/* Titres de groupe : NON cliquables -> ils rangent sans coûter un clic. */
.nav-groupe {
  padding: 9px 14px 4px; font-size: .66rem; letter-spacing: .07em;
  color: #8fb4c8; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; text-align: left; padding: 7px 14px; border: none;
  background: transparent; color: #dce8ef; font-size: .87rem; cursor: pointer;
  border-left: 3px solid transparent; border-radius: 0; font-family: inherit;
}
.nav-item:hover { background: var(--bleu-clair); color: #fff; }
.nav-item.actif { background: var(--gris-bg); color: var(--bleu); font-weight: 700; border-left-color: var(--bleu-clair); }
/* Pastille : une information manque et le calcul en dépend. */
.nav-pastille { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); flex: 0 0 7px; }
.dossier-contenu { flex: 1; min-width: 0; }

/* Tablette en portrait / mobile : la colonne se replie en barre défilante. */
@media (max-width: 900px) {
  .dossier-layout { display: block; }
  .dossier-nav {
    width: auto; flex: none; position: static; display: flex; gap: 4px;
    overflow-x: auto; padding: 6px; margin-bottom: 12px; scrollbar-width: none;
  }
  .dossier-nav::-webkit-scrollbar { display: none; }
  .dossier-nav > div { display: contents; }
  .nav-groupe { display: none; }
  .nav-item { width: auto; white-space: nowrap; border-left: none; border-radius: 6px; padding: 7px 11px; }
  .nav-item.actif { border-left: none; }
}

.subtabbar { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 14px; }
.subtab-btn {
  padding: 6px 13px; border: 1px solid var(--gris-bord); background: #fff;
  color: var(--gris-txt); border-radius: var(--radius-pill); font-size: .85rem;
  font-weight: 500; cursor: pointer; white-space: nowrap; min-height: 36px;
}
.subtab-btn:hover { color: var(--bleu); border-color: var(--bleu-clair); }
.subtab-btn.actif { background: var(--bleu-pale); color: var(--bleu); border-color: var(--bleu); font-weight: 700; }

/* Accueil C — cockpit : deux colonnes (priorités / pipeline). */
.accueil-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }

/* ===========================================================================
   Planning hebdomadaire (Accueil) — jours en COLONNES, heures 9h-19h en lignes.
   Pleine largeur ; défilement horizontal sur petit écran (min-width interne).
   =========================================================================== */
.planning-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.planning-grid { display: grid; grid-template-columns: 46px repeat(5, minmax(112px, 1fr)); min-width: 660px; }
.planning-grid .ph { padding: 6px 4px; font-weight: 700; color: var(--bleu); font-size: .82rem; text-align: center; border-bottom: 2px solid var(--gris-bord); }
.planning-grid .ph .pdate { font-weight: 400; color: var(--gris-txt); font-size: .72rem; }
.planning-grid .ph.auj { background: var(--bleu-pale); border-radius: 6px 6px 0 0; }
.planning-grid .pheure { font-size: .72rem; color: var(--gris-txt); padding: 5px 6px 0 0; text-align: right; border-right: 1px solid var(--gris-bord-2); border-bottom: 1px solid var(--gris-bord-2); }
.planning-grid .pcell { min-height: 32px; border-bottom: 1px solid var(--gris-bord-2); padding: 2px 3px; }
.planning-grid .pcell.auj { background: var(--bleu-pale); }
.prdv { background: var(--bleu); color: #fff; border-radius: 6px; padding: 3px 7px; font-size: .72rem; font-weight: 600; cursor: pointer; margin-bottom: 3px; line-height: 1.3; }
.prdv:hover { background: var(--bleu-clair); }
/* RDV « pro » hors dossier (prospect, banque, comptable…) : pastille ambre. */
.prdv.pro { background: var(--orange); }
.prdv.pro:hover { background: #a06a15; }
.prdv .pcli { font-weight: 400; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Décompte général des dommages (aperçu écran dans l'onglet Rapport). */
.decompte-wrap { overflow-x: auto; }
table.decompte { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.decompte th { background: var(--bleu); color: #fff; padding: 6px 7px; text-align: left; font-weight: 600; white-space: nowrap; }
table.decompte th.r, table.decompte td.r { text-align: right; } table.decompte th.c, table.decompte td.c { text-align: center; }
table.decompte td { padding: 5px 7px; border-bottom: 1px solid var(--gris-bord-2); white-space: nowrap; }
table.decompte tr.t td { font-weight: 700; border-top: 1.5px solid var(--bleu); background: #f5f9fc; }
table.decompte tr.tt td { font-weight: 800; color: var(--bleu); border-top: 2px solid var(--bleu); }

/* ===========================================================================
   États : vide, erreur, succès, information
   =========================================================================== */
.empty { text-align: center; color: var(--gris-txt); padding: 40px 20px; line-height: 1.5; }
.error   { background: var(--rouge-bg);  color: var(--rouge);  padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; margin: 12px 0; border: 1px solid #f3c9c2; }
.success { background: var(--vert-bg);   color: var(--vert);   padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; margin: 12px 0; border: 1px solid #bce8d4; }
.warn    { background: var(--orange-bg); color: var(--orange); padding: 11px 14px; border-radius: var(--radius-sm); font-size: .88rem; margin: 12px 0; border: 1px solid #f0dcb0; }
.muted { color: var(--gris-txt); font-size: .85rem; }

/* ===========================================================================
   Squelettes de chargement (skeleton) + spinner réutilisable
   =========================================================================== */
.skeleton {
  position: relative; overflow: hidden; background: #e9eef2; border-radius: 6px;
  min-height: 14px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-card { height: 64px; margin-bottom: 14px; border-radius: var(--radius); }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; vertical-align: -2px; }

/* ===========================================================================
   Notifications éphémères (toasts)
   =========================================================================== */
.toast-wrap {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--txt); color: #fff;
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--ombre-lg);
  font-size: .9rem; display: flex; align-items: center; gap: 10px;
  animation: toast-in .22s ease-out;
}
.toast.succes { background: var(--vert); }
.toast.erreur { background: var(--rouge); }
.toast.info   { background: var(--bleu-clair); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===========================================================================
   Tableaux responsives (défilement horizontal sur petit écran)
   =========================================================================== */
.container table { border-collapse: collapse; }

/* ===========================================================================
   Accessibilité : focus visible au clavier, mouvement réduit
   =========================================================================== */
:focus-visible { outline: 2px solid var(--bleu-clair); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, .nav-btn:focus-visible, .tab-btn:focus-visible { outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ===========================================================================
   RESPONSIVE — tablette (≤ 980px)
   =========================================================================== */
@media (max-width: 980px) {
  .container { padding: 16px; }
}

/* ===========================================================================
   RESPONSIVE — mobile (≤ 640px)
   La navigation principale passe en barre fixe en bas (pouce-friendly).
   Les onglets de fiche défilent horizontalement. Les tableaux défilent.
   =========================================================================== */
@media (max-width: 640px) {
  .container { padding: 14px 14px 84px; }   /* place pour la barre du bas */
  .toolbar { align-items: flex-start; }
  .toolbar h2 { font-size: 1.12rem; }

  .app-header { padding: 0 14px; }
  .app-header .user .email { max-width: 110px; }

  /* Navigation principale → barre d'onglets fixée en bas */
  .app-nav {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--gris-bord);
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .nav-btn {
    flex: 1; flex-direction: column; gap: 2px; color: var(--gris-txt);
    opacity: 1; border-bottom: none; padding: 4px 6px; font-size: .68rem;
  }
  .nav-btn .ico { font-size: 1.3rem; }
  .nav-btn:hover { background: transparent; }
  .nav-btn.actif { color: var(--bleu); border-bottom: none; }
  .nav-btn.actif .ico { transform: translateY(-1px); }

  /* Onglets de fiche : défilement horizontal sans retour à la ligne */
  .tabbar {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity; scrollbar-width: none; gap: 2px;
  }
  .tabbar::-webkit-scrollbar { display: none; }
  .tab-btn { scroll-snap-align: start; padding: 9px 12px; }
  .subtabbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .subtabbar::-webkit-scrollbar { display: none; }

  /* Tableaux larges : défilement horizontal contenu dans la carte */
  .container table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; font-size: .82rem; }

  .chiffrage-grid { grid-template-columns: 1fr 1fr; }
  .accueil-cols { grid-template-columns: 1fr; }
  .stat .value { font-size: 1.05rem; }
  .toast-wrap { bottom: calc(78px + env(safe-area-inset-bottom)); } /* au-dessus de la barre */
}

/* Très petits écrans */
@media (max-width: 360px) {
  .chiffrage-grid { grid-template-columns: 1fr; }
  /* En-tête serré : on masque l'e-mail pour garder « marque » + « Déconnexion » lisibles. */
  .app-header .user .email { display: none; }
}
