:root {
  --navy: #0f1f3a; --navy2: #1b3159; --gold: #c99a2e; --bg: #f3f5f9; --card: #fff; --text: #1a2233; --muted: #5d6880;
  --line: #dde2ec; --rot: #c62f2f; --rot-bg: #fde8e8; --gelb: #b77900; --gelb-bg: #fff4d6; --gruen: #1f8a4c; --gruen-bg: #e3f5ea; --blau-bg: #e7eefc;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--navy2); }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.klein { font-size: .85rem; }
.rechts { text-align: right; }
.zeile { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.zeile.ende { justify-content: flex-end; }
.spacer { flex: 1; }

/* Kopf und Navigation */
.kopf { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; position: sticky; top: 0; z-index: 20; }
.marke { display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: .02em; }
.marke svg { width: 28px; height: 28px; }
.marke small { display: block; font-weight: 400; color: #c8d1e4; font-size: .75rem; letter-spacing: 0; }
.kopf .wer { margin-left: auto; font-size: .85rem; color: #c8d1e4; }
.kopf button { background: transparent; border: 1px solid #44587e; color: #fff; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
nav.seite { background: #fff; border-right: 1px solid var(--line); padding: .8rem .5rem; }
nav.seite a { display: flex; gap: .55rem; align-items: center; padding: .55rem .75rem; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
nav.seite a:hover { background: var(--bg); }
nav.seite a.aktiv { background: var(--blau-bg); color: var(--navy); font-weight: 600; }
nav.seite .gruppe { font-size: .72rem; text-transform: uppercase; color: var(--muted); padding: .9rem .75rem .3rem; letter-spacing: .05em; }
nav.seite .zahl { margin-left: auto; background: var(--rot); color: #fff; border-radius: 10px; font-size: .72rem; padding: 0 .45rem; }
main { padding: 1.4rem 1.6rem 3rem; min-width: 0; }

/* Bausteine */
.karte { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.kachel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.kachel .wert { font-size: 1.8rem; font-weight: 700; }
.kachel.rot .wert { color: var(--rot); } .kachel.gelb .wert { color: var(--gelb); } .kachel.gruen .wert { color: var(--gruen); }
.raster2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1000px) { .raster2 { grid-template-columns: 1fr; } }
button, .knopf { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: .45rem .85rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover { border-color: #aab4c8; }
button.primaer { background: var(--navy); border-color: var(--navy); color: #fff; }
button.primaer:hover { background: var(--navy2); }
button.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
button.gefahr { color: var(--rot); border-color: #f0b8b8; }
button.klein { padding: .2rem .55rem; font-size: .82rem; }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; border: 1px solid #c9d0dd; border-radius: 8px; padding: .45rem .6rem; background: #fff; width: 100%; color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .7rem; }
label > input, label > select, label > textarea { margin-top: .2rem; }
label.check { display: flex; gap: .45rem; align-items: center; color: var(--text); font-size: .92rem; }
label.check input { width: auto; margin: 0; }
.felder { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 .9rem; }
.felder.drei { grid-template-columns: repeat(3, 1fr); }
.felder .ganz { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; background: #fafbfd; }
tr.klickbar { cursor: pointer; } tr.klickbar:hover td { background: #f7f9fc; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; }
.tabelle { border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.tabelle table { border: 0; }
.marker { display: inline-block; padding: .1rem .5rem; border-radius: 20px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.m-ok { background: var(--gruen-bg); color: var(--gruen); }
.m-laeuft_ab, .m-gelb, .m-beantragt, .m-pause, .m-unvollständig { background: var(--gelb-bg); color: var(--gelb); }
.m-abgelaufen, .m-fehlt, .m-rot, .m-nicht_erschienen, .m-abgelehnt { background: var(--rot-bg); color: var(--rot); }
.m-im_dienst, .m-genehmigt, .m-gestempelt { background: var(--gruen-bg); color: var(--gruen); }
.m-geplant, .m-beendet, .m-Plan { background: #eef0f4; color: var(--muted); }
.ampel { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.ampel.ok { background: var(--gruen); } .ampel.laeuft_ab { background: #e7a400; } .ampel.abgelaufen, .ampel.fehlt { background: var(--rot); }
.ampel.fehlt { background: #fff; border: 2px solid #d4d9e3; }
.hinweis { background: var(--blau-bg); border-radius: 10px; padding: .7rem .9rem; margin: .6rem 0; font-size: .9rem; }
.hinweis.warn { background: var(--gelb-bg); color: #6b4700; }
.hinweis.fehler { background: var(--rot-bg); color: #7d1d1d; }
.hinweis.gut { background: var(--gruen-bg); color: #14582f; }
.hinweis ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: flex-start; }
.liste li:last-child { border-bottom: 0; }
.leer { color: var(--muted); padding: .8rem 0; }

/* Dienstplan */
.plan { border-collapse: separate; border-spacing: 0; table-layout: fixed; min-width: 980px; }
.plan th, .plan td { border-right: 1px solid var(--line); }
.plan th.objekt, .plan td.objekt { width: 190px; position: sticky; left: 0; background: #fff; z-index: 2; }
.plan th.heute { background: var(--blau-bg); color: var(--navy); }
.plan th.feiertag, .plan th.sonntag { color: var(--rot); }
.plan td { padding: .35rem; min-height: 60px; }
.plan td.tag:hover { background: #fafbfe; }
.dienst { border-radius: 7px; padding: .3rem .45rem; margin-bottom: .3rem; background: var(--blau-bg); border-left: 4px solid var(--navy2); font-size: .82rem; cursor: pointer; line-height: 1.3; }
.dienst.offen { background: var(--rot-bg); border-left-color: var(--rot); }
.dienst.warn { border-left-color: #e7a400; background: var(--gelb-bg); }
.dienst.entwurf { border-style: dashed; border-width: 1px 1px 1px 4px; border-color: #9fb0d0; }
.dienst b { display: block; }
.dienst .w { color: var(--gelb); font-weight: 700; }
.neu-im-tag { opacity: 0; font-size: .78rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; text-align: center; padding: .15rem; cursor: pointer; }
td.tag:hover .neu-im-tag { opacity: 1; }

/* Dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(720px, 94vw); box-shadow: 0 20px 60px rgba(10,20,40,.35); }
dialog::backdrop { background: rgba(10, 20, 40, .45); }
dialog .dkopf { padding: 1rem 1.2rem .4rem; display: flex; align-items: center; }
dialog .dkopf h2 { margin: 0; }
dialog .dinhalt { padding: .4rem 1.2rem 1rem; max-height: 72vh; overflow: auto; }
dialog .dfuss { padding: .8rem 1.2rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-end; background: #fafbfd; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .7rem 1.2rem; border-radius: 10px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.fehler { background: var(--rot); }
.passwort { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; background: #fff; padding: .5rem .8rem; border-radius: 8px; border: 1px dashed var(--gold); display: inline-block; user-select: all; }
.foto-klein { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.foto-gross { max-width: 100%; border-radius: 10px; }

/* Anmeldung */
.anmeldung { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy), #08142a); padding: 1rem; }
.anmeldung .karte { width: min(400px, 100%); padding: 1.6rem; }
.anmeldung .marke { color: var(--navy); margin-bottom: 1.2rem; font-size: 1.15rem; }
.anmeldung .marke small { color: var(--muted); }

/* Druck (QR-Aushang, Leistungsnachweis) */
#druck { display: none; }
@media print {
  body > *:not(#druck) { display: none !important; }
  #druck { display: block !important; padding: 0; }
  @page { margin: 15mm; }
}
.druck-qr { text-align: center; padding-top: 10mm; }
.druck-qr svg { width: 120mm; height: 120mm; }
.druck-qr h1 { font-size: 26pt; }
.druck-ln { font-size: 10pt; }
.druck-ln table { font-size: 9pt; }
.druck-ln th, .druck-ln td { padding: 3px 5px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  nav.seite { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .4rem; }
  nav.seite .gruppe { display: none; }
  nav.seite a { white-space: nowrap; }
  main { padding: 1rem; }
  .felder, .felder.drei { grid-template-columns: 1fr; }
}

/* ===== Handy-App ===== */
body.app { background: #eef1f6; }
.app-kopf { background: var(--navy); color: #fff; padding: .8rem 1rem; display: flex; align-items: center; gap: .6rem; position: sticky; top: 0; z-index: 10; }
.app-kopf .marke svg { width: 26px; height: 26px; }
.app-inhalt { padding: 1rem; max-width: 560px; margin: 0 auto; padding-bottom: 5.5rem; }
.app-tabs { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.app-tabs a { text-align: center; padding: .55rem 0 .6rem; color: var(--muted); text-decoration: none; font-size: .75rem; }
.app-tabs a span { display: block; font-size: 1.3rem; line-height: 1.3; }
.app-tabs a.aktiv { color: var(--navy); font-weight: 700; }
.status { border-radius: 16px; padding: 1.1rem; color: #fff; background: #5d6880; margin-bottom: 1rem; }
.status.im_dienst { background: var(--gruen); } .status.pause { background: #b77900; }
.status .gross { font-size: 1.35rem; font-weight: 700; margin: .2rem 0; }
.knopf-gross { display: block; width: 100%; padding: 1rem; font-size: 1.1rem; font-weight: 700; border-radius: 14px; justify-content: center; margin-bottom: .6rem; border: 0; }
.knopf-gross.gruen { background: var(--gruen); color: #fff; } .knopf-gross.rot { background: var(--rot); color: #fff; }
.knopf-gross.gelb { background: #e7a400; color: #fff; } .knopf-gross.blau { background: var(--navy); color: #fff; }
.knopf-gross.weiss { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.app-karte { background: #fff; border-radius: 14px; padding: .9rem 1rem; margin-bottom: .8rem; border: 1px solid var(--line); }
.app-karte .zeit { font-weight: 700; font-size: 1.05rem; }
.vorschau-foto { max-width: 100%; border-radius: 10px; margin: .4rem 0; }

input[type=month], .zeile > select, .zeile label > input, .zeile label > select { width: auto; }
.zeile > label { margin-bottom: 0; }
