/* MisterClean38 — interface mobile : blanc et bleu de la marque.
   Pensée pour un iPhone tenu d'une main : onglets en bas, gros boutons.
   Aucun style en ligne dans les gabarits : la politique de sécurité du
   contenu les interdit (style-src 'self'). */

:root {
  color-scheme: light;
  --bleu-logo: #60b8f4;          /* fond du logo */
  --bleu: #0a7bc4;               /* boutons, liens : lisible sur blanc */
  --bleu-fonce: #075f98;
  --marine: #0d2659;             /* titres, comme sur les devis */
  --bleu-pale: #eaf5fd;
  --bleu-ciel: #cfe8fa;
  --cyan: #52b6c2;
  --fond: #f3f7fb;
  --carte: #ffffff;
  --texte: #14213d;
  --doux: #6b7a90;
  --ligne: #e3eaf2;
  --vert: #1e9e6a;
  --vert-pale: #e3f6ee;
  --orange: #d9822b;
  --orange-pale: #fdf1e3;
  --rouge: #d64545;
  --rouge-pale: #fcebeb;
  --violet: #6f5cd6;
  --violet-pale: #efecfc;
  --rayon: 16px;
  --ombre: 0 1px 2px rgba(13, 38, 89, .06), 0 4px 16px rgba(13, 38, 89, .06);
  --barre-bas: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
a { color: var(--bleu); }
h1, h2, h3 { color: var(--marine); }
.ic { flex: none; display: block; }

/* --- Barre du haut ---------------------------------------------------------- */
.entete-app {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ligne);
}
.entete-app h1 { flex: 1; margin: 0; font-size: 1.15rem; font-weight: 700; overflow: hidden;
                 text-overflow: ellipsis; white-space: nowrap; }
.entete-app .retour { display: flex; align-items: center; margin-left: -8px; padding: 6px; border-radius: 10px;
                      color: var(--bleu); text-decoration: none; font-weight: 600; }
.entete-app .action-haut { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
                           color: var(--bleu); background: var(--bleu-pale); text-decoration: none; }

main { max-width: 640px; margin: 0 auto;
       padding: 16px 16px calc(var(--barre-bas) + env(safe-area-inset-bottom) + 28px); }

/* --- Onglets en bas ---------------------------------------------------------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--barre-bas) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96); backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--ligne);
}
.onglets a { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--doux);
             text-decoration: none; font-size: .7rem; font-weight: 600; position: relative; }
.onglets a[aria-current="page"] { color: var(--bleu); }
.onglets a[aria-current="page"]::before { content: ""; position: absolute; top: 0; width: 32px; height: 3px;
                                          border-radius: 0 0 3px 3px; background: var(--bleu); }
.onglets .pastille { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px;
                     padding: 0 5px; border-radius: 9px; background: var(--rouge); color: #fff;
                     font-size: .68rem; line-height: 18px; text-align: center; }

/* Bouton flottant (ajouter un prospect) */
.flottant {
  position: fixed; right: 18px; z-index: 25;
  bottom: calc(var(--barre-bas) + env(safe-area-inset-bottom) + 16px);
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px;
  background: var(--bleu); color: #fff; box-shadow: 0 6px 20px rgba(10, 123, 196, .35); text-decoration: none;
}

/* --- Éléments communs ---------------------------------------------------------- */
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; }
.carte + .carte, .carte + .section, .section + .carte { margin-top: 14px; }
.carte > p:first-child, .carte > .bloc-titre:first-child { margin-top: 0; }
.carte > p:last-child { margin-bottom: 0; }
.section { margin-top: 22px; }
.titre-section { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.titre-section h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.titre-section a { font-size: .9rem; font-weight: 600; text-decoration: none; }
.aide, .vide { color: var(--doux); }
.vide { text-align: center; padding: 28px 16px; }
.erreur { color: var(--rouge); font-weight: 600; }
.succes { color: var(--vert); font-weight: 600; }
.petit { font-size: .85rem; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--ligne); border-radius: 12px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--bleu); box-shadow: 0 0 0 3px var(--bleu-ciel); }
label { display: grid; gap: 6px; font-weight: 600; color: var(--marine); font-size: .92rem; }
.pile { display: grid; gap: 14px; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 12px 18px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 700;
  background: var(--bleu-pale); color: var(--bleu); text-decoration: none; list-style: none;
}
.bouton::-webkit-details-marker { display: none; }
.bouton.principal { background: var(--bleu); color: #fff; width: 100%; }
.bouton.principal:active { background: var(--bleu-fonce); }
.bouton.danger { background: var(--rouge); color: #fff; width: 100%; }
.bouton.discret { background: transparent; color: var(--bleu); }
.bouton.plein { width: 100%; }
.bouton[disabled], .htmx-request .bouton { opacity: .6; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px;
  border: 1px solid var(--ligne); background: #fff; color: var(--texte); font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; list-style: none;
}
.puce::-webkit-details-marker { display: none; }
.puce[aria-pressed="true"], .puce.active { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.defile { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px;
          scrollbar-width: none; }
.defile::-webkit-scrollbar { display: none; }
.masque { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

/* Étapes : couleur par étape */
.etape { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: .78rem;
         font-weight: 700; white-space: nowrap; background: var(--bleu-pale); color: var(--bleu); }
.etape-nouveau { background: var(--violet-pale); color: var(--violet); }
.etape-infos_demandees { background: var(--orange-pale); color: var(--orange); }
.etape-devis_envoye { background: var(--bleu-pale); color: var(--bleu); }
.etape-rdv_pris { background: #e0f4f6; color: #23848f; }
.etape-fait, .etape-avis_demande { background: var(--vert-pale); color: var(--vert); }
.etape-perdu { background: var(--rouge-pale); color: var(--rouge); }
.etape-archive { background: #eef1f5; color: var(--doux); }

.avatar { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%;
          background: var(--bleu-ciel); color: var(--marine); font-weight: 800; font-size: .95rem; }
.avatar.grand { width: 64px; height: 64px; font-size: 1.3rem; }

/* --- Connexion ---------------------------------------------------------------- */
.page-connexion { min-height: 100vh; background: linear-gradient(180deg, var(--bleu-logo) 0%, #9dd3f8 38%, var(--fond) 72%); }
.page-connexion main { padding-top: calc(env(safe-area-inset-top) + 40px); }
.connexion-logo { display: block; width: 150px; height: 150px; margin: 0 auto 18px; border-radius: 34px;
                  box-shadow: 0 10px 30px rgba(13, 38, 89, .2); }
.connexion .carte { max-width: 380px; margin: 0 auto; padding: 22px; }
.connexion h1 { margin: 0 0 4px; font-size: 1.35rem; text-align: center; }
.connexion .aide { text-align: center; margin: 0 0 18px; }

/* --- Accueil ---------------------------------------------------------------- */
.bonjour { margin: 2px 2px 14px; }
.bonjour h2 { margin: 0; font-size: 1.5rem; }
.bonjour p { margin: 2px 0 0; color: var(--doux); }
.tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tuile { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 12px;
         text-decoration: none; color: var(--texte); display: grid; gap: 2px; }
.tuile .valeur { font-size: 1.6rem; font-weight: 800; color: var(--marine); line-height: 1.1; }
.tuile .libelle { font-size: .78rem; color: var(--doux); font-weight: 600; }
.tuile.accent { background: linear-gradient(135deg, var(--bleu) 0%, #2a9be0 100%); }
.tuile.accent .valeur, .tuile.accent .libelle { color: #fff; }

/* Listes (tâches, prospects, RDV) */
.liste { list-style: none; margin: 0; padding: 0; background: var(--carte); border-radius: var(--rayon);
         box-shadow: var(--ombre); overflow: hidden; }
.liste > li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--ligne); }
.liste > li:last-child { border-bottom: 0; }
.liste .lien-ligne { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit;
                     text-decoration: none; }
.liste .corps { flex: 1; min-width: 0; display: grid; gap: 2px; }
.liste .ligne1 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.liste .nom { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .quand { margin-left: auto; flex: none; color: var(--doux); font-size: .78rem; }
.liste .detail { color: var(--doux); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .en-retard { color: var(--rouge); font-weight: 600; }
.pastille-icone { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
                  background: var(--bleu-pale); color: var(--bleu); }
.pastille-icone.rdv { background: #e0f4f6; color: #23848f; }
.pastille-icone.retard { background: var(--rouge-pale); color: var(--rouge); }
.pastille-icone.nouveau { background: var(--violet-pale); color: var(--violet); }
.appel-rond { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%;
              background: var(--vert-pale); color: var(--vert); text-decoration: none; }
.appel-rond.douteux { background: var(--rouge-pale); color: var(--rouge); }
.heure-rdv { flex: none; width: 52px; text-align: center; font-weight: 800; color: var(--marine); }
.heure-rdv small { display: block; font-weight: 600; color: var(--doux); font-size: .7rem; }

/* --- Prospects ------------------------------------------------------------------ */
.recherche { position: relative; margin-bottom: 10px; }
.recherche .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--doux); }
.recherche input { padding-left: 42px; background: #fff; border-radius: 14px; }

/* --- Fiche ------------------------------------------------------------------------ */
.profil { display: flex; align-items: center; gap: 14px; }
.profil h2 { margin: 0; font-size: 1.3rem; }
.profil .tel { margin: 2px 0 0; font-weight: 700; color: var(--texte); text-decoration: none; display: inline-block; }
.profil .tel.douteux { color: var(--rouge); }
.selecteur-etape { margin-top: 14px; }
.selecteur-etape label { font-size: .8rem; color: var(--doux); font-weight: 700; text-transform: uppercase;
                         letter-spacing: .04em; }
.selecteur-etape select { font-weight: 700; color: var(--marine); background-color: var(--bleu-pale);
                          border-color: var(--bleu-ciel); -webkit-appearance: none; appearance: none;
                          background-image: linear-gradient(45deg, transparent 50%, var(--bleu) 50%),
                                            linear-gradient(135deg, var(--bleu) 50%, transparent 50%);
                          background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
                          background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.infos { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.infos li { display: flex; align-items: center; gap: 10px; color: var(--texte); }
.infos .ic { color: var(--bleu); }
.infos .cle-info { color: var(--doux); font-size: .85rem; }
.infos .corps-info { flex: 1; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.action { display: grid; justify-items: center; gap: 6px; padding: 12px 4px; border-radius: var(--rayon);
          background: var(--carte); box-shadow: var(--ombre); color: var(--bleu); text-decoration: none;
          font-size: .78rem; font-weight: 700; cursor: pointer; list-style: none; }
.action::-webkit-details-marker { display: none; }
.action .rond { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
                background: var(--bleu-pale); }
.action.appel .rond { background: var(--vert-pale); color: var(--vert); }
.action span:last-child { color: var(--texte); }
.action-menu { position: relative; }
.action-menu[open] > .menu {
  position: absolute; z-index: 15; top: calc(100% + 8px); left: 0; min-width: 260px; display: grid; gap: 8px;
  padding: 10px; background: var(--carte); border-radius: var(--rayon);
  box-shadow: 0 12px 32px rgba(13, 38, 89, .18);
}
.actions > .action-menu:nth-child(n+3) > .menu { left: auto; right: 0; }
.menu a { display: block; padding: 12px 14px; border-radius: 12px; background: var(--fond); text-decoration: none;
          color: var(--texte); font-weight: 600; }
.menu a.suggere { background: var(--bleu-pale); color: var(--bleu); }

.bloc-titre { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1rem; }
.bloc-titre .ic { color: var(--bleu); }

.devis-image { width: 100%; border-radius: 12px; border: 1px solid var(--ligne); display: block; margin-bottom: 8px; }
.boutons-devis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.boutons-devis .principal { grid-column: 1 / -1; }
table.montants { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.montants td { padding: 7px 0; border-bottom: 1px solid var(--ligne); }
table.montants td:last-child { text-align: right; white-space: nowrap; }
table.montants .total td { font-weight: 800; color: var(--marine); border-bottom: 0; font-size: 1.05rem; }

.fil { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.fil::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--ligne); }
.fil li { position: relative; padding: 0 0 14px 12px; }
.fil li::before { content: ""; position: absolute; left: -17px; top: 6px; width: 10px; height: 10px; border-radius: 50%;
                  background: #fff; border: 2px solid var(--bleu-logo); }
.fil .ev-quand { display: block; color: var(--doux); font-size: .78rem; }
.fil .ev-note .ev-texte { white-space: pre-wrap; }

details.repli > summary { cursor: pointer; list-style: none; display: flex; align-items: center;
                          justify-content: space-between; font-weight: 700; color: var(--marine); }
details.repli > summary::-webkit-details-marker { display: none; }
details.repli > summary::after { content: "›"; font-size: 1.4rem; color: var(--doux); transition: transform .2s; }
details.repli[open] > summary::after { transform: rotate(90deg); }
details.repli[open] > summary { margin-bottom: 14px; }
details.repli.danger > summary { color: var(--rouge); }

.creneaux-liste > li { gap: 10px; }
.rond-itineraire { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%;
                   background: var(--bleu-pale); color: var(--bleu); text-decoration: none; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photos figure { margin: 0; position: relative; }
.photos img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.photos button { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; border: 0;
                 background: rgba(13, 38, 89, .6); color: #fff; display: grid; place-items: center; }
.ajout-photos { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
                border: 2px dashed var(--bleu-ciel); border-radius: 12px; color: var(--bleu); font-weight: 700;
                cursor: pointer; }
.ajout-photos input { display: none; }
.revient { display: inline-flex; padding: 2px 8px; border-radius: 999px; background: var(--vert-pale); color: var(--vert);
           font-size: .72rem; font-weight: 800; white-space: nowrap; }
.carte-revient { border: 1px solid #bfe7d4; background: var(--vert-pale); }
.carte-revient .bloc-titre, .carte-revient .ic { color: var(--vert); }
.ligne-rdv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.alerte-carte { border: 1px solid #f4d2a8; background: var(--orange-pale); }
.alerte-carte .bloc-titre, .alerte-carte .ic { color: var(--orange); }
.reglage-nombre { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.reglage-nombre .aide { grid-column: 1 / -1; margin: 0; }
.reglage-nombre .saisie { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--doux); }
.reglage-nombre input { width: 72px; text-align: center; font-weight: 700; color: var(--marine); }

.modale { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
          background: rgba(13, 38, 89, .45); padding: 16px; padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
.modale .feuille { width: 100%; max-width: 480px; background: #fff; border-radius: 24px; padding: 24px 20px 16px;
                   display: grid; gap: 10px; text-align: center; box-shadow: 0 20px 50px rgba(13, 38, 89, .3); }
.modale h3 { margin: 4px 0 0; font-size: 1.25rem; }
.modale .aide { margin: 0 0 6px; }
.pastille-succes { justify-self: center; display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%;
                   background: var(--vert-pale); color: var(--vert); }

.toast {
  position: fixed; left: 16px; right: 16px; z-index: 40;
  bottom: calc(var(--barre-bas) + env(safe-area-inset-bottom) + 14px);
  max-width: 608px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 16px; border-radius: var(--rayon); background: var(--marine); color: #fff;
  box-shadow: 0 10px 30px rgba(13, 38, 89, .3);
}
.toast button { min-height: 38px; padding: 6px 14px; border-radius: 10px; border: 0; background: rgba(255,255,255,.15);
                color: #fff; font-weight: 700; }

/* --- Statistiques ------------------------------------------------------------------ */
.grille-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.barres { display: grid; gap: 10px; }
.barre { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: .9rem; }
.barre svg { grid-column: 1 / -1; width: 100%; height: 10px; display: block; }
.fond-barre { fill: var(--bleu-pale); }
.plein-barre { fill: var(--bleu); }
.histogramme { display: block; width: 100%; height: 90px; }
table.tableau { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tableau th { text-align: left; color: var(--doux); font-weight: 700; font-size: .78rem; padding: 0 0 8px; }
table.tableau td { padding: 8px 0; border-top: 1px solid var(--ligne); }
table.tableau td + td, table.tableau th + th { text-align: right; padding-left: 8px; }

/* --- Réglages ------------------------------------------------------------------ */
.reglage { display: flex; align-items: center; gap: 12px; }
.reglage .corps { flex: 1; display: grid; }
.etat { font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.etat.ok { background: var(--vert-pale); color: var(--vert); }
.etat.non { background: var(--orange-pale); color: var(--orange); }
.modele-sms { white-space: pre-wrap; background: var(--fond); border-radius: 12px; padding: 12px; font-size: .9rem; margin: 6px 0 0; }

/* --- htmx -------------------------------------------------------------------------- */
.htmx-request { opacity: .6; transition: opacity .2s; }
.indicateur { display: none; }
.indicateur.htmx-request { display: flex; opacity: 1; align-items: center; gap: 8px; }
.marge { margin-top: 12px; }
