:root {
    --bg: #060b17;
    --surface: #0f172a;
    --surface-alt: #17223b;
    --text: #dbeafe;
    --muted: #93c5fd;
    --border: #243b62;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #16a34a;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 20px 44px rgba(2, 6, 23, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top, #0a1a38 0%, var(--bg) 50%);
    min-height: 100vh;
    font-size: 13px;
}

h1, h2, h3 {
    color: var(--text);
}

h1 {
    font-size: 1.45rem;
}

h2 {
    font-size: 1.15rem;
}

h3 {
    font-size: 1rem;
}

a {
    color: var(--primary);
}

.institute-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.institute-brand.center {
    justify-content: center;
    margin-bottom: 1rem;
}

.institute-logo {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: 1px solid #2b4372;
    background: #0f172a;
    object-fit: cover;
}

.institute-name {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #dbeafe;
}

.header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
    color: #fff;
    padding: 1.25rem 2rem;
    box-shadow: 0 8px 22px rgba(49, 46, 129, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header .student-info {
    color: rgba(255, 255, 255, 0.9);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.header-brand .institute-name {
    color: #bfdbfe;
}

.container {
    max-width: 1240px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.card,
.summary-card,
.questions-card,
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.card,
.summary-card,
.questions-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
}

th,
td {
    text-align: left;
    padding: 0.75rem 0.8rem;
    border-bottom: 1px solid #e6eaf3;
}

th {
    background: #1e3a8a;
    color: #dbeafe;
    font-weight: 600;
}

tr:hover td {
    background: #1a2845;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
    min-height: 52px;
    padding: 0.95rem 1.45rem;
    min-width: 168px;
    transition: transform 0.15s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-primary,
.btn-password,
.btn-view,
.btn-teacher {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: #fff;
}

.btn-success,
.btn-start,
.btn-secondary,
.btn-student {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: #fff;
}

.btn-danger,
.btn-logout {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: #fff;
}

input,
select,
textarea {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    font-size: 12px;
    background: #0b1222;
    color: #e2e8f0;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.45rem;
    color: #bfdbfe;
    font-weight: 600;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: none;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.65rem 1.1rem;
    color: #bfdbfe;
    background: #17223b;
    font-weight: 600;
}

.tab.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
}

.exam-list {
    display: grid;
    gap: 1rem;
}

.question-selector {
    max-height: 320px;
    overflow-y: auto;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    background: #0f172a;
}

.results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filters-form {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #0f172a;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
    align-items: end;
}

.filter-actions,
.selection-actions,
.folder-selector {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.selection-actions {
    margin-bottom: 0.7rem;
}

.folder-button {
    background: #1e3a8a;
    color: #dbeafe;
    border: 1px solid #2d4f9c;
}

.folder-button.active {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: #fff;
    border-color: transparent;
}

.folder-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    background: #1e3a8a;
    color: #dbeafe;
    font-size: 0.78rem;
    font-weight: 700;
}

.question-group {
    margin-bottom: 0.9rem;
    border-bottom: 1px solid #edf0f7;
    padding-bottom: 0.9rem;
}

.question-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.question-group-title {
    margin-bottom: 0.6rem;
    display: flex;
    justify-content: space-between;
    gap: 0.7rem;
    align-items: center;
    flex-wrap: wrap;
}

.question-item {
    padding: 0.55rem 0;
    border-bottom: 1px solid #243b62;
}

.question-item:last-child {
    border-bottom: none;
}

.exam-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #182742;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.score.pass,
.status-active,
.stat-value.correct {
    color: var(--success);
}

.score.fail,
.status-inactive,
.stat-value.wrong {
    color: var(--danger);
}

.help-text,
.results-count,
.info,
.stat-label,
.marks-info {
    color: var(--muted);
}

/* Landing + login */
.landing-page,
.login-page,
.result-compact-page {
    background: radial-gradient(circle at top, #12306d 0%, #0b1222 45%, #060b17 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.landing-page .container {
    text-align: center;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    max-width: 760px;
}

.landing-page h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 0.8rem;
}

.landing-page p {
    color: var(--muted);
}

.landing-page .buttons {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.login-box,
.result-card {
    width: 100%;
    max-width: 460px;
    padding: 2rem;
}

.result-card {
    text-align: center;
}

.result-card h1 {
    color: var(--success);
}

.result-compact-page .result-card {
    max-width: 620px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.4rem;
}

.login-box .btn {
    width: 100%;
    padding: 0.9rem 1rem;
}

.password-message {
    margin-top: 0.8rem;
    font-size: 0.9rem;
}

.password-message.success {
    color: var(--success);
}

.password-message.error {
    color: var(--danger);
}

.error {
    color: var(--danger);
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
}

.back-link {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: none;
}

/* Exam page */
.exam-page .header {
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.timer {
    font-size: 1.25rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.18);
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
}

.timer.warning {
    background: rgba(220, 38, 38, 0.92);
}

.question-card,
.result-question {
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.2rem;
    margin-bottom: 1rem;
}

.question-card.locked .option {
    cursor: not-allowed;
    opacity: 0.9;
}

.question-card.locked .option:hover {
    background: #0f172a;
}

.locked-badge {
    display: inline-block;
    margin-left: 0.5rem;
    background: #f59e0b;
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.12rem 0.5rem;
}

.reattempt-badge {
    display: inline-block;
    margin-left: 0.5rem;
    background: #8b5cf6;
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.12rem 0.5rem;
    font-weight: 700;
}

.attempt-badge {
    display: inline-block;
    margin-left: 0.5rem;
    background: #6366f1;
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 0.12rem 0.5rem;
    font-weight: 700;
}

.hierarchical-results {
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.tree-node {
    margin-bottom: 0.5rem;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: #17223b;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.folder-header:hover {
    background: #1e3a8a;
}

.folder-icon {
    font-size: 1.1rem;
}

.folder-name {
    font-weight: 700;
    color: #dbeafe;
    flex: 1;
}

.folder-count {
    color: var(--muted);
    font-size: 0.85rem;
}

.folder-content {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
}

.exam-folder > .folder-content {
    margin-left: 1rem;
}

.student-folder > .folder-content {
    margin-left: 1rem;
}

.result-item {
    background: #0b1222;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.result-score {
    font-weight: 700;
    color: var(--primary);
}

.result-percentage {
    font-weight: 700;
    color: var(--success);
}

.result-date {
    color: var(--muted);
    font-size: 0.85rem;
    margin-left: auto;
}

.result-details {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.question-number {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.45rem;
}

.question-text,
.result-question-text {
    font-size: 0.92rem;
    margin-bottom: 0.8rem;
}

.options,
.result-options {
    display: grid;
    gap: 0.6rem;
}

.exam-page .options {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.option,
.result-option {
    display: flex;
    gap: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    align-items: center;
}

.option:hover {
    background: #182742;
}

.option.selected {
    border-color: #818cf8;
    background: #1e3a8a;
}

.exam-page .option {
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 78px;
}

.exam-page .option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.exam-page .option-code {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e3a8a;
    border: 1px solid #3b82f6;
    color: #dbeafe;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.exam-page .option.selected .option-code {
    background: #2563eb;
    border-color: #93c5fd;
}

.exam-page .option-text {
    text-align: center;
}

.correct-answer,
.selected-correct {
    border-color: #22c55e;
    background: #0f2c1e;
}

.selected-wrong {
    border-color: #ef4444;
    background: #3b1010;
}

.result-question.correct {
    border-left: 5px solid var(--success);
}

.result-question.wrong {
    border-left: 5px solid var(--danger);
}

.result-question.unanswered {
    border-left: 5px solid var(--warning);
}

.status-badge {
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    color: #fff;
    font-weight: 700;
}

.status-badge.correct {
    background: var(--success);
}

.status-badge.wrong {
    background: var(--danger);
}

.status-badge.unanswered {
    background: var(--warning);
}

.result-question-header {
    display: flex;
    justify-content: space-between;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.result-marks {
    color: var(--muted);
    margin-top: 0.55rem;
    font-size: 0.88rem;
}

.option-label {
    font-weight: 700;
}

.submit-btn {
    margin-top: 1.5rem;
    padding: 1rem 1.8rem;
    font-size: 12px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

/* Post-submit screen in exam page */
.exam-result-page {
    min-height: 100vh;
    background: radial-gradient(circle at top, #12306d 0%, #0b1222 45%, #060b17 100%);
    padding: 2rem 1rem;
}

.exam-result-layout {
    max-width: 1100px;
    margin: 0 auto;
}

.exam-result-summary,
.exam-result-details {
    background: #0f172a;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.exam-result-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.9rem;
    margin: 1rem 0;
}

.metric {
    background: #17223b;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.8rem;
    text-align: center;
}

.metric-label {
    color: var(--muted);
    font-size: 0.85rem;
}

.metric-value {
    margin-top: 0.25rem;
    font-size: 1.3rem;
    font-weight: 700;
}

.exam-result-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.score {
    font-size: 1.35rem;
    font-weight: 700;
}

.percentage {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--primary);
}

.actions {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.stat-box {
    padding: 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    text-align: center;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.answer-summary {
    background: #17223b;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
}

.student-answer.correct,
.correct-answer-text,
.correct-indicator {
    color: var(--success);
    font-weight: 700;
}

.student-answer.wrong {
    color: var(--danger);
    font-weight: 700;
}

.wrong-indicator {
    color: var(--danger);
    font-weight: 700;
    margin-left: auto;
}

@media (max-width: 900px) {
    .container {
        padding: 0 1rem;
    }

    .header,
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .exam-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    table {
        display: block;
        overflow-x: auto;
    }

    .exam-page .options {
        grid-template-columns: 1fr;
    }
}
