:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --primary: #4e73df;
    --primary-dark: #2e59d9;
    --success: #1cc88a;
    --warning: #f6c23e;
    --danger: #e74a3b;
    --purple: #6f42c1;
}

* { box-sizing: border-box; }

body {
    background-color: #f4f6f9;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    transition: width 0.25s ease;
    overflow-y: auto;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role-badge,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-logout span { display: none; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary);
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-brand i { font-size: 1.5rem; }

.sidebar-user {
    text-align: center;
    padding: 18px 10px;
    border-bottom: 1px solid #f0f0f0;
}
.user-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.3rem;
    margin: 0 auto 8px;
}
.user-name { font-weight: 600; font-size: 0.92rem; color: #333; }
.user-role-badge {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.7rem;
    padding: 2px 10px;
    background: #eef1fd;
    color: var(--primary);
    border-radius: 20px;
    font-weight: 600;
}

.sidebar-nav { padding: 10px 12px; flex: 1; }
.nav-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: #adb5bd;
    letter-spacing: 0.06em;
    margin: 16px 10px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #495057;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.15s ease;
}
.nav-link i { font-size: 1.05rem; width: 20px; text-align: center; color: #868e96; transition: color .15s ease; }
.nav-link:hover { background: #f1f4fd; color: var(--primary); }
.nav-link:hover i { color: var(--primary); }
.nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 10px rgba(78,115,223,0.35);
}
.nav-link.active i { color: #fff; }

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px;
    color: #e74a3b;
    text-decoration: none;
    font-weight: 600;
    border-top: 1px solid #f0f0f0;
    font-size: 0.9rem;
}
.sidebar-logout:hover { background: #fdf1f0; color: #c0392b; }

/* ===== MAIN CONTENT ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}
.main-wrapper.expanded { margin-left: var(--sidebar-collapsed-width); }

.topbar {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}
.sidebar-toggle-btn {
    border: none;
    background: #f1f4fd;
    color: var(--primary);
    width: 38px; height: 38px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
}
.sidebar-toggle-btn:hover { background: #e3e9fb; }
.topbar-right { display: flex; align-items: center; gap: 18px; font-size: 0.88rem; color: #6c757d; }

.content-area { padding: 26px; flex: 1; }
.page-footer { text-align: center; color: #adb5bd; font-size: 0.82rem; padding: 16px; }

/* ===== FADE-IN ANIMATION ===== */
.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== CARDS ===== */
.card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* ===== STAT CARDS ===== */
.stat-card {
    border-radius: 14px;
    padding: 1.3rem 1.4rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgba(0,0,0,0.16); }
.stat-card .stat-icon {
    position: absolute;
    right: 14px; top: 14px;
    font-size: 2.2rem;
    opacity: 0.25;
}
.stat-card p { margin: 0 0 4px; opacity: .92; font-size: 0.85rem; font-weight: 600; }
.stat-card h2 { font-weight: 700; margin: 0; font-size: 2rem; }
.stat-card .stat-sub { font-size: 0.75rem; opacity: 0.85; margin-top: 4px; }

.bg-c1 { background: linear-gradient(135deg,#4e73df,#3355c9); }
.bg-c2 { background: linear-gradient(135deg,#1cc88a,#159b6a); }
.bg-c3 { background: linear-gradient(135deg,#f6c23e,#e0a416); }
.bg-c4 { background: linear-gradient(135deg,#e74a3b,#c0392b); }
.bg-c5 { background: linear-gradient(135deg,#6f42c1,#59339d); }
.bg-c6 { background: linear-gradient(135deg,#20c997,#159b78); }

/* ===== CHART CARD ===== */
.chart-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.3rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    animation: fadeIn 0.6s ease;
}
.chart-card h6 {
    font-weight: 700;
    color: #333;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-card h6 i { color: var(--primary); }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg,#4e73df,#224abe);
}
.login-card {
    max-width: 400px;
    width: 100%;
    border-radius: 16px;
    animation: fadeIn 0.5s ease;
}

table th { white-space: nowrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
    .sidebar { width: var(--sidebar-collapsed-width); }
    .sidebar .brand-text, .sidebar .user-name, .sidebar .user-role-badge,
    .sidebar .nav-section-title, .sidebar .nav-link span, .sidebar .sidebar-logout span { display: none; }
    .main-wrapper { margin-left: var(--sidebar-collapsed-width); }
    .sidebar.collapsed { width: var(--sidebar-width); }
    .sidebar.collapsed .brand-text, .sidebar.collapsed .user-name, .sidebar.collapsed .user-role-badge,
    .sidebar.collapsed .nav-section-title, .sidebar.collapsed .nav-link span, .sidebar.collapsed .sidebar-logout span { display: block; }
}
