:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b1d21;
  --muted: #6b7280;
  --line: #e6e8ec;
  --spoe: #e2001a;
  --spoe-dark: #b80016;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.06);
  /* 5-stufige Ampel */
  --a1: #c0392b;
  --a2: #e67e22;
  --a3: #f1c40f;
  --a4: #7cb342;
  --a5: #2e7d32;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.35;
}
.hidden { display: none !important; }
.screen { min-height: 100%; }

/* ---------- Buttons / Inputs ---------- */
button { font: inherit; cursor: pointer; border: none; border-radius: 12px; }
.primary { background: var(--spoe); color: #fff; padding: 15px 18px; font-weight: 600; }
.primary:active { background: var(--spoe-dark); }
.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line); padding: 14px 18px; font-weight: 600; }
.wide { width: 100%; }
input, textarea {
  width: 100%; font: inherit; padding: 14px; margin: 6px 0;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--spoe); }

/* ---------- Login ---------- */
#login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 22px; width: 100%; max-width: 380px; }
.brand { font-size: 26px; font-weight: 800; color: var(--spoe); letter-spacing: -.5px; }
.sub { color: var(--muted); margin: 4px 0 18px; }
.error { color: var(--spoe); min-height: 20px; margin: 8px 0 0; font-size: 15px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
}
.gemeinde { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; flex: none; }
.seg-btn { background: transparent; color: var(--muted); padding: 7px 11px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.seg-btn.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.icon-btn { background: transparent; color: var(--muted); font-size: 20px; padding: 8px 10px; }

.offline-bar { background: #fff7e6; color: #92600a; border-bottom: 1px solid #f3e2bd; padding: 8px 14px; font-size: 14px; text-align: center; }

/* ---------- Liste ---------- */
.list { list-style: none; margin: 0; padding: 8px 12px 28px; }
.row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px; min-height: 60px; cursor: pointer;
}
.row:active { transform: scale(.995); }
.dot { width: 26px; height: 26px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.row-main { flex: 1; min-width: 0; }
.row-addr { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.row-dist { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; flex: none; }
.visited { color: var(--a5); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Ampel-Farben */
.a1 { background: var(--a1); } .a2 { background: var(--a2); } .a3 { background: var(--a3); }
.a4 { background: var(--a4); } .a5 { background: var(--a5); }

/* ---------- Karte ---------- */
#mapView { position: absolute; left: 0; right: 0; bottom: 0; top: 0; }
#map { width: 100%; height: 100%; }
.map-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--muted); background: var(--bg); }

/* ---------- Sheet (Detail + Anliegen) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.18); animation: slideup .18s ease-out;
  max-height: 88vh; overflow-y: auto; position: relative;
}
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-close { position: absolute; right: 12px; top: 10px; background: transparent; font-size: 28px; color: var(--muted); line-height: 1; padding: 4px 8px; }
.sheet-head { display: flex; align-items: center; gap: 16px; margin: 6px 0 14px; }
.ampel-big { width: 52px; height: 52px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 3px rgba(255,255,255,.7); }
.d-address { font-size: 20px; font-weight: 700; }
.d-label { color: var(--muted); }
.factors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: #34373d; }
.last-visit { background: #eef7ef; color: #2e7d32; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.d-section-title { font-weight: 700; margin: 6px 0 10px; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.outcome { padding: 16px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; text-align: center; display: flex; align-items: center; justify-content: center; min-height: 64px; }
.outcome .oc-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.outcome:active { background: var(--bg); }
.an-for { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.hint-small { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1b1d21; color: #fff; padding: 12px 18px; border-radius: 999px; z-index: 100; box-shadow: var(--shadow); font-size: 15px; }

@media (min-width: 620px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 20px; }
}

/* ---------- Registrierung ---------- */
select { width: 100%; font: inherit; padding: 14px; margin: 6px 0; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); }
.switch { text-align: center; color: var(--muted); font-size: 15px; margin-top: 16px; }
.link { color: var(--spoe); font-weight: 600; cursor: pointer; }

/* ---------- Admin-Verwaltung ---------- */
.badge { background: var(--spoe); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 13px; margin-left: 6px; vertical-align: middle; }
.admin-body { padding: 14px 12px 30px; max-width: 680px; margin: 0 auto; }
.admin-section { margin-bottom: 22px; }
.admin-section h3 { font-size: 16px; margin: 6px 4px 10px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.arow { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 8px; }
.arow.col { display: block; }
.arow-main { flex: 1; min-width: 0; }
.arow-actions { display: flex; gap: 8px; flex: none; }
.mini { padding: 10px 13px; border-radius: 10px; font-weight: 600; font-size: 14px; border: 1.5px solid var(--line); background: #fff; }
.mini.approve { background: var(--a5); color: #fff; border-color: var(--a5); }
.mini.reject { color: var(--a1); border-color: #f0c9c4; }
.an-text { margin: 6px 0; }
.super-row { display: flex; gap: 8px; align-items: center; }
.super-row select { flex: 1; margin: 0; }
.data-stats { color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.role-select { flex: none; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; }
