:root{
  --shadow: 0 10px 30px rgba(0,0,0,.15);
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:#0c8fa0;}

/* Bandeau haut */
.banner{
  position:fixed;top:0;left:0;right:0;
  height:80px;                          /* hauteur fixe — sidebar et carte calées dessus */
  background: linear-gradient(135deg, #2bb673 0%, #14a0a5 60%, #0c8fa0 100%);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 24px;
  z-index:2000;
  box-shadow:none;
  overflow:hidden;
}

.banner-left{display:flex;align-items:center}
.logo-interlud{height:30px;max-width:220px;object-fit:contain}

.banner-text{flex:1; text-align:center; padding:0 16px;}
.banner-text h1{margin:0;font-size:22px;font-weight:800;color:#fff}
.banner-text p{margin:6px 0 0 0;font-size:14px;font-style:italic;color:rgba(255,255,255,.95)}

.banner-logos{display:flex;align-items:center;gap:12px}
.banner-logos img{height:40px;max-width:160px;object-fit:contain;filter: drop-shadow(0 1px 1px rgba(0,0,0,.15))}
.banner-logos .logo-lai{height:34px;width:34px;max-width:34px;}

/* Sidebar */
.sidebar{
  position:fixed;
  top:80px;
  left:0;
  bottom:0;
  width:320px;
  background:#fff;
  padding:16px;
  z-index:1500;
  box-shadow:2px 0 6px rgba(0,0,0,.15);
  overflow:auto;
}
.sidebar h2{margin:0 0 12px 0;font-size:18px}

.mode-list{display:flex;flex-direction:column;gap:10px;margin:0 0 14px 0}

.mode-btn{
  width:100%;
  border:1px solid rgba(0,0,0,.12);
  background:#fff;
  border-radius:14px;
  padding:10px 10px;
  display:grid;
  grid-template-columns:22px 1fr;
  grid-template-rows:auto auto;
  column-gap:10px;
  row-gap:4px;
  text-align:left;
  cursor:pointer;
  box-shadow:0 1px 2px rgba(0,0,0,.04);
}
.mode-btn:hover{box-shadow:0 2px 6px rgba(0,0,0,.08)}

/* Bouton sélectionné : plus visible, mais restant "sobre" */
.mode-btn.active{border-color:rgba(0,0,0,.28);box-shadow:0 4px 10px rgba(0,0,0,.12)}
.mode-btn.active .mode-title{color:#0f172a}

/* Teintes par thème (fond très léger + petite bordure) */
.mode-btn[data-mode="colis"].active{background:rgba(76,175,80,.10);border-color:rgba(76,175,80,.45)}
.mode-btn[data-mode="aires"].active{background:rgba(255,152,0,.12);border-color:rgba(255,152,0,.45)}
.mode-btn[data-mode="nuisances"].active{background:rgba(229,57,53,.10);border-color:rgba(229,57,53,.45)}
.mode-btn[data-mode="autre"].active{background:rgba(33,150,243,.10);border-color:rgba(33,150,243,.45)}

/* Légendes : 3 cercles colorés */
.swatch{grid-row:1 / span 2;align-self:center;justify-self:center;width:14px;height:14px;border-radius:50%}
.swatch-colis{background:#4CAF50}
.swatch-aires{background:#FF9800}
.swatch-nuisances{background:#E53935}
.swatch-autre{background:#2196F3}

.mode-title{font-weight:800;font-size:14px;line-height:1.15}
.mode-sub{font-size:12px;color:#555;line-height:1.2}

.btn{
  appearance:none;border:0;cursor:pointer;
  padding:10px 12px;border-radius:10px;
  color:#fff;background:#2ecc71;
  font-weight:700;
}
.btn-secondary{background:#e6e6e6;color:#000}

.helper{font-size:13px;color:#444;margin:10px 0 0 0}
.helper.small{font-size:12px;color:#666}

/* Pas-à-pas */
.quicksteps{margin-top:12px;padding:10px 12px;border:1px solid #eee;border-radius:12px;background:#fafafa}
.quicksteps-toggle{width:100%;display:flex;align-items:center;justify-content:space-between;gap:10px;border:0;background:transparent;padding:0;margin:0 0 6px 0;font-weight:800;font-size:14px;cursor:pointer;text-align:left}
.quicksteps-toggle:after{content:"▾";font-weight:900;color:#666}
.quicksteps.collapsed .quicksteps-toggle:after{content:"▸"}
.quicksteps-body{margin:0}
.quicksteps-list{margin:0;padding-left:18px;font-size:13px;color:#333}
.quicksteps-list li{margin:6px 0}
.quicksteps-list span{color:#666}

.quicksteps.collapsed .quicksteps-body{display:none}

.sidebar-actions{margin-top:14px;display:flex;flex-direction:column;gap:8px}

/* Map */
#map{
  position:absolute;
  top:80px;
  left:320px;
  right:0;
  bottom:0;
}

/* Logo superposé sur la carte (bas droite) */
.map-logos{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:1200; /* au-dessus de Leaflet */
  pointer-events:none;
}

.map-logo{
  height:90px;
  width:auto;
  max-width:260px;
  display:block;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.18));
}

/* Modal */
.modal{position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,.45);z-index:1600}

/* Modal bienvenue : démarre sous le bandeau fixe (hauteur ~80px) */
#welcomeModal{top:80px;align-items:flex-start;padding-top:16px;}
.hidden{display:none}
.modal-content{width:min(560px,92vw);background:#f8f9fa;border:1px solid #ddd;border-radius:16px;padding:18px;box-shadow:var(--shadow)}
.modal-content h2{margin:0 0 12px 0;font-size:18px}

/* Pas-à-pas (popup) */
.howto-content{width:min(520px,92vw)}
.howto-content p{margin:0 0 10px 0;color:#444;font-size:14px}
.howto-content ol{margin:0 0 14px 0;padding-left:20px;color:#222;font-size:14px}
.howto-content li{margin:8px 0}
.howto-actions{display:flex;justify-content:flex-end}
.howto-close{border:0;background:var(--teal);color:#fff;border-radius:10px;padding:10px 14px;font-weight:800;cursor:pointer}
.howto-close:hover{filter:brightness(.95)}

.row{display:grid;grid-template-columns:140px 1fr;gap:10px;align-items:center;margin-bottom:10px}
label{color:#333;font-size:14px}
input[type="text"],select,textarea,input[type="file"]{width:100%;border:1px solid #ccc;border-radius:10px;padding:8px 10px;background:#fff}
textarea{resize:vertical}

.actions{display:flex;justify-content:flex-end;gap:10px;margin-top:14px}
.msg{min-height:1.2em;color:#c0392b;font-size:14px;margin:10px 0 0 0}

@media (max-width: 920px){
  .banner-text{display:none}
}

@media (max-width: 720px){

  /* Sidebar : hauteur juste suffisante pour la grille 2×2 */
  .sidebar{
    position:fixed;
    top:80px;
    left:0;
    right:0;
    width:100%;
    height:auto;
    max-height:30vh;
    overflow:auto;
    padding:10px 10px 6px;
    z-index:1000;
  }
  .sidebar h2{
    font-size:14px;
    margin:0 0 8px 0;
  }

  /* Grille 2 colonnes : les 4 thèmes tiennent en 2 rangées */
  .mode-list{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:7px;
    margin:0 0 8px 0;
  }

  /* Bouton compact */
  .mode-btn{
    padding:8px 8px 7px;
    grid-template-columns:14px 1fr;
    column-gap:6px;
    row-gap:2px;
    border-radius:10px;
    min-height:unset;
  }
  .swatch{
    width:11px;
    height:11px;
  }
  .mode-title{
    font-size:11.5px;
    line-height:1.2;
  }
  .mode-sub{
    font-size:10.5px;
    line-height:1.2;
    color:#666;
  }

  /* Masque le pas-à-pas sur mobile (déjà replié par le JS) */
  .quicksteps{ display:none; }

  /* Texte d'aide compact */
  .helper{ font-size:12px; margin:4px 0 0; }

  /* Carte : démarre juste sous la sidebar */
  #map{
    position:fixed;
    top:calc(80px + 30vh);
    left:0;
    right:0;
    bottom:0;
    height:auto;
  }
}

.app-version{margin:0 14px;color:rgba(255,255,255,.9);font-weight:700;font-size:12px;opacity:.85}

/* Toast */
.toast{
  position:fixed;bottom:24px;left:50%;transform:translateX(-50%);
  background:#1a2a3a;color:#fff;
  padding:12px 20px;border-radius:12px;
  font-size:14px;font-weight:600;
  z-index:2100;box-shadow:0 4px 16px rgba(0,0,0,.3);
}
.toast--warn{background:#e67e22}
.toast--error{background:#c0392b}

/* Coordonnées compactes */
.coords-row{display:flex;align-items:center;gap:6px;margin-bottom:10px}
.coords-label{font-size:16px}
.coords-row input{flex:1;min-width:0;border:1px solid #ddd;border-radius:8px;padding:6px 8px;font-size:12px;color:#666;background:#f5f5f5}

/* Champs avec message d'erreur */
.field{margin-bottom:10px}
.field label{display:block;font-size:14px;color:#333;margin-bottom:4px;font-weight:600}
.field textarea,.field input[type="file"]{width:100%;border:1px solid #ccc;border-radius:10px;padding:8px 10px;background:#fff}
.field-error{color:#c0392b;font-size:12px;margin-top:4px}
.required{color:#e53935}

/* Prévisualisation photos */
.photo-preview{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.photo-thumb{width:72px;height:72px;object-fit:cover;border-radius:8px;border:1px solid #ddd}

/* Spinner bouton */
.spinner{
  display:inline-block;width:14px;height:14px;
  border:2px solid rgba(255,255,255,.4);border-top-color:#fff;
  border-radius:50%;animation:spin .6s linear infinite;vertical-align:middle;margin-left:6px;
}
@keyframes spin{to{transform:rotate(360deg)}}

/* Tooltip nom de commune */
.commune-tooltip{
  background:rgba(255,255,255,.88);
  border:1px solid #aaa;
  border-radius:6px;
  padding:3px 8px;
  font-size:12px;
  font-weight:600;
  color:#3a5068;
  box-shadow:0 1px 4px rgba(0,0,0,.15);
}

/* PWA – safe areas iOS : le bandeau s'étend sous la barre de statut */
.banner{
  height: calc(80px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
#map{
  padding-bottom:env(safe-area-inset-bottom, 0);
}
.mode-btn{
  min-height:52px; /* desktop : cible tactile confortable */
  -webkit-tap-highlight-color:transparent;
}
/* Sur mobile la grille 2×2 impose sa propre hauteur */
@media (max-width: 720px){
  .mode-btn{ min-height:unset; }
}
.btn{
  min-height:48px;
  min-width:80px;
  touch-action:manipulation;
}
.modal-content{
  max-height:90dvh;
  overflow-y:auto;
}
@media (max-width: 720px){
  .sidebar{
    padding-bottom:max(10px, env(safe-area-inset-bottom, 10px));
    -webkit-overflow-scrolling:touch;
  }
  .toast{
    bottom:max(24px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  }
}

/* =====================================================
   Modal de bienvenue
   ===================================================== */
.welcome-content{
  width:min(620px, 95vw);
  /* hauteur max = espace visible sous le bandeau (80px) - marge basse (16px) */
  max-height:calc(100dvh - 80px - 16px);
  overflow-y:auto;
  padding:0;
  border-radius:20px;
  display:flex;
  flex-direction:column;
}

/* Bouton fermer */
.welcome-close{
  position:absolute;
  top:14px;right:16px;
  background:none;border:none;
  font-size:24px;line-height:1;color:#666;
  cursor:pointer;padding:4px 8px;border-radius:6px;
  z-index:10;
}
.welcome-close:hover{background:#f0f0f0;color:#222}

/* En-tête avec logo + titre */
.welcome-header{
  background:linear-gradient(135deg,#2bb673 0%,#14a0a5 60%,#0c8fa0 100%);
  border-radius:20px 20px 0 0;
  padding:24px 28px 20px;
  display:flex;align-items:center;gap:20px;
}
.welcome-logo-ame{
  height:64px;width:auto;flex-shrink:0;
  filter:brightness(0) invert(1) opacity(.85);
}
.welcome-header h2{
  margin:0;color:#fff;
  font-size:clamp(18px,3vw,24px);
  font-weight:800;line-height:1.25;
}
.welcome-header h2 em{
  font-style:normal;
  display:block;font-size:clamp(20px,3.5vw,28px);
}

/* Corps scrollable */
.welcome-body{
  padding:22px 28px 0;
}

/* Paragraphes d'introduction */
.welcome-intro p{
  margin:0 0 12px;font-size:14.5px;color:#333;line-height:1.6;
}
.welcome-intro p:last-child{margin-bottom:0}

/* Titre de section */
.welcome-subtitle{
  margin:20px 0 12px;
  font-size:15px;font-weight:800;color:#1a3a4a;
  text-transform:uppercase;letter-spacing:.04em;
}

/* Liste des étapes */
.welcome-steps{
  list-style:none;margin:0;padding:0;
  display:flex;flex-direction:column;gap:10px;
}
.welcome-step{
  display:flex;align-items:flex-start;gap:14px;
  background:#f6faf9;
  border-left:4px solid #2bb673;
  border-radius:0 12px 12px 0;
  padding:12px 14px;
}
.step-num{
  flex-shrink:0;
  width:30px;height:30px;
  background:linear-gradient(135deg,#2bb673,#14a0a5);
  color:#fff;font-weight:800;font-size:15px;
  border-radius:50%;
  display:flex;align-items:center;justify-content:center;
}
.step-body{display:flex;flex-direction:column;gap:3px}
.step-title{font-size:14px;font-weight:800;color:#14a0a5}
.step-desc{font-size:13px;color:#555;line-height:1.45}

/* Pied de modal */
.welcome-footer{
  padding:20px 28px 24px;
  display:flex;align-items:center;justify-content:space-between;
  gap:16px;flex-wrap:wrap;
  border-top:1px solid #eee;margin-top:20px;
}
.btn-welcome{
  background:linear-gradient(135deg,#2bb673,#14a0a5);
  font-size:15px;padding:12px 24px;border-radius:12px;
  box-shadow:0 4px 14px rgba(43,182,115,.35);
  flex-shrink:0;
}
.btn-welcome:hover{filter:brightness(1.05)}
.welcome-remember{
  display:flex;align-items:center;gap:7px;
  font-size:13px;color:#666;cursor:pointer;white-space:nowrap;
}
.welcome-remember input{cursor:pointer;width:15px;height:15px}

@media (max-width: 540px){
  .welcome-header{flex-direction:column;align-items:flex-start;gap:12px;padding:20px 18px 16px}
  .welcome-logo-ame{height:48px}
  .welcome-body{padding:16px 18px 0}
  .welcome-footer{padding:16px 18px 20px;flex-direction:column;align-items:flex-start}
  .btn-welcome{width:100%;text-align:center}
}
