:root {
  --ink: #16302b;
  --ink-2: #4a5c57;
  --muted: #74837e;
  --bg: #f3f4f1;
  --card: #ffffff;
  --line: #dde2dc;
  --accent: #d4401f;
  --accent-ink: #ffffff;
  --s-haengt: #d4401f;
  --s-beschaedigt: #e3a008;
  --s-eingesammelt: #8b9893;
  --ok: #1a7f4b;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 22px 0 6px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 10px 0 0; }
input, select {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; font-size: 16px; color: var(--ink);
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
input[type=checkbox] { display: inline; width: auto; margin: 0 8px 0 0; }
input[type=file], [hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 11px;
  background: #fff; color: var(--ink); font: 600 15px system-ui, -apple-system, sans-serif; cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.go { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.danger { color: #b3261e; border-color: #efc9c5; }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 28px 24px; }
.login-card h1 { margin: 8px 0 0; font-size: 24px; }
.login-card .btn { margin-top: 18px; }
.login-logo img { display: block; border-radius: 14px; }
.err { color: #b3261e; font-size: 14px; }

/* ---------- Layout ---------- */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--safe-t)) 12px 8px; background: var(--ink); color: #fff; z-index: 1001;
}
.brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.topbar select {
  margin: 0; flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px;
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.22); font-size: 15px;
}
.topbar select option { color: var(--ink); }
.badge {
  border: 0; border-radius: 99px; padding: 5px 10px; background: var(--s-beschaedigt); color: #1b1300;
  font: 700 12px system-ui, sans-serif; white-space: nowrap; cursor: pointer;
}
main { position: relative; flex: 1; min-height: 0; }
.view { position: absolute; inset: 0; }
.view.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 14px 14px 32px; max-width: 720px; margin: 0 auto; }

/* ---------- Tabbar ---------- */
.tabbar {
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line); z-index: 1001;
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font: 600 11px system-ui, sans-serif; cursor: pointer;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--ink); }
.tabbar .fab {
  flex: 0 0 62px; height: 62px; margin-top: -20px; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(212,64,31,.4);
}
.tabbar .fab svg { width: 30px; height: 30px; }

/* ---------- Karte ---------- */
#map { position: absolute; inset: 0; background: #e8ebe6; }
.maperr { position: absolute; top: 12px; left: 12px; right: 12px; background: #fff; padding: 12px; border-radius: 12px; z-index: 500; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.mapbtn {
  position: absolute; right: 12px; bottom: 54px; z-index: 600;
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff; color: var(--ink);
  display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.18); cursor: pointer;
}
.legend {
  position: absolute; left: 10px; bottom: 12px; z-index: 600;
  display: flex; gap: 10px; padding: 6px 10px; border-radius: 99px;
  background: rgba(255,255,255,.92); font-size: 12px; color: var(--ink-2); box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.s-haengt { background: var(--s-haengt); }
.s-beschaedigt { background: var(--s-beschaedigt); }
.s-eingesammelt { background: var(--s-eingesammelt); }
#v-karte.placing .legend, #v-karte.placing .mapbtn { display: none; }

.crosshair { position: absolute; z-index: 650; width: 0; height: 0; pointer-events: none; }
.crosshair span {
  position: absolute; left: -22px; top: -22px; width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--accent); background: rgba(212,64,31,.12);
}
.crosshair span::before, .crosshair span::after { content: ""; position: absolute; background: var(--accent); }
.crosshair span::before { left: 50%; top: -12px; bottom: -12px; width: 2px; margin-left: -1px; }
.crosshair span::after { top: 50%; left: -12px; right: -12px; height: 2px; margin-top: -1px; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 700;
  background: #fff; border-radius: 18px 18px 0 0; padding: 14px 16px 16px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.15); max-height: 70%; overflow-y: auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.hint { margin: 4px 0 2px; font-size: 13px; color: var(--ink-2); }
.foto-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.foto-row .btn { margin: 0; font-size: 15px; color: var(--ink); }
.foto-preview { position: relative; }
.foto-preview img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.foto-preview button {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; font-size: 12px; cursor: pointer;
}
.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }

/* Leaflet-Popups */
.leaflet-popup-content { margin: 12px; min-width: 220px; }
.leaflet-popup-content .card { box-shadow: none; padding: 0; margin: 0; border: 0; }
.leaflet-container { font: inherit; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 0 0 7px rgba(26,115,232,.18); }

/* ---------- Liste ---------- */
.stats { background: var(--card); border-radius: var(--radius); padding: 14px; }
.stats .nums { display: flex; justify-content: space-between; gap: 8px; }
.stats .num b { display: block; font-size: 24px; line-height: 1.1; }
.stats .num span { font-size: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 99px; background: #e6e9e4; margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.chips { display: flex; gap: 8px; margin: 14px 0 8px; overflow-x: auto; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 99px; padding: 8px 14px; font: 600 14px system-ui, sans-serif; cursor: pointer;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.list-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }

.card {
  display: flex; gap: 12px; background: var(--card); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px; border-left: 5px solid var(--line);
}
.card.st-haengt { border-left-color: var(--s-haengt); }
.card.st-beschaedigt { border-left-color: var(--s-beschaedigt); }
.card.st-eingesammelt { border-left-color: var(--s-eingesammelt); opacity: .8; }
.card .thumb { flex: 0 0 72px; width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: #e6e9e4; cursor: zoom-in; }
.card .nothumb { flex: 0 0 72px; height: 72px; border-radius: 10px; background: #eef0ec; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 650; word-wrap: break-word; }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card .dist { font-weight: 700; color: var(--ink); }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.leaflet-popup-content .card { flex-direction: column; }
.leaflet-popup-content .card .thumb { width: 100%; height: 140px; flex-basis: auto; }
.leaflet-popup-content .card .nothumb { display: none; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; color: #fff; vertical-align: 1px; }
.pill.st-haengt { background: var(--s-haengt); }
.pill.st-beschaedigt { background: var(--s-beschaedigt); color: #2a1d00; }
.pill.st-eingesammelt { background: var(--s-eingesammelt); }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------- Verwaltung ---------- */
.adm-row { background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.adm-row .body { flex: 1 1 220px; min-width: 0; }
.adm-row .sub { font-size: 12.5px; color: var(--muted); }
.adm-row .tools { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; margin: 6px 0 4px; }
.inline-form input { margin: 0; }
.tag { display: inline-block; font-size: 11px; background: #eef0ec; border-radius: 6px; padding: 1px 6px; margin: 2px 3px 0 0; }
.tag.admin { background: var(--ink); color: #fff; }
.checks label { display: flex; align-items: center; font-weight: 500; color: var(--ink); padding: 8px 0; margin: 0; border-bottom: 1px solid #eef0ec; }

/* ---------- Toast & Modal ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 3000; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; z-index: 2500; background: rgba(10,20,18,.55); display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; }
.modal-box.photo { padding: 0; background: #000; max-width: 900px; }
.modal-box.photo img { display: block; width: 100%; height: auto; max-height: 86vh; object-fit: contain; }
.modal-box h3 { margin-top: 0; }
