/* PMH Service — mobile-first (~430 px zuerst) */
:root {
  --blau: #1d4ed8;
  --dunkel: #111827;
  --grau: #6b7280;
  --rand: #e5e7eb;
  --grund: #f3f4f6;
  --weiss: #ffffff;
  --rot: #dc2626;
  --gruen: #16a34a;
  --orange: #ea580c;
  --violett: #7c3aed;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--grund);
  color: var(--dunkel);
  padding-bottom: 72px;
}
main { padding: 12px; max-width: 900px; margin: 0 auto; }
h1 { font-size: 1.25rem; margin: 8px 0 12px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--dunkel); color: var(--weiss); padding: 10px 14px;
}
.marke { font-weight: 700; }
.nutzer { font-size: 0.85rem; opacity: 0.85; }

.navbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--weiss); border-top: 1px solid var(--rand);
}
.navbar a, .navbar button {
  flex: 1; text-align: center; padding: 14px 4px; font-size: 0.95rem;
  color: var(--grau); text-decoration: none; background: none; border: none;
  min-height: 48px; cursor: pointer;
}
.navbar a.aktiv { color: var(--blau); font-weight: 700; }
.nav-logout { flex: 1; display: flex; }
.nav-logout button { width: 100%; }

.flash {
  background: #fef2f2; border: 1px solid var(--rot); color: var(--rot);
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}

.login-box { max-width: 360px; margin: 10vh auto 0; background: var(--weiss);
  padding: 24px; border-radius: 12px; border: 1px solid var(--rand); }
.login-box h1 { margin: 0; }
.untertitel { color: var(--grau); margin-top: 4px; }

label { display: block; margin: 12px 0 4px; font-size: 0.9rem; color: var(--grau); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--rand); border-radius: 8px;
  font-size: 1rem; background: var(--weiss);
}

.btn {
  display: inline-block; width: 100%; padding: 14px; min-height: 48px;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none; margin-top: 14px;
}
.btn-primaer { background: var(--blau); color: var(--weiss); }
.leer { color: var(--grau); }

/* Karten & Badges */
.karte {
  background: var(--weiss); border: 1px solid var(--rand); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; display: block; color: inherit;
  text-decoration: none;
}
a.karte:active { background: #eef2ff; }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.karte-titel { font-weight: 700; margin-top: 4px; }
.karte-zeile { margin-top: 2px; font-size: 0.92rem; }
.karte-fuss { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px;
  font-size: 0.85rem; color: var(--grau); align-items: center; }
.ticket-nr { font-weight: 700; }
.ticket-nr a { color: inherit; }
.grau { color: var(--grau); }
.warnung { color: var(--orange); }
.pruefen { color: var(--blau); font-weight: 700; }
.prio { font-weight: 700; color: var(--rot); }

.badge { padding: 3px 8px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 700; color: var(--weiss); white-space: nowrap; }
.badge-neu { background: var(--grau); }
.badge-geplant { background: var(--blau); }
.badge-unterwegs { background: var(--orange); }
.badge-vor_ort { background: var(--violett); }
.badge-erledigt { background: var(--gruen); }
.badge-unterbrochen_zeit, .badge-unterbrochen_ersatzteil { background: var(--rot); }

/* Kopfzeile, Filter, Zähler */
.kopfzeile { display: flex; justify-content: space-between; align-items: center;
  gap: 8px; flex-wrap: wrap; }
.kopf-aktionen { display: flex; gap: 8px; }
.zaehler { display: flex; gap: 16px; margin: 4px 0 10px; color: var(--grau); }
.filterleiste { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filterleiste select { width: auto; flex: 1; min-width: 110px; padding: 10px; }

/* Buttons */
.btn-klein {
  display: inline-block; padding: 10px 14px; min-height: 44px; border-radius: 8px;
  background: var(--dunkel); color: var(--weiss); border: none; font-size: 0.9rem;
  font-weight: 600; text-decoration: none; cursor: pointer; line-height: 24px;
}
.btn-dunkel { background: var(--dunkel); color: var(--weiss); }
.btn-hell { background: var(--weiss); color: var(--dunkel); border: 1px solid var(--rand); }
.btn-gruen { background: var(--gruen); color: var(--weiss); }
.btn-orange { background: var(--orange); color: var(--weiss); }
.btn-rot { background: var(--rot); color: var(--weiss); }

/* Formulare */
.formular { padding: 16px; }
.feld-reihe { display: flex; gap: 10px; }
.feld-reihe > div { flex: 1; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.inline-form input { flex: 1; }

/* Planung */
.datum-wahl input { padding: 10px; }
.zuweisen-reihe { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-team { background: var(--weiss); border: 2px solid var(--blau); color: var(--dunkel);
  border-radius: 8px; padding: 10px 12px; min-height: 44px; font-weight: 600; cursor: pointer; }
.team-block { margin-top: 20px; }
.team-punkt { display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: 4px; }
.budget { font-size: 0.85rem; color: var(--grau); }
.budget-voll { color: var(--orange); font-weight: 700; }
.einsatz-zeile { display: flex; gap: 10px; align-items: center; }
.einsatz-nr { font-size: 1.1rem; font-weight: 700; color: var(--grau); min-width: 24px;
  text-align: center; }
.einsatz-mitte { flex: 1; }
.einsatz-aktionen { display: flex; gap: 6px; }
.einsatz-aktionen form { margin: 0; }
.btn-icon { width: 44px; height: 44px; border: 1px solid var(--rand); background: var(--weiss);
  border-radius: 8px; font-size: 1.1rem; cursor: pointer; }
.btn-icon-rot { color: var(--rot); }

h2 { font-size: 1.05rem; margin: 18px 0 8px; }

/* Techniker-Flow */
.aktiv-hinweis { background: #ecfdf5; border: 1px solid var(--gruen); color: var(--gruen);
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }
.aktiv-karte { border: 2px solid var(--gruen); }
.einsatz-karte.fertig { opacity: 0.55; }
.zurueck { display: inline-block; color: var(--grau); text-decoration: none;
  padding: 8px 0; font-size: 0.95rem; }
.btn-gross { padding: 18px; font-size: 1.1rem; }
.laufzeit-box { background: var(--dunkel); color: var(--weiss); border-radius: 8px;
  padding: 14px; text-align: center; font-size: 1.1rem; margin: 14px 0;
  font-variant-numeric: tabular-nums; }
.ergebnis-wahl { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ergebnis-karte { display: flex; align-items: center; gap: 10px; border: 1px solid var(--rand);
  border-radius: 8px; padding: 14px; margin: 0; cursor: pointer; font-size: 1rem;
  color: var(--dunkel); }
.ergebnis-karte:has(input:checked) { border-color: var(--blau); background: #eff6ff; }
.ergebnis-karte input { width: 20px; height: 20px; }

/* Karte (Planung) */
#karte { height: 340px; border-radius: 10px; border: 1px solid var(--rand);
  margin-bottom: 14px; z-index: 0; }
.stopp-marker span {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; color: #fff;
  font-weight: 700; font-size: 0.85rem; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.stopp-marker .start-marker { background: var(--dunkel); border-radius: 6px; }
.stopp-marker .pool-marker { background: var(--weiss); color: var(--grau);
  border: 2px solid var(--grau); }

/* Auto-Planung / Bestätigung */
.einsatz-zeile.unbestaetigt { border: 2px solid var(--orange); background: #fff7ed; }
.unbestaetigt-label { color: var(--orange); font-weight: 700; font-size: 0.8rem;
  margin-left: 6px; }
.btn-icon-gruen { color: var(--gruen); border-color: var(--gruen); font-weight: 700; }
.btn-bestaetigen { background: var(--gruen); }

/* Abstände Planung: Button-Zeile ↔ Karten, Aktionen auf Mobil in eigene Zeile */
.team-block .zuweisen-reihe { margin-bottom: 14px; }
.einsatz-zeile { margin-bottom: 12px; }
@media (max-width: 700px) {
  .einsatz-zeile { flex-wrap: wrap; }
  .einsatz-mitte { flex: 1 1 60%; }
  .einsatz-aktionen { width: 100%; justify-content: flex-end; margin-top: 10px; }
}

textarea { overflow: hidden; resize: vertical; }

/* Arbeitsbericht (Etappe 2) */
.hinweis { font-size: 0.85rem; margin: 2px 0 8px; }
.art-wahl { display: flex; flex-wrap: wrap; gap: 8px; }
.art-wahl .ergebnis-karte { flex: 1 1 40%; padding: 12px; }
.janein-frage { display: flex; align-items: center; gap: 10px; margin: 10px 0;
  flex-wrap: wrap; }
.janein-text { flex: 1 1 55%; font-size: 0.95rem; }
.janein { display: flex; gap: 8px; flex: 1 1 150px; }
.janein .ergebnis-karte { flex: 1; padding: 10px 0; justify-content: center; }
.ergebnis-karte.haken { flex: 1; justify-content: center; padding: 10px 0; }
.mat-zeile { display: grid; grid-template-columns: 2fr 1fr 70px; gap: 6px;
  margin-bottom: 6px; }
.mat-zeile.mat-leer { display: none; }
.zeit-block { margin-top: 10px; }
.sig-pad { width: 100%; border: 1px dashed var(--grau); border-radius: 8px;
  background: var(--weiss); touch-action: none; display: block; }
.sig-bild { max-height: 90px; border: 1px solid var(--rand); border-radius: 8px;
  display: block; margin-bottom: 6px; background: var(--weiss); }
.foto-zeile { border-bottom: 1px solid var(--rand); padding-bottom: 12px;
  margin-bottom: 12px; }
.foto-zeile img { max-width: 100%; max-height: 220px; border-radius: 8px; }
.bericht-fehlt { color: var(--orange); font-weight: 700; font-size: 0.85rem; }

/* Tages-Teamwahl (gemeinsamer Mitarbeiter-Zugang) */
.team-karten { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.team-karte { display: flex; align-items: center; gap: 10px; background: var(--weiss);
  border: 2px solid var(--rand); border-radius: 12px; padding: 20px;
  font-size: 1.15rem; font-weight: 700; cursor: pointer; text-align: left; }
.team-karte:active { background: #eff6ff; }
.team-banner { display: flex; justify-content: space-between; align-items: center;
  gap: 8px; background: var(--weiss); border: 2px solid var(--rand);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }

/* Planung: Desktop-Splitansicht (Ticketliste links, Detail-Panel rechts) */
.detail-spalte { display: none; }
@media (min-width: 1100px) {
  main:has(.planung-layout) { max-width: 1600px; }
  .planung-layout { display: flex; gap: 16px; align-items: flex-start; }
  .planung-spalte { flex: 1 1 54%; min-width: 0; }
  .detail-spalte { display: flex; flex-direction: column; flex: 1 1 46%;
    min-width: 0; position: sticky; top: 12px; height: calc(100vh - 96px); }
  .detail-kopf { display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 8px; min-height: 44px; }
  .detail-spalte iframe { flex: 1; width: 100%; border: 1px solid var(--rand);
    border-radius: 10px; background: var(--weiss); }
  .karte.detail-aktiv { border: 2px solid var(--blau); }
  a.ticket-link { cursor: pointer; }
}

/* Seite läuft eingebettet im Detail-Panel: App-Kopf und -Fußleiste ausblenden */
html.eingebettet .topbar, html.eingebettet .navbar { display: none; }
html.eingebettet body { padding-bottom: 16px; }
[data-ticket-url] { cursor: pointer; }
[data-ticket-url]:hover { border-color: var(--blau); }

/* Kopfleiste fixiert (Karl-Wunsch): bleibt beim Scrollen oben stehen */
.topbar { position: sticky; top: 0; z-index: 1100; }
@media (min-width: 1100px) {
  /* Detail-Panel der Planung rutscht unter die fixe Kopfleiste */
  .detail-spalte { top: 56px; height: calc(100vh - 72px); }
}
.hauser-meldung { border-left: 4px solid var(--blau); }
.stopp-marker.marker-aktiv span { transform: scale(1.4); box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.45), 0 1px 4px rgba(0, 0, 0, 0.4); }

/* iOS-Dunkelmodus: Buttons/Eingaben bekommen sonst weiße Systemschrift auf
   unserem weißen Grund (Karl-Fund iPhone, Team-Wahl). App ist bewusst hell. */
:root { color-scheme: light; }
button, input, select, textarea { color: var(--dunkel); }

/* Admin-Footer auf Handy: nur Tickets/Planung/Heute + "Mehr" (Karl-Fund iPhone) */
#mehr-knopf { display: none; }
.mehr-menue { position: fixed; bottom: 64px; right: 8px; background: var(--weiss);
  border: 1px solid var(--rand); border-radius: 12px; padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); z-index: 1200; min-width: 160px; }
.mehr-menue a, .mehr-menue button { display: block; width: 100%; padding: 14px 16px;
  text-align: left; color: var(--dunkel); text-decoration: none; background: none;
  border: none; font-size: 1rem; cursor: pointer; border-radius: 8px; }
.mehr-menue a:active, .mehr-menue button:active { background: var(--grund); }
@media (max-width: 700px) {
  .navbar .nav-extra { display: none; }
  #mehr-knopf { display: block; flex: 1; text-align: center; padding: 14px 4px;
    font-size: 0.95rem; color: var(--grau); background: none; border: none;
    min-height: 48px; cursor: pointer; }
  #mehr-knopf.aktiv { color: var(--blau); font-weight: 700; }
}
.richtung-form { margin: 0 0 8px; }
.richtung-form select { width: auto; min-width: 140px; padding: 8px; }

/* Offline-Warteschlange: Hinweisleiste über der Navigationsleiste */
.offline-banner {
  position: fixed; left: 0; right: 0; bottom: 49px; z-index: 20;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 12px; font-size: 0.9rem;
  background: #fff7ed; border-top: 1px solid #f59e0b; color: #7c2d12;
}
.offline-banner button { flex: 0 0 auto; }
.zustandsblock[hidden] { display: none !important; }

/* Kopfleiste: Rückweg immer am selben Platz — als App vom Startbildschirm
   gibt es keinen Browser-Zurück-Knopf. Auf dunklem Grund weiß, nicht blau. */
.topbar { justify-content: flex-start; gap: 10px; }
.topbar-links:empty { display: none; }
.nutzer { margin-left: auto; }
.topbar-zurueck {
  display: inline-block; padding: 6px 8px; margin: -6px 0 -6px -6px;
  color: var(--weiss); text-decoration: none; font-size: 0.95rem;
  white-space: nowrap; border-radius: 6px;
}
.topbar-zurueck:active { background: rgba(255, 255, 255, 0.15); }
