/* « Mes devis » (Pack « Zéro devis oublié ») : complète espace.css. Pensé d'abord pour le téléphone (artisan sur chantier).
   Couleurs des statuts et des badges reprises de la démo du pack (même univers visuel). Aucun style en ligne (CSP). */

/* ---------------------------------------------------------------- État de l'automatisation */
.etat-auto { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; padding: 7px 14px 7px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 700; background: rgba(46, 230, 166, .14); color: var(--menthe); }
.etat-auto i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.etat-auto[data-etat="actif"] i { animation: pulse 2s infinite; box-shadow: 0 0 0 0 rgba(46, 230, 166, .6); }
.etat-auto[data-etat="pause"] { background: rgba(255, 184, 77, .16); color: #ffc46b; }
.etat-auto[data-etat="pause"] i { border-radius: 2px; width: 8px; height: 10px; background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65%); }
.etat-auto[data-etat="alerte"] { background: rgba(255, 107, 94, .16); color: #ff8a7e; }
.etat-auto[data-etat="test"], .etat-auto[data-etat="attente"] { background: rgba(255, 255, 255, .1); color: #dfe3ec; }
.synchro { display: block; font-size: 12.5px; color: #9aa1b2; margin-top: 8px; }

/* ---------------------------------------------------------------- Bandeaux d'information */
.bandeau { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.bandeau svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.bandeau.file { background: #fff6e5; color: #6b4e00; border: 1px solid #f6dfa8; }
.bandeau.alerte { background: #fdecec; color: #8f241c; border: 1px solid #f3c3bd; }
.bandeau.info { background: var(--bleu-doux); color: #1d2f8f; }
.bandeau.pause { background: #fff1e5; color: #7a4100; border: 1px solid #f7d2ae; }
.bandeau strong { font-weight: 700; }
.autres-messages { margin-top: -10px; font-size: 13px; color: var(--ardoise); }
.autres-messages summary { cursor: pointer; padding: 2px 4px; width: max-content; }
.autres-messages .bandeau { margin-top: 8px; }

/* ---------------------------------------------------------------- Indicateurs */
/* 3 chiffres essentiels (le chiffre d'affaires sauvé en vedette), puis une ligne discrète pour les autres. */
.kpis-devis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis-devis .kpi { padding: 20px 22px; gap: 6px; }
.kpi.fort { background: var(--encre); color: #fff; }
.kpi.fort .kpi-tete, .kpi.fort .kpi-aide { color: #b9bfcc; }
.kpi.fort .kpi-valeur { color: var(--menthe); }
.kpi.fort .kpi-icone { background: rgba(46, 230, 166, .16); color: var(--menthe); }
.kpis-plus { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: -6px 4px 0; font-size: 13.5px; color: var(--ardoise); }
.kpis-plus span { display: inline-flex; align-items: center; gap: 6px; }
.kpis-plus svg { width: 15px; height: 15px; flex: none; color: var(--gris); }
.kpis-plus b { color: var(--encre); font-weight: 700; }

/* ---------------------------------------------------------------- Liste des devis */
.carte-devis { padding-bottom: 8px; }
.outils-devis { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 4px 0 12px; }
.filtres { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filtres::-webkit-scrollbar { display: none; }
.filtres button { flex: none; border: 1px solid var(--bordure); background: #fff; color: var(--ardoise); font: 700 13.5px var(--texte); padding: 8px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.filtres button[aria-pressed="true"] { background: var(--encre); color: #fff; border-color: var(--encre); }
.filtres button span { font-weight: 600; opacity: .7; margin-left: 4px; }
.recherche { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.recherche input { width: 100%; font: 400 14.5px var(--texte); padding: 10px 14px 10px 36px; border: 1px solid var(--bordure); border-radius: 999px; background: var(--nuage); color: var(--encre); }
.recherche input:focus { outline: 2px solid var(--bleu); background: #fff; border-color: transparent; }
.recherche svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--gris); }

.liste-devis { display: flex; flex-direction: column; }
.entete-liste { display: none; }
.devis-ligne { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "client client montant" "statut proch proch"; gap: 6px 10px; align-items: center; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--bordure); background: transparent; padding: 14px 4px; font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
.devis-ligne:first-of-type { border-top: 0; }
.devis-ligne:hover { background: #f8f9fc; }
.devis-ligne:focus-visible { outline-offset: -2px; border-radius: 10px; }
.dl-client { grid-area: client; min-width: 0; }
.dl-client strong { display: block; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-montant { grid-area: montant; font-family: var(--titres); font-weight: 600; font-size: 15px; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.dl-statut { grid-area: statut; display: flex; gap: 6px; align-items: center; min-width: 0; }
.dl-proch { grid-area: proch; min-width: 0; font-size: 13px; color: var(--ardoise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-proch strong { color: var(--encre); font-weight: 700; }
.dl-proch em { font-style: normal; font-weight: 700; color: #7a4100; }
.dl-proch.arret { color: #8f241c; }
.dl-proch.fini { color: var(--gris); }
.devis-ligne.fantome { opacity: .75; background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(59, 91, 255, .04) 10px 20px); }

.puce { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; line-height: 1.3; white-space: nowrap; }
.st-envoye { background: #e8eaed; color: #3c4043; }
.st-discussion { background: #ffe5a0; color: #6b4e00; }
.st-signe { background: #d4edbc; color: #11734b; }
.st-perdu { background: #ffcfc9; color: #b10202; }
.st-termine { background: #bfe1f6; color: #0a53a8; }
.marque { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.marque.envoi { background: var(--bleu-doux); color: var(--bleu-fonce); }
.marque.envoi::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: tourne 0.8s linear infinite; }
.marque.file { background: #fff1cc; color: #6b4e00; }
.marque.ok { background: var(--menthe-doux); color: #0b6b4b; }
.marque.ko { background: #fdecec; color: var(--rouge); }
.marque.avis { background: var(--menthe-doux); color: #0b6b4b; }
@keyframes tourne { to { transform: rotate(360deg); } }
.points { display: inline-flex; gap: 3px; vertical-align: -1px; margin-right: 4px; }
.points i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #9aa0a6; }
.points i.ok { background: var(--bleu); border-color: var(--bleu); }
.liste-vide { padding: 26px 12px; text-align: center; color: var(--ardoise); font-size: 14px; }
.plus-devis { display: block; margin: 10px auto 6px; }

/* ---------------------------------------------------------------- Calendrier des envois */
.calendrier { display: grid; grid-template-columns: auto repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 14px; }
.calendrier .jsem { font-size: 11.5px; font-weight: 700; color: var(--gris); text-align: center; text-transform: uppercase; }
.calendrier .sem { font-size: 11px; color: var(--gris); align-self: center; padding-right: 6px; white-space: nowrap; }
.jour { border: 0; background: var(--nuage); border-radius: 10px; min-height: 52px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 4px; font: 700 14px var(--texte); color: var(--encre); cursor: pointer; }
.jour.weekend { background: #f7f8fb; color: var(--gris); }
.jour.passe { color: var(--ardoise); }
.jour.auj { background: var(--encre); color: #fff; }
.jour[aria-pressed="true"] { outline: 2px solid var(--bleu); outline-offset: 1px; }
.jour .pts { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 34px; min-height: 7px; }
.jour .pts i { width: 7px; height: 7px; border-radius: 50%; }
.pt-envoye { background: var(--menthe); }
.pt-prevu { background: var(--bleu); }
.jour.auj .pt-prevu { background: #8ea2ff; }
.legende-cal { display: flex; gap: 14px; font-size: 12.5px; color: var(--ardoise); margin: -2px 0 10px; flex-wrap: wrap; }
.legende-cal i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.sous-onglets { display: inline-flex; background: var(--nuage); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 10px; }
.sous-onglets button { border: 0; background: transparent; font: 700 13.5px var(--texte); color: var(--ardoise); padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.sous-onglets button[aria-pressed="true"] { background: #fff; color: var(--encre); box-shadow: 0 1px 3px rgba(17, 19, 24, .12); }
.fil-emails { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 420px; overflow: auto; }
.fil-emails .date-groupe { font-size: 12px; font-weight: 700; color: var(--ardoise); text-transform: uppercase; letter-spacing: .04em; padding: 10px 0 4px; }
.fil-emails .date-groupe:first-child { padding-top: 0; }
.email-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: #fafbfd; border: 1px solid var(--bordure); }
.email-item strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item small { grid-column: 2; font-size: 12.5px; color: var(--ardoise); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-item.en-pause { opacity: .55; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; font-size: 11.5px; font-weight: 800; padding: 3px 7px; border-radius: 6px; white-space: nowrap; grid-row: span 2; }
.b-j3 { background: #e8ecff; color: var(--bleu-fonce); }
.b-j7 { background: var(--bleu); color: #fff; }
.b-j14 { background: var(--encre); color: #fff; }
.b-avis { background: var(--menthe); color: var(--encre); }
.b-rappel { background: var(--menthe-doux); color: #0b6b4a; }

/* ---------------------------------------------------------------- Automatisation */
.auto-ligne { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--bordure); font-size: 14px; }
.auto-ligne:first-of-type { border-top: 0; }
.auto-ligne span { color: var(--ardoise); }
.auto-ligne b { text-align: right; }
.auto-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.bouton.attention { background: #fff; color: #7a4100; border: 1px solid #f0c48f; }
.bouton.attention:hover { background: #fff6ec; }
.bouton.vert { background: var(--menthe); color: var(--encre); }
.bouton.vert:hover { background: #22d398; }
.reference { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--nuage); font-size: 13px; color: var(--ardoise); }
.reference svg { width: 20px; height: 20px; flex: none; }

/* ---------------------------------------------------------------- Fiche d'un devis, formulaire (fenêtre) */
.feuille { border: 0; padding: 0; width: min(560px, 100%); max-height: min(92vh, 900px); border-radius: 20px; box-shadow: 0 24px 70px rgba(17, 19, 24, .35); color: var(--encre); background: #fff; }
.feuille::backdrop { background: rgba(17, 19, 24, .55); }
.feuille[open] { animation: monte .22s ease; }
@keyframes monte { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.feuille-corps { padding: 20px 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.feuille-tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.feuille-tete h2 { font-size: 20px; overflow-wrap: anywhere; }
.feuille-tete p { margin: 3px 0 0; color: var(--ardoise); font-size: 14px; overflow-wrap: anywhere; }
.feuille-tete .surtitre-fiche { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bleu); }
.fermer { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--nuage); font-size: 22px; line-height: 1; cursor: pointer; color: var(--encre); }
.infos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.infos div { background: var(--nuage); border-radius: 12px; padding: 9px 12px; min-width: 0; }
.infos dt { font-size: 12px; color: var(--ardoise); font-weight: 600; }
.infos dd { margin: 2px 0 0; font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.choix { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choix .bouton { padding: 13px 10px; font-size: 14.5px; }
.choix .bouton.large { grid-column: 1 / -1; }
.choix .bouton.neutre { background: var(--nuage); color: var(--encre); }
.choix .bouton.neutre:hover { background: #e4e7ef; }
.choix .bouton.danger { background: #fff; color: var(--rouge); border: 1px solid #f3c3bd; }
.choix .bouton.danger:hover { background: #fff6f5; }
.sous-titre-fiche { font-size: 14px; margin: 4px 0 -4px; }
.emails-devis { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.emails-devis li { display: flex; gap: 10px; align-items: center; }
.emails-devis .badge { grid-row: auto; }
.emails-devis .prevu { color: var(--ardoise); }
.note-fiche { font-size: 12.5px; color: var(--ardoise); margin: 0; }
.formulaire-devis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.formulaire-devis .champ.large { grid-column: 1 / -1; }
.formulaire-devis .champ small { font-weight: 400; color: var(--ardoise); font-size: 12.5px; }
.champ textarea { font: 400 15px var(--texte); padding: 12px 14px; border: 1px solid var(--bordure); border-radius: 12px; resize: vertical; }
.champ select:focus, .champ textarea:focus { outline: 2px solid var(--bleu); border-color: transparent; }
.radios { display: flex; gap: 8px; }
.radios label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px; border: 1px solid var(--bordure); border-radius: 12px; font-weight: 700; cursor: pointer; }
.radios label:has(input:checked) { border-color: var(--bleu); background: var(--bleu-doux); color: var(--bleu-fonce); }
.erreur-form { grid-column: 1 / -1; }
.boutons-fin { display: flex; gap: 10px; justify-content: flex-end; grid-column: 1 / -1; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Bouton flottant (téléphone) et messages */
.bouton-flottant { display: none; }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(460px, calc(100% - 28px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--encre); color: #fff; padding: 12px 16px; border-radius: 14px; box-shadow: 0 12px 30px rgba(17, 19, 24, .3); font-size: 14px; line-height: 1.45; animation: monte .25s ease; }
.toast i { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--menthe); }
.toast.file i { background: #ffc46b; }
.toast.ko i { background: #ff8a7e; }
.toast.part { opacity: 0; transition: opacity .4s; }

/* ---------------------------------------------------------------- Ordinateur : liste en tableau */
@media (min-width: 900px) {
  .entete-liste { display: grid; grid-template-columns: minmax(0, 2.2fr) 120px 200px minmax(0, 1.8fr); gap: 16px; padding: 0 12px 10px; font-size: 12px; font-weight: 700; color: var(--ardoise); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--bordure); }
  .entete-liste span:nth-child(2) { text-align: right; }
  .devis-ligne { grid-template-columns: minmax(0, 2.2fr) 120px 200px minmax(0, 1.8fr); grid-template-areas: "client montant statut proch"; gap: 16px; padding: 16px 12px; }
  .devis-ligne:first-of-type { border-top: 0; }
}

@media (max-width: 960px) {
  .grille-devis { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .onglets-espace { padding: 0 14px; }
  .entete-titre { padding-top: 12px; padding-bottom: 26px; }
  .kpis-devis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis-devis .kpi { padding: 14px; }
  .kpis-devis .kpi.fort { grid-column: 1 / -1; }
  .kpis-plus { margin-top: -4px; gap: 4px 16px; font-size: 13px; }
  .kpis-devis .kpi-valeur { font-size: 22px; }
  .kpis-devis .kpi-icone { width: 28px; height: 28px; }
  .carte { padding: 16px 14px; }
  .titre-ligne #ajouter { display: none; }
  .recherche { max-width: none; min-width: 100%; order: -1; }
  .bouton-flottant { display: inline-flex; position: fixed; right: 16px; bottom: 18px; z-index: 40; box-shadow: 0 10px 26px rgba(59, 91, 255, .45); padding: 15px 20px; font-size: 15.5px; }
  .contenu-devis { padding-bottom: 96px; }
  .toasts { bottom: 86px; }
  .feuille { width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .feuille[open] { animation: glisse .25s ease; }
  .formulaire-devis { grid-template-columns: minmax(0, 1fr); }
  .calendrier .sem { display: none; }
  .calendrier { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .entete-barre .qui .bouton { padding: 6px 11px; font-size: 13px; }
}
@keyframes glisse { from { transform: translateY(40px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
