:root {
  --navy: #0b2b45;
  --navy-2: #103a5c;
  --deep: #072033;
  --teal: #1b9aaa;
  --teal-2: #14808e;
  --sand: #f4efe6;
  --foam: #eef4f8;
  --ink: #0e1c28;
  --muted: #5c7284;
  --line: #d9e2ea;
  --card: #ffffff;
  --danger: #c0392b;
  --warn: #e08a2b;
  --ok: #1f8a5b;
  --shadow: 0 2px 10px rgba(11, 43, 69, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--foam);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  line-height: 1.45;
}
a { color: var(--teal-2); }

/* ---- prevent iOS input zoom ---- */
@media (max-width: 1023px) {
  input:not([type='button']):not([type='submit']):not([type='reset']):not([type='checkbox']):not([type='radio']):not([type='file']):not([type='range']):not([type='color']),
  textarea,
  select { font-size: 16px; }
}

input, select, textarea, button { font-family: inherit; }
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 74px; resize: vertical; }
label { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--teal);
  color: #fff;
  transition: filter 0.15s ease;
}
button:hover { filter: brightness(1.05); }
button:active { filter: brightness(0.95); }
button.secondary { background: #e7eef3; color: var(--navy); }
button.ghost { background: transparent; color: var(--teal-2); min-height: 40px; padding: 8px 10px; }
button.danger { background: #fbe9e7; color: var(--danger); }
button.small { min-height: 38px; padding: 7px 12px; font-size: 0.85rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Splash ---- */
.boot-splash { display: grid; place-items: center; min-height: 70vh; color: var(--muted); gap: 14px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--teal);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--navy-2), transparent),
    linear-gradient(160deg, var(--navy), var(--deep));
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand .logo { font-size: 1.7rem; }
.brand h1 { font-size: 1.35rem; margin: 0; color: var(--navy); }
.auth-sub { color: var(--muted); margin: 4px 0 18px; font-size: 0.9rem; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; background: #eef4f8; color: var(--navy); }
.auth-tabs button.active { background: var(--navy); color: #fff; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }

/* ---- App shell ---- */
.app-shell { min-height: 100vh; padding-bottom: 76px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
}
.topbar .logo { font-size: 1.3rem; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .titles .t1 { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titles .t2 { font-size: 0.76rem; opacity: 0.8; }
.topbar select {
  width: auto; max-width: 46vw; background: rgba(255,255,255,0.12);
  color: #fff; border: 1px solid rgba(255,255,255,0.25);
}
.topbar select option { color: #000; }
.icon-btn { background: rgba(255,255,255,0.12); min-height: 40px; padding: 8px 12px; }

.container { max-width: 900px; margin: 0 auto; padding: 16px; }

/* ---- Bottom nav ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(7, 1fr);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px));
}
.tabbar a {
  text-decoration: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 1px; min-height: 44px; font-size: 0.56rem; font-weight: 600;
}
.tabbar a .ic { font-size: 1.1rem; }
.tabbar a.active { color: var(--teal-2); }

/* ---- Cards & lists ---- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin: 4px 0 12px;
}
.section-head h2 { font-size: 1.15rem; margin: 0; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .grid3 { grid-template-columns: 1fr 1fr; } }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; background: #e7eef3; color: var(--navy);
}
.badge.ok { background: #e2f5ec; color: var(--ok); }
.badge.warn { background: #fdf0dd; color: var(--warn); }
.badge.danger { background: #fbe4e0; color: var(--danger); }
.badge.teal { background: #dcf3f5; color: var(--teal-2); }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.item-title { font-weight: 700; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }

.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.empty .big { font-size: 2rem; }

.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 640px) { .stat-tiles { grid-template-columns: 1fr 1fr; } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.tile .n { font-size: 1.5rem; font-weight: 800; color: var(--navy); }
.tile .l { font-size: 0.76rem; color: var(--muted); }

.fab {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 45;
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.6rem; padding: 0;
  box-shadow: 0 8px 20px rgba(20, 128, 142, 0.4);
}

/* level pills (Alt) */
.levels { display: flex; gap: 6px; flex-wrap: wrap; }
.levels button { background: #eef4f8; color: var(--navy); min-height: 40px; padding: 8px 10px; flex: 1; }
.levels button.active { background: var(--teal); color: #fff; }

/* Prozent-Schieberegler */
input[type='range'].pct {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 12px; padding: 0; margin: 6px 0 14px;
  background: #e7eef3; border: none; border-radius: 999px; outline: none;
}
input[type='range'].pct::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal); border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer;
}
input[type='range'].pct::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal); border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer;
}
.pct-val { color: var(--teal-2); font-weight: 700; }

/* Datei-Ablage (Drag & Drop) */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 18px 14px;
  margin: 4px 0 6px;
  text-align: center;
  cursor: pointer;
  background: #f7fafc;
  transition: border-color 0.15s ease, background 0.15s ease;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.dropzone:hover { border-color: var(--teal); }
.dropzone.drag { border-color: var(--teal); background: #e6f5f7; }
.dropzone.has { border-style: solid; border-color: var(--teal); background: #eef8f9; }
.dropzone .dz-icon { font-size: 1.6rem; line-height: 1; }
.dropzone .dz-text { color: var(--muted); font-size: 0.9rem; }
.dropzone .dz-files { color: var(--teal-2); font-weight: 600; font-size: 0.85rem; word-break: break-all; }

/* Dokument-Link (PDF) in Vorschau-Listen */
.filechip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; min-height: 44px;
  background: #eef4f8; color: var(--navy); border: 1px solid var(--line);
  border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 0.85rem;
}
.filechip:hover { border-color: var(--teal); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(7, 32, 51, 0.55);
  z-index: 60; display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 20px; } }
.modal {
  background: #fff; width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal h3 { margin: 0 0 4px; color: var(--navy); }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions button { flex: 1; }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(90px + env(safe-area-inset-bottom, 0px)); z-index: 80;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 0.9rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--danger); }

/* Karte im Vollbild */
.card.map-full {
  position: fixed; inset: 0; z-index: 70; margin: 0; border-radius: 0;
  display: flex; flex-direction: column;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
}
.card.map-full #map { flex: 1; height: auto !important; min-height: 0 !important; margin-top: 8px; }
.leaflet-container { font: inherit; }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pointer { cursor: pointer; }
