:root {
  color-scheme: light;
  --bleu: #1f3b63;
  --bleu-clair: #e6edf6;
  --vert: #2f8a4e;
  --or: #f2b632;
  --fond: #f5f3ee;
  --nav: 64px;
  --texte: #1c2430;
  --gris: #6b7684;
  --bord: #d7dde4;
  --rouge: #b3261e;
  --blanc: #fff;
  --surface: #fff;
  --jaune: #fff4d6;
  --jaune-texte: #6a4b00;
  --estime: #fff8db;
  --section: #e8f0f8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--fond); }
button, input, textarea { font: inherit; }

.barre {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: var(--bleu); color: var(--blanc);
}
.barre h1 { margin: 0; font-size: 1.2rem; }
.barre nav { display: flex; gap: 4px; }
.barre nav button {
  background: transparent; border: 0; color: #cfe0f1; padding: 8px 10px; border-radius: 8px;
}
.barre nav button.actif { background: rgba(255,255,255,.15); color: var(--blanc); font-weight: 600; }

.bandeau { background: var(--jaune); color: var(--jaune-texte); padding: 8px 16px; font-size: .9rem; }

.vue[hidden] { display: none !important; }
.vue { max-width: 900px; margin: 0 auto; padding: 16px; }

/* --- Conversation --- */
#vue-chantier { display: flex; flex-direction: column; min-height: calc(100dvh - 56px); }
.fil { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.bulle {
  max-width: 88%; padding: 10px 14px; border-radius: 14px; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bulle.ia { background: var(--surface); border: 1px solid var(--bord); align-self: flex-start; }
.bulle.moi { background: var(--bleu); color: var(--blanc); align-self: flex-end; }
.bulle.erreur { background: #fde8e7; color: var(--rouge); align-self: center; }
.bulle ol { margin: 6px 0 0; padding-left: 20px; white-space: normal; }
.bulle img { max-width: 120px; border-radius: 8px; display: block; margin-top: 6px; }
.bulle .btn-principal { margin-top: 8px; }
.bulle.attente { color: var(--gris); font-style: italic; }

.apercu-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.apercu-photos img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bord); }

.saisie {
  position: sticky; bottom: 0; display: flex; gap: 6px; align-items: flex-end;
  background: var(--fond); padding: 8px 0;
}
.saisie textarea {
  flex: 1; min-width: 0; resize: vertical; padding: 10px; border-radius: 12px; border: 1px solid var(--bord);
  background: var(--surface); color: var(--texte);
}
.btn-icone {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--bord);
  background: var(--surface); font-size: 1.2rem; cursor: pointer; flex: none;
}
#micro.ecoute { background: var(--rouge); border-color: var(--rouge); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.btn-principal {
  background: var(--bleu); color: var(--blanc); border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; cursor: pointer;
}
.btn-principal:disabled { opacity: .5; }
.options-chantier { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; font-size: .9rem; color: var(--gris); }
.lien { background: none; border: 0; color: var(--bleu); text-decoration: underline; cursor: pointer; padding: 6px 0; }

/* --- Listes & cartes --- */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.carte h2 { margin-top: 0; font-size: 1.1rem; }
.carte label { display: block; margin-bottom: 10px; font-size: .9rem; color: var(--gris); }
.carte label input:not([type=checkbox]), .carte label textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--bord); border-radius: 8px; color: var(--texte); background: var(--surface);
}
.aide { color: var(--gris); font-size: .9rem; }
.element-liste {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.element-liste small { color: var(--gris); display: block; }
.pastille { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--bleu-clair); color: var(--bleu); font-weight: 600; }
.pastille.facture { background: #e3f4e8; color: #1b6b35; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.actions button:not(.lien) {
  background: var(--surface); color: var(--texte); border: 1px solid var(--bord); border-radius: 10px; padding: 8px 12px; cursor: pointer;
}
.actions button.danger { color: var(--rouge); }
#deconnexion { color: var(--texte); background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.hypotheses { background: var(--jaune); color: var(--jaune-texte); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: .9rem; }
.hypotheses ul { margin: 4px 0 0; padding-left: 20px; }

.tarifs { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tarifs td, .tarifs th { padding: 4px; text-align: left; }
.tarifs input { width: 100%; padding: 6px; border: 1px solid var(--bord); border-radius: 6px; background: var(--surface); color: var(--texte); }
.tarifs td:nth-child(2) { width: 80px; }
.tarifs td:nth-child(3) { width: 80px; }

/* --- Document devis / facture (format A4) --- */
.document {
  /* Toujours une feuille blanche, même en thème sombre */
  --texte: #1c2430; --gris: #6b7684; --bord: #d7dde4; --bleu-clair: #e8f0f8; --surface: #fff;
  color: var(--texte); color-scheme: light;
  background: var(--blanc); border: 1px solid var(--bord); border-radius: 4px;
  padding: 28px; font-size: 13px; line-height: 1.4; overflow-x: auto;
}
.doc-entete { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.doc-entete .entreprise strong { font-size: 16px; color: var(--bleu); }
.doc-entete .client { min-width: 220px; border: 1px solid var(--bord); border-radius: 6px; padding: 10px; }
.doc-titre { margin: 20px 0 4px; font-size: 20px; color: var(--bleu); }
.doc-meta { color: var(--gris); margin-bottom: 12px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 12px 0; min-width: 560px; }
.doc-table th { background: var(--bleu); color: var(--blanc); text-align: left; padding: 6px; font-weight: 600; }
.doc-table td { border-bottom: 1px solid var(--bord); padding: 6px; vertical-align: top; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-table .section td { background: var(--bleu-clair); font-weight: 600; }
.doc-table .detail { color: var(--gris); font-size: 12px; }
.doc-table .calcul { color: var(--gris); font-size: 11px; font-style: italic; }
.doc-table [contenteditable] { outline: 1px dashed transparent; border-radius: 3px; }
.doc-table [contenteditable]:focus { outline-color: var(--bleu); background: #fffbe6; }
.doc-totaux { margin-left: auto; width: 280px; border-collapse: collapse; }
.doc-totaux td { padding: 4px 6px; }
.doc-totaux .ttc td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--bleu); }
.doc-mentions { margin-top: 20px; font-size: 11px; color: var(--gris); }
.doc-signature { display: flex; justify-content: space-between; gap: 20px; margin-top: 24px; }
.doc-signature div { flex: 1; border: 1px solid var(--bord); border-radius: 6px; padding: 10px; min-height: 90px; }
.ajout-ligne { margin: 4px 0; }
.suppr-ligne { border: 0; background: none; color: var(--rouge); cursor: pointer; }

@media (max-width: 600px) {
  .document { padding: 14px; font-size: 12px; }
  .doc-table { min-width: 0; font-size: 11px; }
  .doc-table td, .doc-table th { padding: 4px 3px; }
  .doc-entete .client { min-width: 0; width: 100%; }
  .barre h1 { font-size: 1rem; }
}

@media print {
  .no-print, .barre, .actions, .suppr-ligne, .hypotheses { display: none !important; }
  body { background: var(--blanc); }
  .vue { padding: 0; max-width: none; }
  .document { border: 0; padding: 0; overflow: visible; }
  .doc-table { min-width: 0; }
  .doc-table .calcul, .ajout-ligne { display: none; }
  @page { size: A4; margin: 14mm; }
}

/* --- Connexion --- */
.connexion { max-width: 420px; margin: 24px auto; }
.message { background: var(--bleu-clair); color: var(--bleu); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.liens-connexion { display: flex; justify-content: space-between; margin-top: 12px; }

/* --- Réglages --- */
.metiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 12px; margin-bottom: 12px; }
.metiers label { margin: 0; color: var(--texte); }
#grille-tarifs h3 { font-size: .95rem; margin: 16px 0 4px; color: var(--bleu); }
.tarifs select { width: 100%; margin-top: 4px; padding: 4px; border: 1px solid var(--bord); border-radius: 6px; font-size: .8rem; color: var(--gris); background: var(--blanc); }

/* --- Documents --- */
.element-liste .droite { text-align: right; }
.info { background: var(--bleu-clair); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: .9rem; }
.info select { font: inherit; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--bord); }
.doc-table tr.estime td { background: #fff8db; }
.badge-estime { font-size: 10px; font-weight: 600; color: #6a4b00; background: #ffe9a8; border-radius: 99px; padding: 1px 6px; }
@media print { .doc-table tr.estime td { background: none; } }

/* --- Messages et confirmations --- */
.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 50;
  max-width: calc(100% - 32px); background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.erreur { background: var(--rouge); color: #fff; }
.dialogue-fond { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; }
.dialogue { background: var(--surface); color: var(--texte); border-radius: 14px; padding: 18px; max-width: 380px; width: 100%; }
.dialogue p { margin-top: 0; line-height: 1.4; }
.dialogue-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialogue-actions button { border-radius: 10px; padding: 8px 14px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte); cursor: pointer; }
.dialogue-actions .danger { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.dialogue-actions .btn-principal { background: var(--bleu); border-color: var(--bleu); color: #fff; }

/* --- Thème sombre (l'aperçu du document reste blanc, comme sur papier) --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #11161d; --texte: #e3e8ee; --gris: #9aa6b4; --bord: #2c3642; --surface: #1a212b;
    --bleu-clair: #1c2c3d; --jaune: #3a3017; --jaune-texte: #f1d58a; --bleu: #3d6aa8;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #11161d; --texte: #e3e8ee; --gris: #9aa6b4; --bord: #2c3642; --surface: #1a212b;
  --bleu-clair: #1c2c3d; --jaune: #3a3017; --jaune-texte: #f1d58a;
}

/* --- Notes de chantier --- */
.btn-large { width: 100%; padding: 14px; font-size: 1.05rem; }
#vue-notes .aide { margin: 12px 0 16px; }
.element-liste .extrait { color: var(--gris); font-size: .85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.pastille.envoyee { background: #e3f4e8; color: #1b6b35; }
.vue-note:not([hidden]) {
  display: flex; flex-direction: column; gap: 8px;
  height: calc(100dvh - 56px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding-block: 8px;
}
.note-entete { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.etat-note { color: var(--gris); font-size: .8rem; }
.lien.danger { color: var(--rouge); }
.titre-note {
  font: inherit; font-size: 1.15rem; font-weight: 600; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--bord);
  background: transparent; color: var(--texte);
}
.contenu-note {
  flex: 1; min-height: 0; resize: none; width: 100%;
  font: inherit; font-size: 17px; line-height: 1.55; /* 16px minimum : pas de zoom automatique sur iPhone */
  padding: 12px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--texte);
}
.titre-note:focus, .contenu-note:focus { outline: 2px solid var(--bleu); outline-offset: 1px; }
.note-outils { display: flex; gap: 8px; align-items: center; padding-bottom: env(safe-area-inset-bottom, 0px); }
.note-outils .btn-principal { flex: 1; padding: 12px; }
#micro-note.ecoute { background: var(--rouge); border-color: var(--rouge); animation: pulse 1.2s infinite; }
.saisie textarea { font-size: 16px; }
@media (max-width: 430px) {
  .barre h1 { display: none; }
  .barre nav { width: 100%; justify-content: space-between; }
  .barre nav button { padding: 8px 6px; font-size: .95rem; }
}

/* --- Import et photos des notes --- */
.import-notes { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.import-notes > * {
  flex: 1 1 140px; text-align: center; background: var(--surface); color: var(--texte);
  border: 1px solid var(--bord); border-radius: 12px; padding: 10px; cursor: pointer; font-size: .95rem;
}
.photos-note { display: flex; gap: 10px; overflow-x: auto; flex: none; padding: 8px 8px 2px 0; }
.photos-note:empty { display: none; }
.photo-note { position: relative; flex: none; }
.photo-note img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--bord); display: block; }
.photo-note button {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--rouge); color: #fff; font-size: 13px; line-height: 24px; cursor: pointer;
}
.photo-note.envoi img { opacity: .45; }
.doc-mentions .champ-duree { color: var(--texte, #1c2430); font-weight: 600; border-bottom: 1px dashed var(--bleu); padding: 0 2px; }
.doc-mentions .champ-duree:focus { outline: none; background: #fffbe6; }

/* --- Personnalisation (logo, couleur) --- */
.reglage-logo { display: flex; align-items: center; gap: 14px; margin: 8px 0 12px; }
.cadre-logo { width: 140px; height: 70px; border: 1px dashed var(--bord); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; flex-shrink: 0; }
.cadre-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cadre-logo span { color: #6b7684; font-size: .8rem; }
.actions-logo { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.actions-logo .btn { display: inline-block; border: 1px solid var(--bord); border-radius: 12px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.ligne-couleur { display: flex; align-items: center; gap: 10px; }
.ligne-couleur input[type=color] { width: 48px; height: 34px; padding: 0; border: 1px solid var(--bord); border-radius: 8px; background: none; }
.doc-logo { display: block; max-width: 180px; max-height: 80px; object-fit: contain; margin-bottom: 8px; }
.carte .actions-logo label.btn { display: inline-block; margin: 0; color: var(--texte); background: var(--surface, #fff); font-size: .95rem; }
.carte .actions-logo input[type=file] { display: none; }
.carte .ligne-couleur input[type=color] { width: 48px; flex: none; }
div.ligne-couleur { flex-wrap: wrap; margin-bottom: 10px; }
div.ligne-couleur label { margin-bottom: 0; }
#couleur-logo { border: 1px solid var(--bord); border-radius: 12px; padding: 8px 12px; background: var(--surface, #fff); color: var(--texte); font-weight: 600; cursor: pointer; }
.doc-entete .client .champ-email { word-break: break-all; }
.dialogue-envoi h3 { margin: 0 0 10px; }
.ligne-destinataire { display: flex; gap: 6px; margin-bottom: 8px; }
.ligne-destinataire input { flex: 1; min-width: 0; font-size: 1rem; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); color: var(--texte); }
.ligne-destinataire input.invalide { border-color: var(--rouge); }
.ligne-destinataire .retirer { border: 0; background: none; color: var(--gris); font-size: 1.1rem; padding: 0 6px; cursor: pointer; }
.dialogue-envoi .aide { font-size: .8rem; margin: 8px 0 12px; }

/* --- Liste des chantiers --- */
.entete-chantier { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.entete-chantier .titre-chantier { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.btn-secondaire { border: 1px solid var(--bord); border-radius: 12px; padding: 8px 12px; background: var(--surface); color: var(--texte); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-secondaire.actif { background: var(--bleu); border-color: var(--bleu); color: var(--blanc); }
.liste-chantiers .element-liste.courant { border-color: var(--bleu); box-shadow: inset 3px 0 0 var(--bleu); }
.liste-chantiers .suppr-chantier { border: 0; background: none; color: var(--gris); font-size: 1.1rem; padding: 4px 8px; cursor: pointer; }

/* --- Questions de l'IA en cartes --- */
.cartes-questions { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 8px; }
.progression { display: flex; align-items: center; gap: 10px; }
.barre-progression { flex: 1; height: 8px; border-radius: 99px; background: var(--bord); overflow: hidden; }
.barre-progression span { display: block; height: 100%; width: 0; background: var(--vert, #2e9d5b); border-radius: 99px; transition: width .35s ease; }
.progression .compteur { color: var(--gris); font-weight: 600; white-space: nowrap; }
.carte-question { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 12px; transition: border-color .2s, box-shadow .2s; }
.carte-question.repondue { border-color: var(--vert, #2e9d5b); box-shadow: inset 4px 0 0 var(--vert, #2e9d5b); }
.q-entete { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; line-height: 1.35; }
.q-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--bleu); color: var(--blanc); display: grid; place-items: center; font-size: .85rem; }
.q-texte { flex: 1; }
.q-ok { flex: none; color: var(--vert, #2e9d5b); font-size: 1.2rem; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.repondue .q-ok { opacity: 1; transform: scale(1); }
.repondue .q-num { background: var(--vert, #2e9d5b); }
.q-choix { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.puce { border: 1px solid var(--bord); background: var(--fond, transparent); color: var(--texte); border-radius: 99px; padding: 7px 12px; font-size: .9rem; cursor: pointer; transition: transform .1s, background .15s; }
.puce:active { transform: scale(.94); }
.puce.choisie { background: var(--bleu); border-color: var(--bleu); color: var(--blanc); }
.q-reponse { width: 100%; box-sizing: border-box; resize: none; overflow: hidden; font: inherit; font-size: 1rem; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); color: var(--texte); }
.envoyer-reponses { align-self: stretch; padding: 12px; font-size: 1rem; transition: transform .2s; }
.envoyer-reponses.pret { animation: pulse-pret 1.2s ease-in-out 2; }
@keyframes pulse-pret { 50% { transform: scale(1.03); box-shadow: 0 0 0 6px color-mix(in srgb, var(--bleu) 20%, transparent); } }
@media (prefers-reduced-motion: reduce) { .envoyer-reponses.pret { animation: none; } .barre-progression span, .q-ok { transition: none; } }

/* --- Grille de prix en cartes (téléphone) --- */
.recherche-tarifs { width: 100%; box-sizing: border-box; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--texte); margin: 4px 0 8px; }
.groupe-tarifs { margin: 10px 0; }
.groupe-tarifs summary { cursor: pointer; font-weight: 700; color: var(--bleu); padding: 8px 2px; list-style: none; display: flex; align-items: center; gap: 8px; }
.groupe-tarifs summary::-webkit-details-marker { display: none; }
.groupe-tarifs summary::before { content: "▸"; transition: transform .2s; }
.groupe-tarifs[open] summary::before { transform: rotate(90deg); }
.groupe-tarifs .nb { font-size: .75rem; background: var(--bleu-clair); color: var(--bleu); border-radius: 99px; padding: 1px 8px; }
.carte-tarif { border: 1px solid var(--bord); border-radius: 12px; padding: 10px; margin-bottom: 8px; background: var(--surface); }
.carte-tarif textarea[data-k=designation] { width: 100%; box-sizing: border-box; resize: none; overflow: hidden; font: inherit; font-size: 1rem; font-weight: 600; line-height: 1.35; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--texte); }
.carte-tarif textarea[data-k=designation]:focus { border-color: var(--bleu); background: var(--fond); outline: none; }
.ligne-prix { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.carte label.champ-prix { display: flex; align-items: center; gap: 4px; margin: 0; color: var(--gris); }
.carte .champ-prix input { width: 90px !important; font-size: 1.05rem; font-weight: 700; text-align: right; padding: 8px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); color: var(--texte); }
.champ-prix span, .ligne-prix .par { color: var(--gris); font-size: .9rem; white-space: nowrap; }
.ligne-prix select { flex: 1; min-width: 0; font-size: 1rem; padding: 8px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); color: var(--texte); }
.suppr-tarif { border: 0; background: none; font-size: 1.1rem; padding: 6px; cursor: pointer; }
.carte-tarif .choix-metier { width: 100%; margin-top: 8px; font-size: .85rem; padding: 6px 8px; border: 1px dashed var(--bord); border-radius: 8px; color: var(--gris); background: transparent; }
.carte-tarif .doublon { margin: 4px 8px 0; font-size: .8rem; color: #9a6700; }

/* --- Suivi des devis et factures --- */
.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tuile { text-align: left; border: 1px solid var(--bord); border-radius: 14px; padding: 10px 12px; background: var(--surface); color: var(--texte); cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tuile small { color: var(--gris); font-size: .78rem; }
.tuile strong { font-size: 1.15rem; }
.tuile span { color: var(--gris); font-size: .75rem; }
.tuile.actif { border-color: var(--bleu); box-shadow: inset 0 0 0 1px var(--bleu); }
.tuile.alerte strong { color: var(--rouge); }
.filtres-docs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.filtres-docs .puce { white-space: nowrap; flex: none; }
.filtres-docs .puce b { margin-left: 2px; opacity: .7; }
.carte-doc { flex-direction: column; align-items: stretch !important; gap: 6px; }
.carte-doc .ligne-doc { display: flex; justify-content: space-between; gap: 10px; }
.carte-doc .etat-doc { color: var(--gris); font-size: .85rem; }
.carte-doc .a-relancer { color: var(--rouge); font-weight: 600; }
.actions-doc { display: flex; gap: 8px; flex-wrap: wrap; }
.action-doc { border: 1px solid var(--bord); background: var(--surface); color: var(--texte); border-radius: 10px; padding: 8px 12px; font-weight: 600; cursor: pointer; }
.action-doc.principal { background: var(--bleu); border-color: var(--bleu); color: var(--blanc); }
.pastille.statut-accepte, .pastille.statut-payee { background: #e3f4ea; color: #1e7a45; }
.pastille.statut-refuse { background: #fbe9e9; color: #a12b2b; }
.pastille.statut-envoye, .pastille.statut-emise { background: #fff4dc; color: #8a5a00; }
.carte-doc.statut-refuse { opacity: .7; }

/* --- Carnet de clients --- */
.entete-clients { display: flex; gap: 8px; margin-bottom: 8px; }
.entete-clients input { flex: 1; min-width: 0; font-size: 1rem; padding: 10px 12px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--texte); }
.contact-telephone { width: 100%; margin-bottom: 10px; }
.carte-client { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.client-entete { display: flex; gap: 10px; align-items: center; }
.client-entete small { display: block; color: var(--gris); font-size: .8rem; }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--bleu-clair); color: var(--bleu); display: grid; place-items: center; font-weight: 700; }
.client-coordonnees { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.client-coordonnees a { color: var(--texte); text-decoration: none; padding: 4px 0; word-break: break-word; }
.client-notes { margin: 0; color: var(--gris); font-size: .85rem; white-space: pre-line; }
.vide-clients { text-align: center; padding: 30px 10px; }
.fiche-client label { display: block; margin-bottom: 10px; font-size: .9rem; color: var(--gris); }
.fiche-client input, .fiche-client textarea { display: block; width: 100%; box-sizing: border-box; margin-top: 4px; font: inherit; font-size: 1rem; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); color: var(--texte); }
.fiche-client h3, .choix-client h3 { margin-top: 0; }
.danger-texte { color: var(--rouge) !important; margin-right: auto; }
.dialogue { max-height: 90vh; overflow-y: auto; }
.recherche-choix { width: 100%; box-sizing: border-box; font-size: 1rem; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 10px; margin-bottom: 8px; background: var(--surface); color: var(--texte); }
.liste-choix { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.liste-choix button { text-align: left; border: 1px solid var(--bord); border-radius: 10px; padding: 10px; background: var(--surface); color: var(--texte); cursor: pointer; }
.liste-choix small { display: block; color: var(--gris); }
@media (max-width: 420px) { .barre nav button { padding: 8px 4px; font-size: .85rem; } }


/* =====================================================================
   Refonte « Cagot Pro » : barre du haut, onglets en bas, accueil
   ===================================================================== */
body { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px)); }
.barre { background: var(--bleu); padding: 12px 16px; }
.barre .logo { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 800; letter-spacing: .2px; margin: 0; }
.barre .logo svg { width: 28px; height: 26px; fill: none; stroke: var(--or); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.barre .logo span { color: var(--or); }
.btn-reglages { background: rgba(255,255,255,.12); border: 0; color: #fff; font-size: 1.1rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.btn-reglages.actif { background: rgba(255,255,255,.28); }
@media (max-width: 430px) { .barre h1.logo { display: flex !important; } }

.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; gap: 2px;
  height: calc(var(--nav) + env(safe-area-inset-bottom, 0px)); padding: 6px 6px env(safe-area-inset-bottom, 0px);
  background: var(--surface); border-top: 1px solid var(--bord); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.onglets[hidden] { display: none; }
.onglets button {
  flex: 1; max-width: 90px; border: 0; background: transparent; color: var(--gris); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; font-weight: 600; cursor: pointer;
}
.onglets svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglets #onglet-plus svg { fill: currentColor; stroke: none; }
.onglets button.actif { background: var(--bleu); color: #fff; }
.feuille-plus { position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.25); }
.feuille-plus[hidden] { display: none; }
.feuille { position: absolute; right: 10px; bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px) + 8px); background: var(--surface); border-radius: 16px; padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); display: flex; flex-direction: column; min-width: 200px; }
.feuille button { text-align: left; border: 0; background: none; color: var(--texte); padding: 12px 14px; font-size: 1rem; border-radius: 10px; cursor: pointer; }
.feuille button:active { background: var(--fond); }

/* Hauteurs plein écran en tenant compte des onglets */
#vue-chantier { min-height: calc(100dvh - 64px - var(--nav)); }
.saisie { bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px)); }
.vue-note:not([hidden]) { height: calc(100dvh - 64px - var(--nav) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }

/* Accueil */
.accueil-entete { background: linear-gradient(135deg, var(--bleu), #2c5288); color: #fff; margin: -16px -16px 14px; padding: 20px 18px 26px; border-radius: 0 0 22px 22px; }
.accueil-entete h2 { margin: 0; font-size: 1.5rem; }
.accueil-entete p { margin: 4px 0 0; opacity: .85; text-transform: uppercase; letter-spacing: .5px; font-size: .85rem; }
#activite-accueil { margin-top: -6px; }
.btn-devis-rapide { width: 100%; border: 0; border-radius: 16px; padding: 16px; font-size: 1.15rem; font-weight: 800; color: #fff; background: linear-gradient(180deg, #38a05c, var(--vert)); box-shadow: 0 6px 16px rgba(47,138,78,.35); cursor: pointer; margin: 4px 0 6px; }
.btn-devis-rapide:active { transform: scale(.98); }
.titre-section { margin: 18px 2px 10px; font-size: 1.1rem; }
.ligne-titre { display: flex; justify-content: space-between; align-items: center; }
.ligne-titre h3 { margin: 0; font-size: 1.1rem; }
.raccourcis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.raccourcis button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border: 1px solid var(--bord); border-radius: 14px; background: var(--surface); color: var(--texte); font-size: .8rem; font-weight: 600; cursor: pointer; }
.raccourcis button span { font-size: 1.5rem; }
.carte-chantier { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; border: 1px solid var(--bord); border-radius: 14px; background: var(--surface); color: var(--texte); margin-bottom: 8px; cursor: pointer; }
.carte-chantier > span:nth-child(2) { flex: 1; min-width: 0; }
.carte-chantier strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carte-chantier small { color: var(--gris); }
.icone-chantier { width: 44px; height: 44px; border-radius: 12px; background: var(--bleu-clair); display: grid; place-items: center; font-size: 1.4rem; flex: none; }
.tuile { box-shadow: 0 2px 8px rgba(0,0,0,.04); }

/* Segments (Avec l'IA / Mes notes) */
.segments { display: flex; background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.segments button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--gris); cursor: pointer; }
.segments button.actif { background: var(--bleu); color: #fff; }

/* Listes Devis / Factures */
.entete-documents { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.entete-documents h2 { margin: 0; }
.btn-or, .entete-clients .btn-principal { background: var(--vert); border: 0; color: #fff; font-weight: 700; border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.tuiles:has(> :only-child), .tuiles:has(> :nth-child(2):last-child) { grid-template-columns: 1fr 1fr; }

/* Fiche document */
.entete-document { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.entete-document #retour { font-size: 1.4rem; text-decoration: none; padding: 4px 8px; }
.titre-document { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge-statut { font-size: .8rem; font-weight: 700; padding: 3px 12px; border-radius: 99px; background: var(--bleu-clair); color: var(--bleu); }
.badge-statut.statut-accepte, .badge-statut.statut-payee { background: #e3f4ea; color: #1e7a45; }
.badge-statut.statut-envoye, .badge-statut.statut-emise { background: #fff4dc; color: #8a5a00; }
.badge-statut.statut-refuse { background: #fbe9e9; color: #a12b2b; }
.menu-plus { position: relative; }
.menu-plus summary { list-style: none; font-size: 1.5rem; padding: 2px 10px; cursor: pointer; border-radius: 10px; }
.menu-plus summary::-webkit-details-marker { display: none; }
.menu-plus-liste { position: absolute; right: 0; top: 110%; z-index: 15; background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 6px; min-width: 210px; display: flex; flex-direction: column; }
.menu-plus-liste button { text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 9px; font-size: .95rem; color: var(--texte); cursor: pointer; }
.menu-plus-liste button[hidden] { display: none; }
.menu-plus-liste .danger { color: var(--rouge); }
.barre-actions-doc { position: sticky; bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px)); background: var(--fond); padding: 10px 0 6px; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.outils-doc { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.outils-doc button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border: 1px solid var(--bord); border-radius: 12px; background: var(--surface); color: var(--texte); font-size: .75rem; font-weight: 600; cursor: pointer; }
.outils-doc button[hidden] { display: none; }
.outils-doc button span { font-size: 1.2rem; }
.btn-action-principale { border: 0; border-radius: 14px; padding: 14px; font-size: 1.05rem; font-weight: 800; color: #fff; background: var(--vert); cursor: pointer; }
.btn-action-principale[hidden] { display: none; }

/* Réglages en onglets */
.onglets-reglages { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.onglets-reglages button { flex: none; border: 1px solid var(--bord); background: var(--surface); color: var(--texte); border-radius: 99px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.onglets-reglages button.actif { background: var(--bleu); border-color: var(--bleu); color: #fff; }
#form-entreprise[hidden], [data-panneau][hidden] { display: none; }
.btn-enregistrer { width: 100%; margin-top: 8px; padding: 13px; }

/* Boutons principaux en vert (actions), le bleu reste la couleur de structure */
.btn-principal { background: var(--vert); }
.bulle.moi { background: var(--bleu); }
@media print { .onglets, .feuille-plus, .barre-actions-doc, .entete-document { display: none !important; } body { padding: 0; } }
/* Barre d'actions du document : compacte */
.barre-actions-doc { padding: 6px 0 4px; gap: 6px; }
.outils-doc button { flex-direction: row; justify-content: center; gap: 4px; padding: 7px 2px; font-size: .72rem; }
.outils-doc button span { font-size: 1rem; }
.btn-action-principale { padding: 11px; font-size: 1rem; }
.choix-unite { border: 1px dashed var(--bord); background: none; color: inherit; font: inherit; padding: 2px 6px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.grille-unites { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.grille-unites .puce { min-width: 64px; font-size: 1rem; }
.unite-libre { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--gris); }
.unite-libre input { flex: 1; font-size: 1rem; padding: 8px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); color: var(--texte); }
@media print { .choix-unite { border: 0; padding: 0; } }

/* --- Scanner un plan : métré --- */
.piece-pdf { display: inline-block; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.2); font-weight: 600; }
.apercu-photos .piece-pdf { background: var(--bleu-clair); color: var(--bleu); }
.carte-metre { background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 12px; align-self: stretch; }
.metre-titre { font-weight: 800; font-size: 1.05rem; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.metre-titre small { color: var(--gris); font-weight: 600; }
.table-metre { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-metre th { text-align: left; color: var(--gris); font-weight: 600; padding: 4px; }
.table-metre td { padding: 4px; vertical-align: top; border-top: 1px solid var(--bord); }
.table-metre td:nth-child(2), .table-metre td:nth-child(3) { width: 74px; }
.table-metre input { width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem; padding: 6px; border: 1px solid var(--bord); border-radius: 8px; background: var(--surface); color: var(--texte); }
.table-metre td:nth-child(2) input, .table-metre td:nth-child(3) input { text-align: right; }
.table-metre small { display: block; color: var(--gris); font-size: .72rem; margin-top: 2px; }
.table-metre .source-estime small { color: #9a6700; }
.table-metre tfoot td { font-weight: 800; padding-top: 8px; text-align: right; }
.table-metre tfoot td:first-child { text-align: left; }

/* --- Chantiers : liste et fiche en étapes --- */
.centre { text-align: center; }
.carte-fiche { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; padding: 14px; margin-bottom: 10px; border: 1px solid var(--bord); border-radius: 16px; background: var(--surface); color: var(--texte); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.carte-fiche.fini { opacity: .75; }
.ligne-fiche { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ligne-fiche strong { font-size: 1.05rem; }
.ligne-fiche b { white-space: nowrap; }
.carte-fiche small { color: var(--gris); }
.progression-fiche { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.progression-fiche i { height: 6px; border-radius: 99px; background: var(--bord); }
.progression-fiche i.fait { background: var(--vert); }
.progression-fiche i.en-cours { background: var(--or); }
.sous-titre-fiche { color: var(--gris); font-size: .85rem; }
.etapes { list-style: none; margin: 0 0 14px; padding: 0; position: relative; }
.etape { display: flex; gap: 12px; padding: 0 0 18px; position: relative; }
.etape:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2px; background: var(--bord); }
.etape.fait:not(:last-child)::before { background: var(--vert); }
.pastille-etape { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface); border: 2px solid var(--bord); color: var(--gris); z-index: 1; }
.etape.fait .pastille-etape { background: var(--vert); border-color: var(--vert); color: #fff; }
.etape.en-cours .pastille-etape { background: var(--or); border-color: var(--or); color: #1c2430; }
.corps-etape { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--bord); border-radius: 14px; padding: 12px; }
.etape.en-cours .corps-etape { border-color: var(--or); box-shadow: 0 0 0 2px color-mix(in srgb, var(--or) 25%, transparent); }
.etape.a-venir .corps-etape { opacity: .6; }
.corps-etape strong { font-size: 1rem; }
.corps-etape p { margin: 4px 0 8px; color: var(--gris); font-size: .9rem; overflow-wrap: anywhere; }
.corps-etape p strong { color: var(--texte); }
.action-doc:disabled { opacity: .45; cursor: default; }
#etape-suivante { position: sticky; bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px) + 8px); width: 100%; box-shadow: 0 6px 16px rgba(47,138,78,.35); }
#etape-suivante[hidden] { display: none; }
.entete-chantier #retour-conversation { text-decoration: none; font-weight: 600; white-space: nowrap; }
.bulle .btn-secondaire { margin-top: 8px; }
.bandeau.hors-ligne { background: #263548; color: #fff; font-weight: 600; position: sticky; top: 64px; z-index: 9; }

/* --- Options et devis interactif --- */
.badge-option { display: inline-block; margin-top: 4px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #fff4dc; color: #8a5a00; }
.doc-table tr.non-retenue td { color: var(--gris); }
.bascule-option { display: block; font-size: .78rem; margin-top: 2px; }
.signature-client { display: block; max-width: 260px; max-height: 90px; margin-top: 8px; background: #fff; border: 1px solid var(--bord); border-radius: 8px; }
.page-client { padding-bottom: 24px; }
.vue-client { max-width: 760px; }
.vue-client .carte { margin-top: 14px; }
.option-client { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--bord); border-radius: 12px; margin-bottom: 8px; background: var(--surface); cursor: pointer; }
.option-client input { width: 24px; height: 24px; margin: 2px 0 0; flex: none; }
.option-client small { display: block; color: var(--gris); margin-top: 2px; }
.pad-signature { width: 100%; height: auto; aspect-ratio: 600 / 220; background: #fff; border: 2px dashed var(--bord); border-radius: 12px; touch-action: none; }
.case-accord { display: flex !important; gap: 10px; align-items: flex-start; margin: 12px 0; color: var(--texte) !important; }
.case-accord input { width: 22px; height: 22px; flex: none; margin: 0; }
.total-a-signer { font-size: 1.1rem; }
.vue-client #signer { width: 100%; }
.vue-client .btn-principal { width: 100%; padding: 13px; margin-top: 12px; }
.page-client .toast { position: fixed; }

/* --- Ma boîte mail --- */
.boite-ok { background: #e3f4ea; color: #1e7a45; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.boite-ok small { color: #2d6a45; }
.aide-boite { background: var(--bleu-clair); border-radius: 12px; padding: 4px 12px; margin: 4px 0 12px; font-size: .9rem; }
.aide-boite ol { padding-left: 20px; margin: 6px 0; }
.aide-boite li { margin-bottom: 4px; }
#form-boite select { width: 100%; font-size: 1rem; padding: 9px; border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); color: var(--texte); margin-top: 4px; }
