:root {
    --bg-start: #f4efe6;
    --bg-end: #d9e7f4;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --surface-muted: #eef3f7;
    --text: #16202a;
    --text-muted: #5f6d7a;
    --primary: #0b6e4f;
    --primary-dark: #064e3b;
    --accent: #e67e22;
    --danger: #c0392b;
    --warning: #b9770e;
    --success: #1d8348;
    --border: rgba(22, 32, 42, 0.08);
    --shadow: 0 20px 50px rgba(37, 55, 72, 0.14);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(230, 126, 34, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(11, 110, 79, 0.16), transparent 24%),
        linear-gradient(140deg, var(--bg-start), var(--bg-end));
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1160px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 28px;
    align-items: stretch;
    min-height: 100vh;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.hero-panel,
.card,
.dashboard-panel,
.exam-shell {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.hero-panel {
    padding: 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
}

.hero-panel::after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(11, 110, 79, 0.18), transparent 68%);
    bottom: -100px;
    right: -60px;
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(11, 110, 79, 0.12);
    color: var(--primary-dark);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hero-title {
    margin: 22px 0 14px;
    font-size: clamp(2.3rem, 5vw, 4rem);
    line-height: 1.02;
}

.hero-copy {
    max-width: 42rem;
    color: var(--text-muted);
    font-size: 1.05rem;
    line-height: 1.7;
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 28px;
}

.hero-stat {
    padding: 18px;
    background: rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-md);
    border: 1px solid rgba(22, 32, 42, 0.06);
}

.hero-stat strong {
    display: block;
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.hero-stat span {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.card {
    padding: 32px;
}

.card h1,
.card h2,
.dashboard-panel h2,
.exam-shell h2,
.exam-shell h3 {
    margin-top: 0;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.subtle {
    color: var(--text-muted);
    line-height: 1.6;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.field-full {
    grid-column: 1 / -1;
}

.field label {
    font-weight: 600;
}

.field input,
.field select {
    width: 100%;
    padding: 14px 15px;
    border-radius: 14px;
    border: 1px solid rgba(22, 32, 42, 0.13);
    background: rgba(255, 255, 255, 0.95);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: rgba(11, 110, 79, 0.45);
    box-shadow: 0 0 0 4px rgba(11, 110, 79, 0.12);
    transform: translateY(-1px);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.btn {
    appearance: none;
    border: none;
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 12px 24px rgba(6, 78, 59, 0.22);
}

.btn-secondary {
    color: var(--text);
    background: #fff;
    border: 1px solid rgba(22, 32, 42, 0.1);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #d35454, var(--danger));
}

.alert-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
}

.alert-success {
    background: rgba(29, 131, 72, 0.12);
    color: #166534;
    border: 1px solid rgba(29, 131, 72, 0.15);
}

.alert-error {
    background: rgba(192, 57, 43, 0.1);
    color: #991b1b;
    border: 1px solid rgba(192, 57, 43, 0.14);
}

.alert-info {
    background: rgba(14, 116, 144, 0.1);
    color: #155e75;
    border: 1px solid rgba(14, 116, 144, 0.14);
}

.verification-panel,
.otp-preview-card {
    margin-top: 18px;
    padding: 22px;
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(238, 243, 247, 0.9));
    border: 1px solid rgba(22, 32, 42, 0.08);
}

.otp-preview-card h2 {
    margin: 8px 0 10px;
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: 0.18em;
    color: var(--primary-dark);
}

.data-table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(22, 32, 42, 0.08);
    border-radius: var(--radius-md);
    background: #fff;
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(22, 32, 42, 0.08);
    vertical-align: top;
}

.data-table th {
    background: rgba(22, 32, 42, 0.04);
    font-size: 0.92rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.admin-kicker {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(11, 110, 79, 0.12);
    color: var(--primary-dark);
    font-weight: 700;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 24px;
}

.header-brand h1 {
    margin: 6px 0;
    font-size: clamp(1.9rem, 3vw, 2.6rem);
}

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

.dashboard-layout {
    display: grid;
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card,
.subject-card,
.history-card,
.profile-card,
.review-card,
.result-card {
    background: var(--surface-strong);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 20px;
}

.stat-card strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 10px;
}

.subject-card p,
.history-card p,
.profile-card p,
.stat-card span {
    color: var(--text-muted);
}

.two-column {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 24px;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(230, 126, 34, 0.12);
    color: #9a5515;
    font-weight: 700;
    font-size: 0.85rem;
}

.history-list,
.profile-list,
.result-list,
.legend-list {
    display: grid;
    gap: 12px;
}

.history-item,
.profile-list li,
.result-list li {
    list-style: none;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(22, 32, 42, 0.08);
}

.history-item:last-child,
.profile-list li:last-child,
.result-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.exam-shell {
    padding: 24px;
}

.exam-layout {
    display: grid;
    grid-template-columns: 0.78fr 1.22fr;
    gap: 24px;
}

.exam-sidebar,
.exam-main {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
}

.timer-box {
    padding: 18px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #fff2db, #fdebd0);
    margin-bottom: 18px;
}

.timer-box strong {
    display: block;
    font-size: 2rem;
    margin-top: 10px;
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(22, 32, 42, 0.1);
    overflow: hidden;
    margin: 16px 0 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #3aa17e);
    transition: width 0.25s ease;
}

.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}

.palette-btn {
    border: 1px solid rgba(22, 32, 42, 0.12);
    background: #fff;
    border-radius: 12px;
    min-height: 44px;
    font-weight: 700;
    cursor: pointer;
}

.palette-btn.current {
    border-color: var(--primary);
    background: rgba(11, 110, 79, 0.1);
}

.palette-btn.answered {
    background: rgba(29, 131, 72, 0.14);
    border-color: rgba(29, 131, 72, 0.18);
}

.question-card {
    padding: 26px;
    border-radius: 20px;
    background: var(--surface-muted);
}

.question-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.question-text {
    font-size: clamp(1.15rem, 2vw, 1.5rem);
    line-height: 1.55;
    margin-bottom: 22px;
}

.option-list {
    display: grid;
    gap: 14px;
}

.option-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(22, 32, 42, 0.1);
    background: #fff;
    cursor: pointer;
}

.option-item.selected {
    border-color: rgba(11, 110, 79, 0.25);
    background: rgba(11, 110, 79, 0.07);
}

.review-card.correct {
    border-left: 6px solid var(--success);
}

.review-card.incorrect {
    border-left: 6px solid var(--danger);
}

.review-card.unanswered {
    border-left: 6px solid var(--warning);
}

.result-hero {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 24px;
    margin-top: 24px;
}

.score-ring {
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(circle, #fff 44%, transparent 45%),
        conic-gradient(var(--primary) 0deg, var(--primary) var(--score-angle, 0deg), rgba(22, 32, 42, 0.08) var(--score-angle, 0deg));
    border: 14px solid rgba(255, 255, 255, 0.85);
}

.score-ring strong {
    font-size: 2.3rem;
}

.center-empty {
    display: grid;
    place-items: center;
    min-height: 220px;
    text-align: center;
    color: var(--text-muted);
}

.footer-note {
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

/* Result Page Styles */
.result-card {
    padding: 28px;
    background: #fff;
    border: 1px solid rgba(22, 32, 42, 0.08);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(22, 32, 42, 0.08);
}

.result-header h2 {
    margin: 0;
    font-size: 1.6rem;
}

.result-grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.result-grade-badge.grade-a+ {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.result-grade-badge.grade-a {
    background: linear-gradient(135deg, #10b981, #059669);
}

.result-grade-badge.grade-b {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.result-grade-badge.grade-c {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.result-grade-badge.grade-d {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.result-grade-badge.grade-f {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.result-item {
    text-align: center;
    padding: 16px;
    background: rgba(22, 32, 42, 0.02);
    border-radius: 12px;
}

.result-item .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.result-item strong {
    display: block;
    font-size: 1.4rem;
    color: var(--primary);
}

.result-analysis h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.analysis-items {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.analysis-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analysis-item span {
    font-weight: 500;
    font-size: 0.95rem;
}

.progress-bar {
    height: 12px;
    background: rgba(22, 32, 42, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    transition: width 0.3s ease;
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.btn-outline:hover {
    background: rgba(11, 110, 79, 0.08);
}

/* Profile Page Styles */
.form-panel {
    padding: 28px;
    background: #fff;
    border: 1px solid rgba(22, 32, 42, 0.08);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(22, 32, 42, 0.12);
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.12);
}

.form-group input[readonly] {
    background: rgba(22, 32, 42, 0.04);
    cursor: not-allowed;
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.setting-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(22, 32, 42, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-header h3 {
    margin: 0;
    font-size: 1rem;
}

.setting-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.form-section {
    margin-top: 20px;
    padding: 20px;
    background: rgba(22, 32, 42, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(22, 32, 42, 0.08);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    padding: 18px;
    background: rgba(11, 110, 79, 0.08);
    border-radius: 12px;
    text-align: center;
}

.stat-card strong {
    display: block;
    font-size: 1.4rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-card span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Leaderboard Styles */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table thead {
    background: rgba(22, 32, 42, 0.04);
}

.leaderboard-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(22, 32, 42, 0.08);
}

.leaderboard-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(22, 32, 42, 0.06);
}

.leaderboard-table tbody tr {
    transition: background 0.2s ease;
}

.leaderboard-table tbody tr:hover {
    background: rgba(11, 110, 79, 0.06);
}

.leaderboard-table tbody tr.current-user {
    background: linear-gradient(90deg, rgba(11, 110, 79, 0.1), transparent);
    font-weight: 500;
}

.leaderboard-table tbody tr.current-user td {
    border-bottom: 2px solid rgba(11, 110, 79, 0.2);
}

.filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-controls label {
    font-weight: 500;
}

.filter-controls select {
    padding: 10px 12px;
    border: 1px solid rgba(22, 32, 42, 0.12);
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.rank-info {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.rank-item {
    padding: 16px;
    background: rgba(11, 110, 79, 0.06);
    border-radius: 11px;
    text-align: center;
}

.rank-item .label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.rank-item strong {
    display: block;
    font-size: 1.4rem;
    color: var(--primary);
}

@media (max-width: 1024px) {
    .auth-shell,
    .two-column,
    .exam-layout,
    .result-hero {
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .rank-info {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 720px) {
    .page-shell,
    .auth-shell {
        width: min(100% - 20px, 100%);
    }

    .card,
    .hero-panel,
    .dashboard-panel,
    .exam-shell,
    .form-panel {
        padding: 20px;
    }

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

    .stats-grid,
    .result-grid,
    .rank-info {
        grid-template-columns: 1fr;
    }

    .header-bar,
    .header-actions,
    .question-meta,
    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .palette-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-grade-badge {
        margin-top: 12px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .setting-item .btn {
        margin-top: 12px;
    }

    .filter-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .leaderboard-table {
        font-size: 0.9rem;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }
}
