:root {
    /* Muted, neutral color palette */
    --bg-primary: #faf9f7;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover: #f5f5f4;
    --bg-active: #f0f0ef;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #9a9a9a;

    --border-color: #e5e5e5;
    --border-light: #f0f0f0;

    --btn-primary: #1a1a1a;
    --btn-primary-hover: #333333;

    /* Status colors - kept for functional purposes */
    --status-success: #22c55e;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;

    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    transition: transform 0.2s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h4 {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-header small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.sidebar-header i {
    color: var(--text-primary);
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0 1.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.nav-item {
    margin-bottom: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
    border-radius: 0;
    position: relative;
    font-size: 0.875rem;
    font-weight: 450;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-primary);
}

.nav-link i {
    margin-right: 0.75rem;
    width: 1rem;
    text-align: center;
    font-size: 0.9375rem;
    color: var(--text-muted);
}

.nav-link:hover i,
.nav-link.active i {
    color: var(--text-primary);
}

.nav-badge {
    margin-left: auto;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-weight: 500;
    min-width: 1.25rem;
    text-align: center;
    transition: all 0.15s ease;
}

.nav-badge.badge-loading {
    background: var(--bg-hover);
    animation: pulse 1.5s ease-in-out infinite;
}

.nav-badge.badge-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
}

/* Sidebar footer buttons */
.sidebar .mt-auto {
    border-top: 1px solid var(--border-color);
    padding: 1rem !important;
}

.sidebar .btn-outline-light {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.sidebar .btn-outline-light:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.sidebar .btn-outline-danger {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.sidebar .btn-outline-danger:hover {
    background: rgba(239, 68, 68, 0.05);
    border-color: var(--status-danger);
    color: var(--status-danger);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-primary);
}

.top-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.top-bar h5 {
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.top-bar .btn-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.375rem 0.5rem;
}

.top-bar .btn-link:hover {
    color: var(--text-primary);
}

.top-bar .dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 0.5rem;
}

.top-bar .dropdown-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
}

.top-bar .dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.content-area {
    padding: 1.5rem;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.15s ease;
    position: relative;
}

.stat-card::before {
    display: none;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    background: var(--bg-hover);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 450;
}

.stat-change {
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.stat-change.positive {
    color: var(--status-success);
}

.stat-change.negative {
    color: var(--status-danger);
}

/* Chart Cards */
.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
}

.chart-card h5,
.chart-card h6 {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Data Tables */
.data-table {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.table-header {
    background: var(--bg-card);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h5,
.table-header h6 {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9375rem;
    margin: 0;
}

.table-responsive {
    max-height: 400px;
    overflow-y: auto;
}

.table {
    margin-bottom: 0;
}

.table th {
    background: var(--bg-primary);
    border: none;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.table tbody tr:hover {
    background-color: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-active {
    background-color: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.status-pending {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-failed {
    background-color: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.status-suspended {
    background-color: var(--bg-hover);
    color: var(--text-secondary);
}

/* Action Buttons */
.action-btn {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-right: 0.25rem;
}

.action-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
    background: var(--bg-card);
}

.action-btn.danger:hover {
    border-color: var(--status-danger);
    color: var(--status-danger);
}

/* Status Indicator */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-connected {
    background: var(--status-success);
}

.status-disconnected {
    background: var(--status-danger);
}

/* System Health */
.system-health {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.health-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.health-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.health-healthy {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.health-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.health-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
        padding-top: 4rem;
    }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--btn-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.625rem;
    font-size: 1.125rem;
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

.loading-spinner {
    display: none;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.loading-spinner .spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 2px;
    color: var(--text-muted);
}

/* Bootstrap Overrides */
.btn-primary {
    background: var(--btn-primary);
    border: none;
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.btn-outline-primary:hover {
    background: var(--bg-hover);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-secondary {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.btn-secondary:hover {
    background: var(--bg-active);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--status-danger);
    border: none;
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.btn-success {
    background: var(--status-success);
    border: none;
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.form-control {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-select:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: none;
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* Modals */
.modal-content {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.modal-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem;
}

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

.btn-close {
    opacity: 0.5;
}

.btn-close:hover {
    opacity: 1;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Grid fixes for swarms section */
#swarmRegionsGrid {
    display: flex !important;
    flex-wrap: wrap !important;
}

#swarmRegionsGrid > div[class*="col-"] {
    flex: 0 0 auto !important;
}

@media (min-width: 1200px) {
    #swarmRegionsGrid > .col-xl-3 {
        flex: 0 0 25% !important;
        max-width: 25% !important;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    #swarmRegionsGrid > .col-lg-4 {
        flex: 0 0 33.333333% !important;
        max-width: 33.333333% !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    #swarmRegionsGrid > .col-md-6 {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

@media (max-width: 767.98px) {
    #swarmRegionsGrid > .col-12 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* Tab Styles */
.nav-tabs {
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 0 !important;
}

.nav-tabs .nav-item {
    margin-bottom: -1px !important;
}

.nav-tabs .nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.75rem 1rem !important;
    margin-right: 0.125rem !important;
    background: none !important;
    border: 1px solid transparent !important;
    border-top-left-radius: 6px !important;
    border-top-right-radius: 6px !important;
    color: var(--text-secondary) !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
    position: relative !important;
    transform: none !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-color) var(--border-color) transparent !important;
    color: var(--text-primary) !important;
    background-color: var(--bg-hover) !important;
    transform: none !important;
}

.nav-tabs .nav-link.active {
    color: var(--text-primary) !important;
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) var(--border-color) var(--bg-card) !important;
    box-shadow: none !important;
    transform: none !important;
}

.nav-tabs .nav-link.active::before {
    display: none !important;
}

.nav-tabs .nav-link .icon {
    margin-right: 0.5rem !important;
    width: 16px !important;
    height: 16px !important;
}

.tab-content {
    border: 1px solid var(--border-color) !important;
    border-top: none !important;
    background: var(--bg-card) !important;
    border-radius: 0 0 8px 8px !important;
}

.tab-pane {
    padding: 0 !important;
}

/* Widget styles */
.widget {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.widget-body {
    padding: 0;
}

.widget-content {
    padding: 0;
}

.form-section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.container-fluid {
    padding: 0 !important;
}

/* Utility classes */
.flex {
    display: flex !important;
}

.items-center {
    align-items: center !important;
}

.justify-between {
    justify-content: space-between !important;
}

.gap-2 {
    gap: 0.5rem !important;
}

.gap-3 {
    gap: 1rem !important;
}

.whitespace-normal {
    white-space: normal !important;
}

.pt-3 {
    padding-top: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.text-2xl {
    font-size: 1.5rem !important;
}

.font-medium {
    font-weight: 500 !important;
}

.text-gray-11 {
    color: var(--text-primary) !important;
}

.text-gray-7 {
    color: var(--text-secondary) !important;
}

.text-xs {
    font-size: 0.75rem !important;
}

.space-x-2 > * + * {
    margin-left: 0.5rem !important;
}

.text-blue-9 {
    color: var(--text-primary) !important;
}

.hover\:text-blue-11:hover {
    color: var(--text-secondary) !important;
}

.hover\:underline:hover {
    text-decoration: underline !important;
}

/* Badge overrides */
.badge {
    font-weight: 500;
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.badge.bg-primary {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.badge.bg-success {
    background: rgba(34, 197, 94, 0.1) !important;
    color: #16a34a !important;
}

.badge.bg-danger {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #dc2626 !important;
}

.badge.bg-warning {
    background: rgba(245, 158, 11, 0.1) !important;
    color: #d97706 !important;
}

.badge.bg-info {
    background: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
}

.badge.bg-secondary {
    background: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
}

/* Text utilities */
.text-muted {
    color: var(--text-muted) !important;
}

.text-primary {
    color: var(--text-primary) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.fw-bold {
    font-weight: 600 !important;
}

/* Background utilities */
.bg-light {
    background-color: var(--bg-hover) !important;
}

.bg-white {
    background-color: var(--bg-card) !important;
}

/* Border utilities */
.border {
    border-color: var(--border-color) !important;
}

.border-bottom {
    border-bottom-color: var(--border-color) !important;
}

.border-top {
    border-top-color: var(--border-color) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Pagination */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
}

.page-link:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background: var(--btn-primary);
    border-color: var(--btn-primary);
    color: white;
}

.page-item.disabled .page-link {
    background: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-muted);
}

/* Breadcrumbs */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.875rem;
}

.breadcrumb-item {
    color: var(--text-secondary);
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--text-primary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-muted);
}
