/* ===== Default theme — светлая + тёмная + mobile-first ===== */

:root {
    --bg: #ffffff;
    --bg-soft: #f6f7f9;
    --surface: #ffffff;
    --border: #e6e8ec;
    --border-strong: #c9ced6;
    --text: #14171c;
    --text-muted: #5b6370;
    --accent: #2a6df4;
    --accent-hover: #1f58d0;
    --accent-soft: #e8f0ff;
    --brand: #009688;
    --brand-hover: #00796b;
    --danger: #d93b3b;
    --success: #1f9c5b;
    --warning: #e6a700;
    --shadow-sm: 0 1px 2px rgba(20, 23, 28, 0.04);
    --shadow-md: 0 4px 16px rgba(20, 23, 28, 0.06);
    --radius: 10px;

    /* Score backgrounds — на светлой теме нужны заметные цвета,
       иначе на белом фоне строки выглядят как «почти-белые» полосы.
       Берём tailwind 200/300 — насыщенно, но не кричаще. */
    --score-1-bg: #fecaca;
    --score-2-bg: #fde68a;
    --score-3-bg: #fef08a;
    --score-4-bg: #bbf7d0;
    --score-5-bg: #86efac;
    /* Цвет пустых звёзд в результатах — должен быть видим на пастельных
       фонах score-row. На светлой — серый посильнее, на тёмной — приглушённый. */
    --star-empty: #94a3b8;

    /* Accents for session cards */
    --card-finished-bg: var(--bg-soft);
    --card-soon-border: #fde68a;
    --card-soon-bg: #fffbeb;

    --alert-success-bg: #f0fdf4;
    --alert-success-border: #bbf7d0;
    --alert-warning-bg: #fffbeb;
    --alert-warning-border: #fde68a;
    --alert-danger-bg: #fef2f2;
    --alert-danger-border: #fecaca;
}

[data-theme="dark"] {
    --bg: #0f1216;
    --bg-soft: #151921;
    --surface: #1a1f27;
    --border: #2a303b;
    --border-strong: #3a424f;
    --text: #e7eaf0;
    --text-muted: #8a93a3;
    --accent: #5b8cff;
    --accent-hover: #7aa4ff;
    --accent-soft: #1d2b4a;
    --danger: #ff6467;
    --success: #4cd089;
    --warning: #f5c04b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);

    --score-1-bg: #4a1b1b;
    --score-2-bg: #4a3212;
    --score-3-bg: #4a3f14;
    --score-4-bg: #133a27;
    --score-5-bg: #164d34;
    --star-empty: #4b5563;

    --card-finished-bg: #151921;
    --card-soon-border: #8a6d1a;
    --card-soon-bg: #2e2716;

    --alert-success-bg: #143823;
    --alert-success-border: #1f6038;
    --alert-warning-bg: #2e2716;
    --alert-warning-border: #8a6d1a;
    --alert-danger-bg: #3a1818;
    --alert-danger-border: #6b2828;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Manrope', -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}
@media (max-width: 640px) {
    .container { padding: 0 16px; }
}

/* ===== Header ===== */
.site-header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    gap: 12px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    flex-shrink: 0;
    letter-spacing: -0.01em;
}
.brand-logo {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: block;
}
.brand-text {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.05;
    letter-spacing: -0.01em;
}
.brand-text-company {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    text-transform: uppercase;
}
.brand-text-product {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}
.nav {
    display: flex;
    align-items: center;
    gap: 20px;
    color: var(--text-muted);
}
.nav a { color: var(--text-muted); font-weight: 500; }
.nav a:hover { color: var(--text); }

.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 6px;
    margin-left: auto;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }
    .nav {
        position: absolute;
        top: 64px; left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 8px 16px 16px;
        display: none;
        z-index: 50;
    }
    .nav.open { display: flex; }
    .nav a, .nav form, .nav span {
        padding: 10px 0;
        border-bottom: 1px solid var(--border);
    }
    .nav form { border-bottom: none; margin-top: 8px; }
    .theme-toggle {
        align-self: flex-end;
        margin-top: 8px;
    }
}

/* ===== Main/footer ===== */
.main { padding: 40px 0 80px; }
@media (max-width: 640px) {
    .main { padding: 24px 0 48px; }
}

/* ===== Typography ===== */
h1, h2, h3 { color: var(--text); margin: 0 0 16px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 36px; line-height: 1.15; }
h2 { font-size: 24px; line-height: 1.25; }
h3 { font-size: 18px; line-height: 1.3; }
.lead { font-size: 17px; color: var(--text-muted); max-width: 640px; }
@media (max-width: 640px) {
    h1 { font-size: 26px; }
    h2 { font-size: 20px; }
    .lead { font-size: 16px; }
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card h3 { margin-top: 0; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:disabled { background: var(--border-strong); color: var(--surface); cursor: not-allowed; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--text-muted); }
.btn-danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border-strong);
}
.btn-danger:hover { border-color: var(--danger); }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-yandex {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}
.btn-yandex:hover { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }
.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}
body.login-page .login-divider { color: rgba(231, 234, 240, 0.5); }
body.login-page .login-divider::before,
body.login-page .login-divider::after { background: rgba(255, 255, 255, 0.12); }

/* ===== Avatar ===== */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-soft);
    flex: none;
    overflow: hidden;
    user-select: none;
    line-height: 1;
}
.avatar-fallback {
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* Большой аватар на splash-экране питча */
.pitcher-avatar-slot {
    display: inline-flex;
    justify-content: center;
}
.pitcher-avatar {
    box-shadow: 0 4px 24px rgba(0, 150, 136, 0.20);
    border: 4px solid var(--surface);
    outline: 1px solid var(--border);
}
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
}

/* ===== Feedback bullet list ===== */
.fb-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 6px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.fb-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 6px;
}
.fb-item .fb-item-bullet { margin-top: 6px; }
.fb-item .fb-item-remove { margin-top: 2px; }
.fb-item:hover { background: var(--bg-soft); }
.fb-item:focus-within { background: var(--bg-soft); }
.fb-item-bullet {
    color: var(--brand);
    font-size: 18px;
    line-height: 1;
    flex: none;
    user-select: none;
}
.fb-item-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 4px 0 !important;
    min-height: 28px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    line-height: 1.45;
    outline: none;
    /* textarea: запрещаем ручной ресайз и убираем родной скроллбар —
       высота управляется JS (autosizeTextarea) */
    resize: none;
    overflow: hidden;
    /* перенос длинных слов и URL без пробелов */
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.fb-item-input:focus { box-shadow: none !important; }
.fb-item-input::placeholder { color: var(--text-muted); }

/* Длинные пункты в карточках (ОС, сводка, табло) — переносить по словам;
   слитные «ТестТестТест…» без пробелов — разрывать только если совсем не
   помещается (overflow-wrap: break-word, не anywhere — иначе режет среди
   нормальных слов). hyphens:auto добавляет дефис при разрыве. */
.card {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}
.card ul li, .card ol li {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* ===== Заголовки секций ОС («Что хорошо» / «Над чем поработать») ===== */
.fb-section-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text) !important;
    margin-bottom: 8px;
}
.fb-section-good { color: var(--success) !important; }
.fb-section-bad  { color: var(--warning) !important; }

/* ===== Топик-баннер (тема питча на splash + active) =====
   На splash фон карточки часто тёмный (тематика-фон), поэтому используем
   плотный teal с белым текстом — читается на любом фоне. */
.topic-banner {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-radius: 999px;
    background: var(--brand);
    border: 1px solid var(--brand-hover);
    color: #fff;
    max-width: 100%;
    box-shadow: 0 2px 12px rgba(0, 150, 136, 0.25);
}
.topic-banner-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}
.topic-banner-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}
.topic-banner-compact { padding: 6px 14px; box-shadow: none; }
.topic-banner-compact .topic-banner-title { font-size: 17px; }

/* Аватарка активного питчера — крупный круг с белой обводкой и тенью,
   чтобы читаться на любом тематическом фоне (костёр, шторы, паттерн). */
.pitcher-avatar-active img,
.pitcher-avatar-active .avatar-fallback {
    border: 3px solid rgba(255, 255, 255, 0.92);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.3);
}

/* ===== Splash-карточка intro: ВКС в нижнем углу, контролы аккуратные ===== */
.stage-intro-card {
    position: relative;
}
.vks-corner-btn {
    /* Переехала из bottom-right в top-right: в нижнем правом сидит
       change-pitcher-row (admin/organizer), и открытый <select> или
       просто длинная кнопка «Сменить» визуально въезжали в эту ВКС-кнопку.
       Сверху она ни с чем не конфликтует — над hero-стартом места много. */
    position: absolute;
    right: 16px;
    top: 16px;
    padding: 6px 14px !important;
    font-size: 13px !important;
}
@media (max-width: 640px) {
    .vks-corner-btn {
        position: static;
        display: inline-block;
        margin-top: 16px;
    }
}

/* Большая кнопка «Старт питча» */
.btn-xl {
    padding: 18px 40px !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 16px rgba(42, 109, 244, 0.30);
}
.btn-xl:hover { box-shadow: 0 6px 20px rgba(42, 109, 244, 0.40); }

/* «Сменить питчера» — компактно в одну строку, без переноса */
.change-pitcher-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    max-width: 100%;
}
.change-pitcher-label {
    font-size: 13px;
    flex: none;
    white-space: nowrap;
}
.change-pitcher-select {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 260px;
}
.change-pitcher-row .btn {
    flex: none;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .change-pitcher-row { flex-wrap: wrap; justify-content: center; }
    .change-pitcher-select { flex: 1 1 100%; max-width: 100%; }
}

/* ===== Звёзды рейтингов — общая палитра ===== */
.stars-row { color: var(--text); }
.stars-row .stars .star { transition: color .1s ease; color: var(--star-empty); }
.stars-row .stars .star.star-filled { color: #f59e0b; }

/* Звёзды на табло результатов — тоже через --star-empty,
   чтобы на пастельном фоне score-row они не сливались. */
.score-row .star-empty { color: var(--star-empty); }
.score-row .star-filled { color: #f59e0b; }
.score-row { border: 1px solid rgba(0,0,0,0.06); }
[data-theme="dark"] .score-row { border-color: rgba(255,255,255,0.06); }
.fb-item-remove {
    flex: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity .15s;
}
.fb-item:hover .fb-item-remove,
.fb-item:focus-within .fb-item-remove { opacity: 1; }
.fb-item-remove:hover { color: var(--danger); background: rgba(217, 59, 59, 0.08); }

/* ===== Голосование за пункты ОС (👍/👎) ===== */
.vote-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
    line-height: 1.4;
    font-family: inherit;
}
.vote-btn:hover { border-color: var(--border-strong); color: var(--text); }
.vote-btn[disabled] { opacity: 0.5; cursor: progress; }
.vote-btn.vote-up.active {
    background: rgba(31, 156, 91, 0.15);
    border-color: var(--success);
    color: var(--success);
    font-weight: 700;
}
.vote-btn.vote-down.active {
    background: rgba(217, 59, 59, 0.12);
    border-color: var(--danger);
    color: var(--danger);
    font-weight: 700;
}
.vote-count { font-variant-numeric: tabular-nums; }

/* ===== Аккордеон тем в профиле ===== */
.topic-accordion summary { list-style: none; padding: 4px 0; }
.topic-accordion summary::-webkit-details-marker { display: none; }
.topic-accordion .topic-disclosure {
    display: inline-block;
    transition: transform .15s;
    color: var(--text-muted);
}
.topic-accordion[open] .topic-disclosure { transform: rotate(90deg); }

/* ===== Team picker — выбор участников из существующих сотрудников ===== */
.team-picker > details > summary {
    cursor: pointer;
    padding: 8px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    user-select: none;
}
.team-picker > details[open] > summary { border-style: solid; }
.team-picker-summary { list-style: none; }
.team-picker-summary::-webkit-details-marker { display: none; }

.team-group { border-bottom: 1px solid var(--border); padding: 4px 0; }
.team-group:last-child { border-bottom: none; }
.team-group-header {
    cursor: pointer;
    padding: 6px 4px;
    list-style: none;
    color: var(--text);
}
.team-group-header::-webkit-details-marker { display: none; }
.team-group-header::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    color: var(--text-muted);
    transition: transform .15s;
}
.team-group[open] > .team-group-header::before { transform: rotate(90deg); }

.team-group-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 4px;
    padding: 6px 0 8px;
}
.team-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    transition: background .12s, border-color .12s;
}
.team-user:hover { background: var(--bg-soft); border-color: var(--border-strong); }
.team-user.selected {
    background: rgba(0, 150, 136, 0.10);
    border-color: var(--brand);
    color: var(--brand);
}
.team-user .avatar { flex: none; }
.team-user-info {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.15;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.team-user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.team-user-pos {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.team-user-action {
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}
.team-user.selected .team-user-action {
    background: var(--brand);
    color: #fff;
}

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}
.input, .textarea, .select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 90px; resize: vertical; }

/* ===== Landing hero ===== */
.hero {
    padding: 60px 0 40px;
    text-align: left;
}
.hero h1 { font-size: 44px; margin-bottom: 16px; }
.hero .cta { margin-top: 24px; }
@media (max-width: 640px) {
    .hero { padding: 32px 0 24px; }
    .hero h1 { font-size: 30px; }
}

/* ===== Run stage (компактный прогон питчей) ===== */
body.running .main { padding: 16px 0 24px; }
body.running h1 { font-size: 22px; margin-bottom: 4px; }
body.running h2 { font-size: 16px; }
body.running .section + .section { margin-top: 24px; }

.run-hero { margin-top: 16px !important; }
.run-hero > .card {
    min-height: calc(100vh - 260px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.run-hero #timer { font-size: 96px; }
.run-hero #stage-intro > div[style*="font-size:40px"] { font-size: 56px !important; }
.run-hero + .section { margin-top: 20px; }

.run-hero > .card > * {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}
.run-hero > .card {
    padding-left: clamp(20px, 4vw, 32px);
    padding-right: clamp(20px, 4vw, 32px);
}

@media (max-width: 640px) {
    .run-hero #timer { font-size: 64px; }
    .run-hero #stage-intro > div[style*="font-size:40px"] { font-size: 36px !important; }
    .run-hero > .card {
        min-height: calc(100vh - 200px);
        padding: 24px 20px;
    }
}

/* ===== Цветовые строки оценки ===== */
.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    margin: 4px 0;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--text);
}
.score-row[data-score="1"] { background: var(--score-1-bg); }
.score-row[data-score="2"] { background: var(--score-2-bg); }
.score-row[data-score="3"] { background: var(--score-3-bg); }
.score-row[data-score="4"] { background: var(--score-4-bg); }
.score-row[data-score="5"] { background: var(--score-5-bg); }
.score-row[data-score="na"] { background: var(--bg-soft); }

/* ===== Подсветка карточек сессий в списке ===== */
.session-card.finished {
    opacity: 0.6;
    background: var(--card-finished-bg);
}
.session-card.active-now {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.session-card.starts-soon {
    border-color: var(--card-soon-border);
    background: var(--card-soon-bg);
}

/* ===== Stat cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: stretch;
}
.stats-grid .card + .card { margin-top: 0; }
.stat-card {
    text-align: center;
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 160px;
    margin: 0;
}
.stat-value { font-size: 44px; font-weight: 700; line-height: 1; margin-bottom: 8px; }

/* ===== Топы в 2 колонки, на мобильном — 1 ===== */
.top-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
}
.top-grid > div {
    display: flex;
    flex-direction: column;
}
.top-grid > div > .card {
    flex: 1;
    margin-top: 0;
}
@media (max-width: 720px) {
    .top-grid { grid-template-columns: 1fr; }
}

/* ===== Вкладки ===== */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
    overflow-y: hidden;
}
.tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab-btn.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== Alerts (работают и в светлой, и в тёмной теме) ===== */
.alert-success {
    background: var(--alert-success-bg) !important;
    border-color: var(--alert-success-border) !important;
}
.alert-warning {
    background: var(--alert-warning-bg) !important;
    border-color: var(--alert-warning-border) !important;
}
.alert-danger {
    background: var(--alert-danger-bg) !important;
    border-color: var(--alert-danger-border) !important;
}

/* ===== Utilities ===== */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.muted { color: var(--text-muted); }
.stack > * + * { margin-top: 12px; }
.section + .section { margin-top: 40px; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
}
.badge-admin {
    background: rgba(0, 150, 136, 0.12);
    color: var(--brand);
}

/* ===== Tables (admin/users) ===== */
.table { font-size: 14px; }
.table th, .table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg-soft);
}
.table tr:last-child td { border-bottom: none; }

/* link-styled <button> для form-based logout в navi */
.link-button {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
}
.link-button:hover { color: var(--text); }

/* ===== Sync stats grid ===== */
.sync-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}
@media (max-width: 640px) {
    .sync-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.sync-stat {
    background: var(--bg-soft);
    border-radius: var(--radius);
    padding: 12px;
    text-align: left;
}
.sync-stat-value {
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1.1;
}
.sync-stat-label {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Dynamic form rows (модули/критерии/участники) — на мобильном сжимаются ===== */
@media (max-width: 640px) {
    .dyn-row { flex-wrap: wrap; }
}

/* ===== Feedback: две колонки на широких, одна на узких ===== */
.fb-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 720px) {
    .fb-columns { grid-template-columns: 1fr; }
}

/* =====================================================================
   Страница входа — красивый фон + карточка + лого партнёра
   ===================================================================== */
body.login-page {
    min-height: 100vh;
    overflow-x: hidden;
    background: linear-gradient(160deg, #0c0f16 0%, #15111e 50%, #0a1220 100%);
    color: #e7eaf0;
}
[data-theme="light"] body.login-page,
body.login-page:not([data-theme]) {
    /* принудительно тёмная базовая гамма на странице входа */
}
body.login-page .site-header {
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
body.login-page .site-header .brand,
body.login-page .site-header .nav a { color: #e7eaf0; }
body.login-page .site-header .brand-text-product { color: #e7eaf0; }
body.login-page .site-header .brand-text-company { color: rgba(231, 234, 240, 0.55); }
body.login-page .theme-toggle {
    color: #e7eaf0;
    border-color: rgba(255,255,255,0.15);
}

.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
.login-bg .blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    will-change: transform;
}
.login-bg .blob-1 {
    width: 520px; height: 520px;
    left: -120px; top: -120px;
    background: radial-gradient(circle, #5b8cff 0%, transparent 70%);
    animation: pm-blob-1 22s ease-in-out infinite alternate;
}
.login-bg .blob-2 {
    width: 480px; height: 480px;
    right: -100px; top: 30%;
    background: radial-gradient(circle, #a855f7 0%, transparent 70%);
    animation: pm-blob-2 28s ease-in-out infinite alternate;
}
.login-bg .blob-3 {
    width: 460px; height: 460px;
    left: 30%; bottom: -160px;
    background: radial-gradient(circle, #22c55e 0%, transparent 70%);
    opacity: 0.35;
    animation: pm-blob-3 26s ease-in-out infinite alternate;
}
@keyframes pm-blob-1 {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(80px, 40px) scale(1.1); }
    100% { transform: translate(-40px, 90px) scale(0.95); }
}
@keyframes pm-blob-2 {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(-70px, 50px) scale(1.15); }
    100% { transform: translate(40px, -40px) scale(0.9); }
}
@keyframes pm-blob-3 {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(60px, -60px) scale(1.1); }
    100% { transform: translate(-40px, -30px) scale(0.95); }
}

body.login-page .main { position: relative; z-index: 1; padding: 0; }

.login-wrap {
    min-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    gap: 32px;
}
.login-card {
    width: 100%;
    max-width: 440px;
    background: rgba(23, 28, 38, 0.72);
    backdrop-filter: blur(18px) saturate(1.3);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.login-card .login-title { font-size: 32px; margin-bottom: 10px; color: #fff; }
.login-card .lead { color: rgba(255,255,255,0.65); }
.login-card .field label { color: rgba(255,255,255,0.6); }
.login-card .input {
    background: rgba(15, 18, 24, 0.8);
    color: #fff;
    border-color: rgba(255,255,255,0.12);
}
.login-card .input::placeholder { color: rgba(255,255,255,0.35); }
.login-card .input:focus {
    border-color: #5b8cff;
    box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.2);
}
.login-card .btn-primary { background: #5b8cff; border-color: #5b8cff; }
.login-card .btn-primary:hover { background: #7aa4ff; }

.partner-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.partner-logo:hover { opacity: 1; }
.partner-logo img {
    height: 28px;
    width: auto;
    display: block;
}

@media (max-width: 640px) {
    .login-card { padding: 28px 22px; }
    .login-card .login-title { font-size: 26px; }
    .login-bg .blob { filter: blur(70px); opacity: 0.45; }
    .login-bg .blob-1, .login-bg .blob-2, .login-bg .blob-3 {
        width: 300px; height: 300px;
    }
}

/* =====================================================================
   Темы оформления — применяются ТОЛЬКО на странице прогона (body.running)
   ===================================================================== */

/* flicker-анимация (для факелов/ламп) */
@keyframes pm-flicker {
    0%   { opacity: 0.6; transform: scale(1); }
    50%  { opacity: 0.95; transform: scale(1.08); }
    100% { opacity: 0.55; transform: scale(0.96); }
}
@keyframes pm-glow {
    0%, 100% { text-shadow: 0 0 20px currentColor; }
    50%      { text-shadow: 0 0 35px currentColor, 0 0 50px currentColor; }
}

/* --- Открытый микрофон ---
   Слои (от заднего к переднему):
   1. .card background — основной градиент сцены + сверху конус прожектора
   2. .run-hero::before — стилизованные шторы со складками (SVG data-URI)
   3. .run-hero::after  — большой силуэт микрофона снизу (SVG data-URI)
   4. .card::before     — emoji 🎤 в правом верхнем углу
   5. контент (timer, кнопки) — z-index выше декораций */
body.running.theme-openmic .run-hero {
    position: relative;
}
body.running.theme-openmic .run-hero > .card {
    background:
        /* конус прожектора сверху */
        radial-gradient(ellipse 50% 65% at 50% -10%, rgba(255,224,160,0.35), rgba(255,224,160,0) 70%),
        /* боковая засветка */
        radial-gradient(ellipse at 50% 10%, rgba(255,220,150,0.15), transparent 55%),
        linear-gradient(180deg, #2a0f0e 0%, #160706 100%);
    color: #fbe6cf;
    border: 1px solid #4a1c1b;
    position: relative;
    overflow: hidden;
    z-index: 0;
}
body.running.theme-openmic .run-hero > .card > * { position: relative; z-index: 2; }
/* Силуэт микрофона по центру снизу. inline-SVG как data-URI, без отдельного файла. */
body.running.theme-openmic .run-hero > .card::after {
    content: "";
    position: absolute;
    bottom: -10px; left: 50%;
    transform: translateX(-50%);
    width: 180px; height: 280px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 80 200'><ellipse cx='40' cy='38' rx='22' ry='30' fill='%231a1a1a' stroke='%23555' stroke-width='1.5'/><line x1='22' y1='30' x2='58' y2='30' stroke='%23444' stroke-width='1.2'/><line x1='22' y1='40' x2='58' y2='40' stroke='%23444' stroke-width='1.2'/><line x1='22' y1='50' x2='58' y2='50' stroke='%23444' stroke-width='1.2'/><rect x='37' y='68' width='6' height='8' fill='%23222'/><path d='M44 76 Q60 80 60 110' stroke='%23333' stroke-width='3' fill='none'/><rect x='38' y='110' width='4' height='75' fill='%232a2a2a'/><rect x='24' y='184' width='32' height='5' rx='1' fill='%231a1a1a'/><ellipse cx='40' cy='192' rx='28' ry='4' fill='%23090909'/></svg>") center bottom no-repeat;
    background-size: contain;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}
body.running.theme-openmic .run-hero > .card::before {
    /* шторы слева и справа — пять складок, реалистичная вертикальная драпировка */
    content: "";
    position: absolute;
    inset: 0;
    background:
        /* левая штора */
        linear-gradient(90deg,
            #4a0e0a 0px, #6b1813 16px, #3a0907 32px, #6b1813 48px, #3a0907 64px,
            #6b1813 80px, #3a0907 96px, transparent 110px) left top / 110px 100% no-repeat,
        /* правая штора (зеркало) */
        linear-gradient(270deg,
            #4a0e0a 0px, #6b1813 16px, #3a0907 32px, #6b1813 48px, #3a0907 64px,
            #6b1813 80px, #3a0907 96px, transparent 110px) right top / 110px 100% no-repeat;
    pointer-events: none;
    z-index: 1;
    opacity: 0.9;
}
body.running.theme-openmic .run-hero .muted { color: #dbb892; }
body.running.theme-openmic #timer {
    color: #ffd788;
    text-shadow: 0 0 28px rgba(255,215,136,0.7), 0 0 60px rgba(255,170,80,0.35);
}
body.running.theme-openmic .btn-primary { background: #c4402c; border-color: #c4402c; }
body.running.theme-openmic .btn-primary:hover { background: #a2321e; }
/* Иконка 🎤 в углу — поверх штор, чтобы её было видно. */
body.running.theme-openmic .run-hero::before {
    content: "🎤";
    position: absolute;
    top: 18px; right: 30px;
    font-size: 42px;
    z-index: 3;
    filter: drop-shadow(0 0 10px rgba(255,200,120,0.5));
}


/* --- Последний герой ---
   Слои:
   1. .card background — ночное небо → закат → жар углей внизу + россыпь звёзд (radial-gradient точки)
   2. .run-hero > .card::before — SVG пальмы по краям (силуэты)
   3. .run-hero > .card::after  — большой SVG костёр снизу с CSS-анимацией мерцания
*/
body.running.theme-survivor .run-hero > .card {
    background:
        /* звёзды — много мелких белых точек через radial-gradients */
        radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,240,200,0.9), transparent 60%),
        radial-gradient(1px 1px at 28% 8%, rgba(255,240,200,0.7), transparent 60%),
        radial-gradient(1px 1px at 47% 22%, rgba(255,240,200,0.8), transparent 60%),
        radial-gradient(1.2px 1.2px at 63% 12%, rgba(255,240,200,0.6), transparent 60%),
        radial-gradient(1.5px 1.5px at 78% 20%, rgba(255,240,200,0.9), transparent 60%),
        radial-gradient(1px 1px at 88% 6%, rgba(255,240,200,0.7), transparent 60%),
        radial-gradient(1px 1px at 95% 24%, rgba(255,240,200,0.6), transparent 60%),
        /* жар углей внизу */
        radial-gradient(ellipse 60% 25% at 50% 100%, rgba(251,146,60,0.45), transparent 70%),
        /* основной градиент: ночь → закат → угли */
        linear-gradient(180deg, #0a0a1a 0%, #2d1505 65%, #1a0a02 90%, #0a0602 100%);
    color: #ffe4c2;
    border: 1px solid #5a2a10;
    position: relative;
    overflow: hidden;
}
/* Пальмы — две SVG силуэта с обеих сторон. */
body.running.theme-survivor .run-hero > .card::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        /* левая пальма */
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 400'><path d='M85 400 L78 200 Q72 150 68 100' stroke='%23080604' stroke-width='8' fill='none' stroke-linecap='round'/><path d='M68 100 Q40 70 12 80 Q35 78 55 95' fill='%23080604'/><path d='M68 100 Q90 60 130 55 Q105 75 78 102' fill='%23080604'/><path d='M68 100 Q50 130 25 155 Q55 130 75 110' fill='%23080604'/><path d='M68 100 Q105 130 145 130 Q110 115 80 105' fill='%23080604'/><circle cx='70' cy='95' r='6' fill='%23080604'/></svg>") left bottom / auto 92% no-repeat,
        /* правая пальма (зеркало) */
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 400'><path d='M115 400 L122 200 Q128 150 132 100' stroke='%23080604' stroke-width='8' fill='none' stroke-linecap='round'/><path d='M132 100 Q160 70 188 80 Q165 78 145 95' fill='%23080604'/><path d='M132 100 Q110 60 70 55 Q95 75 122 102' fill='%23080604'/><path d='M132 100 Q150 130 175 155 Q145 130 125 110' fill='%23080604'/><path d='M132 100 Q95 130 55 130 Q90 115 120 105' fill='%23080604'/><circle cx='130' cy='95' r='6' fill='%23080604'/></svg>") right bottom / auto 92% no-repeat;
    pointer-events: none;
    z-index: 1;
}
/* Костёр внизу — SVG пламени с CSS-анимацией мерцания и плавного scale. */
body.running.theme-survivor .run-hero > .card::after {
    content: "";
    position: absolute;
    bottom: -10px; left: 50%;
    transform: translateX(-50%);
    width: 200px; height: 180px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><defs><radialGradient id='f1' cx='0.5' cy='0.85' r='0.6'><stop offset='0' stop-color='%23fff2c0'/><stop offset='0.3' stop-color='%23ffb84d'/><stop offset='0.7' stop-color='%23e2570c'/><stop offset='1' stop-color='%23a01a05' stop-opacity='0'/></radialGradient></defs><path d='M50 95 Q35 70 32 55 Q40 60 42 50 Q42 30 50 12 Q56 30 58 50 Q60 60 68 55 Q65 70 50 95 Z' fill='url(%23f1)'/><path d='M50 95 Q42 80 40 70 Q45 75 47 65 Q49 50 50 35 Q52 50 53 65 Q56 75 60 70 Q58 80 50 95 Z' fill='%23fff2c0' opacity='0.55'/><ellipse cx='50' cy='90' rx='32' ry='6' fill='%231a0a02'/><line x1='25' y1='92' x2='75' y2='85' stroke='%23231007' stroke-width='3' stroke-linecap='round'/><line x1='30' y1='95' x2='70' y2='95' stroke='%23170a04' stroke-width='3' stroke-linecap='round'/></svg>") center bottom / contain no-repeat;
    pointer-events: none;
    z-index: 1;
    transform-origin: 50% 100%;
    animation: pm-fire-dance 0.7s infinite alternate ease-in-out;
    filter: drop-shadow(0 -10px 30px rgba(251,146,60,0.6));
}
@keyframes pm-fire-dance {
    0%   { transform: translateX(-50%) scale(1, 0.95); opacity: 0.95; }
    50%  { transform: translateX(-50%) scale(1.03, 1.08); opacity: 1; }
    100% { transform: translateX(-50%) scale(0.98, 1); opacity: 0.9; }
}
body.running.theme-survivor .run-hero > .card > * { position: relative; z-index: 2; }
body.running.theme-survivor .run-hero .muted { color: #d7ac7e; }
body.running.theme-survivor #timer {
    color: #fb923c;
    text-shadow: 0 0 22px rgba(251,146,60,0.55), 0 0 50px rgba(220,80,30,0.35);
}
body.running.theme-survivor .btn-primary { background: #c2410c; border-color: #c2410c; }
body.running.theme-survivor .btn-primary:hover { background: #9a3412; }

/* --- Игра в кальмара ---
   Слои:
   1. .card background — основной тёмный градиент + tiled паттерн ◯△▢ через
      SVG data-URI (репитится по всей карточке как обои).
   2. .run-hero > .card::before — большой контурный знак-страж по правому краю
      (полупрозрачный, медленно пульсирует).
   3. .run-hero > .card::after — оверлей-«виньетка» с тёмными краями и
      кроваво-розовым свечением в центре — атмосфера дозы.
*/
body.running.theme-squidgame .run-hero > .card {
    background:
        /* tiled паттерн ◯△▢ — три фигуры в розовой стороже */
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><g stroke='%23e91e63' stroke-width='2' fill='none' opacity='0.18'><circle cx='40' cy='40' r='22'/><polygon points='90,18 112,62 68,62'/><rect x='128' y='18' width='44' height='44'/><polygon points='40,98 62,142 18,142'/><rect x='68' y='98' width='44' height='44'/><circle cx='150' cy='120' r='22'/></g></svg>"),
        radial-gradient(circle at 20% 20%, rgba(233,30,99,0.14), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(233,30,99,0.10), transparent 50%),
        linear-gradient(180deg, #1b0f16 0%, #0c0709 100%);
    color: #fff;
    border: 1px solid #3b1525;
    position: relative;
    overflow: hidden;
}
/* Большой страж-силуэт справа, пульсирующий — отсылка к маске «менеджера». */
body.running.theme-squidgame .run-hero > .card::before {
    content: "";
    position: absolute;
    top: 50%; right: -40px;
    transform: translateY(-50%);
    width: 280px; height: 280px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><g stroke='%23e91e63' stroke-width='3' fill='none' opacity='0.55'><circle cx='100' cy='100' r='95'/><circle cx='100' cy='100' r='75'/><polygon points='100,30 165,150 35,150' stroke-width='2.5'/></g></svg>") center / contain no-repeat;
    pointer-events: none;
    z-index: 1;
    animation: pm-squid-pulse 3.5s infinite ease-in-out;
}
/* Виньетка — затемнение по краям + кровавый розовый glow по центру снизу. */
body.running.theme-squidgame .run-hero > .card::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 30% at 50% 105%, rgba(255,64,129,0.22), transparent 70%),
        radial-gradient(ellipse 110% 80% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
    pointer-events: none;
    z-index: 1;
}
body.running.theme-squidgame .run-hero > .card > * { position: relative; z-index: 2; }
@keyframes pm-squid-pulse {
    0%, 100% { opacity: 0.4; transform: translateY(-50%) scale(1); }
    50%      { opacity: 0.7; transform: translateY(-50%) scale(1.04); }
}
body.running.theme-squidgame .run-hero .muted { color: #e0bfcf; }
body.running.theme-squidgame #timer {
    color: #ff4081;
    text-shadow: 0 0 22px rgba(255,64,129,0.65), 0 0 60px rgba(255,30,100,0.35);
}
body.running.theme-squidgame .btn-primary { background: #e91e63; border-color: #e91e63; }
body.running.theme-squidgame .btn-primary:hover { background: #c2185b; }

