:root {
  --header-bg: #0b3d62;
  --header-fg: #ffffff;
  --sidebar-bg: #f7f8fa;
  --border: #e2e6ea;
  --text: #1c2733;
  --muted: #5a6b7b;
  --accent: #0b6fb8;
  --sidebar-w: 320px;
  --header-h: 64px;
}

* { 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);
}

/* --- Header --- */
.app-header {
  height: var(--header-h);
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  position: relative;
  z-index: 1100;
}
.app-header .title h1 { font-size: 1.1rem; margin: 0; line-height: 1.2; }
.app-header .subtitle { margin: 2px 0 0; font-size: 0.78rem; opacity: 0.85; }
.app-header .meta { margin-left: auto; text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.badge {
  background: rgba(255,255,255,0.15);
  padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
}
.updated { font-size: 0.72rem; opacity: 0.8; }

.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,0.15);
  color: #fff; border: 0; border-radius: 6px; padding: 8px 12px;
  font-size: 0.85rem; cursor: pointer;
}

/* --- Layout --- */
.layout { display: flex; height: calc(100vh - var(--header-h)); }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.filter-group { margin-bottom: 20px; }
.filter-label {
  display: block; font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); margin-bottom: 8px;
}
.filter-head { display: flex; justify-content: space-between; align-items: baseline; }

#search {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.92rem;
}
#search:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 6px 11px; border-radius: 999px; font-size: 0.82rem; cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.cat-actions { display: flex; gap: 10px; }
.link-btn {
  background: none; border: 0; color: var(--accent); cursor: pointer;
  font-size: 0.78rem; padding: 0; text-decoration: underline;
}

.category-list { list-style: none; margin: 0; padding: 0; }
.category-list li {
  display: flex; align-items: center; gap: 9px; padding: 5px 4px;
  border-radius: 6px; cursor: pointer; user-select: none;
}
.category-list li:hover { background: #eef1f4; }
.category-list input { margin: 0; }
.legend-pin {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1;
}
.cat-name { flex: 1; font-size: 0.9rem; }
.cat-count { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.stats-btn {
  width: 100%; padding: 10px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.stats-btn:hover { background: #eef1f4; }

.disclaimer {
  margin-top: 6px; font-size: 0.72rem; color: var(--muted); line-height: 1.45;
  border-top: 1px solid var(--border); padding-top: 12px;
}
.disclaimer a { color: var(--accent); }

/* --- Map + Marker --- */
.map-wrap { position: relative; flex: 1; }
#map { width: 100%; height: 100%; }

.leaflet-div-icon.pin-wrap { background: transparent; border: 0; }
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
}

.empty-hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 0.9rem; z-index: 1000;
}

/* --- Statistik-Panel --- */
.stats-panel {
  position: absolute; top: 12px; right: 12px; width: 320px;
  max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18); padding: 14px 16px; z-index: 1200;
}
.stats-header { display: flex; justify-content: space-between; align-items: center; }
.stats-close { background: none; border: 0; font-size: 1rem; cursor: pointer; color: var(--muted); }
.stats-note { font-size: 0.74rem; color: var(--muted); margin: 4px 0 10px; }
.stats-panel h4 { margin: 14px 0 6px; font-size: 0.82rem; }
.stats-list { list-style: none; margin: 0; padding: 0; }
.stats-list li { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 0.8rem; }
.bar-label { flex: 0 0 42%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { flex: 1; height: 8px; background: #eef1f4; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { flex: 0 0 auto; min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.stats-empty { color: var(--muted); }

/* --- Knöpfe für Overlays --- */
.panel-buttons { display: flex; flex-direction: column; gap: 8px; }

/* --- 24-Stunden-Ereignisliste --- */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-item {
  display: flex; gap: 9px; padding: 9px 2px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.event-item:hover { background: #eef1f4; }
.event-emoji {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
  border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.event-body { flex: 1; min-width: 0; }
.event-headline { font-size: 0.85rem; font-weight: 600; margin: 0 0 2px; }
.event-meta { font-size: 0.74rem; color: var(--muted); }
.event-empty { color: var(--muted); padding: 10px 2px; }

/* --- Popup --- */
.popup-cat {
  display: inline-block; font-size: 0.72rem; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 999px; margin-bottom: 6px;
}
.leaflet-popup-content { margin: 12px 14px; line-height: 1.45; }
.popup-headline { font-weight: 700; font-size: 0.98rem; margin: 0 0 4px; }
.popup-meta { font-size: 0.78rem; color: var(--muted); margin: 0 0 6px; }
.popup-summary { font-size: 0.86rem; margin: 0 0 8px; }
.popup-link { font-size: 0.82rem; }

/* --- Mobil --- */
@media (max-width: 760px) {
  .sidebar-toggle { display: block; }
  .app-header .subtitle { display: none; }
  .layout { position: relative; }
  .sidebar {
    position: absolute; z-index: 1050; height: 100%;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .stats-panel { width: calc(100% - 24px); }
}

/* --- Dark Mode (folgt automatisch der Browser-/System-Einstellung) --- */
@media (prefers-color-scheme: dark) {
  :root {
    --header-bg: #0c2438;
    --sidebar-bg: #181c21;
    --border: #2c333b;
    --text: #e7eaed;
    --muted: #97a2ad;
    --accent: #4aa3e6;
  }
  body { background: #15181c; }

  /* Eingaben, Chips, Buttons */
  #search, .chip, .stats-btn { background: #20262d; color: var(--text); }
  #search::placeholder { color: var(--muted); }
  .chip.active { color: #0a1722; }
  .category-list li:hover,
  .event-item:hover,
  .stats-btn:hover { background: #252c34; }

  /* Overlays / Hinweise / Balken */
  .empty-hint, .stats-panel { background: #1b2026; }
  .bar { background: #2a3139; }

  /* Karte abdunkeln (ohne Anbieterwechsel) */
  .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9);
  }

  /* Popups */
  .leaflet-popup-content-wrapper,
  .leaflet-popup-tip { background: #1f252b; color: var(--text); }
  .leaflet-popup-content { color: var(--text); }
  .leaflet-popup-close-button { color: var(--muted) !important; }

  /* Leaflet-Bedienelemente + Attribution */
  .leaflet-bar a { background: #20262d; color: var(--text); border-color: var(--border); }
  .leaflet-bar a:hover { background: #252c34; }
  .leaflet-control-attribution {
    background: rgba(24, 28, 33, 0.85) !important;
    color: var(--muted) !important;
  }
  .leaflet-control-attribution a { color: var(--accent) !important; }
}

