/* ============================================================ fondamentaux */
:root {
  --marine:      #0e2e54;
  --marine-clair:#1b4a80;
  --accent:      #2f7de0;
  --fond:        #f5f6f8;
  --surface:     #ffffff;
  --texte:       #16202c;
  --texte-doux:  #64748b;
  --bord:        #e2e6ec;
  --vert:        #17794b;
  --ambre:       #b45309;
  --rouge:       #b42318;
  --ombre:       0 6px 24px rgba(15, 30, 50, .16);
  --rayon:       14px;
  --haut:        env(safe-area-inset-top, 0px);
  --bas:         env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond:       #10151c;
    --surface:    #19202a;
    --texte:      #e8edf3;
    --texte-doux: #93a1b3;
    --bord:       #2a3441;
    --ombre:      0 6px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
/* Les regles d'auteur ci-dessous posent des display: grid/flex qui, sans ceci,
   l'emporteraient sur l'attribut hidden et laisseraient les ecrans visibles. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
  background: var(--fond);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.ico, .bouton-ico svg, .flottant svg {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ============================================================ deverrouillage */
.verrou {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--marine), #071a31);
}
.verrou-carte {
  width: 100%; max-width: 360px; text-align: center; color: #fff;
}
.verrou-logo { border-radius: 22%; margin-bottom: 18px; }
.verrou h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: -.01em; }
.verrou-note {
  margin: 0 0 26px; font-size: 14px; line-height: 1.5;
  color: rgba(255, 255, 255, .7);
}
#form-verrou { display: grid; gap: 10px; }
#champ-mdp {
  padding: 15px 16px; border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 12px; background: rgba(255, 255, 255, .1); color: #fff;
  text-align: center;
}
#champ-mdp::placeholder { color: rgba(255, 255, 255, .5); }
#champ-mdp:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#btn-deverrouiller {
  padding: 15px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 600;
}
#btn-deverrouiller[disabled] { opacity: .55; }
.erreur { margin-top: 14px; color: #ffb4ab; font-size: 14px; }

/* ==================================================================== barre */
.barre {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; gap: 8px; align-items: center;
  padding: calc(var(--haut) + 8px) 12px 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--bord);
}
.recherche {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 42px;
  background: var(--fond); border: 1px solid var(--bord); border-radius: 21px;
}
.recherche .ico { width: 18px; height: 18px; color: var(--texte-doux); flex: none; }
#champ-recherche {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  -webkit-appearance: none;
}
#champ-recherche::-webkit-search-cancel-button { display: none; }
.bouton-ico {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--bord); border-radius: 50%;
  background: var(--surface); color: var(--texte-doux);
}
.bouton-ico svg { width: 19px; height: 19px; }

/* ==================================================================== carte */
#carte { position: fixed; inset: 0; background: var(--fond); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-top { margin-top: calc(var(--haut) + 56px); }

.pastille {
  width: 100%; height: 100%; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  background: var(--accent);
}
.pastille.hors-idf { background: #8a97a8; }
.pastille.doute    { background: var(--ambre); }
.pastille.actif    { background: var(--marine); transform: scale(1.35); }
.pastille.voisin   { background: var(--vert); }
/* Ou tu es. Vert, parce que les pastilles clients sont marine, ambre et
   grises : aucune chance de le confondre avec un point de la carte. */
.marqueur-moi {
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--vert); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(23, 121, 75, .28), 0 1px 4px rgba(0, 0, 0, .35);
}

/* ============================================================== suggestions */
.suggestions {
  position: fixed; z-index: 480;
  top: calc(var(--haut) + 58px); left: 12px; right: 12px;
  max-height: 55vh; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--rayon); box-shadow: var(--ombre);
}
.suggestions li button {
  display: block; width: 100%; padding: 11px 12px; text-align: left;
  border: 0; border-radius: 9px; background: none;
}
.suggestions li button:active { background: var(--fond); }
.suggestions .nom { font-weight: 600; }
.suggestions .sous { font-size: 13px; color: var(--texte-doux); }

/* ================================================================= flottant */
.flottant {
  position: fixed; z-index: 470;
  right: 12px; bottom: calc(var(--bas) + 20px);
  display: flex; align-items: center; gap: 8px;
  padding: 13px 18px; border: 0; border-radius: 26px;
  background: var(--marine); color: #fff; font-weight: 600;
  box-shadow: var(--ombre);
}
.flottant svg { width: 18px; height: 18px; }
.flottant[hidden] { display: none; }

/* ================================================================== panneau */
.panneau {
  position: fixed; z-index: 490; left: 0; right: 0; bottom: 0;
  max-height: 25vh; display: flex; flex-direction: column;
  padding: 0 16px calc(var(--bas) + 16px);
  background: var(--surface);
  border-radius: 20px 20px 0 0; box-shadow: var(--ombre);
  animation: monte .22s ease;
}
@keyframes monte { from { transform: translateY(100%); } }
.poignee {
  align-self: center; flex: none;
  width: 44px; height: 5px; margin: 10px 0 4px; padding: 0;
  border: 0; border-radius: 3px; background: var(--bord);
}
#panneau-contenu { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------- tournée */
.tournee-flottant {
  bottom: calc(var(--bas) + 80px);
  background: var(--vert);
}
.tournee .etapes { margin: 4px 0 0; padding: 0; list-style: none; }
.tournee .etapes li {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-top: 1px solid var(--bord);
}
.tournee .rang {
  flex: none; width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--marine); color: #fff;
  font-size: 13px; font-weight: 700;
}
.tournee .corps { flex: 1; min-width: 0; }
.tournee .corps .nom { display: block; font-weight: 600; }
.tournee .corps .sous { display: block; font-size: 13px; color: var(--texte-doux); }
.tournee .ordre { flex: none; display: flex; gap: 3px; }
.tournee .ordre button {
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--bord); border-radius: 8px;
  background: var(--surface); color: var(--texte-doux); font-size: 15px;
}
.tournee .ordre button[disabled] { opacity: .3; }
.tournee .total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 4px 0 16px; padding-top: 13px; border-top: 2px solid var(--bord);
}
.tournee .total strong { font-size: 20px; }
.actions .retrait {
  background: var(--fond); color: var(--rouge); border: 1px solid currentColor;
}

.fiche .titre {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 2px;
}
.fiche .titre h2 { flex: 1; min-width: 0; margin: 0; }
.picto {
  flex: none; width: 38px; height: 38px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--bord); border-radius: 50%;
  background: var(--fond); color: var(--texte-doux);
}
.picto svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.retour {
  margin: 4px 0 2px; padding: 6px 0;
  border: 0; background: none; color: var(--accent);
  font-size: 15px; font-weight: 600;
}
.fiche h2 { margin: 6px 0 2px; font-size: 20px; letter-spacing: -.01em; }
.fiche .adresse { margin: 0 0 4px; color: var(--texte-doux); font-size: 14px; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.etiquette {
  padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--fond); color: var(--texte-doux); border: 1px solid var(--bord);
}
.etiquette.alerte { color: var(--ambre); border-color: currentColor; }
.etiquette.trajet { color: var(--vert); border-color: currentColor; }
.etiquette.enregistre { color: #fff; background: var(--vert); border-color: var(--vert); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions a, .actions button {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 10px; border: 1px solid var(--bord); border-radius: 11px;
  background: var(--fond); color: var(--texte);
  font-size: 15px; font-weight: 600; text-decoration: none; text-align: center;
}
.actions .plein { grid-column: 1 / -1; background: var(--marine); color: #fff; border: 0; }
/* Boutons de marque : le logo remplace le libelle, donc moins de marge
   verticale pour lui laisser la hauteur dont il a besoin. */
.actions .marque { padding: 9px 8px; }
.actions .marque.plein { background: var(--fond); color: var(--texte);
  border: 1px solid var(--bord); }
.actions .absent { opacity: .4; pointer-events: none; }
.actions .court, .actions .ico-bouton { display: none; }

/* --------------------------------------- le panneau ne prend qu'un quart
   Choix de Pierre du 16/10/2026 : la carte d'abord. Sur ordinateur (ou tout
   ecran plus large que haut), le panneau devient une colonne a gauche, large
   d'un quart de l'ecran ; sur le telephone tenu droit, un bandeau en bas haut
   d'un quart, ou la fiche range ses boutons en une seule rangee de
   pictogrammes. Listes et formulaires y defilent. */
@media (max-width: 899px) and (max-aspect-ratio: 4/3) {
  .panneau { padding-bottom: calc(var(--bas) + 8px); }
  .poignee { margin: 7px 0 3px; }
  .fiche .titre { margin: 0; }
  .fiche .titre h2 { font-size: 17px; line-height: 1.25; }
  .fiche .picto { width: 32px; height: 32px; }
  .fiche .sous-titre {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: 3px 8px; margin: 2px 0 8px;
  }
  .fiche .adresse { margin: 0; font-size: 13px; }
  .fiche .etiquettes { margin: 0; gap: 4px; }
  .fiche .etiquette { padding: 1px 7px; font-size: 11px; }
  .fiche .actions { display: flex; gap: 5px; }
  .fiche .actions > * { flex: 1 1 0; min-width: 0; height: 44px; padding: 0 2px; }
  .fiche .actions .tournee-bouton { flex-grow: 2; font-size: 14px; }
  .fiche .actions .libelle { display: none; }
  .fiche .actions .court { display: inline; white-space: nowrap; }
  .fiche .actions .ico-bouton { display: block; }
  .fiche .actions svg { width: auto; height: 20px; flex: none; }
  .fiche .actions .ico-bouton:not(.logo) {
    width: 20px; fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
  }
  .fiche .depuis { margin: 6px 0 0; font-size: 12px; color: var(--texte-doux); }
  .fiche .depuis .lien { margin-left: 4px; font-size: inherit; }
  /* Le zoom de la carte remonte au-dessus du bandeau, au lieu d'y disparaitre. */
  body:has(#panneau:not([hidden])) .leaflet-bottom { bottom: 25vh; }
}

@media (min-width: 900px), (min-aspect-ratio: 4/3) {
  .panneau {
    top: calc(var(--haut) + 59px); right: auto; bottom: 0;
    width: max(25vw, 320px); max-height: none;
    padding: 0 16px 16px; border-radius: 0;
    border-right: 1px solid var(--bord);
    animation-name: glisse;
  }
  /* La poignee n'a plus de sens sur une colonne : elle devient une croix. */
  .poignee {
    align-self: flex-end; position: relative;
    width: 32px; height: 32px; margin: 10px -4px 0 0;
    border: 1px solid var(--bord); border-radius: 50%; background: var(--fond);
  }
  .poignee::before, .poignee::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 14px; height: 2px; border-radius: 1px; background: var(--texte-doux);
    transform: translate(-50%, -50%) rotate(45deg);
  }
  .poignee::after { transform: translate(-50%, -50%) rotate(-45deg); }
  .fiche .depuis { font-size: 13px; color: var(--texte-doux); }
  /* Les resultats de recherche passent devant la colonne, et le zoom de la
     carte se decale pour ne pas finir dessous. */
  .suggestions { z-index: 495; }
  body:has(#panneau:not([hidden])) .leaflet-bottom.leaflet-left { left: max(25vw, 320px); }
}
@keyframes glisse { from { transform: translateX(-100%); } }

/* ------------------------------------------------------- liste des voisins */
.voisins h2 { margin: 6px 0 2px; font-size: 19px; }
.voisins .depuis { margin: 0 0 12px; font-size: 13px; color: var(--texte-doux); }
.voisins ol { margin: 0; padding: 0; list-style: none; }
.voisins li { border-top: 1px solid var(--bord); }
.voisins li button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 2px; border: 0; background: none; text-align: left;
}
.duree {
  flex: none; min-width: 62px; text-align: center;
  padding: 7px 4px; border-radius: 10px;
  background: color-mix(in srgb, var(--vert) 12%, transparent);
  color: var(--vert); font-weight: 700; font-size: 15px; line-height: 1.1;
}
.duree small { display: block; font-size: 10px; font-weight: 600; opacity: .8; }
.duree.approx { background: var(--fond); color: var(--texte-doux); }
.voisins .nom { font-weight: 600; }
.voisins .sous { font-size: 13px; color: var(--texte-doux); }

.voisins .depuis .lien { margin-left: 8px; font-size: 13px; }
.depart-adresse { display: flex; gap: 8px; margin: 14px 0 4px; }
.depart-adresse input {
  flex: 1; min-width: 0; padding: 12px; border: 1px solid var(--bord);
  border-radius: 10px; background: var(--fond); -webkit-appearance: none;
}
.depart-adresse button {
  flex: none; padding: 0 16px; border: 1px solid var(--bord);
  border-radius: 10px; background: var(--fond); font-weight: 600;
}
[data-role="resultats-adresse"] { margin: 0; padding: 0; list-style: none; }
[data-role="resultats-adresse"] li button {
  display: block; width: 100%; padding: 11px 2px; text-align: left;
  border: 0; border-top: 1px solid var(--bord); background: none;
}
/* Une adresse proposee en correction ou en ajout s'enregistre au toucher :
   la ligne entiere reste la cible, et le bouton vert le dit. */
[data-role="resultats-adresse"] .consigne {
  padding: 10px 2px 8px; font-size: 13px; font-weight: 600; color: var(--texte);
}
[data-role="resultats-adresse"] li button.choix-adresse {
  display: flex; align-items: center; gap: 12px; min-height: 52px;
}
.choix-adresse > span:first-child { flex: 1; min-width: 0; }
.choix-adresse .valider {
  flex: none; padding: 9px 16px; border-radius: 10px;
  background: var(--vert); color: #fff; font-weight: 700; font-size: 14px;
}
.ajout-client { margin: 14px 0 4px; }
.ajout-client > input[name="nom"] {
  width: 100%; margin-bottom: 8px; padding: 12px;
  border: 1px solid var(--bord); border-radius: 10px;
  background: var(--fond); -webkit-appearance: none;
}
.ajout-client .depart-adresse { margin: 0; }
.pastille.modifie { box-shadow: 0 0 0 3px rgba(23, 121, 75, .45); }

.vide, .chargement {
  padding: 22px 4px 26px; text-align: center; color: var(--texte-doux); font-size: 14px;
}
.chargement::after {
  content: ""; display: block; width: 22px; height: 22px; margin: 12px auto 0;
  border: 2.5px solid var(--bord); border-top-color: var(--accent);
  border-radius: 50%; animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* ================================================================== modale */
.modal {
  position: fixed; inset: 0; z-index: 800;
  display: grid; place-items: end center;
  background: rgba(8, 16, 28, .45);
}
.modal-carte {
  width: 100%; max-height: 92vh; overflow-y: auto;
  padding: 20px 16px calc(var(--bas) + 20px);
  background: var(--surface); border-radius: 20px 20px 0 0;
}
.modal-carte h2 { margin: 0 0 18px; font-size: 20px; }
.champ { display: block; margin-bottom: 18px; }
.champ > span { display: block; margin-bottom: 6px; font-weight: 600; font-size: 15px; }
.champ select, .champ input {
  width: 100%; padding: 12px; border: 1px solid var(--bord);
  border-radius: 10px; background: var(--fond); -webkit-appearance: none;
}
.champ small {
  display: block; margin-top: 6px; font-size: 13px; line-height: 1.4;
  color: var(--texte-doux);
}
.champ small.actif { color: var(--vert); font-weight: 600; }
.secondaire {
  width: 100%; padding: 12px; border: 1px solid var(--bord);
  border-radius: 10px; background: var(--fond); font-weight: 600;
}
.secondaire[disabled] { opacity: .55; }
.modal-actions {
  display: flex; justify-content: space-between; gap: 12px;
  margin: 22px 0 18px; padding-top: 16px; border-top: 1px solid var(--bord);
}
.lien {
  border: 0; background: none; padding: 4px 0;
  color: var(--accent); font-size: 15px; font-weight: 600;
}
.lien.danger { color: var(--rouge); }
.principal {
  width: 100%; padding: 14px; border: 0; border-radius: 12px;
  background: var(--marine); color: #fff; font-weight: 600;
}
.pied {
  margin: 16px 0 0; text-align: center;
  font-size: 12px; line-height: 1.5; color: var(--texte-doux);
}

/* Retour : pleine largeur et 44 px de haut, le minimum confortable au doigt. */
.retour {
  display: flex; align-items: center; width: 100%;
  margin: 2px 0 6px; padding: 0; min-height: 44px;
  border: 0; background: none; color: var(--accent);
  font-size: 15px; font-weight: 600; text-align: left;
  -webkit-tap-highlight-color: rgba(47, 125, 224, .2);
}
.retour:active { opacity: .55; }

/* Liste des voisins : le seuil sépare, il ne masque plus. */
.avis {
  margin: 8px 0 0; padding: 10px 12px;
  border-radius: 10px; background: var(--fond);
  font-size: 13px; line-height: 1.4; color: var(--texte-doux);
}
.separateur {
  margin: 16px 0 0; padding-top: 12px;
  border-top: 2px solid var(--bord);
  font-size: 13px; font-weight: 600; color: var(--texte-doux);
}
.attenue .duree { opacity: .75; }
.attenue .nom { font-weight: 500; }
.reglages-rapides {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--bord);
}
.reglages-rapides button { font-size: 14px; font-weight: 600; }

/* ======================================================= adaptation Sacha */
/* Clients en bleu (comme chez Pierre), prospects en rouge, prospects deja
   contactes en orange : on voit d'un coup d'oeil ou il reste a frapper. */
.pastille.prospect          { background: #d92d20; }
.pastille.prospect.contacte { background: #f79009; }
.pastille.prospect.doute,
.pastille.prospect.hors-idf { opacity: .7; }
.pastille.actif    { background: var(--marine); }
.pastille.voisin   { background: var(--vert); }

.filtres {
  position: fixed; z-index: 490; left: 12px; right: 12px;
  top: calc(var(--haut) + 66px);
  display: flex; gap: 6px; justify-content: center; pointer-events: none;
}
.filtres button {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 17px;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
  font: inherit; font-size: 14px; font-weight: 600; box-shadow: var(--ombre);
}
.filtres button small { color: var(--texte-doux); font-weight: 500; }
.filtres button[aria-pressed="true"] { background: var(--marine); color: #fff; border-color: var(--marine); }
.filtres button[aria-pressed="true"] small { color: rgba(255,255,255,.75); }
.filtres .puce { width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  border: 1.5px solid #fff; display: inline-block; }
.filtres .puce.prospect { background: #d92d20; }
.leaflet-top { margin-top: calc(var(--haut) + 106px); }
.suggestions { top: calc(var(--haut) + 106px); }

.etiquette.prospect { color: #b42318; border-color: currentColor; }
.etiquette.client   { color: var(--accent); border-color: currentColor; }
.mini-prospect { font-style: normal; font-size: 11px; font-weight: 600; color: #b42318;
  margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; }

.fiche .details {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 12px;
  margin: 0 0 12px; font-size: 14px;
}
.fiche .details dt { color: var(--texte-doux); }
.fiche .details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.fiche .details a { color: var(--accent); }
.ajout-client select {
  width: 100%; height: 42px; margin: 8px 0; padding: 0 10px; font: inherit;
  border: 1px solid var(--bord); border-radius: 10px; background: var(--surface); color: var(--texte);
}
@media (max-width: 700px) {
  .fiche .details { font-size: 13px; margin: 8px 0; }
}
