@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800;1,14..32,400&display=swap');

/* ============================================================
   STADTWERK PORTAL – app.css  v3
   Design-System: Stripe / N26 / Linear-Niveau
   Premium, ruhig, präzise. Mobile-first ab 375px.
   ============================================================ */

/* ============================================================
   1. TOKENS
   ============================================================ */
:root {
  /* Farben – Marke */
  --primary:            #0f3460;
  --primary-light:      #1a4d8a;
  --primary-hover:      #0a2444;
  --sidebar-bg:         #0c2d52;
  --sidebar-hover:      #1a4880;
  --sidebar-active:     #1e5799;
  --accent:             #e8821a;
  --accent-hover:       #cf6f14;

  /* Farben – Status */
  --success:            #16a34a;
  --success-bg:         #f0fdf4;
  --success-bg-strong:  #dcfce7;
  --warning:            #d97706;
  --warning-bg:         #fffbeb;
  --warning-bg-strong:  #fef3c7;
  --danger:             #dc2626;
  --danger-bg:          #fef2f2;
  --danger-bg-strong:   #fee2e2;
  --info:               #2563eb;
  --info-bg:            #eff6ff;
  --info-bg-strong:     #dbeafe;

  /* Farben – Flächen */
  --bg:                 #f8fafc;
  --card:               #ffffff;
  --border:             #e2e8f0;
  --border-subtle:      #f1f5f9;
  --border-strong:      #cbd5e1;

  /* Farben – Text */
  --text:               #0f172a;
  --text-muted:         #64748b;
  --text-light:         #94a3b8;
  --text-on-dark:       rgba(255,255,255,.92);
  --text-on-dark-muted: rgba(255,255,255,.6);

  /* Typografie – disziplinierte 6er-Skala */
  --text-xs:    0.6875rem;  /* 11px */
  --text-sm:    0.75rem;    /* 12px */
  --text-base:  0.875rem;   /* 14px */
  --text-md:    1rem;       /* 16px */
  --text-lg:    1.25rem;    /* 20px */
  --text-xl:    1.75rem;    /* 28px */
  --text-2xl:   2.25rem;    /* 36px */

  /* Spacing – 4px-Grid */
  --space-1:    0.25rem;
  --space-2:    0.5rem;
  --space-3:    0.75rem;
  --space-4:    1rem;
  --space-5:    1.25rem;
  --space-6:    1.5rem;
  --space-8:    2rem;
  --space-10:   2.5rem;

  /* Layout */
  --sidebar-w:           240px;
  --sidebar-w-collapsed: 64px;
  --header-h:            56px;

  /* Radius & Shadow */
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  18px;
  --shadow-sm:  0 1px 2px rgba(15,23,42,.05);
  --shadow:     0 1px 3px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.04);
  --shadow-md:  0 6px 24px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.04);
  --shadow-lg:  0 16px 56px rgba(15,23,42,.12), 0 3px 10px rgba(15,23,42,.06);

  /* Motion */
  --transition: 140ms cubic-bezier(.25,0,.1,1);
  --transition-slow: 260ms cubic-bezier(.25,0,.1,1);

  /* Z-Layers */
  --z-sidebar: 90;
  --z-header:  100;
  --z-modal:   500;
  --z-toast:   1000;
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Custom scrollbars – slim & elegant */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(15,23,42,.14); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,.28); }
* { scrollbar-width: thin; scrollbar-color: rgba(15,23,42,.14) transparent; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
input, select, textarea, button { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: var(--primary-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }
code {
  font-family: 'SFMono-Regular', 'JetBrains Mono', Consolas, monospace;
  font-size: 0.85em;
  background: var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}
::selection { background: rgba(15,52,96,.15); color: var(--primary); }

/* Focus-Ring (a11y) */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 3px;
}
button:focus-visible, a:focus-visible {
  outline-offset: 3px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   3. VIEWS
   ============================================================ */
.view { display: none; min-height: 100vh; }
.view.active { display: block; animation: fadeIn 200ms ease; }

/* ============================================================
   4. APP-SHELL (Sidebar-Layout)
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: #ffffff;
  color: var(--text);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: transform var(--transition-slow), width var(--transition-slow);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-5);
  font-weight: 800;
  font-size: var(--text-md);
  color: var(--text);
  letter-spacing: -.03em;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}
.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #d96e0b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(232,130,26,.25);
}
.sidebar-logo-text { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.sidebar-logo-text small {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-light);
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Scrollable nav wrapper */
.sidebar-nav-wrapper {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--space-2) 0 var(--space-2);
  border-top: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.08) transparent;
}
.sidebar-nav-wrapper::-webkit-scrollbar { width: 3px; }
.sidebar-nav-wrapper::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 3px; }

.sidebar-section {
  padding: var(--space-1) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidebar-section + .sidebar-section { padding-top: var(--space-1); }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 var(--space-2) var(--space-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  position: relative;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--info-bg);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.sidebar-link-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: .5;
  transition: opacity var(--transition);
}
.sidebar-link:hover .sidebar-link-icon { opacity: .75; }
.sidebar-link.active .sidebar-link-icon { opacity: 1; }
.sidebar-link-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Colored icons per section (works on light bg) */
.sidebar-section:nth-child(2) .sidebar-link svg { color: #d97706; }
.sidebar-section:nth-child(2) .sidebar-link:hover svg,
.sidebar-section:nth-child(2) .sidebar-link.active svg { color: #b45309; opacity: 1; }
.sidebar-section:nth-child(3) .sidebar-link svg { color: #2563eb; }
.sidebar-section:nth-child(3) .sidebar-link:hover svg,
.sidebar-section:nth-child(3) .sidebar-link.active svg { color: #1d4ed8; opacity: 1; }
.sidebar-section:nth-child(4) .sidebar-link svg { color: var(--text-light); }

.sidebar-badge {
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.4;
}
.sidebar-badge.badge-muted { background: var(--border); color: var(--text-muted); }

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) var(--space-3);
  list-style: none;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  margin-bottom: var(--space-1);
}
.sidebar-user:hover { background: var(--border-subtle); }
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar-user-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  margin-top: var(--space-2);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: var(--text-on-dark);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-logout:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.2);
  color: white;
}

/* Collapsed Variant */
.app-sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.app-sidebar.collapsed .sidebar-logo-text,
.app-sidebar.collapsed .sidebar-link-text,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-user-info,
.app-sidebar.collapsed .sidebar-logout span { display: none; }
.app-sidebar.collapsed .sidebar-logo { justify-content: center; padding: var(--space-5) var(--space-2) var(--space-4); }
.app-sidebar.collapsed .sidebar-link { justify-content: center; padding: var(--space-3); }
.app-sidebar.collapsed .sidebar-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  padding: 0 4px;
  font-size: 9px;
}

/* App Content (Mainbereich rechts der Sidebar) */
.app-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
  min-width: 0;
  max-width: calc(100vw - var(--sidebar-w));
  background: #f4f7fb;
}
.app-shell.sidebar-collapsed .app-content { margin-left: var(--sidebar-w-collapsed); }

.app-content-inner {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Logout link variant (used in linda.html sidebar footer) */
.sidebar-logout-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  width: 100%;
  text-decoration: none;
}
.sidebar-logout-link:hover {
  background: var(--danger-bg);
  color: var(--danger);
  text-decoration: none;
}
.sidebar-logout-link svg { flex-shrink: 0; opacity: .6; }

/* ---- Mobile top-bar (hamburger + title, only on ≤768px) ---- */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--primary);
  transition: background var(--transition);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.sidebar-toggle-btn:hover { background: var(--bg); }
.mobile-topbar-title {
  flex: 1;
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--primary);
  letter-spacing: -.01em;
}
.mobile-topbar-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--danger);
  color: white;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.mobile-topbar-badge:empty { display: none; }

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: calc(var(--z-sidebar) + 1);
  width: 40px;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: var(--text-md);
}
.sidebar-backdrop,
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  z-index: calc(var(--z-sidebar) - 1);
}
.sidebar-backdrop.open,
.sidebar-overlay.active { display: block; }

/* ============================================================
   5. TOP-HEADER (für Legacy-/Verwaltungs-Layout)
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  height: var(--header-h);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 2px 12px rgba(0,0,0,.18);
}
.header-left { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.header-logo {
  font-weight: 700;
  font-size: var(--text-md);
  white-space: nowrap;
  letter-spacing: -.01em;
}
.header-badge {
  background: var(--accent);
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .7px;
}
.header-center { flex: 1; display: flex; justify-content: center; min-width: 0; }
.header-right { display: flex; align-items: center; gap: var(--space-4); flex-shrink: 0; }
.header-user { font-size: var(--text-base); opacity: .85; }

.btn-logout {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-logout:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.4);
  text-decoration: none;
}

/* Notification Bell */
.notif-bell {
  position: relative;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  font-size: var(--text-md);
  padding: 5px 10px;
  line-height: 1;
  transition: background var(--transition);
}
.notif-bell:hover { background: rgba(255,255,255,.2); }
.notif-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger);
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--primary);
}

/* Tab Navigation – verbessert mit inset shadow */
.tab-nav {
  display: flex;
  gap: 2px;
  background: rgba(0,0,0,.18);
  padding: 4px;
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  position: relative;
}
.tab-btn:hover { background: rgba(255,255,255,.1); color: white; }
.tab-btn.active {
  background: white;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.12), inset 0 -2px 0 var(--accent);
}

/* ============================================================
   6. MAIN CONTENT (Legacy)
   ============================================================ */
.view-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 200ms ease; }

/* ============================================================
   7. PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.02em;
  line-height: 1.2;
}
.page-header h1 {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.025em;
  line-height: 1.15;
}
.page-desc { color: var(--text-muted); font-size: var(--text-base); margin-top: var(--space-1); }
.page-actions { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }

/* ============================================================
   8. BUTTONS – Vollständiges System
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: .005em;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
  line-height: 1.3;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn:disabled, .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(180deg, #2d72d9 0%, var(--primary) 100%);
  color: white;
  border: 1px solid transparent;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 1px 2px rgba(15,52,96,.2), inset 0 1px 0 rgba(255,255,255,.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  line-height: 1.3;
  white-space: nowrap;
}
.btn-primary:hover {
  background: linear-gradient(180deg, #3b82f6 0%, var(--primary-light) 100%);
  box-shadow: 0 4px 14px rgba(15,52,96,.3), inset 0 1px 0 rgba(255,255,255,.1);
  text-decoration: none;
  color: white;
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(.98) translateY(0); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid rgba(0,0,0,.12);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: var(--text-base);
  transition: all var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  line-height: 1.3;
  white-space: nowrap;
}
.btn-secondary:hover {
  border-color: rgba(0,0,0,.2);
  background: var(--bg);
  text-decoration: none;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.btn-secondary:active { transform: scale(.98) translateY(0); }

.btn-accent {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-base);
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 1px 2px rgba(232,130,26,.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  line-height: 1.3;
  white-space: nowrap;
}
.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(232,130,26,.35);
  color: white;
  text-decoration: none;
}
.btn-accent:active { transform: scale(.98); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 1px 2px rgba(220,38,38,.25);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 4px 12px rgba(220,38,38,.3);
  color: white;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--border-subtle);
  color: var(--primary);
  text-decoration: none;
}

.btn-sm { padding: 5px 12px; font-size: var(--text-sm); border-radius: 7px; }
.btn-lg { padding: 11px 22px; font-size: var(--text-md); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon.btn-sm { width: 28px; height: 28px; }

.btn-block { width: 100%; }

/* Legacy Action-Buttons */
.btn-action {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition);
  line-height: 1.5;
}
.btn-action:hover { opacity: .85; transform: translateY(-1px); }
.btn-info  { background: var(--info-bg-strong);    color: var(--info); }
.btn-pdf   { background: var(--danger-bg-strong);  color: var(--danger); }
.btn-csv   { background: var(--success-bg-strong); color: var(--success); }
.btn-next  { background: var(--warning-bg-strong); color: var(--warning); }

/* ============================================================
   9. STAT-CARDS (Dashboard KPIs)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat-card {
  background: var(--card);
  border: 1px solid rgba(0,0,0,.07);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  transition: box-shadow var(--transition), transform var(--transition);
  animation: countUp 300ms cubic-bezier(.25,0,.1,1) backwards;
}
.stat-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.09);
  transform: translateY(-2px);
}
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 40ms; }
.stat-card:nth-child(3) { animation-delay: 80ms; }
.stat-card:nth-child(4) { animation-delay: 120ms; }

.stat-card.ampel-rot   { border-left-color: var(--danger); }
.stat-card.ampel-gelb  { border-left-color: var(--warning); }
.stat-card.ampel-gruen { border-left-color: var(--success); }
.stat-card.stat-accent { border-left-color: var(--accent); }
.stat-card.stat-primary { border-left-color: var(--primary); }

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-card-value {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.stat-card-trend {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-top: var(--space-1);
}
.stat-card-trend.up { color: var(--success); }
.stat-card-trend.down { color: var(--danger); }
.stat-card-trend.flat { color: var(--text-muted); }
.stat-card-foot {
  font-size: var(--text-xs);
  color: var(--text-light);
  margin-top: var(--space-1);
}

/* Legacy stats-grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.stat-icon { font-size: 1.4rem; }
.stat-value {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: var(--text-sm); color: var(--text-muted); font-weight: 500; }

/* Legacy stat-card mit ::before-stripe */
.stats-grid .stat-card { border-left: 1px solid var(--border); padding-left: var(--space-5); }
.stats-grid .stat-card::before {
  content: '';
  position: absolute;
  left: -1px; top: -1px; bottom: -1px;
  width: 4px;
  background: var(--primary);
  border-radius: var(--radius) 0 0 var(--radius);
}
.stats-grid .stat-card.stat-accent::before { background: var(--accent); }

/* ============================================================
   10. CARDS / SECTIONS
   ============================================================ */
.card,
.section-card {
  background: var(--card);
  border: 1px solid rgba(0,0,0,.07);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.03);
}

.dashboard-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: var(--space-6);
}
.dashboard-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.dashboard-section h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   11. TABELLEN
   ============================================================ */
.table-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  /* No overflow-x: auto — table-layout:fixed keeps it within bounds */
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  table-layout: fixed; /* KEY: columns share container width, no overflow */
}
.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table thead tr { background: var(--bg); border-bottom: 2px solid var(--border); }
.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:nth-child(even) { background: rgba(248,250,252,.7); }
.data-table tbody tr:hover { background: var(--info-bg); }
.data-table tbody td {
  padding: 10px 14px;
  vertical-align: middle;
  font-size: var(--text-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Column width system — prevents overflow */
.data-table thead th:first-child,
.data-table tbody td:first-child { width: 52px; color: var(--text-light); font-size: var(--text-sm); }
.data-table thead th:last-child,
.data-table tbody td:last-child  { width: 148px; white-space: normal; overflow: visible; }
.data-table thead th:nth-last-child(2),
.data-table tbody td:nth-last-child(2) { width: 110px; }

.data-table tbody tr.ampel-rot   { box-shadow: inset 3px 0 0 var(--danger); }
.data-table tbody tr.ampel-gelb  { box-shadow: inset 3px 0 0 var(--warning); }
.data-table tbody tr.ampel-gruen { box-shadow: inset 3px 0 0 var(--success); }

.td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-objekt { }
.td-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.data-table-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.table-empty {
  padding: var(--space-10) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   12. POSTEN-TABELLE (Legacy)
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  margin-top: var(--space-2);
}
.section-header h3 { font-size: var(--text-base); font-weight: 700; color: var(--primary); }
.posten-table-wrap { overflow-x: auto; margin-bottom: var(--space-6); }
.posten-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.posten-table thead tr { background: var(--bg); color: var(--text-muted); border-bottom: 2px solid var(--border); }
.posten-table thead th { padding: 10px 12px; text-align: left; font-weight: 700; white-space: nowrap; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.posten-table tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.posten-table tbody tr:hover { background: var(--bg); }
.posten-table tfoot td { padding: 10px 12px; background: var(--info-bg); font-weight: 700; }
.gesamt-label { text-align: right; color: var(--primary); }
.gesamt-value { text-align: right; color: var(--primary); font-size: var(--text-md); font-variant-numeric: tabular-nums; }
.col-pos     { width: 44px; }
.col-bez     { min-width: 200px; }
.col-menge   { width: 90px; }
.col-einheit { width: 110px; }
.col-betrag  { width: 120px; }
.col-action  { width: 44px; }
.col-ust     { width: 100px; text-align: right; }

.input-inline {
  width: 100%;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: var(--text-base);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-inline:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.input-num { text-align: right; font-variant-numeric: tabular-nums; }

.btn-remove {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: var(--text-base);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
}
.btn-remove:hover { color: var(--danger); background: var(--danger-bg); }

/* ============================================================
   13. SKELETON-LOADER
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border-subtle) 0%,
    var(--border) 50%,
    var(--border-subtle) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
}
.skeleton-text { height: 12px; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-text.long { width: 95%; }
.skeleton-row {
  display: flex;
  gap: var(--space-4);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
}
.skeleton-row:last-child { border-bottom: none; }
.skeleton-cell { height: 14px; flex: 1; }
.skeleton-cell.cell-sm { flex: 0 0 60px; }
.skeleton-cell.cell-md { flex: 0 0 120px; }
.skeleton-circle { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   14. EMPTY STATE
   ============================================================ */
.empty-state {
  padding: var(--space-10) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-light);
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}
.empty-state-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.empty-state-text {
  font-size: var(--text-base);
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.5;
}
.empty-state-action {
  margin-top: var(--space-3);
}

/* ============================================================
   15. INBOX
   ============================================================ */
.inbox-list {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: white;
  transition: background var(--transition), transform var(--transition);
  position: relative;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.inbox-item:last-child { border-bottom: none; }
.inbox-item:hover { transform: none; background: var(--bg); }
.inbox-item.ampel-rot {
  border-left-color: var(--danger);
  background: linear-gradient(90deg, rgba(220,38,38,.03) 0%, transparent 30%);
}
.inbox-item.ampel-rot:hover { background: linear-gradient(90deg, rgba(220,38,38,.06) 0%, var(--bg) 30%); }
.inbox-item.ampel-gelb {
  border-left-color: var(--warning);
  background: linear-gradient(90deg, rgba(217,119,6,.03) 0%, transparent 30%);
}
.inbox-item.ampel-gelb:hover { background: linear-gradient(90deg, rgba(217,119,6,.06) 0%, var(--bg) 30%); }
.inbox-item.ampel-gruen { border-left-color: var(--success); }

.inbox-item-ampel {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}
.inbox-item-ampel.ampel-rot   { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.inbox-item-ampel.ampel-gelb  { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.inbox-item-ampel.ampel-gruen { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }

.inbox-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.inbox-item-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.inbox-item-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.inbox-item-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

/* ============================================================
   16. ABRECHNUNGS-CARDS (Verwaltung)
   ============================================================ */
.card-list { display: flex; flex-direction: column; gap: var(--space-3); }
.abr-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.abr-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: var(--border-strong);
}
.abr-card-main { display: flex; flex-direction: column; gap: var(--space-1); }
.abr-card-id {
  font-size: var(--text-xs);
  color: var(--text-light);
  font-family: 'SFMono-Regular', Consolas, monospace;
  letter-spacing: .02em;
}
.abr-card-obj { font-weight: 600; color: var(--text); font-size: var(--text-md); letter-spacing: -.01em; }
.abr-card-meta { font-size: var(--text-base); color: var(--text-muted); }
.abr-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-2); }
.abr-card-sum {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   17. LIST ITEMS (Dashboard)
   ============================================================ */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }
.list-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-item-main strong { font-size: var(--text-base); color: var(--primary); font-weight: 600; }
.list-item-sub { font-size: var(--text-sm); color: var(--text-muted); }
.list-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); flex-shrink: 0; }
.list-item-date { font-size: var(--text-xs); color: var(--text-light); }

/* ============================================================
   18. BADGES & PILLS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
  line-height: 1.5;
}
.badge-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-danger  { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.badge-info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-neutral { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.badge-primary { background: #eff6ff; color: var(--primary); border: 1px solid #dbeafe; }

/* Legacy badges */
.badge-eingegangen { background: var(--info-bg-strong);    color: var(--info); }
.badge-geprueft    { background: var(--warning-bg-strong); color: var(--warning); }
.badge-exportiert  { background: var(--success-bg-strong); color: var(--success); }
.badge-wechsel     { background: #f3e5ff; color: #6a1b9a; }

.badge-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text);
  font-weight: 500;
}
.badge-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  flex-shrink: 0;
}
.badge-dot.dot-success::before { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.badge-dot.dot-warning::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.badge-dot.dot-danger::before  { background: var(--danger);  box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.badge-dot.dot-info::before    { background: var(--info);    box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

.badge-tiny {
  display: inline-flex;
  align-items: center;
  background: var(--info-bg);
  color: var(--primary);
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-schluessel { background: #f3e5ff; color: #6a1b9a; font-size: var(--text-xs); padding: 2px 8px; border-radius: 20px; }
.badge-typ-hz  { background: var(--danger-bg-strong);  color: var(--danger); }
.badge-typ-bk  { background: var(--success-bg-strong); color: var(--success); }
.badge-typ-wa  { background: var(--info-bg-strong);    color: var(--info); }

/* Status-Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.status-eingegangen, .status-neu        { background: var(--info-bg-strong); color: var(--info); }
.status-pruefung, .status-in-pruefung   { background: var(--warning-bg-strong); color: var(--warning); }
.status-geprueft                        { background: var(--warning-bg-strong); color: var(--warning); }
.status-freigegeben                     { background: var(--success-bg-strong); color: var(--success); }
.status-exportiert, .status-fertig      { background: var(--success-bg-strong); color: var(--success); }
.status-abgelehnt, .status-fehler       { background: var(--danger-bg-strong); color: var(--danger); }
.status-archiviert                      { background: var(--border); color: var(--text-muted); }

/* Ampel */
.ampel-rot   { color: var(--danger); }
.ampel-gelb  { color: var(--warning); }
.ampel-gruen { color: var(--success); }

.ampel-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.ampel-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ampel-dot.ampel-rot   { background: var(--danger);  box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.ampel-dot.ampel-gelb  { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.ampel-dot.ampel-gruen { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }

.user-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ============================================================
   19. FORMS
   ============================================================ */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.form-input,
.form-select,
.form-textarea,
.form-group input,
.form-group select,
.form-group textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: white;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: var(--text-base);
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,52,96,.12);
}
.form-input.error,
.form-group input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
.form-textarea,
.form-group textarea { min-height: 96px; resize: vertical; font-family: inherit; }
.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: 2px;
  font-weight: 500;
}
.form-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.form-section:last-child { border-bottom: none; padding-bottom: 0; }
.form-section-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: var(--space-4);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

/* ============================================================
   20. FILTER BAR
   ============================================================ */
.filter-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: white;
  color: var(--text);
  font-size: var(--text-base);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}

.archiv-filter-bar,
.filter-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
}
.filter-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: white;
  color: var(--text);
  font-size: var(--text-base);
  min-width: 200px;
  flex: 1;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,52,96,.1);
}

/* ============================================================
   21. LOGIN – SPLIT-SCREEN + Legacy
   ============================================================ */
.login-page {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.login-brand-panel {
  background:
    radial-gradient(ellipse at top left, rgba(232,130,26,.15) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(30,87,153,.4) 0%, transparent 50%),
    linear-gradient(135deg, #040e1f 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: white;
  padding: var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-brand-panel::before {
  content: '';
  position: absolute;
  top: -50%; right: -30%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(232,130,26,.1) 0%, transparent 60%);
  pointer-events: none;
}

.login-brand-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: -.01em;
  position: relative;
  z-index: 1;
}
.login-brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #d96e0b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  box-shadow: 0 4px 16px rgba(232,130,26,.4);
}

.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
}
.login-brand-headline {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.025em;
  margin-bottom: var(--space-4);
  color: white;
}
.login-brand-sub {
  font-size: var(--text-md);
  line-height: 1.6;
  color: rgba(255,255,255,.75);
  margin-bottom: var(--space-8);
}
.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.login-brand-feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  color: rgba(255,255,255,.85);
  font-size: var(--text-base);
  line-height: 1.5;
}
.login-brand-feature-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.login-brand-feature strong { color: white; font-weight: 600; display: block; margin-bottom: 2px; }

.login-brand-foot {
  position: relative;
  z-index: 1;
  font-size: var(--text-xs);
  color: rgba(255,255,255,.4);
}

.login-form-panel {
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-8);
}
.login-form-inner {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.login-form-header {
  text-align: left;
}
.login-form-header h1 {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.025em;
  margin-bottom: var(--space-2);
}
.login-form-header p {
  font-size: var(--text-base);
  color: var(--text-muted);
}

.login-demo-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}
.login-demo-box summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--transition);
}
.login-demo-box summary::-webkit-details-marker { display: none; }
.login-demo-box summary::after {
  content: '+';
  font-size: var(--text-md);
  color: var(--text-muted);
  transition: transform var(--transition);
}
.login-demo-box[open] summary::after { content: '−'; }
.login-demo-box summary:hover { background: var(--border-subtle); }
.login-demo-box-body {
  padding: 0 var(--space-4) var(--space-4);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: var(--text-xs);
  line-height: 1.7;
  color: var(--text);
}

/* Legacy Login (zentrierte Karte) */
.login-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, rgba(232,130,26,.15) 0%, transparent 60%),
    linear-gradient(135deg, #040e1f 0%, var(--primary) 45%, var(--primary-light) 80%, #2171c7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
}
.login-card {
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.15);
  border: 1px solid rgba(255,255,255,.6);
}
.login-logo { text-align: center; margin-bottom: var(--space-8); }
.logo-icon { font-size: 2.5rem; margin-bottom: var(--space-2); display: block; }
.login-logo h1 {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--primary);
  margin-bottom: var(--space-1);
  letter-spacing: -.025em;
}
.login-subtitle { color: var(--text-muted); font-size: var(--text-base); }

.login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-form-group { display: flex; flex-direction: column; gap: var(--space-2); }
.login-form-group label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.login-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: white;
  color: var(--text);
  font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.login-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,52,96,.12);
}
.login-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: .005em;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(15,52,96,.3);
  margin-top: var(--space-1);
}
.login-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15,52,96,.35);
}
.login-btn:active { transform: translateY(0); }
.login-error {
  background: var(--danger-bg);
  border-left: 3px solid var(--danger);
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 500;
}
.login-hint {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.login-roles { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-6); }
.role-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-align: left;
  width: 100%;
}
.role-btn:hover {
  border-color: var(--primary);
  background: var(--info-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.role-icon { font-size: 1.5rem; }
.role-btn strong { font-size: var(--text-md); color: var(--primary); font-weight: 700; }
.role-desc { font-size: var(--text-sm); color: var(--text-muted); }
.login-demo-note { text-align: center; color: var(--text-light); font-size: var(--text-sm); margin-top: var(--space-2); }

/* ============================================================
   22. ADMIN
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--text-on-dark);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}
.admin-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.admin-section h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.user-list { display: flex; flex-direction: column; }
.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
  transition: background var(--transition);
}
.user-item:last-child { border-bottom: none; }
.user-item.user-inactive { opacity: .5; }
.user-item-info { display: flex; flex-direction: column; gap: 2px; }

.firma-list { display: flex; flex-direction: column; }
.firma-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--space-3);
}
.firma-item:last-child { border-bottom: none; }

/* ============================================================
   23. MODAL
   ============================================================ */
.modal-overlay,
#detail-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 180ms ease;
}
.modal-overlay.open,
#detail-modal.open { display: flex; }

.modal,
.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  animation: modalIn 200ms cubic-bezier(.2,0,.13,1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.015em;
}
.modal-close {
  background: none;
  border: none;
  font-size: var(--text-md);
  cursor: pointer;
  color: var(--text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-body { overflow-y: auto; padding: var(--space-6); flex: 1; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============================================================
   24. DETAIL VIEW
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  border: 1px solid var(--border);
}
.detail-item label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  margin-bottom: 4px;
}
.detail-item span { font-size: var(--text-base); font-weight: 500; color: var(--text); }
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
  margin-bottom: var(--space-4);
}
.detail-table thead tr { background: var(--primary); color: white; }
.detail-table thead th { padding: 8px 12px; text-align: left; font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; }
.detail-table thead th.td-num { text-align: right; }
.detail-table tbody tr { border-bottom: 1px solid var(--border-subtle); }
.detail-table tbody tr:hover { background: var(--bg); }
.detail-table tbody td { padding: 8px 12px; }
.tfoot-gesamt { background: var(--info-bg); }
.tfoot-gesamt td { padding: 10px 12px; font-weight: 700; color: var(--primary); }
.detail-bemerkung {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  margin-top: var(--space-2);
  color: var(--warning);
}
.rechtsgrundlage-box {
  background: var(--info-bg);
  border-left: 3px solid var(--primary);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--primary);
  margin-bottom: var(--space-4);
}

.nutzer-grid { display: flex; gap: var(--space-4); align-items: center; margin: var(--space-4) 0; flex-wrap: wrap; }
.nutzer-card {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  border: 1px solid var(--border);
}
.nutzer-alt { border-left: 3px solid var(--danger); }
.nutzer-neu { border-left: 3px solid var(--success); }
.nutzer-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.nutzer-name { font-weight: 600; font-size: var(--text-base); margin-bottom: 2px; }
.nutzer-meta { font-size: var(--text-sm); color: var(--text-muted); }
.nutzer-arrow { font-size: 1.5rem; color: var(--text-muted); flex-shrink: 0; }

/* ============================================================
   25. LOADING / SPINNER
   ============================================================ */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10);
  color: var(--text-muted);
  gap: var(--space-3);
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* ============================================================
   26. TOAST
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 240ms cubic-bezier(.2,0,.13,1), transform 240ms cubic-bezier(.2,0,.13,1);
  max-width: 380px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid rgba(255,255,255,.08);
}
.toast.toast-visible { opacity: 1; transform: translateX(0); }
.toast.toast-success { background: var(--success); border-color: rgba(255,255,255,.15); }
.toast.toast-error   { background: var(--danger);  border-color: rgba(255,255,255,.15); }
.toast.toast-warning { background: var(--warning); border-color: rgba(255,255,255,.15); }
.toast.toast-info    { background: var(--info);    border-color: rgba(255,255,255,.15); }

/* ============================================================
   27. BK-FORM (Kostenarten)
   ============================================================ */
.bk-positionen-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.bk-pos-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  flex-wrap: wrap;
  transition: background var(--transition), border-color var(--transition);
}
.bk-pos-row:hover { background: var(--bg); border-color: var(--border-strong); }
.bk-pos-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  flex: 1;
  min-width: 250px;
}
.bk-pos-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.bk-pos-nr {
  font-size: var(--text-xs);
  color: var(--text-light);
  white-space: nowrap;
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: var(--info-bg);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.bk-pos-label { font-size: var(--text-base); font-weight: 500; color: var(--text); }
.bk-pos-inputs { display: flex; gap: var(--space-2); align-items: center; }
.bk-gesamt-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--info-bg);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--primary);
  margin-bottom: var(--space-2);
  border: 1px solid #dce8f5;
}
.bk-gesamt-row strong { font-size: var(--text-md); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ============================================================
   28. UTILITIES
   ============================================================ */
.text-muted { color: var(--text-muted); font-size: var(--text-sm); }
.text-light { color: var(--text-light); }
.text-mono { font-family: 'SFMono-Regular', Consolas, monospace; }
.text-tabular { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.wasser-verbrauch { color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-5) 0;
  border: none;
}

.flex-row { display: flex; gap: var(--space-3); align-items: center; }
.flex-col { display: flex; flex-direction: column; gap: var(--space-2); }
.flex-grow { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   29. ANIMATIONEN
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes slideInRight {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   30. RESPONSIVE – ab 375px
   ============================================================ */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .app-content-inner { padding: var(--space-5); }
}

@media (max-width: 768px) {
  /* Mobile topbar sichtbar */
  .mobile-topbar { display: flex; }

  /* Sidebar wird Overlay */
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; max-width: 100%; }
  .app-shell.sidebar-collapsed .app-content { margin-left: 0; }
  .col-bez { min-width: 0; }
  .sidebar-toggle { display: flex; }
  .app-content-inner { padding: calc(var(--space-3) + 40px) var(--space-4) var(--space-5); }

  /* Header */
  .app-header { padding: 0 var(--space-4); gap: var(--space-2); }
  .header-center { display: none; }
  .view-content { padding: var(--space-4); }

  /* Forms & Layout */
  .form-card { padding: var(--space-5); }
  .form-grid { grid-template-columns: 1fr; }
  .modal,
  .modal-box { max-height: 95vh; border-radius: var(--radius); }
  .dashboard-sections { grid-template-columns: 1fr; }

  /* Tabellen */
  .td-objekt { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .data-table thead th,
  .data-table tbody td { padding: 10px 12px; }

  /* Inbox */
  .inbox-item { padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
  .inbox-item-actions { flex-direction: column; width: 100%; align-items: stretch; margin-top: var(--space-2); }

  /* Login */
  .login-page { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-form-panel { padding: var(--space-6) var(--space-4); }

  /* Tabs */
  .tab-nav { padding: 3px; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 6px 12px; font-size: var(--text-sm); }

  /* Stats */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .stat-card { padding: var(--space-3) var(--space-4); }
  .stat-card-value { font-size: var(--text-lg); }

  /* Toast */
  #toast-container {
    bottom: var(--space-3);
    right: var(--space-3);
    left: var(--space-3);
  }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  :root { --header-h: 52px; }
  .stat-grid,
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .abr-card { flex-direction: column; align-items: flex-start; }
  .abr-card-right { align-items: flex-start; width: 100%; }
  .page-header h1 { font-size: var(--text-lg); }
  .page-header h2 { font-size: var(--text-md); }
  .login-brand-headline { font-size: var(--text-xl); }
  .login-form-panel { padding: var(--space-5) var(--space-4); }
  .modal-header,
  .modal-body,
  .modal-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
}

@media (max-width: 375px) {
  .stat-grid,
  .stats-grid { grid-template-columns: 1fr; }
  .app-content-inner { padding: calc(var(--space-3) + 40px) var(--space-3) var(--space-4); }
}

/* ============================================================
   31. PRINT
   ============================================================ */
@media print {
  .app-sidebar,
  .sidebar-toggle,
  .sidebar-backdrop,
  .app-header,
  .tab-nav,
  .page-actions,
  .btn,
  .btn-primary,
  .btn-secondary,
  .btn-accent,
  .btn-danger,
  .btn-action,
  .btn-logout,
  .modal-footer,
  #toast-container,
  .filter-select,
  .archiv-filter-bar,
  .filter-bar { display: none !important; }

  body { background: white; font-size: 11pt; }
  .app-content { margin-left: 0 !important; }
  .app-content-inner,
  .view-content { padding: 0; max-width: 100%; }
  .table-card, .form-card, .dashboard-section, .card, .section-card { box-shadow: none; border: 1px solid #ccc; }
  .data-table thead tr,
  .posten-table thead tr,
  .detail-table thead tr {
    background: #333 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  a { color: inherit; text-decoration: none; }
  .stat-card { break-inside: avoid; }
}

/* ============================================================
   32. PRELOADER — Arc-Charge Reveal
   ============================================================ */
#preloader {
  position: fixed;
  inset: 0;
  background: #06101f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 99999;
  transition: opacity 0.65s 0.08s ease, visibility 0.65s 0.08s;
}
#preloader.loaded { opacity: 0; visibility: hidden; pointer-events: none; }
#preloader::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.016) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
}

/* Arc + icon container */
.pl-wrap {
  position: relative;
  width: 128px;
  height: 128px;
}
.pl-arc-svg {
  position: absolute;
  inset: 0;
  width: 128px;
  height: 128px;
  transform: rotate(-90deg);
  overflow: visible;
}
.pl-arc-bg {
  fill: none;
  stroke: rgba(255,255,255,.055);
  stroke-width: 2;
}
.pl-arc-fg {
  fill: none;
  stroke: #e8821a;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 0 346;
  animation: arc-charge 1.5s cubic-bezier(.35,.05,.55,1) forwards;
  filter: drop-shadow(0 0 5px rgba(232,130,26,.55));
}
@keyframes arc-charge {
  0%   { stroke-dasharray: 0 346; }
  88%  { stroke-dasharray: 330 346; }
  100% { stroke-dasharray: 346 346; }
}

/* Center bolt icon */
.pl-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pl-bolt-svg { width: 52px; height: 52px; overflow: visible; }
.pl-bolt-outline {
  fill: none;
  stroke: rgba(255,255,255,.1);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
/* Fills upward from bottom as arc completes */
.pl-bolt-fill {
  fill: #e8821a;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  filter: drop-shadow(0 0 10px rgba(232,130,26,.85)) drop-shadow(0 0 26px rgba(232,130,26,.35));
  animation: bolt-rise .48s .88s cubic-bezier(.4,0,.15,1) forwards;
}
@keyframes bolt-rise { to { transform: scaleY(1); } }

/* Radial glow burst when bolt fully lit */
.pl-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,130,26,.22) 0%, transparent 62%);
  opacity: 0;
  pointer-events: none;
  animation: glow-pop .26s 1.36s ease forwards, glow-fade .52s 1.62s ease forwards;
}
@keyframes glow-pop  { to   { opacity: 1; transform: scale(1.06); } }
@keyframes glow-fade { from { opacity: 1; } to { opacity: 0; transform: scale(1.28); } }

/* Text block */
.pl-text {
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  animation: pl-text-rise .4s 1.1s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes pl-text-rise { to { opacity: 1; transform: none; } }
.pl-name {
  display: block;
  font-size: .9rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.pl-sub {
  display: block;
  font-size: .58rem;
  font-weight: 500;
  color: rgba(255,255,255,.3);
  letter-spacing: .3em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Legacy selectors — kept for old HTML not yet updated */
.preloader-logo, .preloader-bolt, .preloader-track, .preloader-bar,
.preloader-name, .preloader-inner, .preloader-ring, .preloader-icon,
.preloader-bolt-svg, .bolt-stroke, .preloader-label, .preloader-sub,
.preloader-dots { display: none; }

/* ============================================================
   33. PAGE-HEADER ILLUSTRATIONS + COLOR ACCENTS
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding: 0 0 var(--space-5);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  position: relative;
  overflow: visible;
  box-shadow: none;
}
.page-header::before,
.page-header::after { display: none; }
.page-header h1,
.page-header h2 {
  font-size: clamp(1.2rem, 1.6vw, 1.625rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1.15;
  margin-bottom: var(--space-1);
}
.page-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.5;
}
.page-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Tab-content – direct child of .app-content (linda.html, no inner wrapper) */
.tab-content {
  padding: var(--space-6) var(--space-8);
  max-width: 1560px;
  width: 100%;
}
@media (max-width: 1400px) {
  .tab-content { padding: var(--space-6) var(--space-6); }
}
@media (max-width: 900px) {
  .tab-content { padding: var(--space-4) var(--space-4); }
}
/* Admin uses .app-content-inner which already has padding – avoid double-padding */
.app-content-inner .tab-content { padding: 0; }

@media (max-width: 768px) {
  .tab-content { padding: var(--space-4) var(--space-3); max-width: none; }
  .page-header { padding: var(--space-4) var(--space-4); }
  .page-header h1, .page-header h2 { font-size: var(--text-md); }
}

/* Colored section dividers */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.section-header-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  border: 1px solid var(--info-bg-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}
.section-header h3 {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.015em;
}

/* Enhanced stat-card color system */
.stat-card[style*="--card-accent:var(--primary)"] { background: linear-gradient(135deg, #fff 0%, #eff6ff 100%); }
.stat-card[style*="--card-accent:var(--danger)"]  { background: linear-gradient(135deg, #fff 0%, #fff5f5 100%); }
.stat-card[style*="--card-accent:var(--success)"] { background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%); }
.stat-card[style*="--card-accent:var(--accent)"]  { background: linear-gradient(135deg, #fff 0%, #fff7ed 100%); }
.stat-card[style*="--card-accent:var(--warning)"] { background: linear-gradient(135deg, #fff 0%, #fffbeb 100%); }

/* ============================================================
   34. ANALYTICS DASHBOARD
   ============================================================ */

.dash-header-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(15,52,96,.3);
  flex-shrink: 0;
}

.dash-date-chip {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* KPI Row */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
@media (max-width: 1280px) {
  .dash-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr !important; }
  .dash-card-full { grid-column: auto; }
}

.dash-kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: default;
  box-shadow: var(--shadow-sm);
}
.dash-kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--primary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dash-kpi-card::after {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--kpi-color, var(--primary));
  opacity: .04;
  pointer-events: none;
}
.dash-kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.dash-kpi-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--space-3);
}
.dash-kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--kpi-color, var(--primary)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--kpi-color, var(--primary)) 25%, transparent);
  display: flex; align-items: center; justify-content: center;
  color: var(--kpi-color, var(--primary));
  flex-shrink: 0;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--kpi-color, var(--primary)) 18%, transparent);
}
/* Fallback for browsers without color-mix */
@supports not (background: color-mix(in srgb, red, blue)) {
  .dash-kpi-icon { background: var(--info-bg); border-color: var(--info-bg-strong); color: var(--primary); }
}

.dash-sparkline { flex-shrink: 0; }

.dash-kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: var(--space-1);
}
.dash-kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.dash-kpi-delta {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-light);
  display: flex; align-items: center; gap: 3px;
}
.dash-kpi-delta.up   { color: var(--success); }
.dash-kpi-delta.down { color: var(--danger); }

/* Main grid */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
}
.dash-card-full { grid-column: 1 / -1; }

.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 1px 3px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.04);
  transition: box-shadow var(--transition), transform var(--transition);
}
.dash-card:hover {
  box-shadow: 0 4px 20px rgba(15,52,96,.1), 0 1px 4px rgba(15,23,42,.05);
  transform: translateY(-1px);
}

.dash-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.dash-card-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--primary);
  display: flex; align-items: center; gap: var(--space-2);
  letter-spacing: -.01em;
}
.dash-card-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--info-bg);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.dash-card-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.dash-activity-count {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-light);
}

/* Activity Feed */
.dash-activity {
  display: flex; flex-direction: column;
  max-height: 230px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.dash-activity-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.dash-activity-item:last-child { border-bottom: none; }
.dash-activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 5px;
}
.dash-activity-main { font-size: var(--text-sm); font-weight: 500; color: var(--text); }
.dash-activity-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* Sidebar search */
.sidebar-search {
  padding: 0 var(--space-3) var(--space-3);
}
.sidebar-search-input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: white;
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-search-input::placeholder { color: rgba(255,255,255,.35); }
.sidebar-search-input:focus {
  background: rgba(255,255,255,.11);
  border-color: rgba(255,255,255,.25);
}

/* Shortcut chip in nav */
.sidebar-shortcut {
  font-size: 10px;
  font-weight: 600;
  background: var(--border-subtle);
  color: var(--text-light);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  letter-spacing: .02em;
  font-family: 'SFMono-Regular', Consolas, monospace;
  border: 1px solid var(--border);
}

/* Sidebar footer extras */
.sidebar-shortcut-hint {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--text-light);
  font-size: var(--text-xs);
  background: none; border: none; cursor: pointer; width: 100%;
  text-align: left; border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.sidebar-shortcut-hint:hover { color: var(--text-muted); background: var(--border-subtle); }

.sidebar-clock {
  font-size: var(--text-xs);
  color: var(--text-light);
  text-align: center;
  padding: var(--space-1) var(--space-4) var(--space-2);
  font-variant-numeric: tabular-nums;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* Global Search */
.global-search-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9998; align-items: flex-start; justify-content: center;
  padding-top: 14vh;
}
.global-search-overlay.open { display: flex; }
.global-search-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 560px; max-width: 92vw; overflow: hidden;
  animation: modalIn 160ms cubic-bezier(.2,0,.13,1);
}
.global-search-input {
  width: 100%; padding: var(--space-4) var(--space-5);
  border: none; outline: none;
  font-size: var(--text-md); font-family: inherit; color: var(--text);
  background: transparent; border-bottom: 1px solid var(--border);
}
.global-search-results { max-height: 360px; overflow-y: auto; }
.global-search-result {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); cursor: pointer;
  transition: background var(--transition);
  border-left: 2px solid transparent;
}
.global-search-result:hover,
.global-search-result.focused { background: var(--info-bg); border-left-color: var(--primary); }
.global-search-result-icon {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--info-bg-strong); display: flex;
  align-items: center; justify-content: center;
  color: var(--primary); flex-shrink: 0;
}
.global-search-result-label { font-size: var(--text-base); font-weight: 600; color: var(--text); }
.global-search-result-sub { font-size: var(--text-xs); color: var(--text-muted); }
.global-search-footer {
  padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border);
  display: flex; gap: var(--space-4); align-items: center;
  font-size: var(--text-xs); color: var(--text-light);
  flex-wrap: wrap;
}
.kbd {
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 3px; padding: 1px 5px;
  font-family: 'SFMono-Regular', Consolas, monospace; font-size: 10px;
  color: var(--text-muted); font-weight: 600;
  box-shadow: 0 1px 0 var(--border-strong);
}

/* Shortcuts Panel */
.shortcuts-panel {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.55); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); z-index: 9999;
  align-items: center; justify-content: center;
}
.shortcuts-panel.open { display: flex; }
.shortcuts-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 440px; max-width: 90vw; padding: var(--space-6);
  animation: modalIn 160ms cubic-bezier(.2,0,.13,1);
}
.shortcuts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
}
.shortcut-item {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-sm); color: var(--text-muted);
  padding: var(--space-2) 0;
}
.shortcut-item span { flex: 1; }

/* Responsive */
@media (max-width: 1200px) {
  .dash-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-card-full { grid-column: 1; }
}
@media (max-width: 768px) {
  .dash-kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .dash-kpi-row { grid-template-columns: 1fr 1fr; }
  .dash-kpi-value { font-size: var(--text-xl); }
  .dash-grid { gap: var(--space-3); }
}

/* ============================================================
   35. TAB CONTENT POLISH – Premium UI Refinements
   ============================================================ */

/* ---- Page Header: refined visual bar ---- */
.page-header {
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
}
.page-header h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.025em;
  line-height: 1.2;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1.15;
}
.page-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}

/* ---- Filter selects: custom arrow + refined styling ---- */
.filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: white;
  color: var(--text);
  font-size: var(--text-base);
  font-family: inherit;
  font-weight: 500;
  height: 36px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  min-width: 140px;
}
.filter-select:hover { border-color: var(--border-strong); background-color: var(--bg); }
.filter-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background-color: white;
}

/* ---- Filter input: search icon treatment ---- */
.filter-input {
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
  color: var(--text);
  font-size: var(--text-base);
  font-family: inherit;
  height: 36px;
  min-width: 200px;
  flex: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-input::placeholder { color: var(--text-light); }
.filter-input:hover { border-color: var(--border-strong); }
.filter-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ---- Filter bar: refined container ---- */
.archiv-filter-bar,
.filter-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  margin-bottom: var(--space-4);
}

/* Filter bar inline – in .page-actions (no card wrapper needed) */
.page-actions .filter-select {
  margin: 0;
}

/* ---- Table card: refined ---- */
.table-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
  overflow: hidden;
}

/* ---- Table header: cleaner ---- */
.data-table thead tr {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  white-space: nowrap;
}

/* ---- Table rows: better height + hover ---- */
.data-table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  font-size: var(--text-base);
  color: var(--text);
  line-height: 1.4;
}
.data-table tbody tr {
  border-bottom: 1px solid rgba(226,232,240,.6);
  transition: background var(--transition);
}
.data-table tbody tr:nth-child(even) { background: rgba(248,250,252,.5); }
.data-table tbody tr:hover { background: #f0f6ff; }
.data-table tbody tr:last-child { border-bottom: none; }

/* ---- ID column: monospace pill ---- */
.data-table thead th:first-child,
.data-table tbody td:first-child {
  width: 58px;
  color: var(--text-light);
  font-size: 11px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  letter-spacing: .01em;
  padding-left: 16px;
}

/* ---- Last two columns: fixed for actions + status ---- */
.data-table thead th:last-child,
.data-table tbody td:last-child {
  width: 152px;
  white-space: normal;
  overflow: visible;
}
.data-table thead th:nth-last-child(2),
.data-table tbody td:nth-last-child(2) {
  width: 116px;
}

/* ---- Action buttons in tables: outlined pill style ---- */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
  transition: all var(--transition);
  line-height: 1.4;
  font-family: inherit;
  opacity: .85;
}
.btn-action:hover {
  opacity: 1;
  transform: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.btn-info  { color: var(--info);    border-color: rgba(37,99,235,.3);  background: var(--info-bg); }
.btn-info:hover  { background: var(--info-bg-strong); border-color: var(--info); }
.btn-pdf   { color: var(--danger);  border-color: rgba(220,38,38,.3);  background: var(--danger-bg); }
.btn-pdf:hover   { background: var(--danger-bg-strong); border-color: var(--danger); }
.btn-csv   { color: var(--success); border-color: rgba(22,163,74,.3);  background: var(--success-bg); }
.btn-csv:hover   { background: var(--success-bg-strong); border-color: var(--success); }
.btn-next  { color: var(--warning); border-color: rgba(217,119,6,.3);  background: var(--warning-bg); }
.btn-next:hover  { background: var(--warning-bg-strong); border-color: var(--warning); }

/* td-actions: better alignment */
.td-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* ---- Ampel rows: left accent stripe ---- */
.data-table tbody tr.ampel-rot  { box-shadow: inset 3px 0 0 var(--danger); }
.data-table tbody tr.ampel-gelb { box-shadow: inset 3px 0 0 var(--warning); }
.data-table tbody tr.ampel-gruen { box-shadow: inset 3px 0 0 var(--success); }

/* ---- Empty state in table ---- */
.table-empty {
  padding: 3rem var(--space-6);
  text-align: center;
  color: var(--text-muted);
}
.table-empty svg {
  width: 36px; height: 36px;
  color: var(--border-strong);
  margin-bottom: var(--space-3);
}

/* ---- Table footer count bar ---- */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: var(--text-sm);
  color: var(--text-muted);
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-footer-count { font-weight: 600; color: var(--text); }

/* ---- Inbox tab: improved item quality ---- */
.inbox-item {
  padding: var(--space-4) var(--space-5);
  gap: var(--space-4);
  border-left: 3px solid transparent;
}
.inbox-item-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.inbox-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  gap: var(--space-3);
}
.inbox-item-ampel {
  width: 9px;
  height: 9px;
}

/* ---- Responsive: stack filters on mobile ---- */
@media (max-width: 640px) {
  .archiv-filter-bar,
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-input,
  .filter-select { min-width: 0; width: 100%; }
  .page-header { flex-direction: column; gap: var(--space-3); }
  .page-actions { flex-wrap: wrap; }
}

/* ============================================================
   36. INBOX SECTIONS – Gruppierung nach Ampel
   ============================================================ */
.inbox-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  background: var(--bg); border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.inbox-section-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.inbox-section-rot   .inbox-section-dot { background: var(--danger);  box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.inbox-section-gelb  .inbox-section-dot { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.15); }
.inbox-section-gruen .inbox-section-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.inbox-section-rot   { color: var(--danger); }
.inbox-section-gelb  { color: var(--warning); }
.inbox-section-gruen { color: var(--success); }
.inbox-type-icon { display: inline-flex; align-items: center; line-height: 0; }

/* ============================================================
   37. VERWALTUNG SUB-NAV  (tab row below the header)
   ============================================================ */
.vw-subnav {
  position: sticky;
  top: var(--header-h);
  z-index: calc(var(--z-header) - 1);
  background: #fff;
  border-bottom: 1.5px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  flex-shrink: 0;
}
.vw-subnav::-webkit-scrollbar { display: none; }
.vw-subnav .tab-btn {
  background: none !important;
  border-radius: 0;
  color: var(--text-muted) !important;
  padding: 0 14px;
  height: 44px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: none !important;
}
.vw-subnav .tab-btn.active {
  color: var(--primary) !important;
  border-bottom-color: var(--primary) !important;
  font-weight: 600;
}
.vw-subnav .tab-btn:hover {
  background: rgba(15,52,96,.04) !important;
  color: var(--primary) !important;
}
@media (max-width: 768px) {
  .vw-subnav { padding: 0 var(--space-3); }
  .vw-subnav .tab-btn { padding: 0 10px; font-size: var(--text-xs); }
}

/* ============================================================
   38. PRÜF-STREAM – Innovative Inbox / Review Interface
   ============================================================ */
#tab-inbox { padding: 0; overflow: hidden; }

.pruef-stream {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h) - 56px);
  min-height: 500px;
  background: #f4f7fb;
  overflow: hidden;
}

/* Stats bar */
.ps-stats {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  row-gap: 6px;
}
.ps-stat-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 16px;
}
.ps-stat-item:first-child { padding-left: 0; }
.ps-stat-num {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}
.ps-stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ps-stat-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.ps-refresh-btn {
  margin-left: auto;
  padding: 5px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary);
  background: rgba(15,52,96,.06);
  border: 1px solid rgba(15,52,96,.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.ps-refresh-btn:hover { background: rgba(15,52,96,.12); }

/* Filter row */
.ps-filters {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.ps-filters::-webkit-scrollbar { display: none; }
.ps-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  transition: all 150ms;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.ps-pill:hover { border-color: var(--primary); color: var(--primary); }
.ps-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.ps-pill.a-rot.active   { background: #dc2626; border-color: #dc2626; }
.ps-pill.a-gelb.active  { background: #d97706; border-color: #d97706; }
.ps-pill.a-gruen.active { background: #16a34a; border-color: #16a34a; }
.ps-pill-div { width: 1px; height: 16px; background: var(--border); flex-shrink: 0; margin: 0 2px; }

/* Body: list + detail split */
.ps-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ---- Card list ---- */
.ps-list {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--border);
}
.ps-list-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.ps-card {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(0,0,0,.06);
  cursor: pointer;
  transition: background 120ms;
  position: relative;
}
.ps-card:hover { background: #f8fafc; }
.ps-card.selected { background: #eff5ff; }
.ps-card.selected::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}
.ps-card-strip {
  width: 3px;
  flex-shrink: 0;
  border-radius: 0 2px 2px 0;
}
.ps-card-strip.rot   { background: #dc2626; }
.ps-card-strip.gelb  { background: #d97706; }
.ps-card-strip.gruen { background: #16a34a; }

.ps-card-body { flex: 1; padding: 11px 13px; min-width: 0; }
.ps-card-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.ps-card-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.ps-card-date { font-size: 10px; color: var(--text-muted); opacity: .7; }
.ps-card-id {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-mono, monospace);
  margin-bottom: 2px;
}
.ps-card-obj {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ps-card-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}
.ps-card-chip.rot   { background: #fef2f2; color: #dc2626; }
.ps-card-chip.gelb  { background: #fffbeb; color: #d97706; }
.ps-card-chip.gruen { background: #f0fdf4; color: #16a34a; }
.ps-chip-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---- Detail panel ---- */
.ps-detail {
  flex: 1;
  overflow-y: auto;
  background: #f4f7fb;
  min-width: 0;
}
.ps-detail-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}
.ps-detail-empty svg { opacity: .18; }
.ps-detail-empty-title { font-size: .9rem; font-weight: 600; }
.ps-detail-empty-sub { font-size: .8rem; }

.ps-detail-content { padding: 22px 24px; max-width: 860px; }

/* Detail header */
.ps-dhead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.ps-dtitle { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin-bottom: 3px; }
.ps-dmeta  { font-size: var(--text-sm); color: var(--text-muted); }
.ps-ampel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.ps-ampel-badge.rot   { background: #fef2f2; color: #dc2626; border: 1.5px solid #fecaca; }
.ps-ampel-badge.gelb  { background: #fffbeb; color: #d97706; border: 1.5px solid #fde68a; }
.ps-ampel-badge.gruen { background: #f0fdf4; color: #16a34a; border: 1.5px solid #bbf7d0; }

/* Issues strip */
.ps-issues {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ps-issue { font-size: var(--text-xs); color: #92400e; display: flex; gap: 6px; align-items: flex-start; }

/* Data grid */
.ps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.ps-field-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.ps-field-value { font-size: var(--text-sm); font-weight: 600; color: var(--text); word-break: break-word; }

/* Note area */
.ps-note-wrap { margin-bottom: 16px; }
.ps-note-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 5px;
  display: block;
}
.ps-note {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: var(--text-sm);
  resize: vertical;
  min-height: 56px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  box-sizing: border-box;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ps-note:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(15,52,96,.1); }

/* Action buttons */
.ps-actions {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.ps-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 150ms, transform 120ms, box-shadow 150ms;
}
.ps-btn:active { transform: scale(.97); }
.ps-btn-approve { background: #16a34a; color: #fff; }
.ps-btn-approve:hover { background: #15803d; box-shadow: 0 3px 10px rgba(22,163,74,.3); }
.ps-btn-revise { background: #fffbeb; color: #92400e; border: 1.5px solid #fde68a; }
.ps-btn-revise:hover { background: #fef3c7; border-color: #d97706; }
.ps-btn-reject { background: #fef2f2; color: #991b1b; border: 1.5px solid #fecaca; }
.ps-btn-reject:hover { background: #fee2e2; border-color: #f87171; }

/* Mobile */
@media (max-width: 768px) {
  .pruef-stream { height: auto; min-height: auto; }
  .ps-body { flex-direction: column; }
  .ps-list { width: 100%; max-height: 44vh; border-right: none; border-bottom: 1px solid var(--border); }
  .ps-detail { min-height: 50vh; }
  .ps-grid { grid-template-columns: repeat(2, 1fr); }
  .ps-detail-content { padding: 14px 16px; }
  .ps-stats { gap: 0; }
  .ps-stat-item { padding: 0 10px; }
  .ps-stat-num { font-size: 1.1rem; }
}

/* ============================================================
   39. DARK MODE
   ============================================================ */
:root {
  --dm-transition: background 200ms, color 200ms, border-color 200ms, box-shadow 200ms;
}

html.dark {
  --bg:               #0f172a;
  --card:             #1e293b;
  --border:           #334155;
  --border-subtle:    #1e293b;
  --border-strong:    #475569;
  --text:             #f1f5f9;
  --text-muted:       #94a3b8;
  --text-light:       #64748b;
  --sidebar-bg:       #0a1929;
  --sidebar-hover:    #162a45;
  --sidebar-active:   #1e3a5f;
  --success-bg:       #052e16;
  --success-bg-strong:#14532d;
  --warning-bg:       #1c1002;
  --warning-bg-strong:#422006;
  --danger-bg:        #1c0505;
  --danger-bg-strong: #450a0a;
  --info-bg:          #071828;
  --info-bg-strong:   #0c2244;
}

html.dark body,
html.dark .app-content,
html.dark .tab-content {
  background: var(--bg);
  color: var(--text);
}

html.dark .table-card,
html.dark .form-card,
html.dark .dash-card,
html.dark .dash-kpi-card,
html.dark .modal-box,
html.dark .section-card,
html.dark .card {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

html.dark .data-table thead tr {
  background: #162032;
}
html.dark .data-table thead th {
  color: var(--text-muted);
  border-color: var(--border);
}
html.dark .data-table tbody tr:hover {
  background: rgba(255,255,255,.03);
}
html.dark .data-table tbody td {
  border-color: var(--border-subtle);
  color: var(--text);
}

html.dark .filter-select,
html.dark .filter-input,
html.dark input[type="text"],
html.dark input[type="email"],
html.dark input[type="number"],
html.dark input[type="date"],
html.dark textarea,
html.dark select {
  background: #162032;
  border-color: var(--border);
  color: var(--text);
  color-scheme: dark;
}

html.dark .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-color: #162032;
}

html.dark .btn-secondary {
  background: #1e293b;
  border-color: var(--border);
  color: var(--text);
}
html.dark .btn-secondary:hover { background: #273548; }

html.dark .page-header {
  border-color: var(--border);
}

html.dark code {
  background: #162032;
  color: #93c5fd;
}

html.dark .archiv-filter-bar,
html.dark .filter-bar {
  background: var(--card);
  border-color: var(--border);
}

html.dark .badge { opacity: .9; }

html.dark .ps-detail { background: #0f1c2e; }
html.dark .ps-grid { background: var(--card); border-color: var(--border); }
html.dark .ps-note { background: #162032; border-color: var(--border); color: var(--text); }
html.dark .ps-issues { background: #1c1002; border-color: #713f12; }
html.dark .ps-issue { color: #fde68a; }
html.dark .ps-detail-empty { color: var(--text-muted); }
html.dark .ps-btn-revise { background: #1c1002; border-color: #713f12; color: #fde68a; }
html.dark .ps-btn-reject { background: #1c0505; border-color: #7f1d1d; color: #fca5a5; }

/* Dark Mode Toggle Button */
.dark-mode-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: rgba(255,255,255,.55);
  font-size: var(--text-xs);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  font-family: inherit;
}
.dark-mode-toggle:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.06); }
.dark-mode-toggle .dm-icon-moon  { display: block; }
.dark-mode-toggle .dm-icon-sun   { display: none; }
html.dark .dark-mode-toggle .dm-icon-moon { display: none; }
html.dark .dark-mode-toggle .dm-icon-sun  { display: block; }

/* ============================================================
   40. DATATABLE ENGINE STYLES
   ============================================================ */
.dt-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 20px !important;
}
.dt-sortable::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(148,163,184,.4);
  transition: border-color 150ms;
}
.dt-sortable:hover::after { border-top-color: var(--text-muted); }
.dt-sort-asc::after  {
  border-top: none;
  border-bottom: 5px solid var(--primary);
}
.dt-sort-desc::after { border-top-color: var(--primary); }

/* Row states */
.tr-ampel-rot  td { border-left: 3px solid #dc2626 !important; }
.tr-ampel-gelb td { border-left: 3px solid #d97706 !important; }
.dt-row-selected td { background: var(--info-bg) !important; }
html.dark .dt-row-selected td { background: rgba(37,99,235,.08) !important; }

/* Checkbox cells */
.dt-cb-head, .dt-cb-cell {
  width: 36px !important;
  padding: 8px 10px !important;
  text-align: center;
}
.dt-cb-cell input, .dt-cb-head input {
  cursor: pointer;
  accent-color: var(--primary);
}

/* Empty state */
.dt-empty { padding: 48px 16px !important; }
.dt-empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: var(--text-base);
  font-weight: 500;
}

/* Footer aggregate bar */
.dt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}
.dt-footer-count { color: var(--text-muted); font-weight: 500; }
.dt-footer-sums  { display: flex; gap: var(--space-5); flex-wrap: wrap; }
.dt-footer-item  { display: flex; align-items: center; gap: 5px; }
.dt-footer-label { color: var(--text-muted); }
.dt-footer-item strong { color: var(--primary); font-variant-numeric: tabular-nums; font-weight: 700; }
html.dark .dt-footer { background: #162032; border-color: var(--border); }

/* Bulk action bar */
.dt-bulk-bar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--info-bg);
  border: 1px solid var(--info-bg-strong);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  animation: fadeIn 150ms ease;
}
.dt-bulk-bar.dt-bulk-active { display: flex; }
.dt-bulk-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}
html.dark .dt-bulk-bar { background: #0c2244; border-color: var(--border); }

/* Table search input styling inside table-card */
.table-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.table-search {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-family: inherit;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  color: var(--text);
  transition: border-color 150ms, box-shadow 150ms;
}
.table-search:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(15,52,96,.08); }
html.dark .table-search { background-color: #162032; border-color: var(--border); }

.table-counter { font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   41. COMMAND PALETTE
   ============================================================ */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99990;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.cmd-overlay.cmd-visible {
  opacity: 1;
  pointer-events: auto;
}

.cmd-modal {
  width: 580px;
  max-width: 94vw;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(15,23,42,.35), 0 4px 16px rgba(15,23,42,.2);
  overflow: hidden;
  transform: translateY(-8px) scale(.98);
  transition: transform 150ms cubic-bezier(.2,0,.13,1);
}
.cmd-overlay.cmd-visible .cmd-modal {
  transform: translateY(0) scale(1);
}

.cmd-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-search-icon { color: var(--text-muted); flex-shrink: 0; }
.cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-esc-hint {
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, monospace;
}

.cmd-list {
  list-style: none;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 16px;
  cursor: pointer;
  transition: background 100ms;
  border-left: 2px solid transparent;
}
.cmd-item.cmd-active,
.cmd-item:hover {
  background: var(--info-bg);
  border-left-color: var(--primary);
}
html.dark .cmd-item.cmd-active { background: rgba(37,99,235,.1); }
.cmd-item-icon { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.cmd-item-label { flex: 1; font-size: var(--text-base); font-weight: 500; color: var(--text); }
.cmd-item-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmd-item-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-light);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.cmd-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-base);
}

.cmd-footer {
  display: flex;
  gap: var(--space-5);
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-light);
}
.cmd-footer kbd {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
  box-shadow: 0 1px 0 var(--border-strong);
  margin-right: 4px;
}

/* Trigger button in sidebar footer */
.cmd-trigger-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: rgba(255,255,255,.45);
  font-size: var(--text-xs);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: background 150ms, color 150ms;
  justify-content: space-between;
}
.cmd-trigger-btn:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.8); }
.cmd-trigger-kbd {
  font-size: 10px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* ============================================================
   42. DRAFT SAVE BANNER
   ============================================================ */
.draft-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--info-bg);
  border: 1px solid var(--info-bg-strong);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--primary);
  animation: fadeIn 200ms ease;
  flex-wrap: wrap;
}
html.dark .draft-banner { background: #071828; border-color: #0c2244; }
.draft-banner svg { color: var(--primary); flex-shrink: 0; }
.draft-banner span { flex: 1; font-weight: 500; }
.draft-btn-restore {
  padding: 5px 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms;
}
.draft-btn-restore:hover { background: var(--primary-hover); }
.draft-btn-discard {
  padding: 5px 14px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 150ms, color 150ms;
}
.draft-btn-discard:hover { background: var(--border-subtle); color: var(--text); }

.draft-saved-indicator {
  font-size: var(--text-xs);
  color: var(--success);
  font-weight: 600;
  opacity: 0;
  transition: opacity 300ms;
  display: block;
  margin-bottom: var(--space-2);
}
.draft-saved-indicator.visible { opacity: 1; }

/* ============================================================
   43. ARCHIV / SOFT-DELETE UI
   ============================================================ */
.btn-archive {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-bg-strong);
}
.btn-archive:hover { background: var(--warning-bg-strong); }

.btn-restore {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bg-strong);
}
.btn-restore:hover { background: var(--success-bg-strong); }

/* Archived row indicator */
.tr-archived td {
  opacity: .5;
  text-decoration: line-through;
  text-decoration-color: rgba(148,163,184,.4);
}
.tr-archived td:last-child { text-decoration: none; opacity: 1; }

/* Archive count chip */
.archive-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-bg-strong);
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 150ms;
}
.archive-count-chip:hover { background: var(--warning-bg-strong); }
html.dark .archive-count-chip { background: #1c1002; border-color: #713f12; color: #fde68a; }
