html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

/* Skip link accessibility styles */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 1000;
  background: #fff;
  color: #0077cc;
  text-decoration: none;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  padding: 8px 16px;
  font-size: 1rem;
  border: 2px solid #0077cc;
  border-radius: 4px;
  outline: none;
  box-shadow: 0 0 2px #0077cc;
  text-decoration: none;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

body.dark {
  background-color: #181a1b;
  color: #f1f1f1;
}

body.dark .navbar,
body.dark .footer,
body.dark .bg-white {
  background-color: #23272b !important;
  color: #f1f1f1 !important;
}

body.dark .skip-link {
  background: #23272b;
  color: #90caf9;
}

body.dark .btn,
body.dark .form-control,
body.dark .form-floating,
body.dark .form-check-input {
  background-color: var(--bs-dark-bg-subtle, #23272b);
  color: var(--bs-light, #f1f1f1);
}

body.dark .form-floating > .form-control-plaintext::placeholder,
body.dark .form-floating > .form-control::placeholder {
  color: #b0b0b0;
}

body.dark .form-floating > .form-control-plaintext:focus::placeholder,
body.dark .form-floating > .form-control:focus::placeholder {
  color: #e0e0e0;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* --- Card Styles --- */
.card {
  background: #fff;
  color: #212529;
  border: 1px solid #dee2e6;
}
body.dark .card {
  background: #23272b;
  color: #f8f9fa;
  border: 1px solid #343a40;
}

/* --- Button Styles --- */
.btn-primary {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}
body.dark .btn-primary {
  background-color: #4dabf7;
  border-color: #4dabf7;
  color: #181a1b;
}
.btn-outline-primary {
  color: #0d6efd;
  border-color: #0d6efd;
}
body.dark .btn-outline-primary {
  color: #66bfff;
  border-color: #66bfff;
}
.btn:disabled, .btn.disabled {
  background-color: #e0e0e0 !important;
  color: #6c757d !important;
  border-color: #dee2e6 !important;
}
body.dark .btn:disabled, body.dark .btn.disabled {
  background-color: #343a40 !important;
  color: #adb5bd !important;
  border-color: #23272b !important;
}

/* --- Text Styles --- */
body {
  color: #212529;
}
body.dark {
  color: #f8f9fa;
}
.text-secondary {
  color: #6c757d !important;
}
body.dark .text-secondary {
  color: #adb5bd !important;
}
a, .link {
  color: #0d6efd;
}
body.dark a, body.dark .link {
  color: #66bfff;
}

/* --- Form Styles --- */
.form-control, .form-label, .form-floating {
  background: #fff;
  color: #212529;
}
body.dark .form-control, body.dark .form-label, body.dark .form-floating {
  background: #23272b;
  color: #f8f9fa;
}
body.dark .form-control::placeholder {
  color: #adb5bd;
}

/* --- Navbar/Footer --- */
.navbar, .footer {
  background: #fff;
  color: #212529;
}
body.dark .navbar, body.dark .footer {
  background: #181a1b !important;
  color: #f8f9fa !important;
}

/* --- Navbar/Menu Links --- */
.navbar .nav-link {
  color: #212529;
}
body.dark .navbar .nav-link {
  color: #e0e0e0;
}
body.dark .navbar .nav-link.active,
body.dark .navbar .nav-link:focus,
body.dark .navbar .nav-link:hover {
  color: #fff;
}
.navbar .nav-link.active,
.navbar .nav-link:focus,
.navbar .nav-link:hover {
  color: #0d6efd;
}
body.dark .navbar-brand {
  color: #fff !important;
}

/* --- Buttons --- */
body.dark .btn-primary {
  background-color: #1976d2;
  border-color: #1976d2;
  color: #fff;
}
body.dark .btn,
body.dark .btn-primary {
  color: #fff;
}
body.dark .btn-outline-primary {
  color: #90caf9;
  border-color: #90caf9;
}
body.dark .btn:disabled, body.dark .btn.disabled {
  background-color: #333 !important;
  color: #555 !important;
  border-color: #23272b !important;
}

/* --- Text --- */
body.dark .text-muted,
body.dark .text-secondary {
  color: #b0b0b0 !important;
}
body.dark h1, body.dark h2, body.dark h3, body.dark h4, body.dark h5, body.dark h6 {
  color: #fff;
}
body.dark .lead,
body.dark .display-1,
body.dark .display-2,
body.dark .display-3 {
  color: #fff;
}

/* --- General Links --- */
body.dark a {
  color: #90caf9;
}

/* --- Card Text --- */
body.dark .card {
  color: #f8f9fa;
}

/* --- Fix for .btn-link and disabled buttons in dark mode --- */
body.dark .btn-link,
body.dark .btn-link:disabled,
body.dark .btn-link.disabled {
  background-color: transparent !important;
  color: #90caf9 !important;
  opacity: 0.7;
}

body.dark .btn-link:active,
body.dark .btn-link:focus,
body.dark .btn-link:hover {
  color: #fff !important;
  text-decoration: underline;
  background-color: transparent !important;
}

body.dark .btn-outline-primary:disabled,
body.dark .btn-outline-primary.disabled {
  background-color: transparent !important;
  color: #90caf9 !important;
  border-color: #343a40 !important;
  opacity: 0.5;
}

/* --- Custom .btn-outline-primary appearance for both light and dark modes --- */
.btn-outline-primary {
  background-color: transparent !important;
  color: #0d6efd;
  border-color: #0d6efd;
  transition: background-color 0.15s, color 0.15s;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
  background-color: #0d6efd !important;
  color: #fff !important;
  border-color: #0d6efd !important;
}

body.dark .btn-outline-primary {
  background-color: transparent !important;
  color: #90caf9;
  border-color: #90caf9;
}
body.dark .btn-outline-primary:hover,
body.dark .btn-outline-primary:focus,
body.dark .btn-outline-primary:active {
  background-color: #1976d2 !important;
  color: #fff !important;
  border-color: #1976d2 !important;
}

/* --- Custom .btn-warning appearance for both light and dark modes --- */
.btn-warning {
  background-color: transparent !important;
  color: #fd7e14;
  border-color: #fd7e14;
  transition: background-color 0.15s, color 0.15s;
}
.btn-warning:hover,
.btn-warning:focus,
.btn-warning:active {
  background-color: #fd7e14 !important;
  color: #fff !important;
  border-color: #fd7e14 !important;
}

body.dark .btn-warning {
  background-color: transparent !important;
  color: #ffb74d;
  border-color: #ffb74d;
}
body.dark .btn-warning:hover,
body.dark .btn-warning:focus,
body.dark .btn-warning:active {
  background-color: #ff9800 !important;
  color: #181a1b !important;
  border-color: #ff9800 !important;
}

/* --- Table Styles for Dark Mode --- */
body.dark table,
body.dark .table {
  background-color: #23272b;
  color: #f8f9fa;
}

body.dark th,
body.dark td {
  background-color: #23272b;
  color: #f8f9fa;
  border-color: #343a40;
}

body.dark thead th {
  background-color: #181a1b;
  color: #fff;
  border-color: #343a40;
}

body.dark .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: #262a2e;
}

body.dark .table-hover > tbody > tr:hover {
  background-color: #2c3136;
  color: #fff;
}

/* --- Button Group Styles for Dark Mode --- */
body.dark .btn-group,
body.dark .btn-group > .btn {
  background-color: #23272b;
  border-color: #343a40;
}
body.dark .btn-group > .btn:not(:last-child) {
  border-right: 1px solid #343a40;
}
body.dark .btn-group > .btn:focus,
body.dark .btn-group > .btn:active,
body.dark .btn-group > .btn:hover {
  background-color: #2c3136;
  color: #fff;
}

/* --- Custom .btn-secondary appearance for both light and dark modes --- */
.btn-secondary {
  background-color: transparent !important;
  color: #0d6efd;
  border-color: #6c757d;
  transition: background-color 0.15s, color 0.15s;
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active {
  background-color: #0d6efd !important;
  color: #fff !important;
  border-color: #0d6efd !important;
}

body.dark .btn-secondary {
  background-color: transparent !important;
  color: #90caf9;
  border-color: #adb5bd;
}
body.dark .btn-secondary:hover,
body.dark .btn-secondary:focus,
body.dark .btn-secondary:active {
  background-color: #1976d2 !important;
  color: #fff !important;
  border-color: #1976d2 !important;
}

/* --- Nav Tabs Active Link Styles for Dark Mode --- */
body.dark .nav-tabs .nav-link.active {
  background-color: #23272b !important;
  color: #90caf9 !important;
  border-top: 2px solid #fff !important;
  border-left: 2px solid #fff !important;
  border-right: 2px solid #fff !important;
  border-bottom: 2px solid #23272b !important;
  border-top-left-radius: 0.75rem !important;
  border-top-right-radius: 0.75rem !important;
}
body.dark .nav-tabs .nav-link {
  color: #b0b0b0;
}
body.dark .nav-tabs .nav-link:hover,
body.dark .nav-tabs .nav-link:focus {
  color: #fff;
}

/* --- Custom .btn-danger appearance for both light and dark modes --- */
.btn-danger {
  background-color: transparent !important;
  color: #dc3545;
  border-color: #dc3545;
  transition: background-color 0.15s, color 0.15s;
}
.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active {
  background-color: #dc3545 !important;
  color: #fff !important;
  border-color: #dc3545 !important;
}

body.dark .btn-danger {
  background-color: transparent !important;
  color: #ff6f6f;
  border-color: #ff6f6f;
}
body.dark .btn-danger:hover,
body.dark .btn-danger:focus,
body.dark .btn-danger:active {
  background-color: #ff6f6f !important;
  color: #fff !important;
  border-color: #ff6f6f !important;
}

/* --- Preformatted Text Styles for Dark Mode --- */
body.dark pre {
  background-color: #181a1b !important;
  color: #e0e0e0 !important;
  border: 1px solid #343a40 !important;
}

/* --- Select, Combobox, and Listbox Styles for Dark Mode --- */
body.dark select,
body.dark .form-select,
body.dark .form-control,
body.dark select[multiple],
body.dark select[size],
body.dark option {
  background-color: #23272b !important;
  color: #f8f9fa !important;
  border: 1px solid #343a40 !important;
}
body.dark select:focus,
body.dark .form-select:focus,
body.dark .form-control:focus {
  background-color: #181a1b !important;
  color: #fff !important;
  border-color: #90caf9 !important;
}
body.dark option:checked,
body.dark option:focus {
  background-color: #0d6efd !important;
  color: #fff !important;
}

/* --- Custom .btn-success appearance for both light and dark modes --- */
.btn-success {
  background-color: transparent !important;
  color: #198754;
  border-color: #198754;
  transition: background-color 0.15s, color 0.15s;
}
.btn-success:hover,
.btn-success:focus,
.btn-success:active {
  background-color: #198754 !important;
  color: #fff !important;
  border-color: #198754 !important;
}

body.dark .btn-success {
  background-color: transparent !important;
  color: #6ee7b7;
  border-color: #6ee7b7;
}
body.dark .btn-success:hover,
body.dark .btn-success:focus,
body.dark .btn-success:active {
  background-color: #23c16b !important;
  color: #181a1b !important;
  border-color: #23c16b !important;
}

/* --- Custom .btn-outline-secondary appearance for both light and dark modes --- */
.btn-outline-secondary {
  background-color: transparent !important;
  color: #6c757d;
  border-color: #6c757d;
  transition: background-color 0.15s, color 0.15s;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
  background-color: #0d6efd !important;
  color: #fff !important;
  border-color: #0d6efd !important;
}

body.dark .btn-outline-secondary {
  background-color: transparent !important;
  color: #adb5bd;
  border-color: #adb5bd;
}
body.dark .btn-outline-secondary:hover,
body.dark .btn-outline-secondary:focus,
body.dark .btn-outline-secondary:active {
  background-color: #1976d2 !important;
  color: #fff !important;
  border-color: #1976d2 !important;
}

/* --- Custom .btn-outline-success appearance for both light and dark modes --- */
.btn-outline-success {
  background-color: transparent !important;
  color: #198754;
  border-color: #198754;
  transition: background-color 0.15s, color 0.15s;
}
.btn-outline-success:hover,
.btn-outline-success:focus,
.btn-outline-success:active {
  background-color: #198754 !important;
  color: #fff !important;
  border-color: #198754 !important;
}
body.dark .btn-outline-success {
  background-color: transparent !important;
  color: #6ee7b7;
  border-color: #6ee7b7;
}
body.dark .btn-outline-success:hover,
body.dark .btn-outline-success:focus,
body.dark .btn-outline-success:active {
  background-color: #23c16b !important;
  color: #181a1b !important;
  border-color: #23c16b !important;
}

/* --- Custom .btn-outline-warning appearance for both light and dark modes --- */
.btn-outline-warning {
  background-color: transparent !important;
  color: #fd7e14;
  border-color: #fd7e14;
  transition: background-color 0.15s, color 0.15s;
}
.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-warning:active {
  background-color: #fd7e14 !important;
  color: #fff !important;
  border-color: #fd7e14 !important;
}
body.dark .btn-outline-warning {
  background-color: transparent !important;
  color: #ffb74d;
  border-color: #ffb74d;
}
body.dark .btn-outline-warning:hover,
body.dark .btn-outline-warning:focus,
body.dark .btn-outline-warning:active {
  background-color: #ff9800 !important;
  color: #181a1b !important;
  border-color: #ff9800 !important;
}

/* --- Custom .btn-outline-info appearance for both light and dark modes --- */
.btn-outline-info {
  background-color: transparent !important;
  color: #0dcaf0;
  border-color: #0dcaf0;
  transition: background-color 0.15s, color 0.15s;
}
.btn-outline-info:hover,
.btn-outline-info:focus,
.btn-outline-info:active {
  background-color: #0dcaf0 !important;
  color: #fff !important;
  border-color: #0dcaf0 !important;
}
body.dark .btn-outline-info {
  background-color: transparent !important;
  color: #80deea;
  border-color: #80deea;
}
body.dark .btn-outline-info:hover,
body.dark .btn-outline-info:focus,
body.dark .btn-outline-info:active {
  background-color: #00bcd4 !important;
  color: #181a1b !important;
  border-color: #00bcd4 !important;
}

/* --- Custom .form-check-input appearance for dark mode --- */
body.dark .form-check-input {
  background-color: #23272b !important;
  border-color: #343a40 !important;
}
body.dark .form-check-input:checked {
  background-color: #90caf9 !important;
  border-color: #90caf9 !important;
}
body.dark .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem #90caf9 !important;
}

/* --- Custom .btn-outline-danger appearance for dark mode --- */
body.dark .btn-outline-danger {
  background-color: transparent !important;
  color: #ff6f6f;
  border-color: #ff6f6f;
}
body.dark .btn-outline-danger:hover,
body.dark .btn-outline-danger:focus,
body.dark .btn-outline-danger:active {
  background-color: #ff6f6f !important;
  color: #fff !important;
  border-color: #ff6f6f !important;
}

body.dark .modal-content {
  background-color: #23272b !important;
  color: #f8f9fa !important;
  border: 1px solid #343a40;
  box-shadow: 0 2px 16px rgba(0,0,0,0.32);
}
body.dark .modal-header,
body.dark .modal-footer {
  background-color: #23272b !important;
  color: #f8f9fa !important;
  border-color: #343a40 !important;
}
body.dark .modal-body {
  background-color: #23272b !important;
  color: #f8f9fa !important;
}

/* --- Additional Dark Mode Components --- */

/* Metric/Stat Cards */
body.dark .quick-stat-card,
body.dark .metric-card,
body.dark .stat-card {
  background-color: #161b22 !important;
  border-color: #30363d !important;
  color: #f0f6fc !important;
}

body.dark .quick-stat-value,
body.dark .metric-value,
body.dark .stat-value {
  color: #f0f6fc !important;
}

body.dark .quick-stat-label,
body.dark .metric-label,
body.dark .stat-label {
  color: #8b949e !important;
}

/* Role Example Code Blocks */
body.dark .role-example,
body.dark code.example {
  background-color: #30363d !important;
  border-color: #444c56 !important;
  color: #58a6ff !important;
}

/* Table Headers in Dark Mode */
body.dark th {
  color: #f0f6fc !important;
  border-color: #30363d !important;
}

/* Namespace Badges */
body.dark .namespace-badge,
body.dark .badge {
  opacity: 0.9;
}

body.dark .badge.bg-primary {
  background-color: #1f6feb !important;
  color: #ffffff !important;
}

body.dark .badge.bg-danger {
  background-color: #da3633 !important;
  color: #ffffff !important;
}

body.dark .badge.bg-success {
  background-color: #238636 !important;
  color: #ffffff !important;
}

body.dark .badge.bg-warning {
  background-color: #d29922 !important;
  color: #f0f6fc !important;
}

body.dark .badge.bg-info {
  background-color: #1f6feb !important;
  color: #ffffff !important;
}

body.dark .badge.bg-secondary {
  background-color: #6e7681 !important;
  color: #f0f6fc !important;
}

body.dark .badge.bg-dark {
  background-color: #484f58 !important;
  color: #f0f6fc !important;
}

body.dark .badge.bg-light {
  background-color: #30363d !important;
  color: #8b949e !important;
}

/* Breadcrumbs */
body.dark .breadcrumb {
  background-color: #161b22 !important;
  border-color: #30363d !important;
}

body.dark .breadcrumb-item a {
  color: #58a6ff !important;
}

body.dark .breadcrumb-item.active {
  color: #8b949e !important;
}

body.dark .breadcrumb-item + .breadcrumb-item::before {
  color: #484f58 !important;
}

/* Empty States */
body.dark .empty-state {
  color: #8b949e !important;
}

body.dark .empty-state h5,
body.dark .empty-state h4,
body.dark .empty-state h3 {
  color: #f0f6fc !important;
}

/* Card Headers with Background Colors */
body.dark .card-header.bg-primary {
  background-color: #1f6feb !important;
  border-color: #1f6feb !important;
}

body.dark .card-header.bg-primary * {
  color: #ffffff !important;
}

/* Text Color for Common Classes */
body.dark .fw-semibold,
body.dark .fw-bold {
  color: #f0f6fc !important;
}

/* Icons in Tables and Lists */
body.dark th .bi,
body.dark td .bi {
  color: inherit;
}

/* Search Inputs and Filter Controls */
body.dark input[type="search"],
body.dark .search-input,
body.dark .filter-input {
  background-color: #161b22 !important;
  border-color: #30363d !important;
  color: #f0f6fc !important;
}

body.dark input[type="search"]::placeholder,
body.dark .search-input::placeholder,
body.dark .filter-input::placeholder {
  color: #6e7681 !important;
}

/* Disabled Elements */
body.dark .btn[disabled],
body.dark .btn:disabled,
body.dark button[disabled],
body.dark button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* Table Row Hover States */
body.dark .table-hover tbody tr:hover {
  background-color: #21262d !important;
}

body.dark .role-row:hover,
body.dark .data-row:hover {
  background-color: #21262d !important;
}

/* --- Config Navigation Cards --- */
.config-nav-card {
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: block;
}

.config-nav-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

.config-nav-card.active {
  border-color: #0d6efd !important;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.config-nav-card i {
  transition: color 0.3s ease;
}

.config-nav-card:hover i {
  color: #0d6efd !important;
}

/* Dark mode config cards */
body.dark .config-nav-card {
  background-color: #23272b;
  border-color: #30363d;
}

body.dark .config-nav-card:hover {
  background-color: #2c3136;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.dark .config-nav-card.active {
  border-color: #58a6ff !important;
  box-shadow: 0 0 0 0.25rem rgba(88, 166, 255, 0.25);
}

body.dark .config-nav-card:hover i {
  color: #58a6ff !important;
}

/* --- Modern Card Styles --- */
.modern-card {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

body.dark .modern-card {
  background: #23272b;
  border-color: #30363d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modern-card-header {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 1rem 1.25rem;
  font-weight: 600;
}

body.dark .modern-card-header {
  background: #161b22;
  border-bottom-color: #30363d;
  color: #f0f6fc;
}

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

body.dark .modern-card-body {
  color: #f0f6fc;
}

/* Modern Card Tables */
.modern-card table {
  margin-bottom: 0;
}

body.dark .modern-card table,
body.dark .modern-card .table {
  background-color: transparent;
  color: #f0f6fc;
}

body.dark .modern-card th,
body.dark .modern-card td {
  background-color: transparent;
  color: #f0f6fc;
  border-color: #30363d;
}

body.dark .modern-card thead th {
  background-color: #161b22;
  color: #f0f6fc;
  border-color: #30363d;
}

body.dark .modern-card .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: rgba(33, 38, 45, 0.3);
}

body.dark .modern-card .table-hover > tbody > tr:hover {
  background-color: rgba(33, 38, 45, 0.5);
  color: #fff;
}

/* Heat Map Cells in Modern Cards */
body.dark .modern-card .risk-very-low {
  background-color: #0e4429 !important;
  color: #ffffff !important;
}

body.dark .modern-card .risk-low {
  background-color: #2d5f3f !important;
  color: #ffffff !important;
}

body.dark .modern-card .risk-medium {
  background-color: #9e6a03 !important;
  color: #ffffff !important;
}

body.dark .modern-card .risk-high {
  background-color: #8e1519 !important;
  color: #ffffff !important;
}

body.dark .modern-card .risk-critical {
  background-color: #67060c !important;
  color: #ffffff !important;
}

/* Form Controls in Modern Cards */
body.dark .modern-card .form-control,
body.dark .modern-card .form-select,
body.dark .modern-card input,
body.dark .modern-card select,
body.dark .modern-card textarea {
  background-color: #161b22;
  border-color: #30363d;
  color: #f0f6fc;
}

body.dark .modern-card .form-control:focus,
body.dark .modern-card .form-select:focus,
body.dark .modern-card input:focus,
body.dark .modern-card select:focus,
body.dark .modern-card textarea:focus {
  background-color: #0d1117;
  border-color: #58a6ff;
  color: #f0f6fc;
  box-shadow: 0 0 0 0.2rem rgba(88, 166, 255, 0.25);
}

body.dark .modern-card .form-control::placeholder,
body.dark .modern-card input::placeholder,
body.dark .modern-card textarea::placeholder {
  color: #6e7681;
}

/* Labels in Modern Cards */
body.dark .modern-card label,
body.dark .modern-card .form-label {
  color: #f0f6fc;
}

/* Links in Modern Cards */
body.dark .modern-card a {
  color: #58a6ff;
}

body.dark .modern-card a:hover {
  color: #79c0ff;
}

/* Badges in Modern Cards */
body.dark .modern-card .badge {
  opacity: 0.9;
}

/* Text Muted in Modern Cards */
body.dark .modern-card .text-muted {
  color: #8b949e !important;
}

/* Small Text in Modern Cards */
body.dark .modern-card small {
  color: #8b949e;
}

/* Alert Boxes in Modern Cards */
body.dark .modern-card .alert-info {
  background-color: #1f6feb;
  border-color: #1f6feb;
  color: #ffffff;
}

body.dark .modern-card .alert-warning {
  background-color: #d29922;
  border-color: #d29922;
  color: #f0f6fc;
}

body.dark .modern-card .alert-danger {
  background-color: #da3633;
  border-color: #da3633;
  color: #ffffff;
}

body.dark .modern-card .alert-success {
  background-color: #238636;
  border-color: #238636;
  color: #ffffff;
}

/* Pre/Code blocks in Modern Cards */
body.dark .modern-card pre,
body.dark .modern-card code {
  background-color: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

/* Nested Cards */
body.dark .modern-card .card {
  background-color: #161b22;
  border-color: #30363d;
}

body.dark .modern-card .card-header {
  background-color: #0d1117;
  border-bottom-color: #30363d;
  color: #f0f6fc;
}

/* Full Width Fix for Modern Cards */
.modern-card.full-width {
  width: 100%;
}

/* Remove any constraining wrappers */
.modern-card-container {
  width: 100%;
}

/* Status Indicators in Modern Cards */
body.dark .modern-card .status-active {
  color: #3fb950;
}

body.dark .modern-card .status-inactive {
  color: #8b949e;
}

body.dark .modern-card .status-error {
  color: #f85149;
}

body.dark .modern-card .status-warning {
  color: #d29922;
}

/* --- Monitoring Dashboard Specific Styles --- */
.modern-content-area.monitoring-dashboard {
  max-width: none;
  padding: 1rem;
}

/* Monitoring Grid System */
.monitoring-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Modern Stat Cards with Theme Support */
.modern-stat-card {
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #dee2e6);
  color: var(--bs-body-color, #212529);
  border-radius: 0.5rem;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.modern-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark .modern-stat-card {
  background: #23272b;
  border-color: #30363d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark .modern-stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Stat card info button for tooltips */
.stat-info-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--bs-secondary);
  font-size: 0.875rem;
  padding: 0.25rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.stat-info-btn:hover {
  opacity: 1;
  color: var(--bs-primary);
}

body.dark .stat-info-btn {
  color: #6c757d;
}

body.dark .stat-info-btn:hover {
  color: #0969da;
}

/* Stat Card Icons */
.modern-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.modern-stat-icon.bg-primary-subtle {
  background: rgba(13, 110, 253, 0.1);
  color: #0d6efd;
}

body.dark .modern-stat-icon.bg-primary-subtle {
  background: rgba(88, 166, 255, 0.2);
  color: #58a6ff;
}

.modern-stat-icon.bg-warning-subtle {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

body.dark .modern-stat-icon.bg-warning-subtle {
  background: rgba(255, 183, 77, 0.2);
  color: #ffb74d;
}

.modern-stat-icon.bg-info-subtle {
  background: rgba(13, 202, 240, 0.1);
  color: #0dcaf0;
}

body.dark .modern-stat-icon.bg-info-subtle {
  background: rgba(128, 222, 234, 0.2);
  color: #80deea;
}

.modern-stat-icon.bg-success-subtle {
  background: rgba(25, 135, 84, 0.1);
  color: #198754;
}

body.dark .modern-stat-icon.bg-success-subtle {
  background: rgba(110, 231, 183, 0.2);
  color: #6ee7b7;
}

/* Stat Card Content */
.modern-stat-content {
  position: relative;
  z-index: 1;
}

.modern-stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
  color: var(--bs-body-color);
}

body.dark .modern-stat-value {
  color: #f0f6fc;
}

.modern-stat-label {
  font-size: 0.875rem;
  color: var(--bs-secondary-color, #6c757d);
  margin-bottom: 0.25rem;
}

body.dark .modern-stat-label {
  color: #8b949e;
}

.modern-stat-trend {
  font-size: 0.75rem;
  color: var(--bs-secondary-color, #6c757d);
}

body.dark .modern-stat-trend {
  color: #6e7681;
}

/* Risk Level Color System with WCAG AAA Contrast */
.risk-very-low {
  background-color: #d1f4e0 !important;
  color: #0e4429 !important;
}

body.dark .risk-very-low {
  background-color: #2e8b57 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 2px solid #51cf66 !important;
}

.risk-low {
  background-color: #c3e9d7 !important;
  color: #1a5a3a !important;
}

body.dark .risk-low {
  background-color: #4682b4 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 2px solid #66d9ef !important;
}

.risk-medium {
  background-color: #fff3cd !important;
  color: #856404 !important;
}

body.dark .risk-medium {
  background-color: #0066cc !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 2px solid #4da6ff !important;
}

.risk-high {
  background-color: #f8d7da !important;
  color: #721c24 !important;
}

body.dark .risk-high {
  background-color: #cc5500 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 2px solid #ff922b !important;
}

.risk-critical {
  background-color: #f5c6cb !important;
  color: #721c24 !important;
}

body.dark .risk-critical {
  background-color: #8b0000 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 2px solid #ff6b6b !important;
}

/* Modern Badge Styles for Risk Levels */
.modern-badge {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.badge-verylow {
  background-color: #198754;
  color: #ffffff;
}

body.dark .badge-verylow {
  background-color: #51cf66;
  color: #0d1117;
}

.badge-low {
  background-color: #0dcaf0;
  color: #ffffff;
}

body.dark .badge-low {
  background-color: #66d9ef;
  color: #0d1117;
}

.badge-medium {
  background-color: #ffc107;
  color: #000000;
}

body.dark .badge-medium {
  background-color: #ffd43b;
  color: #0d1117;
}

.badge-high {
  background-color: #fd7e14;
  color: #ffffff;
}

body.dark .badge-high {
  background-color: #ff922b;
  color: #0d1117;
}

.badge-critical {
  background-color: #dc3545;
  color: #ffffff;
}

body.dark .badge-critical {
  background-color: #ff6b6b;
  color: #ffffff;
}

/* Heat Map Grid Improvements */
.risk-heat-map {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 1rem;
}

body.dark .risk-heat-map {
  background: #161b22;
  border-color: #30363d;
}

.heat-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.heat-map-cell {
  padding: 1.5rem;
  border-radius: 0.375rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.heat-map-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark .heat-map-cell:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.heat-map-label {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.heat-map-value {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
  line-height: 1;
}

.heat-map-percent {
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 1;
}

/* Ensure text visibility in heat map cells */
body.dark .heat-map-cell {
  color: #ffffff !important;
}

/* Heat map intensity classes for dark mode */
body.dark .heat-map-cell.intensity-verylow {
  background-color: #1a472a !important;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 2px solid #2d5a3d !important;
}

body.dark .heat-map-cell.intensity-low {
  background-color: #1e3a5f !important;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 2px solid #2a4d7a !important;
}

body.dark .heat-map-cell.intensity-medium {
  background-color: #5d4e37 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 2px solid #7a6548 !important;
}

body.dark .heat-map-cell.intensity-high {
  background-color: #7c5000 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 2px solid #a66a00 !important;
}

body.dark .heat-map-cell.intensity-critical {
  background-color: #8b0000 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  border: 2px solid #aa2e2e !important;
}

/* Ensure heat map text elements are visible in dark mode */
body.dark .heat-map-label,
body.dark .heat-map-value,
body.dark .heat-map-percent {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Adjust hover state for dark mode */
body.dark .heat-map-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

body.dark .heat-map-cell.risk-very-low,
body.dark .heat-map-cell.risk-low,
body.dark .heat-map-cell.risk-medium,
body.dark .heat-map-cell.risk-high,
body.dark .heat-map-cell.risk-critical {
  color: #ffffff !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 20px rgba(0,0,0,0.8);
}

/* Add visual indicators for accessibility */
.heat-map-cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  border-radius: inherit;
}

body.dark .heat-map-cell.risk-critical::before {
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255,255,255,0.1) 10px,
    rgba(255,255,255,0.1) 20px
  );
}

/* Focus states for keyboard navigation */
.heat-map-cell:focus {
  outline: 4px solid #0d6efd;
  outline-offset: 2px;
}

body.dark .heat-map-cell:focus {
  outline-color: #58a6ff;
}

/* Monitoring Table Optimizations */
.monitoring-table {
  font-size: 0.875rem;
  width: 100%;
}

.monitoring-table th,
.monitoring-table td {
  padding: 0.75rem;
  white-space: nowrap;
}

.monitoring-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bs-body-bg);
}

body.dark .monitoring-table thead {
  background: #161b22;
}

.monitoring-table tbody tr {
  transition: background-color 0.15s;
}

.monitoring-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

body.dark .monitoring-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Risk Score Display */
.risk-score-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.risk-score-value {
  font-weight: 600;
  font-size: 1rem;
}

.risk-score-bar {
  flex: 1;
  height: 6px;
  background: var(--bs-gray-200);
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}

body.dark .risk-score-bar {
  background: #30363d;
}

.risk-score-fill {
  height: 100%;
  background: linear-gradient(90deg, #198754 0%, #ffc107 50%, #dc3545 100%);
  transition: width 0.3s ease;
}

/* Alert Queue Styles */
.alert-queue {
  max-height: 400px;
  overflow-y: auto;
}

.alert-item {
  padding: 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  transition: background-color 0.15s;
}

body.dark .alert-item {
  border-bottom-color: #30363d;
}

.alert-item:hover {
  background-color: var(--bs-gray-100);
}

body.dark .alert-item:hover {
  background-color: #21262d;
}

/* Connection Status Indicator */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.connection-status.connected {
  background-color: rgba(25, 135, 84, 0.1);
  color: #198754;
}

body.dark .connection-status.connected {
  background-color: rgba(81, 207, 102, 0.2);
  color: #51cf66;
}

.connection-status.disconnected {
  background-color: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

body.dark .connection-status.disconnected {
  background-color: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
}

/* Action Buttons in Tables */
.action-buttons {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.action-buttons .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Empty State Improvements */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color);
}

body.dark .empty-state {
  color: #6e7681;
}

.empty-state i {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

/* User Avatar for Tables */
.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bs-gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--bs-gray-600);
}

body.dark .user-avatar-sm {
  background: #30363d;
  color: #8b949e;
}

/* ==========================================================================
   Missing Bootstrap Utility Dark Mode Overrides
   Covers bg-light, bg-white, borders, pagination, list-group, accordion,
   dropdown, offcanvas, progress, and alert-light
   ========================================================================== */

/* --- bg-light and bg-white --- */
body.dark .bg-light {
  background-color: #2a2f35 !important;
  color: #e4e4e7 !important;
}

body.dark .bg-white {
  background-color: #1e2126 !important;
}

/* --- Border utilities --- */
body.dark .border-light {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark .border-secondary {
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* --- Pagination --- */
body.dark .page-link {
  background-color: #23272b;
  color: #90caf9;
  border-color: #444;
}

body.dark .page-link:hover {
  background-color: #2a2f35;
  color: #bbdefb;
  border-color: #555;
}

body.dark .page-item.active .page-link {
  background-color: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

body.dark .page-item.disabled .page-link {
  background-color: #1a1d21;
  color: #555;
  border-color: #343a40;
}

/* --- List Group --- */
body.dark .list-group-item {
  background-color: #23272b;
  color: #f1f1f1;
  border-color: #444;
}

body.dark .list-group-item-action:hover,
body.dark .list-group-item-action:focus {
  background-color: #2a2f35;
  color: #fff;
}

body.dark .list-group-item.active {
  background-color: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

/* --- Accordion --- */
body.dark .accordion-item {
  background-color: #23272b;
  border-color: #444;
  color: #f1f1f1;
}

body.dark .accordion-button {
  background-color: #23272b;
  color: #f1f1f1;
  box-shadow: none;
}

body.dark .accordion-button:not(.collapsed) {
  background-color: #2a2f35;
  color: #90caf9;
}

body.dark .accordion-button::after {
  filter: invert(1);
}

body.dark .accordion-body {
  background-color: #1e2126;
  color: #e0e0e0;
}

/* --- Dropdown --- */
body.dark .dropdown-menu {
  background-color: #23272b;
  border-color: #444;
  color: #f1f1f1;
}

body.dark .dropdown-item {
  color: #e0e0e0;
}

body.dark .dropdown-item:hover,
body.dark .dropdown-item:focus {
  background-color: #2a2f35;
  color: #fff;
}

body.dark .dropdown-item.active,
body.dark .dropdown-item:active {
  background-color: #1976d2;
  color: #fff;
}

body.dark .dropdown-divider {
  border-color: #444;
}

body.dark .dropdown-header {
  color: #8b949e;
}

/* --- Offcanvas --- */
body.dark .offcanvas {
  background-color: #1e2126;
  color: #f1f1f1;
}

body.dark .offcanvas-header {
  border-bottom-color: #444;
}

body.dark .offcanvas .btn-close {
  filter: invert(1);
}

/* --- Progress --- */
body.dark .progress {
  background-color: #343a40;
}

body.dark .progress-bar {
  color: #fff;
}

/* --- Alert Light --- */
body.dark .alert-light {
  background-color: #2a2f35;
  border-color: #444;
  color: #e0e0e0;
}

/* --- Toast --- */
body.dark .toast {
  background-color: #23272b;
  border-color: #444;
  color: #f1f1f1;
}

body.dark .toast-header {
  background-color: #1e2126;
  border-bottom-color: #444;
  color: #e0e0e0;
}

/* --- Popover --- */
body.dark .popover {
  background-color: #23272b;
  border-color: #444;
}

body.dark .popover-header {
  background-color: #1e2126;
  border-bottom-color: #444;
  color: #f0f6fc;
}

body.dark .popover-body {
  color: #e0e0e0;
}

/* --- Tab Content Panes --- */
body.dark .tab-content {
  background-color: #1e2126;
  color: #f1f1f1;
}

body.dark .nav-tabs {
  border-bottom-color: #444;
}

/* --- Input Group --- */
body.dark .input-group-text {
  background-color: #343a40;
  border-color: #444;
  color: #e0e0e0;
}