:root {
    /* Core Brand */
    --brand-primary: #2C2579;
    --brand-secondary: #ED7302;

    /* Neutrals & Surfaces */
    --surface-main: #FFFFFF;
    --surface-secondary: #F8FAFC;
    --surface-tertiary: #F1F5F9;

    /* Text */
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-tertiary: #94A3B8;

    /* Borders & Lines */
    --border-subtle: #E2E8F0;
    --border-focus: #2C2579;

    /* Effects */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    --shadow-float: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background-color: var(--surface-secondary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
}

/* --- Layout --- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar */
.app-sidebar {
    width: 260px;
    background: var(--surface-main);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: var(--transition);
}

.sidebar-header {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid transparent;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin: 24px 16px 8px;
}

.nav-label:first-child {
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    border: 1px solid transparent;
}

.nav-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 1.1rem;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.nav-link:hover {
    background-color: var(--surface-tertiary);
    color: var(--brand-primary);
}

.nav-link:hover i {
    color: var(--brand-primary);
}

.nav-link.active {
    background-color: rgba(44, 37, 121, 0.05);
    color: var(--brand-primary);
    border-color: rgba(44, 37, 121, 0.1);
}

.nav-link.active i {
    color: var(--brand-primary);
}

/* User Profile Bottom */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-subtle);
}

.user-card-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
}

.user-card-mini:hover {
    background-color: var(--surface-tertiary);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--brand-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Main Content */
.app-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 83%;
}

/* --- Components --- */

/* Cards */
.card-modern {
    background: var(--surface-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.card-modern:hover {
    box-shadow: var(--shadow-float);
    transform: translateY(-2px);
    border-color: rgba(44, 37, 121, 0.1);
}

/* Typography */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Statistics */
.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.icon-blue {
    background: rgba(44, 37, 121, 0.1);
    color: var(--brand-primary);
}

.icon-orange {
    background: rgba(237, 115, 2, 0.1);
    color: var(--brand-secondary);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Buttons */
.btn-modern {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-v2 {
    background-color: var(--brand-primary);
    color: white;
}

.btn-primary-v2:hover {
    background-color: #201b5c;
    box-shadow: 0 4px 12px rgba(44, 37, 121, 0.25);
    transform: translateY(-1px);
    color: white;
}

/* Tables */
.table-minimal {
    width: 100%;
    border-collapse: collapse;
}

.table-minimal th {
    text-align: left;
    padding: 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
}

.table-minimal td {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.table-minimal tr:last-child td {
    border-bottom: none;
}

.table-minimal tr:hover td {
    background-color: var(--surface-secondary);
}

/* Login Page Only */
.login-split {
    display: flex;
    min-height: 100vh;
}

.login-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-main);
}

.login-right {
    flex: 1;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
    display: none;
    position: relative;
}

@media (min-width: 992px) {
    .login-right {
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
    }
}

.login-shimmer {
    position: absolute;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 45%, rgba(255, 255, 255, 0.03) 50%, transparent 55%);
    animation: shimmer 10s infinite linear;
}

@keyframes shimmer {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(0%, 0%) rotate(360deg);
    }
}

/* Form Controls Minimal */
.input-group-minimal {
    position: relative;
    margin-bottom: 20px;
}

.input-minimal {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--surface-secondary);
    outline: none;
}

.input-minimal:focus {
    background: var(--surface-main);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(44, 37, 121, 0.1);
}

.input-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: block;
}

/* --- Responsive Utilities --- */

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1040;
    /* Bootstrap modal is 1055, header is usually lower */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile & Tablet Breakpoints */
@media (max-width: 991.98px) {

    /* Hide Sidebar */
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 0 transparent;
        z-index: 1050;
        /* Higher than overlay */
    }

    /* Active Sidebar State */
    .app-sidebar.active {
        transform: translateX(0);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.15);
    }

    /* Main Content Adjustment */
    .app-main {
        margin-left: 0;
        max-width: 100%;
        /* Force full width on mobile */
        padding: 16px;
        /* Reduce padding on mobile */
    }

    /* Login Page Adjustments */
    .login-split {
        flex-direction: column;
    }

    .login-right {
        display: none;
        /* Already handled but reinforcing */
    }

    .login-left {
        padding: 20px;
    }
}