:root {
    /* СОВРЕМЕННАЯ ПАЛИТРА (Inspired by Tailwind CSS) */
    --primary: #6366f1;
    /* Индиго (Акцентный цвет) */
    --secondary: #94a3b8;
    /* Серый (Вторичный текст) */
    --success: #10b981;
    /* Изумруд (Успех) */
    --warning: #f59e0b;
    /* Янтарный (Внимание) */
    --danger: #ef4444;
    /* Красный (Ошибка) */

    --bg: #0f172a;
    /* Темно-синий фон страницы (Slate-900) */
    --card-bg: #ffffff;
    /* Белый фон карточки */
    --text: #1e293b;
    /* Темно-серый текст */
    --border-radius: 16px;
}

body {
    /* Градиентный фон для современности */
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
    /* Центрирует элементы по вертикали (если экран высокий) */
    flex-direction: column;
    /* <--- ВАЖНО: Выстраиваем Квиз и Футер друг под другом */
    align-items: center;
    /* Центрируем по горизонтали */
    padding: 20px;
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 800px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    position: relative;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 20px;
    margin-bottom: 20px;
    /* Отступ от контейнера до футера */
    flex: 0 0 auto;
    /* Запрещаем контейнеру растягиваться по высоте */
}

header {
    background: var(--primary);
    color: white;
    margin: -20px -20px 20px -20px;
    padding: 30px 20px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    text-align: center;
    /* Легкий градиент в шапке */
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

header h1 {
    font-size: 1.6rem;
    margin-bottom: 5px;
    font-weight: 700;
    letter-spacing: -0.025em;
}

header p {
    font-size: 0.95rem;
    opacity: 0.9;
    font-weight: 400;
}

.logo-container {
    display: flex;
    align-items: center;

    /* Меняем здесь */
    justify-content: flex-start;
    /* Был center */
    margin-bottom: 10px;
}

/* Стили для экранов */
.screen {
    display: none;
    animation: fadeIn 0.5s;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Кнопки и вводы */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    margin: 5px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Опросник */
.progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

.category-tag {
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 10px;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.option-btn {
    padding: 15px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
}

.option-btn:hover {
    background: #f0f9ff;
    border-color: var(--primary);
}

/* Результаты */
.category-result {
    border: 1px solid #e2e8f0;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
}

.squares-container {
    display: flex;
    gap: 3px;
    margin-top: 10px;
}

.square {
    height: 15px;
    flex: 1;
    background: #e2e8f0;
    border-radius: 2px;
}

.square.fill-high {
    background: var(--success);
}

.square.fill-mid {
    background: var(--warning);
}

.square.fill-low {
    background: var(--danger);
}

.problem-zones {
    background: #fef2f2;
    border-left: 4px solid var(--danger);
    padding: 15px;
    margin-top: 20px;
}

/* Админка (список) */
.admin-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
    align-items: center;
}

/* Футер */
footer {
    display: block;
    /* Блочный элемент */
    width: 100%;
    /* На всю ширину экрана */
    margin-top: 30px;
    /* Отступ от контента сверху */

    /* Современный темный фон */
    background: #1e293b;
    color: var(--secondary);

    padding: 40px 20px;
    /* Вертикальный отступ побольше для воздуха */
    text-align: center;

    /* Граница сверху, чтобы отделить от фона */
    border-top: 1px solid #334155;

    /* ВАЖНО: Высота только под контент */
    min-height: auto;
    box-sizing: border-box;
}

/* Если хочешь, чтобы текст внутри футера не был слишком широким на ПК, можно ограничить ширину контента */
footer p {
    max-width: 600px;
    /* Текст не растянется на весь экран, а будет аккуратным по центру */
    margin: 0 auto 10px auto;
    /* Центрируем параграф */
    font-size: 0.95rem;
}

footer a {
    color: var(--primary);
    /* Фиолетовый цвет ссылок */
    text-decoration: none;
    font-weight: 600;
    margin: 0 5px;
}

footer a:hover {
    text-decoration: underline;
    color: #818cf8;
}

/* Универсальное модальное окно */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    /* Затемнение фона */
    z-index: 100000;
    /* Поверх всего, даже выше куки */
    display: none;
    /* Скрыто по умолчанию */
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Само окно */
.modal-window {
    background: #ffffff;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    /* Не выше 90% экрана */
    overflow-y: auto;
    /* Если текст длинный, скроллим */
    border-radius: 8px;
    padding: 30px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Кнопка закрытия */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    line-height: 24px;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background: #f1f5f9;
    color: #333;
}

/* Стили текста внутри окна (можно дополнить) */
.modal-content h2 {
    margin-top: 0;
    color: var(--primary);
}

.modal-content p {
    line-height: 1.6;
    color: #333;
}

/* Переключатель режимов в админке */
.admin-mode-switcher {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.mode-label {
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    color: var(--secondary);
    transition: all 0.2s;
    user-select: none;
}

/* Скрыть саму радио-кружок */
.mode-label input[type="radio"] {
    display: none;
}

/* Стили активной вкладки */
.mode-label.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.mode-label:hover:not(.active) {
    background-color: #e2e8f0;
}

/* Текст результата по категориям */
.cat-score-text {
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: 5px;
    display: block;
    /* Чтобы был с новой строки */
}

/* Цвета для текста */
.text-danger {
    color: var(--danger);
}

/* Красный */
.text-success {
    color: var(--success);
}

/* Зеленый */
.text-warning {
    color: var(--warning);
}

/* Желтый */
/* Контейнер для вариантов ответов */
#q-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Расстояние между вариантами ответа */
    margin-top: 20px;
}

/* Обертка одного варианта */
.option-wrapper {
    width: 100%;
}

/* Стиль самой кнопки-ответа (Label) */
.option-wrapper label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 15px;
    /* Большой отступ для удобства нажатия на мобильном */
    border: 1px solid #e2e8f0;
    /* Цвет границы из палитры */
    border-radius: 8px;
    background-color: #ffffff;
    transition: all 0.2s;
    font-size: 1rem;
    width: 100%;
    /* Растягиваем на всю ширину */
    box-sizing: border-box;
    /* Чтобы padding не увеличивал ширину */
}

/* Эффект наведения мышкой */
.option-wrapper label:hover {
    border-color: var(--primary);
    background-color: #f8fafc;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Текст ответа (отступ от радио-кнопки) */
.option-text {
    margin-left: 12px;
    line-height: 1.4;
    /* Межстрочный интервал для читаемости */
}

/* --- АДАПТАЦИЯ ПОД МОБИЛЬНЫЕ УСТРОЙСТВА (до 768px) --- */
@media (max-width: 768px) {

    /* Убираем лишние отступы по краям экрана */
    body {
        padding: 10px;
    }

    /* Контейнер занимает почти весь экран */
    .container {
        width: 95%;
        /* Ширина 95% от экрана (а не 100%) */
        margin: 0 auto;
        /* ПРИНУДИТЕЛЬНОЕ ЦЕНТРИРОВАНИЕ */
        padding: 15px;
        border-radius: 8px;
    }

    /* Шапка компактнее */
    header {
        padding: 15px;
        margin: -15px -15px 15px -15px;
        /* Компенсируем отступы контейнера */
    }

    header h1 {
        font-size: 1.2rem;
        /* Уменьшаем заголовок */
        margin-bottom: 5px;
    }

    header p {
        font-size: 0.85rem;
        display: none;
        /* Скрываем подзаголовок, чтобы не занимал место */
    }

    /* Кнопки на весь экран для удобства нажатия */
    .btn {
        width: 100%;
        display: block;
        margin: 10px 0;
        padding: 15px 20px;
        font-size: 1rem;
        min-height: 48px;
        /* Стандартная высота для тач-интерфейса */
    }

    /* Сетка ответов: превращаем в 1 колонку */
    .options-grid {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Обертка для радиокнопок (новый тест) */
    .option-wrapper {
        width: 100%;
    }

    .option-wrapper label {
        width: 100%;
        padding: 15px;
        font-size: 1rem;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* Чекбоксы (Чек-лист) */
    #cl-items-container>div {
        padding: 15px;
    }

    /* Футер */
    footer {
        font-size: 0.8rem;
        padding: 20px 10px;
    }

    /* Модальное окно */
    .modal-window {
        width: 95%;
        max-height: 95vh;
        padding: 20px;
    }

    /* Адаптивность для админки */
    .admin-row {
        flex-direction: column;
        /* Выстраиваем поля друг под другом */
        align-items: stretch;
    }

    .admin-row input[type="text"] {
        width: 100% !important;
        /* Растягиваем на всю ширину */
        margin-bottom: 10px;
        box-sizing: border-box;
    }

    .num-input,
    .cat-input {
        width: 100% !important;
        /* ID и Категория тоже во всю ширину */
    }

    .admin-btn {
        width: 100%;
        margin-bottom: 5px;
    }

    /* Текстовое поле для вариантов */
    .admin-row div[style*="flex-direction:column"] {
        width: 100%;
    }
}