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

:root {
    --bg:            #f8fafc;
    --surface:       #ffffff;
    --surface-2:     #f1f5f9;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;
    --text:          #0f172a;
    --text-muted:    #64748b;

    --primary:       #1e3a5f;
    --primary-hover: #152c48;
    --accent:        #3b82f6;
    --accent-hover:  #2563eb;
    --accent-light:  #dbeafe;

    --success:       #10b981;
    --success-light: #d1fae5;
    --danger:        #ef4444;
    --danger-light:  #fee2e2;
    --warning:       #f59e0b;

    --dark:          #0f172a;
    --dark-2:        #1e293b;

    --sidebar-width: 260px;

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --shadow:    0 4px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 20px 50px rgba(15,23,42,.15);

    --transition: all .2s cubic-bezier(.4,0,.2,1);
}

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

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

code, pre, textarea {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
}

/* ============================================================
   HOME
   ============================================================ */
body.home {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8c 50%, #3b82f6 100%);
    color: #fff; position: relative; overflow: hidden;
}
body.home::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(59,130,246,.4) 0%, transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(30,58,95,.6) 0%, transparent 50%);
    pointer-events: none;
}
.home .center {
    text-align: center; position: relative; z-index: 1; padding: 40px;
    animation: fadeUp .8s ease-out;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.home .home-logo {
    height: 100px; width: auto; max-width: 100%; margin: 0 auto 32px; display: block;
    filter: brightness(0) invert(1); object-fit: contain;
}
.home h1 {
    font-size: clamp(40px, 7vw, 72px); font-weight: 800;
    letter-spacing: -.03em; margin-bottom: 16px; line-height: 1;
}
.home .subtitle { font-size: 18px; color: #cbd5e1; margin-bottom: 40px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-big {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 16px 40px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius);
    font-size: 17px; font-weight: 600; cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 8px 24px rgba(59,130,246,.35);
    font-family: inherit;
}
.btn-big:hover {
    background: var(--accent-hover); transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(59,130,246,.45);
    color: #fff; text-decoration: none;
}
.btn-big:active { transform: translateY(0); }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: var(--transition); font-family: inherit;
}
.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; transform: translateY(-1px); }

.btn-sm {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 6px 10px; background: var(--accent); color: #fff;
    border: none; border-radius: 6px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: var(--transition); text-decoration: none;
    font-family: inherit; min-width: 32px;
}
.btn-sm:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-sm.danger { background: var(--danger); }
.btn-sm.danger:hover { background: #dc2626; }

.btn-primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 4px 14px rgba(59,130,246,.3);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }

/* ============================================================
   AUTH (ЛОГИН)
   ============================================================ */
body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8c 50%, #3b82f6 100%);
    padding: 20px;
    overflow: hidden;
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: fadeUp .6s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.auth-logo-wrap {
    width: 100%;
    height: 72px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px auto;
    overflow: hidden;
    padding: 0 12px;
}

.auth-logo {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.auth-title {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.auth-card label {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-card input[type=text],
.auth-card input[type=password] {
    width: 100%;
    padding: 12px 14px;
    margin-top: 6px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: var(--transition);
    box-sizing: border-box;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.auth-card .btn-big {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.auth-card > p {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
}

/* ============================================================
   CARD (общий)
   ============================================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 420px;
}
.card h2, .card h3 {
    margin-top: 0; margin-bottom: 20px; color: var(--text);
    font-weight: 700; letter-spacing: -.02em;
}
.card h2 { font-size: 24px; }
.card h3 { font-size: 18px; }
.card label { display: block; margin-bottom: 16px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.card input[type=text], .card input[type=password],
.card input[type=number], .card input[type=email] {
    width: 100%; padding: 12px 14px; margin-top: 6px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit; color: var(--text);
    background: #fff; transition: var(--transition);
}
.card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }
.card .btn-big { width: 100%; justify-content: center; margin-top: 8px; }
.card > p { margin-top: 16px; text-align: center; font-size: 14px; }

/* ============================================================
   ALERTS
   ============================================================ */
.error, .info {
    padding: 14px 18px; border-radius: var(--radius-sm);
    margin-bottom: 18px; font-size: 14px; font-weight: 500;
    border-left: 4px solid;
}
.error { background: var(--danger-light); color: #991b1b; border-color: var(--danger); }
.info { background: var(--success-light); color: #065f46; border-color: var(--success); margin: 16px 0; }

/* ============================================================
   SIDEBAR LAYOUT
   ============================================================ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width); background: var(--primary); color: #fff;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-logo {
    padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; justify-content: center;
}
.sidebar-logo img {
    height: 44px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.sidebar-user { padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-user-name { font-weight: 600; font-size: 14px; color: #fff; margin-bottom: 4px; line-height: 1.3; word-break: break-word; }
.sidebar-user-role { font-size: 12px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .05em; }
.sidebar-nav { flex: 1; padding: 16px 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: rgba(255,255,255,.8);
    font-size: 14px; font-weight: 500; transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(59,130,246,.2); color: #fff; border-left-color: var(--accent); }

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-bottom { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-bottom a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; color: rgba(255,255,255,.7); font-size: 13px;
}
.sidebar-bottom a:hover { color: #fff; text-decoration: none; }

.main-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; }

.page-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}
.page-header-actions { display: flex; gap: 12px; align-items: center; }

.container { max-width: 1400px; margin: 0 auto; padding: 32px; }
.container > h2 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 24px; color: var(--primary); }
.container > h3 { font-size: 20px; font-weight: 700; margin: 24px 0 16px; color: var(--primary); }

.topbar { display: none; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow-sm); transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.action-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.action-card {
    display: flex; align-items: center; gap: 16px;
    padding: 20px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); transition: var(--transition);
    text-decoration: none; color: var(--text);
}
.action-card:hover {
    transform: translateY(-2px); box-shadow: var(--shadow);
    border-color: var(--accent); text-decoration: none; color: var(--text);
}
.action-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--accent-light); color: var(--accent);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.action-icon svg {
    width: 24px; height: 24px; stroke: currentColor; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.action-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; color: var(--text); }
.action-desc { font-size: 13px; color: var(--text-muted); line-height: 1.4; }

/* ============================================================
   TOPICS
   ============================================================ */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.topic-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-sm);
    border: 1px solid var(--border); transition: var(--transition);
    display: flex; flex-direction: column;
}
.topic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.topic-card h3 { margin: 12px 0 16px; font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.3; }
.badge {
    display: inline-block; background: var(--accent-light); color: var(--primary);
    padding: 4px 12px; border-radius: 999px; font-size: 12px;
    font-weight: 600; width: fit-content;
}
.status { margin: 8px 0; font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.status b { color: var(--text); }
.topic-card .btn { margin-top: auto; justify-content: center; width: 100%; margin-top: 16px; }

.ok { color: var(--success); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.partial { color: var(--warning); font-weight: 600; }

/* ============================================================
   THEORY
   ============================================================ */
.theory { max-width: 900px; padding: 28px; line-height: 1.7; }
.theory h3 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; color: var(--primary); }
.theory h3:first-child { margin-top: 0; }
.theory h4 { font-size: 16px; font-weight: 600; margin: 20px 0 10px; color: var(--text); }
.theory p { margin: 12px 0; color: var(--text-muted); }
.theory ul, .theory ol { margin: 12px 0 12px 24px; color: var(--text-muted); }
.theory li { margin: 6px 0; }
.theory code { background: var(--surface-2); color: var(--accent-hover); padding: 2px 6px; border-radius: 4px; font-size: .9em; }
.theory pre {
    background: var(--dark); color: #a5f3fc; padding: 18px 22px;
    border-radius: var(--radius); overflow-x: auto;
    font-size: 14px; line-height: 1.6; margin: 16px 0;
}

/* ============================================================
   PRACTICE
   ============================================================ */
.practice-layout { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
.tasks {
    background: var(--surface); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    position: sticky; top: 90px; max-height: calc(100vh - 120px); overflow-y: auto;
}
.tasks h3 { margin-bottom: 16px; font-size: 18px; }
.tasks .task {
    background: var(--surface-2); padding: 12px 14px;
    border-radius: var(--radius-sm); margin-bottom: 10px;
    border: 1px solid var(--border);
}
.task-head { display: flex; justify-content: space-between; margin-bottom: 4px; font-size: 14px; }
.tasks .task p { font-size: 13px; color: var(--text-muted); }
.hint {
    font-size: 13px; color: var(--text-muted);
    background: #fef3c7; border-left: 3px solid var(--warning);
    padding: 12px 14px; border-radius: var(--radius-sm); margin: 12px 0;
}
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor textarea {
    width: 100%; min-height: 380px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 14px; line-height: 1.6; padding: 18px;
    border-radius: var(--radius); border: 1px solid var(--dark-2);
    background: var(--dark); color: #e2e8f0; resize: vertical;
}
.editor textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(59,130,246,.2);
}
.editor .row { display: flex; gap: 14px; align-items: center; }
.output {
    background: var(--dark); color: #86efac; padding: 18px;
    border-radius: var(--radius); min-height: 100px; overflow: auto;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 13px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}

/* ============================================================
   RESULT
   ============================================================ */
.check-result-box { margin-top: 12px; }
.result-success {
    background: var(--success-light); color: #065f46;
    border-left: 4px solid var(--success);
    padding: 14px 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 15px;
}
.result-error {
    background: var(--danger-light); color: #991b1b;
    border-left: 4px solid var(--danger);
    padding: 14px 18px; border-radius: var(--radius-sm);
    font-size: 14px; line-height: 1.55;
}
.result-error b { display: block; margin-bottom: 8px; }
.result-error ul { margin: 0; padding-left: 22px; }
.result-error li { margin: 4px 0; }
.result-error pre {
    background: #7f1d1d; color: #fecaca; padding: 10px;
    border-radius: 6px; margin-top: 8px; font-size: 12px;
    overflow-x: auto; white-space: pre-wrap;
}

/* ============================================================
   PROGRESS
   ============================================================ */
.progress-wrap {
    margin-bottom: 24px; background: var(--surface);
    padding: 16px 20px; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.progress-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.progress-count { color: var(--text-muted); font-weight: 500; }
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 999px; transition: width .4s ease;
}
.step-nav {
    display: flex; justify-content: space-between; gap: 12px;
    margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* ============================================================
   FINISH
   ============================================================ */
.finish-card { max-width: 600px; margin: 40px auto; text-align: center; padding: 40px 32px; }
.finish-icon {
    font-size: 0; width: 64px; height: 64px; margin: 0 auto 16px;
    border-radius: 50%; background: var(--success-light); position: relative;
}
.finish-icon::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 24px; height: 14px;
    border-left: 3px solid var(--success); border-bottom: 3px solid var(--success);
    transform: translate(-50%, -65%) rotate(-45deg);
}
.finish-card h2 { font-size: 26px; margin-bottom: 12px; color: var(--primary); }
.finish-card p { color: var(--text-muted); margin-bottom: 24px; }
.finish-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters {
    display: flex; gap: 20px; margin-bottom: 24px; align-items: flex-end;
    flex-wrap: wrap; padding: 16px 20px; background: var(--surface);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.filters label { font-size: 13px; font-weight: 600; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }
.filters select, .filters input[type=text] {
    padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: #fff;
    font-family: inherit; font-size: 14px; color: var(--text);
    min-width: 180px; transition: var(--transition);
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }

/* ============================================================
   TABLES
   ============================================================ */
.table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.table th, .table td {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    text-align: left; font-size: 14px; vertical-align: middle;
}
.table th {
    background: var(--primary); color: #fff; font-weight: 600;
    font-size: 12px; text-transform: uppercase;
    letter-spacing: .05em; white-space: nowrap;
}
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td b { color: var(--primary); font-weight: 700; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.grades-table th.mini-head { font-size: 11px; padding: 10px 8px; text-align: center; }
.grade-cell { text-align: center; font-weight: 700; font-size: 15px; }
.grade-cell.g-ok  { color: #065f46; background: #d1fae5; }
.grade-cell.g-mid { color: #d97706; background: #fef3c7; }
.grade-cell.g-bad { color: #991b1b; background: #fee2e2; }
.avg-cell { text-align: center; font-size: 16px; }
.avg-cell.g-ok  { color: #065f46; }
.avg-cell.g-mid { color: #d97706; }
.avg-cell.g-bad { color: #991b1b; }

.stats-summary { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stats-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 20px;
    display: flex; flex-direction: column; gap: 2px; min-width: 120px;
}
.stats-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stats-value { font-size: 22px; font-weight: 800; color: var(--primary); }

/* ============================================================
   PROFILE
   ============================================================ */
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 24px; }
.avatar-wrap { display: flex; justify-content: center; margin-bottom: 16px; }
.avatar-img {
    width: 140px; height: 140px; border-radius: 50%;
    object-fit: cover; border: 4px solid var(--accent-light);
}
.avatar-placeholder {
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--text-muted);
    font-size: 48px; font-weight: 700;
}

/* ============================================================
   ADMIN
   ============================================================ */
.two-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.two-cards .card { max-width: none; }
.edit-card { margin-bottom: 20px; max-width: 640px; border: 2px solid var(--accent); }
.actions { display: flex; gap: 6px; align-items: center; }

/* ============================================================
   CHECKS UI
   ============================================================ */
.checks-block { margin: 16px 0; display: flex; flex-direction: column; gap: 16px; }
.check-section {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
}
.check-section-title { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 10px; }
.check-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.check-row { display: flex; gap: 8px; align-items: center; }
.check-row input {
    flex: 1; padding: 8px 12px; border: 1.5px solid var(--border);
    border-radius: 6px; font-family: 'JetBrains Mono', monospace;
    font-size: 13px; background: #fff;
}
.check-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.chk-eq { color: var(--text-muted); font-weight: 700; font-size: 14px; padding: 0 4px; }
.chk-remove { flex-shrink: 0; font-size: 16px; line-height: 1; min-width: 32px; height: 32px; }
.chk-add {
    background: var(--accent-light); color: var(--accent); font-weight: 600;
    padding: 8px 14px; border: 1px dashed var(--accent); width: 100%; justify-content: center;
}
.chk-add:hover { background: var(--accent); color: #fff; }

/* ============================================================
   BADGE GRADE
   ============================================================ */
.badge-grade {
    background: var(--success-light); color: #065f46;
    padding: 4px 12px; border-radius: 999px;
    font-weight: 700; font-size: 13px; display: inline-block;
}
.badge-grade.badge-fail { background: var(--danger-light); color: #991b1b; }
.attempts-info { font-size: 13px; color: var(--text-muted); font-weight: 600; }

/* ============================================================
   MISC
   ============================================================ */
.container > p { color: var(--text-muted); font-size: 14px; margin: 12px 0; }
.container > p b { color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .practice-layout { grid-template-columns: 1fr; }
    .tasks { position: static; max-height: none; }
    .two-cards { grid-template-columns: 1fr; }
    .container { padding: 20px 16px; }
    .page-header { padding: 16px 20px; }
    .profile-grid { grid-template-columns: 1fr; }
}
/* ============================================================
   CHAT
   ============================================================ */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
}

.chat-empty {
    margin: auto;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.chat-msg {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
    animation: fadeUp .2s ease-out;
}
.chat-msg-mine {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-other {
    align-self: flex-start;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    opacity: .85;
}
.chat-msg-author { font-weight: 700; }
.chat-msg-time {
    font-size: 11px;
    opacity: .7;
    font-weight: 500;
    white-space: nowrap;
}
.chat-msg-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-form {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: var(--transition);
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}
.chat-form .btn {
    padding: 12px 22px;
    font-weight: 600;
    flex-shrink: 0;
}
/* ============================================================
   NAV BADGE
   ============================================================ */
.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ============================================================
   MESSENGER
   ============================================================ */
.messenger {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 160px);
    min-height: 500px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.messenger-side {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow-y: auto;
}

.messenger-search {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.messenger-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-2);
    transition: var(--transition);
}
.messenger-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 4px var(--accent-light);
}

.messenger-section-title {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.dialogs {
    display: flex;
    flex-direction: column;
}
.dialogs-empty {
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

.dialog-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    align-items: center;
}
.dialog-item:hover {
    background: var(--surface-2);
    text-decoration: none;
    color: var(--text);
}
.dialog-item.active {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
    padding-left: 13px;
}

.dialog-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
    text-transform: uppercase;
}

.dialog-info {
    flex: 1;
    min-width: 0;
}
.dialog-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dialog-last {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dialog-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.dialog-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.dialog-badge {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Правая часть — сам чат */
.messenger-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.chat-header-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}
.chat-header-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-empty-select {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    gap: 12px;
    background: var(--bg);
}
.chat-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--surface-2);
    position: relative;
}
.chat-empty-icon::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 28px; height: 20px;
    border: 3px solid var(--text-muted);
    border-radius: 8px;
    transform: translate(-50%, -50%);
    border-bottom-right-radius: 0;
}

.chat-empty {
    margin: auto;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.chat-msg {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    word-wrap: break-word;
    animation: fadeUp .2s ease-out;
}
.chat-msg-mine {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-other {
    align-self: flex-start;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-msg-time {
    font-size: 11px;
    opacity: .7;
    margin-top: 4px;
    text-align: right;
}
.chat-msg-mine .chat-msg-time { color: rgba(255,255,255,.8); }
.chat-msg-other .chat-msg-time { color: var(--text-muted); }

.chat-form {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    align-items: flex-end;
}
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    resize: none;
    max-height: 120px;
    min-height: 44px;
    transition: var(--transition);
}
.chat-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}
.chat-form .btn {
    padding: 12px 22px;
    font-weight: 600;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .messenger { grid-template-columns: 1fr; height: auto; }
    .messenger-side { max-height: 300px; border-right: none; border-bottom: 1px solid var(--border); }
}
/* ============================================================
   STUDENT GRADES
   ============================================================ */
.overall-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.overall-label {
    font-size: 15px;
    font-weight: 500;
    opacity: .9;
}
.overall-value {
    font-size: 42px;
    font-weight: 800;
    line-height: 1;

}

.grade-topics {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.grade-topic-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.grade-topic-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--accent);
}
.grade-topic-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}
.grade-topic-head h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 8px 0 0 0;
}
.grade-topic-avg {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    min-width: 60px;
    text-align: right;
}
.grade-empty { color: var(--text-muted); }

.grade-excellent { color: #10b981; }
.grade-good     { color: #3b82f6; }
.grade-bad      { color: #ef4444; }

.grade-topic-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-muted);
}
.grade-meta-item b { color: var(--text); }

.grade-mini-table {
    margin-top: 12px;
}
.grade-mini-table .final-row {
    background: #fef3c7;
}
.grade-mini-table .final-row td {
    border-top: 2px solid var(--warning);
}
/* ============================================================
   STUDENT GRADES
   ============================================================ */
.overall-card {
    background: linear-gradient(135deg, #1e3a5f 0%, #3b82f6 100%);
    color: #ffffff;
    border-radius: var(--radius);
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.overall-label {
    font-size: 15px;
    font-weight: 500;
    color: #ffffff;
    opacity: .95;
}

.overall-value {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    color: #ffffff;
    text-shadow: 0 2px 12px rgba(0,0,0,.35);
    /* перебиваем цвет от .grade-excellent и т.п. */
}

.overall-card .overall-value,
.overall-card .overall-value.grade-excellent,
.overall-card .overall-value.grade-good,
.overall-card .overall-value.grade-bad {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff;
}

.grade-excellent { color: #10b981; }
.grade-good     { color: #3b82f6; }
.grade-bad      { color: #ef4444; }
/* ============================================================
   MODAL — Участники чата
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn .15s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
@keyframes modalIn {
    from { transform: scale(.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}
.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.modal-close:hover {
    background: var(--surface-2);
    color: var(--text);
}

.modal-body {
    padding: 12px 0;
    overflow-y: auto;
    flex: 1;
}

.modal-loading, .modal-empty, .modal-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}
.modal-error { color: var(--danger); }

.members-list {
    display: flex;
    flex-direction: column;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: var(--surface-2); }

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.member-avatar-teacher {
    background: var(--primary);
}

.member-info {
    flex: 1;
    min-width: 0;
}
.member-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
    word-break: break-word;
}
.member-badge {
    background: var(--accent-light);
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: .04em;
}
.member-sub {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* ============================================================
   WIDE FORM
   ============================================================ */
.wide-card {
    max-width: none !important;
    width: 100%;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
    margin-bottom: 8px;
}

.form-grid label {
    margin-bottom: 0;
}

.form-grid input[type=text],
.form-grid select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    margin-top: 6px;
    transition: var(--transition);
}

.form-grid input[type=text]:focus,
.form-grid select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

/* ============================================================
   TOP STUDENTS
   ============================================================ */
.top-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.top-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: var(--transition);
}
.top-row:hover {
    background: var(--accent-light);
    transform: translateX(4px);
}

.top-place {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    background: var(--surface);
    color: var(--text-muted);
    flex-shrink: 0;
    border: 2px solid var(--border);
}
.top-place-1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
    border-color: #f59e0b;
    font-size: 22px;
}
.top-place-2 {
    background: linear-gradient(135deg, #d1d5db, #9ca3af);
    color: #fff;
    border-color: #9ca3af;
    font-size: 22px;
}
.top-place-3 {
    background: linear-gradient(135deg, #f97316, #c2410c);
    color: #fff;
    border-color: #c2410c;
    font-size: 22px;
}

.top-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.top-info {
    flex: 1;
    min-width: 0;
}
.top-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.top-grade {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent);
    padding: 4px 14px;
    background: #fff;
    border-radius: 8px;
    border: 2px solid var(--accent-light);
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
}

.top-place-1 + .top-avatar + .top-info .top-name { color: #b45309; }
.top-place-1 ~ .top-grade { color: #b45309; border-color: #fbbf24; }

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
    .top-row { padding: 10px 12px; gap: 10px; }
    .top-place { width: 36px; height: 36px; font-size: 16px; }
    .top-avatar { width: 34px; height: 34px; font-size: 14px; }
    .top-grade { font-size: 18px; padding: 4px 10px; min-width: 48px; }
}
.group-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-top: 8px;
    padding: 12px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.group-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0 !important;
    font-size: 14px;
    color: var(--text) !important;
    font-weight: 500 !important;
    cursor: pointer;
}
.group-check input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}
/* ============================================================
   CONSOLE — ввод данных
   ============================================================ */
.console-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 12px;
}
.console-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.console-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    resize: vertical;
    min-height: 80px;
    margin-bottom: 10px;
}
.console-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}