:root {
  --verlauf: linear-gradient(135deg, #ff3d71 0%, #8b2cf5 48%, #1e88e5 100%);
  --tief: #1d1b3a;
  --text: #24213f;
  --leise: #5b5878;
  --ok: #10b981;
  --warn: #f59e0b;
  --rot: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: #dfe7ef;
}

#karte { position: absolute; inset: 0; }

.versteckt { display: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, rgba(255, 61, 113, .25), transparent 55%),
              radial-gradient(circle at 80% 80%, rgba(30, 136, 229, .3), transparent 55%),
              rgba(29, 27, 58, .92);
  color: #fff;
}

.karte-spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .2);
  border-top-color: #ff3d71;
  border-right-color: #8b2cf5;
  animation: drehen 0.9s linear infinite;
}

@keyframes drehen { to { transform: rotate(360deg); } }

.hinweis-box { text-align: center; max-width: 420px; padding: 24px; }
.hinweis-symbol { font-size: 52px; }
.hinweis-box h2 { margin: 10px 0 6px; font-size: 22px; }
.hinweis-box p { margin: 0; opacity: .85; }

#panel {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 40;
  width: 272px;
  max-height: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 30px rgba(29, 27, 58, .35);
}

#panel-kopf {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  padding: 10px 12px;
  background: var(--verlauf);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.panel-titel { font-weight: 700; font-size: 14px; }
.panel-zahlen { flex: 1; font-size: 11px; opacity: .95; }
.panel-pfeil { transition: transform .2s; }
#panel.zu .panel-pfeil { transform: rotate(-90deg); }
#panel.zu #panel-inhalt { display: none; }

#panel-inhalt { display: flex; flex-direction: column; min-height: 0; padding: 8px 10px 10px; }

.schalter { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; }
.schalter label { display: flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 600; }
.schalter input { accent-color: #8b2cf5; }

.knopf {
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #ede9fe, #dbeafe);
  color: var(--tief);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.knopf:hover { background: linear-gradient(90deg, #ddd6fe, #bfdbfe); }

.legende {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  display: grid;
  gap: 3px;
}

.legende li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  background: #f6f5fb;
}
.legende li:hover { background: #ece9f8; }
.legende .farbe { width: 12px; height: 12px; border-radius: 3px; }
.legende .name { font-weight: 600; }
.legende .werte { color: var(--leise); font-size: 11px; white-space: nowrap; }

.rund-knopf {
  position: fixed;
  bottom: 28px;
  z-index: 30;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--verlauf);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29, 27, 58, .35);
}
.rund-knopf.links { left: 10px; }
.rund-knopf.rechts { right: 10px; }
.rund-knopf.aktiv { background: linear-gradient(135deg, #10b981, #1e88e5); }
.rund-knopf:disabled { opacity: .5; }

.dialog-hintergrund {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(29, 27, 58, .55);
}
.dialog {
  width: min(420px, calc(100% - 24px));
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.dialog-kopf { display: flex; align-items: center; padding: 12px 14px; background: var(--verlauf); color: #fff; }
.dialog-kopf h3 { margin: 0; flex: 1; font-size: 16px; }
.schliessen { border: 0; background: transparent; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.dialog-inhalt { padding: 14px; }
.dialog-inhalt dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.dialog-inhalt dt { color: var(--leise); }
.dialog-inhalt dd { margin: 0; font-weight: 600; }
.status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 700; margin-bottom: 10px; color: #fff; }
.status.safe { background: var(--ok); }
.status.warning { background: var(--warn); }
.status.danger { background: var(--rot); }
.dialog-inhalt ul { margin: 6px 0 0; padding-left: 18px; color: var(--leise); }

.maplibregl-popup-content { padding: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 8px 24px rgba(29, 27, 58, .35); }
.maplibregl-popup-close-button { color: #fff; font-size: 18px; }
.popup { min-width: 200px; max-width: 280px; }
.popup-kopf { padding: 8px 28px 8px 10px; background: var(--verlauf); color: #fff; }
.popup-adresse { font-weight: 700; font-size: 14px; }
.popup-ort { font-size: 12px; opacity: .9; }
.popup-rumpf { padding: 8px 10px; display: grid; gap: 4px; }
.popup-zeile { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.popup-hh { font-weight: 600; }
.popup-status { padding: 2px 8px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 700; }
.popup-ausreisser { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #111; color: #fff; font-size: 11px; font-weight: 700; }
.popup-eigen { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; font-size: 12px; }
.popup-eigen dt { color: var(--leise); }
.popup-eigen dd { margin: 0; word-break: break-word; }
.popup-route {
  display: block;
  margin-top: 4px;
  padding: 6px;
  border-radius: 8px;
  text-align: center;
  background: linear-gradient(90deg, #1e88e5, #8b2cf5);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
}

.standort-punkt {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1e88e5;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(30, 136, 229, .3);
}

@media (max-width: 640px) {
  #panel { width: calc(100% - 20px); max-height: 46%; }
  .rund-knopf { bottom: 34px; }
}
