:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceee9;
  --text: #1b1f1d;
  --muted: #5d6661;
  --line: #d9ddd6;
  --accent: #0f6e5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --danger: #b3261e;
  --warn: #9a6200;
  --st-offen: #8a938e;
  --st-spaeter: #c78a00;
  --st-interesse: #1f6fd1;
  --st-auftrag: #0f8a4f;
  --st-kein: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111413; --surface: #1a1e1c; --surface-2: #232825; --text: #eef1ee; --muted: #a1aba5;
    --line: #2f3632; --accent: #3fbf9f; --accent-ink: #06231c; --accent-soft: #173a31;
    --danger: #ff8a80; --warn: #f2b84b; --st-offen: #87908b; --st-spaeter: #f2b84b;
    --st-interesse: #6aa8ff; --st-auftrag: #4fd18b; --st-kein: #ff8a80;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111413; --surface: #1a1e1c; --surface-2: #232825; --text: #eef1ee; --muted: #a1aba5;
  --line: #2f3632; --accent: #3fbf9f; --accent-ink: #06231c; --accent-soft: #173a31;
  --danger: #ff8a80; --warn: #f2b84b; --st-offen: #87908b; --st-spaeter: #f2b84b;
  --st-interesse: #6aa8ff; --st-auftrag: #4fd18b; --st-kein: #ff8a80;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { border: 0; background: none; font-size: 26px; line-height: 1; padding: 0 6px 0 0; cursor: pointer; }
.sync { font-size: 12px; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; }
.sync.ok { background: var(--accent-soft); color: var(--accent); }
.sync.pending { background: #fff1d6; color: var(--warn); }
.sync.offline { background: #fde3e1; color: var(--danger); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sync.pending { background: #3a2c0c; }
  :root:not([data-theme="light"]) .sync.offline { background: #3d1614; }
}

main { padding: 16px; max-width: 720px; margin: 0 auto; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=tel], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); font-size: 16px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 70px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 18px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Login */
.login { max-width: 360px; margin: 18vh auto 0; padding: 24px; text-align: center; }
.login h1 { font-size: 26px; margin: 0 0 4px; }
.login input { text-align: center; font-size: 24px; letter-spacing: 8px; margin: 18px 0 12px; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Suche */
.recent { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 8px 13px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; font-size: 14px; color: var(--muted); }
.tabs { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.tabs button.on { background: var(--surface); box-shadow: var(--shadow); }

.side-head { padding: 12px 0 8px; font-weight: 700; display: flex; justify-content: space-between; }
.side-head .muted { font-weight: 400; font-size: 14px; }

/* Laden-Karte */
.place { margin-bottom: 10px; overflow: hidden; border-left: 5px solid var(--st-offen); }
.place[data-status="spaeter"] { border-left-color: var(--st-spaeter); }
.place[data-status="interesse"] { border-left-color: var(--st-interesse); }
.place[data-status="auftrag"] { border-left-color: var(--st-auftrag); }
.place[data-status="kein_interesse"] { border-left-color: var(--st-kein); opacity: .6; }
.place-head { display: flex; gap: 12px; padding: 13px 14px; cursor: pointer; align-items: flex-start; }
.hn { min-width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; text-align: center; line-height: 1.1; padding: 2px; }
.place-title { flex: 1; min-width: 0; }
.place-title b { display: block; font-size: 16px; }
.place-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.badge { font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.badge.chain { background: #fff1d6; color: var(--warn); }
.badge.owner { background: var(--accent-soft); color: var(--accent); }
.badge.photos { background: #dcebff; color: #1f5fb0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.chain { background: #3a2c0c; }
  :root:not([data-theme="light"]) .badge.photos { background: #142a47; color: #8fbfff; }
}
.quick-call { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 20px; display: flex; align-items: center; justify-content: center; text-decoration: none; flex-shrink: 0; }

.place-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.status-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 12px 0; }
.status-row button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 2px; font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.15; }
.status-row button.on[data-s="offen"] { background: var(--st-offen); color: #fff; border-color: transparent; }
.status-row button.on[data-s="spaeter"] { background: var(--st-spaeter); color: #fff; border-color: transparent; }
.status-row button.on[data-s="interesse"] { background: var(--st-interesse); color: #fff; border-color: transparent; }
.status-row button.on[data-s="auftrag"] { background: var(--st-auftrag); color: #fff; border-color: transparent; }
.status-row button.on[data-s="kein_interesse"] { background: var(--st-kein); color: #fff; border-color: transparent; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.actions .btn { min-height: 44px; font-size: 14px; padding: 0 10px; }
.info-line { font-size: 14px; margin: 4px 0; }
.blocked-note { background: #fde3e1; color: var(--danger); border-radius: 10px; padding: 10px; font-size: 14px; margin: 10px 0; }

/* Karte */
#map { height: calc(100dvh - 230px); min-height: 320px; border-radius: var(--radius); overflow: hidden; }
.leaflet-container { background: var(--surface-2); }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

.fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 30;
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 30px; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer;
}

/* Bottom-Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 92dvh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); }
.sheet h2 { margin: 0 0 14px; font-size: 19px; }

/* Aufnahmeprotokoll */
.device { padding: 14px; margin-bottom: 12px; }
.device-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.device-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.thumb { position: relative; width: 74px; height: 74px; border-radius: 10px; flex-shrink: 0; background: var(--surface-2) center/cover no-repeat; }
.thumb .state { position: absolute; right: 3px; bottom: 3px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 0 4px; }
.thumb.add { display: flex; align-items: center; justify-content: center; font-size: 26px; border: 2px dashed var(--line); background: none; cursor: pointer; color: var(--muted); }
.label-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.label-chips .chip { padding: 6px 11px; font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; cursor: pointer; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; font-size: 18px; }

/* Kamera */
.camera { position: fixed; inset: 0; background: #000; z-index: 100; display: flex; flex-direction: column; }
.camera video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.camera .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.camera .flash.on { opacity: .7; transition: none; }
.camera-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; color: #fff; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(rgba(0,0,0,.55), transparent); font-weight: 600; }
.camera-bar { display: flex; align-items: center; justify-content: space-between; padding: 18px 26px calc(env(safe-area-inset-bottom) + 22px); background: #000; }
.shutter { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: #fff; box-shadow: inset 0 0 0 4px #000; cursor: pointer; }
.shutter:active { transform: scale(.94); }
.cam-btn { min-width: 76px; color: #fff; background: rgba(255,255,255,.14); border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 700; cursor: pointer; }
.cam-btn.done { background: var(--accent); color: var(--accent-ink); }
.counter { font-size: 15px; background: rgba(0,0,0,.5); padding: 5px 11px; border-radius: 99px; }
.cam-error { color: #fff; padding: 30px; text-align: center; margin: auto; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%); background: #1b1f1d; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 200; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
