/* fit4school ToDo – ruhiges, papierartiges Design in der Formensprache
   von Things (Cultured Code): viel Weissraum, feine Linien, leise Farben.
   Markenfarben: Blau #015694, Grün #bccf02 */

:root {
  --blau: #015694;
  --blau-dunkel: #01466f;
  --blau-hell: #eef4f9;
  --gruen: #bccf02;
  --bg: #f5f5f7;
  --karte: #ffffff;
  --rand: #ececef;          /* Haarlinie */
  --rand-stark: #dcdfe4;    /* Eingabefelder, Umriss-Knöpfe */
  --text: #1c1c1e;
  --text2: #86868b;
  --rot: #d0342c;
  --rot-hell: #fdefee;
  --orange: #c77700;
  --orange-hell: #fdf3e4;
  --gruen-ok: #1d7a3a;
  --gruen-hell: #edf7ef;
  --radius: 14px;
  --schatten: 0 1px 2px rgba(28, 28, 30, 0.04), 0 6px 20px rgba(28, 28, 30, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blau); text-decoration: none; }

/* Fettgedrucktes soll deutlich hervorstechen */
strong, b { font-weight: 700; font-size: 1.03em; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */

.topbar {
  background: var(--karte);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inhalt {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 60px;
  flex-wrap: wrap;
}

.logo { display: flex; align-items: center; }
.logo:hover { text-decoration: none; }
.logo-bild { height: 38px; width: auto; display: block; }
.app-titel {
  color: var(--blau);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Im Cockpit (iframe): Logo ausblenden, weniger Abstand */
.im-cockpit .logo { display: none; }
.im-cockpit .topbar-inhalt,
.im-cockpit .inhalt { padding-left: 14px; padding-right: 14px; }

.hauptnav { display: flex; gap: 2px; flex-wrap: wrap; }
.hauptnav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-weight: 700;
  font-size: 14.5px;
}
.hauptnav a:hover { color: var(--text); text-decoration: none; background: #f2f2f4; }
.hauptnav a.aktiv { color: var(--blau); background: var(--blau-hell); }

.einstellung-schalter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  font-size: 14.5px;
  border-bottom: 1px solid var(--rand);
  cursor: pointer;
}
.einstellung-schalter:last-of-type { border-bottom: none; }
.einstellung-schalter input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blau);
  flex: none;
}

/* Untermenü (Einstellungen: Allgemein · Benutzer · Stammdaten) */
.untermenu {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--rand);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.untermenu a {
  padding: 9px 16px;
  color: var(--text2);
  font-weight: 700;
  font-size: 15px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.untermenu a:hover { color: var(--blau); text-decoration: none; }
.untermenu a.aktiv { color: var(--blau); border-bottom-color: var(--blau); }

/* Navigations-Menü (Einstellungen) */
.nav-menue { position: relative; }
.nav-menue-knopf {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.55;
}
.nav-menue-knopf .pfeil { font-size: 10px; }
.nav-menue-knopf:hover { color: var(--text); background: #f2f2f4; }
.nav-menue-knopf.aktiv { color: var(--blau); background: var(--blau-hell); }
.nav-menue-liste {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(28, 39, 51, 0.16);
  padding: 6px;
  min-width: 170px;
  z-index: 60;
}
.nav-menue.offen .nav-menue-liste { display: block; }
.nav-menue-liste a { display: block; }

.topbar-rechts { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.benutzer-chip { display: flex; align-items: center; gap: 8px; }
.benutzer-chip:hover { text-decoration: none; }
.benutzer-name { font-weight: 700; font-size: 14.5px; color: var(--text); }
.rolle-badge {
  background: var(--gruen);
  color: #3d4402;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ---------- Inhalt ---------- */

.inhalt { max-width: 1200px; margin: 0 auto; padding: 26px 24px 60px; }

.seitenkopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.seitenkopf h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.seitenkopf .untertitel { color: var(--text2); font-size: 14px; margin-top: 3px; }

h2 {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  margin: 0 0 14px;
}

.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 22px 24px;
  margin-bottom: 22px;
}

.karte-gelb { background: #fffdf0; border-color: #efe4bc; }

/* ---------- Detailansicht: eine Kachel, kompakt gegliedert ---------- */

.detail-karte { padding: 18px 20px; }
/* Status steht in der Titelzeile – im PopUp-Kopf wie auf der eigenen Seite */
.kopf-status { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.titel-zeile { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-kopf .kopf-status { margin-right: auto; }
/* Alle Knöpfe in einer Zeile (unterhalb der Anhänge) */
.aktionsleiste {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.aktionsleiste .aktion-rechts { margin-left: auto; }
.detail-karte .trennlinie { margin: 14px 0; }
.detail-karte h2 { margin-bottom: 10px; }
.detail-karte label.feld { margin-bottom: 10px; }
.detail-karte .zuweisung { margin-bottom: 10px; }
.detail-karte .meta-raster { gap: 10px 22px; }
.detail-karte .dropzone { padding: 12px 14px; }
.detail-karte .kommentar { padding: 10px 0; }
textarea.kompakt { min-height: 62px; }

.raster-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.raster-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .raster-2, .raster-3 { grid-template-columns: 1fr; } }

/* ---------- Kennzahlen ---------- */

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .kennzahlen { grid-template-columns: repeat(2, 1fr); } }

.kennzahl {
  display: block;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 18px 20px;
}
a.kennzahl:hover {
  text-decoration: none;
  border-color: var(--rand-stark);
  background: #fcfcfd;
}
a.kennzahl .beschriftung { color: var(--text2); }
.kennzahl .wert { font-size: 30px; font-weight: 700; color: var(--blau); line-height: 1.2; }
.kennzahl .beschriftung { color: var(--text2); font-size: 13.5px; font-weight: 700; }
.kennzahl.warnung .wert { color: var(--rot); }
.kennzahl.ok .wert { color: var(--gruen-ok); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  background: var(--blau);
  color: #fff;
  border: 1px solid var(--blau);
  border-radius: 9px;
  padding: 8px 15px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.btn:hover { background: var(--blau-dunkel); text-decoration: none; color: #fff; }
.btn-leer {
  background: transparent;
  color: var(--blau);
  border-color: var(--rand-stark);
}
.btn-leer:hover { background: var(--blau-hell); color: var(--blau); }
.btn-rot { background: transparent; color: var(--rot); border-color: var(--rand-stark); }
.btn-rot:hover { background: var(--rot-hell); color: var(--rot); }
.btn-klein { padding: 5px 11px; font-size: 13px; border-radius: 8px; }

/* ---------- Checkboxen (Things-Stil: gerundetes Kästchen) ---------- */

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 19px;
  height: 19px;
  margin: 0;
  border: 1.5px solid var(--rand-stark);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  position: relative;
  flex: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
input[type="checkbox"]:hover { border-color: var(--blau); }
input[type="checkbox"]:checked {
  background: var(--blau);
  border-color: var(--blau);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"]:disabled { background: #f4f4f6; border-color: var(--rand); cursor: default; }
input[type="checkbox"]:disabled:checked { background: #b9c3cc; border-color: #b9c3cc; }
input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(1, 86, 148, 0.18); }

/* ---------- Badges (leise Etiketten wie Things-Tags) ---------- */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.status-offen { background: var(--blau-hell); color: var(--blau); }
.status-in_arbeit { background: var(--orange-hell); color: var(--orange); }
.status-zur_freigabe { background: #f3e8ff; color: #7c3aed; }
.status-erledigt { background: var(--gruen-hell); color: var(--gruen-ok); }

.freigabe-karte { border-left: 4px solid #7c3aed; }
/* Freigabe als hervorgehobener Abschnitt innerhalb der Detail-Kachel */
.freigabe-block {
  border-left: 3px solid #7c3aed;
  background: #faf7ff;
  border-radius: 0 10px 10px 0;
  padding: 16px 18px;
}

.prio-niedrig { background: #eef1f5; color: var(--text2); }
.prio-normal { background: var(--blau-hell); color: var(--blau); }
.prio-hoch { background: var(--orange-hell); color: var(--orange); }
.prio-dringend { background: var(--rot-hell); color: var(--rot); }

.badge.kategorie {
  background: color-mix(in srgb, var(--kat) 14%, #ffffff);
  color: var(--kat);
  border: 1px solid color-mix(in srgb, var(--kat) 30%, #ffffff);
}

.ueberfaellig { color: var(--rot); font-weight: 700; }

/* ---------- Tabellen ---------- */

.tabelle-umbruch { overflow-x: auto; }

table.liste { width: 100%; border-collapse: collapse; }
table.liste th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text2);
  padding: 6px 10px;
  border-bottom: 1px solid var(--rand);
  white-space: nowrap;
}
table.liste td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}
table.liste tr:last-child td { border-bottom: none; }
table.liste tr[data-href] { cursor: pointer; }
/* Zeile hebt sich beim Überfahren als weich gerundetes Feld hervor */
table.liste tr[data-href]:hover td { background: var(--blau-hell); }
table.liste tr[data-href]:hover td:first-child { border-radius: 9px 0 0 9px; }
table.liste tr[data-href]:hover td:last-child { border-radius: 0 9px 9px 0; }
table.liste td a { color: var(--text); font-weight: 600; }
table.liste td a:hover { color: var(--blau); text-decoration: none; }
table.liste td strong { font-weight: 600; }
/* Rechtsausrichtung muss die Kopfzeilen-Regel oben überstimmen,
   damit Zahlen genau unter ihrem Spaltentitel stehen */
td.rechts, th.rechts,
table.liste td.rechts, table.liste th.rechts { text-align: right; }

/* Pendenzenliste: Titel führt, Nebenangaben treten zurück */
table.todo-tabelle td:nth-child(4),
table.todo-tabelle td:nth-child(5),
table.todo-tabelle td:nth-child(6) { font-size: 13.5px; color: var(--text2); }
table.todo-tabelle td:nth-child(6).ueberfaellig { color: var(--rot); font-weight: 700; }
table.liste td.ueberfaellig { color: var(--rot); }
table.todo-tabelle td a strong { font-size: 15.5px; font-weight: 600; }

.leer-hinweis { color: var(--text2); padding: 14px 4px; }

/* ---------- Formulare ---------- */

label.feld { display: block; margin-bottom: 14px; }
label.feld .feldname {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1px;
  color: var(--text2);
  margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}
select { -webkit-appearance: auto; appearance: auto; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blau);
  box-shadow: 0 0 0 3px rgba(1, 86, 148, 0.13);
}
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  cursor: pointer;
  background: var(--text2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 4l8 8M12 4l-8 8' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="search"]::-webkit-search-cancel-button:hover { background: var(--blau); }
textarea { min-height: 110px; resize: vertical; }
input[type="color"] { border: 1px solid var(--rand); border-radius: 8px; height: 38px; width: 54px; padding: 2px; background: #fff; }

.formular-zeile { display: flex; gap: 14px; flex-wrap: wrap; }
.formular-zeile > label.feld { flex: 1; min-width: 160px; }

.karte.filterleiste {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin-bottom: 18px;
}
.filterleiste .such-voll { display: block; margin-bottom: 12px; }
.filterleiste .such-voll input {
  width: 100%;
  font-size: 15.5px;
  padding: 11px 15px;
  background: #efeff1;
  border-color: transparent;
  border-radius: 11px;
}
.filterleiste .such-voll input::placeholder { color: #9a9aa0; }
.filterleiste .such-voll input:focus { background: #fff; border-color: var(--blau); }
.filter-zeile {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-zeile label.feld { margin-bottom: 0; flex: 1; min-width: 130px; max-width: 220px; }

/* ---------- Flash ---------- */

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 14px;
}
.flash-ok { background: var(--gruen-hell); color: var(--gruen-ok); }
.flash-fehler { background: var(--rot-hell); color: var(--rot); }

/* ---------- Login ---------- */

.login-buehne {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 34px 34px 28px;
  width: 100%;
  max-width: 400px;
}
.login-karte .logo { justify-content: center; }
.login-karte .logo-bild { height: 64px; margin: 4px auto 8px; }
.login-karte h1 { font-size: 19px; margin: 10px 0 18px; }
.login-karte .btn { width: 100%; margin-top: 6px; }
.login-fuss { margin-top: 14px; font-size: 13.5px; color: var(--text2); }

/* ---------- ToDo-Detail ---------- */

.meta-raster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 18px;
  margin: 14px 0 4px;
}
.meta-feld .feldname { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text2); font-weight: 700; }
.meta-feld .feldwert { font-size: 14.5px; margin-top: 2px; }

.beschreibung { white-space: pre-wrap; }

.status-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.kommentar { border-top: 1px solid var(--rand); padding: 12px 2px; }
.kommentar:first-of-type { border-top: none; }
.kommentar-kopf { font-size: 13px; color: var(--text2); margin-bottom: 3px; }
.kommentar-kopf strong { color: var(--text); }
.kommentar-text { white-space: pre-wrap; }

.verlauf-liste { list-style: none; margin: 8px 0 0; padding: 0; }
.verlauf-liste li {
  padding: 7px 2px 7px 18px;
  border-left: 2px solid var(--rand);
  margin-left: 6px;
  font-size: 13.5px;
  color: var(--text2);
  position: relative;
}
.verlauf-liste li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gruen);
}
.verlauf-liste strong { color: var(--text); }

details.aufklapp > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15.5px;
  color: var(--blau);
  list-style: none;
}
details.aufklapp > summary::before { content: "▸ "; }
details.aufklapp[open] > summary::before { content: "▾ "; }

/* ---------- Kleinkram ---------- */

.hinweis { color: var(--text2); font-size: 13.5px; }
.abstand-oben { margin-top: 16px; }
.abstand-klein { margin-top: 6px; }
.trennlinie { border: none; border-top: 1px solid var(--rand); margin: 18px 0; }
.inaktiv-zeile td { opacity: 0.55; }
.nowrap { white-space: nowrap; }

.seitennav { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; }

/* ---------- PopUps (dialog) ---------- */

dialog.modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(28, 39, 51, 0.25);
  color: var(--text);
}
dialog.modal::backdrop { background: rgba(28, 39, 51, 0.45); }

.modal-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 22px;
  border-bottom: 1px solid var(--rand);
}
.modal-kopf h2 { margin: 0; font-size: 17px; }
.modal-schliessen {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  padding: 0;
  border-radius: 50%;
}
.modal-schliessen svg { width: 19px; height: 19px; }
.modal-schliessen:hover { background: var(--blau-hell); color: var(--blau); }
.modal-body { padding: 18px 22px; max-height: min(68vh, 640px); overflow-y: auto; }
dialog.modal-breit { width: min(860px, calc(100vw - 32px)); }
dialog.modal-breit .modal-body { max-height: min(80vh, 760px); }
/* Detailinhalt im PopUp: ohne eigenen Kachelrahmen */
.detail-karte.im-popup { padding: 0; }
/* Der Status wandert in die Titelzeile – die erste Trennlinie entfällt dann */
.detail-karte > hr.trennlinie:first-child { display: none; }
.modal-fuss {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--rand);
  flex-wrap: wrap;
}
.modal-fuss-links { display: flex; gap: 10px; }
.modal-fuss-rechts { display: flex; gap: 10px; margin-left: auto; }

tr.benutzer-zeile { cursor: pointer; }
tr.benutzer-zeile:hover td { background: var(--blau-hell); }

.rechte-tabelle td, .rechte-tabelle th { padding: 7px 10px; }
.rechte-tabelle.ohne-bearbeiten th:nth-child(3),
.rechte-tabelle.ohne-bearbeiten td:nth-child(3) { display: none; }
.recht-standort-zeile.inbegriffen td { opacity: 0.55; }
.recht-standort-zeile.inbegriffen input[type="checkbox"] { accent-color: var(--text2); }
.rechte-tabelle input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--blau); }

/* ---------- Stammdaten: ausklappbare Liste ---------- */

.klapp-spalte { width: 30px; }
.klapp-knopf {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 14px;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 6px;
  transition: transform 0.15s ease;
}
.klapp-knopf:hover { background: var(--blau-hell); color: var(--blau); }
tbody.gebiet-gruppe.offen .gebiet-zeile .klapp-knopf { transform: rotate(90deg); }

tbody.gebiet-gruppe tr.gebiet-zeile { cursor: pointer; }
tbody.gebiet-gruppe tr.gebiet-zeile:hover td { background: var(--blau-hell); }
tbody.gebiet-gruppe tr.standort-zeile { display: none; }
tbody.gebiet-gruppe.offen tr.standort-zeile { display: table-row; }
tbody.gebiet-gruppe.offen tr.standort-zeile td { background: #fafbfd; }

.standort-einzug { padding-left: 30px !important; }

/* ---------- Kalender ---------- */

.kal-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.kal-titel { margin: 0; font-size: 18px; }

.kalender {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  min-width: 760px;
}
.kal-tag { min-width: 0; }
.kal-eintrag { overflow-wrap: anywhere; }
.kal-kopfzelle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text2);
  font-weight: 700;
  padding: 2px 6px;
}
.kal-tag {
  background: #fafbfd;
  border: 1px solid var(--rand);
  border-radius: 10px;
  min-height: 104px;
  padding: 6px 7px;
}
.kal-tag[data-datum] { cursor: pointer; }
.kal-tag[data-datum]:hover { border-color: var(--blau); background: var(--blau-hell); }
.kal-tag.leer { background: transparent; border: none; }
.kal-tag.heute { border-color: var(--blau); box-shadow: 0 0 0 2px rgba(1, 86, 148, 0.15); background: #fff; }
.kal-nummer { font-size: 12.5px; font-weight: 700; color: var(--text2); }
.kal-tag.heute .kal-nummer { color: var(--blau); }

.kal-eintrag {
  display: block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kal-eintrag:hover { text-decoration: none; filter: brightness(0.93); }
.kal-eintrag.kal-ueberfaellig { box-shadow: inset 2px 0 0 var(--rot); color: var(--rot); }
.kal-eintrag.kal-vorschau { opacity: 0.55; border: 1px dashed rgba(1, 86, 148, 0.35); }

/* ---------- Zuweisung: Chips ---------- */

.zuweisung {
  margin-bottom: 14px;
}
/* Ein einziges Feld: Etiketten und Eingabe liegen zusammen im selben Rahmen */
.zuweisung-feld {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 5px 8px;
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  background: #fff;
  cursor: text;
}
.zuweisung-feld:focus-within {
  border-color: var(--blau);
  box-shadow: 0 0 0 3px rgba(1, 86, 148, 0.13);
}
.zuweisung-chips { display: contents; }
.zuweisung-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--blau-hell);
  color: var(--blau);
  font-weight: 700;
  font-size: 13.5px;
  border-radius: 999px;
  padding: 3px 8px 3px 12px;
}
.zuweisung-entfernen {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blau);
  font-size: 16px;
  line-height: 1;
  padding: 1px 6px;
  border-radius: 50%;
}
.zuweisung-entfernen:hover { background: rgba(1, 86, 148, 0.18); }
/* Suche mit Vorschlägen (ersetzt die Auswahlliste) */
.zuweisung-suche {
  flex: 1;
  min-width: 150px;
  width: auto;
  border: none;
  border-radius: 0;
  background: none;
  padding: 4px 2px;
  font-size: 14.5px;
}
.zuweisung-suche:focus { outline: none; box-shadow: none; border: none; }
/* Vorschläge erscheinen im Feld selbst (kein aufklappendes Menü) */
.zuweisung-vorschlaege {
  flex: 1 0 100%;
  border-top: 1px solid var(--rand);
  margin-top: 4px;
  padding-top: 4px;
  max-height: 210px;
  overflow-y: auto;
}
.zuweisung-vorschlaege[hidden] { display: none; }
.zuweisung-vorschlag {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.zuweisung-vorschlag:hover, .zuweisung-vorschlag.markiert { background: var(--blau-hell); }
.zuweisung-vorschlag-info { color: var(--text2); font-size: 12.5px; }
.zuweisung-anlegen { color: var(--blau); font-weight: 700; }
.zuweisung-vorschlag-leer { padding: 7px 8px; color: var(--text2); font-size: 13.5px; }

/* ---------- Anhänge: Drag & Drop ---------- */

.dropzone {
  border: 2px dashed var(--rand);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
  background: #fafbfd;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.js { cursor: pointer; }
.dropzone:hover, .dropzone.aktiv {
  border-color: var(--blau);
  background: var(--blau-hell);
}
.dropzone-text { color: var(--text2); font-size: 14.5px; font-weight: 700; }
.dropzone.aktiv .dropzone-text { color: var(--blau); }
.dropzone-liste { margin-top: 6px; word-break: break-word; }
.dropzone input[type="file"] { margin-top: 8px; }
.dropzone input[type="file"].verborgen { display: none; }

.stamm-karte { position: relative; }
.stamm-aktionen {
  position: absolute;
  top: 15px;
  right: 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 1;
}
.stamm-karte details.aufklapp > summary { padding-right: 180px; }
@media (max-width: 760px) {
  .stamm-aktionen { position: static; margin-bottom: 10px; }
  .stamm-karte details.aufklapp > summary { padding-right: 0; }
}

/* Der Titel «Pendenzen» steht auf dem Desktop bereits als erster
   Navigationspunkt – dort deshalb nicht doppelt anzeigen. */
@media (min-width: 641px) { .app-titel { display: none; } }

/* ---------- Erledigt-Checkbox in der ToDo-Liste ---------- */
.titel-zeile { display: flex; align-items: flex-start; gap: 10px; }
.erledigt-form { display: flex; padding-top: 2px; }
.erledigt-box {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--blau);
  cursor: pointer;
  flex: none;
}
.titel-text { min-width: 0; }
.erledigt-zeile .titel-text a strong { text-decoration: line-through; font-weight: 600; }
.erledigt-zeile .titel-text a { color: var(--text2); }

/* ---------- Handy-Ansicht (PWA): App-Layout mit Burger-Menü ---------- */
.burger, .burger-menue, .fab { display: none; } /* Desktop: obere Navigation */
.filter-hinweis { display: none; }              /* Desktop: Dropdowns zeigen den Filter */

@media (max-width: 640px) {
  .inhalt { padding: 14px 12px calc(90px + env(safe-area-inset-bottom)); }
  .topbar-inhalt { padding: 10px 12px; gap: 10px; min-height: 0; }
  .logo-bild { height: 28px; }
  .app-titel { font-size: 17px; }
  .benutzer-name { display: none; }
  .hauptnav { display: none; }        /* ersetzt durch das Burger-Menü */
  .abmelden-knopf { display: none; }  /* Abmelden im Burger-Menü */

  /* Burger-Knopf in der Kopfzeile */
  .burger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background: none;
    border: 1px solid var(--rand);
    border-radius: 10px;
    color: var(--blau);
    cursor: pointer;
  }
  .burger svg { width: 22px; height: 22px; }

  /* Menü klappt unter der Kopfzeile auf */
  .burger-menue {
    display: block;
    position: fixed;
    top: 61px;
    left: 0;
    right: 0;
    background: var(--karte);
    border-bottom: 1px solid var(--rand);
    box-shadow: 0 12px 30px rgba(28, 39, 51, 0.16);
    padding: 8px;
    z-index: 59;
  }
  .burger-menue[hidden] { display: none; }
  .burger-menue a {
    display: block;
    padding: 15px 14px;
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    border-radius: 10px;
  }
  .burger-menue a + a { border-top: 1px solid var(--rand); border-radius: 0; }
  .burger-menue a.aktiv { color: var(--blau); background: var(--blau-hell); }
  .burger-menue a:hover { text-decoration: none; }

  /* Schwebender Knopf für ein neues ToDo */
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--blau);
    color: #fff;
    font-size: 32px;
    font-weight: 500;
    line-height: 1;
    padding-bottom: 4px;
    box-shadow: 0 6px 18px rgba(1, 86, 148, 0.4);
    cursor: pointer;
    z-index: 58;
  }

  /* Grössere Trefferfläche für die Erledigt-Checkbox */
  .erledigt-box { width: 23px; height: 23px; border-radius: 7px; }
  .erledigt-box:checked::after { left: 7px; top: 4px; }
  .badge { font-size: 11px; padding: 1px 7px; }

  /* Schliessen-Knopf als gut treffbarer runder Knopf */
  .modal-kopf { padding: 14px 12px 14px 18px; }
  .modal-schliessen {
    width: 40px;
    height: 40px;
    background: var(--bg);
    color: var(--text);
  }
  .modal-schliessen svg { width: 21px; height: 21px; }

  /* Zähler offener ToDos im Burger-Menü */
  .menue-zaehler {
    display: inline-block;
    min-width: 22px;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 11px;
    background: var(--blau);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
    vertical-align: 1px;
  }
  .untermenu {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .untermenu::-webkit-scrollbar { display: none; }
  .untermenu a { white-space: nowrap; }
  .seitenkopf { flex-direction: column; align-items: stretch; gap: 10px; }
  .seitenkopf .btn { width: 100%; text-align: center; }
  .seitenkopf .btn[data-dialog="todo-dialog"] { display: none; } /* runder +-Knopf übernimmt */
  .kennzahlen { gap: 8px; }
  .kennzahl .wert { font-size: 24px; }
  .karte { padding: 14px; }
  dialog.modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .modal-body { max-height: none; flex: 1; }
  dialog.modal form { display: flex; flex-direction: column; height: 100%; }
  .modal-fuss { flex-wrap: wrap; }
  .zuweisung-feld { min-height: 44px; }
  .liste td, .liste th { padding: 8px 8px; }

  /* Alle übrigen Listen stapeln sich, damit nichts seitlich hinausläuft.
     Die eigens gestalteten Tabellen bleiben ausgenommen. */
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle),
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) > tbody,
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) tr,
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) td {
    display: block;
    width: 100%;
  }
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) tr:has(th) {
    display: none; /* Kopfzeile entfällt in der gestapelten Ansicht */
  }
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) tr {
    padding: 10px 2px;
    border-bottom: 1px solid var(--rand);
  }
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) tr:last-child {
    border-bottom: none;
  }
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) td {
    border: none;
    padding: 2px 0;
    white-space: normal;
  }
  /* Erste Spalte als Titelzeile, die übrigen Angaben kompakt in einer Zeile */
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) td:not(:first-child):not(.rechts) {
    display: inline;
    width: auto;
    font-size: 13.5px;
    color: var(--text2);
  }
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) td:not(:first-child):not(.rechts) + td:not(.rechts)::before {
    content: " · ";
    color: var(--text2);
  }
  /* Aktionsspalte: Knöpfe nebeneinander, links ausgerichtet, umbruchfähig */
  table.liste:not(.todo-tabelle):not(.benutzer-tabelle):not(.belastung-tabelle):not(.rechte-tabelle):not(.stamm-tabelle) td.rechts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    text-align: left;
    margin-top: 8px;
  }

  /* Stammdaten: Gebiete mit Klapp-Spalte und eingerückten Standorten */
  table.stamm-tabelle, table.stamm-tabelle tbody, table.stamm-tabelle tr { display: block; width: 100%; }
  table.stamm-tabelle tr.gebiet-zeile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    border-bottom: 1px solid var(--rand);
  }
  table.stamm-tabelle tr.gebiet-zeile td { display: block; border: none; padding: 0; }
  table.stamm-tabelle tr.gebiet-zeile td.klapp-spalte { flex: none; }
  /* Höhere Spezifität als die Desktop-Regeln der ausklappbaren Liste */
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile {
    display: block;
    padding: 10px 10px 10px 16px;
    border-bottom: 1px solid var(--rand);
    background: #fafbfd;
  }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td {
    display: inline;
    background: none;
    border: none;
    padding: 0;
    white-space: normal;
  }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td:first-child { display: none; }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td.standort-einzug {
    display: inline;
    padding-left: 0 !important;
    font-weight: 600;
  }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td.standort-einzug .hinweis { display: inline; font-weight: 400; }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td.standort-einzug + td::before { content: " · "; color: var(--text2); }
  table.stamm-tabelle tbody.gebiet-gruppe.offen tr.standort-zeile td.rechts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    text-align: left;
  }
  table.stamm-tabelle tbody.gebiet-gruppe:last-child tr:last-child { border-bottom: none; }

  /* Stammdaten/Einstellungen: Aktionsknopf unter den Kartentitel */
  .stamm-karte { display: flex; flex-direction: column; }
  .stamm-karte .stamm-aktionen { order: 2; margin: 12px 0 0; }
  .stamm-karte > details.aufklapp { order: 1; }
  /* Mobil nur die Live-Suche — Filter-Dropdowns bleiben dem Desktop vorbehalten */
  .filterleiste .filter-zeile { display: none; }
  .filterleiste .such-voll { margin-bottom: 0; }
  .filter-hinweis { display: block; } /* aktiver Filter als Hinweis mit «aufheben» */
  .nur-desktop { display: none; }

  /* ToDo-Liste als gestapelte Karten */
  table.todo-tabelle, table.todo-tabelle tbody, table.todo-tabelle tr, table.todo-tabelle td { display: block; width: 100%; }
  table.todo-tabelle tr:first-child { display: none; } /* Kopfzeile */
  table.todo-tabelle tr { padding: 10px 2px; border-bottom: 1px solid var(--rand); }
  table.todo-tabelle tr:last-child { border-bottom: none; }
  table.todo-tabelle td { border: none; padding: 1px 0; }
  table.todo-tabelle td:nth-child(2), table.todo-tabelle td:nth-child(3) { display: inline-block; width: auto; margin: 3px 6px 1px 0; }
  table.todo-tabelle td:nth-child(4), table.todo-tabelle td:nth-child(5), table.todo-tabelle td:nth-child(6) { display: inline; width: auto; font-size: 13px; color: var(--text2); white-space: normal; }
  table.todo-tabelle td:nth-child(5)::before, table.todo-tabelle td:nth-child(6)::before { content: " · "; }
  table.todo-tabelle td:nth-child(6).ueberfaellig { color: var(--rot); font-weight: 700; }

  /* Benutzerliste als gestapelte Karten */
  table.benutzer-tabelle, table.benutzer-tabelle tbody, table.benutzer-tabelle tr, table.benutzer-tabelle td { display: block; width: 100%; }
  table.benutzer-tabelle tr:first-child { display: none; } /* Kopfzeile */
  table.benutzer-tabelle tr { padding: 10px 2px; border-bottom: 1px solid var(--rand); }
  table.benutzer-tabelle tr:last-child { border-bottom: none; }
  table.benutzer-tabelle td { border: none; padding: 1px 0; }
  table.benutzer-tabelle td:nth-child(2) { display: inline-block; width: auto; margin: 4px 8px 2px 0; }
  table.benutzer-tabelle td:nth-child(3), table.benutzer-tabelle td:nth-child(4), table.benutzer-tabelle td:nth-child(5) { display: inline; width: auto; font-size: 13px; white-space: normal; }
  table.benutzer-tabelle td:nth-child(3)::before { content: "\A"; white-space: pre; } /* Meta-Angaben auf eigener Zeile */
  table.benutzer-tabelle td:nth-child(4)::before, table.benutzer-tabelle td:nth-child(5)::before { content: " · "; }
  table.benutzer-tabelle td:nth-child(6) { display: none; } /* Letzte Anmeldung */
  table.benutzer-tabelle td:nth-child(7) { text-align: left; padding-top: 6px; }

  /* Auslastungstabellen: Gebiet-Spalte ausblenden, damit die Zahlen Platz haben */
  table.belastung-tabelle th:nth-child(2), table.belastung-tabelle td:nth-child(2) { display: none; }
  table.belastung-tabelle { min-width: 0; width: 100%; }
  table.belastung-tabelle td, table.belastung-tabelle th { padding: 8px 4px; font-size: 13px; }
  table.belastung-tabelle th { font-size: 10.5px; }
}
