:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #14171c;
  --muted: #5f6774;
  --border: #dde1e7;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --good: #1a7f37;
  --bad: #c62828;
  --warn: #b26a00;
  --radius: 12px;
  --tabs-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --surface-2: #222831;
    --text: #e8ebef;
    --muted: #9aa3b0;
    --border: #2c333d;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --good: #4ac26b;
    --bad: #ff6b6b;
    --warn: #f0a33a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top h1 { font-size: 17px; margin: 0; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.seg button.on { background: var(--accent); color: var(--accent-text); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px);
}

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabs button {
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.tabs button.on { color: var(--accent); font-weight: 600; }
.tabs button .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--bad);
}

.map {
  height: 42vh;
  min-height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-2);
}

.map.small { height: 32vh; min-height: 200px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.muted { color: var(--muted); font-size: 13px; }

.btn, button.primary, button.secondary, button.danger {
  border-radius: 10px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  min-height: 44px;
}

button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: 0.5; cursor: default; }
button.small { padding: 6px 10px; min-height: 34px; font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card.err { border-style: dashed; }

.opt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.opt-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--good);
  color: var(--surface);
}
.badge.bad { background: var(--bad); }
.badge.soft { background: var(--surface-2); color: var(--muted); }

.big { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big small { font-size: 14px; font-weight: 500; color: var(--muted); }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.facts b { color: var(--text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.chip.m2, .chip.m3, .chip.c8 { border-color: var(--bad); color: var(--bad); }
.chip.m1, .chip.c9 { border-color: var(--warn); color: var(--warn); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1; min-width: 0; }

input[type=text], input[type=password], input[type=search] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  min-height: 44px;
}

label.field { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }

h2 { font-size: 17px; margin: 20px 0 10px; }
h3 { font-size: 15px; margin: 14px 0 8px; }

.good { color: var(--good); }
.bad { color: var(--bad); }

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.live-dev { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .axis { stroke: var(--border); }
.chart .zero { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .pos { fill: var(--bad); }
.chart .neg { fill: var(--good); }

.results { margin-top: 6px; }
.results button {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  cursor: pointer;
}

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 2000;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#toast.show { opacity: 1; }

.via-marker {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 50%;
  width: 26px !important;
  height: 26px !important;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid #fff;
}

.pin {
  background: #111;
  color: #fff;
  border-radius: 6px;
  width: 26px !important;
  height: 26px !important;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid #fff;
}

.pos-dot {
  width: 18px !important;
  height: 18px !important;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--accent);
}

.leaflet-container { font: inherit; }

dialog.dialog {
  width: min(calc(100vw - 32px), 380px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
dialog.dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog.dialog p { margin: 0 0 12px; }
dialog.dialog input { width: 100%; margin-bottom: 12px; }
dialog.dialog .row { justify-content: flex-end; }

/* Login- und Einrichtungsseite (vom Server ausgeliefert) */
main.auth { max-width: 420px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 16px 24px; }
main.auth h1 { font-size: 22px; margin: 0 0 16px; }
main.auth form { display: grid; gap: 10px; }
main.auth input { width: 100%; }
