:root {
    --sidebar-width: 260px;
    --sidebar-bg: #f8f9fa;
    --primary-color: #6f42c1; /* Purple */
    --text-dark: #333333;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --bg-light: #f8f9fa;
}

/* Dark Mode Variables */
body.dark-mode {
    --sidebar-bg: #1f2937;
    --text-dark: #f9fafb;
    --text-muted: #9ca3af;
    --border-color: #374151;
    --bg-light: #111827;
    --primary-color: #a78bfa; /* Lighter purple for dark mode */
}

body.dark-mode .main-content,
body.dark-mode .top-bar {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

body.dark-mode .sidebar {
    background-color: var(--sidebar-bg);
    border-right-color: var(--border-color);
}

/* Dark Mode Dropdowns */
body.dark-mode .dropdown-menu {
    background-color: #1f2937;
    border-color: #374151;
}

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

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

body.dark-mode .dropdown-divider {
    border-top-color: #374151;
}

/* Dark Mode Common Components */
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .list-group-item {
    background-color: #1f2937;
    color: #f9fafb;
    border-color: var(--border-color);
}

body.dark-mode .list-group-item.bg-light {
    background-color: #374151 !important;
}
body.dark-mode .list-group-item.bg-white {
    background-color: #1f2937 !important;
}

body.dark-mode .nav-item {
    color: var(--text-dark);
}
body.dark-mode .nav-item:hover,
body.dark-mode .site-row:hover,
body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
    background-color: #374151;
    color: #f9fafb;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}
body.dark-mode .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23f9fafb' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='4 6 8 10 12 6'/%3e%3c/svg%3e");
}
body.dark-mode .form-control::placeholder {
    color: #9ca3af;
}

body.dark-mode .btn-admin {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

body.dark-mode .btn-admin:hover {
    background-color: #4b5563;
}

body.dark-mode .text-dark,
body.dark-mode .link-dark {
    color: #f9fafb !important;
}

body.dark-mode .offcanvas {
    background-color: #1f2937;
    color: #f9fafb;
}
body.dark-mode .offcanvas-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

body.dark-mode .site-row {
    border-bottom-color: var(--border-color);
}
body.dark-mode .site-row:hover {
    background-color: #1f2937; /* or slightly lighter? */
}

body.dark-mode .sidebar .nav-item.active {
    background-color: #4c1d95; /* Darker purple */
    color: #f9fafb;
    border-right-color: #a78bfa;
}
body.dark-mode .sidebar .nav-item.active i {
    color: #f9fafb;
}

body.dark-mode .site-url {
    color: #e5e7eb !important; /* Lighter grey */
}

/* Global Dark Mode Text Muted Override */
body.dark-mode .text-muted {
    color: #9ca3af !important;
}

/* Dark Mode Background Overrides */
body.dark-mode .bg-light {
    background-color: #111827 !important;
}

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

body.dark-mode .border,
body.dark-mode .border-end,
body.dark-mode .border-bottom {
    border-color: #374151 !important;
}

/* Dark Mode Alerts */
body.dark-mode .alert-light {
    background-color: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

body.dark-mode .alert-success {
    background-color: #064e3b;
    border-color: #065f46;
    color: #d1fae5;
}

body.dark-mode .alert-success .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

body.dark-mode .alert-danger {
    background-color: #7f1d1d;
    border-color: #991b1b;
    color: #fee2e2;
}

body.dark-mode .alert-danger .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Inner Sidebar Nav */
body.dark-mode .nav-pills .nav-link.active,
body.dark-mode .nav-pills .show > .nav-link {
    background-color: var(--primary-color);
    color: #fff;
}
body.dark-mode .nav-link {
    color: #e5e7eb;
}
body.dark-mode .nav-link:hover {
    color: #fff;
}

/* Dark Mode Status Icons */
body.dark-mode .status-up {
    background-color: rgba(15, 179, 108, 0.2);
    color: #34d399;
}

body.dark-mode .status-down {
    background-color: rgba(220, 53, 69, 0.2);
    color: #f87171;
}

body.dark-mode .status-paused {
    background-color: rgba(108, 117, 125, 0.2);
    color: #9ca3af;
}

body.dark-mode .status-unknown {
    background-color: rgba(255, 193, 7, 0.2);
    color: #fbbf24;
}

body.dark-mode .action-btn:hover {
    background-color: #064e3b;
}

body.dark-mode .page-link-custom {
    color: #f9fafb;
    border-color: #4b5563;
}
body.dark-mode .page-link-custom:hover {
    background-color: #374151;
}
body.dark-mode .page-link-custom.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

/* Dark Mode Button Overrides */
body.dark-mode .btn-outline-dark {
    color: #f9fafb;
    border-color: #f9fafb;
}
body.dark-mode .btn-outline-dark:hover {
    background-color: #f9fafb;
    color: #1f2937;
}

body.dark-mode .btn-outline-secondary {
    color: #d1d5db;
    border-color: #6b7280;
}
body.dark-mode .btn-outline-secondary:hover {
    background-color: #374151;
    color: #fff;
    border-color: #6b7280;
}

/* Ensure icons inside buttons inherit color correctly */
body.dark-mode .btn i {
    color: inherit !important;
}
body.dark-mode .top-bar a,
body.dark-mode .top-bar .text-muted {
    color: #e5e7eb !important;
}

body.dark-mode .top-bar-title,
body.dark-mode .top-bar-title-icon {
    color: #9ca3af;
}

/* Sort Text & Filters */
body.dark-mode .search-filter-bar,
body.dark-mode .search-filter-bar .text-muted {
    color: #e5e7eb !important;
}

/* Three Dots / Actions */
body.dark-mode .site-actions .text-muted,
body.dark-mode .site-actions .dropdown-toggle {
    color: #e5e7eb !important;
}

/* Sidebar Footer / Collapse */
body.dark-mode .sidebar-footer,
body.dark-mode .sidebar-footer .nav-link,
body.dark-mode .sidebar-footer i {
    color: #e5e7eb !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    margin: 0;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Centered Layout (Login, Invite, etc.) */
body.centered-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    /* Reduced z-index to be below Bootstrap's offcanvas backdrop (z-index 1040) */
    z-index: 1000;
    transition: width 0.3s ease;
}

/* Collapsed Sidebar State */
body.sidebar-collapsed .sidebar {
    width: 60px;
}

body.sidebar-collapsed .main-content {
    margin-left: 60px;
}

/* Hide text in collapsed sidebar */
body.sidebar-collapsed .sidebar-header .nav-text,
body.sidebar-collapsed .sidebar .nav-item .nav-text,
body.sidebar-collapsed .sidebar-footer .nav-text,
body.sidebar-collapsed .nav-header {
    display: none !important;
}

/* Fix dropdown in collapsed mode */
body.sidebar-collapsed .sidebar-header .dropdown-menu {
    width: auto !important;
    min-width: 250px;
    top: 0;
    left: 100%;
    margin-left: 10px;
}

/* Center icons in collapsed state */
body.sidebar-collapsed .sidebar .nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar .nav-item i {
    margin-right: 0;
    font-size: 1.2rem;
}
body.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 1rem 0;
}

body.sidebar-collapsed .workspace-selector {
    display: flex !important;
    justify-content: center;
    width: 100%;
    padding: 0;
}

body.sidebar-collapsed .workspace-selector i {
    margin-right: 0 !important;
    font-size: 1.5rem;
}

body.sidebar-collapsed .sidebar-header .settings-icon {
    display: none !important;
}

body.sidebar-collapsed .sidebar-header .nav-icon-only {
    display: none !important;
}

body.sidebar-collapsed .sidebar-header i {
    margin-right: 0;
    font-size: 1.5rem;
}

/* Adjust footer for collapsed state */
body.sidebar-collapsed .sidebar-footer {
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

/* Rotate collapse icon */
#collapseIcon {
    transition: transform 0.3s ease;
    display: inline-block;
}

body.sidebar-collapsed #collapseIcon {
    transform: rotate(180deg);
}

/* Dark Mode Table Overrides */
body.dark-mode .table {
    color: #e5e7eb;
    border-color: #374151;
}
body.dark-mode .table > :not(caption) > * > * {
    background-color: transparent;
    color: inherit;
    border-bottom-color: #374151;
}
body.dark-mode .table-hover > tbody > tr:hover > * {
    color: #f9fafb;
    background-color: #374151;
}

/* Dark Mode Text Utilities */
body.dark-mode .text-dark {
    color: #f9fafb !important;
}

/* Dark Mode Nav Tabs */
body.dark-mode .nav-tabs {
    border-bottom-color: #374151;
}
body.dark-mode .nav-tabs .nav-link:hover,
body.dark-mode .nav-tabs .nav-link:focus {
    border-color: #374151 #374151 #1f2937;
}
body.dark-mode .nav-tabs .nav-link.active {
    color: #f9fafb;
    background-color: #1f2937;
    border-color: #374151 #374151 #1f2937;
}

/* Dark Mode Dropdowns */
body.dark-mode .dropdown-menu {
    background-color: #1f2937;
    border-color: #374151;
}
body.dark-mode .dropdown-item {
    color: #e5e7eb;
}
body.dark-mode .dropdown-item:hover,
body.dark-mode .dropdown-item:focus {
    background-color: #374151;
    color: #f9fafb;
}
body.dark-mode .dropdown-divider {
    border-top-color: #374151;
}
.sidebar-header {
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    align-items: center;
    color: var(--primary-color);
}
.workspace-selector {
    display: flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    flex-grow: 1;
    margin-right: 0.5rem;
    white-space: nowrap;
}

.workspace-selector:hover {
    color: #553098;
}

.workspace-selector i:first-child {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.nav-icon-only {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.2s;
}

.nav-icon-only:hover {
    color: var(--text-dark);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    margin-top: 1rem;
    font-weight: 600;
}

.nav-item {
    list-style: none;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-dark);
    text-decoration: none;
    transition: background-color 0.2s;
    font-weight: 500;
    white-space: nowrap; /* Prevent text wrapping */
}

.sidebar .nav-item:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}

.sidebar .nav-item.active {
    background-color: #f0ebf8; /* Light purple bg */
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
}

.sidebar .nav-item i {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    color: var(--text-muted);
}

.sidebar .nav-item.active i {
    color: var(--primary-color);
}

/* Bulk Management Submenu */
.bulk-management-group {
    position: relative;
}

.bulk-management-group > .nav-item {
    position: relative;
    padding-right: 2.5rem;
}

.bulk-management-group .bulk-chevron {
    position: absolute;
    right: 1.25rem;
    margin: 0 !important;
    width: auto !important;
    transition: transform 0.2s ease;
}

.bulk-management-group > .nav-item[aria-expanded="true"] .bulk-chevron {
    transform: rotate(180deg);
}

.nav-submenu .nav-subitem {
    padding-left: 3rem;
    font-size: 0.9em;
    font-weight: 400;
}

body.dark-mode .nav-submenu .nav-subitem {
    color: var(--text-dark);
}

body.sidebar-collapsed .nav-submenu {
    display: none !important;
}

body.sidebar-collapsed .bulk-chevron {
    display: none !important;
}

/* Bulk Management Collapsed Flyout */
.bulk-flyout-panel {
    position: fixed;
    left: 60px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1100;
    padding: 6px 0;
    border: 1px solid var(--border-color);
}

.bulk-flyout-header {
    padding: 8px 16px 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.bulk-flyout-item {
    display: block;
    padding: 9px 16px;
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.15s;
}

.bulk-flyout-item:hover {
    background-color: #f0ebf8;
    color: var(--primary-color);
}

.bulk-flyout-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

body.dark-mode .bulk-flyout-panel {
    background: #1f2937;
    border-color: #374151;
}

body.dark-mode .bulk-flyout-header {
    border-color: #374151;
    color: #9ca3af;
}

body.dark-mode .bulk-flyout-item {
    color: #e5e7eb;
}

body.dark-mode .bulk-flyout-item:hover {
    background-color: #4c1d95;
    color: #f9fafb;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    background-color: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    position: relative; /* Ensure stacking context */
    z-index: 1; /* Lower than sidebar but establishes context */
}

.top-bar {
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    position: sticky;
    top: 0;
    z-index: 90;
}

.top-bar-title {
    color: #6b7280;
    font-size: 1rem;
    font-weight: 500;
}

.top-bar-title-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #6b7280;
    flex-shrink: 0;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
    position: relative; /* Ensure alerts inside stack correctly */
    z-index: 1; 
}

/* Ensure Alerts sit nicely */
.alert {
    position: relative;
    z-index: 10;
}

/* Monitoring summary stat tiles */
.stat-tile .card-body {
    padding: 1.25rem;
}

.stat-tile__title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-dark);
    text-transform: none;
    letter-spacing: 0;
}

.stat-tile__info {
    font-size: 0.75rem;
    font-weight: 900;
    font-family: "Font Awesome 6 Free", "Font Awesome 5 Free", sans-serif;
    color: var(--text-muted);
    margin-left: 0.15rem;
    cursor: help;
}

.stat-tile__pair {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
}

.stat-tile__value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-tile__value--success {
    color: #0fb36c;
}

.stat-tile__value--orange {
    color: #e67e22;
}

.stat-tile__value--danger {
    color: #dc3545;
}

.stat-tile__label {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-muted);
}

.stat-tile__divider {
    width: 1px;
    height: 1.25em;
    background-color: var(--border-color);
    flex-shrink: 0;
}

.stat-tile__divider--sm {
    height: 1em;
}

.stat-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 4px;
}

.stat-badge--success {
    background-color: rgba(15, 179, 108, 0.15);
    color: #0fb36c;
}

.stat-badge--warning {
    background-color: rgba(255, 193, 7, 0.2);
    color: #b8860b;
}

.stat-badge--danger {
    background-color: rgba(220, 53, 69, 0.15);
    color: #dc3545;
}

.uptime-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 32px;
}

.uptime-bars__bar {
    flex: 1;
    min-width: 3px;
    background-color: #0fb36c;
    border-radius: 2px;
    transition: height 0.2s ease;
}

.stat-tile__pagespeed {
    flex-wrap: wrap;
}

.stat-tile__pagespeed-g {
    font-weight: 700;
    color: var(--text-dark);
}

/* Monitoring table: Performance column and row alignment */
.content-body .table.table-hover tbody td {
    vertical-align: middle !important;
}

.content-body .table.table-hover thead th {
    vertical-align: middle !important;
}

.performance-col {
    color: var(--text-muted) !important;
    font-weight: 500;
}

.performance-cell {
    white-space: nowrap;
    vertical-align: middle !important;
    border-bottom: none !important;
    line-height: 1;
}

.performance-cell .performance-cell__g,
.performance-cell .performance-cell__sep,
.performance-cell .performance-cell__icon,
.performance-cell .performance-score {
    display: inline;
    vertical-align: middle;
}

.performance-cell__g {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.9375rem;
}

.performance-cell__sep {
    display: inline-block;
    width: 1px;
    height: 1em;
    background-color: var(--border-color);
    margin: 0 0.5rem;
    vertical-align: middle;
}

.performance-cell__icon {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-right: 0.25rem;
}

.performance-score {
    font-weight: 500;
    font-size: 0.9375rem;
}

.performance-score--good {
    color: #0fb36c;
}

.performance-score--average {
    color: #e67e22;
}

.performance-score--poor {
    color: #dc3545;
}

body.dark-mode .performance-col {
    color: var(--text-muted) !important;
}

body.dark-mode .performance-score--good {
    color: #34d399;
}

body.dark-mode .performance-score--average {
    color: #f59e0b;
}

body.dark-mode .performance-score--poor {
    color: #ef4444;
}

body.dark-mode .stat-tile__title {
    color: var(--text-dark);
}

body.dark-mode .stat-tile__value:not([class*="--success"]):not([class*="--orange"]):not([class*="--danger"]) {
    color: var(--text-dark);
}

body.dark-mode .stat-badge--success {
    background-color: rgba(15, 179, 108, 0.25);
}

body.dark-mode .stat-badge--warning {
    background-color: rgba(255, 193, 7, 0.25);
}

body.dark-mode .stat-badge--danger {
    background-color: rgba(220, 53, 69, 0.25);
}

body.dark-mode .uptime-bars__bar {
    background-color: #0fb36c;
}

/* Search & Filters */
.search-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-input-group {
    position: relative;
    width: 300px;
}

.search-input-group input {
    padding-left: 2.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.search-input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Sites / Monitoring search & filter bar (pill style, icon buttons) */
.search-filter-bar--sites {
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-filter-bar--sites .search-filter-bar__form {
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 360px;
}

.search-input-group--pill {
    width: 100%;
}

.search-input-group--pill .search-input-group__input {
    border-radius: 9999px;
    padding-left: 2.5rem;
    padding-right: 1.25rem;
    border: 1px solid var(--border-color);
    background-color: #fff;
    color: var(--text-dark);
    font-size: 0.9375rem;
}

.search-input-group--pill .search-input-group__input::placeholder {
    color: var(--text-muted);
}

.search-input-group--pill .search-input-group__icon {
    left: 1.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-filter {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-dark);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    white-space: nowrap;
}

/* Monitoring bulk actions bar (between search bar and table) */
.monitoring-bulk-bar {
    background-color: #f5f3f8;
    border: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

body.dark-mode .monitoring-bulk-bar {
    background-color: rgba(55, 65, 81, 0.5);
    border-color: var(--border-color);
}

.monitoring-bulk-bar__select-all {
    color: var(--primary-color);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
}

.monitoring-bulk-bar__select-all:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.monitoring-bulk-bar__clear {
    color: #0d6efd;
    font-weight: 700;
    font-size: 0.9375rem;
}

.monitoring-bulk-bar__clear:hover {
    color: #0a58ca;
    text-decoration: underline;
}

body.dark-mode .monitoring-bulk-bar__clear {
    color: #6ea8fe;
}

body.dark-mode .monitoring-bulk-bar__clear:hover {
    color: #9ec5fe;
}

.monitoring-bulk-bar__count {
    font-size: 0.9375rem;
}

.monitoring-bulk-bar__actions {
    font-size: 0.9375rem;
}

.monitoring-bulk-bar__action {
    color: var(--text-muted) !important;
}

.monitoring-bulk-bar__action:not(:disabled):hover {
    color: var(--text-dark) !important;
}

.monitoring-bulk-bar__action:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.monitoring-bulk-bar__divider {
    width: 1px;
    height: 1em;
    background-color: var(--border-color);
}

.btn-filter:hover {
    background-color: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-dark);
}

.btn-filter .dropdown-toggle::after {
    margin-left: 0.35rem;
}

body.dark-mode .search-input-group--pill .search-input-group__input {
    background-color: #374151;
    border-color: #4b5563;
    color: var(--text-dark);
}

body.dark-mode .btn-filter {
    background-color: #374151;
    border-color: #4b5563;
    color: var(--text-dark);
}

body.dark-mode .btn-filter:hover {
    background-color: #4b5563;
    border-color: #6b7280;
    color: #fff;
}

@media (max-width: 768px) {
    .top-bar {
        padding: 0.75rem 1rem;
    }

    .content-body {
        padding: 1rem;
    }

    .search-filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .search-filter-bar form {
        width: 100%;
        max-width: 100% !important;
    }

    .search-input-group {
        width: 100%;
    }

    .search-filter-bar > .dropdown,
    .search-filter-bar > .d-flex {
        width: 100%;
    }

    .search-filter-bar > .d-flex {
        justify-content: flex-end;
        flex-wrap: wrap;
        column-gap: 0.5rem;
        row-gap: 0.5rem;
    }
}

/* Site List Row */
.site-row {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.1s;
}

.site-row:hover {
    background-color: #fbfbfb;
}

.site-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 12px;
}

/* Status Variants (Light Mode) */
.status-up {
    background-color: #e6f9f0;
    color: #0fb36c;
}

.status-down {
    background-color: #fde8e8;
    color: #dc3545;
}

.status-paused {
    background-color: #e9ecef;
    color: #6c757d;
}

.status-unknown {
    background-color: #fff3cd;
    color: #ffc107;
}

.site-info {
    width: 450px; /* Fixed width for alignment on desktop */
    padding-right: 1rem;
}

.site-title {
    font-weight: 600;
    color: #6f42c1; /* Purple link color */
    text-decoration: none;
    display: block;
    margin-bottom: 2px;
}

.site-url {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.site-metrics {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-grow: 1;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.metric-icon-g {
    /* Google G icon style placeholder */
    font-weight: bold;
    color: #4285f4;
}

.metric-risk {
    color: #dc3545; /* Red */
}

.metric-update {
    color: #dc3545;
}

.site-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile layout for Sites list */
@media (max-width: 768px) {
    .site-row {
        align-items: flex-start;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .site-info {
        width: 100%;
        padding-right: 0;
        margin-top: 0.5rem;
    }

    .site-status-icon {
        order: 2;
        margin-top: 0.75rem;
        margin-right: 0.5rem;
    }

    .site-actions {
        order: 2;
        margin-top: 0.5rem;
        flex-wrap: wrap;
    }

    .site-actions .btn-admin {
        margin-left: 0;
    }
}

.action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #0fb36c; /* Green icons */
    background: transparent;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:hover {
    background-color: #e6f9f0;
}

.btn-admin {
    border-radius: 20px;
    padding: 0.25rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-admin:hover {
    background-color: var(--bg-light);
    border-color: #d3d3d3;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-link-custom {
    border: 1px solid var(--border-color);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    color: var(--text-dark);
    text-decoration: none;
    margin: 0 2px;
}

.page-link-custom.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
    font-weight: 600;
}

/* Team Management */
.team-tabs {
    border-bottom: 1px solid var(--border-color);
}

.team-tabs .nav-link {
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
}

.team-tabs .nav-link:hover {
    color: var(--primary-color);
    border-color: transparent;
}

.team-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    background: transparent;
}

.team-row {
    display: flex;
    align-items: center;
    background: white;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.team-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.team-avatar {
    width: 40px;
    height: 40px;
    background-color: #f3e5f5; /* Light purple */
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 1.5rem;
    font-size: 1rem;
}

.team-info {
    display: flex;
    flex-direction: column;
}

.team-actions .btn-link {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s;
}

.team-actions .btn-link:hover {
    color: var(--primary-color);
}

/* App Confirm / Alert modals (themed) */
.app-confirm-modal .modal-dialog,
.app-alert-modal .modal-dialog {
    max-width: 420px;
}
.app-confirm-modal-content,
.app-alert-modal-content {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}
.app-confirm-modal-header .modal-title,
.app-alert-modal-header .modal-title {
    color: var(--text-dark);
    font-weight: 600;
}
.app-confirm-modal-body .app-confirm-message,
.app-alert-modal-body .app-alert-message {
    color: var(--text-dark);
    line-height: 1.5;
}
.app-confirm-ok,
.app-alert-ok {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
}
.app-confirm-ok:hover,
.app-alert-ok:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    filter: brightness(1.08);
}
.app-confirm-cancel {
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
}
body.dark-mode .app-confirm-modal-content,
body.dark-mode .app-alert-modal-content {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
body.dark-mode .app-confirm-ok,
body.dark-mode .app-alert-ok {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
body.dark-mode .app-confirm-ok:hover,
body.dark-mode .app-alert-ok:hover {
    filter: brightness(1.15);
}

/* Signature preview (Report template – Email content step) */
.signature-preview-label {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    background-color: var(--bg-light);
    border-radius: 9999px;
    margin-bottom: 0.5rem;
}
.signature-preview-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    padding: 1.25rem;
}
body.dark-mode .signature-preview-box {
    background-color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.signature-preview-logo-row {
    margin-bottom: 0.75rem;
}
.signature-preview-logo-wrap .sig-preview-logo-img {
    max-height: 48px;
    width: auto;
    display: block;
}
.signature-preview-remove-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}
.signature-preview-remove-btn:hover {
    background-color: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-dark);
}
body.dark-mode .signature-preview-remove-btn {
    background: #374151;
    border-color: var(--border-color);
    color: var(--text-dark);
}
body.dark-mode .signature-preview-remove-btn:hover {
    background: #4b5563;
}
.signature-preview-body {
    font-size: 0.875rem;
    color: var(--text-dark);
}
.signature-preview-name {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}
.signature-preview-line {
    margin-bottom: 0.2rem;
}
.signature-preview-line:last-child {
    margin-bottom: 0;
}
.signature-preview-line a {
    color: var(--text-dark);
    text-decoration: none;
}
.signature-preview-line a:hover {
    text-decoration: underline;
}
body.dark-mode .signature-preview-label {
    background-color: #374151;
    color: var(--text-muted);
}
body.dark-mode .signature-preview-body,
body.dark-mode .signature-preview-name,
body.dark-mode .signature-preview-line,
body.dark-mode .signature-preview-line a {
    color: var(--text-dark);
}

/* PDF Add section button and grid menu (Report template step 3) */
.pdf-add-section-btn {
    background: #fff;
    border: 2px dashed var(--primary-color);
    color: var(--primary-color);
}
.pdf-add-section-btn:hover,
.pdf-add-section-btn:focus {
    background: rgba(111, 66, 193, 0.06);
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.pdf-add-section-menu {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}
.pdf-add-section-choice {
    color: var(--primary-color) !important;
}
.pdf-add-section-choice:hover {
    background: rgba(111, 66, 193, 0.08);
    color: var(--primary-color) !important;
}
.pdf-add-section-icon {
    color: var(--primary-color);
    opacity: 0.9;
}
.pdf-add-section-choice-disabled,
.pdf-add-section-choice:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.pdf-add-section-choice-disabled .pdf-add-section-icon {
    opacity: 0.6;
}
body.dark-mode .pdf-add-section-btn {
    background: #1f2937;
    border-color: var(--primary-color);
    color: var(--primary-color);
}
body.dark-mode .pdf-add-section-btn:hover {
    background: rgba(167, 139, 250, 0.15);
}
body.dark-mode .pdf-add-section-menu {
    background: #1f2937;
    border-color: var(--border-color);
}
body.dark-mode .pdf-add-section-choice {
    color: var(--primary-color) !important;
}
body.dark-mode .pdf-add-section-choice:hover {
    background: rgba(167, 139, 250, 0.12);
}
body.dark-mode .pdf-add-section-icon {
    color: var(--primary-color);
}

/* PDF Cover preview (Report template step 3) – Default/Custom toggle: raised pill buttons */
.pdf-cover-tabs.btn-group {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.pdf-cover-tab {
    background-color: #f1f3f5;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 0.4rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
}
.pdf-cover-tab:hover {
    background-color: #e9ecef;
    color: #212529;
    border-color: #dee2e6;
}
.pdf-cover-tab.active {
    background-color: #e2e3e5;
    border-color: #ced4da;
    color: #212529;
    font-weight: 500;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}
.pdf-cover-tab:first-of-type { border-radius: 0.375rem 0 0 0.375rem; }
.pdf-cover-tab:last-of-type { border-radius: 0 0.375rem 0.375rem 0; }
.pdf-cover-tab + .pdf-cover-tab { margin-left: -1px; }

/* Color selectors: single panel with rectangular layout icons */
.pdf-cover-color-panel {
    background-color: #f1f3f5;
    border: 1px solid #dee2e6;
}
/* Cover orientation: vertical (stacked) vs horizontal (side-by-side) */
.pdf-cover-orientation-btn {
    width: 40px;
    height: 32px;
    background: #e9ecef;
    border: 2px solid #dee2e6;
    cursor: pointer;
    padding: 0;
    border-radius: 0.375rem;
    overflow: hidden;
}
.pdf-cover-orientation-btn:hover {
    background: #e2e3e5;
}
.pdf-cover-orientation-btn.pdf-cover-orientation-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}
.pdf-cover-orientation-inner {
    border-radius: 0.2rem;
}
/* Non-selected: both icons greyscale */
.pdf-cover-orientation-stacked {
    background: linear-gradient(to bottom, #9ca3af 50%, #e5e7eb 50%);
}
.pdf-cover-orientation-side {
    background: linear-gradient(to right, #9ca3af 33.33%, #e5e7eb 33.33%);
}
/* Selected: icon in color */
.pdf-cover-orientation-active .pdf-cover-orientation-stacked {
    background: linear-gradient(to bottom, var(--primary-color) 50%, #e5e7eb 50%);
}
.pdf-cover-orientation-active .pdf-cover-orientation-side {
    background: linear-gradient(to right, var(--primary-color) 33.33%, #e5e7eb 33.33%);
}
/* Cover preview: fill column width, proportionally taller (reference: min-h 81vh) */
.pdf_cover_preview_wrapper {
    width: 740px;
    max-width: 100%;
    height: 775px;
    max-height: 85vh;
}
/* Tabs overlay: centered at top, gray bar, rounded bottom only */
.pdf-cover-tabs-overlay {
    min-width: 65px;
    background-color: #f3f4f6;
    z-index: 100;
    pointer-events: none;
}
.pdf-cover-tabs-overlay .pdf-cover-tabs,
.pdf-cover-tabs-overlay .btn {
    pointer-events: auto;
}
.pdf-cover-tabs-overlay .pdf-cover-tabs.btn-group {
    background-color: transparent;
    border: none;
}
/* Color panel overlay: centered below tabs */
.pdf-cover-color-overlay {
    top: 4rem;
    z-index: 100;
    pointer-events: none;
}
.pdf-cover-color-overlay .pdf-cover-color-panel,
.pdf-cover-color-overlay .btn,
.pdf-cover-color-overlay .form-check-input,
.pdf-cover-color-overlay label {
    pointer-events: auto;
}
.pdf-cover-color-overlay .pdf-cover-color-panel {
    background-color: #f3f4f6;
    backdrop-filter: blur(4px);
}
/* Cover content: grid 2/5 + 3/5 (z-index below overlays so controls stay on top) */
.pdf-cover-preview {
    width: 100%;
    height: 100%;
    inset: 0;
    z-index: 1;
}
.pdf-cover-default {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}
.pdf-cover-grid {
    display: grid;
    grid-template-columns: minmax(180px, 40%) 1fr;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
}
.pdf-cover-grid.pdf-cover-grid-vertical {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(120px, 40%) 1fr;
}
.pdf-cover-grid.pdf-cover-grid-vertical .pdf-cover-left,
.pdf-cover-grid.pdf-cover-grid-vertical .pdf-cover-right {
    width: 100%;
    min-height: 0;
}
.pdf-cover-left {
    width: 100%;
    min-width: 0;
    min-height: 100%;
}
.pdf-cover-right {
    min-width: 0;
    min-height: 100%;
    overflow-wrap: break-word;
}
.pdf-cover-logo-box {
    z-index: 1;
    max-width: 100%;
    box-sizing: border-box;
    padding: 1rem;
}
.pdf-cover-logo-content {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
    text-align: center;
}
.pdf-cover-logo-content img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}
.pdf-cover-logo-placeholder {
    border-color: currentColor !important;
    color: inherit;
}
.pdf-cover-logo-placeholder i,
.pdf-cover-logo-placeholder span {
    color: inherit;
}
/* Editable cover title */
.pdf-cover-title-editable {
    cursor: text;
    outline: none;
    min-width: 1.5em;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}
.pdf-cover-title-editable:focus {
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.pdf-cover-title-editable:empty:before {
    content: attr(data-placeholder);
    color: #adb5bd;
}
/* Custom cover view */
.pdf-cover-custom {
    z-index: 1;
    background: #f1f3f5;
    width: 100%;
    height: 100%;
}
.pdf-cover-custom #pdf_cover_custom_display {
    width: 100%;
    height: 100%;
    min-height: 100%;
}
.pdf-cover-custom-placeholder {
    background: #fff;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.pdf-cover-custom-img {
    object-fit: cover;
    object-position: center;
}
body.dark-mode .pdf-cover-tabs-overlay {
    background-color: rgba(31, 41, 55, 0.95);
}
body.dark-mode .pdf-cover-color-overlay .pdf-cover-color-panel {
    background-color: rgba(31, 41, 55, 0.95);
}
body.dark-mode .pdf-cover-tab {
    background-color: #374151;
    border-color: var(--border-color);
    color: var(--text-dark);
}
body.dark-mode .pdf-cover-tab.active {
    background-color: #4b5563;
    border-color: var(--border-color);
}
body.dark-mode .pdf-cover-color-panel {
    background-color: #374151;
    border-color: var(--border-color);
}
body.dark-mode .pdf-cover-orientation-btn {
    background: #4b5563;
    border-color: var(--border-color);
}
body.dark-mode .pdf-cover-orientation-stacked {
    background: linear-gradient(to bottom, #6b7280 50%, #4b5563 50%);
}
body.dark-mode .pdf-cover-orientation-side {
    background: linear-gradient(to right, #6b7280 33.33%, #4b5563 33.33%);
}
body.dark-mode .pdf-cover-orientation-active .pdf-cover-orientation-stacked {
    background: linear-gradient(to bottom, var(--primary-color) 50%, #4b5563 50%);
}
body.dark-mode .pdf-cover-orientation-active .pdf-cover-orientation-side {
    background: linear-gradient(to right, var(--primary-color) 33.33%, #4b5563 33.33%);
}
/* Right pane when "Reverse color" is on: dark background, light text */
.pdf-cover-right.pdf-cover-right-reversed,
.pdf-cover-right.pdf-cover-right-reversed .text-muted,
.pdf-cover-right.pdf-cover-right-reversed .text-dark,
.pdf-cover-right.pdf-cover-right-reversed .btn-link {
    color: #fff !important;
}
.pdf-cover-right.pdf-cover-right-reversed .btn-link:hover {
    color: rgba(255, 255, 255, 0.85) !important;
}
body.dark-mode .pdf-cover-right:not(.pdf-cover-right-reversed) {
    background-color: #1f2937 !important;
}
body.dark-mode .pdf-cover-right:not(.pdf-cover-right-reversed) .text-dark {
    color: var(--text-dark) !important;
}
