/* ═══ SkyGeoScan Kataster — eigenständige, fokussierte Feld-App ═══════════════
   Mobile-first: große Touch-Ziele (Feldarbeit mit Handschuhen), wenig Deko,
   SkyGeoScan-Branding (Navy #1a2e3f, Cyan #00b4d8). Bewusst KEIN Dashboard-Look.
   Die CSS-Variablen (--text1…3, --border, --glass, --accent) werden von den
   portierten Views (liste/akte/editor) in Inline-Styles referenziert. */

:root {
  --navy:      #1a2e3f;
  --navy-tief: #12212e;
  --navy-hell: #24394d;
  --cyan:      #00b4d8;
  --accent:    #00b4d8;
  --bg:        #0e1a24;      /* Grundfläche (dunkles Navy, blendfrei) */
  --panel:     #162735;      /* Karten/Panels */
  --glass:     rgba(255, 255, 255, 0.06);
  --border:    rgba(255, 255, 255, 0.12);
  --text1:     #eef4f8;
  --text2:     #b8c9d6;
  --text3:     #7e93a5;
  --rot:       #e05252;
  --gruen:     #3aaa35;
  --radius:    12px;
  --tap:       48px;         /* Mindest-Touch-Ziel */
  --topbar-h:  54px;
  --tabbar-h:  62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text1);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img { max-width: 100%; }
a { color: var(--cyan); }
[hidden] { display: none !important; }

/* ─── Screens ────────────────────────────────────────────────────────────── */
.screen { min-height: 100dvh; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
#screen-login {
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--navy-tief) 0%, var(--navy) 60%, #1f3a50 100%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px 26px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo-mark { font-size: 40px; margin-bottom: 8px; }
.login-logo h1 { font-size: 21px; font-weight: 700; letter-spacing: 0.4px; }
.login-logo h1 span { color: var(--cyan); }
.login-logo p { font-size: 12.5px; color: var(--text3); margin-top: 4px; }
.login-error {
  background: rgba(224, 82, 82, 0.12);
  border: 1px solid rgba(224, 82, 82, 0.4);
  color: #ff9d9d;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.login-step .form-input { margin-bottom: 14px; }
.login-hint { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 14px; }
.login-qr { text-align: center; margin-bottom: 10px; }
.login-qr img { border-radius: 10px; border: 4px solid var(--border); background: #fff; }
.login-secret {
  font-family: ui-monospace, monospace; font-size: 12.5px; color: var(--cyan);
  background: var(--navy-tief); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 10px; text-align: center; word-break: break-all; margin-bottom: 14px;
}

/* ─── Projekt-Auswahl ────────────────────────────────────────────────────── */
#screen-projekt { display: flex; justify-content: center; padding: 26px 16px; }
.projekt-wahl { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 14px; }
.projekt-wahl-kopf h2 { font-size: 22px; }
.projekt-wahl-kopf p { color: var(--text3); font-size: 13.5px; margin-top: 2px; }
.projekt-liste { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.projekt-karte {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-height: 64px;
  cursor: pointer; text-align: left; width: 100%; color: var(--text1);
  font: inherit; transition: border-color 0.15s, transform 0.06s;
}
.projekt-karte:active { transform: scale(0.99); }
.projekt-karte:hover { border-color: var(--cyan); }
.projekt-karte .pk-farbe { width: 14px; height: 42px; border-radius: 5px; flex-shrink: 0; }
.projekt-karte .pk-name { font-weight: 600; font-size: 16px; }
.projekt-karte .pk-sub { font-size: 12.5px; color: var(--text3); margin-top: 2px; }
.lade-hinweis { color: var(--text3); font-size: 13.5px; padding: 18px 4px; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: var(--navy);
  border-bottom: 1px solid var(--border);
}
.topbar-marke { font-weight: 700; font-size: 15px; white-space: nowrap; }
.topbar-marke span { color: var(--cyan); }
.topbar-projekt {
  flex: 1; min-width: 0; min-height: 40px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--glass); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text1); font: inherit; font-size: 14px; font-weight: 600;
  padding: 6px 12px; cursor: pointer;
}
.topbar-projekt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-logout {
  min-width: 40px; min-height: 40px;
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text2); font-size: 17px; cursor: pointer;
}
.topbar-logout:hover { color: var(--rot); border-color: var(--rot); }

/* ─── View-Bereich ───────────────────────────────────────────────────────── */
.view-wrap {
  padding: calc(var(--topbar-h) + 12px) 12px calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  max-width: 1280px; margin: 0 auto;
}
.view { animation: viewIn 0.14s ease; }
@keyframes viewIn { from { opacity: 0.4; } to { opacity: 1; } }

/* ─── Tab-Leiste (Hauptnavigation) ───────────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--navy);
  border-top: 1px solid var(--border);
}
.tab {
  flex: 1; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text3); text-decoration: none; font-size: 11px; font-weight: 600;
  border-top: 2px solid transparent;
}
.tab-icon { font-size: 20px; line-height: 1.15; }
.tab.active { color: var(--cyan); border-top-color: var(--cyan); background: rgba(0, 180, 216, 0.07); }

/* ─── Karten / Buttons / Formulare (von den portierten Views genutzt) ────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text1);
  font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s, transform 0.06s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #06222c; }
.btn-secondary { background: var(--glass); }
.btn-danger { background: rgba(224, 82, 82, 0.12); border-color: rgba(224, 82, 82, 0.45); color: #ff9d9d; }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 12px; }
.form-label { display: block; font-size: 12px; color: var(--text3); margin-bottom: 5px; letter-spacing: 0.3px; }
.form-input, select.form-input, textarea.form-input {
  width: 100%; min-height: var(--tap);
  background: var(--navy-tief);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text1);
  font: inherit; font-size: 15px;
  padding: 10px 12px;
  outline: none;
}
textarea.form-input { min-height: 70px; resize: vertical; }
.form-input:focus { border-color: var(--cyan); }
select.form-input { appearance: auto; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.form-actions .btn { flex: 1; }

/* ─── Leerzustände ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 48px 18px; color: var(--text3);
}
.empty-icon { font-size: 40px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text1); }
.empty-desc { font-size: 13.5px; max-width: 420px; line-height: 1.55; }
.empty-state .btn { margin-top: 10px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(6, 13, 19, 0.72);
  display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 640px;
  max-height: 92dvh; overflow: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: modalIn 0.16s ease;
}
@keyframes modalIn { from { transform: translateY(24px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }

/* ─── Foto-Großansicht ───────────────────────────────────────────────────── */
.foto-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 9, 13, 0.92);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.foto-overlay.open { display: flex; }
.foto-overlay img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* ─── Toast / Offline-Hinweis ────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(16px);
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  background: var(--navy-hell); color: var(--text1);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 18px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  max-width: min(92vw, 480px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(224, 82, 82, 0.55); color: #ffb1b1; }
.offline-badge {
  position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%);
  z-index: 60;
  background: #4d3a12; color: #ffd97a; border: 1px solid #8a6d2a;
  border-radius: 10px; padding: 7px 14px; font-size: 12.5px; font-weight: 600;
}

/* ─── Schäden-View: Liste + Akte (mobil nacheinander, breit nebeneinander) ── */
.sk-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.sk-tab {
  border: 1px solid var(--border); border-radius: 10px; background: transparent;
  color: var(--text3); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; min-height: 40px; cursor: pointer;
}
.sk-tab.active { background: var(--glass); color: var(--text1); border-color: var(--cyan); }
.sk-split { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
.sk-liste { display: flex; flex-direction: column; gap: 8px; }
.sk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; min-height: 56px; cursor: pointer;
}
.sk-item.active { border-color: var(--cyan); }
.sk-zurueck { margin-bottom: 10px; }
/* Mobil: entweder Liste ODER Akte sichtbar */
.sk-split .sk-detail { display: none; }
.sk-split.zeige-detail .sk-liste-wrap { display: none; }
.sk-split.zeige-detail .sk-detail { display: block; }
@media (min-width: 900px) {
  .sk-split { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); }
  .sk-split .sk-detail, .sk-split.zeige-detail .sk-liste-wrap { display: block; }
  .sk-zurueck { display: none; }
}

/* ─── Plan-Editor (portierter 2D-Viewer) ─────────────────────────────────── */
.pv-viewport {
  position: relative; overflow: hidden;
  height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 190px);
  min-height: 320px;
  flex: 1;
  background: var(--navy-tief);
  border: 1px solid var(--border); border-radius: 10px;
  cursor: grab;
  touch-action: none; /* Hook: Touch-Gesten (Pinch-Zoom/Pan) baut der Editor-Agent aus */
}
.pv-zeile { display: flex; gap: 10px; align-items: stretch; }
.pv-werkzeuge { width: 104px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.pv-ebenen { width: 160px; flex-shrink: 0; }
@media (max-width: 720px) {
  .pv-zeile { flex-wrap: wrap; }
  .pv-werkzeuge { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .pv-werkzeuge .btn { flex: 1 1 30%; }
  .pv-ebenen { width: 100%; }
  .pv-viewport { flex-basis: 100%; height: 56dvh; }
}
/* Desktop (Stufe b, Schreibtisch): der Editor lebt vom Platz – die Plan-View
   sprengt die 1280px-Deckelung von .view-wrap und nutzt die volle Fenster-
   breite und -höhe. Andere Views (Erfassen/Listen) bleiben bewusst schmal. */
@media (min-width: 1100px) {
  .view-wrap:has(#view-plan:not([hidden])) { max-width: none; }
  .pv-viewport { height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 150px); }
}

/* ─── Kleinkram ──────────────────────────────────────────────────────────── */
.hinweis-box {
  border: 1px dashed var(--border); border-radius: 10px;
  background: var(--glass); padding: 14px; font-size: 13px; color: var(--text2); line-height: 1.6;
}
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--glass); color: var(--text2); }
