/* ============================================
   Haushahn - Zentrales Stylesheet
   Mobile-First, Responsive Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #2c6fad;
  --color-primary-dark: #1e4f7a;
  --color-primary-light: #e8f1fa;
  --color-accent: #f59e0b;
  --color-accent-dark: #d97706;
  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-danger: #ef4444;
  --color-danger-light: #fee2e2;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-text: #1e293b;
  --color-text-light: #64748b;
  --color-text-muted: #94a3b8;
  --color-bg: #f1f5f9;
  --color-white: #ffffff;
  --color-border: #e2e8f0;
  --color-border-dark: #cbd5e1;
  --sidebar-width: 260px;
  --header-height: 56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --color-text: #f1f5f9;
  --color-text-light: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-bg: #0f172a;
  --color-white: #1e293b;
  --color-border: #334155;
  --color-border-dark: #475569;
  --color-primary-light: rgba(96, 165, 250, 0.15);
  --color-success-light: rgba(34, 197, 94, 0.15);
  --color-danger-light: rgba(239, 68, 68, 0.15);
  --color-warning-light: rgba(245, 158, 11, 0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}
[data-theme="dark"] body {
  background: var(--color-bg);
}
[data-theme="dark"] .topbar {
  background: var(--color-white);
  border-bottom-color: var(--color-border);
}
[data-theme="dark"] .card,
[data-theme="dark"] .card-stat {
  background: var(--color-white);
  border-color: var(--color-border);
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #0f172a;
  border-color: #334155;
  color: var(--color-text);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #64748b;
}
[data-theme="dark"] .form-group label {
  color: var(--color-text-light);
}
[data-theme="dark"] table th {
  background: #0f172a;
  color: var(--color-text-light);
}
[data-theme="dark"] table td {
  border-color: var(--color-border);
  color: var(--color-text);
}
[data-theme="dark"] .badge-pill.success { background: rgba(34,197,94,0.2); color: #4ade80; }
[data-theme="dark"] .badge-pill.danger { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .badge-pill.warning { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .badge-pill.info { background: rgba(96,165,250,0.2); color: #93c5fd; }
[data-theme="dark"] .badge-pill.neutral { background: #334155; color: #cbd5e1; }
[data-theme="dark"] .chip { background: #0f172a; color: var(--color-text-light); border-color: var(--color-border); }
[data-theme="dark"] .feature-tip {
  background: linear-gradient(135deg, rgba(96,165,250,0.08) 0%, rgba(96,165,250,0.04) 100%);
  border-color: rgba(96,165,250,0.2);
}
[data-theme="dark"] .toast {
  background: var(--color-white);
  color: var(--color-text);
}
[data-theme="dark"] .stat-icon.amber { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .stat-icon.blue { background: rgba(96,165,250,0.2); color: #93c5fd; }
[data-theme="dark"] .stat-icon.red { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .stat-icon.green { background: rgba(34,197,94,0.2); color: #4ade80; }
[data-theme="dark"] .stat-icon.purple { background: rgba(124,58,237,0.2); color: #c4b5fd; }

/* Dark Mode: Modals */
[data-theme="dark"] .task-modal,
[data-theme="dark"] #projektModalOverlay > div,
[data-theme="dark"] #hwModalOverlay > div {
  background: var(--color-white) !important;
  color: var(--color-text);
}
[data-theme="dark"] .task-modal-header,
[data-theme="dark"] .task-modal-footer {
  background: var(--color-white) !important;
  border-color: var(--color-border) !important;
}
[data-theme="dark"] .task-modal-header h2,
[data-theme="dark"] .task-modal h2,
[data-theme="dark"] .task-modal h3,
[data-theme="dark"] #projektModalOverlay h2,
[data-theme="dark"] #projektModalOverlay h3,
[data-theme="dark"] #hwModalOverlay h2,
[data-theme="dark"] #hwModalOverlay h3 {
  color: var(--color-text) !important;
}
[data-theme="dark"] .task-modal label,
[data-theme="dark"] .task-modal-body label {
  color: var(--color-text-light) !important;
}
[data-theme="dark"] .task-modal .form-control,
[data-theme="dark"] .task-modal-body .form-control,
[data-theme="dark"] .task-modal input,
[data-theme="dark"] .task-modal select,
[data-theme="dark"] .task-modal textarea {
  background: #0f172a !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
}
[data-theme="dark"] .task-modal-meta,
[data-theme="dark"] .task-modal small {
  color: var(--color-text-muted) !important;
}
[data-theme="dark"] .checklist-item,
[data-theme="dark"] .checklist-section {
  background: var(--color-white);
  color: var(--color-text);
}
[data-theme="dark"] .te-comment,
[data-theme="dark"] .comment-item,
[data-theme="dark"] .comment {
  background: #0f172a !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}
/* Sprechblasen-Inhalt: Author / Datum / Text in Dark Mode lesbar machen */
[data-theme="dark"] .te-comment-author,
[data-theme="dark"] .te-comment-text,
[data-theme="dark"] .comment-text,
[data-theme="dark"] .comment-header strong,
[data-theme="dark"] .comment-item strong,
[data-theme="dark"] .comment-item p {
  color: var(--color-text) !important;
}
[data-theme="dark"] .te-comment-date,
[data-theme="dark"] .comment-time {
  color: var(--color-text-light) !important;
}
/* "Eigene" Kommentare: leicht akzentuierter Hintergrund */
[data-theme="dark"] .comment.comment-own {
  background: #1e1b4b !important;
}
[data-theme="dark"] .checkbox-label {
  color: var(--color-text);
}

/* Dark Mode: Buttons */
[data-theme="dark"] .btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-light);
}
[data-theme="dark"] .btn-outline:hover {
  background: #0f172a;
  color: var(--color-text);
}
[data-theme="dark"] button:disabled,
[data-theme="dark"] .btn:disabled {
  background: #334155 !important;
  color: #64748b !important;
  border-color: #334155 !important;
  cursor: not-allowed;
}

/* Dark Mode: Sidebar bleibt dunkel auch im Light Mode - macht im Dark Mode nichts */

/* Dark Mode: Page header */
[data-theme="dark"] .page-header {
  border-bottom-color: var(--color-border);
}
[data-theme="dark"] .page-header h1 {
  color: var(--color-text);
}

/* Dark Mode: Card hover */
[data-theme="dark"] .card-stat:hover {
  background: #243049;
}

/* Dark Mode: Tables */
[data-theme="dark"] table {
  color: var(--color-text);
}
[data-theme="dark"] table tr:hover {
  background: rgba(96,165,250,0.05);
}
[data-theme="dark"] .table-cards tbody tr {
  background: var(--color-white);
  border-color: var(--color-border);
}

/* Dark Mode: Empty state */
[data-theme="dark"] .empty-state h3 {
  color: var(--color-text);
}

/* Dark Mode: Hardcoded backgrounds */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"] {
  background: var(--color-white) !important;
}
[data-theme="dark"] [style*="background:#f8fafc"],
[data-theme="dark"] [style*="background: #f8fafc"],
[data-theme="dark"] [style*="background:#f1f5f9"],
[data-theme="dark"] [style*="background: #f1f5f9"] {
  background: #0f172a !important;
}
[data-theme="dark"] [style*="color:#1e3a5f"],
[data-theme="dark"] [style*="color: #1e3a5f"],
[data-theme="dark"] [style*="color:#1e293b"],
[data-theme="dark"] [style*="color: #1e293b"] {
  color: var(--color-text) !important;
}
[data-theme="dark"] [style*="color:#555"],
[data-theme="dark"] [style*="color: #555"],
[data-theme="dark"] [style*="color:#64748b"],
[data-theme="dark"] [style*="color: #64748b"] {
  color: var(--color-text-light) !important;
}

/* Theme Toggle Button */
.topbar-hilfe {
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-height: 34px;
  text-decoration: none;
}
.topbar-hilfe:hover { color: var(--color-primary); border-color: var(--color-primary); }
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  transition: all 0.2s;
}
.theme-toggle:hover {
  background: var(--color-bg);
  color: var(--color-primary);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #1e3a5f 0%, #162d4a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow: hidden;
}
.sidebar.open {
  transform: translateX(0);
}

.sidebar-brand {
  padding: 14px 18px 12px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.sidebar-brand h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin: 0;
}
.sidebar-brand small {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1 1 0;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
  /* Platz für den Verlauf am Fuß, damit der letzte Eintrag lesbar bleibt */
  padding-bottom: 24px;
}

/* Die Navigation ist länger als die Seitenleiste hoch ist. Ohne Hinweis
   sah der angeschnittene Abschnitt am Fuß wie ein Darstellungsfehler aus,
   statt zum Rollen einzuladen. Die Klasse .rollbar setzt das Skript am Ende
   von base.html, sobald unterhalb der Kante noch etwas liegt. */
.sidebar-nav { position: relative; }
.sidebar-nav-rahmen {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
}
.sidebar-nav-rahmen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
  background: linear-gradient(to bottom, rgba(24,49,79,0) 0%, #18314f 78%, #17304d 100%);
}
.sidebar-nav-rahmen.rollbar::after { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .sidebar-nav-rahmen::after { transition: none; }
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }
.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,0.35);
  padding: 12px 18px 4px;
  font-weight: 600;
}
.nav-section-label.sec-vermieter { color: #60a5fa; border-left: 3px solid #3b82f6; padding-left: 17px; }
.nav-section-label.sec-persoenlich { color: #4ade80; border-left: 3px solid #22c55e; padding-left: 17px; }
.nav-section-label.sec-mieter { color: #fbbf24; border-left: 3px solid #f59e0b; padding-left: 17px; }

.nav-section-label-fav {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(245, 158, 11, 0.85);
  padding: 14px 20px 4px;
  font-weight: 700;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}
.nav-section-label-fav::before {
  content: '★';
  font-size: 11px;
  color: #f59e0b;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  line-height: 1.4;
}
.nav-item a:hover,
.nav-item a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: var(--color-accent);
}
.nav-item a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* Submenu */
.nav-item.has-submenu > a::after {
  content: '';
  margin-left: auto;
  border: 4px solid transparent;
  border-top-color: rgba(255,255,255,0.4);
  transition: transform var(--transition);
}
.nav-item.has-submenu.open > a::after {
  transform: rotate(180deg);
}
.submenu-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.nav-item.has-submenu.open > .submenu-items {
  max-height: 1200px;
}
.submenu-items a {
  padding-left: 48px;
  font-size: 12px;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Collapsible section toggle headers */
.nav-section-toggle {
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.55) !important;
  padding: 9px 18px !important;
}
.nav-section-toggle:hover {
  color: #fff !important;
}
.nav-section-toggle.sec-vermieter { color: #60a5fa !important; }
.nav-section-toggle.sec-persoenlich { color: #4ade80 !important; }
.nav-section-toggle.sec-mieter { color: #fbbf24 !important; }

/* Sublabels within collapsible sections */
.nav-sublabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.3);
  padding: 10px 20px 4px 52px;
  font-weight: 600;
  list-style: none;
}
.nav-sublabel.sec-vermieter { color: #60a5fa; }
.nav-sublabel.sec-persoenlich { color: #4ade80; }
.nav-sublabel.sec-mieter { color: #fbbf24; }

/* Nested submenus (e.g. Objekte > Häuser & Wohnungen) */
.submenu-items .nav-item.has-submenu > a::after {
  border-width: 3px;
}
.submenu-items .submenu-items a {
  padding-left: 72px;
  font-size: 12px;
}
.submenu-items .nav-item.has-submenu.open > .submenu-items {
  max-height: 400px;
}
/* Submenu items with icons */
.submenu-items .nav-item > a {
  padding-left: 36px;
  gap: 10px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 10px 18px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  padding: 8px 0;
  transition: color var(--transition);
}
.sidebar-footer a:hover {
  color: #fff;
}
/* Kontozeile: ersetzt fünf gestapelte Verweise, die der Navigation rund
   170px Höhe nahmen */
.sidebar-konto {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sidebar-footer .sidebar-konto-name {
  flex: 1;
  min-width: 0;
  gap: 10px;
  padding: 6px 6px 6px 0;
  border-radius: 8px;
}
.sidebar-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-konto-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.sidebar-konto-text strong {
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-konto-text small {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer .sidebar-konto-name.active .sidebar-avatar { background: var(--color-accent, #f59e0b); }
.sidebar-footer .sidebar-konto-knopf {
  position: relative;
  flex-shrink: 0;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}
.sidebar-footer .sidebar-konto-knopf:hover { background: rgba(255,255,255,0.08); }
.sidebar-konto-punkt {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #1e293b;
}
.sidebar-footer a:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

/* --- Backdrop (Mobile) --- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}
.sidebar-backdrop.show {
  display: block;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- Header / Topbar --- */
.topbar {
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding-left: 16px;
  padding-right: 16px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 22px;
  transition: background var(--transition);
}
.menu-toggle:hover {
  background: var(--color-bg);
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Die rechte Kopfzeile war mit 255px breiter als ein Handybild und ragte
   auf zehn Vermieterseiten über den Rand. Mandantenname und die
   Beschriftung des Verwaltung/Privat-Umschalters weichen mobil dem Symbol;
   beides wird unterwegs selten gebraucht, kostete aber zwei Drittel der
   Breite. */
.nur-breit { display: inline; }
@media (max-width: 639px) {
  .topbar-right { gap: 6px; }
  .nur-breit { display: none; }
  .topbar-right .view-mode-toggle {
    padding-left: 8px;
    padding-right: 8px;
    min-width: 40px;
    justify-content: center;
  }
  .topbar-user strong { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.topbar-user {
  font-size: 13px;
  color: var(--color-text-light);
}
.view-mode-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; border: 1px solid #334155;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; background: transparent; color: #94a3b8;
}
.view-mode-toggle:hover { border-color: #60a5fa; color: #60a5fa; }
/* Tippziele: 26px bzw. 28px hoch waren mit dem Finger schwer zu treffen. */
.view-mode-toggle { min-height: 34px; }
.theme-toggle { min-height: 34px; min-width: 38px; }
@media (max-width: 639px) {
  .view-mode-toggle, .theme-toggle { min-height: 40px; }
  .chip, a.chip { min-height: 34px; display: inline-flex; align-items: center; }
}
.view-mode-toggle.mode-privat { background: rgba(34,197,94,0.12); color: #22c55e; border-color: rgba(34,197,94,0.3); }
.view-mode-toggle.mode-verwaltung { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.topbar-user strong {
  color: var(--color-text);
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 16px;
}

/* --- Cards --- */
.card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body {
  padding: 20px;
}

/* Aktionsleiste am Kartenende, z.B. unter Formularen */
.card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Kennzahl, die Aufmerksamkeit braucht (offene Posten) */
.card-stat--warning {
  border-color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 8%, var(--color-white));
}

/* --- Dashboard Grid --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.stat-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon.green { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.amber { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon.red { background: var(--color-danger-light); color: var(--color-danger); }

/* Zählersymbole: Linien-Icon in getönter Kachel (Hintergrund aus der
   Symbolfarbe gemischt, passt damit auch im dunklen Modus) */
.zaehler-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #64748b;
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.zaehler-icon--gross { width: 48px; height: 48px; }
.zaehler-icon--strom { color: #d97706; }
.zaehler-icon--wasser_kalt { color: #0284c7; }
.zaehler-icon--wasser_warm { color: #dc2626; }
.zaehler-icon--brauchwasser { color: #0891b2; }
.zaehler-icon--gas { color: #ea580c; }
.zaehler-icon--heizung { color: #e11d48; }
.zaehler-icon--sonstige { color: #64748b; }

.stat-info h3 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}
.stat-info p {
  font-size: 13px;
  color: var(--color-text-light);
  margin-top: 2px;
}

/* Clickable stat cards */
a.stat-card-link {
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
}
a.stat-card-link:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: inherit;
}

/* --- Tables --- */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table th,
table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
table th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-light);
  white-space: nowrap;
}
table tr:hover {
  background: var(--color-primary-light);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44,111,173,0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  color: #fff;
}
.btn-accent {
  background: var(--color-accent);
  color: #fff;
}
.btn-accent:hover {
  background: var(--color-accent-dark);
  color: #fff;
}
.btn-success {
  background: var(--color-success);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
  color: #fff;
}
.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover {
  background: #dc2626;
  color: #fff;
}
.btn-outline {
  background: transparent;
  border-color: var(--color-border-dark);
  color: var(--color-text);
}
.btn-outline:hover {
  background: var(--color-bg);
  border-color: var(--color-text-light);
  color: var(--color-text);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
}
.badge-success {
  background: var(--color-success-light);
  color: #065f46;
}
.badge-danger {
  background: var(--color-danger-light);
  color: #991b1b;
}
.badge-warning {
  background: var(--color-warning-light);
  color: #92400e;
}
.badge-info {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

/* --- Alerts / Messages --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error {
  background: var(--color-danger-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.alert-danger { /* Alias für Formular-Fehlerboxen */

  background: var(--color-danger-light);
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.alert-success {
  background: var(--color-success-light);
  color: #065f46;
  border: 1px solid #6ee7b7;
}
.alert-warning {
  background: var(--color-warning-light);
  color: #92400e;
  border: 1px solid #fcd34d;
}
.alert-info {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  border: 1px solid #93c5fd;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, transparent 0%, rgba(59,130,246,0.02) 100%);
  margin: 8px 0;
}
.empty-state svg {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: block;
  stroke: var(--color-primary);
  opacity: 0.5;
}
.empty-state p {
  font-size: 14px;
  margin: 0;
}
.empty-state h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}
.empty-state .btn {
  margin-top: 16px;
}
[data-theme="dark"] .empty-state {
  background: linear-gradient(180deg, transparent 0%, rgba(96,165,250,0.04) 100%);
  border-color: var(--color-border);
}

/* --- Lists --- */
.item-list {
  list-style: none;
}
.item-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.item-list li:last-child {
  border-bottom: none;
}

/* --- Calendar --- */
.calendar-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.calendar-table th {
  padding: 8px 4px;
  font-size: 12px;
  text-align: center;
  background: var(--color-bg);
}
.calendar-table td {
  border: 1px solid var(--color-border);
  vertical-align: top;
  padding: 4px;
  min-height: 80px;
  height: 80px;
}
.calendar-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-light);
  padding: 2px 4px;
}
.calendar-event {
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  border-radius: 3px;
  padding: 2px 6px;
  margin-top: 2px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Kanban --- */
.kanban-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.kanban-column {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--color-border);
}
.kanban-column-header {
  font-weight: 700;
  font-size: 14px;
  padding: 8px 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-column-header .count {
  background: var(--color-border);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--color-text-light);
}
.kanban-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: box-shadow var(--transition);
}
.kanban-card:hover {
  box-shadow: var(--shadow-md);
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card h4 {
  font-size: 14px;
  margin-bottom: 4px;
}
.kanban-card p {
  font-size: 12px;
  color: var(--color-text-light);
}
.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.kanban-card-meta .badge {
  font-size: 11px;
  padding: 2px 8px;
}
.kanban-card .due-date {
  font-size: 11px;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kanban-card .due-date.overdue {
  color: var(--color-danger);
  font-weight: 600;
}

/* --- Checkbox Group --- */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  transition: all var(--transition);
}
.checkbox-label:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

/* --- Profile --- */
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.profile-field:last-child {
  border-bottom: none;
}
.profile-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-light);
}
.profile-value {
  font-size: 15px;
  color: var(--color-text);
}

/* --- Upload Box --- */
.upload-box {
  border: 2px dashed var(--color-border-dark);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.upload-box:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.upload-box p {
  color: var(--color-text-light);
  margin-top: 8px;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-light); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.page-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin: 0;
}
.page-header p {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-top: 6px;
}
.page-header.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header.flex-between > div {
  flex: 1;
  min-width: 200px;
}
@media (max-width: 639px) {
  .page-header h1 { font-size: 20px; }
  .page-header { padding-bottom: 12px; margin-bottom: 16px; }
  .page-header.flex-between > .btn,
  .page-header.flex-between > a.btn { width: 100%; }
}

/* --- Login Page (standalone) --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2c6fad 50%, #1e4f7a 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-primary-dark);
}
.login-brand p {
  font-size: 14px;
  color: var(--color-text-light);
  margin-top: 4px;
}
.login-card .form-group {
  margin-bottom: 18px;
}
.login-card .btn {
  margin-top: 8px;
}

.password-wrapper {
  position: relative;
}
.password-wrapper input {
  padding-right: 44px;
}
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--color-text-muted);
  padding: 4px;
  transition: color var(--transition);
}
.toggle-password:hover {
  color: var(--color-text);
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
}
.login-footer a {
  color: var(--color-text-light);
}
.login-footer a:hover {
  color: var(--color-primary);
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* --- Bottom Navigation (Mobile) ---
   Die Regeln stehen weiter unten im Abschnitt "Mobile Bottom Nav";
   die früher hier doppelt geführte Definition (abweichende Höhe und
   z-index 1001 statt 1000) ist entfernt. */
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--color-primary);
}
.bottom-nav-item.active svg {
  stroke: var(--color-primary);
}
.bottom-nav-item svg {
  stroke: var(--color-text-muted);
  transition: stroke 0.2s;
}
.bottom-nav-item:hover svg {
  stroke: var(--color-primary);
}

/* --- A2HS Install Banner --- */
.a2hs-banner {
  position: fixed;
  bottom: 70px;
  left: 12px;
  right: 12px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  padding: 14px 16px;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.a2hs-content {
  display: flex;
  align-items: center;
  gap: 12px;
}
.a2hs-content strong {
  display: block;
  font-size: 14px;
  color: var(--color-text);
}
.a2hs-content small {
  font-size: 12px;
  color: var(--color-text-light);
}
.a2hs-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.a2hs-dismiss {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
}
.a2hs-install {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.a2hs-install:hover {
  background: var(--color-primary-dark);
}

/* --- Mobile Bottom Sheet Menu --- */
.mm-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1099;
}
.mm-backdrop.show {
  display: block;
}
.mobile-menu {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: var(--color-bg);
  flex-direction: column;
  max-height: 70vh;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
  overflow: hidden;
}
.mobile-menu.open {
  display: flex;
}
.mm-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 4px;
  flex-shrink: 0;
  cursor: pointer;
}
.mm-handle-bar {
  width: 36px;
  height: 4px;
  background: var(--color-border-dark);
  border-radius: 2px;
}
.mm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 16px 8px;
  flex-shrink: 0;
}
.mm-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
}
.mm-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
}
.mm-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.mm-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-muted);
  font-weight: 600;
  padding: 14px 0 6px;
}
.mm-section:first-child {
  padding-top: 0;
}
.mm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 8px;
}
.mm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 4px 10px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
  min-height: 72px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.mm-item:hover,
.mm-item:active {
  background: var(--color-primary-light);
  color: var(--color-text);
}
.mm-item svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.mm-item.mm-danger svg {
  stroke: var(--color-danger);
}
.mm-item.mm-danger {
  color: var(--color-danger);
}

/* Mobile-only fixes (< 640px) */
@media (max-width: 639px) {
  /* Bottom navigation visible on mobile */
  .bottom-nav {
    display: flex;
  }

  /* Hide hamburger menu toggle - bottom nav replaces it */
  .menu-toggle {
    display: none;
  }

  /* iOS safe area + bottom nav spacing */
  body {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* Prevent horizontal overflow */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .page-content {
    overflow-x: hidden;
    padding: 12px;
  }

  /* Page header: stack on mobile */
  .page-header.flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header.flex-between > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header.flex-between > div:last-child .btn {
    flex: 1;
    text-align: center;
    min-width: 0;
  }
  .page-header h1 {
    font-size: 18px;
  }

  /* Tables: make scrollable, smaller text */
  .table-container {
    margin: 0 -14px;
    padding: 0 14px;
  }
  table {
    font-size: 12px;
  }
  table th, table td {
    padding: 8px 8px;
    white-space: nowrap;
  }

  /* Cards: less padding on mobile */
  .card-body {
    padding: 12px;
  }
  .card-header {
    padding: 10px 12px;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Stat cards: compact on mobile */
  .stat-card {
    padding: 12px;
    gap: 10px;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
  }
  .stat-icon svg {
    width: 18px;
    height: 18px;
  }
  .stat-info h3 {
    font-size: 18px;
  }
  .stat-info p {
    font-size: 11px;
  }

  /* Item list: stack on mobile */
  .item-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .item-list li .flex {
    width: 100%;
  }

  /* Forms: full width on mobile */
  .form-actions {
    flex-direction: column;
    padding-bottom: 60px;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Extra scroll space so keyboard doesn't hide submit button */
  .card-body form {
    padding-bottom: 40px;
  }

  /* Dashboard: force 2 columns for stat cards */
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  /* Buttons: touch-friendly sizing */
  .btn {
    padding: 10px 14px;
    font-size: 13px;
    min-height: 44px;
  }
  .btn-sm {
    padding: 8px 12px;
    min-height: 36px;
  }

  /* Calendar: tiny cells on mobile */
  .calendar-table td {
    height: 60px;
    min-height: 60px;
    padding: 2px;
  }
  .calendar-table th {
    font-size: 10px;
    padding: 4px 2px;
  }
  .calendar-day-num {
    font-size: 11px;
  }
  .calendar-event {
    font-size: 9px;
    padding: 1px 3px;
  }

  /* ALL inline grids: force single column on mobile */
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Inline-Flex umbrechen lassen.
     Die Regel traf früher nur "display: flex" mit Leerzeichen. 70 von 90
     Templates schreiben aber "display:flex" ohne, weshalb Zeilen wie die
     Knopfleiste der E-Mail-Einstellungen mobil aus dem Bild liefen. */
  div[style*="display: flex"][style*="gap"],
  div[style*="display:flex"][style*="gap"] {
    flex-wrap: wrap !important;
  }

  /* Feste Pixelbreiten in Inline-Styles duerfen das Bild nicht sprengen */
  [style*="width:250px"],
  [style*="width: 250px"],
  input[style*="width:"],
  .form-actions .btn {
    max-width: 100%;
  }
  .form-actions {
    flex-wrap: wrap;
    gap: 10px;
  }
  .form-actions > * { margin-left: 0 !important; }

  /* Fix inline max-width cards */
  div[style*="max-width"] {
    max-width: 100% !important;
  }

  /* Kanban: force single column */
  .kanban-board {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar: full width on mobile with safe area */
  .sidebar {
    width: 85vw;
    max-width: 300px;
  }

  /* Topbar: compact on mobile */
  .topbar {
    padding: 0 14px;
    gap: 8px;
  }
  .topbar-title {
    font-size: 15px;
  }
  .topbar-user {
    display: none;
  }

  /* A2HS banner: above bottom nav */
  .a2hs-banner {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 8px);
  }

  /* Form actions: extra bottom padding for bottom nav */
  .form-actions {
    padding-bottom: 20px;
  }

  /* Mobile touch-friendly inputs */
  .form-control,
  input[type="text"],
  input[type="email"],
  input[type="date"],
  input[type="number"],
  input[type="password"],
  select.form-control,
  textarea.form-control {
    font-size: 16px !important;
    min-height: 44px;
  }
  .btn {
    min-height: 44px;
  }
  .btn-sm {
    min-height: 38px;
  }

  /* Fix select elements overflowing */
  select.form-control,
  .form-group select {
    max-width: 100%;
  }

  /* Waste calendar mobile fixes */
  .waste-chip {
    min-width: 100% !important;
  }
  .waste-day {
    flex-direction: column;
    gap: 8px;
  }
  .waste-date {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .waste-date-day {
    font-size: 16px !important;
  }

  /* Floor plan editor: not usable on mobile */
  .editor-layout {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }
  .editor-toolbar {
    max-height: none;
    border-right: none !important;
    border-bottom: 1px solid #e2e8f0;
  }
  .editor-canvas-wrap {
    min-height: 50vh;
  }
}

/* Tablet (>= 640px) */
@media (min-width: 640px) {
  .page-content {
    padding: 24px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .kanban-board {
    grid-template-columns: repeat(2, 1fr);
  }

  .login-card {
    padding: 40px 36px;
  }
}

/* Desktop (>= 1024px) */
@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
  }

  .main-content {
    margin-left: var(--sidebar-width);
  }

  .menu-toggle {
    display: none;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .page-content {
    padding: 28px 32px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .kanban-board {
    grid-template-columns: repeat(3, 1fr);
  }

  .calendar-table td {
    min-height: 100px;
    height: 100px;
  }
}

/* Large Desktop (>= 1280px) */
@media (min-width: 1280px) {
  .page-content {
    padding: 32px 40px;
    max-width: 1400px;
  }

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

/* ── Nav Badges ─────────────────────────────── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 9px;
  margin-left: auto;
  line-height: 1;
}
.bnav-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid #fff;
}

/* ── Mobile Enhancements (2026-03) ────────────── */
@media (max-width: 639px) {
  /* Task modal: full screen on mobile */
  .task-modal {
    border-radius: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
  }
  .task-modal-overlay {
    align-items: stretch !important;
  }
  .task-modal-header {
    padding: 12px 16px !important;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-bottom: 1px solid var(--color-border);
  }
  .task-modal-header h2 {
    font-size: 16px !important;
  }
  .task-modal-body {
    padding: 12px 16px !important;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .task-modal-footer {
    padding: 10px 16px !important;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--color-border);
    flex-wrap: wrap;
    gap: 6px !important;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .task-modal-footer .btn {
    flex: 1;
    min-width: 0;
    font-size: 12px !important;
    padding: 8px 10px !important;
  }
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 28px !important;
  }

  /* Checklist items: more padding for touch */
  .checklist-item {
    padding: 10px 4px !important;
    min-height: 44px;
  }
  .checklist-del {
    min-width: 36px;
    min-height: 36px;
    font-size: 18px !important;
  }
  .checklist-add-row input {
    min-height: 44px;
  }

  /* Comments: touch-friendly */
  .comment-input-row {
    gap: 6px !important;
  }
  .comment-input-row input {
    min-height: 44px;
  }
  .comment-input-row .btn {
    min-height: 44px;
    padding: 8px 12px !important;
  }

  /* Wizard steps: scrollable horizontally */
  .wiz-step {
    padding: 6px 10px !important;
    font-size: 11px !important;
    min-height: 36px;
  }

  /* Tables on mobile: card-like stacking for specific pages */
  .mobile-stack td {
    display: block;
    text-align: left !important;
    padding: 4px 8px !important;
    border: none !important;
  }
  .mobile-stack tr {
    display: block;
    border-bottom: 2px solid var(--color-border);
    padding: 8px 0;
  }
  .mobile-stack thead {
    display: none;
  }

  /* Fix: Projekt modal on mobile */
  #projektModalOverlay > div {
    width: 95vw !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Forward section: better touch */
  .forward-section input,
  .forward-section textarea {
    min-height: 44px;
  }

  /* Prevent zoom on select focus (iOS) */
  select {
    font-size: 16px !important;
  }

  /* Better spacing for inline edit forms */
  .checklist-section textarea,
  #checklistDescInput {
    min-height: 60px;
  }
}

/* ============================================
   PHASE 2 - Utility Classes & Modern Design
   ============================================ */

/* --- Spacing Utilities --- */
.m-0 { margin: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; }
.px-3 { padding-left: 12px; padding-right: 12px; } .px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; } .py-3 { padding-top: 12px; padding-bottom: 12px; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }

/* --- Flex Utilities --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }

/* --- Grid Utilities --- */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (max-width: 639px) {
  .grid-2 { grid-template-columns: 1fr !important; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-1-mobile { grid-template-columns: 1fr !important; }
  .sm\:grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
  /* Hoechste Spezifizitaet fuer Dashboard Stat-Grid */
  div.grid.grid-4 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  div.grid.grid-3 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
}
@media (min-width: 640px) and (max-width: 1023px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* --- Text Utilities --- */
.text-xs { font-size: 11px; } .text-sm { font-size: 13px; } .text-base { font-size: 15px; }
.text-lg { font-size: 18px; } .text-xl { font-size: 22px; } .text-2xl { font-size: 28px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.text-muted { color: var(--color-text-muted); }
.text-light { color: var(--color-text-light); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.d-inline { display: inline; }
.d-inline-flex { display: inline-flex; }
.d-none { display: none; }
.d-block { display: block; }
.w-full { width: 100%; }
.overflow-x-auto { overflow-x: auto; }
.col-span-full { grid-column: 1 / -1; }
.min-w-0 { min-width: 0; }
.leading-relaxed { line-height: 1.7; }
.whitespace-pre { white-space: pre-wrap; }
.font-extrabold { font-weight: 800; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }
.p-0 { padding: 0; }
.text-left { text-align: left; }

/* --- Modern Card Variants --- */
.card-glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.card-stat {
  display: block;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}
.card-stat:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: inherit;
}
.card-stat .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}
.card-stat .stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.card-stat .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-stat .stat-icon svg {
  width: 20px;
  height: 20px;
}
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
@media (max-width: 639px) {
  .card-stat { padding: 12px 14px; }
  .card-stat .stat-value { font-size: 22px; }
  .card-stat .stat-label { font-size: 11px; }
  .card-stat .stat-icon { width: 32px; height: 32px; border-radius: 8px; }
  .card-stat .stat-icon svg { width: 16px; height: 16px; }
}

/* --- Progress Bar --- */
.progress-bar {
  height: 8px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar .progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-success) 100%);
}
.progress-bar.danger .progress-fill {
  background: linear-gradient(90deg, var(--color-warning) 0%, var(--color-danger) 100%);
}

/* --- Status Dots --- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.green { background: var(--color-success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.status-dot.red { background: var(--color-danger); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.status-dot.yellow { background: var(--color-warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.status-dot.blue { background: var(--color-primary); box-shadow: 0 0 6px rgba(44, 111, 173, 0.4); }

/* --- Modern Badges --- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-pill.success { background: var(--color-success-light); color: #065f46; }
.badge-pill.danger { background: var(--color-danger-light); color: #991b1b; }
.badge-pill.warning { background: var(--color-warning-light); color: #92400e; }
.badge-pill.info { background: #dbeafe; color: #1e40af; }
.badge-pill.neutral { background: #f1f5f9; color: #475569; }

/* --- SVG Icon Defaults --- */
.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 12px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--color-white);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border-left: 4px solid var(--color-primary);
  animation: toast-in 0.3s ease;
  font-size: 14px;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast .toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* --- Wizard Step Component --- */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wizard-step {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}
.wizard-step::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border);
  border-radius: 3px;
}
.wizard-step.active {
  color: var(--color-primary);
}
.wizard-step.active::after {
  background: var(--color-primary);
}
.wizard-step.done {
  color: var(--color-success);
}
.wizard-step.done::after {
  background: var(--color-success);
}
.wizard-step .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-bg);
  font-size: 12px;
  margin-bottom: 4px;
}
.wizard-step.active .step-number {
  background: var(--color-primary);
  color: #fff;
}
.wizard-step.done .step-number {
  background: var(--color-success);
  color: #fff;
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, #e8edf2 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: var(--radius-md); }
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* (Empty State styles bereits oben definiert) */

/* --- Responsive Table Enhancement --- */
@media (max-width: 639px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .table-responsive table {
    min-width: 600px;
  }
  /* Karten-Tabellen brauchen keine Mindestbreite und dürfen umbrechen */
  .table-responsive .table-cards,
  .table-responsive table.table-cards {
    min-width: 0;
  }
  .table-cards td,
  .table-cards th {
    white-space: normal;
  }
  /* Die Kopfzeile trägt den Seitentitel, die H1 darunter wäre mobil doppelt.
     Ausnahme: .page-header--eigener-titel für Seiten, deren H1 etwas anderes
     sagt als die Kopfzeile - auf dem Dashboard steht dort "Dashboard",
     in der H1 aber die persönliche Begrüßung. */
  .page-header h1 {
    display: none;
  }
  .page-header:has(> h1:only-child) {
    display: none;
  }
  .page-header--eigener-titel,
  .page-header--eigener-titel:has(> h1:only-child) {
    display: block;
  }
  .page-header--eigener-titel h1 {
    display: block;
    font-size: 20px;
  }
  /* Card-style table for mobile */
  .table-cards tbody tr {
    display: block;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
  }
  .table-cards thead { display: none; }
  .table-cards td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border: none !important;
    font-size: 14px;
  }
  .table-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 12px;
    flex-shrink: 0;
    margin-right: 8px;
  }
}

/* --- Mobile Bottom Nav (optional, added via template) --- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  z-index: 1000;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
@media (max-width: 639px) {
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .page-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}
.bottom-nav-item.active {
  color: var(--color-primary);
}
.bottom-nav-item:hover {
  color: var(--color-primary);
}

/* --- Floating Action Button --- */
.fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(44, 111, 173, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 900;
  transition: all 0.2s;
}
.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(44, 111, 173, 0.45);
}
.fab svg {
  width: 24px;
  height: 24px;
}
@media (min-width: 640px) {
  .fab { bottom: 24px; }
}

/* --- Smooth Page Transitions --- */
.page-content {
  animation: page-fade-in 0.2s ease;
}
@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Better Form Styling --- */
input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 173, 0.15);
  outline: none;
}
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-light);
  margin-bottom: 4px;
  display: block;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--color-text-light);
  transition: color 0.2s;
}
.breadcrumbs a:hover {
  color: var(--color-primary);
}
.breadcrumbs .sep {
  color: var(--color-border-dark);
}

/* --- Unified Page Header --- */
.ph {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ph-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin: 0;
}
.ph-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.ph-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
@media (max-width: 639px) {
  .ph-title { font-size: 20px; }
  .ph-actions { width: 100%; }
  .ph-actions .btn { flex: 1; min-height: 40px; }
}

/* --- Form Validation Feedback --- */
.form-control.is-invalid,
input.is-invalid, select.is-invalid, textarea.is-invalid {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.form-control.is-valid,
input.is-valid, select.is-valid, textarea.is-valid {
  border-color: var(--color-success) !important;
}
.invalid-feedback {
  display: block;
  font-size: 12px;
  color: var(--color-danger);
  margin-top: 4px;
}
/* Auto: validate after user touched a field */
form.validated input:invalid,
form.validated select:invalid,
form.validated textarea:invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
form.validated input:valid:required,
form.validated select:valid:required,
form.validated textarea:valid:required {
  border-color: var(--color-success);
}
/* Pflichtfeld-Markierung.
   Die Regel griff nur bei input und ließ select und textarea aus. In den
   Templates stand deshalb zusätzlich ein Sternchen von Hand - bei den
   input-Feldern kam so ein doppeltes heraus ("Mietbeginn * *"). Jetzt setzt
   allein das CSS die Markierung, die Templates schreiben keine mehr. */
.form-group label.required::after,
.form-group label[for]:has(+ input[required])::after,
.form-group label[for]:has(+ select[required])::after,
.form-group label[for]:has(+ textarea[required])::after {
  content: ' *';
  color: var(--color-danger);
}

/* Felder, die eine Wahl zwischen mehreren Wegen sind, tragen keine
   Pflicht-Markierung: das required gilt nur innerhalb des jeweiligen
   Formulars, nicht für die Seite. Beispiel: CSV oder MT940 hochladen. */
.form-group--wahl label::after { content: none !important; }

/* Nebenkosten-Prognose ohne Datengrundlage: weder gut noch schlecht. */
.nk-unklar { color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }

/* --- Empty State Improved --- */
.empty-state-modern {
  text-align: center;
  padding: 48px 20px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, transparent 0%, rgba(59,130,246,0.02) 100%);
}
.empty-state-modern .empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, #f0f9ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--color-primary);
}
.empty-state-modern .empty-icon svg {
  width: 36px;
  height: 36px;
}
.empty-state-modern h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}
.empty-state-modern p {
  font-size: 14px;
  color: var(--color-text-muted);
  max-width: 420px;
  margin: 0 auto 20px;
}

/* --- Chip / Tag --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
}
.chip.primary { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.chip.success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.chip.warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.chip.danger { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }


/* Checkbox mit Label in einer Zeile (Gesetz der Nähe) */
.form-group.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-group.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
}
.form-group.form-check label {
  margin: 0;
  cursor: pointer;
}
.form-hinweis-pflicht {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
details.form-details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary);
  padding: 10px 0;
  list-style: none;
}
details.form-details > summary::before { content: "\25B8  "; }
details.form-details[open] > summary::before { content: "\25BE  "; }


/* --- Erinnerungskarte ---------------------------------------------------
   War ein starrer Vierspalter ohne Umbruch: auf dem Handy wurde das
   Fälligkeitsdatum auf "30.11.202" abgeschnitten, und die Knöpfe
   "Erledigt" und "X" lagen komplett ausserhalb des Bildes, eine
   Erinnerung liess sich unterwegs also nicht abhaken. */
.erinnerung-zeile {
  display: flex;
  align-items: center;
  gap: 16px;
}
.erinnerung-icon { font-size: 24px; flex-shrink: 0; }
.erinnerung-text { flex: 1 1 200px; min-width: 0; }
.erinnerung-frist { text-align: right; min-width: 100px; flex-shrink: 0; white-space: nowrap; }
.erinnerung-aktionen { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 639px) {
  .erinnerung-zeile {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px 12px;
  }
  .erinnerung-text { flex: 1 1 100%; order: 2; }
  .erinnerung-icon { order: 1; }
  .erinnerung-frist {
    order: 1;
    text-align: left;
    min-width: 0;
    flex: 1 1 auto;
  }
  .erinnerung-aktionen {
    order: 3;
    flex: 1 1 100%;
    gap: 8px;
  }
  .erinnerung-aktionen form { flex: 1 1 auto; display: flex; }
  .erinnerung-aktionen .btn {
    flex: 1 1 auto;
    min-height: 40px;
    justify-content: center;
  }
}


/* --- Assistent: Feinheiten -------------------------------------------
   Die Schrittleiste gab es schon, aber ohne Regel für die Beschriftung.
   Die Nummer gehört über den Text, und auf dem Handy passen sieben
   Beschriftungen nicht nebeneinander - dort bleibt nur die des aktuellen
   Schritts stehen, der Rest schrumpft auf die Nummer. */
.wizard-step .step-label {
  display: block;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.wizard-step:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: 4px;
}

@media (max-width: 639px) {
  .wizard-steps { gap: 2px; }
  .wizard-step { padding: 10px 2px; font-size: 11px; }
  .wizard-step .step-label { display: none; }
  .wizard-step.active .step-label { display: block; }
  .wizard-step.active { flex: 2 1 auto; }
}

/* Ein gesetztes hidden-Attribut muss immer gewinnen - der Assistent
   blendet seine Karten darüber aus. */
[hidden] { display: none !important; }


/* Pflichtseiten im Fuß der Seitenleiste: unauffällig, aber immer erreichbar.
   Ein Mieter kennt nur die Adresse seines Vermieters, nicht die Startseite. */
.sidebar-rechtliches {
  margin: 10px 0 0;
  padding: 10px 20px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}
.sidebar-rechtliches a {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  padding: 0;
}
.sidebar-rechtliches a:hover { color: rgba(255,255,255,0.8); }
.sidebar-rechtliches span { color: rgba(255,255,255,0.25); }

/* Checkboxen in Labels nicht auf volle Breite strecken (Formulare mit
   display:flex-Labels zeigten den Haken sonst mittig über dem Text) */
.form-group label input[type="checkbox"],
.form-group label input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
}

/* Einstieg auf dem Dashboard: Erste Schritte (Verwalter), Begrüßung (Eigentümer/Mieter) */
.erste-schritte .progress-bar { margin: 0; border-radius: 0; height: 4px; }
.erste-schritte-liste { list-style: none; margin: 0; padding: 4px 16px 12px; }
.erste-schritte-punkt { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.erste-schritte-punkt:last-child { border-bottom: none; }
.erste-schritte-marke { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; border: 2px solid var(--color-border); color: var(--color-text-light); }
.erste-schritte-punkt.naechster .erste-schritte-marke { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.erste-schritte-punkt.erledigt .erste-schritte-marke { border-color: var(--color-success); background: var(--color-success); color: #fff; }
.erste-schritte-punkt.erledigt strong { color: var(--color-text-light); font-weight: 500; text-decoration: line-through; }
.begruessung-kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.begruessung-kachel { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  color: inherit; text-decoration: none; transition: border-color .15s; }
.begruessung-kachel:hover { border-color: var(--color-primary); }
.begruessung-kachel strong { color: var(--color-primary); }
.begruessung-kachel span { font-size: 13px; color: var(--color-text-light); }
@media (max-width: 639px) {
  .erste-schritte-punkt { flex-wrap: wrap; }
  .erste-schritte-punkt .btn { margin-left: 40px; }
}
.eigentuemer-haeuser { list-style: none; margin: 0; padding: 0; }
.eigentuemer-haeuser li { padding: 6px 0; border-bottom: 1px solid var(--color-border); }
.eigentuemer-haeuser li:last-child { border-bottom: none; }
.demo-ansicht { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-text-light);
  border: 1px solid var(--color-warning); background: var(--color-warning-light); border-radius: 8px; padding: 2px 4px 2px 10px; min-height: 34px; }
.demo-ansicht select { border: none; background: transparent; font-size: 12px; font-weight: 600; color: var(--color-text); padding: 4px; cursor: pointer; }
