* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

/* --- Shared --- */

.container {
    background: #fff;
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
}

h1 { margin-bottom: 16px; font-size: 24px; }
h2 { margin-bottom: 12px; font-size: 20px; }
p { margin-bottom: 16px; color: #666; }

.btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: #2563eb;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}
.btn:hover { background-color: #1d4ed8; }
.btn:disabled { background-color: #94a3b8; cursor: not-allowed; }
.btn-secondary { background-color: #64748b; }
.btn-secondary:hover { background-color: #475569; }
.btn-success { background-color: #16a34a; }
.btn-success:hover { background-color: #15803d; }
.btn-danger { background-color: #dc2626; }
.btn-danger:hover { background-color: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.input:focus { outline: none; border-color: #2563eb; }

.form-group { margin-bottom: 12px; text-align: left; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: #555; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

.text-muted { color: #94a3b8; font-size: 14px; }

/* --- Alerts --- */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background-color: #dcfce7; color: #166534; }
.alert-error { background-color: #fee2e2; color: #991b1b; }
.alert-warning { background-color: #fef3c7; color: #92400e; }

/* --- Admin layout --- */

.admin-container {
    max-width: 900px;
    width: 95%;
    margin: 24px auto;
    padding: 0 16px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* --- File list --- */

.file-list {
    list-style: none;
    margin-top: 12px;
    margin-bottom: 16px;
}
.file-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 14px;
}
.file-list-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

/* --- Upload zone --- */

.upload-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 4px;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: #2563eb;
    background: #eff6ff;
}
.upload-zone p { margin: 4px 0; }
.upload-icon { font-size: 40px; color: #94a3b8; line-height: 1; margin-bottom: 8px; }

.btn-link {
    background: none;
    border: none;
    color: #2563eb;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    text-decoration: underline;
    padding: 0;
}
.btn-link:hover { color: #1d4ed8; }

.upload-preview {
    list-style: none;
    margin-top: 10px;
}
.upload-preview li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    background: #f1f5f9;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 3px;
}
.upload-preview .preview-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}
.upload-preview .preview-remove:hover { color: #dc2626; }

.upload-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.upload-progress-bar-wrap {
    flex: 1;
    background: #e5e7eb;
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
}
.upload-progress-bar {
    height: 8px;
    background: #2563eb;
    border-radius: 99px;
    width: 0%;
    transition: width 0.2s;
}
.upload-progress-label { font-size: 13px; color: #64748b; min-width: 36px; text-align: right; }

.upload-result-item {
    font-size: 13px;
    padding: 4px 0;
}
.upload-result-item.ok { color: #166534; }
.upload-result-item.err { color: #991b1b; }

/* --- Stats --- */

.stats {
    display: flex;
    gap: 24px;
    margin: 16px 0;
}
.stat { text-align: center; }
.stat-value { display: block; font-size: 28px; font-weight: 700; color: #2563eb; }
.stat-label { font-size: 13px; color: #94a3b8; }

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

/* --- Questions --- */

.section-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}
.toggle-icon { font-size: 12px; color: #94a3b8; }
.badge {
    font-size: 12px;
    background: #e0e7ff;
    color: #3730a3;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
    font-weight: 400;
}

.question-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.question-actions { display: flex; gap: 4px; }

.question-text { margin-bottom: 8px; font-size: 15px; color: #333; }

.options-list {
    list-style: none;
    font-size: 14px;
}
.options-list li {
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
}
.options-list li.correct {
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
}

/* --- Test page --- */

.test-container {
    max-width: 600px;
    width: 90%;
    margin: 0 auto;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.timer {
    font-size: 24px;
    font-weight: 700;
    color: #2563eb;
}
.timer.warning { color: #f59e0b; }
.timer.danger { color: #dc2626; }

.section-name {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
}

.question-text-test {
    font-size: 18px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.options {
    list-style: none;
    margin-bottom: 24px;
}
.options li {
    margin-bottom: 8px;
}
.options label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
    font-size: 15px;
}
.options label:hover { border-color: #2563eb; }
.options input[type="radio"] { accent-color: #2563eb; width: 18px; height: 18px; }
.options input[type="radio"]:checked + span { font-weight: 600; }

/* --- Results --- */

.result-score {
    font-size: 48px;
    font-weight: 700;
    margin: 16px 0;
}
.result-score.passed { color: #16a34a; }
.result-score.failed { color: #dc2626; }

.result-status {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}
.result-status.passed { color: #16a34a; }
.result-status.failed { color: #dc2626; }

.mistakes-list {
    text-align: left;
    margin-top: 24px;
}
.mistake-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.mistake-question { font-weight: 600; margin-bottom: 8px; }
.mistake-answer { color: #dc2626; font-size: 14px; }
.mistake-correct { color: #16a34a; font-size: 14px; }

/* --- Responsive --- */

@media (max-width: 600px) {
    body { padding: 12px 8px; justify-content: flex-start; }
    .container { padding: 24px 16px; }
    .admin-container { padding: 0; width: 100%; }
    .card { padding: 16px; }
    .stats { gap: 12px; }
    .stat-value { font-size: 22px; }
    .question-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .question-actions { width: 100%; }
    .admin-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .actions { flex-direction: column; }
    .actions .btn { width: 100%; text-align: center; }
    .options label { padding: 12px; }
    .result-score { font-size: 36px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; text-align: center; }
    .file-list-item { flex-wrap: wrap; gap: 6px; }
    .test-container { width: 100%; }
    .question-text-test { font-size: 16px; }
    .timer { font-size: 20px; }
    .upload-zone { padding: 20px 12px; }
}
