:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #64748b;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --bg: #f1f5f9;
    --white: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius: 10px;
    --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { text-decoration: none; color: var(--primary); transition: var(--transition); }
img { max-width: 100%; height: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; background: var(--primary); color: var(--white); border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; font-weight: 600; transition: var(--transition); box-shadow: var(--shadow-sm); text-align: center; }
.btn:hover { background: var(--primary-hover); color: var(--white); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; background: var(--bg); color: var(--text-light); border: 1px solid var(--border); box-shadow: none; white-space: nowrap; }
.btn-sm:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); transform: none; }
.btn-block { display: flex; width: 100%; }

.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; background: var(--sidebar-bg); color: var(--white); display: flex; flex-direction: column; z-index: 1000; transition: var(--transition); box-shadow: var(--shadow-lg); overflow-y: auto; }
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { font-size: 20px; font-weight: 700; background: linear-gradient(135deg, #818cf8, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.close-btn { display: none; background: none; border: none; color: white; font-size: 28px; cursor: pointer; }
.sidebar nav { flex: 1; padding: 10px 0; }
.sidebar nav a { display: flex; align-items: center; padding: 12px 24px; color: #94a3b8; font-size: 14px; font-weight: 500; border-left: 4px solid transparent; transition: var(--transition); margin-bottom: 2px; }
.sidebar nav a:hover { background: var(--sidebar-hover); color: var(--white); border-left-color: rgba(255,255,255,0.2); }
.sidebar nav a.active { background: rgba(79, 70, 229, 0.2); color: #818cf8; border-left-color: var(--primary); font-weight: 600; }
.sidebar-footer { padding: 20px 24px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; color: #64748b; }
.btn-logout { display: flex; align-items: center; justify-content: center; margin-top: 15px; padding: 10px; background: rgba(239, 68, 68, 0.1); color: #f87171; text-align: center; border-radius: 8px; font-weight: 600; border: 1px solid transparent; }
.btn-logout:hover { background: var(--danger); color: white; border-color: var(--danger); }

.main-content { margin-left: 260px; min-height: 100vh; }
.topbar { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 15px 25px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 15px; position: sticky; top: 0; z-index: 100; }
.menu-btn { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); }
.topbar h3 { font-size: 18px; font-weight: 700; }
.content-area { padding: 25px; animation: fadeIn 0.3s ease-out; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS - REMOVED OVERFLOW-X SCROLLING */
.card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px; border: 1px solid var(--border); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.stat-card { background: var(--white); padding: 20px; border-radius: var(--radius); text-align: left; box-shadow: var(--shadow-sm); border: 1px solid var(--border); border-left: 5px solid var(--primary); transition: var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card h3 { font-size: 28px; margin-bottom: 5px; font-weight: 800; }
.stat-card p { color: var(--text-light); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.primary { border-left-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

/* TABLES - MOBILE PERFECT, NO HORIZONTAL SCROLL */
.table { width: 100%; border-collapse: collapse; table-layout: fixed; /* Forces columns to fit container */ }
.table th, .table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; word-wrap: break-word; overflow-wrap: break-word; }
.table th { background: var(--bg); font-weight: 700; color: var(--text-light); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.table tbody tr:hover { background: #f8fafc; }
.actions { white-space: nowrap; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.form-group input[type="text"], .form-group input[type="email"], .form-group input[type="number"], .form-group input[type="password"], .form-group input[type="datetime-local"], .form-group input[type="file"], .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: 8px; font-size: 16px; font-family: inherit; transition: var(--transition); background: var(--white); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.form-group textarea { resize: vertical; }
.checkbox-group label { font-weight: normal; display: flex; align-items: center; gap: 8px; cursor: pointer; }

.auth-page, .landing-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); padding: 20px; }
.auth-container, .landing-container { background: var(--white); padding: 30px; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; text-align: center; }
.landing-container h1 { font-size: 28px; margin-bottom: 15px; }
.landing-container p { margin-bottom: 25px; color: var(--text-light); }
.landing-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.landing-btns .btn { padding: 12px 24px; font-size: 15px; border-radius: 50px; flex: 1; }
.auth-container h2 { margin-bottom: 20px; font-size: 22px; }
.auth-container p { margin-top: 15px; font-size: 14px; color: var(--text-light); }

.badge { padding: 4px 10px; border-radius: 50px; font-size: 11px; font-weight: 700; display: inline-block; margin-bottom: 4px;}
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-primary { background: var(--primary-light); color: var(--primary-hover); }
.badge-info { background: var(--info-light); color: #075985; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; border-left: 4px solid; }
.alert-success { background: var(--success-light); border-color: var(--success); color: #065f46; }
.alert-error { background: var(--danger-light); border-color: var(--danger); color: #991b1b; }

.filter-card { padding: 15px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form input, .filter-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; min-width: 0; flex: 1 1 150px; }
.header-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.test-list { list-style: none; }
.test-list li { padding: 15px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.test-list li:last-child { border-bottom: none; }
.test-list small { display: block; color: var(--text-light); margin-top: 4px; }
.profile-info p { margin-bottom: 10px; }

/* EXAM STYLES */
.exam-container { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden; border: 1px solid var(--border); }
.exam-header { background: var(--sidebar-bg); color: var(--white); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.exam-title strong { font-size: 16px; }
.exam-timer { background: var(--primary); padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; transition: var(--transition); }
.exam-timer.timer-critical { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

.exam-body { display: flex; min-height: 70vh; flex-direction: column; }
.question-nav-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 15px; background: #f8fafc; }
.question-nav-panel h4 { margin-bottom: 10px; color: var(--text-light); font-size: 13px; text-transform: uppercase; }
.q-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.q-btn { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border: 2px solid var(--border); border-radius: 6px; background: var(--white); font-weight: 700; color: var(--text-light); cursor: pointer; transition: var(--transition); font-size: 12px; }
.q-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.q-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.q-btn.answered { background: var(--success); color: var(--white); border-color: var(--success); }

.question-area { flex: 1; padding: 20px; display: flex; flex-direction: column; overflow-y: auto; }
.q-meta { color: var(--text-light); margin-bottom: 15px; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 10px; font-weight: 600; }
.q-text { font-size: 16px; font-weight: 600; margin-bottom: 20px; line-height: 1.6; }
.q-image { margin-bottom: 20px; border: 1px solid var(--border); padding: 10px; border-radius: 8px; background: #f8fafc; display: inline-block; }
.q-image img { max-height: 250px; border-radius: 4px; }

.options-area { flex: 1; display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; }

.option-label { display: flex; align-items: center; padding: 15px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; transition: var(--transition); background: var(--white); }
.option-label:hover { border-color: #cbd5e1; background: #f8fafc; }

.option-label input[type="radio"] {
    appearance: none; -webkit-appearance: none;
    width: 22px; height: 22px; min-width: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    margin-right: 15px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.option-label input[type="radio"]::after {
    content: "";
    display: block;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: var(--transition);
}
.option-label input[type="radio"]:checked {
    border-color: var(--primary);
    background: var(--primary);
}
.option-label input[type="radio"]:checked::after {
    transform: translate(-50%, -50%) scale(1);
}

.opt-key { display: flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; border-radius: 50%; background: var(--bg); font-weight: 800; margin-right: 12px; font-size: 13px; color: var(--text-light); flex-shrink: 0; }
.option-text { font-size: 15px; font-weight: 500; }

.q-navigation { margin-top: auto; padding-top: 15px; border-bottom: none; border-top: 2px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.q-navigation .btn { flex: 1; }

.result-container { max-width: 800px; margin: 0 auto; text-align: center; padding: 30px 15px; }
.result-header { margin-bottom: 30px; }
.result-header h2 { font-size: 24px; margin-bottom: 5px; }
.result-header h3 { font-size: 20px; color: var(--primary); }
.result-stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; margin-bottom: 15px; }
.result-stat-card { padding: 20px 10px; border-radius: 12px; text-align: center; }
.result-stat-card h3 { font-size: 32px; margin-bottom: 5px; font-weight: 800; }
.result-stat-card p { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.bg-success-light { background: var(--success-light); color: #065f46; }
.bg-danger-light { background: var(--danger-light); color: #991b1b; }
.bg-warning-light { background: var(--warning-light); color: #92400e; }
.bg-primary-light { background: var(--primary-light); color: var(--primary-hover); }

/* DESKTOP OVERRIDES */
@media (min-width: 768px) {
    .exam-body { flex-direction: row; }
    .question-nav-panel { width: 220px; border-right: 1px solid var(--border); border-bottom: none; }
    .q-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .question-area { padding: 30px; }
    .q-text { font-size: 18px; }
    .option-label { padding: 16px 20px; }
    .option-text { font-size: 16px; }
    .result-stats-grid { grid-template-columns: repeat(4, 1fr); }
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* MOBILE OVERRIDES */
@media (max-width: 767px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .close-btn { display: block; }
    .main-content { margin-left: 0; }
    .menu-btn { display: block; }
    .content-area { padding: 15px; }
    .grid-2 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar h3 { font-size: 16px; }
    .header-actions { flex-direction: column; align-items: stretch; }
    .header-actions h4 { font-size: 16px; }
    .table th, .table td { padding: 8px 6px; font-size: 12px; } /* Smaller text on mobile tables */
}