:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #1f2933;
  --muted: #6b7785;
  --accent: #2563eb;
  --shadow: 0 2px 12px rgba(20, 30, 50, 0.10);
  --sidebar-w: 340px;
  --detail-w: 380px;
}

* { box-sizing: border-box; }

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

/* ---- Barre du haut ---- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 1000;
}
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand .subtitle { font-size: 0.8rem; color: var(--muted); }
.topbar-stats { font-size: 0.82rem; color: var(--muted); text-align: right; }
.topbar-stats strong { color: var(--text); }
.topbar-link {
  font-size: 0.82rem; color: var(--accent); text-decoration: none;
  white-space: nowrap; padding: 6px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg);
}
.topbar-link:hover { background: #eef2ff; }

/* ---- Disposition principale ---- */
#layout {
  position: relative;
  display: flex;
  height: calc(100vh - 53px);
}

/* ---- Barre latérale ---- */
#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
}
.filters { padding: 12px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.filters input[type="search"],
.filters select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.type-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
  background: #fff;
  transition: background 0.12s, border-color 0.12s;
}
.type-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.type-chip.off { opacity: 0.4; }
.type-chip:hover { border-color: var(--accent); }

.result-count { padding: 8px 12px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.list li {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.list li:hover { background: #f0f5ff; }
.list li.active { background: #e0ebff; }
.list .li-dot { width: 11px; height: 11px; border-radius: 50%; margin-top: 3px; flex: 0 0 auto; }
.list .li-name { font-size: 0.86rem; font-weight: 600; line-height: 1.25; }
.list .li-meta { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }

/* ---- Carte ---- */
#map { flex: 1; min-width: 0; height: 100%; background: #aadaff; }

/* Marqueurs ronds colorés */
.mat-marker {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

/* Légende */
.legend {
  background: rgba(255,255,255,0.95);
  padding: 8px 10px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 0.78rem;
  line-height: 1.6;
}
.legend .legend-title { font-weight: 700; margin-bottom: 4px; }
.legend .row { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; }

/* ---- Panneau détail ---- */
.detail {
  width: var(--detail-w);
  flex: 0 0 var(--detail-w);
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  position: relative;
  box-shadow: -2px 0 12px rgba(20,30,50,0.06);
}
.detail.hidden { display: none; }
.detail-close {
  position: absolute; top: 8px; right: 10px;
  border: none; background: transparent;
  font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--muted);
}
.detail-close:hover { color: var(--text); }

.detail-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.detail-header h2 { margin: 0 28px 6px 0; font-size: 1.05rem; line-height: 1.25; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  font-size: 0.72rem; padding: 3px 8px; border-radius: 999px;
  background: #eef2f7; color: var(--text); display: inline-flex; align-items: center; gap: 5px;
}
.badge .dot { width: 9px; height: 9px; border-radius: 50%; }
.detail-addr { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.detail-addr.approx::after { content: " (localisation approximative)"; font-style: italic; }

.section { padding: 12px 18px; border-bottom: 1px solid var(--border); }
.section h3 { margin: 0 0 8px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.metric { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 3px 0; }
.metric .m-label { font-size: 0.86rem; }
.metric .m-label .hint { display: block; font-size: 0.72rem; color: var(--muted); }
.metric .m-value { font-size: 0.92rem; font-weight: 600; white-space: nowrap; }
.metric.highlight { background: #fff7ed; margin: 2px -8px; padding: 5px 8px; border-radius: 6px; }
.metric .nd { color: var(--muted); font-weight: 400; }

.mortalite-note { font-size: 0.74rem; color: var(--muted); font-style: italic; margin: 0 0 8px; }
.mort-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 0.85rem; }
.mort-row .m-region { font-weight: 600; }
.mort-row .m-france { color: var(--muted); font-size: 0.8rem; }
.mort-head { grid-template-columns: 1fr auto auto; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.source-note { padding: 12px 18px; font-size: 0.72rem; color: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #layout { flex-direction: column; height: auto; }
  #sidebar { width: 100%; flex: none; max-height: 38vh; }
  #map { height: 50vh; }
  .detail { position: fixed; top: 0; right: 0; height: 100vh; z-index: 1200; width: min(100%, var(--detail-w)); }
}
