:root {
    --primary: #3862e9;
    --primary-dark: #3156d3;
    --ink: #1c2b43;
    --muted: #71809a;
    --page: #f2f5fb;
    --line: #e4e9f2;
    --sidebar-width: 264px;
    --card-shadow: 0 8px 24px rgba(30, 55, 90, .07);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--page);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { text-decoration: none; }

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    min-height: 100vh;
    padding: 18px 18px 20px;
    background: #fff;
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    margin: 4px 10px 20px;
    color: #17243b;
    font-size: 15px;
    font-weight: 750;
    letter-spacing: -.4px;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(145deg, #4b78ff, #2c52d6);
    box-shadow: 0 7px 15px rgba(56, 98, 233, .25);
    font-size: 19px;
}

.brand-accent { color: #2874f0; }

.user-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 20px;
    padding: 17px 12px;
    border: 1px solid #e3e9f5;
    border-radius: 16px;
    background: #f8faff;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    border-radius: 12px;
    color: var(--primary);
    background: #e8efff;
    font-size: 22px;
}

.user-card strong { font-size: 13px; font-weight: 700; }
.user-card small { color: var(--muted); font-size: 12px; }
.role-badge {
    margin-top: 3px;
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--primary-dark);
    background: #e8efff;
    font-size: 10px;
    font-weight: 700;
}

.side-nav { display: grid; gap: 5px; }

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 47px;
    padding: 10px 13px;
    border-radius: 10px;
    color: #61708a;
    font-size: 12px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.sidebar .nav-link i { width: 20px; color: #8998b0; font-size: 15px; text-align: center; }
.sidebar .nav-link:hover { color: var(--primary-dark); background: #f2f5ff; }
.sidebar .nav-link:hover i { color: var(--primary); }
.sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(110deg, #426df0, #3156d8);
    box-shadow: 0 7px 15px rgba(56, 98, 233, .2);
}
.sidebar .nav-link.active i { color: #fff; }
.sidebar .logout-link { margin-top: 15px; color: #c15261; }
.sidebar .logout-link i { color: #c15261; }

.main-content {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 27px 25px 40px;
}

.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5 {
    color: #1e2b40;
    font-weight: 700;
    letter-spacing: -.45px;
}
.main-content h2 { margin: 0 0 18px; font-size: 23px; }
.main-content .text-muted { color: var(--muted) !important; }

.card {
    margin-bottom: 24px;
    border: 1px solid rgba(222, 229, 241, .85);
    border-radius: 15px;
    background: #fff;
    box-shadow: var(--card-shadow);
}
.card-header {
    padding: 16px 18px;
    border-bottom: 1px solid #edf0f6;
    background: transparent;
    font-weight: 650;
}
.card-body { padding: 18px; }

.btn {
    border-radius: 8px;
    font-size: 12px;
    font-weight: 650;
}
.btn-primary {
    border-color: var(--primary);
    background: linear-gradient(110deg, #426df0, #3156d8);
    box-shadow: 0 4px 9px rgba(56, 98, 233, .16);
}
.btn-primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.btn-success { background-color: #178e5b; border-color: #178e5b; }
.btn-warning { color: #1f2937; }
.form-label { color: #394861; font-size: 12px; font-weight: 650; }
.form-control, .form-select {
    min-height: 42px;
    border-color: #dfe5ef;
    border-radius: 9px;
    color: #334159;
    font-size: 13px;
    box-shadow: none !important;
}
textarea.form-control { min-height: 100px; }
.form-control:focus, .form-select:focus { border-color: #85a0f7; }
.form-control[readonly] { background: #f8faff; color: #61708a; }

.table-responsive { border-radius: 10px; }
.table-custom, .table {
    margin-bottom: 0;
    color: #344158;
    font-size: 12px;
    vertical-align: middle;
}
.table-custom thead th, .table thead th {
    padding: 13px 12px;
    border-bottom: 1px solid #e3e8f1;
    background: #f8faff;
    color: #74829a;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}
.table-custom tbody td, .table tbody td {
    padding: 14px 12px;
    border-color: #edf0f5;
}
.table-custom tbody tr:hover, .table tbody tr:hover { background: #fafbfe; }
.table .badge { font-size: 9px; }

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 96px;
    padding: 18px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    box-shadow: var(--card-shadow);
}
.stat-card h3 { margin: 0 0 5px; color: #fff; font-size: 27px; }
.stat-card span { font-size: 11px; font-weight: 650; }
.stat-card i { font-size: 25px; opacity: .9; }
.stat-primary { background: linear-gradient(120deg, #4574f3, #3158d7); }
.stat-warning { background: linear-gradient(120deg, #f8bd4d, #e79926); }
.stat-info { background: linear-gradient(120deg, #32b5c5, #198da5); }
.stat-success { background: linear-gradient(120deg, #39b98b, #218d71); }
.chart-container { position: relative; height: 300px; }

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: linear-gradient(125deg, #e8edff 0%, #f5f7fc 52%, #e6f4f4 100%);
}
.login-card {
    width: min(100%, 440px);
    padding: 38px 40px;
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 20px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 22px 55px rgba(43, 61, 93, .12);
}
.login-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 18px;
    border-radius: 15px;
    color: #fff;
    background: linear-gradient(145deg, #4b78ff, #2c52d6);
    box-shadow: 0 8px 18px rgba(56,98,233,.26);
    font-size: 24px;
}
.login-eyebrow { color: #3970d6; font-size: 10px; font-weight: 700; letter-spacing: .8px; }
.login-title { margin: 7px 0 24px; color: #1e2b40; font-size: 23px; font-weight: 750; letter-spacing: -.6px; }
.login-card .form-label { font-size: 12px; }
.login-card .form-control { min-height: 44px; }
.login-card .btn { min-height: 43px; font-size: 13px; }

.loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.75);
}
.loading.show { display: flex; }

@media (max-width: 900px) {
    :root { --sidebar-width: 225px; }
    .sidebar { padding-right: 12px; padding-left: 12px; }
    .main-content { padding: 22px 17px 32px; }
}

@media (max-width: 680px) {
    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
        padding: 10px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .brand { margin: 3px 4px 10px; }
    .user-card { display: none; }
    .side-nav { display: flex; overflow-x: auto; gap: 5px; padding-bottom: 2px; }
    .sidebar .nav-link { flex: 0 0 auto; min-height: 40px; padding: 8px 10px; }
    .sidebar .nav-link span { white-space: nowrap; }
    .sidebar .logout-link { align-self: flex-start; margin: 5px 0 0; }
    .main-content { margin-left: 0; padding: 20px 14px 30px; }
}

@media (max-width: 480px) {
    .login-card { padding: 30px 24px; }
}
