/* KommunalOS · ITSM — Mobile-PWA.
   Helle Oberfläche, große Touch-Flächen (min. 44px), Safe-Area-Insets.
   Design-Tokens übernommen aus web/itsm/itsm.css (eigenständige Kopie). */

:root {
  --primary: #2273B9;
  --primary-dunkel: #185a92;
  --primary-hell: #e8f1f9;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --rot: #dc2626;
  --rot-hell: #fee2e2;
  --amber: #d97706;
  --amber-hell: #fef3c7;
  --gruen: #16a34a;
  --gruen-hell: #dcfce7;
  --violett: #7c3aed;
  --violett-hell: #ede9fe;
  --blau-hell: #dbeafe;
  --grau: #64748b;
  --grau-hell: #f1f5f9;
  --schatten: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --schatten-gross: 0 10px 30px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-oben: env(safe-area-inset-top, 0px);
  --safe-unten: env(safe-area-inset-bottom, 0px);
  --tabbar-hoehe: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* ── Formulare & Buttons ───────────────────────────────────────────── */
input, select, textarea, button { font-family: inherit; font-size: 16px; color: var(--text); }
input[type="text"], input[type="search"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  width: 100%;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 90px; }
label.feld { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.feld > input, label.feld > select, label.feld > textarea { margin-top: 4px; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; }
.btn.primaer { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primaer:active { background: var(--primary-dunkel); }
.btn.gefahr { color: var(--rot); border-color: #fecaca; }
.btn.gruen { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.btn.rot { background: var(--rot); border-color: var(--rot); color: #fff; }
.breit-btn { width: 100%; }
.btn-zeile { display: flex; gap: 10px; }
.btn-zeile .btn { flex: 1; }

/* ── Vollbild (Login / API-down) ───────────────────────────────────── */
.vollbild {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: calc(20px + var(--safe-oben)) 20px calc(20px + var(--safe-unten));
}
.vollbild .box {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--schatten-gross); padding: 28px 24px; width: 100%; max-width: 400px;
}
.vollbild .box .marke { font-weight: 800; font-size: 17px; margin-bottom: 4px; color: var(--muted); }
.vollbild .box .marke .modul { color: var(--primary); }
.vollbild .box .untertitel { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-fehler { color: var(--rot); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ── App-Shell ─────────────────────────────────────────────────────── */
#kopf {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + var(--safe-oben)) 16px 10px;
}
.wortmarke { font-weight: 700; font-size: 12px; color: var(--muted); white-space: nowrap; }
.wortmarke .modul { color: var(--primary); }

#view {
  padding: calc(64px + var(--safe-oben)) 14px calc(var(--tabbar-hoehe) + 18px + var(--safe-unten));
  max-width: 640px; margin: 0 auto;
}

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-unten);
}
#tabbar button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: none; background: transparent; cursor: pointer;
  min-height: var(--tabbar-hoehe);
  color: var(--muted); font-weight: 600; font-size: 11px;
}
#tabbar button.aktiv { color: var(--primary); }
#tabbar .tab-icon { font-size: 22px; line-height: 1.2; position: relative; }
.badge {
  position: absolute; top: -4px; right: -12px;
  background: var(--rot); color: #fff;
  border-radius: 999px; min-width: 17px; height: 17px;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
  padding: 0 4px;
}

/* ── Karten, Pills, Listen ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card.klickbar { cursor: pointer; }
.card.klickbar:active { background: var(--primary-hell); }

.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.pill.st-NEU { background: var(--blau-hell); color: var(--primary-dunkel); }
.pill.st-IN_BEARBEITUNG { background: var(--amber-hell); color: var(--amber); }
.pill.st-WARTET_RUECKMELDUNG, .pill.st-WARTET_GENEHMIGUNG { background: var(--violett-hell); color: var(--violett); }
.pill.st-GELOEST { background: var(--gruen-hell); color: var(--gruen); }
.pill.st-GESCHLOSSEN { background: var(--grau-hell); color: var(--grau); }
.pill.neutral { background: var(--grau-hell); color: var(--grau); }
.pill.gruen { background: var(--gruen-hell); color: var(--gruen); }
.pill.rot { background: var(--rot-hell); color: var(--rot); }
.pill.amber { background: var(--amber-hell); color: var(--amber); }
.pill.blau { background: var(--blau-hell); color: var(--primary-dunkel); }
.rot-text { color: var(--rot); font-weight: 700; }

.hinweis { font-size: 13px; color: var(--muted); }
.leer-hinweis { padding: 30px 10px; text-align: center; color: var(--muted); }
.lade { color: var(--muted); padding: 34px 10px; text-align: center; }
.fehler-box {
  background: var(--rot-hell); border: 1px solid #fecaca; color: var(--rot);
  border-radius: 10px; padding: 12px 14px; margin: 10px 0;
}
.seitenkopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* Ticket-Karten */
.tk-kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.tk-nr { font-size: 12px; font-weight: 700; color: var(--muted); }
.tk-alter { margin-left: auto; font-size: 12px; color: var(--muted); }
.tk-titel { font-weight: 600; word-break: break-word; }

/* ── Scan-Screen ───────────────────────────────────────────────────── */
.scan-start {
  display: flex; flex-direction: column; gap: 16px; align-items: stretch;
  padding-top: 24px;
}
.scan-gross {
  min-height: 130px; font-size: 22px; font-weight: 800;
  border-radius: 18px; flex-direction: column; gap: 6px;
}
.scan-gross .sub { font-size: 13px; font-weight: 500; opacity: .85; }

/* Vollbild-Kamera */
#scanner {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
#scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-rahmen {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -60%);
  width: min(72vw, 320px); aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, .9); border-radius: 20px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
}
#scanner-status {
  position: relative; z-index: 1; color: #fff; font-size: 14px;
  text-shadow: 0 1px 3px rgba(0,0,0,.7); margin-bottom: 12px; text-align: center; padding: 0 16px;
}
#scanner-abbrechen {
  position: relative; z-index: 1;
  width: calc(100% - 32px); margin: 0 16px calc(20px + var(--safe-unten));
  background: rgba(255, 255, 255, .92); border-color: transparent;
}

/* Asset-Card */
.asset-invnr { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.asset-meta { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.kv { display: flex; gap: 8px; padding: 4px 0; font-size: 14px; }
.kv .k { color: var(--muted); flex: 0 0 110px; font-weight: 600; }
.kv .v { flex: 1; word-break: break-word; }

/* Zeitleiste */
.zeitleiste { margin-top: 6px; border-left: 2px solid var(--border); padding-left: 14px; }
.zl-eintrag { position: relative; padding: 5px 0 9px; }
.zl-eintrag::before {
  content: ""; position: absolute; left: -20px; top: 12px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff;
}
.zl-text { font-size: 14px; word-break: break-word; }
.zl-zeit { font-size: 12px; color: var(--muted); }

/* Timeline (Ticket-Detail, Sprechblasen) */
.blase {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 9px 12px; background: #fff; margin-bottom: 8px;
}
.blase .kopf { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.blase .text { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.blase.system { background: var(--grau-hell); }

.kommentar-zeile { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.kommentar-zeile textarea { flex: 1; min-height: 44px; }

/* Vollbild-Overlay (Personensuche, Schnellerfassung usw.) */
.overlay {
  position: fixed; inset: 0; z-index: 90; background: var(--bg);
  display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-oben)) 14px calc(14px + var(--safe-unten));
  overflow-y: auto;
}
.overlay .overlay-kopf { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.overlay .overlay-kopf h2 { margin: 0; flex: 1; }
.overlay .overlay-kopf .btn { min-width: 44px; }
.personen-liste .card { display: flex; flex-direction: column; gap: 2px; }
.personen-liste .sub { font-size: 12px; color: var(--muted); }

/* Segmente (Typ-Auswahl) */
.segmente { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 4px 0 12px; }
.segmente button {
  flex: 1; border: none; background: #fff; padding: 11px 8px; min-height: 44px;
  cursor: pointer; font-weight: 600; color: var(--muted);
}
.segmente button.aktiv { background: var(--primary); color: #fff; }

/* Chips (Anhang / Asset) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--grau-hell); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600;
}
.chip button { border: none; background: transparent; cursor: pointer; color: var(--muted); font-weight: 700; padding: 0 2px; font-size: 15px; }

/* Erfolg-Screen */
.erfolg-screen { text-align: center; padding-top: 36px; }
.erfolg-screen .haken { font-size: 52px; }
.erfolg-screen .hd { font-size: 32px; font-weight: 800; color: var(--primary-dunkel); margin: 8px 0 4px; }

/* Ich-Screen */
.profil-kopf { text-align: center; padding: 8px 0 14px; }
.profil-kopf .avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--primary-hell);
  color: var(--primary-dunkel); font-size: 26px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px;
}
.profil-kopf .name { font-size: 18px; font-weight: 700; }
.geraete-zeile { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.geraete-zeile:last-child { border-bottom: none; }
.freigabe-aktionen { display: flex; gap: 10px; margin-top: 10px; }
.freigabe-aktionen .btn { flex: 1; }

/* ── Toasts ────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; bottom: calc(var(--tabbar-hoehe) + 14px + var(--safe-unten));
  left: 14px; right: 14px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--text); color: #fff; border-radius: 12px;
  padding: 12px 16px; box-shadow: var(--schatten-gross);
  font-size: 14px; animation: toast-rein .18s ease-out;
}
.toast.fehler { background: var(--rot); }
.toast.erfolg { background: var(--gruen); }
@keyframes toast-rein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
