:root {
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --app-bg: #f3f4f6;
  --app-card-radius: 0.9rem;
  --app-card-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

body {
  background-color: var(--app-bg);
}

/* ------------------------------------------------------------
   App Shell (Sidebar + Topbar)
------------------------------------------------------------ */

.app-body {
  min-height: 100vh;
}

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

.app-sidebar {
  width: 280px;
  background: #ffffff;
  border-right: 1px solid rgba(15, 23, 42, 0.06);
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-sidebar-inner {
  padding: 1rem;
}

.app-logo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 1rem 0.5rem;
  text-decoration: none;
  color: inherit;
}

.app-brand {
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.app-brand-sub {
  font-size: 0.85rem;
  line-height: 1.2;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.9rem;
  color: rgba(15, 23, 42, 0.85);
  text-decoration: none;
  font-weight: 600;
}

.app-nav-link i {
  font-size: 1.1rem;
}

.app-nav-link:hover {
  background: rgba(37, 99, 235, 0.06);
  color: rgba(15, 23, 42, 0.95);
}

.app-nav-link.active {
  background: rgba(37, 99, 235, 0.12);
  color: #0f172a;
}

.app-sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.app-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.12);
  color: #1e40af;
  font-weight: 800;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(243, 244, 246, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-page-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
}

.app-page-subtitle {
  font-size: 0.85rem;
  line-height: 1.2;
}

.app-main {
  padding: 1.25rem;
}

/* Constrain content width so admin areas feel more "app-like" */
.app-page {
  max-width: 1100px;
  margin-inline: auto;
}

.app-page .card {
  overflow: hidden;
}

.list-group-item {
  border-color: rgba(15, 23, 42, 0.06);
}

.app-offcanvas {
  --bs-offcanvas-width: 320px;
}

.app-footer {
  padding: 1rem 1.25rem 1.5rem;
}

.btn.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

.app-offcanvas .offcanvas-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

/* Dark mode tweaks */
[data-bs-theme="dark"] body {
  --app-bg: #0b1220;
}

[data-bs-theme="dark"] .app-sidebar,
[data-bs-theme="dark"] .btn.btn-icon,
[data-bs-theme="dark"] .card {
  background: rgba(15, 23, 42, 0.9);
}

[data-bs-theme="dark"] .app-topbar {
  background: rgba(11, 18, 32, 0.75);
}

[data-bs-theme="dark"] .app-nav-link {
  color: rgba(226, 232, 240, 0.9);
}

[data-bs-theme="dark"] .app-nav-link:hover {
  background: rgba(37, 99, 235, 0.16);
}

[data-bs-theme="dark"] .app-nav-link.active {
  background: rgba(37, 99, 235, 0.24);
}

/* Navbar */
.navbar {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.navbar-nav .nav-link {
  font-weight: 500;
  padding-inline: 1rem;
}

/* Cards & layout */
.card {
  border-radius: var(--app-card-radius);
  border: none;
  box-shadow: var(--app-card-shadow);
}

.card-title {
  font-weight: 600;
}

.card h6.text-muted {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

/* ------------------------------------------------------------
   KPI / Stat cards (mobile-safe)
------------------------------------------------------------ */

.app-stat-card {
  overflow: hidden;
}

.app-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.10);
  color: #1e40af;
  flex: 0 0 auto;
}

.app-stat-icon i {
  font-size: 1.35rem;
}

.app-stat-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(100, 116, 139, 0.95);
  line-height: 1.2;
  margin-bottom: 0.15rem;
}

.app-stat-value {
  font-size: clamp(1.5rem, 5.6vw, 2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-stat-sub {
  color: rgba(100, 116, 139, 0.95);
  line-height: 1.15;
  max-width: 100%;
  /* Clean wrapping by default (no forced hyphenation). */
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.app-stat-metrics {
  min-width: 0;
}

[data-bs-theme="dark"] .app-stat-icon {
  background: rgba(37, 99, 235, 0.18);
  color: rgba(191, 219, 254, 0.95);
}

[data-bs-theme="dark"] .app-stat-label,
[data-bs-theme="dark"] .app-stat-sub {
  color: rgba(203, 213, 225, 0.85);
}

/* Buttons */
.btn {
  border-radius: 999px;
  font-weight: 500;
}

/* Tables */
.table {
  margin-bottom: 0;
}

.table thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Forms */
form .form-label {
  font-weight: 500;
}

.form-control, .form-select {
  border-radius: 0.6rem;
}

/* Main container */
.main-container {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

/* Mobile tweaks */
@media (max-width: 576px) {
  /* App shell spacing */
  .app-topbar {
    padding: 0.65rem 0.85rem;
    gap: 0.5rem;
  }

  .app-main {
    padding: 0.85rem;
  }

  .app-footer {
    padding: 0.75rem 0.85rem 1.25rem;
  }

  .app-page-title {
    font-size: 0.98rem;
  }

  .app-page-subtitle {
    display: none;
  }

  #themeToggle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    padding: 0;
    display: grid;
    place-items: center;
  }

  #themeToggle span {
    display: none !important;
  }

  .btn.btn-icon {
    width: 40px;
    height: 40px;
  }

  .card {
    border-radius: 0.85rem;
  }

  /* Make grid gaps a bit tighter on phones */
  .row.g-4 {
    --bs-gutter-x: 0.85rem;
    --bs-gutter-y: 0.85rem;
  }

  .navbar-brand {
    font-size: 1rem;
  }

  .card {
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  }

  .table-responsive {
    border-radius: 0.8rem;
    background: var(--bs-body-bg);
    padding: 0.5rem;
  }

  .app-offcanvas {
    --bs-offcanvas-width: min(88vw, 340px);
  }

  .btn {
    padding-block: 0.6rem;
    /* Auf Handy weniger "Pill"-Look, sonst werden Buttons bei Text-Umbruch zu Kreisen */
    border-radius: 0.85rem;
    white-space: normal;
  }

  /* KPI cards: prevent label/sub from looking "off" inside the box */
  .app-stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .app-stat-value {
    font-size: 1.85rem;
  }

  .app-stat-sub {
    font-size: 0.95rem;
    width: 100%;
    text-align: center;
    /* Wrap at spaces for a calmer look ("des Unternehmens"),
       but still avoid overflow in tight tiles. */
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
  }

  /* Stack number + subtitle on phones so the text never feels "cut" */
  .app-stat-metrics {
    flex-direction: column;
    align-items: center !important;
    gap: 0.15rem !important;
    width: 100%;
  }

  /* if the subtitle is longer, allow 2 lines instead of ugly truncation */
  .app-stat-sub.text-truncate {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  /* KPI cards: make tiles look clean and consistent on 2-column mobile grid */
  .app-stat-card .card-body {
    flex-direction: column;
    justify-content: center;
    align-items: center !important;
    text-align: center;
    gap: 0.6rem !important;
  }

  .app-stat-card .flex-grow-1 {
    text-align: center;
    width: 100%;
  }

  .app-stat-icon {
    margin-bottom: 0.1rem;
  }
  .app-stat-value {
    max-width: 100%;
  }
}

/* Tablet: reduce paddings slightly */
@media (max-width: 991.98px) {
  .app-topbar {
    padding: 0.75rem 1rem;
  }

  .app-main {
    padding: 1rem;
  }

  .app-offcanvas {
    --bs-offcanvas-width: min(320px, 88vw);
  }
}

.app-logo {
  height: 44px;
  width: auto;
}

@media (max-width: 768px) {
  .app-logo {
    height: 36px;
  }
}

/* Public (not logged-in) layout */
.public-body {
  background: var(--bs-body-bg);
}

.public-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--bs-body-bg);
  border-bottom: 1px solid rgba(0,0,0,.08);
  padding: 0.75rem 0;
}

.public-logo {
  height: 28px;
  width: auto;
}
[data-bs-theme="dark"] .public-topbar {
  border-bottom-color: rgba(255,255,255,.12);
}

.public-shell .container {
  max-width: 980px;
}

/* ------------------------------------------------------------
   Mobile bottom navigation
------------------------------------------------------------ */

.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.6rem;
  padding-bottom: calc(0.4rem + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.app-bottom-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: rgba(15, 23, 42, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.25rem;
  border-radius: 0.85rem;
  font-weight: 700;
  font-size: 0.72rem;
  line-height: 1;
}

.app-bottom-link i {
  font-size: 1.15rem;
}

.app-bottom-link.active {
  color: rgba(15, 23, 42, 0.95);
  background: rgba(37, 99, 235, 0.12);
}

[data-bs-theme="dark"] .app-bottom-nav {
  background: rgba(15, 23, 42, 0.86);
  border-top-color: rgba(148, 163, 184, 0.18);
}

[data-bs-theme="dark"] .app-bottom-link {
  color: rgba(226, 232, 240, 0.86);
}

[data-bs-theme="dark"] .app-bottom-link.active {
  background: rgba(37, 99, 235, 0.24);
  color: rgba(226, 232, 240, 0.95);
}

@media (max-width: 576px) {
  /* Prevent content from being hidden behind bottom nav */
  .app-main {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
}

/* Field-mode bottom nav (+ button) */
.app-bottom-plus {
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -26px;
  width: 76px;
  flex: 0 0 76px;
}

.app-bottom-plus-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,0.92);
  background: var(--bs-primary);
  color: #fff;
  box-shadow: 0 18px 38px rgba(37, 99, 235, 0.45);
  transform: translateZ(0);
}

[data-bs-theme="dark"] .app-bottom-plus-inner {
  border-color: rgba(15, 23, 42, 0.92);
}

.app-bottom-plus i {
  font-size: 1.6rem;
  color: inherit;
}

.app-bottom-plus:active .app-bottom-plus-inner {
  transform: translateY(1px) scale(0.98);
}

/* Smaller role badges (mobile-friendly) */
.role-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  max-width: 100%;
}

@media (max-width: 576px) {
  .role-badge {
    font-size: 0.62rem;
    padding: 0.2rem 0.45rem;
  }
}

/* prevent content hiding behind bottom nav */
@media (max-width: 991.98px) {
  .app-main {
    padding-bottom: 90px;
  }
}


/* --- Mobile bottom nav: highlight the + area (FAB well) --- */
.app-bottom-plus{position:relative; z-index:1;}
.app-bottom-plus::before{
  content:"";
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  bottom:-10px;
  width:86px;
  height:52px;
  border-radius:26px;
  background: rgba(37, 99, 235, 0.14);
  z-index:0;
}
[data-bs-theme="dark"] .app-bottom-plus::before{
  background: rgba(37, 99, 235, 0.26);
}

/* Make the center + more prominent */
.app-bottom-plus-inner{
  position:relative;
  z-index:1;
  width:70px;
  height:70px;
  border-width:5px;
}
.app-bottom-plus i{font-size:1.8rem;}

/* Smaller role badges (override Bootstrap .badge defaults) */
.badge.role-badge{
  font-size:0.58rem !important;
  padding:0.18rem 0.45rem !important;
  line-height:1.1 !important;
  letter-spacing:0.02em;
  max-width: 10.5rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
@media (max-width: 420px){
  .badge.role-badge{
    font-size:0.54rem !important;
    padding:0.16rem 0.40rem !important;
    max-width: 9rem;
  }
}
