/* Designsystem DreyerDispo (#78), Werte aus der Roadmap (analyse/18_roadmap.html).
   tests/test_designsystem.py prüft die Kontraste beider Darstellungen nach WCAG AA. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f2; --side: #f9faf8; --surface: #ffffff; --field: #eceee9;
  --text: #1c1f1a; --text2: #595959; --sep: #e6e6e6; --sep2: #80867c; /* Bedienrahmen ≥ 3:1 auf allen Flächen */
  --brand: #649f30;            /* Dreyer-Grün: nur Flächen und Markierungen, nie Text */
  --accent: #4a7a22; --on-accent: #ffffff; --accent-soft: #eef5e6;
  --warn: #8a5a00; --warn-bg: #fff3d6; --crit: #b3261e; --crit-bg: #fce9e7;
  --f1: #1f63b0; --f2: #a14f00; --f3: #6d42a8; --f4: #1f7a6d; --on-f: #ffffff; /* Fahrten im Strang (#196), immer mit Kürzel */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-grp: Arial, Helvetica, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412; --side: #171a16; --surface: #1c1f1a; --field: #262a24;
    --text: #eceeea; --text2: #a9afa5; --sep: #2e332c; --sep2: #787f74;
    --brand: #7db84a;
    --accent: #8bc34a; --on-accent: #10140e; --accent-soft: #22301a;
    --warn: #f0c25e; --warn-bg: #3a2e12; --crit: #ff8a80; --crit-bg: #3b1d1b;
    --f1: #7fb2ec; --f2: #f0a35c; --f3: #bfa2ec; --f4: #5cc6b4; --on-f: #10140e;
  }
}

* { box-sizing: border-box; }
html { font: 400 14px/1.45 var(--font); font-variant-numeric: tabular-nums; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.35rem; font-weight: 600; margin: 0; }
.i { width: 1em; height: 1em; vertical-align: -.15em; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hinweis { color: var(--text2); font-size: .9rem; }
.leer { flex: 1; }

/* Grundaufbau: Seitenleiste | Inhalt; Bearbeiten als Fläche unter dem Seitenkopf (#165) */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.seitenleiste { background: var(--side); border-right: 1px solid var(--sep); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; }
.logo { display: block; width: 150px; height: auto; margin: 0 0 12px 6px; color: var(--text); }
.logo .gruen { fill: var(--brand); }
.gruppe { font: 700 .75rem/1 var(--font-grp); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text2); padding: 14px 8px 6px; }
.nav { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; min-height: 44px;
  color: var(--text); text-decoration: none; }
.nav:hover { background: var(--field); }
.nav .zahl { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 11px; text-align: center;
  background: var(--crit-bg); color: var(--crit); font-size: .8rem; font-weight: 600; }
.nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brand); }
.konto { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--sep);
  display: grid; gap: 6px; font-size: .9rem; }
.inhalt { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.karte.flaeche { border: 2px solid var(--accent); }
.flaeche > .formular { max-width: 760px; } /* Felder nicht über die volle Inhaltsbreite ziehen */
.kopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pfad { font-size: .85rem; color: var(--text2); }
.pfad a { color: inherit; }
.tabs { display: none; }

/* Bausteine */
.karte { background: var(--surface); border: 1px solid var(--sep); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ueberschrift { font: 700 .75rem/1 var(--font-grp); letter-spacing: .1em; text-transform: uppercase;
  color: var(--text2); margin: 0; }
.spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px;
  align-items: start; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--text2); }
.kv dd { margin: 0; }
/* Lage der Baustelle: Koordinate zum Kopieren und Kartenausschnitt (#161) */
.lage { display: grid; gap: 8px; }
.lage-ziel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lage-ziel .knopf { display: inline-flex; align-items: center; text-decoration: none; }
.lage-karte { width: 100%; height: 260px; border: 1px solid var(--sep); border-radius: 6px; }
.tabelle { width: 100%; border-collapse: collapse; }
/* Breite Tabellen in schmalen Karten scrollen statt abgeschnitten zu werden */
.karte:has(> .tabelle) { overflow-x: auto; }
.tabelle th { font-size: .85rem; font-weight: 600; color: var(--text2); text-align: left;
  padding: 6px 8px; border-bottom: 1px solid var(--sep2); }
.tabelle td { padding: 8px; border-bottom: 1px solid var(--sep); vertical-align: middle; }
.tabelle tbody tr:hover { background: var(--field); }
/* Besetzungsraster wie Klickdummy v2 (#170): eine Woche, Kacheln je Platz, scrollt in der Karte */
.raster { overflow-x: auto; }
.raster table { min-width: 760px; }
.raster th { white-space: nowrap; }
.raster td { padding: 4px; }
.kachel { display: flex; flex-direction: column; gap: 1px; min-height: 56px; padding: 5px 8px;
  border: 1px solid transparent; border-radius: 5px; background: var(--side); color: var(--text);
  text-decoration: none; }
a.kachel:hover { border-color: var(--accent); }
.kachel b { font-weight: 600; }
.kachel .status { font-size: .8rem; color: var(--text2); }
.kachel.besetzt { background: var(--accent-soft); }
.kachel.besetzt b::before { content: "✓ "; color: var(--accent); }
.kachel.offen { background: var(--crit-bg); border: 2px solid var(--crit); padding: 4px 7px; }
.kachel.offen b::before { content: "! "; color: var(--crit); font-weight: 700; }
.kachel.pruefen { background: var(--warn-bg); border: 1px dashed var(--warn); }
.kachel.aus { background: repeating-linear-gradient(135deg, var(--bg) 0 6px, var(--field) 6px 12px);
  color: var(--text2); }
.kachel.gewaehlt { border: 2px solid var(--accent); padding: 4px 7px; }
/* Plantafel (#116): Abwesenheit, freier Tag, Wochenende; Farben je Grund folgen mit #115 */
.kachel.abwesend, .marke.abwesend { background: var(--field); border-left: 4px solid var(--sep2); }
.kachel.abwesend.nicht-sperrend { border-left-style: dashed; }
.kachel.frei { background: transparent; border: 1px dashed var(--sep); }
a.kachel.frei .status { visibility: hidden; }
a.kachel.frei:hover .status, a.kachel.frei:focus .status { visibility: visible; }
.marke.ok { background: var(--accent-soft); color: var(--accent); }
/* Kopfzeile bleibt beim Rollen sichtbar: die Karte scrollt selbst, weil sie für breite Tafeln schon overflow-x hat */
.plantafel { max-height: calc(100vh - 2rem); overflow-y: auto; }
.plantafel thead th { position: sticky; top: -14px; z-index: 2; background: var(--surface); }
.plantafel .we { background: var(--bg); }
.plantafel .kachel b { white-space: nowrap; }
.plantafel.monat table { min-width: 1200px; }
.plantafel.monat td { padding: 2px; }
.plantafel.monat .kachel { min-height: 36px; padding: 3px 4px; font-size: .8rem; }
.auswahlleiste { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0;
  padding: 10px 12px; border: 1px solid var(--accent); border-radius: 5px; background: var(--accent-soft); }
.knopf[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.legende { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* Vorschläge neben dem Raster ab Laptopbreite, sonst darunter (ADR 0011 erlaubt das; #169) */
.besetzung { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.besetzung > * { min-width: 0; } /* sonst schiebt das breite Raster die Seite auf */
@media (min-width: 1280px) {
  .besetzung.mit-vorschlaegen { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  /* Leiste rechts über beide Zeilen, Fahrgemeinschaft links unter dem Raster (#143) */
  .besetzung.mit-vorschlaegen > .vorschlagsleiste { grid-column: 2; grid-row: 1; }
  /* Fahrgemeinschaft über die volle Breite, die Stränge brauchen sie (#196) */
  .besetzung.mit-vorschlaegen > .fahrgemeinschaft { grid-column: 1 / -1; }
}
/* Fahrgemeinschaft (#143): drei Spalten, Zusatzfelder unter der Anreise; scrollt notfalls in sich */
.rollbar { overflow-x: auto; }
/* Formset-Tabellen (Positionen): Formular darf breiter werden, Felder füllen ihre Spalte statt Standardbreite */
.flaeche > .formular:has(.tabelle.formset) { max-width: none; }
.tabelle.formset :is(input:not([type=checkbox]), select) { width: 100%; min-width: 4.5em; box-sizing: border-box; }
/* Kurze Werte schmal, damit Bezeichnung bzw. Vertragsposition (mit Preis/Einheit im Text) Platz haben */
.tabelle.formset td :is([name$="-pos_nr"], [name$="-menge"], [name$="-preis"], [name$="-einzelpreis"], [name$="-einheit"]) { width: 6.5em; }
.tabelle.formset td :is([name$="-bezeichnung"]) { min-width: 11em; }
.tabelle.formset td [name$="-vertragsposition"] { min-width: 16em; }
.positionstext { display: block; margin-top: 2px; }
.positionstext[title]:not([title='']) { cursor: help; text-decoration: underline dotted; }
.tabelle.formset .fehler { font-size: .8rem; }
.fehler-uebersicht { border: 1px solid var(--crit); border-left-width: 4px; border-radius: 5px; padding: 10px 12px; margin-bottom: 12px; color: var(--crit); }
.fehler-uebersicht ul { margin: 6px 0 0; padding-left: 18px; }
.fehler-uebersicht a { color: inherit; }
.fehlerfeld + .fehlerfeld::before { content: ', '; }
#id_kunden:has(input.tag-knopf) { max-height: 15em; overflow-y: auto; }
.fg-tabelle tbody th { font-size: 1rem; color: var(--text); min-width: 9rem; }
.fg-tabelle td { vertical-align: top; }
.fg-strecke { white-space: nowrap; }
.fg-anreise { display: grid; gap: 8px; min-width: 16rem; }
.fg-anreise select, .fg-anreise input:not([type=radio]) { width: 100%; }
.fg-zusatz { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.fg-zusatz .feld label .hinweis { font-weight: 400; }
.fg-orte { border: 1px solid var(--sep); border-radius: 6px; margin: 0; padding: 8px 12px; display: grid; gap: 2px; }
.fg-orte legend { font-weight: 600; padding: 0 4px; }
.fg-ort { display: flex; align-items: center; gap: 12px; }
.fg-ort label { flex: 1; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.fg-ort a { min-height: 44px; display: inline-flex; align-items: center; }
.fg-gilt { border: 0; margin: 0; padding: 0; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.fg-gilt legend { float: left; font-weight: 600; margin-right: 4px; padding: 0; }
.fg-gilt label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.vorschlagsleiste { border: 2px solid var(--accent); border-radius: 10px; padding: 14px;
  display: grid; gap: 8px; }
.vorschlagsleiste h3 { margin: 0; font-size: 1.05rem; }
.vorschlaege { max-height: 640px; overflow-y: auto; margin: 0 -14px; border-top: 1px solid var(--sep); }
.vorschlag { display: grid; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--sep); }
.vorschlag-gruppe h4 { position: sticky; top: 0; z-index: 1; /* Richtung bleibt beim Rollen sichtbar (#186) */
  margin: 0; padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--sep); font-size: .95rem; }
.vorschlag-gruppe > .hinweis { margin: 0; padding: 6px 14px 0; }
.vorschlag:last-child { border-bottom: 0; }
.dienstfahrzeug { display: inline-flex; vertical-align: middle; color: var(--text2); position: relative; }
/* Fahrgemeinschaft (#143): Symbol und Text, nie nur Farbe */
/* Routenstränge (#196): Linie = Fahrt, Kreis = abholen, Raute = Treffpunkt, gestrichelt = Vorschlag */
.fg-strang { border-top: 1px solid var(--sep); padding-top: 10px; display: grid; gap: 4px; }
.fg-strang h4 { margin: 0; font-size: 1rem; }
.fg-rose { width: 32px; height: 32px; flex: none; }
.fg-rose circle { fill: var(--field); stroke: var(--sep2); }
.fg-rose text { font: 700 8px var(--font-grp); fill: var(--text2); }
.fg-rose line { stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; }
.fg-saetze { margin: 0; padding-left: 18px; }
.fg-bild { width: 100%; height: auto; display: block; }
.fg-bild text { font: 12.5px var(--font); fill: var(--text); }
.fg-bild .klein { font-size: 11.5px; fill: var(--text2); }
.fg-bild .fett { font-weight: 600; }
.fg-bild .vtext { fill: var(--accent); font-weight: 600; }
.fg-bild .achse { stroke: var(--sep2); }
.fg-bild .ziel { fill: var(--text); }
.fg-bild .bahn { stroke: var(--f); stroke-width: 7; stroke-linecap: round; }
.fg-bild .spitze { fill: var(--f); }
.fg-bild .halt { fill: var(--surface); stroke: var(--f); stroke-width: 3.5; }
.fg-bild .halt.vorschlag { stroke-dasharray: 3 3; }
.fg-bild .fzt { font: 700 11.5px var(--font-grp); fill: var(--on-f); }
.fg-bild .privat .bahn { stroke-width: 2.5; stroke-dasharray: 6 5; }
.f1 { --f: var(--f1); } .f2 { --f: var(--f2); } .f3 { --f: var(--f3); } .f4 { --f: var(--f4); } .privat { --f: var(--sep2); }
.fz-marke { display: inline-flex; padding: 0 6px; border-radius: 4px; font: 700 .8rem/1.4 var(--font-grp);
  background: var(--f); color: var(--on-f); }
.fg-symbole { display: flex; flex-wrap: wrap; gap: 2px 8px; }
.fg-symbol { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; color: var(--text2);
  position: relative; /* hält den Vorlesetext im rollbaren Raster */ }
.fg-symbol .i { color: var(--accent); }
.nur-vorleser { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; }
.verlauf { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.verlauf li { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 10px; overflow-wrap: anywhere; }
.verlauf span { color: var(--text2); }

.knopf { min-height: 44px; /* Zielgröße 44 px (#78) */ padding: 0 14px; border-radius: 6px; border: 1px solid var(--sep2);
  background: var(--surface); color: var(--text); font: 500 1rem/1 var(--font);
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; cursor: pointer; }
.knopf[hidden] { display: none; }
.knopf.haupt { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  font-weight: 600; }
.knopf.link { border: 0; background: none; padding: 0; color: var(--accent);
  text-decoration: underline; }

/* Statusmarke: immer Farbe, Symbol und Text */
.marke { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px;
  font-size: .85rem; font-weight: 600; white-space: nowrap; background: var(--accent-soft);
  color: var(--accent); }
.marke.laeuft_ab, .marke.faellig { background: var(--warn-bg); color: var(--warn); }
.marke.abgelaufen, .marke.ueberfaellig, .marke.abgelehnt { background: var(--crit-bg); color: var(--crit); }
.marke.ausgetreten, .marke.entwurf { background: var(--field); color: var(--text2); }

/* Formular */
.formular { display: grid; gap: 12px; }
.feld { display: grid; gap: 4px; }
.feld label { font-weight: 600; font-size: .9rem; }
/* Gegliedertes Formular: Abschnitte mit Überschrift, zusammengehörige Felder in einer Zeile */
.formular.gegliedert { gap: 24px; max-width: 760px; }
.abschnitt { border: 0; border-top: 1px solid var(--sep); margin: 0; padding: 14px 0 0;
  display: grid; gap: 12px; min-width: 0; }
.abschnitt:first-of-type { border-top: 0; padding-top: 0; }
.abschnitt > legend { float: left; width: 100%; padding: 0; margin-bottom: 2px; }
.zeile { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 12px; align-items: start; }
.zeile > .feld, .zeile select { min-width: 0; } /* lange Auswahltexte nicht über den Rand */
.feld > .platz { font-size: .9rem; } /* Knopf in der Zeile auf Höhe der Eingabefelder */
.unsichtbar { position: absolute; left: -9999px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--sep2); border-radius: 6px; padding: 6px 8px; min-height: 44px; }
label:has(> input[type="checkbox"]) { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }
/* Checkbox im Formular: Feld und Beschriftung als 44 px hohe Zeile, die Beschriftung schaltet mit */
.feld:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; }
.feld:has(> input[type="checkbox"]) label { min-height: 44px; display: inline-flex; align-items: center; }
/* Muster (ui-ux-pro-max-Review 05.11.2026): Pflicht-Stern, Wochentage als Umschaltknöpfe,
   kompakte Zeilen für Besetzung und Stammteam, eingeklappte Nebenangaben */
.pflicht { color: var(--crit); }
div:has(> div > label > input.tag-knopf) { display: flex; flex-wrap: wrap; gap: 6px; }
label:has(> input.tag-knopf) { position: relative; display: inline-flex; align-items: center;
  justify-content: center; min-width: 48px; min-height: 44px; padding: 0 10px; cursor: pointer;
  border: 1px solid var(--sep2); border-radius: 5px; background: var(--surface); }
label:has(> input.tag-knopf:checked) { background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); }
label:has(> input.tag-knopf:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
input.tag-knopf { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.zeile.kompakt { grid-template-columns: minmax(0, 260px) minmax(0, 260px) auto; }
.zeile.kompakt:has(> .feld > input[type="number"]) { grid-template-columns: minmax(0, 260px) 110px auto; }
.zeile.kompakt ~ .zeile.kompakt .feld:not(:has(> input[type="checkbox"])) > label,
.zeile.kompakt ~ details.mehr .zeile.kompakt .feld:not(:has(> input[type="checkbox"])) > label {
  position: absolute; left: -9999px; } /* Beschriftung nur über der ersten Zeile sichtbar */
details.abschnitt > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
details.abschnitt > summary::before { content: "▸"; margin-right: 6px; }
details.abschnitt[open] > summary::before { content: "▾"; }
details.abschnitt[open] > summary { margin-bottom: 6px; }
.langtext { max-width: 75ch; margin: 4px 0; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.fehler { color: var(--crit); font-size: .9rem; margin: 0; padding: 0; list-style: none; }
.meldung { background: var(--accent-soft); color: var(--accent); border-radius: 8px;
  padding: 8px 12px; margin: 0; }
.meldung.error { background: var(--crit-bg); color: var(--crit); }
/* Ablagefeld für Dokumente: Dateien per Drag & Drop auf das Feld ziehen (#108) */
input.ablage { min-height: 96px; border-style: dashed; padding: 16px; }

/* Anmeldeseiten (allauth) */
.eingang { max-width: 420px; margin: 8vh auto; padding: 0 16px; display: grid; gap: 16px; }
.eingang .karte form { display: grid; gap: 10px; }
.eingang .karte form p { display: grid; gap: 4px; margin: 0; }
.eingang button { min-height: 44px; padding: 0 14px; border-radius: 6px; font: 600 1rem/1 var(--font);
  background: var(--accent); border: 1px solid var(--accent); color: var(--on-accent); cursor: pointer; }

.nur-handy { display: none; }
/* Handy: nur schneller Blick, Erfassung erst ab Tablet (Entscheidung in #78) */
@media (max-width: 767px) {
  html { font-size: 15px; }
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: 64px; }
  .seitenleiste, .flaeche, .nur-erfassung { display: none; }
  .nur-handy { display: block; }
  .inhalt { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  /* Wer geändert hat unter den Text, sonst schiebt die Mailadresse die Seite breiter als das Handy */
  .verlauf li { grid-template-columns: 90px minmax(0, 1fr); }
  .verlauf li > span:last-child { grid-column: 2; }
  .tabs { display: flex; position: fixed; inset: auto 0 0 0; background: var(--side);
    border-top: 1px solid var(--sep); }
  .tabs a, .tabs button { flex: 1; min-height: 56px; border: 0; background: none; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; font-size: .8rem; color: var(--text2); text-decoration: none; }
  .tabs form { flex: 1; display: flex; }
  .tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .tabs .i { width: 22px; height: 22px; }
  .tabelle td a { min-height: 44px; }
  .tabelle td a { display: inline-flex; align-items: center; }
}
/* „+ Einsatzart“ im Muster: weitere Zeilen ohne Neuladen aufklappen */
details.mehr > summary { list-style: none; display: inline-flex; align-items: center; width: fit-content; cursor: pointer; }
details.mehr > summary::-webkit-details-marker { display: none; }
details.mehr[open] > summary { display: none; }
.tabelle .knopf { white-space: nowrap; } /* Aktionen in Tabellen einzeilig (Handlungsbedarf) */
.tabelle .name { white-space: nowrap; } /* Personen in breiten Tabellen (Lohn) */
