/* Hausbesuchs-Dokumentation – schlankes CSS, mobile first, Ziel WCAG 2.1 AA.
   Alle Farbpaare haben mindestens 4,5:1 Kontrast (Text) bzw. 3:1 (Bedienelemente). */

:root {
  --blau: #17406d;
  --blau-hell: #e8eef6;
  --text: #1a1a1a;
  --text-leise: #4a4a4a;
  --grund: #ffffff;
  --flaeche: #f4f5f7;
  --rand: #767676;
  --rand-leise: #d0d4da;
  --fokus: #ffbf47;
  --gruen: #17693a;
  --gruen-hell: #e3f3e8;
  --gelb: #f5c400;
  --gelb-hell: #fff6cc;
  --rot: #b3261e;
  --rot-hell: #fbe4e2;
  --radius: 10px;
  --abstand: 1rem;
  font-size: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--flaeche);
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: var(--abstand);
}

main:focus {
  outline: none;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0.5rem 0 1rem;
}

h2 {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.75rem;
}

a {
  color: var(--blau);
  text-underline-offset: 0.15em;
}

:focus-visible {
  outline: 3px solid var(--fokus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--text);
}

.sprunglink {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--grund);
  padding: 0.5rem 1rem;
  z-index: 10;
}

.sprunglink:focus {
  left: 0.5rem;
}

.unsichtbar {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Kopf und Navigation ---------- */
.kopf {
  background: var(--blau);
  color: #fff;
}

.kopf-zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.5rem var(--abstand);
}

.marke {
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
}

.wer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  font-size: 0.95rem;
}

.wer-rolle {
  opacity: 0.9;
}

.abmelden {
  margin: 0;
}

.nav {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0 auto;
  padding: 0 var(--abstand) 0.5rem;
  max-width: 60rem;
  overflow-x: auto;
}

.nav a {
  display: inline-block;
  color: #fff;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}

.nav a[aria-current="page"] {
  background: #fff;
  color: var(--blau);
  font-weight: 700;
}

.fuss {
  max-width: 60rem;
  margin: 2rem auto;
  padding: 0 var(--abstand);
  color: var(--text-leise);
  font-size: 0.95rem;
}

/* ---------- Bausteine ---------- */
.karte {
  background: var(--grund);
  border: 1px solid var(--rand-leise);
  border-radius: var(--radius);
  padding: var(--abstand);
  margin-bottom: var(--abstand);
}

.schmal {
  max-width: 36rem;
}

.hinweis {
  background: var(--blau-hell);
  border-left: 4px solid var(--blau);
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
}

.warnung {
  background: var(--gelb-hell);
  border-left: 4px solid #8a6d00;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
}

.demo-banner {
  margin: 0;
  padding: 0.4rem 1rem;
  background: #5a2d82;
  color: #fff;
  text-align: center;
}

.fehler {
  background: var(--rot-hell);
  border-left: 4px solid var(--rot);
  color: #7a1a14;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  font-weight: 600;
}

.erfolg {
  background: var(--gruen-hell);
  border-left: 4px solid var(--gruen);
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
}

.knopf {
  display: inline-block;
  min-height: 44px;
  padding: 0.6rem 1.1rem;
  border: 2px solid var(--blau);
  border-radius: var(--radius);
  background: var(--blau);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.knopf:hover {
  background: #0f2d4f;
}

.knopf-zweit {
  background: var(--grund);
  color: var(--blau);
}

.knopf-zweit:hover {
  background: var(--blau-hell);
}

.knopf-klein {
  min-height: 36px;
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
  background: transparent;
  border-color: #fff;
}

.knopf-gross {
  width: 100%;
  min-height: 56px;
  font-size: 1.15rem;
}

.knopf-gefahr {
  background: var(--rot);
  border-color: var(--rot);
}

/* ---------- Formulare ---------- */
.formular {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.formular label,
.formular legend {
  font-weight: 600;
}

.formular .auswahl {
  font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--grund);
  border: 2px solid var(--rand);
  border-radius: 8px;
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0.5rem 0;
}

.auswahl {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.auswahl input {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
}

.feldhinweis {
  color: var(--text-leise);
  font-size: 0.95rem;
  margin: 0;
}

.reihe {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
}

.reihe label {
  flex: 1 1 10rem;
}

.pflicht::after {
  content: " *";
  color: var(--rot);
}

/* ---------- Ampel ---------- */
.ampel-gruppe {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.ampel-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.ampel-option span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  border-radius: var(--radius);
  border: 3px solid transparent;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  padding: 0.4rem 0.25rem;
  cursor: pointer;
  text-align: center;
  overflow-wrap: anywhere;
}

.ampel-gruen span {
  background: var(--gruen);
  color: #fff;
}

.ampel-gelb span {
  background: var(--gelb);
  color: #1a1a1a;
}

.ampel-rot span {
  background: var(--rot);
  color: #fff;
}

.ampel-option input:checked + span {
  border-color: var(--text);
  box-shadow: 0 0 0 3px #fff inset;
  outline: 3px solid var(--text);
}

.ampel-option small {
  font-weight: 400;
  font-size: 0.85rem;
}

.ampel-option input:checked + span::before {
  content: "✓ ausgewählt";
  font-size: 0.8rem;
}

.ampel-option input:focus-visible + span {
  outline: 3px solid var(--fokus);
  outline-offset: 3px;
}

.rot-bereich {
  border: 3px solid var(--rot);
  border-radius: var(--radius);
  padding: 0.75rem;
  background: var(--rot-hell);
}

.rot-bereich[hidden] {
  display: none;
}

.kontaktarten {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem 0.75rem;
}

/* Kennzeichnung per Text + Farbe (nie nur Farbe) */
.marke-ampel {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.marke-gruen {
  background: var(--gruen);
  color: #fff;
}

.marke-gelb {
  background: var(--gelb);
  color: #1a1a1a;
}

.marke-rot {
  background: var(--rot);
  color: #fff;
}

.storniert {
  text-decoration: line-through;
  color: var(--text-leise);
}

/* ---------- Listen und Tabellen ---------- */
.liste {
  list-style: none;
  padding: 0;
  margin: 0;
}

.liste-eintrag {
  background: var(--grund);
  border: 1px solid var(--rand-leise);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.tabelle-rahmen {
  overflow-x: auto;
  background: var(--grund);
  border: 1px solid var(--rand-leise);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rand-leise);
  vertical-align: top;
}

th {
  background: var(--flaeche);
}

tr.markiert td {
  background: var(--gelb-hell);
}

tr.ueberschritten td {
  background: var(--rot-hell);
}

.zahl {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Kalender ---------- */
.kalender-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.kalender {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0;
}

.kalender .wochentag {
  font-weight: 700;
  text-align: center;
  font-size: 0.85rem;
}

.kalender .tag {
  min-height: 4.5rem;
  background: var(--grund);
  border: 1px solid var(--rand-leise);
  border-radius: 6px;
  padding: 0.2rem;
  font-size: 0.8rem;
}

.kalender .tag.leer {
  background: transparent;
  border: 0;
}

.kalender .tag.heute {
  border: 2px solid var(--blau);
}

.kalender .tag-nr {
  font-weight: 700;
}

.kalender .punkte {
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kalender .punkte a {
  display: block;
  border-radius: 4px;
  padding: 0 0.2rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 40rem) {
  body {
    font-size: 1.0625rem;
  }

  main {
    padding: 1.5rem var(--abstand);
  }

  .kontaktarten {
    grid-template-columns: repeat(4, 1fr);
  }

  .kalender .tag {
    min-height: 6rem;
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .kopf,
  .fuss,
  .nav {
    display: none;
  }
}

/* ---------- Einzelansichten ---------- */
.angaben {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) 1fr;
  gap: 0.4rem 1rem;
  margin: 1rem 0;
}

.angaben dt {
  font-weight: 700;
}

.angaben dd {
  margin: 0;
}

.vermerk {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

details summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--blau);
}

/* ---------- Hilfeseite ---------- */
.regeln li {
  margin-bottom: 0.6rem;
}

.regeln li::marker {
  font-weight: 700;
}
