:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1a1d21;
    --text-muted: #5f6b7a;
    --primary: #1a1d21;
    --primary-hover: #2d3239;
    --accent: #3d5a80;
    --accent-light: #eef2f7;
    --border: #d8dee6;
    --success: #2d6a4f;
    --success-bg: #edf7f1;
    --warning: #9a6700;
    --warning-bg: #fff8e6;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
    --radius: 10px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    width: min(920px, 92vw);
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.5rem, 4vw, 2rem);
    color: var(--primary);
    font-weight: 700;
}

.header p {
    margin: 0;
    color: var(--text-muted);
    max-width: 640px;
    margin-inline: auto;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--border);
}

/* Progress bar */
.progress-wrap {
    margin-bottom: 2rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width 0.35s ease;
}

.step-indicators {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s, transform 0.3s;
}

.step-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.step-dot.done {
    background: var(--accent);
}

/* Form steps */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--primary);
}

.step-desc {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label,
.question-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.q-number {
    color: var(--primary);
    margin-right: 0.25rem;
}

.form-group .hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
textarea,
select {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.15);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-out 0s;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.field-error {
    border-color: var(--danger) !important;
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

/* Likert scale */
.question-group {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.question-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.group-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.8rem;
}

.likert-item {
    margin-bottom: 1.25rem;
}

.likert-item > label.item-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
}

.likert-scale {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.likert-option {
    flex: 1;
    min-width: 52px;
    text-align: center;
}

.likert-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.likert-option span {
    display: block;
    padding: 0.55rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.15s;
    user-select: none;
}

.likert-option span:hover {
    border-color: var(--primary);
    background: rgba(30, 77, 140, 0.05);
}

.likert-option input:checked + span {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.likert-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Radio / checkbox options */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.option-item:hover {
    border-color: var(--primary);
    background: rgba(30, 77, 140, 0.03);
}

.option-item input {
    margin-top: 0.2rem;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.option-item.selected {
    border-color: var(--primary);
    background: rgba(30, 77, 140, 0.06);
}

/* Buttons */
.btn-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Success page */
.success-card {
    text-align: center;
    padding: 3rem 2rem;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1.5rem;
}

.readiness-badge {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: 99px;
    font-weight: 700;
    font-size: 1rem;
    margin: 1rem 0;
}

.badge-well { background: var(--success-bg); color: var(--success); }
.badge-moderate { background: #dbeafe; color: #1d4ed8; }
.badge-developing { background: var(--warning-bg); color: var(--warning); }
.badge-support { background: var(--danger-bg); color: var(--danger); }

/* Admin */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tr:hover td {
    background: rgba(30, 77, 140, 0.02);
}

.table-wrap {
    overflow-x: auto;
}

.level-pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}

.detail-panel {
    margin-top: 1rem;
    padding: 1.25rem;
    background: var(--bg);
    border-radius: 8px;
    font-size: 0.9rem;
}

.detail-panel h4 {
    margin: 0 0 0.5rem;
    color: var(--primary);
}

.detail-panel dl {
    margin: 0;
}

.detail-panel dt {
    font-weight: 600;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.detail-panel dd {
    margin: 0.15rem 0 0;
}

.login-form {
    max-width: 400px;
    margin: 4rem auto;
}

.login-form h2 {
    text-align: center;
    color: var(--text);
    font-weight: 600;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.export-link {
    font-size: 0.9rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.export-link:hover {
    text-decoration: underline;
}

.admin-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.admin-nav a {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a.active {
    color: var(--primary);
}

.admin-nav a.active {
    text-decoration: underline;
}

.preview-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid #fcd34d;
    border-radius: var(--radius);
    padding: 0.9rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.preview-banner-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.student-preview-body {
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px);
}

.preview-sticky-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    background: var(--warning-bg);
    color: var(--warning);
    border-bottom: 1px solid #fcd34d;
    font-size: 0.88rem;
    font-weight: 600;
}

.preview-sticky-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.preview-sticky-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

.student-preview-container {
    width: min(640px, 100%);
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

.student-preview-header h1 {
    font-size: clamp(1.25rem, 5vw, 1.65rem);
}

.student-preview-instructions {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.9rem;
}

.student-preview-body .card {
    padding: 1.25rem 1rem;
}

.programme-select {
    width: 100%;
    min-height: 3rem;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: menulist;
}

.programme-other-wrap {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
}

.programme-other-wrap[hidden] {
    display: none !important;
}

.student-preview-body .btn-row {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    margin: 1rem -1rem 0;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.quiz-status-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    border-radius: var(--radius);
    padding: 0.9rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.quiz-status-open {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #86efac;
}

.quiz-status-closed {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.timer-bar {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: var(--text);
    border-radius: 99px;
    transition: width 0.9s linear;
}

.timer-fill.timer-urgent {
    background: #888888;
}

.timer-display {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 1rem;
    line-height: 1;
}

.timer-display.timer-urgent {
    color: var(--danger);
}

#btn-skip {
    margin-right: auto;
}

.btn-row {
    align-items: center;
}

/* Quiz QR code */
.qr-admin-card {
    padding: 2rem;
}

.qr-admin-intro {
    margin: 0 0 1.75rem;
    color: var(--text-muted);
    max-width: 52rem;
}

.qr-admin-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.qr-code-wrap {
    flex-shrink: 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.qr-code-wrap img {
    display: block;
}

.qr-admin-details {
    flex: 1;
    min-width: 220px;
}

.qr-url-display {
    margin: 0 0 0.75rem;
    word-break: break-all;
    font-size: 0.95rem;
}

.qr-url-display a {
    color: var(--primary);
    font-weight: 600;
}

.qr-admin-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.qr-projection-body {
    background: var(--surface);
}

.qr-projection {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.qr-projection-course {
    margin: 0 0 0.5rem;
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.qr-projection-title {
    margin: 0 0 1rem;
    font-size: clamp(1.75rem, 5vw, 3rem);
    color: var(--primary);
    line-height: 1.15;
    max-width: 18ch;
}

.qr-projection-lead {
    margin: 0 0 2rem;
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    color: var(--text-muted);
    max-width: 28rem;
}

.qr-code-wrap--large {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.qr-projection-url {
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    word-break: break-all;
    max-width: min(90vw, 36rem);
}

.qr-projection-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.programme-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.programme-card {
    display: block;
    cursor: pointer;
}

.programme-card input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.programme-card-body {
    display: flex;
    align-items: center;
    min-height: 3.25rem;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
}

.programme-card input:checked + .programme-card-body {
    border-color: var(--primary);
    background: rgba(30, 77, 140, 0.06);
    box-shadow: 0 0 0 3px rgba(30, 77, 140, 0.12);
}

.programme-card:active .programme-card-body {
    transform: scale(0.99);
}

@media (max-width: 600px) {
    .card {
        padding: 1.25rem;
    }

    .likert-scale {
        gap: 0.25rem;
    }

    .likert-option {
        min-width: 44px;
    }

    .btn-row {
        flex-direction: column-reverse;
    }

    .btn {
        width: 100%;
    }
}
