:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2430;
  --muted: #6a7383;
  --border: #dde1e7;
  --accent: #0f4c81;
  --c-none: #7d8a9c;
  --c-modif: #e07b00;
  --c-quest: #1f6fd1;
  --c-zae: #0f4c81;
  --c-req: #c0392b;
  --radius: 8px;
  --shadow: 0 4px 18px rgba(20, 30, 50, .12);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
body { display: flex; flex-direction: column; }

/* ---------- Barre haute ---------- */
.topbar {
  flex: none; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: var(--accent); color: #fff;
}
.titles { flex: 1; min-width: 0; }
.titles h1 { margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titles p { margin: 2px 0 0; font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-icon {
  border: 0; background: transparent; color: inherit; font-size: 20px; cursor: pointer;
  width: 36px; height: 36px; border-radius: 6px; flex: none;
}
.btn-icon:hover { background: rgba(127,127,127,.15); }

/* ---------- Mise en page ---------- */
.layout { position: relative; display: flex; flex: 1; min-height: 0; }
#map { flex: 1; height: 100%; }

.sidebar {
  width: 320px; flex: none; height: 100%; overflow: hidden;
  display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar.collapsed { display: none; }
.panel { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 0; }
.panel h2 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

.legend { display: flex; flex-direction: column; gap: 4px; }
.legend .check { justify-content: space-between; }
.legend .lbl { display: flex; align-items: center; gap: 8px; }
.legend .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend .note { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; display: flex; align-items: center; gap: 6px; }

.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.check input { margin: 0; accent-color: var(--accent); }

.sw-line { width: 22px; height: 0; border-top: 3px solid; flex: none; }
.sw-line.zae { border-color: var(--c-zae); }
.sw-line.req { border-color: var(--c-req); border-top-style: dashed; }

input[type="search"] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff;
}
input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.list { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.list li { display: flex; align-items: center; gap: 9px; padding: 7px 6px; border-radius: 6px; cursor: pointer; }
.list li:hover, .list li.active { background: #eef3f9; }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .id { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; min-width: 28px; }

/* ---------- Symboles ---------- */
.dot-icon { background: transparent; border: 0; }
.dot-icon svg { display: block; overflow: visible; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.35)); }
.dot-icon.selected svg { filter: drop-shadow(0 0 4px rgba(0,0,0,.6)); }
.sym { display: inline-block; flex: none; line-height: 0; }
.sym svg { overflow: visible; }
.legend .note .sym { margin-right: 6px; }

/* ---------- Fiche détaillée ---------- */
.detail {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 400px; z-index: 1000;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto; padding: 18px 18px 22px;
}
.detail .close { position: absolute; top: 10px; right: 10px; color: var(--muted); font-size: 16px; }
.detail h3 { margin: 0 32px 4px 0; font-size: 18px; line-height: 1.25; }
.detail .sub { color: var(--muted); margin: 0 0 12px; display: flex; align-items: center; gap: 7px; }
.flag { border-radius: 6px; padding: 9px 11px; margin: 0 0 10px; line-height: 1.4; }
.flag b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.flag.modif { background: #fdf0e1; border-left: 4px solid var(--c-modif); }
.flag.modif b { color: #9a5300; }
.flag.quest { background: #e7f0fc; border-left: 4px solid var(--c-quest); }
.flag.quest b { color: #164f97; }

table.attrs { width: 100%; border-collapse: collapse; margin: 6px 0 0; font-size: 13px; }
table.attrs th, table.attrs td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.attrs th { color: var(--muted); font-weight: 500; width: 38%; }
table.attrs td.empty { color: #b2b9c4; }

.leaflet-tooltip.occ-tip { font-size: 12.5px; padding: 4px 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .titles p { display: none; }
  .sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 1001; box-shadow: var(--shadow); width: min(320px, 88vw); }
  .detail { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 70%; }
}
