:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --error: #f87171;
  --border: #334155;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* Les règles `display:` ci-dessous écraseraient sinon l'attribut `hidden`. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ---------- Auth screen ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a5f 0%, var(--bg) 60%);
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.brand {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline { margin: 0.25rem 0 1.5rem; color: var(--muted); font-size: 0.9rem; }

.field { margin-bottom: 0.75rem; }
.name-fields { display: flex; gap: 0.5rem; }

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn-primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  color: #04263a;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: 0.55; cursor: progress; }

.switch { margin: 1rem 0 0; text-align: center; color: var(--muted); font-size: 0.88rem; }
.switch a { color: var(--accent); text-decoration: none; margin-left: 0.3rem; }
.switch a:hover { text-decoration: underline; }

.error { color: var(--error); font-size: 0.85rem; margin: 0.5rem 0 0; }
.info { color: var(--text); font-size: 0.85rem; margin: 0.5rem 0 0; line-height: 1.4; }
.info a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.info a:hover { text-decoration: underline; }

/* ---------- App ---------- */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand-sm { font-weight: 700; color: var(--accent); }
.brand-sm .version { font-weight: 400; font-size: 0.8em; color: var(--muted); }
.spacer { flex: 1; }
.user-label { color: var(--muted); font-size: 0.88rem; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-ghost:hover { background: var(--panel-2); }

.layout { flex: 1; display: flex; min-height: 0; }

.panel {
  width: 320px;
  flex-shrink: 0;
  padding: 1rem;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.lbl { display: block; margin: 0.9rem 0 0.35rem; font-size: 0.85rem; color: var(--muted); }
.lbl:first-child { margin-top: 0; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

.filters {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.9rem 0 0;
  padding: 0.5rem 0.75rem 0.65rem;
}
.filters legend { color: var(--muted); font-size: 0.8rem; padding: 0 0.3rem; }
.filters label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}

.status { color: var(--muted); font-size: 0.85rem; min-height: 1.1rem; margin: 0.6rem 0 0; }
.status.err { color: var(--error); }

.results-summary {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.map { flex: 1; min-width: 0; }

/* Leaflet popups */
.leaflet-popup-content { font-size: 0.85rem; }
.popup-title { font-weight: 700; margin-bottom: 0.2rem; }
.popup-meta { color: #475569; margin-bottom: 0.4rem; }
.popup-table { border-collapse: collapse; width: 100%; }
.popup-table th, .popup-table td {
  border: 1px solid #cbd5e1;
  padding: 2px 6px;
  text-align: right;
}
.popup-table th:first-child, .popup-table td:first-child { text-align: left; }
.popup-table th { background: #f1f5f9; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .panel { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); max-height: 45%; }
}
