/* BEM-Check NEXT - Grunddesign. Freundlich, hell, motivierend.
   Primaer: Indigo. Energie-Akzent: Orange (Buero + Baustelle).
   Alle Farben als Tokens -> zieht durch alle fuenf Apps. */
:root {
  --bg: #eef2fb;
  --bg-grad: linear-gradient(180deg, #f4f7fd 0%, #e9eefa 100%);
  --card: #ffffff;
  --card-grad: linear-gradient(180deg, #ffffff 0%, #f7f9ff 100%);
  --card-2: #f6f8fd;
  --text: #1b2438;
  --text-muted: #667088;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --energy: #f97316;
  --energy-hover: #ea580c;
  --energy-soft: #fff2e6;
  --border: #e4e8f2;
  --danger: #e11d48;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 36, 56, 0.06);
  --shadow-md: 0 10px 28px rgba(27, 36, 56, 0.10);
  --shadow-accent: 0 8px 20px rgba(79, 70, 229, 0.28);
  /* Statusfarben: semantisch, weiche Flaechen, lebendiger */
  --st-offen-bg: #ffe4e6;   --st-offen-fg: #e11d48;
  --st-arbeit-bg: #ffedd5;  --st-arbeit-fg: #ea580c;
  --st-fertig-bg: #d1fae5;  --st-fertig-fg: #059669;
  --st-doku-bg: #dbeafe;    --st-doku-fg: #2563eb;
  --st-info-bg: #ede9fe;    --st-info-fg: #7c3aed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.center-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.brand span {
  background: linear-gradient(90deg, var(--accent) 0%, var(--energy) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* v2.191: "Auf diesem Geraet angemeldet bleiben" (Anmeldeseite). Erscheint nur,
   wenn der Admin eine Dauer > 0 eingestellt hat (login.js blendet ein). */
.bleiben {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px; /* mit Handschuh treffbar */
}
.bleiben input { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
.bleiben.versteckt { display: none; }

button.primary {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
button.primary:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 12px 26px rgba(79, 70, 229, 0.36); }
button.primary:active { transform: translateY(0); }
/* Deaktiviert heisst NICHT "laedt": cursor:wait zeigte das drehende Windows-Rad,
   sobald der Knopf nach dem Speichern gesperrt blieb - fuehlte sich an wie
   "speichert noch" (v2.148.1). not-allowed = ruhig, nichts zu klicken. */
button.primary:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; transform: none; }

button.ghost {
  padding: 8px 14px;
  background: var(--card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
button.ghost:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.error {
  display: none;
  margin-top: 16px;
  padding: 10px 12px;
  background: #fff1f3;
  border: 1px solid #fecdd3;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 14px;
}
.error.sichtbar { display: block; }

.version-badge {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* App-Shell */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border: 0;
  border-bottom: 3px solid;
  border-image: linear-gradient(90deg, var(--accent) 0%, var(--energy) 100%) 1;
  box-shadow: var(--shadow-sm);
  /* Kopf-/Info-Leiste bleibt beim Scrollen oben fest (alle Apps).
     z-index unter Modals (50) und Toasts (60), aber ueber dem Inhalt. */
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .brand { font-size: 17px; margin: 0; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar .userinfo { font-size: 14px; color: var(--text-muted); }

main.shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.app-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.app-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.app-tile h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.app-tile p { margin: 0; font-size: 13px; color: var(--text-muted); }
.app-tile.gesperrt { opacity: 0.45; pointer-events: none; }
/* Badge "Mein Bereich": ueberfaellig + heute faellig (v2.140) */
.app-tile { position: relative; }
.tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--st-offen-fg);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}
.tile-badge.versteckt { display: none; }

.status-legende { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.status-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.st-offen  { background: var(--st-offen-bg);  color: var(--st-offen-fg); }
.st-arbeit { background: var(--st-arbeit-bg); color: var(--st-arbeit-fg); }
.st-fertig { background: var(--st-fertig-bg); color: var(--st-fertig-fg); }
.st-doku   { background: var(--st-doku-bg);   color: var(--st-doku-fg); }
.st-info   { background: var(--st-info-bg);   color: var(--st-info-fg); }

/* v3.4.0 (A2/A4): Art eines Punkts - Wahl im Erfassen-Fenster (PRO + Mobile) und
   Marke in Listen/"Heute". Farben aus den Status-Tokens, damit hell/dunkel stimmt. */
.pa-wahl { display: flex; gap: 6px; margin: 2px 0 10px; }
.pa-wahl.versteckt { display: none; }
.pa-chip {
  flex: 1 1 0; min-height: 40px; padding: 6px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.pa-chip:disabled { cursor: default; opacity: 0.6; }
.pa-chip.gewaehlt { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pa-chip.pa-frage.gewaehlt { border-color: var(--st-arbeit-fg); background: var(--st-arbeit-bg); color: var(--st-arbeit-fg); box-shadow: 0 0 0 1px var(--st-arbeit-fg) inset; }
.pa-chip.pa-info.gewaehlt { border-color: var(--st-info-fg); background: var(--st-info-bg); color: var(--st-info-fg); box-shadow: 0 0 0 1px var(--st-info-fg) inset; }
.pa-marke { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pa-marke.pa-frage { background: var(--st-arbeit-bg); color: var(--st-arbeit-fg); }
.pa-marke.pa-frage.pa-erledigt { background: var(--st-fertig-bg); color: var(--st-fertig-fg); }
/* v4.58.0: beantwortet, noch nicht geklaert - kraeftig, damit der Fragesteller es sieht */
.pa-marke.pa-frage.pa-antwort { background: #f59e0b; color: #1b2438; }
.pa-marke.pa-frage.pa-antwort-meine { box-shadow: 0 0 0 2px #b45309 inset; }
.pa-marke.pa-alle { background: var(--st-offen-bg, #fde8ec); color: var(--st-offen-fg, #c0123c); }   /* v4.31.0 */
.pa-marke.pa-info { background: var(--st-info-bg); color: var(--st-info-fg); }
/* v4.64.0: an mich gerichtet - deutlich (kraeftiges Rot, weisse Schrift) */
.pa-marke.pa-anmich { background: #dc2626; color: #fff; }
.pa-anmich-hinweis { background: #fee2e2; color: #7f1d1d; border: 2px solid #dc2626; border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; font-weight: 700; font-size: 14px; }
.pa-anmich-hinweis.versteckt { display: none; }
html.dunkel .pa-anmich-hinweis { background: #3a1418; color: #fecaca; }
.pa-marke.pa-info.pa-neu { background: var(--st-info-fg); color: var(--card); }
.pa-gelesen {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 8px 0; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--st-info-bg); color: var(--st-info-fg); font-size: 14px;
}
.pa-gelesen.versteckt { display: none; }
.pa-gelesen-text { flex: 1 1 200px; }

/* ---------------------------------------------------------------------------
   Menues (v2.165): JEDES aufklappbare Menue der Apps sieht gleich aus und
   klappt immer direkt am Ausloeser auf. Deutlicher Rahmen + Titelzeile +
   abgedunkelter Hintergrund -> sofort sichtbar, auch oben links im Fenster.
   Gilt fuer BemMenu (Rechtsklick/Stift) und das Kopf-Menue (bk-menue).
--------------------------------------------------------------------------- */
.bem-menu-scrim { position: fixed; inset: 0; z-index: 1290; background: rgba(15, 23, 42, 0.32); }
.bem-menu {
  position: fixed; z-index: 1300; min-width: 220px;
  max-width: min(340px, calc(100vw - 24px)); padding: 0; overflow: hidden;
  background: var(--card, #fff);
  border: 2px solid var(--accent, #4f46e5); border-radius: 14px;
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.34);
  animation: bem-menu-auf 0.12s ease-out;
}
@keyframes bem-menu-auf { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
/* Titelzeile: sagt, WOZU das Menue gehoert (z. B. "Anlage – EG") */
.bem-menu-titel, .bk-menue-titel {
  background: var(--accent, #4f46e5); color: #fff;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 9px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bem-menu-liste { padding: 6px; max-height: min(70vh, 560px); overflow-y: auto; }
.bem-menu .bem-menu-item {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text, #0f172a); cursor: pointer;
}
.bem-menu .bem-menu-item:hover, .bem-menu .bem-menu-item:focus-visible {
  background: var(--accent-soft, #eef0ff); color: var(--accent, #4f46e5); outline: 0;
}
.bem-menu .bem-menu-item:disabled { opacity: 0.45; cursor: default; }
.bem-menu .bem-menu-header {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted, #64748b); padding: 8px 10px 4px; font-weight: 700;
}
.bem-menu .bem-menu-sep { border: 0; border-top: 1px solid var(--border, #e2e8f0); margin: 6px 4px; }
.bem-menu .bem-menu-info {
  font-size: 11.5px; color: var(--text-muted, #64748b); padding: 4px 10px; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bem-menu .bem-menu-liste > :not(.bem-menu-info) + .bem-menu-info { border-top: 1px solid var(--border, #e2e8f0); margin-top: 6px; padding-top: 8px; }
.bem-menu .bem-menu-item.gefahr { color: var(--danger, #dc2626); }
.bem-menu .bem-menu-item.gefahr:hover, .bem-menu .bem-menu-item.gefahr:focus-visible {
  background: #fff1f3; color: var(--danger, #dc2626);
}
html.dunkel .bem-menu .bem-menu-item.gefahr:hover,
html.dunkel .bem-menu .bem-menu-item.gefahr:focus-visible { background: #3b1a22; }

/* ---------------------------------------------------------------------------
   Dialoge (BemDialog, v2.166): ersetzen prompt/confirm/alert. Gleiche Optik
   wie die Menues, in jeder App identisch, am Handy gross genug.
--------------------------------------------------------------------------- */
.bd-bg {
  position: fixed; inset: 0; z-index: 8000;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.bd-karte {
  width: min(420px, calc(100vw - 32px));
  background: var(--card, #fff); color: var(--text, #0f172a);
  border: 2px solid var(--accent, #4f46e5); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.38);
  animation: bem-menu-auf 0.12s ease-out;
}
.bd-titel {
  background: var(--accent, #4f46e5); color: #fff;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 9px 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bd-koerper { padding: 16px 16px 4px; }
.bd-text { font-size: 14.5px; line-height: 1.5; white-space: pre-line; }   /* v4.15.0: \n = neue Zeile */
.bd-feldhuelle { margin-top: 12px; }
.bd-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-muted, #64748b); }
.bd-feld {
  display: block; width: 100%; margin-top: 6px; box-sizing: border-box;
  font: inherit; font-size: 16px;              /* 16px = iOS zoomt beim Tippen nicht */
  padding: 11px 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  background: var(--card, #fff); color: var(--text, #0f172a);
}
.bd-feld:focus { outline: 2px solid var(--accent, #4f46e5); outline-offset: 1px; }
.bd-leiste { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 16px 16px; }
.bd-btn {
  min-height: 44px; padding: 0 18px; border-radius: 10px; font: inherit;
  font-size: 15px; font-weight: 700; cursor: pointer; border: 1px solid transparent;
}
.bd-btn-ghost { background: var(--card-2, #f1f5f9); color: var(--text-muted, #64748b); border-color: var(--border, #e2e8f0); }
.bd-btn-ok { background: var(--accent, #4f46e5); color: #fff; }
.bd-btn-ok:hover { background: var(--accent-hover, #4338ca); }
.bd-btn-gefahr { background: var(--danger, #e11d48); }
.bd-btn-gefahr:hover { background: #be123c; }
/* v2.214/v2.215: BemDialog.abtippen - Fehlerzeile, und der Knopf bleibt gesperrt,
   solange der abgetippte Text nicht passt (und waehrend die Aktion laeuft). */
.bd-fehler { display: none; margin-top: 10px; font-size: 13.5px; font-weight: 700; color: var(--danger, #e11d48); }
.bd-fehler.an { display: block; }
.bd-btn:disabled { opacity: 0.6; cursor: default; }
.bd-btn-ok:disabled:hover { background: var(--accent, #4f46e5); }
.bd-btn-gefahr:disabled:hover { background: var(--danger, #e11d48); }
.bd-feld:disabled { opacity: 0.6; }

/* v2.208: BemDialog.wahl - mehrere Wege als grosse Knoepfe untereinander */
.bd-wahl { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
/* v2.209: viele Wege (z. B. ein Archiv in vielen Teilen) - die Liste rollt, "Fertig" bleibt sichtbar */
.bd-wahl { max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
.bd-wahl-knopf {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  min-height: 48px; padding: 10px 14px; box-sizing: border-box; text-align: left; cursor: pointer;
  border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  background: var(--card-2, #f1f5f9); color: var(--text, #0f172a); font: inherit;
}
.bd-wahl-knopf:hover, .bd-wahl-knopf:focus-visible {
  border-color: var(--accent, #4f46e5); background: var(--card, #fff); outline: none;
}
.bd-wahl-label { font-size: 15px; font-weight: 700; }
.bd-wahl-info { font-size: 12.5px; color: var(--text-muted, #64748b); }
.bd-wahl-leise { background: transparent; }
.bd-wahl-leise .bd-wahl-label { font-weight: 600; color: var(--text-muted, #64748b); }

/* ---------------------------------------------------------------------------
   Warteanzeige (BemWarte, v2.165): animierte Sanduhr bei Datei-Uploads,
   Downloads und laengeren Bild-/PDF-Vorgaengen. In jeder App identisch.
--------------------------------------------------------------------------- */
.bw-aus { display: none !important; }
.bw-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, 0.42);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  animation: bw-ein 0.15s ease-out;
}
@keyframes bw-ein { from { opacity: 0; } to { opacity: 1; } }
.bw-karte {
  min-width: 220px; max-width: min(360px, calc(100vw - 40px));
  background: var(--card, #fff); color: var(--text, #0f172a);
  border: 1px solid var(--border, #e2e8f0); border-radius: 18px;
  padding: 22px 26px 18px; text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}
.bw-sanduhr {
  font-size: 40px; line-height: 1; margin-bottom: 10px;
  animation: bw-dreh 2.4s cubic-bezier(0.55, 0, 0.35, 1) infinite;
}
/* Sanduhr kippt nach jedem Durchlauf um - laeuft rund, ohne Ruecksprung */
@keyframes bw-dreh {
  0%, 42%  { transform: rotate(0deg); }
  50%, 92% { transform: rotate(180deg); }
  100%     { transform: rotate(360deg); }
}
.bw-text { font-size: 15px; font-weight: 700; line-height: 1.4; }
.bw-balken {
  position: relative; height: 4px; margin-top: 14px; border-radius: 999px;
  background: var(--accent-soft, #eef0ff); overflow: hidden;
}
.bw-balken span {
  position: absolute; top: 0; bottom: 0; width: 40%; border-radius: 999px;
  background: var(--accent, #4f46e5); animation: bw-lauf 1.25s ease-in-out infinite;
}
@keyframes bw-lauf { from { left: -42%; } to { left: 100%; } }
.bw-lange { margin-top: 12px; font-size: 12.5px; color: var(--text-muted, #64748b); line-height: 1.5; }
/* Knopf, der gerade eine Datei-Aktion ausfuehrt */
.bw-knopf-laedt { opacity: 0.75; cursor: progress; }
.bw-knopf-uhr { display: inline-block; animation: bw-dreh 2.4s cubic-bezier(0.55, 0, 0.35, 1) infinite; }
/* Sanduhr-Platzhalter, solange ein Bild laedt */
.bw-bild-laedt { position: relative; }
.bw-bild-laedt::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--card-2, #f1f5f9); pointer-events: none;
}
.bw-bild-laedt::after {
  content: "⏳"; position: absolute; left: 50%; top: 50%; margin: -14px 0 0 -12px;
  font-size: 24px; line-height: 1; pointer-events: none;
  animation: bw-dreh 2.4s cubic-bezier(0.55, 0, 0.35, 1) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .bw-sanduhr, .bw-knopf-uhr, .bw-bild-laedt::after { animation-duration: 6s; }
  .bw-balken span { animation: none; left: 0; width: 100%; opacity: 0.55; }
  .bem-menu { animation: none; }
}

/* Geraete-Schranke: Desktop-Apps auf Smartphones sperren (Hinweis statt zerrissener UI) */
.geraet-block { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; text-align: center; box-sizing: border-box; }
.geraet-box { max-width: 340px; }
.geraet-ic { font-size: 46px; margin-bottom: 10px; }
.geraet-box h1 { font-size: 20px; margin: 0 0 10px; }
.geraet-box p { font-size: 15px; color: #5f5e5a; line-height: 1.55; margin: 0 0 20px; }
.geraet-btn { display: inline-block; padding: 13px 24px; border-radius: 10px; background: #d9480f; color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; }


/* v2.108: Dunkel-Token (aktiv, wenn html die Klasse "dunkel" traegt — bisher nur Mobile) */
html.dunkel {
  --bg: #10141f;
  --bg-grad: linear-gradient(180deg, #141a29 0%, #0e1220 100%);
  --card: #1a2130;
  --card-grad: linear-gradient(180deg, #1c2434 0%, #171e2c 100%);
  --card-2: #222b3d;
  --text: #e6eaf3;
  --text-muted: #96a1b8;
  --accent: #818cf8;
  --accent-2: #6366f1;
  --accent-hover: #a5b4fc;
  --accent-soft: #262b45;
  --energy: #fb923c;
  --energy-hover: #fdba74;
  --energy-soft: #3a2a1a;
  --border: #2c3548;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
  --shadow-accent: 0 8px 20px rgba(99, 102, 241, 0.35);
  --st-offen-bg: #3b1a22;  --st-offen-fg: #fda4af;
  --st-arbeit-bg: #3a2513; --st-arbeit-fg: #fdba74;
  --st-fertig-bg: #132e24; --st-fertig-fg: #6ee7b7;
  --st-doku-bg: #16283f;   --st-doku-fg: #93c5fd;
  --st-info-bg: #251c3a;   --st-info-fg: #c4b5fd;
}

/* v2.108: Dunkelmodus-Umschalter in der Topbar (theme.js) */
.theme-knopf {
  margin-left: 10px; width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  font-size: 16px; line-height: 1;
}
html.dunkel input, html.dunkel select, html.dunkel textarea {
  background: var(--card-2); color: var(--text); border-color: var(--border);
}
html.dunkel button.ghost { background: var(--card); color: var(--text-muted); }
html.dunkel .table-wrap table, html.dunkel table { color: var(--text); }
html.dunkel img { filter: brightness(0.94); }
html.dunkel .brand { color: #e6eaf3; }
html.dunkel .app-tag { background: var(--accent-soft); color: var(--accent); }

/* v2.127: Instanz-Branding (Logo/Name in der Wortmarke) */
.brand-logo { height: 26px; width: auto; max-width: 170px; vertical-align: middle; margin-right: 8px; border-radius: 4px; object-fit: contain; }
.brand .brand-name { vertical-align: middle; }

/* v2.135: grosses, nebeliges Hintergrund-Logo auf der App-Uebersicht (/app).
   Zeigt nur, wenn ein Logo gesetzt ist (sonst 404 -> kein Bild). Liegt hinter dem Inhalt. */
.brand-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("/api/brand/logo");
  background-repeat: no-repeat;
  background-position: center 44%;
  background-size: min(92vmin, 900px);
  opacity: 0.26;
  filter: blur(0.5px);
}

/* v2.139.1: Kopfleiste aufgeraeumt (alle Apps) - eine ruhige Zeile, nichts bricht
   um oder ragt aus dem Bild. Wortmarke: Logo + Name einzeilig mit Ellipsis;
   eigene Kundennamen EINFARBIG (der Farbverlauf bleibt der Standard-Wortmarke
   "BEM-Check" vorbehalten - wortweise zerrissener Verlauf wirkte unruhig).
   Benutzer rechts zweizeilig (Name fett, Rolle klein), Abmelden immer sichtbar. */
.topbar {
  gap: 12px;
  padding: 14px clamp(12px, 3vw, 24px);
  padding-top: max(14px, env(safe-area-inset-top)); /* iPhone-Kerbe (installierte App) */
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden; /* v2.145: nichts ragt mehr unter Nachbarn (iOS-Logo-Falle) */
}
.topbar .brand .brand-name { overflow: hidden; text-overflow: ellipsis; }
/* v2.144.1: Logo darf mitschrumpfen (object-fit: contain haelt es sauber) -
   vorher lief ein breites Kunden-Logo unter den App-Tag ("Mein Bereich"). */
.topbar .brand-logo { flex: 0 1 auto; min-width: 24px; margin-right: 0; }
.brand span.brand-name {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: inherit;
}
.topbar .right { flex: 0 1 auto; min-width: 0; gap: 10px; }
.topbar .right button { flex: none; white-space: nowrap; }
.topbar .userinfo { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .userinfo.gestapelt { text-align: right; }
.userinfo-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.userinfo-rolle {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* v2.145: Kopfleiste am Handy DEUTLICH kompakter (alle Apps) - kleinere
   Schrift, kleineres Logo, nichts ueberlappt (Wunsch Andrej, iPhone-Screenshots). */
@media (max-width: 520px) {
  .topbar { gap: 8px; }
  .topbar .brand { font-size: 15px; gap: 6px; }
  .topbar .brand-logo { height: 22px; max-width: 92px; }
  .app-tag { font-size: 10.5px; padding: 2px 8px; letter-spacing: 0.2px; }
  .topbar .userinfo { max-width: 26vw; }
  .userinfo-name { font-size: 12px; }
  .userinfo-rolle { font-size: 10px; }
  .topbar .right { gap: 6px; }
  .topbar button.ghost { font-size: 12px; padding: 6px 10px; }
  .theme-knopf { width: 30px; height: 30px; font-size: 13px; margin-left: 4px; flex: none; }
}

/* v2.154: Die alten /app-Kopf-Sonderregeln (v2.139.2) entfallen - die
   App-Uebersicht nutzt jetzt dieselbe einheitliche Fixmaske (.bk-*, unten)
   wie alle anderen Apps. */
/* Branding-Hintergrundbild: GANZES Bild sichtbar (contain, nichts abgeschnitten),
   damit z. B. ein Spruch am unteren Bildrand sichtbar bleibt. Kein Zuschnitt wie
   bei cover. Dezent hinter den Kacheln. */
.app-page .brand-bg {
  background-size: contain;
  background-position: center;
  opacity: 0.18;
  filter: blur(0.5px);
}

/* ============================================================================
   v2.154: EINHEITLICHE OBERE FIXMASKE (alle Apps, auch Smartphone)
   Links: Logo (bzw. Wortmarke) oben, darunter klein der Name der Unter-App
   (auf /app der Branding-Anzeigename). Rechts: NUR das Menue (wie Mobile):
   Startseite, Zu den Apps, Mein Bereich, Anzeige, Mein Konto, Abmelden, Info.
   Die alten Kopf-Knoepfe (.right) bleiben im DOM (JS-Verdrahtung), unsichtbar.
   ========================================================================== */
.topbar[data-bem-kopf] { gap: 10px; }
.topbar[data-bem-kopf] .right { display: none !important; }
.topbar[data-bem-kopf] .theme-knopf { display: none !important; }

/* Marke links: zwei Zeilen, kompakt */
.bk-marke {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  flex: 0 1 auto; min-width: 0; max-width: 46vw;
  text-decoration: none; color: inherit; line-height: 1.15;
}
.bk-marke .brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 17px; margin: 0; min-width: 0; max-width: 100%;
  white-space: nowrap; overflow: hidden;
}
.bk-marke .brand .brand-name { overflow: hidden; text-overflow: ellipsis; }
.bk-marke .brand-logo { height: 26px; max-width: 170px; margin: 0; flex: 0 1 auto; min-width: 24px; }
.bk-appname {
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.04em; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%;
}
/* Mit Logo: Name aus Zeile 1 raus (Logo oben, App-Name darunter) */
.topbar[data-bem-kopf] .brand:has(.brand-logo) .brand-name { display: none; }
/* /app: Zeile 2 zeigt den Branding-Anzeigenamen - nur mit Logo noetig,
   ohne Logo steht der Name bereits als Wortmarke in Zeile 1 */
.bk-appname[data-brandname] { display: none; }
.bk-marke:has(.brand-logo) .bk-appname[data-brandname] { display: block; }

/* Mitte: app-eigene Elemente (Krümelpfad, Baum-Knopf, Zurück) behalten Platz */
.bk-mitte { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }

/* Rechts: EIN Menue-Knopf */
.bk-menuewrap { position: relative; flex-shrink: 0; margin-left: auto; }
.bk-menue-knopf {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 17px;
  font-weight: 700; line-height: 1.2; cursor: pointer;
}
.bk-menue-knopf:active { background: var(--bg); }

/* Aufklapp-Menue - gleiche Optik wie BemMenu (v2.165): Rahmen, Titel, Schatten.
   Position: immer direkt unter dem ☰-Knopf, der es geoeffnet hat. */
.bk-menue {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1300;
  min-width: 230px; max-width: min(320px, calc(100vw - 20px));
  background: var(--card); border: 2px solid var(--accent); border-radius: 14px;
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.34); overflow: hidden;
  animation: bem-menu-auf 0.12s ease-out;
  /* v2.210: mit dem Projekt-Block darin wird das Menue laenger - es rollt,
     statt unten aus dem Fenster zu laufen. */
  max-height: calc(100vh - 74px); overflow-y: auto; overscroll-behavior: contain;
}
.bk-menue.bk-zu { display: none; }
/* Abdunkler fuer das Kopf-Menue: liegt unter der Topbar (z-index 40), damit
   Knopf + Menue hell bleiben und der Rest der Seite zuruecktritt. */
.bk-menue-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(15, 23, 42, 0.32); }
.bk-menue-scrim.bk-zu { display: none; }
.bk-menue-knopf[aria-expanded="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.bk-menue-item {
  display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
  text-align: left; padding: 10px 14px; background: none; border: 0;
  border-top: 1px solid var(--border); font: inherit; font-size: 13.5px;
  font-weight: 600; color: var(--text); cursor: pointer; text-decoration: none;
}
.bk-menue-item:first-child { border-top: 0; }
/* v2.210: EIN Menue - der Block der App (in PRO die Projekt-/KDI-Werkzeuge) steht
   ganz oben, darunter die Wege der App selbst. bk-aus = nicht vorhanden. */
.bk-aus { display: none !important; }
.bk-menue-header {
  padding: 7px 14px 6px; border-top: 1px solid var(--border); background: var(--bg);
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bk-menue-titel + .bk-menue-header { border-top: 0; }
.bk-kontext { display: flex; flex-direction: column; }
.bk-menue-zahl {
  display: inline-block; margin-left: 6px; min-width: 18px; text-align: center;
  background: #d9480f; color: #fff; border-radius: 999px; padding: 0 5px;
  font-size: 0.72rem; font-weight: 700; vertical-align: 2px;
}
.bk-menue-icon { font-size: 16px; flex-shrink: 0; }
.bk-menue-item:active, .bk-menue-item:hover { background: var(--bg); }
.bk-menue-danger { color: #c0392b; }
.bk-menue-info {
  padding: 9px 14px; border-top: 1px solid var(--border); background: var(--bg);
  font-size: 11.5px; color: var(--text-muted); line-height: 1.6;
}
.bk-menue-info div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mein-Konto-Dialog (gemeinsam fuer alle Apps ohne eigenen Dialog) */
.bk-dialog-bg {
  position: fixed; inset: 0; z-index: 1400; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.bk-dialog-bg.bk-zu { display: none; }
.bk-dialog {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 380px; padding: 20px 20px 16px;
  max-height: calc(100dvh - 32px); overflow: auto;
}
.bk-dialog h3 { margin: 0 0 12px; }
.bk-dialog label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; }
.bk-dialog input {
  width: 100%; box-sizing: border-box; padding: 9px 10px; font: inherit;
  font-size: 16px; /* iOS-Zoom-Falle: nie kleiner als 16px */
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-input, #fff); color: var(--text);
}
.bk-dialog-zeile { display: flex; gap: 8px; align-items: center; }
.bk-dialog-zeile input { flex: 1 1 auto; min-width: 0; }
.bk-dialog-zeile button { flex-shrink: 0; }
.bk-dialog-trenner { border: 0; border-top: 1px solid var(--border); margin: 14px 0 4px; }
.bk-dialog-aktionen { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
html.dunkel .bk-dialog input { background: var(--card-2); color: var(--text); border-color: var(--border); }

/* Smartphone: alles kompakt, nichts ueberlappt */
@media (max-width: 520px) {
  .topbar[data-bem-kopf] { gap: 8px; }
  .bk-marke { max-width: 52vw; }
  .bk-marke .brand { font-size: 15px; gap: 6px; }
  .bk-marke .brand-logo { height: 22px; max-width: 120px; }
  .bk-appname { font-size: 10.5px; }
  .bk-menue-knopf { padding: 4px 10px; }
}

/* v2.155: Einstellbarer Seiten-Hintergrund (Branding, Config -> Branding).
   Gilt fuer ALLE Apps, aber NUR im Hellmodus - der Dunkelmodus behaelt sein
   eigenes dunkles Design. brand.js setzt die Klasse hg-eigen + --hg-grad. */
html.hg-eigen:not(.dunkel) body { background: var(--hg-grad); background-attachment: fixed; }

/* v3.5.0 (A1): Antworten im Ticket (antworten.js) - Mobile und PRO */
.aw-block { margin: 10px 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card-2); }
.aw-kopf { padding: 8px 10px; font-weight: 700; font-size: 14px; border-bottom: 1px solid var(--border); }
.aw-liste { max-height: 320px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.aw-leer { margin: 2px 0; color: var(--text-muted); font-size: 14px; }
.aw-eintrag { align-self: flex-start; max-width: 92%; background: var(--card); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 6px 10px; }
.aw-eintrag.aw-ich { align-self: flex-end; background: var(--accent-soft); border-color: transparent; border-radius: 12px 12px 4px 12px; }
.aw-wer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.aw-name { font-weight: 700; color: var(--text); }
.aw-zeit { font-size: 12px; color: var(--text-muted); }
.aw-loeschen { margin-left: auto; border: 0; background: none; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.aw-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; margin-top: 2px; }
.aw-foto { display: block; max-width: 220px; max-height: 220px; border-radius: 8px; margin-top: 4px; cursor: zoom-in; }
.aw-foto-klein { max-width: 120px; max-height: 120px; }
.aw-ton-zeile { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.aw-ton { height: 36px; max-width: 240px; }
.aw-eingabe { border-top: 1px solid var(--border); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.aw-feld { width: 100%; resize: vertical; font: inherit; font-size: 16px; }
.aw-knoepfe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.aw-platz { flex: 1 1 auto; }
.aw-vorschau { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aw-vorschau.versteckt { display: none; }
.aw-aufnahme { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aw-rot { color: var(--danger); animation: aw-blink 1s infinite; }
@keyframes aw-blink { 50% { opacity: 0.2; } }
.aw-haken { font-size: 14px; }
.aw-haken.versteckt { display: none; }
.aw-fehler { display: none; color: var(--danger); font-size: 13px; }
.aw-fehler.sichtbar { display: block; }

/* v4.67.0: Dateien (PDF, Word, Excel, Text ...) am Ticket und im Verlauf - punktdateien.js */
.pd-block { margin: 2px 0 10px; }
.pd-kopf { display: flex; align-items: baseline; gap: 6px; }
.pd-titel { margin: 0; }
.pd-liste { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 6px; }
.pd-leer { color: var(--text-muted); font-size: 13px; }
.pd-karte { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); min-width: 0; max-width: 100%; box-sizing: border-box; }
.pd-karte.pd-tippbar { cursor: pointer; }
.pd-karte.pd-tippbar:hover { border-color: var(--accent); }
.pd-karte.pd-lokal { border-style: dashed; }
.pd-ic { font-size: 22px; line-height: 1; flex: 0 0 auto; }
.pd-mitte { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.pd-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-info { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-akt { display: flex; gap: 4px; flex: 0 0 auto; }
.pd-knopf { min-height: 32px; padding: 4px 8px; }
.pd-hinzu.versteckt { display: none; }
.pd-fehler { color: var(--danger); font-size: 13px; }
.pd-fehler:empty { display: none; }
.pd-kopf .label-neben { font-size: 12px; color: var(--text-muted); }
.aw-datei { margin-top: 4px; width: 340px; }
.aw-vorschau .pd-karte { width: 340px; }
@media (max-width: 520px) { .aw-datei, .aw-vorschau .pd-karte { width: 100%; } }

/* v3.5.0 (A3): "Ähnlich gibt es schon" beim Anlegen */
.aw-aehnlich { margin: 6px 0 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--st-arbeit-bg); color: var(--text); }
.aw-aehnlich.versteckt { display: none; }
.aw-aehnlich-kopf { font-weight: 700; font-size: 13px; color: var(--st-arbeit-fg); margin-bottom: 4px; }
.aw-aehnlich-zeile { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: var(--card); color: var(--text); border-radius: 8px; padding: 6px 8px; margin-top: 4px; cursor: pointer; font: inherit; font-size: 14px; }
.aw-aehnlich-text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }

/* v4.4.0: Passwort vergessen / neues Passwort */
.pw-info { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; line-height: 1.45; }
.pw-unten { margin: 16px 0 0; text-align: center; font-size: 14px; }
.pw-unten a, .pw-link { color: var(--accent); text-decoration: underline; cursor: pointer; background: none; border: 0; padding: 8px 4px; font: inherit; font-size: 14px; }
.pw-ok { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: #ecfdf5; color: #065f46; font-size: 14px; line-height: 1.4; }
#vergessen-form.versteckt, #pw-form.versteckt, .pw-ok.versteckt { display: none; }

/* v4.5.0: Fotos speichern / als PDF - gemeinsam fuer PRO, Mobile, Mein Bereich (mein-druck.js) */
.md-druckrahmen { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; }
@media print { .md-druckrahmen { display: none; } }
.foto-pdf-knopf { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; }
.foto-pdf-knopf.versteckt { display: none; }
.m-bf-detail-speichern { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.m-bf-detail-speichern button { min-height: 40px; }

/* v4.38.0: gemeinsame Filterleiste fuer Projekt-/KDI-Listen (assets/listenfilter.js) */
.lf-leiste { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.lf-leiste .versteckt, .lf-leiste.versteckt, #pro-filter.versteckt { display: none; }
.lf-suche { flex: 1 1 220px; min-width: 160px; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: 15px; }
.lf-select { flex: 0 1 auto; max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); font: inherit; font-size: 14px; }
.lf-zaehler { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.pz-ruhend, .m-ruhend { display: inline-block; font-size: 12px; padding: 2px 7px; border-radius: 10px; background: #fff3bf; color: #7a5b00; white-space: nowrap; }
@media (max-width: 600px) { .lf-select { flex: 1 1 45%; } .lf-suche { flex-basis: 100%; font-size: 16px; } }

/* v4.68.0: Startseite - "Ohne Anmeldung testen" (fuehrt auf demo.mychecks.work) */
.demo-einladung {
  width: 100%;
  max-width: 400px;
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1px solid #fed7aa;
  text-align: center;
}
.demo-einladung p { margin: 0 0 12px; font-size: 14px; color: #7c2d12; }
.demo-einladung p b { display: block; font-size: 16px; margin-bottom: 2px; }
a.demo-knopf {
  display: block;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(234, 88, 12, 0.3);
}
a.demo-knopf:hover { filter: brightness(1.05); }
