* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    color: #1b1f24;
}

:root {
    --brand-primary: #8f2a7a;
    --brand-primary-dark: #742163;
    --brand-soft: #f6edf4;
    --panel-bg: #f4f4f6;
    --card-bg: #ffffff;
    --text-main: #1f1f27;
    --text-muted: #6c6c79;
    --border-soft: #e5d8e2;
}

.auth-body {
    min-height: 100vh;
    background: linear-gradient(150deg, #f2f2f5 0%, #ededf2 100%);
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 30px 28px 26px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 16px 30px rgba(67, 33, 61, 0.12);
}

.auth-title {
    margin: 0 0 10px;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    justify-content: center;
}

.auth-logo-wrap {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 10px 12px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(80, 35, 72, 0.1);
}

.auth-logo {
    display: block;
    max-width: 100%;
    width: 320px;
    height: auto;
}

.auth-subtitle {
    margin: 0 0 22px;
    color: var(--text-muted);
    text-align: center;
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: #333344;
}

.form-control {
    width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 11px 12px;
    outline: none;
    font-size: 14px;
    background: #faf8fb;
}

.form-control:focus {
    border-color: var(--brand-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(143, 42, 122, 0.14);
}

.form-check-row {
    display: flex;
    justify-content: flex-start;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.checkbox-input {
    width: 16px;
    height: 16px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small {
    padding: 7px 10px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), #a63f90);
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(143, 42, 122, 0.28);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(143, 42, 122, 0.34);
}

.btn-secondary {
    background: #545468;
    color: #ffffff;
}

.btn-secondary:hover {
    background: #444458;
}

.btn-danger {
    background: #d94141;
    color: #ffffff;
}

.btn-danger:hover {
    background: #bc2f2f;
}

.status-btn {
    border: none;
    border-radius: 999px;
    padding: 6px 12px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.status-active {
    background: #1f9d55;
}

.status-active:hover {
    background: #168447;
}

.status-inactive {
    background: #d94141;
}

.status-inactive:hover {
    background: #bc2f2f;
}

.alert {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.alert-success {
    background: #e8f8ed;
    border: 1px solid #c0e8cc;
    color: #207245;
}

.alert-danger {
    background: #ffe9e9;
    border: 1px solid #ffc8c8;
    color: #a52626;
}

.alert-warning {
    background: #fff5da;
    border: 1px solid #f4d47a;
    color: #6e4f00;
}

.alert-warning-title {
    margin: 0 0 6px;
    font-weight: 700;
}

.alert-warning-text {
    margin: 0;
    font-size: 14px;
}

.alert-list {
    margin: 0;
    padding-left: 18px;
}

.dashboard-body {
    min-height: 100vh;
    background: var(--panel-bg);
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.mobile-topbar {
    display: none;
}

.mobile-menu-toggle {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

.sidebar {
    width: 250px;
    background: #f0f0f3;
    color: var(--text-main);
    padding: 24px 16px;
    border-right: 1px solid #e2e2e8;
}

.sidebar-brand {
    margin-bottom: 24px;
    padding: 0 10px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    padding: 8px;
}

.sidebar-logo {
    display: block;
    width: 210px;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-link {
    text-decoration: none;
    color: #5f6170;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    border-left: 3px solid transparent;
}

.menu-link:hover {
    background: #e8e2e7;
    color: #2f2f38;
}

.menu-link-active {
    background: var(--brand-soft);
    border-left-color: var(--brand-primary);
    color: var(--brand-primary-dark);
    font-weight: 700;
}

.menu-link-active:hover {
    color: var(--brand-primary-dark);
}

.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dashboard-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-soft);
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-title {
    margin: 0;
    font-size: 24px;
}

.dashboard-role {
    margin: 4px 0 0;
    color: var(--text-muted);
}

.dashboard-main {
    margin: 26px;
    padding: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stats-card {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 16px;
}

.stats-title {
    margin: 0;
    font-size: 14px;
    color: #787786;
}

.stats-value {
    margin: 10px 0 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--brand-primary-dark);
}

.role-card {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-top: 4px solid var(--brand-primary);
    border-radius: 14px;
    padding: 22px;
}

.role-title {
    margin: 0 0 8px;
    font-size: 21px;
}

.role-text {
    margin: 0;
    color: #595967;
    line-height: 1.55;
}

.table-wrap {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    border-bottom: 1px solid #edf1f6;
    text-align: left;
    padding: 12px 14px;
    vertical-align: top;
    font-size: 14px;
}

.data-table th {
    background: #f8f3f7;
    font-weight: 700;
}

.action-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    font-size: 12px;
    background: var(--brand-soft);
    color: var(--brand-primary-dark);
    border-radius: 999px;
    padding: 4px 10px;
}

.muted-text {
    color: #7e8a9d;
    font-size: 13px;
}

.empty-cell {
    text-align: center;
    color: #7e8a9d;
}

.pagination-wrap {
    margin-top: 14px;
}

.panel-form {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.permissions-box {
    margin: 18px 0;
    border-top: 1px solid #edf1f6;
    padding-top: 14px;
}

.section-title {
    margin: 0 0 10px;
    font-size: 18px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}

.classes-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 14px;
}

.classes-card {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 14px;
}

.classes-title {
    margin: 0 0 12px;
    font-size: 18px;
    color: var(--brand-primary-dark);
}

.classes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.class-item {
    border: 1px solid #eee3eb;
    border-radius: 10px;
    padding: 10px;
    background: #fffafd;
}

.class-name {
    margin: 0 0 6px;
    font-weight: 700;
    color: #2f2f38;
}

.class-meta {
    margin: 0 0 4px;
    font-size: 13px;
    color: #656574;
}

.class-link {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
}

.class-link:hover {
    text-decoration: underline;
}

@media (max-width: 992px) {
    .classes-grid {
        grid-template-columns: 1fr;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border-soft);
        background: #ffffff;
        position: sticky;
        top: 0;
        z-index: 1001;
    }

    .mobile-topbar-title {
        font-size: 16px;
        color: #3a3a46;
        font-weight: 600;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        width: 40px;
        height: 36px;
        border: 1px solid var(--border-soft);
        border-radius: 10px;
        background: #ffffff;
        padding: 0 10px;
        cursor: pointer;
    }

    .mobile-menu-toggle span {
        width: 100%;
        height: 2px;
        background: var(--brand-primary-dark);
        border-radius: 8px;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(23, 14, 25, 0.4);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease;
        z-index: 1002;
    }

    .sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-open {
        overflow: hidden;
    }

    .admin-layout {
        min-height: auto;
    }

    .sidebar {
        width: 280px;
        max-width: 82%;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1003;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        overflow-y: auto;
        box-shadow: 8px 0 20px rgba(0, 0, 0, 0.12);
        border-right: 1px solid #e2e2e8;
    }

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

    .dashboard-main {
        margin: 18px;
    }
}

@media (max-width: 768px) {
    .auth-wrapper {
        padding: 16px 12px;
    }

    .auth-card {
        max-width: 100%;
        padding: 22px 18px 18px;
        border-radius: 14px;
    }

    .auth-logo {
        width: 240px;
    }

    .sidebar {
        width: 260px;
        padding: 14px 12px;
    }

    .sidebar-brand {
        max-width: 190px;
        margin: 0 0 12px;
    }

    .sidebar-menu {
        flex-direction: column;
        overflow: visible;
        padding-bottom: 0;
    }

    .menu-link {
        padding: 8px 10px;
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 16px;
    }

    .dashboard-title {
        font-size: 20px;
    }

    .dashboard-main {
        margin: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }

    .stats-value {
        font-size: 22px;
    }

    .role-card,
    .panel-form {
        padding: 14px;
    }

    .form-grid,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding: 10px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .auth-title {
        font-size: 24px;
    }

    .auth-logo {
        width: 190px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .dashboard-main {
        margin: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-title {
        font-size: 18px;
    }
}

.field-error {
    color: #b42318;
    font-size: 12px;
    margin-top: 4px;
    display: inline-block;
}

.input-error {
    border-color: #d94141 !important;
}

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--border-soft) !important;
    border-radius: 12px !important;
    min-height: 42px;
    background: #faf8fb;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
    color: #333344;
    padding-left: 12px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px;
    right: 8px;
}

.select2-container--default .select2-selection--multiple {
    padding: 4px 8px;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--brand-primary) !important;
    box-shadow: 0 0 0 4px rgba(143, 42, 122, 0.14);
    background: #ffffff;
}
