/* Klassenbuch – mobile-first, große Tippflächen, Druck-CSS für A4 */
:root {
  --blau: #1f4e79; --blau-hell: #e3edf6; --grund: #f4f6f9; --karte: #fff; --text: #1b1f24;
  --grau: #5f6b78; --linie: #d5dbe2; --gruen: #1e7d34; --gruen-hell: #e2f4e6; --gelb: #8a5a00;
  --gelb-hell: #fff3d6; --rot: #b42318; --rot-hell: #fde8e6; --lila: #6b3fa0; --lila-hell: #efe6f9;
  --radius: 12px; --tipp: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px;
  color: var(--text); background: var(--grund); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(68px + env(safe-area-inset-bottom)); min-height: 100vh; background: var(--grund); }
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; margin: .4rem 0 .8rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 .6rem; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
p { line-height: 1.45; }
a { color: var(--blau); }
main { max-width: 760px; margin: 0 auto; padding: 12px 14px 24px; }
.laden { color: var(--grau); text-align: center; margin-top: 30vh; }

/* Kopf und Navigation */
.kopf { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: var(--blau); color: #fff; padding: calc(8px + env(safe-area-inset-top)) 14px 8px; min-height: 52px; }
.kopf-titel { font-weight: 650; font-size: 1.1rem; }
.sync { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; font-weight: 600; min-height: 36px; }
.sync.ok { background: rgba(255,255,255,.18); color: #fff; }
.sync.offen { background: #ffcc4d; color: #3d2a00; }
.sync.konflikt { background: #ff8a80; color: #4a0d07; }
.navigation { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--karte);
  border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom); }
.navigation a { flex: 1; text-align: center; padding: 14px 2px; min-height: 56px; text-decoration: none; color: var(--grau); font-weight: 600; font-size: .88rem; }
.navigation a.aktiv { color: var(--blau); box-shadow: inset 0 3px 0 var(--blau); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--gelb-hell);
  color: var(--gelb); padding: 10px 14px; font-weight: 600; }
.meldung { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; max-width: 640px;
  margin: 0 auto; background: #263241; color: #fff; padding: 12px 16px; border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.meldung.fehler { background: var(--rot); }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; color: var(--grau); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 1rem; padding: 10px 12px; min-height: var(--tipp);
  border: 1px solid var(--linie); border-radius: 10px; background: #fff; color: var(--text); }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--blau-hell); border-color: var(--blau); }
input[type=checkbox], input[type=radio] { width: 24px; min-height: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }
.zeile { display: flex; gap: 10px; }
.zeile > * { flex: 1; min-width: 0; }
.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 650;
  min-height: var(--tipp); padding: 10px 18px; border-radius: 10px; border: 1px solid var(--blau); background: var(--blau);
  color: #fff; cursor: pointer; text-decoration: none; }
.knopf.zweit { background: #fff; color: var(--blau); }
.knopf.gefahr { background: var(--rot); border-color: var(--rot); }
.knopf.klein { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.knopf.breit { width: 100%; margin-top: 12px; }
.knopf:disabled { opacity: .5; cursor: not-allowed; }
.linkknopf { background: none; border: 0; color: var(--blau); font: inherit; text-decoration: underline; padding: 10px 0; min-height: 44px; cursor: pointer; }
.linkknopf.gefahr { color: var(--rot); }
.hinweis { background: var(--blau-hell); border-radius: 10px; padding: 10px 12px; font-size: .95rem; line-height: 1.4; }
.hinweis.warnung { background: var(--gelb-hell); color: #4d3300; }
.hinweis.gefahr { background: var(--rot-hell); color: #5c120c; }
.klein-grau { color: var(--grau); font-size: .85rem; }

/* Karten */
.karte { background: var(--karte); border-radius: var(--radius); padding: 14px; margin: 12px 0; border: 1px solid var(--linie); }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.liste { list-style: none; padding: 0; margin: 0; }
.liste > li { border-bottom: 1px solid var(--linie); }
.liste > li:last-child { border-bottom: 0; }
.menue a, .menue button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 14px 4px;
  min-height: 52px; text-decoration: none; color: var(--text); font: inherit; background: none; border: 0; text-align: left; cursor: pointer; }
.menue a::after, .menue button::after { content: "›"; color: var(--grau); font-size: 1.4rem; }
.zahl { background: var(--rot); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .8rem; margin-left: auto; margin-right: 8px; }

/* Anwesenheit */
.anw { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.anw-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.anw-status { min-width: 150px; min-height: var(--tipp); border-radius: 10px; border: 2px solid transparent; font: inherit;
  font-weight: 650; font-size: .92rem; padding: 6px 10px; cursor: pointer; }
.st-anwesend { background: var(--gruen-hell); color: var(--gruen); }
.st-fehlt { background: var(--rot-hell); color: var(--rot); }
.zaehler { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.zaehler span { font-size: .85rem; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.wartet { outline: 2px dashed #e0a800; outline-offset: 2px; }

/* Tabellen */
.tabelle-huelle { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { font-size: .8rem; color: var(--grau); text-transform: uppercase; letter-spacing: .02em; }
td.z, th.z { text-align: right; font-variant-numeric: tabular-nums; }

/* QR / Scanner */
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; }
.qr img { width: 100%; max-width: 420px; image-rendering: pixelated; }
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; max-width: 420px; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.code { font-family: ui-monospace, monospace; font-size: .75rem; word-break: break-all; background: #f0f2f5; padding: 8px; border-radius: 8px; }

/* Umzug */
.umzug { background: var(--rot-hell); border: 2px solid var(--rot); }

/* Druckansicht */
.druck { background: #fff; color: #000; }
.druck h1 { font-size: 18pt; }
.druck .abend { break-inside: avoid; border-top: 1px solid #999; padding: 6px 0; }
.druck .unterschriften { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 24px; margin-top: 24px; break-inside: avoid; }
.druck .unterschrift { border-top: 1px solid #000; padding-top: 4px; font-size: 9pt; margin-top: 38px; }
.druck .seitenumbruch { break-before: page; }
.druck table { font-size: 9pt; }
.druck th { color: #000; }

.rollen-hinweis { background: var(--gelb-hell); color: #4d3300; border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 650;
  white-space: nowrap; order: 3; }
.kopf { gap: 6px 8px; flex-wrap: wrap; }
.kopf-titel, .sync { flex: none; white-space: nowrap; }
.stempel { border: 2px solid #1f6f3f; border-radius: 8px; padding: 8px 12px; margin: 8px 0 14px; line-height: 1.45; }
.stempel.entwurf { border-color: #b3261e; color: #8c1d18; font-weight: 700; font-size: 1.15rem; text-align: center; }
.stempel.abweichung { border-color: #b3261e; background: var(--rot-hell); }
.stempel code { font-family: ui-monospace, monospace; font-size: 1em; }
.wasserzeichen { display: none; }
.fusszeile { margin: 28px 0 8px; text-align: center; font-size: .68rem; color: #8a8f98; }
.fusszeile a { color: #8a8f98; text-decoration: none; }
.fusszeile a:hover, .fusszeile a:focus { text-decoration: underline; }
.rechtstext { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; line-height: 1.5; }
.rechtstext h1 { font-size: 1.4rem; }
.rechtstext h2 { font-size: 1.05rem; margin-top: 1.4em; }
.rechtstext .fehlt { background: var(--gelb-hell); color: #4d3300; padding: 0 4px; border-radius: 4px; }
.testkurs-banner { background: #6a1b9a; color: #fff; text-align: center; font-weight: 700; padding: 6px 12px; font-size: .9rem; letter-spacing: .02em; }
.testkurs-druck { border: 3px solid #6a1b9a; color: #6a1b9a; font-weight: 800; text-align: center; padding: 6px; font-size: 1.3rem; margin-bottom: 10px; }
.linkstatus { font-size: .8rem; color: #555; }
.linkstatus .offen { color: #1f4e79; font-weight: 650; }
.linkstatus .genutzt { color: #1f6f3f; }
.linkstatus .abgelaufen { color: #8c1d18; }
/* Woche, Kalender, Fehlzeiten */
.vorumbruch { white-space: pre-wrap; }
.nur-druck { display: none; }
.fehltage { display: block; font-size: .8rem; font-weight: 400; color: var(--grau); }
tr.fehlt-zeile td:first-child { font-weight: 600; }
.woche-block { border-left: 3px solid var(--blau-hell); padding: 4px 0 4px 10px; margin: 8px 0; }
.woche-bemerkung { background: var(--grund); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.hinweis.termin { margin: 6px 0; }
.termin-pruefung { border-left: 4px solid var(--lila); }
.termin-ferien, .termin-frei { border-left: 4px solid var(--gelb); }
.termin-zeile { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0 8px 10px;
  border-bottom: 1px solid var(--linie); }
.kal-kopf { display: flex; justify-content: space-between; align-items: center; }
.kal-kopf h2 { margin: 0; }
.kal-kopf .linkknopf { font-size: 1.6rem; min-width: var(--tipp); }
.kal-raster { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.kal-wt { text-align: center; font-size: .8rem; font-weight: 600; color: var(--grau); }
.kal-tag { aspect-ratio: 1; min-height: 40px; border: 1px solid var(--linie); border-radius: 8px; background: #fff; color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font: inherit; padding: 2px; cursor: pointer; }
.kal-tag.leer { border: 0; background: transparent; cursor: default; }
.kal-tag.kurstag { background: var(--blau-hell); border-color: var(--blau); }
.kal-tag.kal-ferien, .kal-tag.kal-frei { background: var(--gelb-hell); border-color: var(--gelb); }
.kal-tag.kal-frei { background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(138,90,0,.12) 6px 8px); }
.kal-tag.kal-pruefung { outline: 2px solid var(--lila); outline-offset: -3px; }
.kal-tag.storniert .kal-zahl { text-decoration: line-through; }
.kal-tag.heute .kal-zahl { font-weight: 800; text-decoration: underline; }
.kal-tag.gewaehlt { box-shadow: 0 0 0 3px var(--blau); }
.kal-marken { font-size: .7rem; color: var(--lila); font-weight: 700; min-height: 1em; }
.kal-legende { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; }
.kal-l { padding: 0 6px; border-radius: 4px; border: 1px solid var(--linie); }
.kal-l.kurstag { background: var(--blau-hell); }
.kal-l.kal-ferien { background: var(--gelb-hell); }
.kal-l.kal-frei { background: var(--gelb-hell); background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(138,90,0,.12) 6px 8px); }
.kal-l.kal-pruefung { outline: 2px solid var(--lila); }

@media print {
  .nur-druck { display: block; }
  .woche-tag { break-inside: avoid; margin-bottom: 8px; }
  .wasserzeichen { display: flex; position: fixed; inset: 0; align-items: center; justify-content: center; pointer-events: none;
    font-size: 54pt; font-weight: 800; color: rgba(179, 38, 30, .13); transform: rotate(-32deg); white-space: nowrap; z-index: 5; }
  @page { size: A4; margin: 16mm 14mm 18mm; }
  :root { font-size: 10pt; background: #fff; }
  body { padding: 0; background: #fff; }
  .nur-bildschirm, .navigation, .kopf, .banner, .meldung, .knopf, .linkknopf { display: none !important; }
  main { max-width: none; padding: 0; }
  .karte { border: 0; padding: 0; margin: 0; }
  a { color: #000; text-decoration: none; }
  .qr img { max-width: 120mm; }
}
@media (min-width: 600px) {
  .anw-status { min-width: 180px; }
}
@media (max-width: 420px) {
  .kopf-titel { font-size: 1rem; }
  .sync { padding: 6px 9px; font-size: .78rem; }
}
.sync { order: 2; }
@media (min-width: 600px) {
  .rollen-hinweis { order: 1; margin-right: auto; }
}
