/* ─── Сброс и база ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #1f2937;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Шапка ─────────────────────────────────────────────────────────────────── */
.header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ─── Контейнер ─────────────────────────────────────────────────────────────── */
.container {
    max-width: 640px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
}

/* ─── Карточка ──────────────────────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 32px;
}

/* ─── Состояния ─────────────────────────────────────────────────────────────── */
.state {
    display: none;
}

.state.active {
    display: block;
}

/* ─── Загрузка ──────────────────────────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.loading p {
    color: #6b7280;
    margin-top: 16px;
    font-size: 15px;
}

/* ─── Спиннер ───────────────────────────────────────────────────────────────── */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Прогресс ──────────────────────────────────────────────────────────────── */
.progress-section {
    margin-bottom: 24px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
}

.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    border-radius: 99px;
    transition: width 0.4s ease;
}

/* ─── Ошибка ────────────────────────────────────────────────────────────────── */
.error-box {
    display: none;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ─── Вопрос ────────────────────────────────────────────────────────────────── */
.question-num {
    font-size: 13px;
    color: #4f46e5;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.question-text {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 24px;
}

/* ─── Варианты ответов ──────────────────────────────────────────────────────── */
.answers-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 15px;
    user-select: none;
}

.answer-option:hover {
    border-color: #a5b4fc;
    background: #f5f3ff;
}

.answer-option:has(input:checked) {
    border-color: #4f46e5;
    background: #ede9fe;
}

.answer-option input {
    width: 18px;
    height: 18px;
    accent-color: #4f46e5;
    flex-shrink: 0;
}

/* ─── Кнопки навигации ──────────────────────────────────────────────────────── */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #4338ca;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

/* ─── Подвал ────────────────────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 24px;
    color: #9ca3af;
    font-size: 13px;
}

/* ─── Страница результата ───────────────────────────────────────────────────── */
.result-card {
    text-align: center;
}

.result-circle-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.result-circle {
    position: relative;
    width: 160px;
    height: 160px;
}

.result-circle-bg {
    fill: none;
    stroke: #e5e7eb;
    stroke-width: 10;
}

.result-circle-fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
    transform: rotate(-90deg);
    transform-origin: center;
}

.result-circle-fill.cat-low           { stroke: #059669; }
.result-circle-fill.cat-low_medium    { stroke: #d97706; }
.result-circle-fill.cat-medium        { stroke: #dc2626; }
.result-circle-fill.cat-high          { stroke: #9d174d; }

.result-circle-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.result-percent {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.result-percent-label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.result-category {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 14px;
    border-radius: 99px;
    display: inline-block;
    margin-bottom: 12px;
}

.result-category.cat-low           { background: #d1fae5; color: #065f46; }
.result-category.cat-low_medium    { background: #fef3c7; color: #92400e; }
.result-category.cat-medium        { background: #fee2e2; color: #991b1b; }
.result-category.cat-high          { background: #fce7f3; color: #9d174d; }

.result-message {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 24px;
    padding: 0 10px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 24px;
}

.result-stat-item {
    text-align: center;
}

.result-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #4f46e5;
}

.result-stat-label {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ─── Адаптивность ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .container {
        margin: 20px auto;
        padding: 0 12px;
    }
    .card {
        padding: 24px 16px;
        border-radius: 14px;
    }
    .question-text {
        font-size: 16px;
    }
    .header {
        padding: 14px 16px;
    }
    .header-title {
        font-size: 17px;
    }
}