* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f4f6f8;
  color: #333;
}

/* ── Map page ─────────────────────────────────────── */

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#toolbar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: calc(100vw - 32px);
  width: max-content;
}

#toolbar-left {
  display: flex;
  flex-direction: column;
}

#toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#toolbar h1 {
  font-size: 1rem;
  font-weight: 700;
  color: #2563eb;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

#toolbar .hint {
  font-size: 0.75rem;
  color: #6b7280;
}

/* ── Search bar ───────────────────────────────────── */

#search-bar {
  display: flex;
  align-items: center;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}

#search-input {
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 0.85rem;
  outline: none;
  width: 200px;
}

#search-bar button {
  background: none;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: #6b7280;
  transition: color 0.2s;
}

#search-bar button:hover { color: #2563eb; }

#admin-link {
  font-size: 0.8rem;
  color: #9ca3af;
  text-decoration: none;
  margin-left: 8px;
}

#admin-link:hover { color: #2563eb; }

#gps-btn {
  padding: 6px 14px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

#gps-btn:hover { opacity: 0.85; }
#gps-btn:disabled { background: #9ca3af; cursor: default; }

@media (max-width: 600px) {
  #toolbar { flex-direction: column; align-items: flex-start; padding: 10px 14px; width: calc(100vw - 32px); }
  #toolbar-right { width: 100%; justify-content: space-between; }
  #toolbar-hint { display: none; }
  #admin-link { display: none; }
  #search-input { width: 130px; }
}

/* ── Modal signalement ────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: #111;
}

.modal label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 4px;
  margin-top: 12px;
}

.modal select,
.modal textarea,
.modal input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.modal select:focus,
.modal textarea:focus,
.modal input:focus {
  border-color: #2563eb;
}

.modal textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 9px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }

.btn-primary {
  background: #2563eb;
  color: white;
  flex: 1;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
}

/* ── Photo drop zone ─────────────────────────────── */

#photo-drop {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-top: 4px;
}

#photo-drop:hover, #photo-drop.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

#photo-placeholder {
  font-size: 0.85rem;
  color: #9ca3af;
}

#photo-remove {
  display: block;
  margin-top: 6px;
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ── Toast ────────────────────────────────────────── */

#toast {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: white;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 0.9rem;
  z-index: 3000;
  animation: fadeup 0.3s ease;
}

@keyframes fadeup {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Leaflet popup ────────────────────────────────── */

.leaflet-popup-content {
  margin: 12px 16px;
}

.leaflet-popup-content img {
  display: block;
  max-width: 100% !important;
  height: auto !important;
  border-radius: 6px;
  margin-top: 8px;
}

/* ── Filtre panel ────────────────────────────────── */

#filter-panel {
  position: fixed;
  top: 100px;
  left: 16px;
  z-index: 1000;
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  max-width: 220px;
}

.filter-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 6px;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-btn {
  padding: 3px 10px;
  border-radius: 99px;
  border: 2px solid var(--c, #9ca3af);
  background: white;
  color: var(--c, #9ca3af);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.45;
}

.filter-btn.active {
  background: var(--c, #9ca3af);
  color: white;
  opacity: 1;
}

.filter-btn[data-filter="statut"] { --c: #4b5563; }
.filter-btn[data-value="nouveau"]  { --c: #1d4ed8; }
.filter-btn[data-value="en_cours"] { --c: #a16207; }
.filter-btn[data-value="traite"]   { --c: #15803d; }

@media (max-width: 600px) {
  #filter-panel {
    top: auto;
    bottom: 80px;
    left: 8px;
    max-width: calc(100vw - 16px);
    padding: 10px 12px;
  }
  .filter-buttons { gap: 4px; }
}

/* ── Marqueur temporaire ──────────────────────────── */

.temp-marker {
  width: 20px;
  height: 20px;
  background: #2563eb;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(37,99,235,0.4);
  animation: pulse-marker 1.2s infinite;
}

@keyframes pulse-marker {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

/* ── Cluster ──────────────────────────────────────── */

.cluster-icon {
  width: 36px;
  height: 36px;
  background: #2563eb;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 3px solid white;
  box-shadow: 0 2px 10px rgba(37,99,235,0.4);
}

/* ── PWA install btn ──────────────────────────────── */

#install-btn {
  padding: 6px 14px;
  background: #059669;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  align-items: center;
  gap: 4px;
}

/* ── Stats dashboard ──────────────────────────────── */

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

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  text-align: center;
  border-top: 4px solid #e5e7eb;
}

.stat-card-blue   { border-top-color: #2563eb; }
.stat-card-yellow { border-top-color: #d97706; }
.stat-card-green  { border-top-color: #059669; }

.stat-number {
  font-size: 2.2rem;
  font-weight: 800;
  color: #111;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 500;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stats-block {
  background: white;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.stats-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  margin-bottom: 14px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.bar-label {
  width: 90px;
  flex-shrink: 0;
  color: #4b5563;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 4px;
}

.bar-val {
  width: 24px;
  text-align: right;
  font-weight: 700;
  color: #374151;
}

/* ── Legend ───────────────────────────────────────── */

#legend {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 1000;
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  font-size: 0.8rem;
}

#legend h3 {
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Admin page ───────────────────────────────────── */

.admin-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  background: #2563eb;
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.admin-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
}

.admin-nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,0.2);
  color: white;
}

.nav-btn.active, .nav-btn:hover {
  background: rgba(255,255,255,0.35);
}

.admin-content {
  padding: 24px;
  flex: 1;
}

/* ── Login ────────────────────────────────────────── */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  padding: 36px;
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: #2563eb;
  margin-bottom: 6px;
}

.login-card p {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 24px;
}

/* ── Table signalements ───────────────────────────── */

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters select {
  padding: 7px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

thead {
  background: #f8fafc;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 12px 16px;
  font-size: 0.85rem;
  border-top: 1px solid #f1f5f9;
}

tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-nouveau    { background: #dbeafe; color: #1d4ed8; }
.badge-en_cours   { background: #fef9c3; color: #a16207; }
.badge-traite     { background: #dcfce7; color: #15803d; }
.badge-banc       { background: #ede9fe; color: #6d28d9; }
.badge-eclairage  { background: #fef3c7; color: #b45309; }
.badge-signalisation { background: #fee2e2; color: #b91c1c; }
.badge-voirie     { background: #e0f2fe; color: #0369a1; }
.badge-commerce   { background: #d1fae5; color: #065f46; }
.badge-autre      { background: #f3f4f6; color: #374151; }

.action-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  margin-right: 4px;
}

.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-warn   { background: #fef9c3; color: #a16207; }
.btn-ok     { background: #dcfce7; color: #15803d; }

/* ── Section admins ───────────────────────────────── */

.admin-list {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  margin-bottom: 24px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.add-admin-form {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.add-admin-form input {
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  flex: 1;
  min-width: 180px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 12px;
}
