:root {
    --cr-primary: #7c3aed;
    --cr-primary-dark: #5b21b6;
    --cr-ink: #1f2430;
    --cr-sidebar-bg: #171b26;
    --cr-sidebar-hover: #232838;
    --cr-sidebar-active: #7c3aed;
    --cr-bg: #f4f5f9;
    --cr-card-radius: 0.9rem;
}

body {
    background: var(--cr-bg);
    color: var(--cr-ink);
    font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Topbar */
.cr-topbar {
    background: #fff;
    border-bottom: 1px solid #e7e8ee;
    padding: 0.65rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.cr-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--cr-ink);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cr-brand .cr-logo {
    width: 34px;
    height: 34px;
    border-radius: 0.6rem;
    background: linear-gradient(135deg, var(--cr-primary), #b794f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.cr-user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--cr-bg);
    padding: 0.3rem 0.75rem;
    border-radius: 2rem;
}

.cr-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--cr-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Sidebar */
.cr-sidebar {
    background: var(--cr-sidebar-bg);
    min-height: calc(100vh - 58px);
    padding: 1.25rem 0.75rem;
}

.cr-sidebar .nav-link {
    color: #b7bccb;
    border-radius: 0.6rem;
    padding: 0.6rem 0.9rem;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.93rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.cr-sidebar .nav-link:hover {
    background: var(--cr-sidebar-hover);
    color: #fff;
}

.cr-sidebar .nav-link.active {
    background: var(--cr-primary);
    color: #fff;
    font-weight: 600;
}

.cr-sidebar .nav-link i {
    width: 1.1rem;
    text-align: center;
    font-size: 1rem;
}

.cr-sidebar-section {
    color: #565d70;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0.9rem 0.9rem 0.3rem;
}

/* Mobile sidebar (off-canvas) */
.cr-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
}

.cr-sidebar-backdrop.show {
    display: block;
}

@media (max-width: 767.98px) {
    .cr-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 80vw;
        min-height: 100vh;
        z-index: 1050;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .cr-sidebar.cr-sidebar-open {
        transform: translateX(0);
    }
}

/* Content */
.cr-content {
    padding: 1.75rem;
}

.cr-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cr-page-header h2 {
    font-weight: 700;
    margin: 0;
    font-size: 1.5rem;
}

.cr-page-header .text-muted {
    font-size: 0.9rem;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--cr-card-radius);
    box-shadow: 0 1px 3px rgba(20, 22, 30, 0.06), 0 1px 2px rgba(20, 22, 30, 0.04);
}

.cr-stat-card {
    border-radius: var(--cr-card-radius);
    padding: 1.25rem 1.4rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.cr-stat-card .cr-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.8rem;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.cr-stat-card h2 {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 0;
}

.cr-stat-card .cr-stat-label {
    font-size: 0.82rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cr-stat-orange { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.cr-stat-blue   { background: linear-gradient(135deg, #3b6ef6, #6f9bff); }
.cr-stat-green  { background: linear-gradient(135deg, #17a673, #35c896); }

/* Tables */
.cr-table-card {
    border-radius: var(--cr-card-radius);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #fafafc;
    border-bottom: 1px solid #ececf3;
    color: #6b7080;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.92rem;
}

.table-hover tbody tr:hover {
    background-color: #fff6f1;
}

.badge-status-active {
    background: #e6f7ef;
    color: #17a673;
    font-weight: 600;
    padding: 0.35em 0.7em;
    border-radius: 2rem;
}

.badge-status-inactive {
    background: #fdeceb;
    color: #e04b3f;
    font-weight: 600;
    padding: 0.35em 0.7em;
    border-radius: 2rem;
}

/* Forms */
.cr-form-card {
    border-radius: var(--cr-card-radius);
    padding: 1.75rem;
    max-width: 780px;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #3a3f4d;
}

.form-control, .form-select {
    border-radius: 0.6rem;
    border-color: #e2e3ec;
    padding: 0.55rem 0.8rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--cr-primary);
    box-shadow: 0 0 0 0.2rem rgba(255, 107, 53, 0.15);
}

.btn-primary {
    background: var(--cr-primary);
    border-color: var(--cr-primary);
    border-radius: 0.6rem;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--cr-primary-dark);
    border-color: var(--cr-primary-dark);
}

.btn-outline-primary {
    color: var(--cr-primary);
    border-color: var(--cr-primary);
    border-radius: 0.6rem;
    font-weight: 600;
}

.btn-outline-primary:hover {
    background: var(--cr-primary);
    border-color: var(--cr-primary);
}

.btn-outline-secondary {
    border-radius: 0.6rem;
}

.btn-sm {
    border-radius: 0.5rem;
}

.alert {
    border-radius: 0.7rem;
    border: none;
}

.alert-success {
    background: #e6f7ef;
    color: #128b5d;
}

.alert-danger {
    background: #fdeceb;
    color: #c8362a;
}

.nav-pills .nav-link {
    color: #4a4f5e;
    background: #fff;
    border: 1px solid #e7e8ee;
    border-radius: 0.6rem;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
}

.nav-pills .nav-link.active {
    background: var(--cr-primary);
    border-color: var(--cr-primary);
    color: #fff;
}

/* Login page */
.cr-login-wrap {
    min-height: 100vh;
    background: radial-gradient(circle at top left, #a78bfa, #7c3aed 35%, #1f2430 100%);
}

.cr-login-card {
    border-radius: 1.1rem;
    padding: 2.25rem 2rem;
    width: 380px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}

.cr-login-logo {
    width: 56px;
    height: 56px;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--cr-primary), #b794f6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    margin: 0 auto 1rem;
}
