:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #5b6570;
  --line: #e2e5e9;
  --accent: #1e6b3a;
  --accent-ink: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.app-header {
  background: var(--accent);
  color: var(--accent-ink);
}
.app-header__inner { max-width: 1400px; margin: 0 auto; padding: 16px 20px; }
.app-header h1 { margin: 0; font-size: 1.35rem; font-weight: 650; }
.app-header__sub { margin: 4px 0 0; font-size: .9rem; opacity: .92; }

/* --- Kennzahlen --- */
.stats {
  max-width: 1400px; margin: 16px auto 0; padding: 0 20px;
  display: flex; flex-wrap: wrap; gap: 10px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px; min-width: 120px;
}
.stat__num { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat__label { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.stat__bar { height: 6px; border-radius: 3px; margin-top: 8px; background: var(--line); overflow: hidden; }
.stat__bar > i { display: block; height: 100%; }

/* --- Steuerung --- */
.controls { max-width: 1400px; margin: 14px auto 0; padding: 0 20px; }
.controls__row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.controls__row + .controls__row { margin-top: 10px; }
.control { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--muted); }
.control input, .control select {
  font: inherit; font-size: .9rem; color: var(--ink);
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 190px;
}
.control input:focus, .control select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.btn-reset {
  font: inherit; font-size: .85rem; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
.btn-reset:hover { background: var(--bg); }

/* --- Kategorie-Toggles / Legende --- */
.controls__row--legend { align-items: center; }
.legend-title {
  font-size: .78rem; color: var(--muted); font-weight: 600;
  letter-spacing: .01em; margin-right: 2px;
}
.chip-filter {
  padding: 5px 10px; border: 1px dashed var(--line); border-radius: 999px;
  background: #fff; color: var(--muted); font-size: .78rem; cursor: pointer;
}
.chip-filter:hover { color: var(--ink, #1f2a24); border-style: solid; }
.status-toggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font-size: .82rem; user-select: none;
}
.status-toggle input { display: none; }
.status-toggle .dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 1px solid rgba(0, 0, 0, .18);   /* hält auch sehr helle Kategorien sichtbar */
}
.status-toggle.off { opacity: .4; }
.status-toggle .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- Layout Karte + Tabelle --- */
.layout {
  max-width: 1400px; margin: 14px auto 24px; padding: 0 20px;
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

.map {
  height: 620px; border-radius: var(--radius); border: 1px solid var(--line);
  box-shadow: var(--shadow); background: #dfe3e7;
}
@media (max-width: 960px) { .map { height: 420px; } }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  max-height: 620px;
}
.table-meta { padding: 8px 12px; font-size: .82rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
thead th {
  position: sticky; top: 0; background: #fafbfc; text-align: left; z-index: 1;
  padding: 8px 10px; border-bottom: 2px solid var(--line); cursor: pointer; white-space: nowrap;
}
thead th:hover { background: #f0f2f4; }
thead th.sorted-asc::after { content: " ▲"; color: var(--muted); }
thead th.sorted-desc::after { content: " ▼"; color: var(--muted); }
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f3f8f4; }
tbody tr.active { background: #e6f2ea; }
.nr { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem;
  color: #fff; white-space: nowrap;
}
/* Vor-Ort-Spalte der Tabelle: schmal halten, Vermerk steckt im Tooltip. */
tbody td [title] { cursor: help; border-bottom: 1px dotted var(--line); }
.jahr { font-variant-numeric: tabular-nums; color: var(--muted); }

/* --- Popup --- */
.leaflet-popup-content { margin: 12px 14px; font-size: .86rem; line-height: 1.4; }
.popup h3 { margin: 0 0 6px; font-size: 1rem; }
.popup .badge { margin-bottom: 8px; }
.popup dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; }
.popup dt { color: var(--muted); }
.popup dd { margin: 0; }
.popup .desc { margin: 8px 0 0; }
.popup__vorort { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.popup__vorort h4 { margin: 0 0 6px; font-size: .8rem; color: var(--muted); font-weight: 600; }

.app-footer {
  max-width: 1400px; margin: 0 auto; padding: 16px 20px 32px; color: var(--muted); font-size: .78rem;
}
.app-footer p { margin: 4px 0; }
