:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --border: #2d3a4d;
  --text: #e8eef5;
  --muted: #8a9bb0;
  --accent: #3d9cf0;
  --accent-hover: #5eb0f7;
  --danger: #e85d5d;
  --ok: #4caf7a;
  --warn: #e6b422;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Sonst schlägt z. B. .auth-screen { display: grid } das HTML-Attribut hidden */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: max(0.65rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(0.65rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.topbar__title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 12rem;
  min-width: 0;
}

.topbar__title-row h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}

.btn-mobile-menu {
  display: none;
  flex-shrink: 0;
}

.view-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.view-switch__btn {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.65rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.view-switch__btn:hover {
  color: var(--text);
}

.view-switch__btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  line-height: 1.2;
  touch-action: manipulation;
}

.btn:hover {
  border-color: var(--muted);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
}

.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(232, 93, 93, 0.12);
}

.btn--block {
  width: 100%;
  margin-top: 0.5rem;
}

.btn--file {
  display: inline-block;
}

.btn[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.map-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 0.5rem 0.5rem;
}

.map-shell {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 1px solid rgba(213, 222, 232, 0.35);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

.legend {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 500;
  max-width: min(300px, calc(100% - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(213, 222, 232, 0.45);
  border-radius: 14px;
  background: rgba(26, 34, 45, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.legend-block h2,
.legend h2 {
  margin: 0 0 0.55rem;
  font-size: 0.86rem;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text);
}

.legend-block + .legend-block {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(213, 222, 232, 0.2);
}

.legend ul,
.legend-block ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem 0.7rem;
}

.legend li,
.legend-block li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
}

.legend .dot {
  flex-shrink: 0;
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.dot--gefuellt {
  background: var(--ok);
}

.dot--nicht_gefuellt {
  background: #dc2626;
}

.dot--zu_reparieren {
  background: #eab308;
}

.dot--fk_zu_reparieren {
  background: #dc2626;
}

.dot--fk_zu_fuellen {
  background: #f97316;
}

.dot--fk_gefuellt {
  background: #16a34a;
}

.dot--fk_aufzuraeumen {
  background: #6366f1;
}

.list-panel {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 1100;
  width: min(380px, calc(100% - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right))));
  max-height: min(580px, calc(100% - max(24px, env(safe-area-inset-top) + env(safe-area-inset-bottom))));
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid rgba(213, 222, 232, 0.45);
  border-radius: 14px;
  background: rgba(26, 34, 45, 0.96);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

.list-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.list-panel__head h2 {
  margin: 0;
  font-size: 1rem;
}

.btn--icon {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  line-height: 1;
  font-size: 1.25rem;
}

.list-panel__body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.list-panel__section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 0;
  flex: 1;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(213, 222, 232, 0.2);
}

.list-panel__section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-panel__section-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.list-panel__empty {
  margin: 0;
  font-size: 0.82rem;
}

.point-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: auto;
  min-height: 0;
  max-height: min(220px, 32vh);
  padding-right: 0.15rem;
}

.point-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  background: var(--surface);
  color: var(--text);
}

.point-list__item:hover {
  border-color: var(--muted);
}

.point-list__item .num {
  font-weight: 700;
  color: var(--accent);
}

.point-list__main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
  flex: 1;
}

.point-list__item .nm {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point-list__item .lbl {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-pin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.marker-pin .pin-ico {
  display: block;
}

.marker-pin--krippe .marker-num-above {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}

.marker-pin--salz .pin-ico--salz {
  display: block;
}

.panel {
  width: min(380px, 100%);
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  overflow: auto;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.panel label {
  display: block;
  margin-top: 0.85rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.panel select,
.panel textarea,
.panel input[type="text"],
.panel input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  line-height: 1.35;
  padding: 0.55rem 0.65rem;
  min-height: 2.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.panel textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.coords {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  word-break: break-all;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
  justify-content: flex-end;
}

.panel__empty {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.photo-preview {
  margin-top: 0.75rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.photo-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: contain;
  background: #000;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 25, 0.92);
  z-index: 2000;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.5rem;
}

.auth-card h2 {
  margin: 0 0 0.5rem;
}

.auth-card label {
  display: block;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-card input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  line-height: 1.35;
  padding: 0.65rem 0.75rem;
  min-height: 2.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.error {
  color: var(--danger);
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.mobile-bottom-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 920;
  flex-direction: row;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.4rem max(0.45rem, env(safe-area-inset-left)) calc(0.45rem + env(safe-area-inset-bottom))
    max(0.45rem, env(safe-area-inset-right));
  background: linear-gradient(to top, rgba(15, 20, 25, 0.98), rgba(26, 34, 45, 0.96));
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.4);
}

.mobile-bottom-bar__btn {
  flex: 1;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0.58rem 0.35rem;
  min-height: 2.85rem;
  touch-action: manipulation;
  color: #fff;
  line-height: 1.2;
}

.mobile-bottom-bar__btn--salz {
  background: linear-gradient(165deg, #166534, #0f3d24);
  border-color: #22c55e;
}

.mobile-bottom-bar__btn--krippe {
  background: linear-gradient(165deg, #1d4ed8, #172554);
  border-color: #60a5fa;
}

.mobile-menu-sheet {
  position: fixed;
  inset: 0;
  z-index: 2100;
}

.mobile-menu-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.mobile-menu-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(86dvh, 560px);
  padding: 0.65rem max(1rem, env(safe-area-inset-left)) calc(0.85rem + env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-right));
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid var(--border);
  border-bottom: none;
  box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mobile-menu-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mobile-menu-sheet__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.mobile-menu-sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

@media (min-width: 769px) {
  .mobile-bottom-bar {
    display: none !important;
  }
}

.toast {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  z-index: 3000;
  max-width: min(90vw, 420px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

@media (max-width: 768px) {
  .layout {
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.45rem;
  }

  .topbar__title-row h1 {
    font-size: 0.92rem;
    text-align: left;
    line-height: 1.25;
  }

  .btn-mobile-menu {
    display: inline-flex !important;
  }

  .view-switch--desktop,
  .topbar__actions--desktop {
    display: none !important;
  }

  .mobile-bottom-bar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
  }

  .map-area {
    flex: 1 1 auto;
    min-height: 0;
    padding-top: 0;
    padding-right: max(0.25rem, env(safe-area-inset-right));
    padding-bottom: calc(3.45rem + env(safe-area-inset-bottom));
    padding-left: max(0.25rem, env(safe-area-inset-left));
  }

  #map {
    min-height: min(58vh, calc(100dvh - 7.5rem));
    border-radius: 18px;
  }

  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(3.35rem + env(safe-area-inset-bottom));
    width: 100% !important;
    max-width: none;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    max-height: min(72vh, 540px);
    padding: 0.7rem max(0.85rem, env(safe-area-inset-left)) max(0.65rem, env(safe-area-inset-right));
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom));
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.38);
    z-index: 940;
    -webkit-overflow-scrolling: touch;
  }

  .panel:has(#panel-empty:not([hidden])) {
    max-height: min(30vh, 240px);
  }

  .panel__empty {
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .toast {
    bottom: calc(4.1rem + env(safe-area-inset-bottom));
  }

  .legend {
    left: max(8px, env(safe-area-inset-left));
    bottom: calc(3.5rem + 10px + env(safe-area-inset-bottom));
    max-width: calc(100% - max(16px, env(safe-area-inset-left) + env(safe-area-inset-right)));
    padding: 0.5rem 0.58rem;
    border-radius: 12px;
  }

  .legend h2 {
    font-size: 0.78rem;
  }

  .legend ul,
  .legend-block ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legend li,
  .legend-block li {
    font-size: 0.72rem;
    white-space: normal;
  }

  .list-panel {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: min(380px, calc(100% - max(16px, env(safe-area-inset-left) + env(safe-area-inset-right))));
    max-height: min(480px, calc(100% - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom))));
  }

  .point-list__item {
    min-height: 2.75rem;
    padding: 0.65rem 0.75rem;
  }

  .btn--icon {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
  }

  #map .leaflet-bottom.leaflet-right {
    margin-bottom: calc(3.2rem + env(safe-area-inset-bottom));
  }
}

.leaflet-container {
  font-family: var(--font);
}

#map .leaflet-bottom.leaflet-right {
  margin-right: max(0px, env(safe-area-inset-right));
  margin-bottom: max(2px, env(safe-area-inset-bottom));
}

#map .leaflet-top.leaflet-right {
  margin-top: max(0px, env(safe-area-inset-top));
  margin-right: max(0px, env(safe-area-inset-right));
}

#map .leaflet-control-zoom a {
  width: 2.5rem;
  height: 2.5rem;
  line-height: 2.5rem;
  font-size: 1.2rem;
}

/* Leaflet divIcon: kein Standard-Kasten */
.leaflet-div-icon.poi-marker {
  background: transparent !important;
  border: none !important;
}
