:root {
  --primary: #bb0032;
  --primary-dark: #96001f;
  --primary-light: #ffebf0;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --success: #10b981;
  --success-light: #ecfdf5;
  --sidebar-width: 256px;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* ── APP LAYOUT ─────────────────────────────────────────────── */

#app { display: flex; min-height: 100vh; }

/* ── SIDEBAR ────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-header {
  height: 84px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #1e293b;
}

.logo { display: flex; align-items: center; gap: 10px; }

.logo-icon-wrap {
  width: 44px; height: 44px;
  background: #fff;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3px;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text { font-size: 15px; font-weight: 700; color: #f8fafc; letter-spacing: -.3px; }
.logo-sub  { font-size: 11px; color: #64748b; margin-top: 1px; }

.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 16px 16px 5px;
  font-weight: 700;
}

.nav-links { list-style: none; padding: 0 8px 8px; }
.nav-links li { margin: 1px 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
  cursor: pointer;
}

.nav-link:hover { background: #1e293b; color: #e2e8f0; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

/* ── MAIN CONTENT ───────────────────────────────────────────── */

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Auf öffentlichen Seiten (Login, Passwort vergessen/zurücksetzen, Einladung,
   Zugangslink) ist die Sidebar ausgeblendet - der Inhaltsbereich soll dann
   die volle Breite nutzen statt um --sidebar-width eingerückt zu bleiben. */
#main-content.no-sidebar {
  margin-left: 0;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100vh;
}

/* ── LOGIN ──────────────────────────────────────────────────── */

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

.login-card-wrap {
  width: 100%;
  max-width: 380px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  margin-bottom: 24px;
}

.login-brand .logo-icon-wrap {
  width: 56px;
  height: 56px;
  box-shadow: var(--shadow-md);
}

.login-brand-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

.login-brand-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.login-card .card-body {
  padding: 30px 28px;
}

.login-card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: -8px 0 22px;
}

.login-page .form-group {
  gap: 6px;
  margin-bottom: 18px;
}

.login-page label {
  font-size: 13px;
}

.login-page input {
  padding: 10px 13px;
  font-size: 15px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  padding: 10px 14px;
  font-size: 14px;
  margin-top: 4px;
}

.login-forgot {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.login-forgot:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .login-page { padding: 16px; }
  .login-card .card-body { padding: 24px 20px; }
  .login-brand .logo-icon-wrap { width: 48px; height: 48px; }
}

/* ── PAGE HEADER ────────────────────────────────────────────── */

.page-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  height: 84px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.page-title  { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ── PAGE CONTENT ───────────────────────────────────────────── */

/* Scrollt als Ganzes, sobald der Inhalt einer Seite (egal ob Tabelle,
   Karten-Stapel oder Formular) die verfügbare Höhe übersteigt - der
   Seitenkopf (.page-header) bleibt dabei fix oben stehen, da er außerhalb
   dieses Containers liegt. Einzelne Bereiche (z.B. .table-wrapper) dürfen
   zusätzlich ihren eigenen internen Scroll behalten, das bleibt unverändert
   funktionsfähig (verschachteltes Scrollen). */
.page-content {
  padding: 22px 28px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Der letzte Block einer Seite (Tabelle, Karten-Liste, Formular) darf den
   restlichen Platz füllen, wird aber nicht mehr gezwungen, sich unter seine
   natürliche Höhe zu stauchen - das überlässt das Scrollen jetzt .page-content
   selbst, statt sich auf einen pro Seite unterschiedlich funktionierenden
   internen Scroll-Mechanismus zu verlassen. */
.page-content > *:last-child {
  flex: 1;
}

/* ── CARDS ──────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.card-title { font-size: 14px; font-weight: 700; }
.card-body  {
  padding: 18px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ── STATS ──────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.stat-value { font-size: 30px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 5px; font-weight: 500; }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* ── TABLE ──────────────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: #f9fafb;
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }
tbody tr[onclick] { cursor: pointer; }
tbody td { padding: 11px 14px; font-size: 14px; vertical-align: middle; }

/* ── BADGES ─────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }

/* Abgelaufene Schulungstermine: ausgegraut, aber weiterhin anklickbar/lesbar */
tr.row-abgelaufen td { opacity: 0.55; }
tr.row-abgelaufen:hover td { opacity: 0.8; }
.termin-abgelaufen .page-title,
.termin-abgelaufen .page-subtitle { opacity: 0.55; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-orange { background: #ffedd5; color: #c2410c; }

/* ── BUTTONS ────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary { background: #fff; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f9fafb; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── FORMS ──────────────────────────────────────────────────── */

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

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full-width { grid-column: 1 / -1; }

label { font-size: 12px; font-weight: 700; color: var(--text-primary); letter-spacing: .2px; }

input, select, textarea {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(187,0,50,.12);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

/* ── FILTER BAR ─────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.search-input { flex: 1; min-width: 200px; max-width: 320px; }

/* ── LAYOUT HELPERS ─────────────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
}

.content-grid > * {
  min-height: 0;
}

.section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-secondary);
  font-weight: 700;
  margin: 20px 0 10px;
}

.section-title:first-child { margin-top: 0; }

/* ── DETAIL GRID ────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  padding: 10px 12px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detail-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-bottom: 3px;
}

.detail-value { font-size: 14px; font-weight: 500; }

/* ── BREADCRUMB ─────────────────────────────────────────────── */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

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

/* ── ALERT ──────────────────────────────────────────────────── */

.alert {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  flex-shrink: 0;
}

.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-orange  { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }

/* ── EMPTY STATE ────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

.empty-state-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state h3   { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 5px; }
.empty-state p    { font-size: 13px; }

/* ── AVATAR ─────────────────────────────────────────────────── */

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  letter-spacing: .3px;
}

.avatar-img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.avatar-img-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  flex-shrink: 0;
}

/* ── FILE UPLOAD ────────────────────────────────────────────── */

.file-upload-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: #f9fafb;
  transition: all .15s;
}

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

input[type="file"] { display: none; }

.photo-preview {
  width: 70px; height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
  display: none;
}

.photo-placeholder {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: #f3f4f6;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── DRIVER NAME CELL ───────────────────────────────────────── */

.driver-cell { display: flex; align-items: center; gap: 10px; }
.driver-name { font-weight: 600; }
.driver-sub  { color: var(--text-secondary); font-size: 12px; }

/* ── SPINNER ────────────────────────────────────────────────── */

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── LIGHTBOX ───────────────────────────────────────────────── */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn .15s ease;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-img {
  max-width: 100%;
  max-height: 78vh;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  object-fit: contain;
}

.lightbox-caption {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
}

.lightbox-close {
  position: absolute;
  top: -44px;
  right: -4px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.lightbox-close:hover { background: rgba(255,255,255,.3); }

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

/* ── CUSTOM DATEPICKER ──────────────────────────────────────── */

.dp-wrap { position: relative; }

.dp-input-row {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}

.dp-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(187,0,50,.12);
}

.dp-text-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: transparent;
  min-width: 0;
  font-family: inherit;
}

.dp-text-input::placeholder { color: var(--text-secondary); }

.dp-cal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  height: 38px;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}

.dp-cal-btn:hover { background: var(--bg); color: var(--primary); }

.dp-popup {
  position: fixed;
  z-index: 9000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 14px;
  min-width: 274px;
  animation: fadeIn .12s ease;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dp-nav {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: background .1s;
  line-height: 1;
}
.dp-nav:hover { background: var(--bg); }

.dp-month-label {
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.dp-month-label:hover { background: var(--bg); }

.dp-month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 6px 0;
}

.dp-month-cell {
  text-align: center;
  padding: 9px 4px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .1s, color .1s;
}
.dp-month-cell:hover { background: var(--primary-light); color: var(--primary); }
.dp-month-cell.dp-selected { background: var(--primary); color: #fff; border-color: var(--primary); }

[data-theme="dark"] .dp-month-label:hover { background: #0f172a; }
[data-theme="dark"] .dp-month-cell:hover  { background: rgba(187,0,50,.25); color: #fca5a5; }

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.dp-wd {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 3px 0 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dp-day {
  text-align: center;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: background .1s, color .1s;
  border: 1px solid transparent;
}
.dp-day:hover { background: var(--primary-light); color: var(--primary); }
.dp-empty { cursor: default; }
.dp-empty:hover { background: none; color: inherit; }

.dp-today {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.dp-selected {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 700;
  border-color: var(--primary) !important;
}

.dp-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.dp-clear {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 12px; cursor: pointer;
  padding: 3px 8px; border-radius: 4px;
  transition: color .1s;
}
.dp-clear:hover { color: var(--danger); }

.dp-today-btn {
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  padding: 3px 10px; border-radius: 5px;
  transition: background .12s, color .12s;
}
.dp-today-btn:hover { background: var(--primary); color: #fff; }

[data-theme="dark"] .dp-input-row { background: #0f172a; border-color: #334155; }
[data-theme="dark"] .dp-text-input { background: #0f172a; color: #e2e8f0; }
[data-theme="dark"] .dp-text-input::placeholder { color: #64748b; }
[data-theme="dark"] .dp-cal-btn { border-color: #334155; color: #64748b; }
[data-theme="dark"] .dp-cal-btn:hover { background: #162032; color: var(--primary); }
[data-theme="dark"] .dp-popup { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .dp-nav:hover { background: #0f172a; }
[data-theme="dark"] .dp-day:hover { background: rgba(187,0,50,.25); color: #fca5a5; }

/* ── BESTÄTIGUNGS-MODAL ─────────────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn .15s ease;
}

.confirm-dialog {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 36px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}

.confirm-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.confirm-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

[data-theme="dark"] .confirm-dialog {
  background: #1e293b;
}

/* ── MODAL (FORMULAR) ───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: fadeIn .15s ease;
  padding: 20px;
}

.modal-dialog {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--bg); color: var(--primary); }

.modal-body { padding: 20px; }

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 14px;
  padding: 9px 12px;
  background: var(--bg);
  border-radius: 7px;
}

[data-theme="dark"] .modal-dialog { background: #1e293b; }
[data-theme="dark"] .form-hint { background: #0f172a; }

/* ── AUTOCOMPLETE ───────────────────────────────────────────── */

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 200;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-light); }

.autocomplete-name { font-weight: 600; font-size: 14px; }
.autocomplete-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; align-items: center; gap: 6px; }

.autocomplete-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

[data-theme="dark"] .autocomplete-list {
  background: #1e293b;
}

[data-theme="dark"] .autocomplete-item:hover {
  background: rgba(187,0,50,.15);
}

/* ── COPY EMAIL ─────────────────────────────────────────────── */

.copy-email {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  transition: opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.copy-email:hover { opacity: .7; text-decoration: underline; }

/* ── DATUM-FEHLER ────────────────────────────────────────────── */

.form-date-error {
  display: none;
  color: #dc2626;
  font-size: 13px;
  font-weight: 500;
  margin-top: 2px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
}

[data-theme="dark"] .form-date-error {
  background: rgba(220,38,38,.15);
  border-color: rgba(220,38,38,.4);
}

/* ── TOAST ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: #1e293b;
  color: #fff;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  transform: translateY(12px);
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
}

.toast.show   { transform: translateY(0); opacity: 1; }
.toast.success { background: #16a34a; }
.toast.error   { background: var(--danger-dark); }

/* ── FLEX GAP HELPERS ───────────────────────────────────────── */

.flex { display: flex; }
.flex-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

/* Karten innerhalb einer .flex-col behalten ihre natürliche Höhe –
   bei Platzmangel scrollt die .flex-col als Ganzes statt die Karten zu stauchen. */
.flex-col > .card { flex-shrink: 0; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16  { margin-top: 16px; }
.mt-20  { margin-top: 20px; }

.text-danger { color: var(--danger); font-weight: 700; }

.schulung-revalidiert {
  text-decoration: line-through;
  color: var(--text-secondary);
}

/* ── SCROLLBAR ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── RESPONSIVE ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow-y: auto;
  }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .form-grid  { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px; height: auto; padding: 14px 16px; }
  .page-content { padding: 16px; }
}

/* ── SIDEBAR FOOTER (Theme Toggle) ──────────────────────────── */

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px 14px;
  border-top: 1px solid #1e293b;
}

.theme-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-align: left;
  text-decoration: none;
}

.theme-toggle-btn:hover { background: #1e293b; color: #e2e8f0; }

/* ── DARK MODE ──────────────────────────────────────────────── */

[data-theme="dark"] {
  --bg:           #0f172a;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --border:       #334155;
  --primary-light: #3d0014;
  --warning-light: #1c1505;
  --success-light: #052e16;
  --shadow:    0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.5), 0 2px 4px -1px rgba(0,0,0,.4);
}

[data-theme="dark"] .page-header { background: #1e293b; }

[data-theme="dark"] .card,
[data-theme="dark"] .stat-card  { background: #1e293b; }

[data-theme="dark"] .filter-bar { background: #1e293b; }

[data-theme="dark"] thead th    { background: #162032; }

[data-theme="dark"] tbody tr:hover { background: #263248; }

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: #64748b;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(187,0,50,.18);
}

[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme="dark"] .btn-secondary:hover { background: #263248; }

[data-theme="dark"] .detail-item { background: #162032; border-color: var(--border); }

[data-theme="dark"] .file-upload-btn { background: #162032; color: var(--text-secondary); }
[data-theme="dark"] .file-upload-btn:hover { background: var(--primary-light); color: var(--primary); }

[data-theme="dark"] .photo-placeholder { background: #162032; }

[data-theme="dark"] .badge-gray   { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-green  { background: #052e16; color: #4ade80; }
[data-theme="dark"] .badge-red    { background: #450a0a; color: #f87171; }
[data-theme="dark"] .badge-blue   { background: #0c1a3a; color: #60a5fa; }
[data-theme="dark"] .badge-yellow { background: #1c1505; color: #facc15; }
[data-theme="dark"] .badge-orange { background: #2a1605; color: #fb923c; }

[data-theme="dark"] .alert-danger  { background: #450a0a; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-warning { background: #1c1505; color: #fbbf24; border-color: #78350f; }
[data-theme="dark"] .alert-info    { background: #0c1a3a; color: #93c5fd; border-color: #1e3a8a; }
[data-theme="dark"] .alert-orange  { background: #2a1605; color: #fdba74; border-color: #7c2d12; }

[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; }
