/* Berkefeld App – Stylesheet
   Gestaltungssprache nach dem Cockpit des CEO-GPT (21.10.2026, Wunsch GF): warme Flächen, Terrakotta als Akzent,
   Schrift Space Grotesk (lokal, kein externer Aufruf), große ruhige Kacheln mit einer Zahl und Unterzeile,
   seitliches Menü am Mac, Kopfleiste mit Zurück-Knopf am Handy. Handy zuerst (ab 360 px), ab 900 px Mac-Layout.
   Helle Variante ist Standard, dunkle Variante (= Cockpit-Farben) über prefers-color-scheme. */

/* Das Attribut hidden gewinnt immer, auch gegen Klassen mit eigenem display (z. B. .knopf { display: inline-flex }).
   Eine Autorenregel schlägt sonst die Browser-Vorgabe [hidden] { display: none } (04.11.2026). */
[hidden] { display: none !important; }

@font-face {
  font-family: "Space Grotesk";
  src: url("/static/vendor/SpaceGrotesk-var.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Farben (hell) */
  --hintergrund: #f3eee6;
  --flaeche: #fffcf7;
  --flaeche-leise: #f5efe6;
  --flaeche-tief: #ebe3d8;
  --rand: rgba(42, 30, 20, 0.10);
  --rand-stark: rgba(42, 30, 20, 0.20);
  --text: #231a12;
  --text-leise: #5c5046;
  --text-sehr-leise: #857a6f;

  --akzent: #c26b4c;
  --akzent-dunkel: #8a4830;
  --akzent-hell: rgba(194, 107, 76, 0.12);
  --akzent-ring: rgba(194, 107, 76, 0.45);
  --akzent-text: #ffffff;
  /* Alte Namen bleiben gültig (Modul-Stylesheets): „haupt“ ist jetzt der Akzent */
  --haupt: var(--akzent);
  --haupt-dunkel: var(--akzent-dunkel);
  --haupt-hell: var(--akzent-hell);

  --ok: #496423;
  --ok-hell: rgba(73, 100, 35, 0.13);
  --fehler: #ac382b;
  --fehler-hell: rgba(172, 56, 43, 0.12);
  --hinweis: #855b0d;
  --hinweis-hell: rgba(133, 91, 13, 0.14);
  --info: #28677e;
  --info-hell: rgba(40, 103, 126, 0.12);

  --schatten: 0 1px 2px rgba(42, 30, 20, 0.05);
  --schatten-gross: 0 12px 30px rgba(42, 30, 20, 0.18);

  /* Maße */
  --radius: 14px;
  --radius-klein: 8px;
  --rand-seite: 16px;
  --tipp: 46px;
  --leiste-breite: 248px;
  --leiste-hoehe: 54px;

  /* Schrift */
  --schrift: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --schrift-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hintergrund: #0a0805;
    --flaeche: #17130f;
    --flaeche-leise: #1f1914;
    --flaeche-tief: #27201a;
    --rand: rgba(242, 232, 220, 0.08);
    --rand-stark: rgba(242, 232, 220, 0.16);
    --text: #f2e8dc;
    --text-leise: #c4b8a8;
    --text-sehr-leise: #8c8479;

    --akzent: #c26b4c;
    --akzent-dunkel: #d17a5a;
    --akzent-hell: rgba(194, 107, 76, 0.16);
    --akzent-ring: rgba(194, 107, 76, 0.5);
    --akzent-text: #1a0f0a;

    --ok: #9bac72;
    --ok-hell: rgba(155, 172, 114, 0.14);
    --fehler: #e38374;
    --fehler-hell: rgba(227, 131, 116, 0.14);
    --hinweis: #e3b665;
    --hinweis-hell: rgba(227, 182, 101, 0.14);
    --info: #84bbd4;
    --info-hell: rgba(132, 187, 212, 0.14);

    --schatten: 0 1px 2px rgba(0, 0, 0, 0.4);
    --schatten-gross: 0 12px 30px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ---------- Grundlagen ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px; /* kleine Handys (iPhone SE, schmale Android-Geräte); vorher 360 → Seite wurde herausgezoomt */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--hintergrund);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0; background: var(--hintergrund); z-index: -1; pointer-events: none; }
::selection { background: var(--akzent-hell); color: var(--text); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; letter-spacing: -0.015em; }
h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; margin-top: 1.4em; }
h3 { font-size: 1rem; font-weight: 600; margin-top: 1.2em; }
p { margin: 0 0 1em; }
a { color: var(--akzent-dunkel); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 600; }
code {
  font-family: var(--schrift-mono);
  font-size: 0.9em;
  background: var(--flaeche-leise);
  border: 1px solid var(--rand);
  border-radius: 4px;
  padding: 0 4px;
  word-break: break-all;
}
img, svg { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--rand); margin: 1.5rem 0; }

.ikon { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; vertical-align: -3px; }

/* kleine Beschriftung in Großbuchstaben, wie im Cockpit */
.eyebrow, .kachel-titel, .tabelle th, .nav-gruppe-titel, .karte-unter {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-sehr-leise);
}

/* ---------- App-Hülle: Seitenleiste (Mac) und Kopfleiste (Handy) ---------- */

.app-huelle { display: flex; flex-direction: column; flex: 1 0 auto; width: 100%; }

.mobil-leiste {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--leiste-hoehe) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: var(--hintergrund);
  border-bottom: 1px solid var(--rand);
}
.ml-knopf {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-klein);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ml-knopf .ikon { width: 24px; height: 24px; }
.ml-knopf:hover { background: var(--flaeche-leise); }
.ml-zurueck[hidden] { display: none; }
.ml-titel {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-hintergrund {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 310;
  border: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
body.nav-offen .nav-hintergrund { opacity: 1; pointer-events: auto; }

.seitenleiste {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 320;
  display: flex;
  flex-direction: column;
  width: min(86vw, 310px);
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--hintergrund);
  border-right: 1px solid var(--rand-stark);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  overflow-y: auto;
}
.seitenleiste.offen { transform: none; box-shadow: var(--schatten-gross); }

.marke {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  color: var(--text);
  text-decoration: none;
}
.marke:hover { text-decoration: none; }
.marke-zeichen {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--akzent), var(--akzent-dunkel));
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 1px var(--akzent-ring), 0 4px 14px rgba(194, 107, 76, 0.25);
}
.marke-text { display: flex; flex-direction: column; line-height: 1.15; }
.marke-name { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.marke-unter { font-size: 0.72rem; color: var(--text-sehr-leise); margin-top: 3px; }

.sl-nav { flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; padding: 4px 10px 12px; }
.nav-gruppe-titel { padding: 14px 12px 6px; }
.nav-eintrag {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-leise);
  font-size: 0.98rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-eintrag .ikon { width: 19px; height: 19px; color: var(--text-sehr-leise); }
.nav-eintrag:hover { background: var(--flaeche-leise); color: var(--text); text-decoration: none; }
.nav-eintrag:hover .ikon { color: var(--text); }
.nav-eintrag.aktiv { background: var(--akzent-hell); color: var(--text); font-weight: 600; }
.nav-eintrag.aktiv .ikon { color: var(--akzent); }
.nav-eintrag.aktiv::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  width: 3px;
  height: 22px;
  transform: translateY(-50%);
  background: var(--akzent);
  border-radius: 0 2px 2px 0;
}
.nav-eintrag .zaehler {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px !important;
  border-radius: 999px !important;
  background: var(--akzent) !important;
  color: #fff !important;
  font-size: 0.75rem !important;
  font-weight: 600;
  text-align: center;
}

.sl-fuss {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rand);
}
.sl-fuss form { margin: 0; }
.sl-fuss-zeile { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.nav-klein {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text-leise);
  font-size: 0.9rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-klein .ikon { width: 16px; height: 16px; }

/* Kopf ohne Anmeldung (Anmeldeseite, öffentliche Annahme-Seite) */
.kopf {
  display: flex;
  justify-content: center;
  padding: 10px var(--rand-seite) 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.kopf .marke { padding: 14px 8px 6px; }

/* ---------- Inhalt und Fuß ---------- */

.inhalt {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px var(--rand-seite) 40px;
  padding-left: max(var(--rand-seite), env(safe-area-inset-left));
  padding-right: max(var(--rand-seite), env(safe-area-inset-right));
}

.fuss {
  padding: 14px var(--rand-seite);
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-sehr-leise);
}

/* ---------- Karten, Abschnitte, Raster ---------- */

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.karte > :first-child { margin-top: 0; }
.karte > :last-child { margin-bottom: 0; }
.karte h1 { font-size: 1.35rem; }
.karte h2 { font-size: 1.05rem; margin-bottom: 12px; }
.karte h2 .klein, .karte h2 .chip { margin-left: 6px; }

.karte-schmal {
  max-width: 440px;
  margin: 24px auto 16px;
}

.abschnitt { margin-bottom: 24px; }
.abschnitt > :last-child { margin-bottom: 0; }

.seitenkopf {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}
.seitenkopf h1 { margin: 0; }
.seitenkopf h1 .chip { vertical-align: middle; margin-left: 4px; }
.seitenkopf .aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seitenkopf .aktionen form { margin: 0; }

.raster-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

dl.daten {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}
dl.daten dt { color: var(--text-leise); }
dl.daten dd { margin: 0; overflow-wrap: anywhere; }
.vorformatiert { white-space: pre-wrap; }

/* ---------- Kacheln (Leitzahlen und Übersichten) ---------- */

.kacheln {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kacheln > * { min-width: 0; }

.kachel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 112px;
  padding: 16px 16px 14px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color 0.12s, transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
a.kachel:hover, a.kachel:focus-visible, .kachel[role="button"]:hover {
  border-color: var(--akzent);
  color: var(--text);
  text-decoration: none;
  transform: translateY(-1px);
}
.kachel:active { transform: translateY(0); }
.kachel:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.kachel.aktiv { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent-ring); }

.kachel-titel {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-right: 22px;
  line-height: 1.3;
}
.kachel-titel .ikon { width: 14px; height: 14px; color: var(--akzent); }
.kachel-zahl {
  /* Am Handy sind die Kacheln schmal: Betrag und €-Zeichen bleiben in einer Zeile, die Schrift gibt nach. */
  font-size: clamp(1.45rem, 6.5vw, 2.125rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.kachel-zahl .einheit { font-size: 0.55em; font-weight: 500; color: var(--text-leise); margin-left: 3px; letter-spacing: 0; }
.kachel-text {
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text-leise);
}
.kachel-pfeil {
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--text-sehr-leise);
  transition: transform 0.15s;
}
.kachel-pfeil .ikon { width: 16px; height: 16px; }
.kachel.aktiv .kachel-pfeil { transform: rotate(180deg); color: var(--akzent); }

/* Am Handy: Leitzahlen in einer Spalte (Beträge bleiben ganz lesbar), Gruppen zu zweit mit etwas kleinerer Zahl */
@media (max-width: 599px) {
  .kacheln-leit { grid-template-columns: minmax(0, 1fr); }
  .kacheln-leit .kachel { min-height: 0; }
  .kacheln:not(.kacheln-leit) .kachel-zahl { font-size: clamp(1.2rem, 5.4vw, 2.125rem); }
}

/* Handlungsbedarf: Strich links wie die Akzent-Kachel im Cockpit */
.kachel-warnung::after, .kachel-warn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--akzent);
}
.kachel-warnung .kachel-zahl, .kachel-warn .kachel-zahl { color: var(--akzent-dunkel); }
.kachel-warn .kachel-titel { color: var(--text-sehr-leise); }

/* Fortschrittsbalken (Umsatz gegen Ziel) */
.meter {
  height: 7px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--flaeche-tief);
  overflow: hidden;
}
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--akzent); transition: width 0.2s; }
.meter.ok > span { background: var(--ok); }
.meter.warn > span { background: var(--hinweis); }
.meter.err > span { background: var(--fehler); }

/* Aufgeklappte Details direkt unter der Kachel (static/aufklappen.js) */
.kachel-detail {
  grid-column: 1 / -1;
  background: var(--flaeche);
  border: 1px solid var(--akzent);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 16px 16px 14px;
  margin: -2px 0 4px;
}
.kachel-detail[hidden] { display: none; }
.kd-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.kd-kopf h3 { margin: 0; font-size: 1.1rem; }
.kd-text { margin: 4px 0 10px; color: var(--text-leise); font-size: 0.92rem; }
.kd-zu {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--rand-stark);
  border-radius: 999px;
  background: transparent;
  color: var(--text-leise);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.kd-zu:hover { border-color: var(--akzent); color: var(--akzent-dunkel); }
.kd-liste { list-style: none; margin: 0; padding: 0; }
.kd-liste li { border-top: 1px solid var(--rand); }
.kd-liste li:first-child { border-top: 0; }
.kd-liste a, .kd-liste .kd-zeile {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name wert" "neben neben";
  gap: 2px 12px;
  align-items: baseline;
  padding: 10px 4px;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
}
.kd-liste a:hover { background: var(--flaeche-leise); text-decoration: none; }
.kd-name { grid-area: name; font-weight: 500; overflow-wrap: anywhere; }
.kd-neben { grid-area: neben; font-size: 0.85rem; color: var(--text-leise); }
.kd-wert { grid-area: wert; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kd-wert small { font-weight: 400; color: var(--text-leise); }
.kd-alle { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-weight: 600; }
.kd-leer { padding: 12px 4px; color: var(--text-sehr-leise); }

/* Gruppen auf der Startseite */
.gruppe-kopf {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 8px 0 10px;
}
.gruppe-kopf h2 { margin: 0; font-size: 1.05rem; }
.gruppe-kopf .klein { color: var(--text-sehr-leise); }
.gruss { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 14px; }
.gruss h1 { margin: 0; }
.gruss .klein { color: var(--text-sehr-leise); }
.bereiche-leiste { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.bereiche-leiste a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 14px 6px 12px;
  border: 1px solid var(--rand);
  border-radius: 999px;
  background: var(--flaeche);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.bereiche-leiste a:hover { border-color: var(--akzent); text-decoration: none; }
.bereiche-leiste .ikon { width: 16px; height: 16px; color: var(--akzent); }
.bereiche-leiste .zahl { font-size: 0.85rem; color: var(--text-leise); font-variant-numeric: tabular-nums; }

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

.formular {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.formular label,
.feld {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-leise);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  min-height: var(--tipp);
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;            /* gegen Zoom am iPhone */
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.4; }

select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23857a6f' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
  border-color: var(--akzent);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--flaeche-leise);
  color: var(--text-sehr-leise);
}
input[type="file"] { font-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--text-sehr-leise); }

input[type="checkbox"], input[type="radio"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--akzent);
  flex: 0 0 auto;
}

.formular-zeile {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.formular-zeile label, .formular-zeile .feld { flex: 1 1 160px; }
.formular-zeile .knopf, .formular-zeile button { flex: 1 1 140px; }

.felder-2, .felder-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.feld-klein { max-width: 170px; }
.formular-zeile .feld-klein { flex: 0 1 170px; }

.checkbox,
.formular label.checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: var(--tipp);
  color: var(--text);
  font-weight: 400;
  font-size: 1rem;
  cursor: pointer;
}

.formular .knopf, .formular button { width: 100%; }
.formular .knopf-reihe { display: flex; flex-wrap: wrap; gap: 8px; }
.formular .knopf-reihe .knopf { width: auto; flex: 1 1 140px; }
.formular .aktionen { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Knöpfe: ein Primärknopf je Seite (gefüllt), alles andere dezent ---------- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tipp);
  padding: 9px 16px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.knopf:hover { background: var(--flaeche-leise); border-color: var(--text-sehr-leise); color: var(--text); text-decoration: none; }
.knopf:active { transform: translateY(1px); }
.knopf:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.knopf:disabled, .knopf[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

.knopf-haupt {
  color: var(--akzent-text);
  background: var(--akzent);
  border-color: var(--akzent);
  font-weight: 600;
}
.knopf-haupt:hover { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); color: var(--akzent-text); }
@media (prefers-color-scheme: dark) {
  .knopf-haupt:hover { background: #d17a5a; border-color: #d17a5a; }
}

.knopf-akzent {
  color: var(--akzent-dunkel);
  background: var(--akzent-hell);
  border-color: transparent;
  font-weight: 600;
}
.knopf-akzent:hover { background: var(--akzent); color: var(--akzent-text); }

.knopf-leise {
  color: var(--text-leise);
  background: transparent;
  border-color: var(--rand-stark);
}
.knopf-leise:hover { background: var(--flaeche-leise); color: var(--text); }

.knopf-warnung, .knopf-wichtig {
  color: var(--fehler);
  background: transparent;
  border-color: var(--fehler);
}
.knopf-warnung:hover, .knopf-wichtig:hover { background: var(--fehler-hell); color: var(--fehler); }

.knopf-klein {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.88rem;
}

/* ---------- Meldungen ---------- */

.meldungen { margin-bottom: 16px; }

.meldung {
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--rand);
  border-left-width: 4px;
  border-radius: var(--radius-klein);
  background: var(--flaeche);
  transition: opacity 0.4s;
}
.meldung.verblasst { opacity: 0; }

.meldung-ok { background: var(--ok-hell); border-color: var(--ok); color: var(--ok); }
.meldung-fehler { background: var(--fehler-hell); border-color: var(--fehler); color: var(--fehler); }
.meldung-hinweis { background: var(--hinweis-hell); border-color: var(--hinweis); color: var(--hinweis); }

/* ---------- Listen: Karten am Handy, ruhige Tabelle am Mac ---------- */

.liste {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.zeile {
  display: block;
  padding: 12px 14px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
a.zeile { cursor: pointer; }
a.zeile:hover, a.zeile:focus-visible {
  border-color: var(--akzent);
  color: var(--text);
  text-decoration: none;
}
.zeile > * + * { margin-top: 4px; }

.zeile-kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  font-weight: 600;
}
.zeile-neben {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-leise);
  white-space: nowrap;
}
.zeile-neben.betrag { font-weight: 600; color: var(--text); font-size: 0.95rem; }

.leer {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-sehr-leise);
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
  background: var(--flaeche-tief);
  border: 1px solid transparent;
  color: var(--text-leise);
}

.chip-neu          { background: var(--info-hell); color: var(--info); }
.chip-ortstermin   { background: var(--hinweis-hell); color: var(--hinweis); }
.chip-angebot_raus { background: var(--akzent-hell); color: var(--akzent-dunkel); }
.chip-beauftragt   { background: var(--akzent); color: var(--akzent-text); }
.chip-eingeplant   { background: var(--info); color: #fff; }
.chip-ausgefuehrt  { background: var(--ok-hell); color: var(--ok); }
.chip-abgerechnet  { background: var(--ok-hell); color: var(--ok); }
.chip-bezahlt      { background: var(--ok); color: #fff; }
.chip-abgebrochen  { background: var(--flaeche-tief); color: var(--text-sehr-leise); text-decoration: line-through; }
.chip-inaktiv      { background: var(--flaeche-tief); color: var(--text-sehr-leise); }
.chip-warn         { background: var(--fehler-hell); color: var(--fehler); }
.chip-ok           { background: var(--ok-hell); color: var(--ok); }
.chip-hinweis      { background: var(--hinweis-hell); color: var(--hinweis); }

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

.tabelle-huelle {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
}

.tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.tabelle th, .tabelle td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rand);
  vertical-align: top;
}
.tabelle th {
  background: var(--flaeche-leise);
  white-space: nowrap;
}
.tabelle tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--flaeche-leise) 55%, transparent); }
.tabelle tbody tr:last-child td { border-bottom: 0; }
.tabelle tbody tr:hover td { background: var(--flaeche-leise); }
.tabelle tfoot td { font-weight: 600; background: var(--flaeche-leise); }
.tabelle td.betrag, .tabelle td.rechts { font-variant-numeric: tabular-nums; }

.rechts { text-align: right !important; }
.klein { font-size: 0.85rem; color: var(--text-leise); }
.betrag { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hinweis-netto { font-size: 0.75rem; color: var(--text-sehr-leise); margin-left: 3px; }

/* ---------- Suche und Filter ---------- */

.suchleiste {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.suchleiste input[type="search"] { flex: 1 1 220px; min-width: 0; }
.suchleiste select, .suchleiste input[type="date"] { flex: 1 1 140px; min-width: 0; }
.suchleiste .feld-klein { max-width: none; }
.suchleiste .checkbox { flex: 0 0 auto; }
.seiten { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.suchleiste .knopf { flex: 0 0 auto; }

.filter-leiste, .reiter, .bh-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.filter-leiste a, .filter-leiste .chip, .reiter a, .bh-filter a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--rand-stark);
  background: var(--flaeche);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}
.filter-leiste a:hover, .reiter a:hover, .bh-filter a:hover { border-color: var(--akzent); color: var(--akzent-dunkel); text-decoration: none; }
.filter-leiste a.aktiv, .filter-leiste .aktiv, .reiter a.aktiv, .bh-filter a.aktiv {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--akzent-text);
}

/* ---------- Verlauf (Zeitstrich) ---------- */

.verlauf {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.verlauf-eintrag {
  position: relative;
  padding: 6px 0 6px 16px;
  border-left: 2px solid var(--rand-stark);
}
.verlauf-eintrag::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 12px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--akzent);
  border: 2px solid var(--flaeche);
}
.verlauf-eintrag .klein { display: block; margin-bottom: 2px; }
.verlauf-eintrag > :last-child { margin-bottom: 0; }

/* ---------- QR, Telefon, Karte ---------- */

.qr {
  display: flex;
  justify-content: center;
  margin: 12px auto 16px;
  padding: 12px;
  max-width: 260px;
  background: #fff;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
}
.qr svg { width: 100%; height: auto; max-width: 236px; display: block; }

.tel, .karten-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.tel:hover, .karten-link:hover { text-decoration: underline; }
.tel::before { content: "☎"; font-size: 1.05em; }
.karten-link::before { content: "⌖"; font-size: 1.2em; }

/* ---------- Aufklapper (details) ---------- */

details {
  margin: 6px 0;
  border: 1px solid var(--rand);
  border-radius: var(--radius-klein);
  background: var(--flaeche-leise);
  padding: 0 12px;
}
details[open] { padding-bottom: 10px; }
summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
  color: var(--akzent-dunkel);
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  transition: transform 0.15s;
}
details[open] > summary::before { transform: rotate(90deg); }
details > *:not(summary) { margin-top: 6px; }

/* ---------- Hilfsklassen ---------- */

.leise { color: var(--text-leise); }
.fett { font-weight: 600; }
.versteckt { display: none !important; }
.mitte { text-align: center; }
.abstand-oben { margin-top: 16px; }
.abstand-unten { margin-bottom: 16px; }
.nur-handy { display: initial; }
.nur-desktop { display: none; }
.hinweis { color: var(--text-leise); font-size: 0.92rem; }

.htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }

/* Kacheln mit Handlungsbedarf (Startseite) */
.kachel-warnung { border-color: var(--rand); }

/* Protokoll: Änderungen als Feld/Wert-Zeilen */
.protokoll-werte { display: grid; grid-template-columns: max-content 1fr; gap: 0.1rem 0.75rem; margin: 0.25rem 0 0.5rem; font-size: 0.85em; }
.protokoll-werte dt { color: var(--text-leise); }
.protokoll-werte dd { margin: 0; word-break: break-word; }

/* ---------- Ab 600 px ---------- */

@media (min-width: 600px) {
  .felder-2 { grid-template-columns: 1fr 1fr; }
  .seitenkopf {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .formular .knopf, .formular button { width: auto; align-self: flex-start; }
  .formular-zeile .knopf, .formular-zeile button { flex: 0 0 auto; }
  .kd-liste a, .kd-liste .kd-zeile {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
    grid-template-areas: "name neben wert";
  }
  .kd-neben { text-align: left; }
}

/* ---------- Ab 900 px: Mac-Layout mit Seitenleiste ---------- */

@media (min-width: 900px) {
  h1 { font-size: 1.7rem; }

  body.mit-nav .app-huelle { flex-direction: row; align-items: stretch; }
  .mobil-leiste, .nav-hintergrund { display: none; }
  .seitenleiste, .seitenleiste.offen {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--leiste-breite);
    flex: 0 0 var(--leiste-breite);
    transform: none;
    box-shadow: none;
    border-right: 1px solid var(--rand);
  }
  .nav-eintrag { min-height: 40px; padding: 8px 11px; font-size: 0.92rem; }
  .nav-eintrag .ikon { width: 17px; height: 17px; }
  .nav-gruppe-titel { padding: 12px 11px 5px; }

  body.mit-nav .inhalt { flex: 1 1 0; min-width: 0; width: auto; max-width: none; padding: 30px 32px 60px; }
  body.mit-nav .inhalt > * { max-width: 1180px; }
  .karte { padding: 20px 22px; }
  .kacheln { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .kacheln-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kachel { min-height: 124px; padding: 18px 18px 16px; }
  .kachel-detail { padding: 18px 22px 16px; }
  .raster-2 { grid-template-columns: 1fr 1fr; gap: 20px; }
  .nur-handy { display: none; }
  .nur-desktop { display: initial; }

  /* Listen als ruhige Tabelle: eine Fläche, Zeilen mit Linie und Zebra, viel Luft */
  .liste {
    gap: 0;
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    overflow: hidden;
  }
  .liste > .zeile {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 14px 20px;
    background: transparent;
  }
  .liste > .zeile + .zeile { border-top: 1px solid var(--rand); }
  .liste > .zeile:nth-child(even) { background: color-mix(in srgb, var(--flaeche-leise) 55%, transparent); }
  .liste > a.zeile:hover { background: var(--flaeche-leise); box-shadow: inset 3px 0 0 var(--akzent); }
  .liste > .leer { padding: 28px; }
  .zeile > * + * { margin-top: 3px; }
  .fuss { padding-left: calc(var(--leiste-breite) + 24px); }
  body:not(.mit-nav) .fuss { padding-left: var(--rand-seite); }
}

/* ---------- Druck ---------- */

@media print {
  .kopf, .seitenleiste, .mobil-leiste, .nav-hintergrund, .fuss, .meldungen, .suchleiste, .filter-leiste, .aktionen, .knopf { display: none !important; }
  body { background: #fff; color: #000; }
  .inhalt { max-width: none; padding: 0; }
  .karte, .zeile, .kachel, .tabelle-huelle { box-shadow: none; border-color: #999; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}


/* ---------- „⋯ Mehr“-Menü: Nebensächliches je Seite in einem aufklappbaren Menü (ein gefüllter Hauptknopf je Seite) ---------- */

.menue { position: relative; display: inline-block; border: 0; padding: 0; background: none; }
.menue summary { list-style: none; display: inline-flex; cursor: pointer; }
.menue summary::-webkit-details-marker { display: none; }
.menue summary::before { content: none; }
.menue-liste { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 240px; max-width: 92vw; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten-gross); padding: 6px; display: flex; flex-direction: column; }
.menue-liste a, .menue-liste button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; border-radius: 6px; text-decoration: none; }
.menue-liste a:hover, .menue-liste button:hover { background: var(--flaeche-leise); }
.menue-liste button.warnung, .menue-liste a.warnung { color: var(--fehler); }
.menue-liste form { margin: 0; }

/* ---------- Startseite: große Aktionsknöpfe (eine Zeile, am Handy umbrechend) ---------- */

.startaktionen { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.startaktion {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--tipp); padding: 10px 16px;
  border-radius: 12px; background: var(--flaeche); border: 1px solid var(--rand); color: var(--text);
  font-weight: 600; text-decoration: none; box-shadow: var(--schatten); flex: 1 1 150px;
}
.startaktion .ikon { width: 20px; height: 20px; color: var(--akzent); }
.startaktion:hover { border-color: var(--akzent); text-decoration: none; }
.startaktion-haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.startaktion-haupt .ikon { color: var(--akzent-text); }
.startaktion-haupt:hover { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); }

/* ---------- Verwaltung: Kachel-Raster mit Erklärung ---------- */

.verwaltung-kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 20px; }
.vk { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--schatten); min-height: 110px; }
.vk:hover { border-color: var(--akzent); text-decoration: none; }
.vk-titel { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.vk-titel .ikon { width: 18px; height: 18px; color: var(--akzent); }
.vk-text { color: var(--text-leise); font-size: 0.9rem; line-height: 1.35; }
.vk-stand { margin-top: auto; font-size: 0.82rem; color: var(--text-sehr-leise); }

/* Reiter (Einstellungen) */
.reiter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.reiter a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--rand); background: var(--flaeche); color: var(--text-leise); text-decoration: none; font-weight: 500; font-size: 0.92rem; }
.reiter a.aktiv { background: var(--akzent-hell); border-color: var(--akzent); color: var(--text); font-weight: 600; }
.reiter a:hover { border-color: var(--akzent); text-decoration: none; }

/* Mitarbeiter-Karten */
.mitarbeiter-karten { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mk { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); box-shadow: var(--schatten); color: var(--text); text-decoration: none; }
.mk:hover { border-color: var(--akzent); text-decoration: none; }
.mk-name { font-weight: 600; font-size: 1.02rem; }
.mk-zeile { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mk-klein { font-size: 0.85rem; color: var(--text-sehr-leise); }
.mk.inaktiv { opacity: 0.7; }
.mk.ohne-zugang { border-style: dashed; }

/* Einmal gezeigtes Start-Passwort */
.einmal-passwort { padding: 16px 18px; border: 2px solid var(--hinweis); border-radius: var(--radius); background: var(--hinweis-hell); margin-bottom: 16px; }
.einmal-passwort code { display: inline-block; font-size: 1.4rem; font-family: var(--schrift-mono); padding: 4px 10px; background: var(--flaeche); border-radius: 8px; letter-spacing: 0.04em; user-select: all; }

/* Zugangs-Zettel (druckbar) */
.zettel { max-width: 640px; padding: 28px 32px; background: #fff; color: #111; border: 1px solid var(--rand); border-radius: var(--radius); }
.zettel h1 { font-size: 1.5rem; margin: 0 0 4px; }
.zettel .zettel-adresse { font-size: 1.25rem; font-weight: 700; word-break: break-all; }
.zettel .zettel-raster { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; margin: 18px 0; }
.zettel .qr svg { width: 150px; height: 150px; }
.zettel ol { padding-left: 20px; }
.zettel dt { color: #555; font-size: 0.85rem; margin-top: 8px; }
.zettel dd { margin: 0; font-size: 1.1rem; font-weight: 600; }
@media print { .zettel { border: 0; max-width: none; } .zettel-aktionen { display: none !important; } }

/* Hilfe (Anleitung aus Markdown) */
.hilfe { max-width: 820px; line-height: 1.55; }
.hilfe h2 { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--rand); }
.hilfe code { font-family: var(--schrift-mono); font-size: 0.9em; background: var(--flaeche-leise); padding: 1px 5px; border-radius: 4px; }
.hilfe-inhalt { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; font-size: 0.92rem; }

/* Einrichtungs-Assistent (Meisterbüro, 11.11.2026) */
.einrichtung-schritte { flex-wrap: wrap; }
.einrichtung-logo img { max-height: 80px; max-width: 260px; margin: .3rem 0 .8rem; }
.einrichtung-links { list-style: none; padding: 0; }
.einrichtung-links li { margin-bottom: .8rem; }
.einrichtung-links input, input.einmal-link { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; }
.einrichtung-kacheln a.karte { display: block; text-decoration: none; color: inherit; }
.einrichtung-kacheln a.karte:hover { border-color: var(--akzent); }

/* Erinnerung der Wohnbau (GF 17.11.2026) */
.akte-erinnerung { border: 2px solid #c0392b; background: #fde3e0; color: #9a2a1d; }
.eingang-erinnerung { border-left: 4px solid #c0392b; background: #fdf0ee; }
