:root {
  --bg: #f3f7f4;
  --card: #ffffff;
  --text: #16302a;
  --muted: #5f736c;
  --primary: #0e8c7d;
  --primary-dark: #0b6e62;
  --accent: #5eead4;
  --tone-1: #0e8c7d;
  --tone-2: #46c8b4;
  --grad: linear-gradient(135deg, var(--tone-1) 0%, var(--tone-2) 100%);
  --border: #d3e7e1;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--grad);
  color: #fff;
  padding: 24px 28px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.8;
}

.hero h1 { margin: 0; font-size: 26px; }

.hero-text { margin: 6px 0 0; opacity: 0.9; font-size: 14px; }

.hero-badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 16px;
  white-space: nowrap;
}

.hero-badge .employeur-link {
  color: #fff;
  margin-left: 8px;
  font-weight: 600;
  text-decoration: underline;
  white-space: nowrap;
}

.hero-logout {
  margin-left: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 16px;
  white-space: nowrap;
}

.hero-logout:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Barre de session : déconnexion + identité, fixe en haut à droite */
.admin-bar,
.session-bar {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-dark);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 6px 14px;
  box-shadow: var(--shadow);
  font-size: 16px;
  white-space: nowrap;
}

.admin-bar-info,
.session-bar-info { opacity: 0.95; }
.admin-bar-info strong,
.session-bar-info strong { font-weight: 700; }
.admin-bar .hero-logout,
.session-bar .hero-logout { margin-left: 0; }

/* ---- Notifications agent ---- */
.notif-btn {
  position: relative;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  padding: 5px 8px;
  font-size: 16px;
  line-height: 1;
}

.notif-btn:hover { background: rgba(255, 255, 255, 0.32); }

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.4;
}

.notif-panel {
  position: fixed;
  top: 56px;
  right: 12px;
  z-index: 1500;
  width: min(380px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.notif-panel-head .secondary-btn { padding: 6px 10px; font-size: 12px; }

.notif-list { max-height: 60vh; overflow-y: auto; padding: 6px 0; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.notif-item:last-child { border-bottom: none; }

.notif-item p { margin: 0 0 4px; }

.notif-item .muted { font-size: 12px; }

.notif-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--grad);
  flex-shrink: 0;
}

.notif-item.read .notif-dot { background: var(--border); }

/* Dégage l'en-tête sous la barre fixe quand une session est ouverte */
body.admin-logged .app-shell,
body.session-logged .app-shell { padding-top: 64px; }

@media (max-width: 480px) {
  .admin-bar,
  .session-bar {
    top: 8px;
    right: 8px;
    padding: 5px 10px;
    font-size: 11px;
    gap: 6px;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-card .stat-label {
  display: block;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 26px;
  color: var(--primary-dark);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.form-card h2,
.map-card h2,
.table-card h2,
.activity-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

form label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

form input,
form select,
form textarea {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 16px;
  font-family: inherit;
  background: #fbfcfd;
  color: var(--text);
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.geo-fieldset {
  border: 1px dashed var(--border);
  border-radius: 7px;
  padding: 12px;
  margin: 4px 0 14px;
}

.geo-fieldset legend {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  padding: 0 6px;
}

.geo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.geo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 16px;
  background: var(--grad);
  color: #fff;
  transition: background 0.15s;
}

button:hover { background: var(--primary-dark); }

button.secondary-btn {
  background: #eef1f4;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 15px;
}

button.secondary-btn:hover { background: #e2e7ec; }

.back-home-btn {
  display: inline-block;
  margin-top: 4px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.back-home-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }

a.btn {
  display: inline-block;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  border: none;
  border-radius: 7px;
  padding: 10px 16px;
  font-size: 16px;
  background: var(--grad);
  color: #fff;
  transition: background 0.15s;
}

a.btn:hover { background: var(--primary-dark); color: #fff; }

button.hidden { display: none; }

.form-message {
  font-size: 15px;
  color: var(--primary);
  min-height: 18px;
  margin: 10px 0 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar { display: flex; gap: 8px; }

.toolbar input[type='search'] {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  width: 240px;
  max-width: 100%;
}

/* Barre de filtres des ménages */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filter-bar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  background: #fff;
  max-width: 100%;
}
.filter-bar .muted { font-size: 12px; }

#mapHouseholds,
#mapRoute {
  height: 460px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 0;
}

#mapRoute { height: 360px; }

/* Carte en lecture seule des portails agent / client / superadmin */
.portal-map {
  height: 420px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 0;
}

.map-hint {
  font-size: 16px;
  color: var(--muted);
  margin: 10px 0 0;
}

.hh-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  background: var(--grad);
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Marqueur « collecte effectuée » : pastille verte + marqueur atténué */
.hh-marker { position: relative; }
.hh-marker.is-done span { opacity: 0.5; }
.hh-marker .hh-done {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  font-size: 10px;
  color: #fff;
  background: #1f7a3c;
  border: 1px solid #fff;
  border-radius: 50%;
}

/* Fond de secours si les tuiles en ligne ne se chargent pas (hors ligne) */
.leaflet-container {
  background: #e8efe8;
  background-image:
    linear-gradient(rgba(31,122,60,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,122,60,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* Légende du code couleur des marqueurs */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.map-legend .lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.map-legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
  display: inline-block;
}

.pick-marker span {
  font-size: 26px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.table-card { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  background: #fafbfc;
}

.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  background: #eef1f4;
  color: #374151;
}

.status-badge.àrecueillir { background: #fef3c7; color: #92400e; }
.status-badge.encours { background: #dbeafe; color: #1e40af; }
.status-badge.collecté { background: #d1fae5; color: #065f46; }

/* Badges de priorité de demande de collecte */
.priority-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.priority-badge.urgente { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.priority-badge.haute { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.priority-badge.normale { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.priority-badge.basse { background: #eef1f4; color: #4b5563; border-color: #d1d5db; }

/* Badges de statut supplémentaires */
.status-badge.actif { background: #d1fae5; color: #065f46; }
.status-badge.inactif { background: #fee2e2; color: #991b1b; }
.status-badge.planifiée { background: #dbeafe; color: #1e40af; }
.status-badge.terminée { background: #d1fae5; color: #065f46; }
.status-badge.enattente { background: #fef3c7; color: #92400e; }

/* Liste des arrêts d'une tournée (espace agent) */
.stop-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px dashed var(--border);
}
.stop-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.stop-list li .status-badge { margin-left: auto; }

/* Boîte d'affichage des identifiants générés */
.creds-box {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 12px 0;
}
.creds-box p { margin: 6px 0; }
.creds-box code {
  background: #eef1f4;
  padding: 2px 8px;
  border-radius: 5px;
  font-weight: 700;
  user-select: all;
}

/* Bouton / lien WhatsApp */
.wa-btn,
.wa-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
}

.wa-btn {
  padding: 5px 10px;
  border: none;
}

.wa-btn:hover,
.wa-link:hover { background: #1da851; }

.wa-link {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
}

.recettes-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 16px;
}

.recettes-total strong { color: var(--primary-dark); font-size: 16px; }

.action-btn {
  padding: 5px 10px;
  font-size: 16px;
  border-radius: 6px;
}

.action-btn.edit { background: var(--primary); }
.action-btn.delete { background: var(--danger); }

/* ================= Onglets ================= */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  background: #eef1f4;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}

.tab:hover { background: #e2e7ec; }

.tab.active {
  background: var(--grad);
  color: #fff;
  border-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ================= Tournées ================= */
.routes-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

.route-list-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.route-item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.route-item:hover { background: #eef1f4; }

.route-item.active {
  border-color: var(--primary);
  background: #ecfdf5;
}

.route-item-date {
  font-weight: 700;
  color: var(--primary-dark);
  display: block;
}

.route-item-meta {
  font-size: 16px;
  color: var(--muted);
}

.route-detail-card { grid-column: 1 / -1; }

.route-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.route-detail-grid h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--primary-dark);
}

.add-stop {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.add-stop select { flex: 1; }

.stops-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stops-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafbfc;
}

.stop-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.stop-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 15px;
}

.stop-info .muted { font-size: 12px; }

.stop-rating {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}
.stop-rating .rating-stars-view { color: #f5a623; letter-spacing: 1px; }

.rating-widget {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.rating-widget .rating-stars { display: inline-flex; }
.rating-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: #f5a623;
  padding: 0 1px;
}
.rating-star:hover { transform: scale(1.15); }

.muted { color: var(--muted); }

.danger-btn {
  background: #fde8e8;
  color: var(--danger);
  border: 1px solid #f5c2c2;
}

.danger-btn:hover { background: #f5c2c2; }

/* ================= Finances ================= */
.finance-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card.revenue strong { color: var(--primary-dark); }
.stat-card.expense strong { color: #b45309; }
.stat-card.balance strong,
.stat-card.balance-total strong { color: var(--primary-dark); }
.stat-card strong.negative { color: var(--danger); }

.finance-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.finance-card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--primary-dark);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.inline-form .form-actions { grid-column: 1 / -1; }

.list-panel { display: flex; flex-direction: column; gap: 8px; }

/* Pastille de compteur sur l'onglet Demandes */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: #d64545;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.tab-badge[hidden] { display: none; }

/* Demandes de souscription */
.request-item { align-items: flex-start; }
.list-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 15px;
}
.list-item-title {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.req-service {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  background: #e8f2ea;
  border-radius: 6px;
  padding: 2px 8px;
}
.req-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d64545;
  flex: 0 0 auto;
}
.req-meta { font-size: 13px; color: var(--muted); }
.req-message {
  margin: 4px 0 0;
  font-size: 14px;
  color: #333;
  white-space: pre-wrap;
}
.request-unread { background: #fff8f0; border-color: #f0d9b8; }

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

.list-item.inactive { opacity: 0.55; }

.list-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 15px;
}

.list-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.amount-revenue { color: var(--primary-dark); font-weight: 700; }
.amount-expense { color: #b45309; font-weight: 700; }

/* Espace employeur */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 40px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  margin: 0 0 16px;
  font-size: 20px;
  color: var(--primary-dark);
}

/* Pages de connexion des portails (agence / agent) : présentation façon super admin
   -> masquer la bannière hero et centrer la carte de connexion sur fond tinté,
   uniquement tant que la session n'est pas ouverte (body sans .session-logged). */
body.portal-page:not(.session-logged) {
  background: #f4f7f4;
}
body.portal-page:not(.session-logged) .hero,
body.portal-page:not(.session-logged) .admin-bar,
body.portal-page:not(.session-logged) .session-bar {
  display: none !important;
}
body.portal-page:not(.session-logged) .app-shell {
  max-width: none;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
}
body.portal-page:not(.session-logged) .login-view {
  padding-top: 0;
  width: 100%;
}
body.portal-page:not(.session-logged) .login-card {
  max-width: 400px;
  margin: 8vh auto;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.06);
}

/* Boutons des cartes de connexion centrés et justifiés (comme le super admin) :
   bouton « Se connecter » pleine largeur + lien « Retour à l'accueil » centré. */
.login-card .form-actions {
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.login-card .form-actions button {
  width: 100%;
}
.login-card .map-hint,
.login-card .login-back {
  text-align: center;
  margin: 16px 0 0;
}
.login-card .back-home-btn {
  width: 100%;
  text-align: center;
}

.hidden { display: none !important; }

/* Sélecteur client enrichi */
.picker-wrap { position: relative; }

/* Modale d'ajout de client */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--primary-dark);
}

.modal form label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal form input,
.modal form select {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 16px;
  font-family: inherit;
  background: #fbfcfd;
  color: var(--text);
}

.modal form input:focus,
.modal form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* ---- Reçu de paiement (modale imprimable) ---- */
.receipt-modal { max-width: 560px; }

.receipt-sheet {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 22px 26px;
  font-size: 16px;
}

.receipt-header {
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.receipt-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-dark);
}

.receipt-sub { color: #666; margin-top: 2px; }

.receipt-kicker {
  margin-top: 10px;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--primary);
  font-weight: 700;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dotted #e0e0e0;
}

.receipt-label { color: #666; flex-shrink: 0; }
.receipt-value { font-weight: 600; text-align: right; }

.receipt-footer {
  margin-top: 18px;
  text-align: center;
  color: var(--primary);
  font-weight: 700;
}

.receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.receipt-actions .btn {
  flex: 1 1 auto;
  text-align: center;
}

.receipt-result { margin-top: 14px; }

a.btn.secondary-btn {
  background: #eef1f4;
  color: var(--text);
  border: 1px solid var(--border);
}
a.btn.secondary-btn:hover { background: #e2e7ec; color: var(--text); }

/* Bouton remonter en haut de page */
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1500;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.back-to-top:hover { background: var(--primary-dark); }

.back-to-top.visible { display: flex; opacity: 1; visibility: visible; transform: none; }

.leaflet-popup-content strong { display: block; margin-bottom: 2px; }

/* =========================================================
   Responsive : PC, tablette, mobile, smartphone
   ========================================================= */

/* --- PC large --- */
@media (min-width: 1201px) {
  .app-shell { max-width: 1320px; }
}

/* --- Tablette (1024px et moins) --- */
@media (max-width: 1024px) {
  .content-grid {
    grid-template-columns: minmax(280px, 340px) 1fr;
  }
  .inline-form { grid-template-columns: 1fr 1fr; }
}

/* --- Mobile (768px et moins) --- */
@media (max-width: 768px) {
  .app-shell { padding: 14px 12px 40px; }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px 18px;
  }
  .hero h1 { font-size: 22px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .content-grid { grid-template-columns: 1fr; }

  .tabs {
    flex-wrap: wrap;
    gap: 6px;
  }
  .tab { flex: 1 1 auto; }

  .routes-layout { grid-template-columns: 1fr; }
  .route-detail-grid { grid-template-columns: 1fr; }
  .finance-layout { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }

  #mapHouseholds, #mapRoute { height: 340px; }
  .portal-map { height: 320px; }

  .toolbar { width: 100%; }
  .toolbar input[type='search'] { width: 100%; }
  .section-header { flex-direction: column; align-items: stretch; }

  .list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .list-item-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .table-card table { min-width: 560px; }
}

/* --- Smartphone (480px et moins) --- */
@media (max-width: 480px) {
  .app-shell { padding: 10px 8px 32px; }

  .hero { padding: 16px 14px; }
  .hero h1 { font-size: 19px; }
  .hero-text { font-size: 13px; }
  .hero-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    white-space: normal;
  }
  .hero-badge .employeur-link { margin-left: 0; }

  .stats-grid { grid-template-columns: 1fr; }

  .card { padding: 14px; }

  .geo-row { grid-template-columns: 1fr; }
  .geo-actions { flex-direction: column; }
  .geo-actions button { width: 100%; }

  .form-actions { flex-direction: column; }
  .form-actions button { width: 100%; }

  .add-stop {
    flex-direction: column;
    align-items: stretch;
  }
  .add-stop select { width: 100%; }
  .add-stop button { width: 100%; }

  .finance-summary-grid { grid-template-columns: 1fr; }
  .stops-list li { flex-wrap: wrap; }

  button { padding: 12px 14px; font-size: 15px; }

  .recettes-total { flex-direction: column; align-items: flex-start; }
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal {
    padding: 18px;
    max-width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .modal .form-actions,
  .modal .modal-actions { flex-direction: column; }
  .modal .form-actions button,
  .modal .modal-actions button { width: 100%; }
}

/* ---- Fond de carte local (hors-ligne) ---- */
.offline-label span{
  position:absolute; transform:translate(-50%,-160%); white-space:nowrap;
  font-size:.72rem; font-weight:600; color:#3a5540;
  background:rgba(255,255,255,.72); padding:1px 6px; border-radius:8px;
  border:1px solid rgba(111,138,114,.35); pointer-events:none;
}
.offline-badge span{
  position:absolute; transform:translate(6px,-100%); white-space:nowrap;
  font-size:.68rem; color:#5b6a5f; background:rgba(255,255,255,.8);
  padding:2px 8px; border-radius:8px; border:1px solid #d8e0d8; pointer-events:none;
}
