:root {
  --sidebar-width: 300px;
  --sidebar-collapsed-width: 88px;
  --bs-primary: #22B8BB;
  --bs-primary-rgb: 34, 184, 187;
  --app-red: #B6535E;
  --app-bg-dark: #061523;
  --app-bg-dark-2: #071F34;
  --app-surface-dark: #0B2A42;
  --app-surface-dark-solid: #0B2A42;
  --app-line-dark: #28485A;
  --app-text-dark: #F6F8F9;
  --app-muted-dark: #B8C8CE;
  --app-shadow-dark: 0 22px 60px rgba(0, 0, 0, 0.32);
}

html[data-bs-theme="dark"] {
  --bs-body-bg: var(--app-bg-dark);
  --bs-body-color: var(--app-text-dark);
  --bs-tertiary-bg: var(--app-bg-dark);
  --bs-border-color: var(--app-line-dark);
  --bs-card-bg: var(--app-surface-dark-solid);
}

body.bg-body-tertiary {
  background: #f6f8fc !important;
}

html[data-bs-theme="dark"] body.bg-body-tertiary {
  background:
    radial-gradient(circle at 22% 0%, rgba(34, 184, 187, 0.14), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(239, 68, 68, 0.12), transparent 28rem),
    linear-gradient(145deg, #06111f 0%, #071827 48%, #06111f 100%) !important;
  color: var(--app-text-dark);
}

.app-shell {
  display: flex;
  min-height: calc(100vh - 72px);
}

.app-topbar {
  min-height: 72px;
  background: rgba(255, 255, 255, 0.94) !important;
  border-bottom: 1px solid rgba(15, 23, 42, 0.09);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06) !important;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-topbar .navbar-brand,
.app-topbar .navbar-text,
.app-topbar .nav-link,
.app-topbar .btn {
  color: #0f172a !important;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: #fff !important;
  border-right: 1px solid rgba(15, 23, 42, 0.09) !important;
  overflow: hidden auto;
  transition: width 0.18s ease, flex-basis 0.18s ease;
}

.content {
  flex: 1;
  min-width: 0;
}

.content > .container-fluid {
  max-width: 1680px;
}

html[data-bs-theme="dark"] .content .card,
html[data-bs-theme="dark"] .content .modal-content,
html[data-bs-theme="dark"] .content .dropdown-menu,
html[data-bs-theme="dark"] .content .list-group-item,
html[data-bs-theme="dark"] .content .accordion-item,
html[data-bs-theme="dark"] .content .av-panel,
html[data-bs-theme="dark"] .content .av-metric,
html[data-bs-theme="dark"] .content .av-filter-card,
html[data-bs-theme="dark"] .content .av-file-section,
html[data-bs-theme="dark"] .content .dashboard-card,
html[data-bs-theme="dark"] .content .stat-card {
  background: linear-gradient(180deg, rgba(12, 27, 45, 0.94), rgba(8, 20, 34, 0.94)) !important;
  border: 1px solid var(--app-line-dark) !important;
  box-shadow: var(--app-shadow-dark) !important;
  color: var(--app-text-dark) !important;
}

html[data-bs-theme="dark"] .content .card,
html[data-bs-theme="dark"] .content .av-panel,
html[data-bs-theme="dark"] .content .av-metric,
html[data-bs-theme="dark"] .content .av-filter-card,
html[data-bs-theme="dark"] .content .av-file-section {
  border-radius: 18px !important;
}

html[data-bs-theme="dark"] .content h1,
html[data-bs-theme="dark"] .content h2,
html[data-bs-theme="dark"] .content h3,
html[data-bs-theme="dark"] .content h4,
html[data-bs-theme="dark"] .content h5,
html[data-bs-theme="dark"] .content h6,
html[data-bs-theme="dark"] .content .fw-semibold,
html[data-bs-theme="dark"] .content .fw-bold,
html[data-bs-theme="dark"] .content .table {
  color: var(--app-text-dark) !important;
}

html[data-bs-theme="dark"] .text-secondary,
html[data-bs-theme="dark"] .text-muted,
html[data-bs-theme="dark"] .form-text,
html[data-bs-theme="dark"] .small.text-secondary {
  color: var(--app-muted-dark) !important;
}

html[data-bs-theme="dark"] .content .table-responsive,
html[data-bs-theme="dark"] .content .table {
  border-color: var(--app-line-dark) !important;
}

html[data-bs-theme="dark"] .content .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text-dark);
  --bs-table-border-color: rgba(148, 163, 184, 0.13);
  --bs-table-hover-bg: rgba(34, 184, 187, 0.10);
  --bs-table-hover-color: #fff;
}

html[data-bs-theme="dark"] .content .table thead th,
html[data-bs-theme="dark"] .content .table-light th,
html[data-bs-theme="dark"] .content .table-light td {
  background: rgba(8, 20, 34, 0.98) !important;
  color: #cbd5e1 !important;
  border-color: var(--app-line-dark) !important;
}

html[data-bs-theme="dark"] .content .form-control,
html[data-bs-theme="dark"] .content .form-select,
html[data-bs-theme="dark"] .content .input-group-text {
  background-color: rgba(5, 16, 29, 0.94) !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
  color: #f8fafc !important;
  border-radius: 13px;
}

html[data-bs-theme="dark"] .content .form-control::placeholder {
  color: #82929B !important;
}

html[data-bs-theme="dark"] .content .form-control:focus,
html[data-bs-theme="dark"] .content .form-select:focus {
  border-color: rgba(103, 216, 215, 0.85) !important;
  box-shadow: 0 0 0 0.22rem rgba(103, 216, 215, 0.18) !important;
}

html[data-bs-theme="dark"] .btn-outline-primary,
html[data-bs-theme="dark"] .btn-outline-secondary,
html[data-bs-theme="dark"] .btn-outline-info,
html[data-bs-theme="dark"] .btn-outline-danger,
html[data-bs-theme="dark"] .btn-outline-warning,
html[data-bs-theme="dark"] .btn-light {
  background: #0B2A42  !important;
  border-color: #28485A !important;
  color: #F6F8F9 !important;
}

html[data-bs-theme="dark"] .badge,
html[data-bs-theme="dark"] .alert,
html[data-bs-theme="dark"] .app-pill {
  border: 1px solid rgba(148, 163, 184, 0.14);
}

html[data-bs-theme="dark"] .alert-light,
html[data-bs-theme="dark"] .alert-info,
html[data-bs-theme="dark"] .alert-warning,
html[data-bs-theme="dark"] .alert-success,
html[data-bs-theme="dark"] .alert-danger {
  background: rgba(10, 23, 38, 0.92) !important;
  color: #F6F8F9 !important;
  border-color: var(--app-line-dark) !important;
}

html[data-bs-theme="dark"] .shadow-sm,
html[data-bs-theme="dark"] .shadow {
  box-shadow: var(--app-shadow-dark) !important;
}

.app-page-hero {
  align-items: center;
  background: linear-gradient(135deg, rgba(34, 184, 187, 0.12), rgba(239, 68, 68, 0.08));
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 24px;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  overflow: hidden;
  padding: 1.35rem;
  position: relative;
}

.app-page-hero::after {
  background: radial-gradient(circle, rgba(34, 184, 187, 0.22), transparent 62%);
  content: "";
  height: 260px;
  position: absolute;
  right: -90px;
  top: -120px;
  width: 260px;
}

.app-page-kicker,
.app-module-kicker,
.app-kpi-label {
  color: var(--app-muted-dark);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.app-page-title {
  color: #f8fafc;
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  margin: 0.15rem 0;
}

.app-page-subtitle {
  color: #94a3b8;
  max-width: 680px;
}

.app-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  position: relative;
  z-index: 1;
}

.app-kpi-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.app-kpi-card {
  align-items: center;
  background: linear-gradient(180deg, rgba(12, 27, 45, 0.94), rgba(8, 20, 34, 0.94));
  border: 1px solid var(--app-line-dark);
  border-radius: 22px;
  color: #f8fafc;
  display: flex;
  gap: 1rem;
  min-height: 122px;
  padding: 1.15rem;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.app-kpi-card:hover,
.app-module-link:hover {
  border-color: rgba(103, 216, 215, 0.42);
  color: #fff;
  transform: translateY(-2px);
}

.app-kpi-icon,
.app-module-link-icon {
  align-items: center;
  border-radius: 18px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.app-kpi-card-red .app-kpi-icon { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.app-kpi-card-blue .app-kpi-icon { background: linear-gradient(135deg, #22B8BB, #0D8E90); }
.app-kpi-card-purple .app-kpi-icon { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.app-kpi-card-green .app-kpi-icon { background: linear-gradient(135deg, #10b981, #047857); }

.app-kpi-icon i,
.app-module-link-icon i {
  font-size: 1.4rem;
}

.app-kpi-value {
  color: #fff;
  font-size: 1.18rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-top: 0.12rem;
}

.app-kpi-note {
  color: #94a3b8;
  font-size: 0.84rem;
  margin-top: 0.15rem;
}

.app-module-card {
  background: linear-gradient(180deg, rgba(12, 27, 45, 0.94), rgba(8, 20, 34, 0.94));
  border: 1px solid var(--app-line-dark);
  border-radius: 22px;
  box-shadow: var(--app-shadow-dark);
  padding: 1rem;
}

.app-module-header {
  align-items: center;
  border-bottom: 1px solid var(--app-line-dark);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.85rem;
}

.app-module-header h2 {
  color: #fff;
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0.12rem 0 0;
}

.app-module-count {
  background: rgba(34, 184, 187, 0.14);
  border: 1px solid rgba(103, 216, 215, 0.22);
  border-radius: 999px;
  color: #67D8D7;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0.28rem 0.62rem;
  white-space: nowrap;
}

.app-module-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-module-link {
  align-items: center;
  background: rgba(5, 16, 29, 0.68);
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 18px;
  color: #F6F8F9;
  display: flex;
  gap: 0.75rem;
  padding: 0.82rem;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.app-module-link-icon {
  background: rgba(34, 184, 187, 0.14);
  border: 1px solid rgba(103, 216, 215, 0.18);
  height: 42px;
  width: 42px;
}

.app-module-link strong {
  display: block;
  font-size: 0.90rem;
  line-height: 1.12;
}

.app-module-link small {
  color: #94a3b8;
  display: block;
  font-size: 0.74rem;
  margin-top: 0.15rem;
}

@media (max-width: 1199.98px) {
  .app-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .app-page-hero { align-items: flex-start; flex-direction: column; }
  .app-kpi-grid,
  .app-module-grid { grid-template-columns: 1fr; }
}

@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar {
    display: flex !important;
    flex: 0 0 var(--sidebar-collapsed-width) !important;
    width: var(--sidebar-collapsed-width) !important;
  }
}

html[data-bs-theme="dark"] .app-topbar,
html[data-bs-theme="dark"] .sidebar {
  background: rgba(6, 17, 31, 0.88) !important;
  border-color: var(--app-line-dark) !important;
}

html[data-bs-theme="dark"] .app-topbar .navbar-brand,
html[data-bs-theme="dark"] .app-topbar .navbar-text,
html[data-bs-theme="dark"] .app-topbar .btn {
  color: #f8fafc !important;
}
