* {
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

:root {
    --primary-red: #8b0000;
    --secondary-red: #c1121f;
    --dark-bg: #0f0f14;
    --light-bg: #f5f6fb;
    --white: #ffffff;
    --text-dark: #1f2430;
    --muted: #6c757d;
    --border: #e6e8ef;
    --sidebar-width: 290px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.08);
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--light-bg);
    color: var(--text-dark);
}

body.dark-mode {
    background: #111318;
    color: #f3f4f6;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: linear-gradient(180deg, #5a0000, #7a0000, #9d0b18, #c1121f);
    color: #fff;
    padding: 22px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.18);
    z-index: 1040;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 8px 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.14);
    margin-bottom: 18px;
}

.brand-title {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
}

.brand-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.82);
    margin-top: 4px;
}

.sidebar-user {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px 12px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: rgba(255,255,255,0.11);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 12px 25px rgba(0,0,0,0.12);
}

.user-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.user-role {
    font-size: 12px;
    color: rgba(255,255,255,0.78);
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    word-break: break-word;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link-item,
.nav-group-btn,
.nested-btn {
    width: 100%;
    border: none;
    text-decoration: none;
    color: #fff;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link-item .nav-icon,
.nav-group-btn .nav-icon {
    width: 22px;
    display: inline-flex;
    justify-content: center;
    font-size: 17px;
    transition: transform 0.3s ease;
}

.left-part {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link-item:hover,
.nav-group-btn:hover,
.nested-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    box-shadow: 0 10px 22px rgba(0,0,0,0.16);
    transform: translateX(4px);
}

.nav-link-item:hover .nav-icon,
.nav-group-btn:hover .nav-icon,
.nested-btn:hover i:first-child {
    transform: scale(1.12);
}

.nav-link-item.active,
.submenu-link.active,
.nav-group-btn.open,
.nested-btn.open {
    background: rgba(255,255,255,0.18);
    box-shadow: 0 10px 24px rgba(0,0,0,0.16);
}

.arrow-icon {
    transition: transform 0.3s ease;
}

.nav-group-btn.open .arrow-icon,
.nested-btn.open .arrow-icon {
    transform: rotate(180deg);
}

.submenu,
.nested-submenu {
    display: none;
    padding-left: 10px;
    margin-top: 6px;
}

.submenu.show,
.nested-submenu.show {
    display: block;
    animation: fadeSlideDown 0.25s ease;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.95);
    text-decoration: none;
    padding: 10px 14px;
    margin: 6px 0;
    border-radius: 12px;
    font-size: 13px;
    background: rgba(255,255,255,0.06);
    transition: all 0.3s ease;
}

.submenu-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
    transform: translateX(4px);
}

.nested-group {
    margin: 6px 0;
}

.nested-btn {
    background: rgba(255,255,255,0.06);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
}

.logout-link {
    margin-top: 6px;
}

.main-panel {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
    transition: all 0.3s ease;
}

.topbar {
    background: var(--white);
    border-radius: 22px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-red);
}

.page-subtitle {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle-btn,
.theme-btn {
    border: none;
    background: linear-gradient(135deg, var(--primary-red), var(--secondary-red));
    color: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 22px rgba(139, 0, 0, 0.16);
}

.menu-toggle-btn {
    padding: 10px 14px;
    font-size: 20px;
}

.content-area {
    min-height: calc(100vh - 150px);
}

.stat-card,
.content-card {
    background: #fff;
    border-radius: 22px;
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid #f0f1f5;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-red), var(--secondary-red));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 14px;
}

.stat-label {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-dark);
}

.content-card-header {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.content-card-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-red);
}

.content-card-body p {
    color: var(--muted);
    line-height: 1.7;
}

.custom-table thead th {
    background: #fafafb;
    color: #3b3f46;
    border-bottom: 1px solid #eceef4;
    font-weight: 600;
    font-size: 14px;
}

.custom-table tbody td {
    vertical-align: middle;
    font-size: 14px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1030;
}

body.dark-mode .topbar,
body.dark-mode .stat-card,
body.dark-mode .content-card {
    background: #181c23;
    color: #fff;
    border-color: rgba(255,255,255,0.06);
}

body.dark-mode .page-title,
body.dark-mode .content-card-header h3,
body.dark-mode .stat-value {
    color: #fff;
}

body.dark-mode .page-subtitle,
body.dark-mode .content-card-body p,
body.dark-mode .stat-label {
    color: #c7cbd3;
}

body.dark-mode .custom-table thead th {
    background: #1e232c;
    color: #fff;
    border-color: rgba(255,255,255,0.08);
}

body.dark-mode .custom-table tbody td {
    background: transparent;
    color: #dce1e8;
    border-color: rgba(255,255,255,0.06);
}

@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-panel {
        margin-left: 0;
        padding: 16px;
    }

    .topbar {
        border-radius: 18px;
        padding: 16px;
    }

    .page-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 767px) {
    .stat-card,
    .content-card {
        padding: 18px;
        border-radius: 18px;
    }

    .sidebar {
        width: 280px;
        min-width: 280px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    .theme-btn {
        width: 100%;
    }

    .topbar-right {
        width: 100%;
    }
}