:root {
  --bg-start: #f7fafc;
  --bg-end: #e9eef5;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e5e7eb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 25px rgba(0,0,0,0.08);
}

/* Grundlayout */
html, body {
  min-height: 100%;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  margin: 0;
  width: 100%;
  max-width: 100vw;
  /* overflow-x: hidden;  ENTFERNT! */
}

/* Links */
a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }

/* Sidebar */
.sidebar {
  min-height: 100vh;
  background: linear-gradient(180deg, #0d6efd 0%, #0a58ca 100%);
  color: #fff;
  width: 220px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  z-index: 1000;
  position: fixed;
  left: 0;
  top: 0;
  transition: width 0.2s;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 12px 16px 18px;
  min-height: 56px;
  cursor: pointer;
}
.sidebar.collapsed .sidebar-header { justify-content: center; }

.sidebar .sidebar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  justify-content: flex-start;
}
.sidebar.collapsed .sidebar-title { justify-content: center; width: 100%; }
.sidebar.collapsed .sidebar-title .nav-text { display: none !important; }

.sidebar .sidebar-toggle-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  margin-left: auto;
  margin-right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar.collapsed .sidebar-toggle-btn { display: none; }

#sidebarMenu {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  height: 100%;
  padding: 0;
  margin: 0;
}

.sidebar .nav-link {
  color: #fff !important;
  font-weight: 500;
  margin-bottom: 8px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 1.07rem;
  justify-content: flex-start;
  padding: 0 16px;
  box-shadow: none !important;
}
.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  background: rgba(255,255,255,0.15);
  color: #fff !important;
  box-shadow: none !important;
}
.sidebar .nav-link i {
  width: 32px;
  min-width: 32px;
  text-align: center;
  font-size: 1.6em;
  display: inline-block;
  box-shadow: none !important;
  border-bottom: none !important;
}
.sidebar.collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar .nav-text { margin-left: 12px; transition: opacity 0.2s, width 0.2s; display: inline-block; }
.sidebar.collapsed .nav-text,
.sidebar.collapsed .fa-chevron-down,
.sidebar.collapsed .jahr-dropdown { display: none !important; }

.sidebar .collapse,
.sidebar .collapsing { transition: none; }
.sidebar.collapsed .collapse,
.sidebar.collapsed .collapsing { display: none !important; }

.jahr-dropdown {
  margin: 24px 0 0 0;
  padding: 0 16px;
  transition: opacity 0.2s;
}
.sidebar .form-label,
.sidebar .form-select { font-size: 0.95rem; }

/* MAIN CONTENT LAYOUT: Nur Margin, keine feste Breite */
.main-content {
  margin-left: 220px;
  transition: margin-left 0.2s;
  min-width: 0;
  padding-bottom: 64px;
}
.sidebar.collapsed ~ .main-content {
  margin-left: 48px;
}

/* Responsive Sidebar und Main-Content */
@media (max-width: 991px) {
  .sidebar { width: 60px; }
  .sidebar:not(.collapsed) { width: 220px; }
  .main-content { margin-left: 60px; }
  .sidebar:not(.collapsed) ~ .main-content { margin-left: 220px; }
}

/* Die .container-fluid steuert das Padding für alle Inhalte */
.container-fluid {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  width: 100%;
  box-sizing: border-box;
  /* Optional: max-width für sehr große Bildschirme */
  /* max-width: 1800px; */
  /* margin: 0 auto; */
}

/* Responsive Anpassung */
@media (max-width: 600px) {
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Dashboard Header (Hauptüberschrift + Buttons) */
.main-content .d-flex.justify-content-between {
  flex-wrap: wrap;
  min-width: 0;
}
.main-content .d-flex.justify-content-between > .d-flex {
  min-width: 0;
  flex-shrink: 1;
  overflow-x: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 0.75rem;
  gap: 0.5rem;
}
@media (max-width: 600px) {
  .main-content .d-flex.justify-content-between > .d-flex {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
  }
}

/* Dashboard Icon */
.dashboard-title-icon {
  font-size: 2.4rem !important;
  vertical-align: middle;
  margin-right: 0.3em;
}

/* Karten (Cards) */
.card.compact {
  padding: 0.3rem 0.6rem !important;
  border-radius: 10px !important;
  font-size: 0.93rem !important;
}
.card.compact .card-body { padding: 0.4rem !important; }
.card.compact h5,
.card.compact .card-title {
  font-size: 1.02rem !important;
  margin-bottom: 0.3rem !important;
}
.card.compact .card-title i { font-size: 1.1rem !important; }
.card.compact .card-text,
.card.compact table,
.card.compact th,
.card.compact td { font-size: 0.91rem !important; }

/* Tabellen */
.table-sm th,
.table-sm td { padding: 0.18rem 0.35rem; }
.table-fixed { table-layout: fixed; width: 100%; }
.table-fixed th,
.table-fixed td {
  border: none !important;
  padding-top: 0.22rem !important;
  padding-bottom: 0.22rem !important;
  vertical-align: middle;
  padding-left: 0.4rem !important;
  padding-right: 0.4rem !important;
}
.table-fixed input,
.table-fixed textarea,
.table-fixed select {
  width: 100%;
  min-height: 32px;
  font-size: 1rem;
  padding: 0.22rem 0.6rem;
  box-sizing: border-box;
  resize: none;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
}
.table-fixed textarea { resize: vertical; }
.table-fixed tr { border: none !important; }
.table-fixed th { font-weight: 600; background: none; }
.table-fixed tbody tr { margin-bottom: 0.1rem; }

.table thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    box-shadow: 0 2px 2px -1px rgba(0,0,0,0.1);
}


/* Alerts & Messageboxen */
.alert, .warning, .success, .info {
  padding: 12px 14px;
  border-radius: 10px;
  margin: 8px 0;
  font-size: 14px;
  border: 1px solid var(--border);
}
.alert { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }
.warning { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.success { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.info { background: #e0f2fe; color: #0c4a6e; border-color: #bae6fd; }
.confirm { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.closebtn { cursor: pointer; float: right; font-weight: bold; }

/* Buttons */
.btn-sm {
  font-size: 0.95rem !important;
  padding: 0.25rem 0.5rem !important;
  border-radius: 6px !important;
}
.btn-outline-danger { color: #dc2626; border-color: #fecaca; }
.btn-outline-danger:hover { background: #fee2e2; }
.btn-outline-primary { color: #2563eb; border-color: #93c5fd; }
.btn-outline-primary:hover { background: #e0f2fe; }

/* FontAwesome Icons */
.fa, .fa-solid, .fa-regular, .fa-light, .fa-duotone, .fa-brands {
  font-size: 1.1rem !important;
  vertical-align: middle;
}

/* Kartenabstände */
.row > .col-md-4, .row > .col-md-6 { padding-bottom: 1rem; }

/* Action Bar */
.action-bar-fixed {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1050;
    background: rgba(255,255,255,0.97);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
    padding: 10px 2rem;
    min-height: 48px;
    display: flex;
    justify-content: flex-end;
    gap: 0.7rem;
    align-items: center;
    border-top: 1px solid #e5e7eb;
}
@media (max-width: 900px) {
    .action-bar-fixed { padding: 10px 0.5rem; }
}

/* Action Bar Buttons: gleich breit, responsive */
.action-bar-fixed .btn {
  min-width: 140px;
  max-width: 180px;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  transition: all 0.2s;
}

@media (max-width: 600px) {
  .action-bar-fixed .btn span {
    display: none !important;
  }
  .action-bar-fixed .btn {
    min-width: 40px;
    max-width: 40px;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}
