:root {
  --blue: #0b6e99;
  --blue-dark: #08506f;
  --ok: #1f9d55;
  --ok-light: #8fd6ac;
  --bad: #d64545;
  --bad-light: #f2a7a7;
  --ink: #1d2b36;
  --muted: #5d6f7c;
  --line: #d5dee4;
  --bg: #ffffff;
  --bg-soft: #f3f7f9;
  --shadow: 0 6px 24px rgba(16, 40, 56, .18);
  --radius: 14px;
  --bar-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

/* Kopfzeile */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 1000;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--blue); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { display: block; font-size: 18px; line-height: 1.1; }
.tagline { display: block; font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; align-items: center; gap: 6px; }
.bar select {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px; padding: 6px 4px; font-size: 14px;
}
.bar select option { color: var(--ink); }
.icon-btn {
  border: 0; background: transparent; color: inherit; font-size: 20px;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
}
.bar .icon-btn:hover { background: rgba(255,255,255,.12); }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 99px; font-weight: 600; }
.badge-warn { background: #ffd166; color: #4a3800; }

/* Karte */
#map {
  position: fixed; inset: calc(var(--bar-h) + env(safe-area-inset-top)) 0 0 0;
  background: #dfe8ec;
}
.leaflet-control-attribution { font-size: 10px; }

#crosshair {
  position: fixed; z-index: 900; left: 50%; top: calc(50% + var(--bar-h) / 2);
  width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: none;
  background:
    linear-gradient(var(--bad), var(--bad)) center / 2px 100% no-repeat,
    linear-gradient(var(--bad), var(--bad)) center / 100% 2px no-repeat;
  border-radius: 50%; box-shadow: 0 0 0 2px #fff inset;
}
.pick-bar {
  position: fixed; z-index: 1100; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.pick-bar p { margin: 0 0 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-block { display: flex; width: 100%; margin-top: 10px; }
.row { display: flex; gap: 8px; }
.row > .btn, .row > .toggle { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .btn { flex: 1 1 140px; }

.fabs {
  position: fixed; z-index: 950; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.fab { border: 0; cursor: pointer; box-shadow: var(--shadow); font: inherit; font-weight: 700; }
.fab-main {
  background: var(--blue); color: #fff; border-radius: 99px; padding: 0 20px; height: 54px; font-size: 16px;
}
.fab-small { background: var(--bg); color: var(--blue); width: 46px; height: 46px; border-radius: 50%; font-size: 22px; }

.legend {
  position: fixed; z-index: 940; left: 10px; bottom: calc(22px + env(safe-area-inset-bottom));
  transition: opacity .2s;
  background: rgba(255,255,255,.94); border-radius: 10px; padding: 8px 10px; box-shadow: var(--shadow);
  display: grid; gap: 4px; font-size: 12px; max-width: 46vw;
}
.legend > span { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.dot-working { background: var(--ok); }
.dot-working-u { background: var(--ok-light); }
.dot-broken { background: var(--bad); }
.dot-broken-u { background: var(--bad-light); }

.stats {
  position: fixed; z-index: 940; left: 50%; transform: translateX(-50%);
  top: calc(var(--bar-h) + env(safe-area-inset-top) + 10px);
  background: rgba(255,255,255,.94); padding: 6px 12px; border-radius: 99px; font-size: 12px;
  box-shadow: var(--shadow); white-space: nowrap; max-width: calc(100vw - 120px); overflow: hidden; text-overflow: ellipsis;
}
.stats:empty { display: none; }
.queue {
  position: fixed; z-index: 945; left: 50%; transform: translateX(-50%);
  top: calc(var(--bar-h) + env(safe-area-inset-top) + 46px);
  background: #ffd166; color: #4a3800; border: 0; border-radius: 99px; padding: 6px 12px;
  font: inherit; font-size: 12px; font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
}

/* Bottom Sheets */
.sheet {
  position: fixed; z-index: 1200; left: 0; right: 0; bottom: 0;
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  animation: up .18s ease-out;
}
@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; bottom: 16px; top: calc(var(--bar-h) + 16px); width: 400px; max-height: none; border-radius: 18px; }
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 4px 18px; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.sheet-body { padding: 4px 18px 18px; overflow-y: auto; }
.sheet h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
input[type=email], input[type=password], textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 16px;
}
textarea { resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input, .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg-soft); cursor: pointer;
}
.chip input:checked + span { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip input:focus-visible + span, .toggle input:focus-visible + span { outline: 3px solid #9fd0e6; }
.toggle { position: relative; display: flex; }
.toggle span {
  flex: 1; text-align: center; padding: 11px; border-radius: 10px; border: 2px solid var(--line); font-weight: 700; cursor: pointer;
}
.toggle-ok input:checked + span { border-color: var(--ok); background: #e8f6ee; color: #12693a; }
.toggle-bad input:checked + span { border-color: var(--bad); background: #fcecec; color: #9b2424; }

.pt-photo { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; margin: 6px 0 10px; background: var(--bg-soft); }
.pt-status { font-weight: 700; font-size: 16px; margin: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); }
.pill-good { background: #e8f6ee; border-color: #b9e3c9; color: #12693a; }
.muted { color: var(--muted); margin: 4px 0 12px; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); background: var(--bg-soft); border-radius: 10px; padding: 10px 12px; }
.err { color: var(--bad); font-weight: 600; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history .when { color: var(--muted); font-size: 12px; }
.history img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; float: right; margin-left: 8px; }
.partner-box { margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--blue); border-radius: 12px; background: #f4fafd; }
.partner-box h3 { margin-top: 0; }
.links { margin-top: 18px; font-size: 14px; }
.links a { color: var(--blue); }

.modal { position: fixed; inset: 0; z-index: 1500; background: rgba(16,40,56,.45); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--bg); border-radius: 18px; padding: 22px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.modal-box h2 { margin: 8px 0; }
.modal-box .hint { text-align: left; }

.toast {
  position: fixed; z-index: 1600; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + env(safe-area-inset-bottom)); max-width: min(92vw, 460px);
  background: #102838; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px;
}
.rw-cluster {
  background: var(--blue); color: #fff; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; border: 4px solid rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
@media (max-width: 380px) { .tagline { display: none; } .fab-main { padding: 0 16px; } }

@media (max-width: 560px) {
  .legend { bottom: auto; top: calc(var(--bar-h) + env(safe-area-inset-top) + 84px); left: 10px; max-width: 52vw; }
}

details.sub { margin-top: 14px; }
details.sub summary { cursor: pointer; font-weight: 700; color: var(--blue); padding: 6px 0; }
details.sub form { margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.partner-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.partner-row .who { flex: 1 1 160px; min-width: 0; }
.partner-row .who small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
input[type=text] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 16px; }

.dot-cluster { width: 22px; height: 22px; background: var(--blue); color: #fff; font-size: 9px; font-weight: 700; font-style: normal; display: inline-grid; place-items: center; border: 2px solid #1f9d55; box-shadow: none; }
