/* ==========================================================================
   Портал тестов для аналитиков — общие стили
   ========================================================================== */
:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-faint: #64748b;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-soft: #eef2ff;
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --bad: #dc2626;
    --bad-soft: #fee2e2;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --line: #e2e8f0;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 20px rgba(15, 23, 42, .12), 0 24px 48px rgba(15, 23, 42, .10);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    flex: 1 0 auto;
}

/* ---------- Шапка портала ---------- */
.topbar {
    background: linear-gradient(120deg, #312e81 0%, #4f46e5 55%, #7c3aed 100%);
    color: #fff;
    padding: 14px 0;
    box-shadow: 0 2px 10px rgba(49, 46, 129, .25);
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}
.brand:hover { text-decoration: none; opacity: .95; }
.topbar-links { display: flex; gap: 8px; }
.topbar-links a {
    color: #fff;
    opacity: .9;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .95rem;
}
.topbar-links a:hover { background: rgba(255,255,255,.14); text-decoration: none; opacity: 1; }

/* ---------- Герой (главная) ---------- */
.hero {
    text-align: center;
    padding: 56px 20px 40px;
}
.hero h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -.5px; }
.hero p { color: var(--ink-soft); font-size: 1.15rem; max-width: 720px; margin: 14px auto 0; line-height: 1.55; }
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 26px;
    flex-wrap: wrap;
}
.stat-pill {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 20px;
    font-weight: 600;
    color: var(--ink-soft);
    box-shadow: var(--shadow);
}
.stat-pill b { color: var(--brand); }

/* ---------- Заголовки секций ---------- */
.section-title { font-size: 1.4rem; font-weight: 700; margin: 8px 0 18px; }

/* ---------- Карточки курсов ---------- */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    padding-bottom: 48px;
}
.course-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.course-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand);
}
.course-card .icon { font-size: 2rem; line-height: 1; }
.course-card h2 { font-size: 1.3rem; }
.course-card .desc { color: var(--ink-soft); line-height: 1.5; flex: 1; font-size: .98rem; }
.course-card .meta { color: var(--ink-faint); font-size: .92rem; }
.course-card .audience {
    font-size: .85rem;
    color: var(--brand-dark);
    background: var(--brand-soft);
    padding: 6px 12px;
    border-radius: 999px;
    align-self: flex-start;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 12px;
    padding: 12px 22px;
    font-size: 1rem;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 8px 20px rgba(79, 70, 229, .35); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-soft:hover { background: #e0e7ff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #15803d; }
.btn-block { width: 100%; }

/* ---------- Хлебные крошки и заголовок страницы курса ---------- */
.breadcrumbs { padding: 18px 0 0; color: var(--ink-faint); font-size: .95rem; }
.breadcrumbs a { color: var(--ink-faint); }
.breadcrumbs a:hover { color: var(--brand); }
.course-head { padding: 20px 0 8px; display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.course-head .icon { font-size: 3rem; line-height: 1; }
.course-head h1 { font-size: 2rem; font-weight: 800; }
.course-head .desc { color: var(--ink-soft); margin-top: 6px; max-width: 760px; line-height: 1.5; }
.course-head .chips { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Список тем ---------- */
.tests-list { padding: 10px 0 48px; display: flex; flex-direction: column; gap: 12px; }
.test-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    flex-wrap: wrap;
}
.test-row .num {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem;
}
.test-row .body { flex: 1 1 240px; min-width: 0; }
.test-row .body h3 { font-size: 1.12rem; }
.test-row .body .sub { color: var(--ink-faint); font-size: .9rem; margin-top: 2px; }
.test-row .go { flex: 0 0 auto; }

/* ---------- Страница теста (визард) ---------- */
.test-wrap { max-width: 860px; margin: 0 auto; padding: 24px 0 56px; }
.test-head {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.test-head .crumbs { font-size: .9rem; color: var(--ink-faint); margin-bottom: 6px; }
.test-head h1 { font-size: 1.5rem; }
.progress-track { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.progress-bar { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar .fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--brand), #7c3aed);
    border-radius: 999px;
    transition: width .3s ease;
}
.progress-label { color: var(--ink-soft); font-weight: 600; font-size: .95rem; white-space: nowrap; }

/* Навигатор по вопросам */
.q-dots { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.q-dot {
    width: 30px; height: 30px;
    border-radius: 9px;
    border: 2px solid var(--line);
    background: var(--surface);
    color: var(--ink-faint);
    font-size: .82rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .15s ease;
}
.q-dot:hover { border-color: var(--brand); }
.q-dot.current { border-color: var(--brand); background: var(--brand); color: #fff; }
.q-dot.answered { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.q-dot.answered.current { background: var(--brand); color: #fff; }

/* Карточка вопроса */
.question-view { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.q-counter { font-size: .9rem; font-weight: 700; color: var(--brand-dark); text-transform: uppercase; letter-spacing: .04em; }
.q-text { font-size: 1.3rem; line-height: 1.5; margin: 14px 0 22px; font-weight: 600; }
.q-options { display: flex; flex-direction: column; gap: 12px; }
.q-option {
    display: flex; align-items: flex-start; gap: 14px;
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 15px 16px;
    background: #f8fafc;
    cursor: pointer;
    transition: all .15s ease;
    font-size: 1.02rem;
    line-height: 1.45;
    color: var(--ink);
    text-align: left;
    width: 100%;
    font-family: inherit;
}
.q-option:hover { border-color: var(--brand); background: var(--brand-soft); }
.q-option .letter {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #e2e8f0;
    color: var(--ink-soft);
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem;
}
.q-option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.q-option.selected .letter { background: var(--brand); color: #fff; }

/* Навигация по вопросам */
.nav-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.nav-row .spacer { flex: 1; }
.nav-hint { width: 100%; color: var(--ink-faint); font-size: .85rem; margin-top: 10px; text-align: center; }
kbd {
    background: #e2e8f0; border-radius: 5px; padding: 1px 6px;
    font-family: inherit; font-size: .8rem; font-weight: 600; color: var(--ink-soft);
}

/* ---------- Результаты ---------- */
.results-head { text-align: center; padding: 26px 0 10px; }
.results-head h1 { font-size: 1.9rem; }
.grade-chip { display: inline-block; margin-top: 12px; padding: 8px 22px; border-radius: 999px; font-weight: 700; font-size: 1.05rem; }
.grade-good { background: var(--ok-soft); color: #166534; }
.grade-mid { background: var(--warn-soft); color: #92400e; }
.grade-bad { background: var(--bad-soft); color: #991b1b; }
.score-cards { display: flex; gap: 12px; justify-content: center; margin: 20px 0 10px; flex-wrap: wrap; }
.score-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 22px; box-shadow: var(--shadow); text-align: center; min-width: 110px; }
.score-card .v { font-size: 1.6rem; font-weight: 800; }
.score-card .k { color: var(--ink-faint); font-size: .85rem; }
.score-card.green .v { color: var(--ok); }
.score-card.red .v { color: var(--bad); }
.score-card.brand .v { color: var(--brand); }

.review-list { display: flex; flex-direction: column; gap: 16px; padding: 14px 0 40px; }
.review-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border-left: 6px solid var(--line); }
.review-item.ok { border-left-color: var(--ok); }
.review-item.fail { border-left-color: var(--bad); }
.review-item .top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.review-item .qnum { font-weight: 800; color: var(--brand-dark); }
.badge { padding: 4px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: #166534; }
.badge.fail { background: var(--bad-soft); color: #991b1b; }
.review-item .qtext { margin: 10px 0 12px; font-weight: 600; line-height: 1.45; }
.answer-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-lines .al { border-radius: 10px; padding: 12px 14px; font-size: .97rem; line-height: 1.45; }
.al-user { background: var(--brand-soft); border: 1px solid #c7d2fe; }
.al-correct { background: var(--ok-soft); border: 1px solid #86efac; }
.al .who { font-weight: 700; font-size: .85rem; margin-bottom: 4px; display: block; }
.al-user .who { color: var(--brand-dark); }
.al-correct .who { color: #166534; }
.explain { margin-top: 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; font-size: .97rem; line-height: 1.5; color: #713f12; }
.explain b { color: #92400e; }

/* ---------- Страница «все ответы» ---------- */
.answer-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.answer-section h2 { font-size: 1.25rem; margin-bottom: 4px; }
.answer-section .sub { color: var(--ink-faint); margin-bottom: 14px; }
.answer-q { padding: 14px 0; border-top: 1px solid var(--line); }
.answer-q .qtext { font-weight: 600; margin-bottom: 10px; }
.answer-q .opt { display: flex; gap: 10px; padding: 8px 12px; border-radius: 8px; align-items: flex-start; line-height: 1.45; font-size: .98rem; }
.answer-q .opt.is-correct { background: var(--ok-soft); }
.answer-q .opt .l { font-weight: 800; color: var(--ink-faint); flex: 0 0 auto; }
.answer-q .opt.is-correct .l { color: #166534; }
.answer-q .explain { margin-top: 10px; }

/* ---------- Ошибка ---------- */
.error-box { text-align: center; padding: 80px 20px; }
.error-box .code { font-size: 5rem; font-weight: 800; background: linear-gradient(120deg, var(--brand), #7c3aed); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-box p { color: var(--ink-soft); margin: 12px 0 26px; }

/* ---------- Подвал ---------- */
.footer { margin-top: 40px; padding: 22px 0; text-align: center; color: var(--ink-faint); font-size: .9rem; border-top: 1px solid var(--line); background: #f8fafc; }
.footer a { color: var(--ink-faint); }

/* ---------- Печать (страница «все ответы») ---------- */
@media print {
    .topbar, .footer, .no-print { display: none !important; }
    body { background: #fff; }
    .answer-section, .review-item { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .container { max-width: none; }
}

/* ---------- Адаптивность ---------- */
@media (max-width: 640px) {
    .hero h1 { font-size: 1.8rem; }
    .question-view { padding: 20px 16px; }
    .q-text { font-size: 1.15rem; }
    .answer-lines { grid-template-columns: 1fr; }
    .nav-row .btn { flex: 1 1 auto; }
    .test-row { flex-direction: column; align-items: stretch; text-align: left; }
    .test-row .go { text-align: left; }
    .course-head h1 { font-size: 1.6rem; }
}

/* ---------- Авторизация и формы ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 40px 0 60px; }
.auth-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 32px; width: 100%; max-width: 440px;
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-faint); margin-bottom: 18px; font-size: .95rem; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.form-field input[type=text], .form-field input[type=email],
.form-field input[type=password] {
    width: 100%; padding: 11px 13px; border: 1.5px solid var(--line);
    border-radius: 10px; font-size: 1rem; font-family: inherit; background: #fff;
}
.form-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-field .hint { color: var(--ink-faint); font-size: .85rem; margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--ink-soft); }
.auth-links { margin-top: 16px; font-size: .92rem; color: var(--ink-faint); }
.auth-links a { font-weight: 600; }
.error-msg { background: var(--bad-soft); color: #991b1b; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .93rem; }
.dev-link-box { background: var(--warn-soft); border: 1px solid #fde68a; color: #713f12; padding: 12px 14px; border-radius: 10px; margin: 14px 0; font-size: .92rem; word-break: break-all; }
.flashes { max-width: 1080px; margin: 14px auto 0; padding: 0 20px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 10px; font-size: .95rem; }
.flash.ok { background: var(--ok-soft); color: #166534; }
.flash.warning { background: var(--warn-soft); color: #92400e; }
.flash.error { background: var(--bad-soft); color: #991b1b; }
.avatar-circle { width: 64px; height: 64px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-size: 1.7rem; font-weight: 800; margin-bottom: 12px; }
.profile-row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .97rem; flex-wrap: wrap; }
.profile-row .k { color: var(--ink-faint); }
.badge-ok { background: var(--ok-soft); color: #166534; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.badge-muted { background: var(--line); color: var(--ink-soft); padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.link-btn { background: none; border: none; color: #fff; opacity: .92; font-family: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; padding: 8px 12px; border-radius: 10px; }
.link-btn:hover { background: rgba(255,255,255,.14); opacity: 1; }
.link-btn-brand { background: none; border: none; color: var(--brand); font-family: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; padding: 0; }
.link-btn-brand:hover { text-decoration: underline; }

/* Уровневые чипы на лендинге */
.lv-chip {
    display: inline-block;
    font-size: .85rem;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
}

/* Кнопки-ссылки: без подчёркивания, в т.ч. при наведении */
a.btn,
a.btn:link,
a.btn:visited,
a.btn:hover,
a.btn:active,
a.btn:focus {
    text-decoration: none !important;
}
