/* ==================== БАЗОВЫЕ СТИЛИ ==================== */
:root {
    --bg: #F4F6F9;
    --surface: #FFFFFF;
    --primary: #4F6BED;
    --primary-hover: #3D56D4;
    --primary-light: #EEF1FD;
    --success: #2EAF6A;
    --success-bg: #EAFAF1;
    --danger: #E74C3C;
    --danger-bg: #FDEDEC;
    --warning: #F39C12;
    --warning-bg: #FEF9E7;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --header-dark: #1E293B;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ==================== НАВБАР ==================== */
.navbar {
    background: var(--header-dark);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-logo {
    color: white;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
}

.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-user { color: #CBD5E1; font-size: 13px; }
.nav-link { color: #94A3B8; font-size: 13px; text-decoration: none; }
.nav-link:hover { color: white; }

/* ==================== КНОПКИ ==================== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-dark { background: var(--header-dark); color: white; }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; }

/* ==================== ФОРМЫ ==================== */
.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #F8FAFC;
    transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--primary); background: white; }
.form-input--mono { font-family: 'Consolas', 'Courier New', monospace; font-size: 15px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.required { color: var(--danger); }
.form-link { display: block; text-align: center; margin-top: 16px; color: var(--primary); text-decoration: none; font-size: 13px; }

/* ==================== КАРТОЧКИ ==================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

/* ==================== TOAST ==================== */
#toast-container {
    position: fixed;
    top: 64px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    border-left: 4px solid;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 420px;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
}
.toast--success { background: var(--success-bg); border-color: var(--success); color: #065F46; }
.toast--error { background: var(--danger-bg); border-color: var(--danger); color: #991B1B; }
.toast--warning { background: var(--warning-bg); border-color: var(--warning); color: #92400E; }
.toast--info { background: var(--primary-light); border-color: var(--primary); color: #1E40AF; }

.toast-close { margin-left: auto; cursor: pointer; opacity: 0.6; font-size: 16px; }
.toast-close:hover { opacity: 1; }

@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }

/* ==================== СТРАНИЦА ЛОГИНА ==================== */
.login-page {
    min-height: calc(100vh - 52px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--header-dark);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-md);
}
.login-title { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.form-heading { font-size: 16px; margin-bottom: 20px; text-align: center; }

/* ==================== ГЛАВНОЕ МЕНЮ ==================== */
.menu-page { max-width: 960px; margin: 0 auto; padding: 20px; }
.menu-header { text-align: center; padding: 30px 0 20px; }
.menu-header h1 { font-size: 24px; }
.menu-header p { color: var(--text-secondary); margin-top: 4px; }

.menu-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 30px; }

.menu-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}
.menu-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }

.card-accent { height: 4px; width: 50px; border-radius: 2px; margin-bottom: 18px; }
.card-icon { font-size: 32px; margin-bottom: 8px; }
.menu-card h3 { font-size: 16px; margin-bottom: 6px; }
.menu-card p { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; flex-grow: 1; }
.menu-card .btn { align-self: flex-start; }

.card-progress { margin-bottom: 16px; }
.card-stat { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-text { font-size: 12px; color: var(--text-muted); }

.progress-bar--header { width: 120px; }
.progress-bar--small { width: 100px; }
.progress-text-light { color: rgba(255,255,255,0.7); font-size: 12px; }

.menu-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 40px;
}
.stat-item { text-align: center; }
.stat-num { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-secondary); }

/* ==================== ВАРИАНТЫ ==================== */
.variants-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    color: white;
}
.page-header--success { background: var(--success); }
.page-header--primary { background: var(--primary); }
.page-header h2 { font-size: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.group-section { margin-bottom: 16px; }
.group-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.group-dot { font-size: 12px; }
.group-title { color: var(--text-secondary); font-weight: 400; }
.group-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.variant-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
    transition: all 0.12s;
    position: relative;
}
.variant-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.variant-card--done { background: #F0FFF4; border-color: #A7F3D0; }

.variant-accent { height: 3px; border-radius: 2px; margin-bottom: 10px; }
.variant-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.variant-name { font-weight: 700; font-size: 13px; }
.variant-check { color: var(--success); font-weight: 700; font-size: 16px; }

.variant-params { display: flex; align-items: center; gap: 8px; }
.variant-pressure { font-size: 12px; color: var(--text-secondary); }
.variant-regulation { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.badge-primary { background: var(--primary); color: white; }
.badge-success { background: var(--success); color: white; }
.badge-outline { background: var(--bg); color: var(--text); }

/* ==================== ЭКРАН ЗАДАНИЯ ==================== */
.task-page { display: flex; flex-direction: column; height: calc(100vh - 52px); }

.task-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--header-dark);
    padding: 10px 20px;
    color: white;
}
.task-header--test { background: #7F1D1D; }
.header-title { font-size: 14px; font-weight: 600; }

.test-progress-dots { display: flex; gap: 4px; margin-left: 16px; }
.dot { width: 36px; height: 5px; border-radius: 3px; background: #444; }
.dot--active { background: var(--danger); }
.task-header-left { display: flex; align-items: center; }
.task-header-right { display: flex; align-items: center; }

.timer { font-size: 20px; font-weight: 700; color: #FF6B6B; font-family: 'Consolas', monospace; }

.task-body { display: flex; flex: 1; overflow: hidden; padding: 12px; gap: 12px; }

.task-left { width: 460px; min-width: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.task-right { flex: 1; display: flex; }

.schema-card { display: flex; flex-direction: column; flex: 1; padding: 12px; }
.schema-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.schema-container { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
#schemaCanvas { cursor: crosshair; max-width: 100%; max-height: 100%; }
.schema-hint { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 6px; }

.card-badges { display: flex; gap: 6px; margin-bottom: 12px; }
.params-box { padding: 12px; border-radius: 6px; font-size: 13px; font-weight: 600; margin-bottom: 12px; line-height: 1.8; }
.condition-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.condition-text { font-size: 13px; line-height: 1.6; color: var(--text); padding: 10px; background: #FAFBFC; border: 1px solid var(--border); border-radius: 6px; }

.answer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.answer-header h3 { font-size: 16px; }
.attempt-counter { font-size: 12px; color: var(--text-muted); }
.answer-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.answer-buttons { display: flex; gap: 8px; margin-top: 10px; }
.hint-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.hint-dots { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); }
.hdot { font-size: 16px; }
.hdot--active { color: var(--warning); }

#resultArea { margin-top: 12px; }
.result-msg {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-line;
}
.result-msg--success { background: var(--success-bg); color: #065F46; }
.result-msg--warning { background: var(--warning-bg); color: #92400E; }
.result-msg--error { background: var(--danger-bg); color: #991B1B; }

.task-nav {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* ==================== РЕЗУЛЬТАТ ТЕСТА ==================== */
.result-page { display: flex; justify-content: center; padding: 40px 20px; }
.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; max-width: 560px; width: 100%; text-align: center; }
.result-card h2 { font-size: 18px; margin-bottom: 4px; }
.result-student { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.result-motivation { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.grade-badge {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    color: white;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-bottom: 24px;
    max-width: 100%;
    box-sizing: border-box;
    word-break: keep-all;
    overflow-wrap: anywhere;
    line-height: 1.3;
}

.result-stats { display: flex; justify-content: center; gap: 32px; margin-bottom: 24px; }
.result-detail { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; text-align: left; }
.result-actions { margin-top: 24px; }

.violations-box {
    background: var(--danger-bg);
    border: 1px solid #FECACA;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
    text-align: left;
}
.violations-box h4 { color: var(--danger); font-size: 13px; margin-bottom: 6px; }
.violation-item { font-size: 12px; color: #991B1B; }

/* ==================== ТАБЛИЦА РЕЗУЛЬТАТОВ ==================== */
.results-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }
.table-wrap { overflow-x: auto; }

.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600; font-size: 12px; color: var(--text-secondary); border-bottom: 2px solid var(--border); }
.results-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.results-table tr:hover td { background: #F8FAFC; }
.results-table a { color: var(--primary); text-decoration: none; }

.progress-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.student-progress-item { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.student-progress-item:last-child { border-bottom: none; padding-bottom: 0; }
.student-progress-item .progress-bar { flex: 1; min-width: 100px; }
.sp-count { min-width: 50px; text-align: right; font-weight: 600; color: var(--text-secondary); }
.student-progress-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; }
.sp-name { font-weight: 600; min-width: 140px; }
.sp-group { color: var(--text-muted); font-size: 12px; min-width: 60px; }
.sp-count { font-size: 12px; color: var(--text-secondary); }

.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { color: var(--text-secondary); }
.empty-state p { color: var(--text-muted); font-size: 13px; }

/* ==================== УТИЛИТЫ ==================== */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

/* ==================== АДАПТИВНОСТЬ ==================== */
@media (max-width: 768px) {
    .task-body { flex-direction: column; }
    .task-left { width: 100%; min-width: 0; }
    .menu-stats { flex-wrap: wrap; gap: 20px; }
    .variant-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .result-stats { flex-wrap: wrap; }
    .results-table { font-size: 12px; }
}

/* ==================== АНТИЧИТ СТИЛИ ====================  */

/* Баннер нарушений */
#violation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    padding: 0;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.5);
}
#violation-banner.show {
    transform: translateY(0);
}
.violation-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    max-width: 900px;
    margin: 0 auto;
}
.violation-icon {
    font-size: 28px;
    flex-shrink: 0;
    animation: violationPulse 0.5s ease-in-out infinite alternate;
}
@keyframes violationPulse {
    from { transform: scale(1); }
    to { transform: scale(1.2); }
}
.violation-title {
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.violation-message {
    font-size: 13px;
    opacity: 0.95;
    flex: 1;
}
.violation-counter {
    font-size: 12px;
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}
.violation-timer {
    font-size: 12px;
    opacity: 0.8;
    white-space: nowrap;
}
.violation-timer span {
    font-weight: 700;
    font-size: 16px;
    color: #fbbf24;
}

/* Блокировщик полноэкранного режима */
#fullscreen-blocker {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
}
#fullscreen-blocker.show {
    display: flex;
}
.fullscreen-blocker-content {
    max-width: 450px;
    padding: 40px;
}
.fullscreen-blocker-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: blockerPulse 2s ease-in-out infinite;
}
@keyframes blockerPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}
.fullscreen-blocker-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}
.fullscreen-blocker-content p {
    font-size: 14px;
    color: #d1d5db;
    margin-bottom: 8px;
}
.fullscreen-blocker-content .btn {
    margin-top: 20px;
    padding: 12px 32px;
    font-size: 16px;
}

/* Анимация пульсации таймера при штрафе */
@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Мобильная адаптация баннера */
@media (max-width: 768px) {
    .violation-content {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 14px;
    }
    .violation-title { font-size: 13px; }
    .violation-message { font-size: 12px; width: 100%; }
}

/* ==================== ПРОФИЛЬ И АДМИН ====================  */

/* Профиль */
.profile-page, .admin-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }

.profile-top {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.profile-avatar {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700;
    flex-shrink: 0;
}
.profile-info { flex: 1; }
.profile-info h2 { font-size: 20px; margin-bottom: 4px; }
.profile-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
}
.profile-tag--muted { background: var(--bg); color: var(--text-muted); }

.profile-stats-grid, .admin-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.profile-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    overflow: hidden;
    min-width: 0;
}
.psc-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.15;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}
/* Текстовая оценка ("ОТЛИЧНО (5)" / "НЕУДОВЛЕТВОРИТЕЛЬНО (2)") — мельче чем число */
.psc-value--grade { font-size: 16px; letter-spacing: 0.2px; padding: 6px 4px; }
.psc-label { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.psc-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Progress groups */
.progress-groups { display: flex; flex-direction: column; gap: 12px; }
.pg-group-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.pg-dot { font-size: 14px; }
.pg-name { font-size: 14px; font-weight: 600; flex: 1; }
.pg-count { font-size: 12px; color: var(--text-muted); }

/* Admin tabs */
.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}
.admin-tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.admin-tab:hover { color: var(--primary); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.admin-role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-secondary);
}
.admin-role-badge--teacher { background: #FEF3C7; color: #92400E; }

/* Модалки */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

@media (max-width: 768px) {
    .profile-top { flex-direction: column; text-align: center; }
    .profile-meta { justify-content: center; }
    .admin-tabs { overflow-x: auto; }
}

/* ==================== СХЕМА: ЗУМИРОВАНИЕ И ПАНОРАМА ==================== */
.schema-container {
    overflow: hidden;
    position: relative;
    cursor: crosshair;
}
#schemaCanvas {
    transition: none;
    will-change: transform;
}
.schema-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    gap: 8px;
}
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.zoom-btn {
    width: 30px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}
.zoom-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}
.zoom-btn:active {
    transform: scale(0.95);
}
.zoom-level {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}
@media (max-width: 768px) {
    .schema-toolbar { flex-direction: column; gap: 4px; }
    .zoom-controls { align-self: flex-end; }
}

/* ==================== ЭКРАН СТАРТА ТЕСТА ==================== */
.test-start-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 50000;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.test-start-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.test-start-icon { font-size: 56px; margin-bottom: 12px; }
.test-start-card h2 { font-size: 24px; margin-bottom: 4px; }
.test-start-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.test-start-rules {
    text-align: left;
    background: var(--bg);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 24px;
}
.test-start-rules h3 { font-size: 14px; margin-bottom: 10px; color: var(--text); }
.test-start-rules ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.test-start-rules li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}
.test-start-rules li::before {
    content: '\2022';
    position: absolute;
    left: 6px;
    color: var(--danger);
    font-weight: 700;
}
.test-start-btn {
    font-size: 18px;
    padding: 14px 32px;
}
.test-start-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
}

/* 152-FZ Consent checkbox */
.consent-group {
    margin-top: 12px;
    margin-bottom: 16px;
}
.consent-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    line-height: 1.45;
}
.consent-label input[type='checkbox'] {
    margin-top: 3px;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--success, #2EAF6A);
}
.consent-label a {
    color: var(--primary, #4F6BED);
    text-decoration: underline;
}
.consent-label a:hover {
    text-decoration: none;
}

/* Forgot password */
.form-link--muted {
    color: var(--text-muted, #94a3b8) !important;
    font-size: 13px;
}
.form-link--muted:hover {
    color: var(--primary, #4F6BED) !important;
}
.forgot-info {
    margin-top: 20px;
    padding: 12px 16px;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary, #64748b);
    line-height: 1.5;
}
.forgot-info p { margin: 0; }


/* ==================== ERROR PAGES ==================== */
.error-page {
    min-height: calc(100vh - 52px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}
.error-code {
    font-size: 96px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 8px;
    opacity: 0.3;
}
.error-page h2 {
    font-size: 24px;
    margin-bottom: 8px;
}
.error-page p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ==================== TEST RESULT DETAILS ==================== */
.details-title {
    font-size: 16px;
    margin: 20px 0 12px;
    text-align: left;
}
.result-detail-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-align: left;
}
.result-detail-card--ok {
    background: #f0fdf4;
    border-color: #bbf7d0;
}
.result-detail-card--err {
    background: #fef2f2;
    border-color: #fecaca;
}
.rdc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.rdc-dot { font-size: 12px; }
.rdc-group {
    font-size: 12px;
    color: var(--text-muted);
}
.rdc-status { margin-left: auto; font-size: 13px; }
.rdc-body {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.06);
}
.rdc-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
}
.rdc-label {
    flex-shrink: 0;
    width: 110px;
    color: var(--text-secondary);
    font-weight: 600;
}
.rdc-nums {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.rdc-empty {
    color: var(--text-muted);
    font-style: italic;
}
.num-ok {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #d1fae5;
    color: #065f46;
}
.num-extra {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #fecaca;
    color: #991b1b;
    text-decoration: line-through;
}
.num-missing {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #f59e0b;
}
.rdc-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==================== STATS DASHBOARD ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}
.stats-chart-card canvas {
    width: 100% !important;
}
@media (max-width: 900px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ==================== MOBILE FIX ==================== */
@media (max-width: 900px) {
    .task-body {
        flex-direction: column;
        overflow-y: auto;
    }
    .task-left {
        width: 100%;
        min-width: 0;
        order: 2;
    }
    .task-right {
        order: 1;
        min-height: 300px;
    }
    .task-page {
        height: auto;
        min-height: calc(100vh - 52px);
    }

    .menu-cards {
        grid-template-columns: 1fr;
    }
    .menu-stats {
        flex-wrap: wrap;
        gap: 16px;
        padding: 16px;
    }
    .result-card {
        padding: 24px 16px;
    }
    .result-stats {
        flex-wrap: wrap;
        gap: 16px;
    }
    .grade-badge {
        font-size: 14px;
        padding: 10px 16px;
        letter-spacing: 0.2px;
    }
    .rdc-row {
        flex-direction: column;
        gap: 4px;
    }
    .rdc-label {
        width: auto;
    }
    .variant-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .navbar {
        padding: 0 12px;
    }
    .nav-right {
        gap: 10px;
    }
    .nav-user {
        display: none;
    }
}

@media (max-width: 480px) {
    .task-left { padding: 0; }
    .card { padding: 14px; }
    .login-card { padding: 24px 20px; }
    .answer-buttons { flex-direction: column; }
}

/* ==================== MOBILE — комплексные улучшения ==================== */
/* Тап-таргеты: минимум 44px высоты для всех кнопок и ссылок-кнопок (Apple/Google guideline) */
@media (max-width: 900px) {
    .btn { min-height: 44px; padding: 12px 16px; font-size: 14px; }
    .nav-link { padding: 10px 8px; min-height: 40px; display: inline-flex; align-items: center; }
    .zoom-btn { min-width: 40px; min-height: 40px; }

    /* Заголовок меню — адаптивный */
    .menu-header { padding: 18px 0 14px; }
    .menu-header h1 { font-size: 20px; line-height: 1.3; }
    .menu-header p { font-size: 13px; }
    .menu-page { padding: 12px; }

    /* Карточки меню — компактнее */
    .menu-card { padding: 16px; }
    .menu-cards { gap: 12px; }
    .stat-num { font-size: 22px; }

    /* Таблицы — горизонтальный скролл, чтобы не ломать вёрстку */
    .results-table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .results-table, table.data-table { min-width: 480px; }

    /* Заголовок теста: title + dots + timer в две строки */
    .task-header { padding: 8px 12px; flex-wrap: wrap; gap: 6px; }
    .task-header-left { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; }
    .task-header-right { flex: 0 0 auto; margin-left: auto; }
    .header-title { font-size: 12px; }
    .test-progress-dots { margin-left: 0; }
    .dot { width: 24px; height: 4px; }
    .timer { font-size: 18px; }

    /* Условие задания — без жёстких полей */
    .params-box { font-size: 12px; padding: 10px; line-height: 1.6; }
    .condition-text { font-size: 13px; padding: 10px; }

    /* Стартовый экран теста */
    .test-start-card { padding: 24px 18px; max-width: 95vw; }
    .test-start-rules ul { padding-left: 18px; }
    .test-start-rules li { font-size: 13px; }

    /* Баннер нарушений — компактнее */
    .violation-content { flex-wrap: wrap; padding: 10px 14px; gap: 8px; }
    .violation-title { font-size: 13px; }
    .violation-message { font-size: 12px; flex: 1 1 100%; order: 3; }

    /* Профиль/админка — карточки в одну колонку */
    .profile-grid, .admin-grid { grid-template-columns: 1fr !important; }

    /* Формы — нормальный размер инпутов */
    .form-input { font-size: 16px; }  /* iOS не зумит при 16px+ */

    /* Schema toolbar */
    .schema-toolbar { flex-wrap: wrap; gap: 8px; }
}

/* Очень узкие экраны — телефоны 360-380px */
@media (max-width: 380px) {
    .menu-cards { grid-template-columns: 1fr; }
    .menu-stats { gap: 12px; padding: 12px; }
    .nav-logo { font-size: 14px; }
    .nav-link { font-size: 12px; padding: 8px 6px; }
    .menu-header h1 { font-size: 18px; }
    .timer { font-size: 16px; }
    .test-progress-dots { gap: 3px; }
    .dot { width: 18px; }
    .test-start-card h2 { font-size: 18px; }
    .login-title { font-size: 18px; }
}

/* Альбомная ориентация на телефоне (низкая высота) */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar { padding: 4px 12px; }
    .menu-header { padding: 8px 0; }
    .menu-header h1 { font-size: 16px; }
    .menu-header p { display: none; }
    .test-start-card { padding: 16px; max-height: 90vh; overflow-y: auto; }
    .test-start-rules { font-size: 12px; }
}

/* Touch-friendly canvas: курсор crosshair бесполезен, увеличим радиус хита косвенно через подсказку */
@media (pointer: coarse) {
    #schemaCanvas { cursor: pointer; }
    .schema-hint::before { content: 'Тапните на номер. '; font-weight: 600; }
    /* Скрываем зум-контролы: на тач-устройстве пинч-зум */
    .zoom-controls .zoom-btn[onclick*="zoomReset"] { display: none; }
}

/* ==================== BUTTON DISABLED STATE ==================== */
.btn:disabled, .btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}


/* ==================== DARK MODE ==================== */
.dark-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}
.dark-toggle:hover { background: rgba(255,255,255,0.1); }

html.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --primary: #6381F5;
    --primary-hover: #4F6BED;
    --primary-light: #1e2a4a;
    --success: #34D399;
    --success-bg: #064e3b;
    --danger: #F87171;
    --danger-bg: #450a0a;
    --warning: #FBBF24;
    --warning-bg: #451a03;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --header-dark: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}
html.dark body { background: var(--bg); color: var(--text); }
html.dark .form-input { background: #0f172a; border-color: var(--border); color: var(--text); }
html.dark .form-input:focus { background: #1e293b; }
html.dark .login-page { background: #0f172a; }
html.dark .results-table th { background: #0f172a; color: var(--text-secondary); }
html.dark .results-table tr:hover td { background: #0f172a; }
html.dark .params-box { background: #0f172a !important; }
html.dark .condition-text { background: #0f172a; border-color: var(--border); }
html.dark .task-header { background: #0f172a; }
html.dark .task-header--test { background: #450a0a; }
html.dark .navbar { background: #0f172a; border-bottom: 1px solid #1e293b; }
html.dark .variant-card--done { background: #064e3b; border-color: #065f46; }
html.dark .result-detail-card--ok { background: #064e3b; border-color: #065f46; }
html.dark .result-detail-card--err { background: #450a0a; border-color: #7f1d1d; }
html.dark .num-ok { background: #065f46; color: #34d399; }
html.dark .num-extra { background: #7f1d1d; color: #fca5a5; }
html.dark .num-missing { background: #451a03; color: #fbbf24; border-color: #f59e0b; }
html.dark .violations-box { background: #450a0a; border-color: #7f1d1d; }
html.dark .modal-card { background: #1e293b; }
html.dark .forgot-info { background: #0f172a; }
html.dark .test-start-screen { background: linear-gradient(135deg, #0f172a 0%, #020617 100%); }
html.dark .test-start-rules { background: #0f172a; }

/* ==================== MONITOR ==================== */
.monitor-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }
.monitor-live {
    color: #34d399;
    font-size: 13px;
    font-weight: 600;
    animation: livePulse 2s ease infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.monitor-count {
    text-align: center;
    padding: 20px;
    margin-bottom: 16px;
}
.mc-num {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    display: block;
}
.mc-label {
    font-size: 14px;
    color: var(--text-secondary);
}
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.monitor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.3s;
}
.monitor-card--warn { border-color: var(--warning); background: var(--warning-bg); }
.monitor-card--urgent { border-color: var(--danger); background: var(--danger-bg); animation: urgentPulse 1s ease infinite; }
.monitor-card--violation { box-shadow: 0 0 0 2px var(--danger); }
@keyframes urgentPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}
.mc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.mc-group { font-size: 12px; color: var(--text-muted); }
.mc-timer {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Consolas', monospace;
    color: var(--text);
    margin-bottom: 6px;
}
.mc-progress { margin-bottom: 8px; }
.mc-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}
.mc-violations { color: var(--danger); font-weight: 600; }
.mc-clean { color: var(--success); }

/* ==================== LEADERBOARD ==================== */
.leaderboard-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }
.lb-table .lb-me td { background: var(--primary-light) !important; }
.lb-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-muted);
}
.lb-rank--top { font-size: 20px; }
.lb-score {
    color: var(--primary);
    font-size: 16px;
}
.my-achievements { margin-bottom: 16px; }
.my-achievements h3 { margin-bottom: 12px; }
.ach-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.ach-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 2px solid;
    border-radius: 10px;
    background: var(--surface);
}
.ach-icon { font-size: 28px; }
.ach-text { display: flex; flex-direction: column; }
.ach-text strong { font-size: 13px; }
.ach-text span { font-size: 11px; color: var(--text-muted); }
.ach-mini-row { display: flex; gap: 2px; }
.ach-mini {
    font-size: 16px;
    cursor: help;
}

/* ==================== CONSTRUCTOR ==================== */
.constructor-page { max-width: 1200px; margin: 0 auto; padding: 0 20px 20px; }
.constr-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
}
@media (max-width: 900px) {
    .constr-layout { grid-template-columns: 1fr; }
}
.constr-group { margin-bottom: 14px; }
.constr-group-header { margin-bottom: 6px; }
.constr-group-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}
.constr-group-check input { accent-color: var(--primary); }
.constr-dot { font-size: 14px; }
.constr-variant-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-left: 28px;
}
.constr-v-check {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.1s;
}
.constr-v-check:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.constr-v-check input { accent-color: var(--primary); width: 14px; height: 14px; }
.constr-settings { position: sticky; top: 72px; }

/* ==================== TIMER ALERTS ==================== */
.timer--warn {
    color: #FBBF24 !important;
    text-shadow: 0 0 10px rgba(251,191,36,0.5);
}
.timer--critical {
    color: #FF4444 !important;
    text-shadow: 0 0 15px rgba(255,68,68,0.7);
    animation: timerPulse 0.5s ease infinite;
}

/* ==================== PRACTICE BADGE ==================== */
.practice-badge {
    background: var(--warning);
    color: #000;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    margin-right: 10px;
    letter-spacing: 0.5px;
}
.practice-result {
    display: flex;
    justify-content: center;
    padding: 20px;
}
