/**
 * ARGUS Dashboard
 * Stiftungsamt Aschaffenburg
 * Design inspiriert von stiftungsamt.de
 */

:root {
  /* Farbpalette - würdevoll, behördlich */
  --color-primary: #1a365d;
  --color-primary-light: #2c5282;
  --color-primary-dark: #0f2744;
  --color-accent: #b8860b;
  --color-accent-light: #d4a84b;
  --color-accent-muted: rgba(184, 134, 11, 0.15);
  
  --color-bg: #f8f7f4;
  --color-bg-card: #ffffff;
  --color-bg-header: #1a365d;
  
  --color-text: #2d3748;
  --color-text-muted: #718096;
  --color-text-light: #e2e8f0;
  
  --color-border: #e2e8f0;
  --color-border-focus: #2c5282;
  
  --color-success: #276749;
  --color-success-bg: #c6f6d5;
  --color-error: #c53030;
  --color-error-bg: #fed7d7;
  --color-warning: #b7791f;
  --color-warning-bg: #feebc8;
  
  --shadow-sm: 0 1px 2px rgba(26, 54, 93, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(26, 54, 93, 0.08), 0 2px 4px -2px rgba(26, 54, 93, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(26, 54, 93, 0.08), 0 4px 6px -4px rgba(26, 54, 93, 0.04);
  
  --radius: 6px;
  --radius-lg: 10px;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
}

/* Dark Mode – verbesserter Kontrast */
[data-theme="dark"] {
  --color-primary: #6b9de8;
  --color-primary-light: #8ab4f0;
  --color-primary-dark: #0f2744;
  --color-accent: #e5b84d;
  --color-accent-light: #ecc878;
  --color-accent-muted: rgba(229, 184, 77, 0.25);
  --color-bg: #15181e;
  --color-bg-card: #1e2229;
  --color-bg-header: #1a365d;
  --color-text: #e8ecf2;
  --color-text-muted: #b8c5d6;
  --color-text-light: #e8ecf2;
  --color-border: #3d4554;
  --color-border-focus: #6b9de8;
  --color-success: #5dd68a;
  --color-success-bg: #1e4d32;
  --color-error: #f89898;
  --color-error-bg: #5c2424;
  --color-warning: #f0d050;
  --color-warning-bg: #5c4510;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .login-bg-pattern {
  background: linear-gradient(135deg, #0f2744 0%, #1a365d 100%);
}

[data-theme="dark"] .login-container {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}

[data-theme="dark"] .login-header {
  background: linear-gradient(180deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
}

[data-theme="dark"] .login-form label {
  color: var(--color-text-muted);
}

[data-theme="dark"] .login-footer {
  color: var(--color-text-muted);
}

[data-theme="dark"] .main-header {
  background: var(--color-bg-header);
  border-bottom-color: var(--color-border);
}

[data-theme="dark"] .card {
  background: var(--color-bg-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .card-header {
  background: #2d3748;
  border-color: var(--color-border);
}

[data-theme="dark"] .card-body {
  color: var(--color-text);
}

[data-theme="dark"] .data-table {
  background: var(--color-bg-card);
  color: var(--color-text);
}

[data-theme="dark"] .data-table th {
  background: #2d3748;
  color: var(--color-text);
}

[data-theme="dark"] .data-table td {
  color: var(--color-text);
}

[data-theme="dark"] .data-table tbody tr {
  background: var(--color-bg-card);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) {
  background: #2d3748;
}

[data-theme="dark"] .data-table tr:hover,
[data-theme="dark"] .data-table tbody tr:nth-child(even):hover {
  background: #374151;
}

[data-theme="dark"] .accordion-header {
  background: #2d3748;
  border-color: var(--color-border);
}

[data-theme="dark"] .accordion-header:hover {
  background: #374151;
}

[data-theme="dark"] .accordion-item {
  background: var(--color-bg-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .accordion-body > div {
  border-color: var(--color-border);
}

[data-theme="dark"] .dashboard-nav-arrow {
  background: linear-gradient(180deg, #252a33 0%, #1e2229 100%);
  color: var(--color-primary);
  border-color: var(--color-border);
}
[data-theme="dark"] .dashboard-nav-arrow:hover:not(:disabled) {
  background: linear-gradient(180deg, #2d3440 0%, #252a33 100%);
  color: var(--color-primary-light);
  box-shadow: inset 0 0 0 1px rgba(107, 157, 232, 0.2);
}
[data-theme="dark"] .dashboard-nav-arrow:disabled,
[data-theme="dark"] .dashboard-nav-arrow-disabled {
  color: var(--color-text-muted);
}
[data-theme="dark"] .accordion-detail-grid {
  background: var(--color-bg-card);
}

[data-theme="dark"] .accordion-wohnbereiche {
  background: #252830;
}

[data-theme="dark"] .accordion-detail-table,
[data-theme="dark"] .accordion-bereiche-table,
[data-theme="dark"] .berechnung-table {
  background: transparent;
}

[data-theme="dark"] .accordion-detail-table td,
[data-theme="dark"] .accordion-bereiche-table td,
[data-theme="dark"] .berechnung-table td {
  color: var(--color-text);
}

[data-theme="dark"] .accordion-bereiche-table th {
  background: #2d3748;
  color: var(--color-text);
}

[data-theme="dark"] .berechnung-table th {
  background: #2d3748;
  color: var(--color-text);
}

[data-theme="dark"] .modal-content {
  background: var(--color-bg-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .form-inline select,
[data-theme="dark"] .form-inline input,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #2d3748;
  border-color: var(--color-border);
  color: var(--color-text);
}

[data-theme="dark"] .form-inline label,
[data-theme="dark"] .form-group label {
  color: var(--color-text-muted);
}

[data-theme="dark"] .btn {
  border-color: var(--color-border);
}

[data-theme="dark"] .btn-outline {
  background: transparent;
  color: var(--color-text-muted);
}

[data-theme="dark"] .btn-outline:hover {
  background: #374151;
  color: var(--color-text);
}

[data-theme="dark"] .main-header .btn-outline {
  color: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.5);
  background: transparent;
}
[data-theme="dark"] .main-header .btn-outline:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

[data-theme="dark"] .page-header-actions .btn-outline {
  color: var(--color-primary);
}

[data-theme="dark"] .page-header-actions .btn-outline:hover {
  background: rgba(91, 140, 222, 0.2);
}

[data-theme="dark"] .dashboard-subnav {
  background: #252830;
  border-color: var(--color-border);
}

[data-theme="dark"] .dashboard-subnav a {
  color: var(--color-text-muted);
}

[data-theme="dark"] .dashboard-subnav a:hover {
  color: var(--color-text);
}

[data-theme="dark"] .dashboard-subnav a.active {
  color: white;
  background: var(--color-primary);
}

[data-theme="dark"] .main-footer {
  background: #252830;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

[data-theme="dark"] .kalenderwochen-header {
  background: transparent;
}

[data-theme="dark"] .kalenderwochen-header:hover {
  background: #2d3748;
}

[data-theme="dark"] .kalenderwochen-accordion .accordion-item:nth-child(even) .kalenderwochen-header {
  background: #2d3748;
}

[data-theme="dark"] .kalenderwochen-accordion .accordion-item:nth-child(even) .kalenderwochen-header:hover {
  background: #374151;
}

[data-theme="dark"] .kalenderwochen-accordion .accordion-body > div {
  background: #1a1d24;
}

[data-theme="dark"] .flatpickr-calendar {
  background: var(--color-bg-card);
  border-color: var(--color-border);
}

[data-theme="dark"] .flatpickr-day {
  color: var(--color-text);
}

[data-theme="dark"] .flatpickr-day:hover {
  background: #374151;
}

[data-theme="dark"] .flatpickr-months .flatpickr-month {
  background: var(--color-primary);
}

[data-theme="dark"] .flatpickr-current-month {
  color: white;
}

[data-theme="dark"] .jugendhilfe-quartal-card .card-header {
  background: #3d3520;
  color: var(--color-accent);
  border-color: #5c4a20;
}

[data-theme="dark"] .jugendhilfe-quartal-card .card-body thead th {
  background: #374151;
  color: var(--color-text);
}

[data-theme="dark"] .jugendhilfe-quartal-card .card-body tbody td {
  color: var(--color-text);
}

[data-theme="dark"] .jugendhilfe-quartal-card .card-body tbody tr.accordion-gesamt td {
  background: rgba(91, 140, 222, 0.15);
}

[data-theme="dark"] .jugendhilfe-belegtage-table th,
[data-theme="dark"] .jugendhilfe-belegtage-table td {
  color: var(--color-text);
}

[data-theme="dark"] .section-title {
  color: var(--color-text);
}

[data-theme="dark"] .page-header h1 {
  color: var(--color-primary);
}

[data-theme="dark"] .card-header h2 {
  color: var(--color-primary);
}

[data-theme="dark"] .stichtag-tbody-1 {
  background: #252830;
}

[data-theme="dark"] .stichtag-tbody-2 {
  background: var(--color-bg-card);
}

[data-theme="dark"] .form-group input:disabled {
  background: #374151;
  color: var(--color-text-muted);
}

[data-theme="dark"] .belegung-row.belegung-gesamt {
  background: #2d3748;
}

[data-theme="dark"] .parameter-quoten-label,
[data-theme="dark"] .parameter-pers-label {
  background: #2d3748;
  color: var(--color-text);
}

[data-theme="dark"] .formel-variablen-bar {
  background: #252830;
}

[data-theme="dark"] .accordion-hint code {
  background: #2d3748;
}

/* Chart.js Dark Mode */
[data-theme="dark"] {
  --chart-color: #cbd5e0;
}

* {
  box-sizing: border-box;
}

/* Barrierefreiheit: Sichtbarer Fokus für Tastaturbedienung */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

/* ========== Login Page ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  /* Nicht hidden: sonst kein Scroll bei langen Formularen (z. B. erfassung.php) */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1rem;
  box-sizing: border-box;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 40px,
      rgba(255,255,255,0.02) 40px,
      rgba(255,255,255,0.02) 80px
    );
  z-index: 0;
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  margin: 2rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  /* visible: Inhalt darf die Kartenhöhe bestimmen (Scroll auf .login-page) */
  overflow: visible;
  flex-shrink: 0;
}

.login-header {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  padding: 2.5rem 2rem;
  text-align: center;
}

.logo-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: var(--color-accent);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.login-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
}

.login-header .subtitle {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  opacity: 0.9;
}

.login-form-wrapper {
  padding: 2rem;
}

.login-form .form-group {
  margin-bottom: 1.25rem;
}

.login-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.login-form input:focus,
.login-form input:focus-visible {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.login-form .btn {
  margin-top: 0.5rem;
}

.login-link {
  color: var(--color-primary);
  text-decoration: none;
}
.login-link:hover {
  text-decoration: underline;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.alert-info {
  background: color-mix(in srgb, var(--color-primary, #2563eb) 12%, var(--color-bg-card, #fff));
  color: var(--color-text, #1e293b);
  border: 1px solid color-mix(in srgb, var(--color-primary, #2563eb) 35%, transparent);
}

/* ========== Main Layout ========== */
.main-header {
  background: var(--color-bg-header);
  color: white;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.main-header .header-inner {
  position: relative;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: var(--color-accent);
  border-radius: 6px;
}

.logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}

.main-nav {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.main-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  transition: all 0.2s;
}

.main-nav a:hover {
  color: white;
  background: rgba(255,255,255,0.1);
}

.main-nav a.active {
  color: white;
  background: var(--color-accent);
}

/* Pflege-Dropdown */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-trigger {
  display: inline-block;
  color: rgba(255,255,255,0.85);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-dropdown-trigger:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}
.nav-dropdown:hover .nav-dropdown-trigger,
.nav-dropdown.active .nav-dropdown-trigger {
  color: white;
  background: rgba(255,255,255,0.1);
}
.nav-dropdown.active .nav-dropdown-trigger {
  background: var(--color-accent);
}
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  margin-top: 0.25rem;
  padding: 0.5rem 0;
  background: var(--color-bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
  z-index: 100;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1.25rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  border-radius: 0;
  background: transparent;
}
.nav-dropdown-menu a:hover {
  background: var(--color-accent-muted);
  color: var(--color-primary);
}
.nav-dropdown-menu a.active {
  background: var(--color-accent-muted);
  color: var(--color-primary);
  font-weight: 500;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.header-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  line-height: 1.2;
}

.theme-toggle-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.theme-toggle-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  background: var(--color-bg-card);
  color: var(--color-text);
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-size: 1.4rem;
  z-index: 50;
  transition: transform 0.2s, box-shadow 0.2s;
}
.theme-toggle-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .theme-toggle-fab {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
}

.user-name {
  font-weight: 500;
}

.user-role {
  opacity: 0.8;
  font-size: 0.85rem;
}

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.dashboard-subnav {
  background: #f1f5f9;
  border-bottom: 1px solid var(--color-border);
}

.subnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.dashboard-subnav a {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  color: var(--color-primary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.dashboard-subnav a:hover {
  background: rgba(26, 54, 93, 0.08);
}

.dashboard-subnav a.active {
  background: var(--color-primary);
  color: white;
}

.main-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.main-footer p {
  margin: 0;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-light);
}

.btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.6);
}

.btn-outline:hover {
  background: rgba(255,255,255,0.1);
  border-color: white;
}

.main-content .btn-outline {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.main-content .btn-outline:hover {
  background: var(--color-accent-muted);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover {
  background: #9b2c2c;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ========== Page Header ========== */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-primary);
}

.page-header .lead {
  margin: 0.5rem 0 0;
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

/* ========== Cards ========== */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-primary);
}

.card-body {
  padding: 1.5rem;
}

.badge {
  background: var(--color-primary);
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ========== Dashboard ========== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card-stat .card-body {
  padding: 1.25rem;
}

.card-stat h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-unit {
  font-size: 1rem;
  font-weight: 400;
  color: var(--color-text-muted);
}

.stat-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  margin: 0.75rem 0 0.25rem;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.stat-meta, .stat-date {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }

.chart-section {
  margin-bottom: 1.5rem;
}

.chart-container {
  position: relative;
  height: 320px;
}

.chart-container.chart-bar {
  height: 280px;
}

.chart-container.chart-wohnbereich {
  height: auto;
  min-height: 200px;
}

/* Jugendhilfe Dashboard */
.jugendhilfe-einrichtung-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
}

.jugendhilfe-charts {
  margin-bottom: 1.5rem;
}

.jugendhilfe-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .jugendhilfe-chart-row {
    grid-template-columns: 1fr;
  }
}

.jugendhilfe-quartale-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .jugendhilfe-quartale-grid {
    grid-template-columns: 1fr;
  }
}

.jugendhilfe-quartal-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.jugendhilfe-quartal-card .card-header {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  border-bottom: 1px solid #fcd34d;
}

.jugendhilfe-quartal-card .card-body table {
  width: 100%;
  border-collapse: collapse;
}

.jugendhilfe-quartal-card .card-body thead th {
  background: #4a5568;
  color: white;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
}

.jugendhilfe-quartal-card .card-body thead th:not(:first-child) {
  text-align: right;
}

.jugendhilfe-quartal-card .card-body tbody td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.jugendhilfe-quartal-card .card-body tbody td:not(:first-child) {
  text-align: right;
}

.jugendhilfe-quartal-card .card-body tbody tr.accordion-gesamt td {
  font-weight: 600;
  background: rgba(26, 54, 93, 0.04);
  border-bottom: none;
}

.jugendhilfe-belegtage-table {
  min-width: 720px;
  width: 100%;
}

.jugendhilfe-belegtage-table th,
.jugendhilfe-belegtage-table td {
  padding: 0.5rem 0.75rem;
}

.jugendhilfe-delta-col {
  white-space: nowrap;
  min-width: 4.5rem;
}

.section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-primary);
}

.wohnbereich-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.wohnbereich-card .card-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.wohnbereich-stats {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wohnbereich-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.wohnbereich-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
}

.wohnbereich-name {
  font-weight: 500;
}

.wohnbereich-zahl {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.wohnbereich-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.wohnbereich-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.stichtag-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stichtag-cards-5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1200px) {
  .stichtag-cards-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .stichtag-cards-5 { grid-template-columns: 1fr; }
}

.section-link {
  margin: -0.5rem 0 1rem;
  font-size: 0.95rem;
}

.section-link a {
  color: var(--color-primary);
  text-decoration: none;
}

.section-link a:hover {
  text-decoration: underline;
}

.stichtag-card .card-header h3 {
  margin: 0;
  font-size: 1rem;
}

.stichtag-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stichtag-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-border);
}

.stichtag-row.stichtag-subsection {
  font-weight: 600;
  color: var(--color-primary);
  margin-top: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.stichtag-row.stichtag-subsection:first-of-type {
  margin-top: 0;
}

.stichtag-row.stichtag-gesamt {
  border-bottom: none;
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-top: 0.25rem;
}

/* Stichtagsbelegung: Einrichtung als Karte mit Tabelle – kompakt */
.stichtag-einrichtung-card {
  margin-bottom: 1.25rem;
}

.stichtag-einrichtung-card:last-child {
  margin-bottom: 0;
}

.stichtag-einrichtung-card .card-header {
  padding: 0.6rem 1rem;
}

.stichtag-einrichtung-card .card-header h3 {
  font-size: 1rem;
  margin: 0;
}

.stichtag-einrichtung-card .card-body {
  padding: 0.75rem 1rem;
}

.stichtag-einrichtung-table {
  font-size: 0.8rem;
}

.stichtag-einrichtung-table th,
.stichtag-einrichtung-table td {
  padding: 0.12rem 0.4rem;
  line-height: 1.25;
  border-bottom: 1px solid var(--color-border);
}

.stichtag-einrichtung-table th:not(:first-child),
.stichtag-einrichtung-table td:not(:first-child) {
  text-align: center;
  min-width: 2.5rem;
}

.stichtag-einrichtung-table th {
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.stichtag-einrichtung-table .stichtag-label {
  font-weight: 500;
  color: var(--color-text);
  min-width: 100px;
  font-size: 0.8rem;
}

.stichtag-einrichtung-table tr.stichtag-gesamt td {
  font-weight: 600;
  color: var(--color-primary);
  border-top: 1px solid var(--color-border);
  padding-top: 0.2rem;
}

/* Optische Trennung: 2 Tabellenbereiche */
.stichtag-tbody-1 {
  background: #fafbfc;
}

.stichtag-tbody-2 {
  background: #fff;
}

.stichtag-tbody-1 tr:last-child td {
  padding-bottom: 0.6rem;
}

.stichtag-tbody-2 tr:first-child td {
  border-top: 2px solid var(--color-primary);
  padding-top: 0.4rem;
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.form-group input:disabled {
  background: #f1f5f9;
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.form-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-inline input,
.form-inline select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.form-section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
}
.form-section-title:first-of-type {
  margin-top: 0;
}

.form-inline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
}

/* Fest 2 Spalten (z. B. Jugendhilfe: Plätze | Ist pro Zeile) */
.form-inline-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 480px) {
  .form-inline-grid--2 {
    grid-template-columns: 1fr;
  }
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 480px;
}

.form-stack .form-group {
  margin-bottom: 0;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
}

.input-narrow {
  max-width: 120px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.form-actions {
  margin-top: 2rem;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.col-checkbox {
  width: 1%;
  white-space: nowrap;
  padding-right: 0.5rem;
}

/* ========== Data Table ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--color-primary);
}

.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.data-table tr:hover {
  background: #f1f5f9;
}

.data-table tbody tr:nth-child(even):hover {
  background: #e2e8f0;
}

.data-table tr.disabled {
  opacity: 0.6;
}

.data-table .actions {
  white-space: nowrap;
}

.data-table .actions form {
  display: inline;
}

.data-table .actions .btn {
  margin-right: 0.25rem;
}

/* ========== Benutzerverwaltung (Admin) ========== */
.admin-page-users .card-subtle {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  font-weight: 400;
  line-height: 1.4;
}

.admin-page-users .card-header-row > div {
  flex: 1;
  min-width: 0;
}

.admin-page-users .card-body-tight-top {
  padding-top: 1rem;
}

.admin-page-users .form-users-create {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
  align-items: end;
}

.admin-page-users .form-users-create .form-group-full {
  grid-column: 1 / -1;
}

.admin-page-users .form-users-create-submit {
  margin-top: 0.25rem;
}

.admin-page-users .checkbox-group-roles {
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.admin-page-users .checkbox-group-scroll {
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-page-users .users-admin-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.admin-page-users .user-admin-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  margin-bottom: 0.85rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.admin-page-users .user-admin-card:last-child {
  margin-bottom: 0;
}

.admin-page-users .user-admin-card--inactive {
  opacity: 0.72;
}

.admin-page-users .user-admin-card__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.admin-page-users .user-admin-card__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}

.admin-page-users .user-admin-card__username {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.admin-page-users .user-admin-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.admin-page-users .user-admin-badge--ok {
  background: rgba(39, 103, 73, 0.15);
  color: #276749;
}

.admin-page-users .user-admin-badge--off {
  background: rgba(113, 128, 150, 0.2);
  color: var(--color-text-muted);
}

.admin-page-users .user-admin-dl {
  margin: 0.65rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.admin-page-users .user-admin-dl__row {
  display: grid;
  grid-template-columns: minmax(5.5rem, 7rem) 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.9rem;
  align-items: start;
}

.admin-page-users .user-admin-dl dt {
  margin: 0;
  font-weight: 600;
  color: var(--color-text-muted);
}

.admin-page-users .user-admin-dl dd {
  margin: 0;
  word-break: break-word;
  line-height: 1.45;
  color: var(--color-text);
}

.admin-page-users .user-admin-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.admin-page-users .user-admin-action-form {
  margin: 0;
}

.admin-page-users .user-admin-action-form .btn {
  width: 100%;
}

@media (min-width: 768px) {
  .admin-page-users .user-admin-card {
    grid-template-columns: 1fr minmax(9.5rem, 11rem);
    align-items: start;
  }

  .admin-page-users .user-admin-card__actions {
    padding-top: 0.15rem;
    border-left: 1px solid var(--color-border);
    padding-left: 1rem;
    margin-left: 0.25rem;
  }
}

[data-theme="dark"] .admin-page-users .user-admin-card {
  background: var(--color-bg-card);
  box-shadow: none;
}

[data-theme="dark"] .admin-page-users .user-admin-badge--ok {
  background: rgba(72, 187, 120, 0.2);
  color: #9ae6b4;
}

[data-theme="dark"] .admin-page-users .user-admin-badge--off {
  background: rgba(160, 174, 192, 0.15);
  color: var(--color-text-muted);
}

[data-theme="dark"] .admin-page-users .checkbox-group-scroll {
  background: #2d3748;
}

/* ========== Admin: Einstellungen, Backup, Einrichtungen (gemeinsam) ========== */
.admin-page-settings .card-subtle,
.admin-page-backup .card-subtle,
.admin-page-einrichtungen .card-subtle {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  font-weight: 400;
  line-height: 1.4;
}

.admin-page-settings .settings-card,
.admin-page-backup .settings-card {
  margin-bottom: 1.5rem;
}

.admin-page-settings .admin-form-grid,
.admin-page-backup .admin-form-grid,
.admin-page-einrichtungen .admin-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 1.25rem;
  max-width: 42rem;
}

.admin-page-settings .admin-form-grid .form-group-full,
.admin-page-backup .admin-form-grid .form-group-full,
.admin-page-einrichtungen .admin-form-grid .form-group-full {
  grid-column: 1 / -1;
}

.admin-form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  grid-column: 1 / -1;
  align-items: start;
}

@media (max-width: 520px) {
  .admin-form-row-2 {
    grid-template-columns: 1fr;
  }
}

.admin-form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem 1.25rem;
  grid-column: 1 / -1;
  align-items: start;
}

@media (max-width: 720px) {
  .admin-form-row-3 {
    grid-template-columns: 1fr;
  }
}

.admin-form-actions {
  margin-top: 0.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.settings-media-preview {
  margin-top: 0.35rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.settings-media-preview--logo img {
  max-height: 48px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: middle;
}

.settings-media-preview--favicon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  vertical-align: middle;
}

.settings-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.5rem 0;
}

.settings-subsection {
  margin-top: 0.25rem;
}

.settings-subsection-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text, #1a202c);
}

.settings-subsection-hint {
  margin-bottom: 0.75rem !important;
}

.settings-testmail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-end;
}

.settings-testmail-field {
  flex: 1 1 220px;
  min-width: 0;
  margin-bottom: 0 !important;
}

.settings-testmail-submit {
  flex: 0 0 auto;
  padding-bottom: 0.15rem;
}

.input-width-smtp-port {
  max-width: 6.5rem;
}

.admin-page-backup .backup-run-panel {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md, 8px);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.admin-page-backup .backup-run-panel p:last-of-type {
  margin-bottom: 0;
}

.admin-page-backup .backup-cron-code {
  display: block;
  margin: 0.75rem 0 0;
  padding: 0.85rem 1rem;
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  font-size: 0.85rem;
  line-height: 1.45;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  color: var(--color-text);
}

.admin-page-backup .backup-cron-hints {
  margin-top: 1rem;
}

.admin-page-backup .backup-cron-hints p {
  margin: 0.35rem 0;
}

[data-theme="dark"] .settings-media-preview {
  background: #2d3748;
}

[data-theme="dark"] .admin-page-backup .backup-run-panel {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(56, 189, 248, 0.08) 100%);
  border-color: rgba(56, 189, 248, 0.35);
}

[data-theme="dark"] .admin-page-backup .backup-cron-code {
  background: #1e293b;
}

/* ========== Einrichtungen Admin ========== */
.einrichtung-card {
  margin-bottom: 1.5rem;
}

.admin-page-einrichtungen .einrichtung-card .card-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.admin-page-einrichtungen .einrichtung-create-card {
  margin-bottom: 1.5rem;
}

/* Formular „Neue Einrichtung“: etwas breiter als Standard-42rem */
.admin-page-einrichtungen .admin-form-grid--einrichtung-create {
  max-width: min(48rem, 100%);
}

.einrichtung-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.einrichtung-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.einrichtung-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.einrichtung-section-title {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
}

.einrichtung-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem 1.25rem;
}

.einrichtung-meta-grid .form-group {
  margin-bottom: 0;
}

.einrichtung-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  grid-column: 1 / -1;
}

.einrichtung-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.einrichtung-parameter-row {
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.einrichtung-parameter-row label {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-right: 0.25rem;
}

.einrichtung-pflege-parameter {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.einrichtung-pflege-parameter h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.einrichtung-quoten-table,
.einrichtung-pers-table {
  margin-bottom: 1rem;
}

.admin-page-einrichtungen .einrichtung-quoten-table .table-responsive,
.admin-page-einrichtungen .einrichtung-pers-table .table-responsive {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  background: var(--color-surface, #fff);
}

.admin-page-einrichtungen .einrichtung-quoten-table .data-table,
.admin-page-einrichtungen .einrichtung-pers-table .data-table {
  margin-bottom: 0;
}

.admin-page-einrichtungen .einrichtung-quoten-table .data-table th,
.admin-page-einrichtungen .einrichtung-quoten-table .data-table td,
.admin-page-einrichtungen .einrichtung-pers-table .data-table th,
.admin-page-einrichtungen .einrichtung-pers-table .data-table td {
  white-space: nowrap;
}

.admin-page-einrichtungen .einrichtung-quoten-table .parameter-quoten-label,
.admin-page-einrichtungen .einrichtung-pers-table .parameter-pers-label {
  white-space: normal;
  max-width: 12rem;
}

.einrichtung-pers-table .parameter-personalschluessel-hinweis {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0 0 0.5rem;
}

.einrichtung-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.input-einrichtung-number {
  max-width: 7rem;
}

.input-einrichtung-decimal {
  max-width: 8rem;
}

[data-theme="dark"] .admin-page-einrichtungen .einrichtung-quoten-table .table-responsive,
[data-theme="dark"] .admin-page-einrichtungen .einrichtung-pers-table .table-responsive {
  background: var(--color-surface, #1a202c);
}

.admin-page-einrichtungen .einrichtung-delete-form {
  display: inline;
  margin: 0;
}

.wohnbereich-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.wohnbereich-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.wohnbereich-list li:last-child {
  border-bottom: none;
}

.wohnbereich-list .form-inline input[type="text"] {
  min-width: 180px;
}

.mb-3 { margin-bottom: 1rem; }

/* ========== Belegung ========== */
.belegung-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.belegung-row.belegung-gesamt {
  font-weight: 600;
  background: #f8fafc;
  margin: 0 -1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom-color: var(--color-border);
}

.belegung-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.belegung-inputs input {
  width: 80px;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  text-align: center;
}

.belegung-card h4 {
  margin: 1.5rem 0 0.75rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ========== Modal ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0 0.25rem;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-border);
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state p {
  margin: 0;
  font-size: 0.95rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state .btn {
  margin-top: 1rem;
}

/* ========== Loading Spinner ========== */
.loading-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--color-text-muted);
}

/* ========== User Role Badge ========== */
.user-role-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  color: white;
}

/* ========== Responsive / Mobile ========== */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1.5rem;
  transition: background 0.2s;
}

.nav-toggle:hover {
  background: rgba(255,255,255,0.1);
}

.nav-toggle:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.nav-toggle-icon {
  display: block;
  width: 24px;
  height: 2px;
  background: currentColor;
  position: relative;
  transition: background 0.2s;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: transform 0.2s;
}

.nav-toggle-icon::before {
  top: -7px;
}

.nav-toggle-icon::after {
  top: 7px;
}

.nav-toggle.open .nav-toggle-icon {
  background: transparent;
}

.nav-toggle.open .nav-toggle-icon::before {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open .nav-toggle-icon::after {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 900px) {
  .nav-toggle {
    display: flex;
  }

  .main-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg-header);
    z-index: 50;
    flex-direction: column;
    padding: 0.5rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  .main-nav.open {
    max-height: 500px;
  }

  .main-nav a,
  .nav-dropdown-trigger {
    padding: 0.75rem 1rem;
    width: 100%;
    text-align: left;
    border-radius: var(--radius);
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: rgba(0,0,0,0.1);
    margin: 0.25rem 0 0 1rem;
    padding: 0.25rem 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
  }

  .nav-dropdown.open .nav-dropdown-menu {
    max-height: 300px;
  }

  .nav-dropdown-menu a {
    color: rgba(255,255,255,0.9);
    padding: 0.5rem 1rem;
  }

  .nav-dropdown-menu a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
  }

  .header-inner {
    flex-wrap: wrap;
    position: relative;
  }

  .header-user {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: row;
  }

  .main-nav {
    order: 3;
    width: 100%;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline input {
    width: 100%;
  }
}

/* ========== Print Button ========== */
.page-header-with-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header-actions {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.page-header-actions .btn,
.page-header-actions a.btn {
  min-height: 40px;
  padding: 0.5rem 1rem;
  align-items: center;
  text-decoration: none;
  box-sizing: border-box;
}

.btn-print {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  min-height: 40px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-print:hover {
  background: var(--color-primary-light);
}

.btn-print svg {
  flex-shrink: 0;
}

/* ========== Druckansicht (A4) ========== */
@media screen {
  .print-only {
    display: none !important;
  }
}

@media print {
  .print-only {
    display: block !important;
  }

  .no-print,
  .main-header,
  .dashboard-subnav,
  .main-footer,
  .page-header-actions {
    display: none !important;
  }

  body {
    background: white;
    font-size: 11pt;
  }

  .main-content {
    max-width: none;
    padding: 0;
  }

  @page {
    size: A4;
    margin: 15mm;
  }

  .dashboard {
    padding: 0;
  }

  .page-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #1a365d;
  }

  .page-header h1 {
    font-size: 18pt;
    margin: 0 0 0.25rem;
  }

  .page-header .lead {
    font-size: 10pt;
    margin: 0;
    color: #333;
  }

  .print-meta {
    font-size: 9pt;
    color: #666;
    margin-top: 0.5rem;
  }

  .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
    margin-bottom: 1rem;
  }

  .card-header {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .card-stat {
    break-inside: avoid;
  }

  .stat-bar-fill,
  .wohnbereich-bar-fill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .chart-container {
    height: 200px !important;
    page-break-inside: avoid;
  }

  .wohnbereich-cards {
    display: block;
  }

  .wohnbereich-card {
    break-inside: avoid;
    margin-bottom: 1rem;
  }

  .section-title {
    font-size: 14pt;
    margin: 1.5rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid #ddd;
  }

  .accordion-body {
    max-height: none !important;
  }
  .accordion-toggler {
    display: none;
  }
}

/* Vivendi-Tagesdaten */
.vivendi-datum-filter .form-inline,
.vivendi-filter .form-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.vivendi-datum-filter select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}
.vivendi-variablen-tabelle .var-name code {
  font-size: 0.9em;
  background: #f1f5f9;
  padding: 0.2em 0.4em;
  border-radius: 4px;
}
.vivendi-variablen-tabelle .var-wert {
  font-weight: 600;
  color: var(--color-primary);
}
.vivendi-bereiche-tabelle .bereich-id {
  font-size: 0.85em;
  color: var(--color-text-muted);
}
.vivendi-hinweis {
  margin-top: 1rem;
  font-size: 0.9em;
}

.einrichtung-id-badge {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--color-text-muted);
  background: #e2e8f0;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  margin-left: 0.5rem;
}

/* Dashboard Vivendi-Akkordeon */
.dashboard-filter .form-inline,
.vivendi-datum-filter .form-inline,
.vivendi-filter .form-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.dashboard-filter select,
.vivendi-datum-filter select,
.vivendi-filter select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}

.vivendi-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Dashboard: Slide nur im Bereich zwischen den Tages-Pfeilen (pro Karte) */
.dashboard-nav-main {
  flex: 1;
  min-width: 0;
}
.dashboard-nav-slide-stage {
  overflow: hidden;
  width: 100%;
  position: relative;
  min-height: 1rem;
}
.dashboard-nav-slide-stage--sliding {
  pointer-events: none;
}
.dashboard-nav-slide-track {
  display: flex;
  width: 100%;
  will-change: transform;
}
.dashboard-nav-slide-track.is-double {
  width: 200%;
}
.dashboard-nav-slide-track.is-double .dashboard-nav-slide-panel {
  flex: 0 0 50%;
  width: 50%;
  min-width: 0;
  box-sizing: border-box;
}
.dashboard-nav-slide-panel {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.accordion-item {
  background: var(--color-bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s;
}
.accordion-header:hover {
  background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
}
.accordion-einrichtung {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-primary);
  flex: 1;
  min-width: 0;
}
.accordion-tag {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}
.accordion-belegung {
  font-weight: 600;
  color: var(--color-primary);
}
.accordion-max {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.9em;
}
.accordion-auslastung {
  font-weight: 600;
  color: var(--color-accent);
  min-width: 4ch;
}
.accordion-print-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  padding: 0.35rem;
  border-radius: 6px;
  flex-shrink: 0;
  margin-left: 0.25rem;
}
.accordion-print-link:hover {
  color: var(--color-primary);
  background: rgba(26, 54, 93, 0.08);
}
.accordion-print-link svg {
  display: block;
}
.dashboard-datum-hint {
  display: block;
  width: 100%;
  flex-basis: 100%;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.datensatz-changelog-inline {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.datensatz-changelog-inline__title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.datensatz-changelog-inline__list {
  margin: 0;
  padding-left: 1.1rem;
}
.datensatz-changelog-inline__list li {
  margin-bottom: 0.35rem;
}
.datensatz-changelog-inline__list time {
  color: #a0aec0;
}
.changelog-details-cell {
  max-width: 28rem;
  word-break: break-word;
}
.accordion-toggler {
  font-size: 0.75em;
  color: var(--color-text-muted);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.accordion-item[data-accordion] .accordion-header.expanded .accordion-toggler {
  transform: rotate(180deg);
}
.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-out;
}
.accordion-body.expanded {
  max-height: 2000px;
}
.accordion-body > div {
  border-top: 1px solid var(--color-border);
}

/* Dashboard: Vor/Zurück zwischen Einrichtungen (Akkordeon) */
.dashboard-accordion-nav-shell {
  display: flex;
  align-items: stretch;
  min-height: 8rem;
}
.dashboard-accordion-nav-shell--single {
  display: block;
}
.dashboard-accordion-nav-shell--single .dashboard-nav-main {
  min-width: 0;
}
.dashboard-nav-main {
  flex: 1;
  min-width: 0;
}
a.dashboard-nav-arrow {
  text-decoration: none;
  color: inherit;
}
button.dashboard-nav-arrow {
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.dashboard-nav-arrow {
  flex-shrink: 0;
  align-self: stretch;
  width: 2.75rem;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
  border-right: 1px solid var(--color-border);
  background: linear-gradient(180deg, #f1f5f9 0%, #e8edf3 100%);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
.dashboard-nav-arrow-next {
  border-right: none;
  border-left: 1px solid var(--color-border);
}
.dashboard-nav-arrow:hover:not(:disabled) {
  background: linear-gradient(180deg, #e2e8f0 0%, #d8dee8 100%);
  color: var(--color-primary-light);
  box-shadow: inset 0 0 0 1px rgba(26, 54, 93, 0.08);
}
.dashboard-nav-arrow:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: -2px;
  z-index: 1;
}
.dashboard-nav-arrow:disabled,
.dashboard-nav-arrow-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--color-text-muted);
  pointer-events: none;
}
.dashboard-nav-arrow svg {
  display: block;
}
@media (max-width: 520px) {
  .dashboard-nav-arrow {
    width: 2.25rem;
  }
  .dashboard-nav-arrow svg {
    transform: scale(0.9);
  }
}

.accordion-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  align-items: start;
}
.accordion-row-1 {
  grid-column: 1 / -1;
}
.row-1-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(240px, 2fr);
  gap: 1.5rem;
  align-items: start;
}
.row-1-mitarbeiter h4,
.row-1-chart h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}
.chart-title-with-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.belegung-trend-pfeil {
  font-size: 0.85em;
  font-weight: 600;
}
.row-1-chart {
  min-width: 0;
}
.row-1-grid > .row-1-mitarbeiter:only-child {
  grid-column: 1 / -1;
}
/* Ohne Mitarbeiterzahlen: Belegungs-Chart volle Breite */
.row-1-grid.row-1-no-mitarbeiter .row-1-chart {
  grid-column: 1 / -1;
}
@media (max-width: 700px) {
  .row-1-grid {
    grid-template-columns: 1fr;
  }
}
.pflegegrade-wohnbereiche-grid {
  display: grid;
  grid-template-columns: minmax(180px, 3fr) minmax(0, 7fr);
  gap: 1.5rem;
  grid-column: 1 / -1;
  min-width: 0;
}
.pflegegrade-wohnbereiche-grid > .accordion-detail:only-child {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .pflegegrade-wohnbereiche-grid {
    grid-template-columns: 1fr;
  }
}
.accordion-detail {
  padding: 0;
}
.accordion-wohnbereiche {
  padding: 0;
  min-width: 0;
}
.accordion-detail h4,
.accordion-wohnbereiche h4 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}
.accordion-wohnbereiche {
  background: #fafbfc;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
}
.accordion-detail-table {
  max-width: 280px;
  font-size: 0.9rem;
}
.accordion-detail-table td {
  padding: 0.25rem 0.5rem 0.25rem 0;
  line-height: 1.3;
}
.accordion-detail-table td:first-child {
  padding-right: 1rem;
}
.accordion-detail h4 {
  margin-bottom: 0.5rem;
}
.accordion-hint {
  font-size: 0.8rem;
  margin: 0.5rem 0 1rem;
}
.accordion-hint code {
  font-size: 0.85em;
  background: var(--color-bg);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.accordion-gesamt td {
  font-weight: 600;
  border-top: 1px solid var(--color-border);
  padding-top: 0.35rem;
}
.accordion-bereiche-table th,
.accordion-bereiche-table td {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

/* Parameter-Seite */
.parameter-hinweis {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  max-width: 560px;
}
.parameter-table {
  max-width: 480px;
}
.parameter-input {
  width: 100%;
  max-width: 120px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
}
.parameter-form .form-actions {
  margin-top: 1.25rem;
}

.parameter-quoten {
  margin-bottom: 2rem;
}
.parameter-quoten h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.parameter-quoten-table {
  max-width: 480px;
}
.parameter-quoten-table th,
.parameter-quoten-table td {
  padding: 0.5rem 0.75rem;
  text-align: center;
}
.parameter-quoten-table th:first-child,
.parameter-quoten-table td:first-child {
  text-align: left;
}
.parameter-quoten-label {
  font-weight: 500;
  background: #f8fafc;
}
.parameter-quoten-input {
  max-width: 90px;
  text-align: center;
}

.parameter-personalschluessel {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.parameter-personalschluessel h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.parameter-personalschluessel-hinweis {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}
.parameter-pers-table {
  max-width: 720px;
}
.parameter-pers-table th,
.parameter-pers-table td {
  padding: 0.5rem 0.75rem;
  text-align: center;
}
.parameter-pers-table th:first-child,
.parameter-pers-table td:first-child {
  text-align: left;
}
.parameter-pers-label {
  font-weight: 500;
  background: #f8fafc;
}
.parameter-pers-input {
  max-width: 90px;
  text-align: center;
}

/* Parameter Berechnung – Formel-Editor */
.formel-variablen-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}
.formel-variablen-label {
  font-weight: 500;
  margin-right: 0.5rem;
  flex-shrink: 0;
}
.formel-insert-param {
  font-size: 0.85rem;
}
.formel-section-card {
  margin-bottom: 1.5rem;
}
.formel-table .formel-label {
  font-weight: 500;
  white-space: nowrap;
}
.formel-input {
  width: 100%;
  min-width: 280px;
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
}

/* Dashboard – Berechnungstabellen */
.accordion-berechnung {
  grid-column: 1 / -1;
}
.pflege-berechnung-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
@media (max-width: 700px) {
  .pflege-berechnung-grid {
    grid-template-columns: 1fr;
  }
}
.pflege-berechnung-col h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}
.accordion-berechnung h4 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
}
.accordion-berechnung h4:first-child {
  margin-top: 0;
}
.berechnung-table {
  margin-bottom: 1rem;
  max-width: 520px;
}
.berechnung-table th,
.berechnung-table td {
  padding: 0.4rem 0.6rem;
  text-align: right;
}
.berechnung-table th:first-child,
.berechnung-table td:first-child {
  text-align: left;
}
.berechnung-saldo td,
.berechnung-quote td {
  font-weight: 600;
}
.berechnung-mapping-preview-table {
  max-width: 100%;
}
.berechnung-mapping-formeln-wrap,
.berechnung-mapping-preview-wrap {
  max-height: min(70vh, 36rem);
  overflow: auto;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 6px;
}
#excel-mapping-zellen {
  scroll-margin-top: 5.5rem;
}
.berechnung-mapping-filter-row {
  margin-bottom: 0.75rem;
}
.berechnung-wichtig-hinweis code {
  font-size: 0.95em;
}

/* ========== Parameter: Excel-Berechnung (A1–P32) ========== */
.excel-berechnung-table-wrap {
  max-height: 78vh;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  width: 100%;
}
.excel-berechnung-grid-table {
  font-size: 0.72rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.excel-berechnung-grid-table col.excel-col-zelle { width: 3.2%; }
.excel-berechnung-grid-table col.excel-col-berechnet { width: 7.5%; }
.excel-berechnung-grid-table col.excel-col-db { width: 15%; }
.excel-berechnung-grid-table col.excel-col-formel { width: 11%; }
.excel-berechnung-grid-table col.excel-col-bezeichnung { width: 14%; }
.excel-berechnung-grid-table col.excel-col-portal { width: 12%; }
.excel-berechnung-grid-table col.excel-col-notiz { width: 12%; }
.excel-berechnung-grid-table col.excel-col-hinweis { width: 8%; }
.excel-berechnung-grid-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-bg-card, #fff);
  z-index: 2;
  box-shadow: 0 1px 0 var(--color-border, #ddd);
  white-space: normal;
  line-height: 1.2;
  padding: 0.2rem 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: bottom;
  hyphens: auto;
}
.excel-berechnung-grid-table thead th.excel-th-hinweis {
  font-size: 0.65rem;
}
.excel-berechnung-grid-table td {
  vertical-align: middle;
  padding: 0.12rem 0.15rem;
}
.excel-berechnung-grid-table .excel-td-zelle code {
  font-size: 0.7rem;
}
.excel-berechnung-grid-table .formel-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.72rem;
  padding: 0.18rem 0.22rem;
}
.excel-berechnung-grid-table select.formel-input {
  padding-right: 0.1rem;
}
.excel-berechnung-grid-table .cell-berechnet {
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
}
.excel-berechnung-grid-table .excel-td-db {
  overflow: hidden;
}
.excel-berechnung-grid-table .excel-td-hinweis .formel-input {
  font-size: 0.68rem;
  padding: 0.15rem 0.18rem;
}
.excel-berechnung-toolbar-card {
  margin-bottom: 0.75rem;
}
@media (max-width: 1100px) {
  .excel-berechnung-table-wrap {
    overflow-x: auto;
  }
  .excel-berechnung-grid-table {
    min-width: 52rem;
  }
}

/* ========== Parameter: Excel-Raster Ansicht (A1–P32) ========== */
.parameter-excel-raster-page .excel-raster-sub {
  font-weight: 400;
  color: var(--color-text-muted, #64748b);
  font-size: 0.85em;
}
.excel-raster-stichtag-card {
  margin-bottom: 1rem;
}
.excel-raster-sheet-wrap {
  overflow: auto;
  max-height: min(85vh, 1200px);
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  background: var(--color-bg-card, #fff);
}
.excel-raster-sheet {
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.62rem;
  width: 100%;
  min-width: 52rem;
}
.excel-raster-sheet th,
.excel-raster-sheet td {
  border: 1px solid var(--color-border, #cbd5e1);
  padding: 0.15rem 0.2rem;
  vertical-align: top;
  line-height: 1.2;
}
.excel-raster-corner {
  width: 1.75rem;
  background: var(--color-bg-muted, #f1f5f9);
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
}
.excel-raster-colhead {
  background: var(--color-bg-muted, #f1f5f9);
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 2.6rem;
}
.excel-raster-rowhead {
  background: var(--color-bg-muted, #f1f5f9);
  font-weight: 600;
  text-align: center;
  width: 1.75rem;
  position: sticky;
  left: 0;
  z-index: 3;
}
.excel-raster-cell {
  word-break: break-word;
  hyphens: auto;
  background: var(--color-bg-card, #fff);
}
.excel-raster-cell-empty {
  background: var(--color-bg-page, #fafafa);
}
.excel-raster-calc {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary, #1a365d);
  margin-bottom: 0.1rem;
  font-size: 0.68rem;
}
.excel-raster-main {
  color: var(--color-text, #334155);
}
.excel-raster-dash {
  color: var(--color-text-muted, #94a3b8);
}
[data-theme="dark"] .excel-raster-cell-empty {
  background: rgba(0, 0, 0, 0.15);
}

/* ========== Datum-Kalender (Flatpickr) ========== */
.datum-kalender-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.datum-kalender-input {
  min-width: 140px;
  cursor: pointer;
  background: var(--color-bg-card);
}
.datum-kalender-alle {
  font-size: 0.9rem;
  color: var(--color-primary);
  text-decoration: none;
}
.datum-kalender-alle:hover {
  text-decoration: underline;
}
/* Tage mit vorhandenen Daten markieren */
.flatpickr-day.has-data {
  position: relative;
}
.flatpickr-day.has-data::after {
  content: '';
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-accent);
}
.flatpickr-day.has-data:not(.selected):hover::after,
.flatpickr-day.has-data.selected::after {
  background: white;
}

/* ========== Kalenderwochen Accordion ========== */
.kalenderwochen-accordion {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kalenderwochen-accordion .accordion-item {
  box-shadow: none;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border);
}
.kalenderwochen-accordion .accordion-item:first-child {
  border-top: 1px solid var(--color-border);
}
.kalenderwochen-header {
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  font-weight: 400;
  font-size: 0.95rem;
}
.kalenderwochen-header:hover {
  background: #fafbfc;
}
.kalenderwochen-accordion .accordion-item:nth-child(even) .kalenderwochen-header {
  background: #fafbfc;
}
.kalenderwochen-accordion .accordion-item:nth-child(even) .kalenderwochen-header:hover {
  background: #f1f5f9;
}
.kalenderwochen-kw {
  font-weight: 500;
  color: var(--color-text);
  min-width: 6ch;
}
.kalenderwochen-einrichtung {
  font-weight: 400;
  flex: 1;
  min-width: 120px;
  color: var(--color-text);
}
.kalenderwochen-tage {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.kalenderwochen-belegung,
.kalenderwochen-ruestige,
.kalenderwochen-kzp {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text);
}
.kalenderwochen-pg {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 400;
}
.kalenderwochen-header .accordion-toggler {
  font-size: 0.7em;
  opacity: 0.6;
}
.kalenderwochen-accordion .accordion-body > div {
  border-top: none;
  padding: 0.5rem 1rem 1rem 2rem;
  background: #f8fafc;
}
.kalenderwochen-tage-table {
  font-size: 0.9rem;
}
.kalenderwochen-tage-table th,
.kalenderwochen-tage-table td {
  padding: 0.5rem 0.75rem;
}
