:root {
    --primary-blue: #2563eb;
    --primary-dark: #1e40af;
    --bg-light: #f0f5ff;
    --sidebar-bg: #0f172a;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --white: #ffffff;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Global Reset for Mobile Zoom Issues */
html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-text-size-adjust: 100%;
}

/* ============================================
   LOGIN PAGE RESPONSIVE UI FIX (FINAL VERSION)
   ============================================ */

/* ============================================
   LOGIN CONTAINER
   ============================================ */

body.login-container {
    min-height: 100vh;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
    position: relative;
    box-sizing: border-box;
}

/* Background Pattern */
body.login-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.12;
    z-index: 0;
}

/* ============================================
   LOGIN CARD
   ============================================ */

.login-card {
    width: 100%;
    max-width: 460px;
    background: var(--white);
    border-radius: 20px;
    padding: 40px 35px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12);
    position: relative;
    z-index: 2;
    margin: auto;
    flex-shrink: 0;
}


/* Branding */
.brand-logo {
    font-size: 2.6rem;
    margin-bottom: 10px;
    color: var(--primary-dark);
}

.brand-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.univ-identity {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Headings */
.welcome-text {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.subtitle-text {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 22px;
}

/* ============================================
   ROLE TABS
   ============================================ */

.role-tabs {
    display: flex;
    background: #f1f5f9;
    border-radius: 14px;
    padding: 6px;
    margin-bottom: 30px;
}

.role-tab {
    flex: 1;
    padding: 14px 12px;
    /* Larger tabs */
    border: none;
    cursor: pointer;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    background: transparent;
}

.role-tab.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* ============================================
   FORM INPUTS
   ============================================ */

.form-group {
    text-align: left;
    margin-bottom: 18px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: #94a3b8;
    z-index: 10;
    font-size: 1rem;
    transition: color 0.2s;
}

.form-control {
    width: 100%;
    height: 52px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    padding: 12px 16px;
    padding-left: 44px;
    /* Ensure space for icons */
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-control:focus+.input-icon,
.input-group:focus-within .input-icon {
    color: var(--primary-blue);
}

.show-pass-btn {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color 0.2s;
}

.show-pass-btn:hover {
    color: var(--primary-dark);
}

/* ============================================
   BUTTON
   ============================================ */

.btn-primary {
    width: 100%;
    height: 54px;
    border: none;
    border-radius: 12px;
    background: var(--primary-dark);
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    background: #1e3a8a;
}

.btn-loading {
    opacity: 0.8;
    pointer-events: none;
    cursor: wait;
}

/* Links */
.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    font-size: 0.85rem;
}

.auth-links a {
    text-decoration: none;
    color: #64748b;
}

.auth-links a:hover {
    color: var(--primary-blue);
}

/* Footer */
.login-footer {
    margin-top: 30px;
    font-size: 0.75rem;
    color: #94a3b8;
}



.alert {
    padding: 12px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: left;
}

.alert-danger {
    background-color: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #ecfdf5;
    color: var(--success);
    border: 1px solid #a7f3d0;
}

/* Dashboard Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-size: 1.5rem;
    color: var(--primary-blue);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 1px;
}

.nav-menu {
    padding: 20px 0;
    flex: 1;
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left: 3px solid var(--primary-blue);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.user-profile {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary-blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--white);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: capitalize;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.top-header {
    height: 60px;
    background: var(--white);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-weight: 800;
    font-size: 1.15rem;
    color: #1e293b;
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.02em;
}

.dept-label {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 2px;
    line-height: 1;
}

.content-wrapper {
    padding: 32px;
    flex: 1;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    position: relative;
    border-left: 4px solid var(--primary-blue);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-success {
    background: #ecfdf5;
    color: var(--success);
}

.badge-warning {
    background: #fffbeb;
    color: var(--warning);
}

.badge-danger {
    background: #fef2f2;
    color: var(--danger);
}

.badge-primary {
    background: #eff6ff;
    color: var(--primary-blue);
}

/* Tables */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: #f8fafc;
    white-space: nowrap;
}

.table td {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Utilities */
.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-secondary);
}

/* Grid for Classes - Rules moved to bottom of file (FIXED DASHBOARD GRID LAYOUT section) */

.class-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-dark));
    color: var(--white);
    padding: 20px;
}

.class-body {
    padding: 20px;
}

.class-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    font-size: 1.2rem;
    padding: 4px;
}

.btn-icon:hover {
    color: var(--primary-blue);
}

.menu-toggle {
    display: none;
    margin-right: 16px;
}

/* Mobile sidebar toggle & back button - hidden on desktop */
#sidebarToggle,
.mobile-toggle-btn,
#mobileBackBtn,
.mobile-back-btn {
    display: none;
}

/* Mobile Responsive */
@media (max-width: 1200px) {
    /* Base mobile fixes */
    html {
        font-size: 14px !important;
    }
    
    body {
        overflow-x: hidden !important;
    }
    
    .mobile-toggle-btn,
    .mobile-back-btn {
        display: flex !important;
        z-index: 10002 !important;
        position: fixed !important;
        pointer-events: auto !important;
    }

    .menu-toggle {
        display: none !important;
    }
    
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        transform: translateX(-100%) !important;
        box-shadow: none !important;
        z-index: 9999 !important;
        width: 280px !important;
        max-width: 85vw !important;
        visibility: visible !important;
        opacity: 1 !important;
        transition: transform 0.3s ease !important;
    }

    .sidebar.active {
        transform: translateX(0) !important;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.3) !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }

    .top-header {
        padding: 12px 16px !important;
        padding-left: 120px !important;
        justify-content: flex-start !important;
        min-height: 70px !important;
        flex-wrap: wrap !important;
        z-index: 1001 !important;
        position: sticky !important;
    }
    
    .mobile-back-btn, .mobile-toggle-btn {
        z-index: 10002 !important;
    }

    .page-title {
        font-size: 1.1rem !important;
        margin-right: auto;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 150px !important;
    }

    .dept-label {
        display: none !important;
    }

    /* Content wrapper */
    .content-wrapper {
        padding: 16px !important;
        margin-top: 0 !important;
    }

    /* Cards */
    .card {
        margin: 0 0 16px 0 !important;
        padding: 16px !important;
        border-radius: 12px !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    }

    .card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        padding: 12px 16px !important;
    }

    .card-header .btn-primary,
    .card-header .btn-secondary {
        width: 100% !important;
        margin-top: 8px !important;
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    .stat-card .stat-value {
        font-size: 1.5rem !important;
    }

    /* Tables */
    .table-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px 16px -16px !important;
        padding: 0 16px !important;
    }

    .table {
        font-size: 13px !important;
        margin-bottom: 0 !important;
    }

    .table th,
    .table td {
        padding: 10px 12px !important;
        white-space: nowrap !important;
    }

    /* Forms */
    .form-group {
        margin-bottom: 16px !important;
    }

    .form-group label {
        font-size: 0.9rem !important;
        margin-bottom: 6px !important;
        display: block !important;
    }

    input, select, textarea {
        font-size: 16px !important;
        padding: 12px !important;
        border-radius: 8px !important;
        width: 100% !important;
    }

    /* Buttons */
    .btn-primary, .btn-secondary, .btn-danger, .btn-success {
        padding: 14px 20px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    .btn-sm {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    /* Modals */
    .modal {
        padding: 0 !important;
        align-items: flex-start !important;
    }

    .modal-content {
        margin: 10px !important;
        width: calc(100% - 20px) !important;
        max-height: 90vh !important;
        border-radius: 12px !important;
    }

    .modal-header {
        padding: 16px !important;
        flex-wrap: wrap !important;
    }

    .modal-body {
        padding: 16px !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
    }

    .modal-footer {
        padding: 12px 16px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    /* Chat */
    .chat-container {
        height: calc(100vh - 140px) !important;
    }

    .chat-messages {
        max-height: 50vh !important;
    }

    .chat-input-area {
        padding: 12px !important;
    }

    .chat-input {
        padding: 12px !important;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 9998 !important;
        display: none !important;
        background: rgba(0, 0, 0, 0.5) !important;
        pointer-events: none !important;
    }

    .sidebar-overlay.active {
        display: block !important;
        pointer-events: auto !important;
    }

    /* Mobile sidebar toggle buttons - must show on mobile */
    .mobile-back-btn,
    .mobile-toggle-btn {
        display: flex !important;
    }

    /* Page titles */
    h1 {
        font-size: 1.3rem !important;
    }

    h2 {
        font-size: 1.15rem !important;
    }

    h3 {
        font-size: 1rem !important;
    }

    /* Navigation */
    .nav-menu {
        padding: 16px 0 !important;
    }

    .nav-item {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
    }

    /* Search bar */
    .search-bar {
        margin-bottom: 16px !important;
    }

    .search-bar input {
        padding: 12px !important;
    }

    /* Filters */
    .filters {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .filters select,
    .filters input {
        width: 100% !important;
    }

    /* Badges */
    .badge {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }

    /* Alerts */
    .alert {
        padding: 14px !important;
        border-radius: 8px !important;
        margin-bottom: 16px !important;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
    }

    .pagination a,
    .pagination span {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    /* Empty states */
    .empty-state {
        padding: 40px 20px !important;
        text-align: center !important;
    }

    .empty-state i {
        font-size: 3rem !important;
    }

    /* Action buttons row */
    .action-buttons {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .action-buttons .btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Loading */
    .loading-spinner {
        width: 40px !important;
        height: 40px !important;
    }

    /* No overlap fix for fixed buttons */
    .mobile-back-btn,
    .mobile-toggle-btn {
        top: 15px !important;
    }
}

/* Tablet: 768px - 1024px */
@media (min-width: 768px) and (max-width: 1024px) {
    .top-header {
        padding-left: 130px !important;
        padding-right: 24px !important;
    }

    .page-title {
        max-width: 200px !important;
    }

    .content-wrapper {
        padding: 20px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .sidebar {
        width: 260px !important;
    }

    .card {
        padding: 20px !important;
    }

    .table th,
    .table td {
        padding: 12px !important;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        padding: 12px 18px !important;
    }
}

/* Large Mobile: 576px - 767px */
@media (min-width: 576px) and (max-width: 767px) {
    .top-header {
        padding-left: 120px !important;
        padding-right: 16px !important;
        min-height: 70px !important;
    }

    .page-title {
        font-size: 1rem !important;
        max-width: 120px !important;
    }

    .mobile-back-btn, .mobile-toggle-btn {
        width: 38px !important;
        height: 38px !important;
    }

    .mobile-back-btn {
        left: 10px !important;
    }

    .mobile-toggle-btn {
        left: 55px !important;
    }

    .content-wrapper {
        padding: 16px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .sidebar {
        width: 260px !important;
    }

    .card {
        padding: 14px !important;
    }

    .stat-card .stat-value {
        font-size: 1.4rem !important;
    }

    .table th,
    .table td {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }

    input, select, textarea {
        padding: 10px !important;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        padding: 12px 16px !important;
        font-size: 13px !important;
    }

    h1 {
        font-size: 1.2rem !important;
    }

    h2 {
        font-size: 1.1rem !important;
    }

    h3 {
        font-size: 0.95rem !important;
    }
}

/* Small Mobile: 400px - 575px */
@media (min-width: 400px) and (max-width: 575px) {
    .top-header {
        padding-left: 115px !important;
        padding-right: 14px !important;
        min-height: 65px !important;
    }

    .page-title {
        font-size: 0.95rem !important;
        max-width: 100px !important;
    }

    .mobile-back-btn, .mobile-toggle-btn {
        width: 36px !important;
        height: 36px !important;
        top: 12px !important;
    }

    .mobile-back-btn {
        left: 10px !important;
    }

    .mobile-toggle-btn {
        left: 52px !important;
    }

    .mobile-back-btn span,
    .mobile-toggle-btn span {
        font-size: 16px !important;
    }

    .content-wrapper {
        padding: 14px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .sidebar {
        width: 85vw !important;
        max-width: 300px !important;
    }

    .card {
        padding: 12px !important;
        margin-bottom: 12px !important;
        border-radius: 10px !important;
    }

    .card-header {
        padding: 10px 12px !important;
    }

    .stat-card {
        padding: 14px !important;
    }

    .stat-card .stat-value {
        font-size: 1.3rem !important;
    }

    .stat-card .stat-label {
        font-size: 0.75rem !important;
    }

    .table th,
    .table td {
        padding: 8px !important;
        font-size: 11px !important;
    }

    .table th {
        font-size: 10px !important;
    }

    input, select, textarea {
        padding: 10px !important;
        font-size: 15px !important;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        padding: 12px 14px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
    }

    h1 {
        font-size: 1.1rem !important;
    }

    h2 {
        font-size: 1rem !important;
    }

    h3 {
        font-size: 0.9rem !important;
    }

    .modal-content {
        margin: 8px !important;
        width: calc(100% - 16px) !important;
    }

    .modal-body {
        max-height: 55vh !important;
    }

    .nav-item {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
    }

    .badge {
        padding: 4px 8px !important;
        font-size: 0.7rem !important;
    }

    .search-bar input {
        padding: 10px !important;
    }

    .pagination a,
    .pagination span {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
}

/* Extra Small Mobile: below 400px */
@media (max-width: 399px) {
    .top-header {
        padding-left: 105px !important;
        padding-right: 12px !important;
        min-height: 60px !important;
    }

    .page-title {
        font-size: 0.9rem !important;
        max-width: 80px !important;
    }

    .mobile-back-btn, .mobile-toggle-btn {
        width: 34px !important;
        height: 34px !important;
        top: 10px !important;
    }

    .mobile-back-btn {
        left: 8px !important;
    }

    .mobile-toggle-btn {
        left: 48px !important;
    }

    .mobile-back-btn span,
    .mobile-toggle-btn span {
        font-size: 14px !important;
    }

    html {
        font-size: 13px !important;
    }

    .content-wrapper {
        padding: 12px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .sidebar {
        width: 85vw !important;
        max-width: 280px !important;
    }

    .card {
        padding: 10px !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
    }

    .card-header {
        padding: 8px 10px !important;
    }

    .stat-card {
        padding: 12px !important;
    }

    .stat-card .stat-value {
        font-size: 1.2rem !important;
    }

    .stat-card .stat-label {
        font-size: 0.7rem !important;
    }

    .table th,
    .table td {
        padding: 6px 8px !important;
        font-size: 10px !important;
    }

    .table th {
        font-size: 9px !important;
    }

    input, select, textarea {
        padding: 8px !important;
        font-size: 14px !important;
    }

    .btn-primary, .btn-secondary, .btn-danger {
        padding: 10px 12px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    h1 {
        font-size: 1rem !important;
    }

    h2 {
        font-size: 0.95rem !important;
    }

    h3 {
        font-size: 0.85rem !important;
    }

    .modal-content {
        margin: 6px !important;
        width: calc(100% - 12px) !important;
        max-height: 85vh !important;
    }

    .modal-header {
        padding: 12px !important;
    }

    .modal-body {
        padding: 12px !important;
        max-height: 50vh !important;
    }

    .modal-footer {
        padding: 10px 12px !important;
    }

    .nav-item {
        padding: 10px 14px !important;
        font-size: 0.85rem !important;
    }

    .badge {
        padding: 3px 6px !important;
        font-size: 0.65rem !important;
    }

    .search-bar input {
        padding: 8px !important;
        font-size: 14px !important;
    }

    .pagination a,
    .pagination span {
        padding: 5px 8px !important;
        font-size: 11px !important;
    }

    .alert {
        padding: 10px !important;
        font-size: 0.85rem !important;
    }

    .empty-state {
        padding: 30px 15px !important;
    }

    .empty-state i {
        font-size: 2.5rem !important;
    }

    .empty-state p {
        font-size: 0.85rem !important;
    }

    .form-group label {
        font-size: 0.85rem !important;
    }

    .btn-sm {
        padding: 8px 10px !important;
        font-size: 11px !important;
    }

    .chat-container {
        height: calc(100vh - 120px) !important;
    }

    .chat-messages {
        max-height: 40vh !important;
    }

    .chat-input {
        padding: 8px !important;
    }
}

/* PWA Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-indicator.online {
    background-color: #ecfdf5;
    color: #10b981;
    border: 1px solid #a7f3d0;
}

.status-indicator.offline {
    background-color: #fef3c7;
    color: #f59e0b;
    border: 1px solid #fcd34d;
}

.status-indicator.syncing {
    background-color: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.status-indicator.success {
    background-color: #ecfdf5;
    color: #10b981;
    border: 1px solid #a7f3d0;
}

.status-indicator.error {
    background-color: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
}

.pending-badge {
    background-color: #f59e0b;
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.btn-secondary {
    background-color: #64748b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-secondary:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
}

/* Mobile adjustments for status indicators */
@media (max-width: 1200px) {
    .status-indicator {
        font-size: 0.7rem;
        padding: 6px 10px;
        gap: 4px;
    }

    .pending-badge {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .top-header {
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
        padding: 12px 20px !important;
    }
}

/* ============================================
   FIX: Marks Entry Input Digits Not Visible
   ============================================ */

.marks-table input,
input.marks-input,
.comp-input,
body.marks-entry-page input {
    color: #000 !important;
    /* Digits must be black */
    background-color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    opacity: 1 !important;
    caret-color: #000 !important;
    /* Cursor must also be visible */
    -webkit-text-fill-color: #000 !important;
    /* Force override for WebKit */
    text-indent: 0 !important;
    padding: 0 4px !important;
    /* Ensure padding isn't pushing text out */
}

/* Placeholder styling */
.marks-table input::placeholder,
.comp-input::placeholder {
    color: #888 !important;
    color: #888 !important;
    opacity: 1 !important;
}

/* ============================================
   MOBILE LOGIN PAGE FIX
   ============================================ */

@media (max-width: 768px) {

    body.login-container {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        min-height: 100vh !important;
        width: 100% !important;
        padding: 20px !important;
        margin: 0 !important;
    }

    .login-card {
        width: 100% !important;
        max-width: 380px !important;
        padding: 24px 20px !important;
        margin: 0 auto !important;
        border-radius: 18px !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .brand-logo {
        font-size: 2.2rem !important;
        margin-bottom: 0.25rem !important;
    }

    .brand-text {
        font-size: 1.4rem !important;
    }

    .welcome-text {
        font-size: 1.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    .subtitle-text {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
    }

    .form-control {
        height: 48px !important;
        font-size: 15px !important;
        padding: 10px 14px 10px 42px !important;
    }

    .input-icon {
        top: 15px !important;
        font-size: 0.95rem !important;
    }

    .btn-primary {
        height: 48px !important;
        font-size: 1rem !important;
        margin-top: 0.75rem !important;
    }

    .login-footer {
        font-size: 0.7rem !important;
        margin-top: 1.5rem !important;
        padding-bottom: 0 !important;
    }

    .role-tabs {
        margin-bottom: 1.25rem !important;
    }

    .role-tab {
        padding: 8px !important;
        font-size: 0.85rem !important;
    }

    /* Class cards: 1 per row on mobile */
    .class-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================================
   FIXED CLASS DASHBOARD LAYOUT (Flexbox - Responsive & Robust)
   ========================================================= */

/* Content wrapper - keep original sizing (flex: 1 from line 446) */

/* 1. Flex container for class cards */
.class-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 24px !important;
    width: 100% !important;
    align-items: stretch !important;
    margin-top: 24px !important;
}

/* 2. Nuke ghost elements from layout flow */
.class-grid>*:not(.class-card) {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    flex: 0 0 0 !important;
}

/* 3. Card Styling & Layout */
.class-card {
    background: var(--white);
    border-radius: 20px;
    overflow: hidden !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Flex sizing: 2 per row */
    flex: 0 0 calc(50% - 12px) !important;
    max-width: calc(50% - 12px) !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.class-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* 4. Ensure card body fills available vertical space */
.class-card .class-body {
    flex-grow: 1 !important;
}

/* 5. Responsive Breakpoints */

/* Large Screens (1400px+): 3 per row */
@media (min-width: 1400px) {
    .class-card {
        flex: 0 0 calc(33.333% - 16px) !important;
        max-width: calc(33.333% - 16px) !important;
    }
}

/* Mobile (768px and below): 1 per row */
@media (max-width: 768px) {
    .class-card {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* =========================================================
   DASHBOARD BUTTON OVERRIDES
   Prevents login-specific .btn-primary (100% width, 54px height)
   from polluting and breaking all dashboard interfaces.
   ========================================================= */
.main-content .btn,
.main-content .btn-primary,
.main-content .btn-success,
.main-content .btn-danger,
.main-content .btn-warning,
.main-content .btn-dark,
.main-content .btn-secondary,
.main-content .btn-outline {
    width: auto !important;
    height: 38px !important;
    padding: 0 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    border-radius: 6px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    flex: none !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}

.main-content .btn i,
.main-content .btn-primary i,
.main-content .btn-success i,
.main-content .btn-danger i,
.main-content .btn-warning i,
.main-content .btn-dark i,
.main-content .btn-secondary i,
.main-content .btn-outline i {
    margin-right: 6px !important;
}

/* ============================================
   STUDENT DASHBOARD MOBILE RESPONSIVENESS FIX
   ============================================ */

/* Problem 5: Global horizontal overflow prevention */
.content-wrapper,
.main-content {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Welcome banner inner flex */
.welcome-banner-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 1;
}

/* Stat cards grid */
.student-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

/* Charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* Leaderboard mobile card layout */
.lb-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.lb-entry {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lb-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.lb-entry.lb-rank-1 {
    background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
    border-color: #fbbf24;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.2);
}

.lb-entry.lb-rank-2 {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-color: #93c5fd;
    box-shadow: 0 4px 14px rgba(147, 197, 253, 0.2);
}

.lb-entry.lb-rank-3 {
    background: linear-gradient(135deg, #fdf4ff 0%, #f5f3ff 100%);
    border-color: #c4b5fd;
    box-shadow: 0 4px 14px rgba(196, 181, 253, 0.2);
}

.lb-entry-rank {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.lb-entry-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.lb-entry-name {
    font-weight: 800;
    color: #1e293b;
    font-size: 1rem;
    line-height: 1.3;
}

.lb-entry-reg {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 600;
}

.lb-entry-class {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
}

.lb-entry-bar-wrap {
    width: 100%;
    max-width: 200px;
}

.lb-entry-bar-track {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: 12px;
    overflow: hidden;
}

.lb-entry-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.4s ease;
}

.lb-entry-pct {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 4px;
    text-align: center;
}

.lb-entry-score {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.lb-entry-score span {
    font-size: 0.78rem;
    font-weight: 700;
    opacity: 0.85;
    margin-left: 4px;
}

/* Desktop: leaderboard table stays, cards hidden */
.lb-desktop-table {
    display: block;
}
.lb-mobile-cards {
    display: none;
}

/* Certificate button in leaderboard */
.lb-entry .btn-certificate {
    margin-top: 4px;
}

/* ============================================
   MOBILE BREAKPOINTS FOR DASHBOARD
   ============================================ */

@media (max-width: 768px) {
    /* Problem 5: overflow */
    html, body, .content-wrapper, .main-content {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }

    /* Problem 1: Welcome card flex-wrap */
    .welcome-banner-inner {
        flex-wrap: wrap !important;
        gap: 16px !important;
    }

    .welcome-banner-inner .welcome-profile-img {
        width: 60px !important;
        height: 60px !important;
    }

    .welcome-banner-inner .welcome-text-block {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .welcome-banner-inner .welcome-text-block h2 {
        font-size: 1.5rem !important;
    }

    .welcome-banner-inner .welcome-fee-block {
        flex: 0 0 100% !important;
        width: 100% !important;
        text-align: left !important;
        border-radius: 10px !important;
    }

    /* Problem 2: Stat cards 2x2 */
    .student-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .student-stats-grid > div {
        padding: 16px !important;
        border-radius: 12px !important;
    }

    .student-stats-grid > div .stat-big-number {
        font-size: 1.8rem !important;
    }

    .student-stats-grid > div .stat-icon-box {
        width: 40px !important;
        height: 40px !important;
        font-size: 1.1rem !important;
    }

    /* Problem 3: Charts grid single column */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Problem 4: Leaderboard — show cards, hide table */
    .lb-desktop-table {
        display: none !important;
    }
    .lb-mobile-cards {
        display: block !important;
    }

    /* Minimum font size enforcement */
    .student-stats-grid > div,
    .lb-entry,
    .welcome-banner-inner {
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .welcome-banner-inner .welcome-profile-img {
        width: 50px !important;
        height: 50px !important;
    }

    .welcome-banner-inner .welcome-text-block h2 {
        font-size: 1.25rem !important;
    }

    .student-stats-grid > div {
        padding: 14px !important;
    }

    .student-stats-grid > div .stat-big-number {
        font-size: 1.5rem !important;
    }

    .lb-entry {
        padding: 16px !important;
    }

    .lb-entry-score {
        font-size: 1.3rem !important;
    }
}

/* ============================================
   GLOBAL MOBILE UX FIXES
   ============================================ */
@media (max-width: 1200px) {
    /* Force Sidebar Positioning */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        max-width: 85vw !important;
        z-index: 9999 !important;
    }

    /* Ensure Button is Clickable */
    .top-header {
        z-index: 1001 !important;
        position: sticky !important;
        top: 0 !important;
    }

    /* Fixed mobile buttons should be above everything */
    .mobile-back-btn, .mobile-toggle-btn {
        z-index: 10002 !important;
        pointer-events: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Full width content */
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Better scrolling */
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}