/* Default Fallback Brand Variables (Navy & Cyan SaaS Theme) */
:root {
    --brand-primary: #0056b3;
    --brand-secondary: #00d2ff;
    --brand-sidebar: #0a192f;
    --td-navy: #0a192f;
}

/* Modern SaaS Typography & Base */
body {
    background-color: #f4f6f9;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
    overflow-x: hidden;
    margin: 0;
}

/* Dynamic Brand Utilities */
.bg-brand-primary {
    background-color: var(--brand-primary) !important;
}

.text-brand-primary {
    color: var(--brand-primary) !important;
}

.border-brand-primary {
    border-color: var(--brand-primary) !important;
}

.btn-brand-primary,
.btn-primary {
    background-color: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: #ffffff !important;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    transition: all 0.2s ease;
}

    .btn-brand-primary:hover,
    .btn-primary:hover {
        filter: brightness(92%);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 86, 179, 0.22);
    }

/* Sidebar & Layout Shell */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: linear-gradient( 180deg, var(--brand-sidebar) 0%, color-mix(in srgb, var(--brand-sidebar) 72%, #020617) 100% ) !important;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.25s ease;
    flex-shrink: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 4px 0 24px rgba(10, 25, 47, 0.12);
}

.sidebar-brand {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

    .sidebar-brand:hover {
        color: #ffffff;
    }

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.65rem 1rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}

    .sidebar-link:hover {
        background-color: rgba(255, 255, 255, 0.08);
        color: #ffffff;
    }

    .sidebar-link.active {
        background-color: var(--brand-primary) !important;
        color: #ffffff !important;
        box-shadow: 0 4px 12px rgba(0, 86, 179, 0.35);
    }

/* Light Sidebar Contrast Mode (Auto-enabled when light background color is chosen) */
.sidebar.sidebar-light {
    background: linear-gradient( 180deg, var(--brand-sidebar) 0%, color-mix(in srgb, var(--brand-sidebar) 94%, #cbd5e1) 100% ) !important;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(15, 23, 42, 0.04);
}

    .sidebar.sidebar-light .sidebar-brand {
        color: #0f172a !important;
        border-bottom-color: rgba(15, 23, 42, 0.08);
    }

    .sidebar.sidebar-light .sidebar-link:not(.active) {
        color: #334155 !important;
    }

        .sidebar.sidebar-light .sidebar-link:not(.active):hover {
            background-color: rgba(15, 23, 42, 0.07) !important;
            color: #0f172a !important;
        }

    .sidebar.sidebar-light .sidebar-footer-brand {
        color: #0f172a !important;
    }

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background-color: #ffffff;
    height: 64px;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Modern Cards & Tables */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-header {
    border-bottom: 1px solid #e2e8f0;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    padding: 1rem 1.25rem;
}

.stat-card {
    border: none;
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(10, 25, 47, 0.08) !important;
    }

.table thead th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.85rem 1rem;
}

.table tbody td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
}

/* Form Controls */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 0.55rem 0.85rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .form-control:focus,
    .form-select:focus {
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.14);
    }

/* Avatar Circle */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Mobile Responsive Sidebar */
@media (max-width: 767.98px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: -250px;
        z-index: 1040;
    }

        .sidebar.show {
            left: 0;
        }
}
/* Fix Bootstrap Modal Background / Freeze & Overflow Lock Overrides */
/* Clean & Crisp Modal Backdrop (No Heavy Blur) */
.modal-backdrop {
    background-color: rgba(15, 23, 42, 0.35) !important;
    backdrop-filter: none !important;
}

body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}