/* ---------- Grundlagen ---------- */
:root {
  --bg: #f4f5f7;
  --flaeche: #ffffff;
  --flaeche-2: #f8fafc;
  --rand: #e2e6ec;
  --rand-stark: #cbd2dc;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8a94a6;
  --akzent: #2563eb;
  --akzent-dunkel: #1d4ed8;
  --akzent-hell: #dbeafe;
  --gruen: #16a34a;
  --gruen-hell: #dcfce7;
  --rot: #dc2626;
  --rot-hell: #fee2e2;
  --gelb: #d97706;
  --gelb-hell: #fef3c7;
  --lila: #7c3aed;
  --lila-hell: #ede9fe;
  --nav-bg: #0f172a;
  --nav-text: #cbd5e1;
  --nav-aktiv: #1e293b;
  --schatten: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --schatten-gross: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --radius-klein: 6px;
  --nav-breite: 232px;
  --tab-hoehe: 60px;
  --safe-unten: env(safe-area-inset-bottom, 0px);
  --safe-oben: env(safe-area-inset-top, 0px);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .6em; }
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.dezent { color: var(--text-2); }
.klein { font-size: 13px; }
.sehr-klein { font-size: 12px; color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.rechts { text-align: right; }
.zeile { display: flex; align-items: center; gap: 8px; }
.zeile.umbruch { flex-wrap: wrap; }
.wachsen { flex: 1 1 auto; min-width: 0; }
.abstand { height: 12px; }
.kuerzen { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; display: flex; }
.nav {
  width: var(--nav-breite); flex: 0 0 auto; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding-top: var(--safe-oben);
}
.nav-kopf { padding: 18px 18px 10px; }
.nav-kopf .firma { color: #fff; font-weight: 650; font-size: 15px; }
.nav-kopf .person { font-size: 13px; color: var(--text-3); }
.nav-gruppe { padding: 12px 10px 2px 18px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #64748b; }
.nav a.nav-eintrag {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 1px 8px; border-radius: 8px;
  color: var(--nav-text); font-weight: 500; font-size: 14px;
}
.nav a.nav-eintrag:hover { background: var(--nav-aktiv); text-decoration: none; color: #fff; }
.nav a.nav-eintrag.aktiv { background: var(--nav-aktiv); color: #fff; }
.nav a.nav-eintrag svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.nav .nav-fuss { margin-top: auto; padding: 12px 8px calc(12px + var(--safe-unten)); }
.nav .status-zeile { font-size: 12px; color: #94a3b8; padding: 6px 12px; display: flex; align-items: center; gap: 8px; }
.punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--gruen); display: inline-block; }
.punkt.offline { background: var(--gelb); }
.punkt.wartend { background: var(--akzent); animation: puls 1.4s infinite; }
@keyframes puls { 50% { opacity: .3; } }

.inhalt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.kopf {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--flaeche);
  border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 20; padding-top: calc(14px + var(--safe-oben));
}
.kopf h1 { flex: 1 1 auto; min-width: 0; }
.seite { padding: 20px 24px calc(24px + var(--safe-unten)); max-width: 1400px; width: 100%; }
.seite.breit { max-width: none; }
.tabs { display: none; }

@media (max-width: 899px) {
  .app { flex-direction: column; }
  .nav { display: none; }
  .kopf { padding: 12px 16px; padding-top: calc(12px + var(--safe-oben)); }
  .kopf h1 { font-size: 19px; }
  .seite { padding: 14px 14px calc(var(--tab-hoehe) + 20px + var(--safe-unten)); }
  .tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tab-hoehe) + var(--safe-unten));
    background: var(--flaeche); border-top: 1px solid var(--rand); z-index: 30; padding-bottom: var(--safe-unten);
  }
  .tabs a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; color: var(--text-3); font-weight: 500;
  }
  .tabs a.aktiv { color: var(--akzent); }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs a:hover { text-decoration: none; }
  .nur-desktop { display: none !important; }
}
@media (min-width: 900px) { .nur-mobil { display: none !important; } }

/* ---------- Bausteine ---------- */
.karte {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten);
}
.karte.polster { padding: 16px; }
.karte + .karte { margin-top: 12px; }
.raster > .karte + .karte { margin-top: 0; }
.karte-kopf { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rand); }
.karte-kopf h2 { flex: 1; }
.karte-inhalt { padding: 16px; }
.raster { display: grid; gap: 12px; }
.raster.zwei { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.raster.kacheln { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px;
  border-radius: 8px; border: 1px solid var(--rand-stark); background: var(--flaeche); font-weight: 550; font-size: 14px;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.knopf:hover { background: var(--flaeche-2); }
.knopf:disabled { opacity: .5; cursor: default; }
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.knopf.primaer:hover { background: var(--akzent-dunkel); }
.knopf.gefahr { color: var(--rot); border-color: #fca5a5; }
.knopf.gefahr:hover { background: var(--rot-hell); }
.knopf.gruen { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.knopf.leise { border-color: transparent; background: transparent; }
.knopf.leise:hover { background: var(--rand); }
.knopf.klein { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.knopf.gross { padding: 14px 20px; min-height: 52px; font-size: 16px; }
.knopf.block { width: 100%; }
.knopf svg { width: 16px; height: 16px; }
.knopf.symbol { padding: 6px; width: 38px; }

.feld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.feld label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.eingabe, input[type=text], input[type=email], input[type=password], input[type=search], input[type=date],
input[type=time], input[type=datetime-local], input[type=number], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; min-height: 40px; border: 1px solid var(--rand-stark); border-radius: 8px;
  background: var(--flaeche); outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--akzent); box-shadow: 0 0 0 3px var(--akzent-hell); }
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234b5563' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--akzent); margin: 0; }
.schalter { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--rand-stark); border: none; padding: 0; transition: background .15s; flex: 0 0 auto; }
.schalter::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.schalter.an { background: var(--gruen); }
.schalter.an::after { left: 21px; }
.formular-zeile { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .formular-zeile { grid-template-columns: 1fr; } }
.fehler-text { color: var(--rot); font-size: 13px; }
.hinweis { padding: 10px 12px; border-radius: 8px; background: var(--akzent-hell); color: #1e3a8a; font-size: 13px; }
.hinweis.warnung { background: var(--gelb-hell); color: #78350f; }
.hinweis.fehler { background: var(--rot-hell); color: #7f1d1d; }
.hinweis.erfolg { background: var(--gruen-hell); color: #14532d; }

.pille {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--rand); color: var(--text-2); white-space: nowrap; line-height: 1.5;
}
.pille .punkt { width: 7px; height: 7px; }
.pille.dringend { background: var(--rot-hell); color: var(--rot); }
.pille.rolle-admin { background: var(--lila-hell); color: var(--lila); }
.pille.rolle-buero { background: var(--akzent-hell); color: var(--akzent-dunkel); }
.pille.rolle-monteur { background: var(--gruen-hell); color: #15803d; }
.pille.inaktiv { background: var(--rand); color: var(--text-3); }

.chip-leiste { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--rand-stark); background: var(--flaeche); font-size: 13px; font-weight: 550; color: var(--text-2);
}
.chip.aktiv { background: var(--nav-bg); border-color: var(--nav-bg); color: #fff; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste-eintrag {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rand); color: inherit;
}
.liste-eintrag:last-child { border-bottom: none; }
a.liste-eintrag:hover { background: var(--flaeche-2); text-decoration: none; }
.liste-eintrag .haupt { flex: 1 1 auto; min-width: 0; }
.liste-eintrag .titel { font-weight: 600; }
.liste-eintrag .neben { font-size: 13px; color: var(--text-2); }
.leer { padding: 32px 16px; text-align: center; color: var(--text-3); }

.tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabelle th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 8px 12px; border-bottom: 1px solid var(--rand); font-weight: 600; }
.tabelle td { padding: 10px 12px; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle tr:last-child td { border-bottom: none; }
.tabelle tr.klickbar { cursor: pointer; }
.tabelle tr.klickbar:hover td { background: var(--flaeche-2); }
.tabelle-scroll { overflow-x: auto; }

.suche { position: relative; }
.suche input { padding-left: 36px; }
.suche svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); }

.kennzahl { padding: 14px 16px; }
.kennzahl .wert { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kennzahl .bezeichnung { font-size: 13px; color: var(--text-2); }
.kennzahl.warn .wert { color: var(--rot); }

.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--akzent-hell); color: var(--akzent-dunkel); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto; }

/* ---------- Dialog ---------- */
.dialog-hintergrund { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.dialog {
  background: var(--flaeche); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0;
  box-shadow: var(--schatten-gross); animation: hoch .18s ease-out; padding-bottom: var(--safe-unten);
}
.dialog.breit { max-width: 900px; }
@keyframes hoch { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 900px) {
  .dialog-hintergrund { align-items: center; padding: 24px; }
  .dialog { border-radius: 14px; max-height: 90vh; }
}
.dialog-kopf { display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px; border-bottom: 1px solid var(--rand); position: sticky; top: 0; background: var(--flaeche); z-index: 1; }
.dialog-kopf h2 { flex: 1; }
.dialog-inhalt { padding: 16px 20px; }
.dialog-fuss { display: flex; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--rand); position: sticky; bottom: 0; background: var(--flaeche); }
.dialog-fuss .wachsen { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--tab-hoehe) + 16px + var(--safe-unten)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: var(--nav-bg); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--schatten-gross); animation: hoch .2s; max-width: 90vw; }
.toast.fehler { background: var(--rot); }
.toast.erfolg { background: var(--gruen); }

/* ---------- Laden ---------- */
.laden-voll { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--rand); border-top-color: var(--akzent); border-radius: 50%; animation: dreh .8s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }
.laden-zeile { display: flex; justify-content: center; padding: 24px; }

/* ---------- Anmeldung ---------- */
.login { flex: 1 1 auto; width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--nav-bg); }
.login .karte { width: 100%; max-width: 380px; padding: 28px; }
.login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login .logo img { width: 44px; height: 44px; border-radius: 10px; }

/* ---------- Plantafel ---------- */
.plantafel-werkzeuge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.plantafel-werkzeuge .kw { font-weight: 650; font-size: 16px; min-width: 200px; }
.plantafel { overflow: auto; border: 1px solid var(--rand); border-radius: var(--radius); background: var(--flaeche); }
.plantafel table { border-collapse: separate; border-spacing: 0; min-width: 1100px; width: 100%; table-layout: fixed; }
.plantafel th, .plantafel td { border-bottom: 1px solid var(--rand); border-right: 1px solid var(--rand); vertical-align: top; }
.plantafel th { position: sticky; top: 0; background: var(--flaeche-2); z-index: 3; padding: 8px 10px; text-align: left; font-size: 13px; font-weight: 600; }
.plantafel th.heute { background: var(--akzent-hell); color: var(--akzent-dunkel); }
.plantafel th.wochenende, .plantafel td.wochenende { background: #fafbfc; }
.plantafel th .datum { color: var(--text-3); font-weight: 500; font-size: 12px; }
.plantafel td.mitarbeiter, .plantafel th.mitarbeiter { position: sticky; left: 0; background: var(--flaeche); z-index: 2; width: 160px; min-width: 160px; font-weight: 600; font-size: 13px; padding: 8px 10px; }
.plantafel th.mitarbeiter { z-index: 4; }
.plantafel td.mitarbeiter .klein { font-weight: 400; }
.plantafel tr.gruppe td { background: var(--flaeche-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 10px; font-weight: 600; position: sticky; left: 0; }
.plantafel td.zelle { padding: 4px; min-height: 56px; height: 56px; cursor: cell; transition: background .1s; }
.plantafel td.zelle.heute { background: #f5f9ff; }
.plantafel td.zelle.ziel { background: var(--akzent-hell); }
.plantafel td.zelle.abwesend { background: repeating-linear-gradient(45deg, transparent 0 8px, #f1f5f9 8px 16px); }
.termin-chip {
  display: block; padding: 4px 6px 4px 8px; margin-bottom: 4px; border-radius: 6px; background: var(--flaeche-2); border: 1px solid var(--rand);
  border-left: 4px solid var(--chip-farbe, #94a3b8); font-size: 12px; line-height: 1.3; cursor: pointer; user-select: none; overflow: hidden;
}
.termin-chip:hover { background: #fff; box-shadow: var(--schatten); }
.termin-chip .zeit { color: var(--text-2); font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.termin-chip .zeit .dauer { font-weight: 500; color: var(--text-3); }
.termin-chip .titel { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termin-chip .ort { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termin-chip.ganztags { background: var(--chip-hell, var(--flaeche-2)); }
.termin-chip.art-urlaub { --chip-farbe: #16a34a; --chip-hell: #dcfce7; }
.termin-chip.art-krank { --chip-farbe: #dc2626; --chip-hell: #fee2e2; }
.termin-chip.art-schule { --chip-farbe: #7c3aed; --chip-hell: #ede9fe; }
.termin-chip.art-intern { --chip-farbe: #64748b; --chip-hell: #f1f5f9; }
.termin-chip.mehrere::after { content: "👥"; float: right; font-size: 10px; opacity: .7; }
.termin-chip.ziehen { opacity: .4; }

/* ---------- Tagesansicht Monteur ---------- */
.tag-karte { display: block; color: inherit; padding: 14px 16px; }
.tag-karte:hover { text-decoration: none; background: var(--flaeche-2); }
.tag-karte .zeit { font-weight: 700; font-size: 15px; color: var(--akzent-dunkel); }
.tag-karte .titel { font-weight: 650; font-size: 16px; margin: 2px 0; }
.tag-karte .adresse { color: var(--text-2); }
.tag-karte .mitfahrer { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag-karte.art-urlaub, .tag-karte.art-krank, .tag-karte.art-schule, .tag-karte.art-intern { border-left: 4px solid var(--chip-farbe, #64748b); }
.tag-karte.art-urlaub { --chip-farbe: #16a34a; } .tag-karte.art-krank { --chip-farbe: #dc2626; } .tag-karte.art-schule { --chip-farbe: #7c3aed; }
.tag-kopf { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 8px; }
.tag-kopf:first-child { margin-top: 0; }
.tag-kopf .heute-marke { font-size: 12px; background: var(--akzent); color: #fff; padding: 1px 8px; border-radius: 999px; }

/* ---------- Fotos ---------- */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.foto { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--rand); display: block; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .doku { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 12px; text-align: center; padding: 8px; color: var(--text-2); word-break: break-word; }
.foto .wartend { position: absolute; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-2); }
.foto .loeschen { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(15,23,42,.7); color: #fff; font-size: 14px; display: none; }
.foto:hover .loeschen { display: block; }
.bild-vorschau { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 150; display: flex; align-items: center; justify-content: center; }
.bild-vorschau img { max-width: 100%; max-height: 100%; }

/* ---------- Notizen / Verlauf ---------- */
.notiz { padding: 10px 0; border-bottom: 1px solid var(--rand); }
.notiz:last-child { border-bottom: none; }
.notiz .meta { font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.notiz .text { white-space: pre-wrap; }
.notiz.wartend { opacity: .7; }

/* ---------- Zeiterfassung ---------- */
.stempel-raster { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stempel-raster .knopf { min-height: 60px; flex-direction: column; gap: 2px; }
.stempel-raster .knopf small { font-weight: 400; font-size: 12px; opacity: .8; }
.laufend-anzeige { padding: 14px 16px; border-radius: var(--radius); background: var(--gruen-hell); border: 1px solid #86efac; }
.laufend-anzeige .uhr { font-family: var(--mono); font-size: 28px; font-weight: 700; }
.zeit-art { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.zeit-art.fahrt_hin, .zeit-art.fahrt_zurueck { background: #0ea5e9; }
.zeit-art.arbeit { background: var(--gruen); }
.zeit-art.pause { background: var(--gelb); }
.zeit-art.automatisch { background: repeating-linear-gradient(45deg, var(--gelb) 0 2px, #fff 2px 4px); border: 1px solid var(--gelb); }

/* ---------- Druck ---------- */
@media print { .nav, .tabs, .kopf .knopf, .plantafel-werkzeuge .knopf { display: none !important; } .seite { padding: 0; } }
