* { box-sizing: border-box; }

/* Атрибут hidden должен скрывать элемент, даже если у класса задан display. */
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1f2328;
    background: #f6f7f9;
}

a { color: #0b5cad; }

.site-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 24px;
    background: #1d3557;
    color: #fff;
}
.site-header a { color: #fff; text-decoration: none; }
.site-header nav { display: flex; gap: 16px; }
.brand { font-weight: 600; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-box form { margin: 0; }

main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
main.narrow { max-width: 380px; margin-top: 80px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

input, select, textarea {
    font: inherit;
    padding: 7px 9px;
    border: 1px solid #c4c9d0;
    border-radius: 4px;
    background: #fff;
}

button {
    font: inherit;
    padding: 8px 16px;
    border: 0;
    border-radius: 4px;
    background: #1d3557;
    color: #fff;
    cursor: pointer;
}
button:hover { background: #274b7a; }

.link-button {
    padding: 0;
    background: none;
    color: inherit;
    text-decoration: underline;
}
.link-button:hover { background: none; }

.alert { padding: 10px 12px; border-radius: 4px; }
.alert-error { background: #fde8e8; color: #8a1c1c; }
.alert-info { background: #e7f0fb; color: #1d3557; }

h1 { margin: 0 0 16px; font-size: 26px; }
h2 { font-size: 20px; margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }

.button {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    background: #1d3557;
    color: #fff;
    text-decoration: none;
}
.button:hover { background: #274b7a; }
.danger-button { background: #b42318; }
.danger-button:hover { background: #8f1c13; }
.danger { color: #b42318; }

.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.form-row .grow { flex: 1 1 260px; }
.actions { display: flex; gap: 12px; align-items: center; }
.actions form { margin: 0; }
.field-error { color: #b42318; font-weight: 400; font-size: 14px; }
.field-error:empty { display: none; }
.hint { color: #59636e; font-size: 14px; font-weight: 400; }
textarea { resize: vertical; }

.md-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .md-editor { grid-template-columns: 1fr; } }
.preview-box { min-height: 120px; padding: 10px 14px; border: 1px dashed #c4c9d0; border-radius: 4px; background: #fff; }

.panel { margin-top: 28px; padding: 16px 20px; background: #fff; border: 1px solid #dfe3e8; border-radius: 6px; }
.upload { display: flex; gap: 10px; align-items: flex-end; padding: 10px; border: 1px solid #eceff2; border-radius: 4px; }
.upload label { display: flex; flex-direction: column; gap: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 12px 0 18px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.filters input[type=number] { width: 90px; }

.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid #e6e9ed; text-align: left; vertical-align: top; }
.table th { font-size: 14px; color: #59636e; font-weight: 600; }
.table tr.muted td { color: #8b949e; }
.table td form { margin: 0; }
.badge { display: inline-block; padding: 0 6px; margin-left: 6px; border-radius: 8px; background: #eceff2; color: #59636e; font-size: 12px; }

.markdown img { max-width: 100%; }
.markdown table { border-collapse: collapse; margin: 8px 0; }
.markdown th, .markdown td { border: 1px solid #c4c9d0; padding: 4px 8px; }
.markdown pre { background: #f3f4f6; padding: 10px; overflow-x: auto; }

/* Задание глазами ученика */
.student-frame { background: #fff; border: 1px solid #dfe3e8; border-radius: 6px; padding: 20px 24px; }
.task-header { font-weight: 600; font-size: 18px; margin-bottom: 12px; }
.task-files ul { margin: 4px 0 0; }
.answer { margin-top: 20px; }
.answer-single { width: 260px; }
.answer-grid { border-collapse: collapse; }
.answer-grid td { border: 1px solid #c4c9d0; padding: 0; }
.answer-grid input { border: 0; width: 110px; border-radius: 0; }
.answer-grid.readonly td { padding: 4px 10px; }
.teacher-only { border-color: #f0c36d; background: #fffaf0; }

.spaced { margin-top: 24px; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.checkbox-list label { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 400; }
.invite-link input { width: 100%; margin-top: 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { padding: 16px 20px; background: #fff; border: 1px solid #dfe3e8; border-radius: 6px; }
.card h2 { margin-bottom: 4px; }
.card p { margin: 6px 0; }

.status { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 13px; background: #eceff2; color: #59636e; }
.status-in_progress { background: #fff3cd; color: #7a5b00; }
.status-paused { background: #e3ecf7; color: #2f4a68; }
.status-finished { background: #dcefe0; color: #1e6b31; }
.status-expired, .status-overdue { background: #fde8e8; color: #8a1c1c; }

.facts { margin: 0; padding-left: 20px; }
.facts li { margin: 2px 0; }
.table tr.row-correct > td:first-child { box-shadow: inset 4px 0 #4f9a5d; }
.table tr.row-wrong > td:first-child { box-shadow: inset 4px 0 #c62828; }
.result-task.row-correct { border-left: 4px solid #4f9a5d; }
.result-task.row-wrong { border-left: 4px solid #c62828; }
.result-task details { margin: 8px 0; }
.score-line { font-size: 18px; }

label.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.form label.checkbox { flex-direction: row; }
.paste-status.error { color: #b42318; }
textarea.drop-target { outline: 2px dashed #0b5cad; }

/* ===== Дашборд ученика ===== */
.dashboard h2 { margin-top: 24px; font-size: 18px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid #eceff2;
    border-radius: 6px; background: #fafbfc; }
.stat-label { font-size: 13px; color: #5c6670; }
.stat-value { font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 13px; color: #5c6670; }

/* Карта активности: недели — столбцы, дни — строки (пн сверху). Прокручивается внутри, а не вся страница. */
.heatmap-scroll { overflow-x: auto; padding-bottom: 4px; }
.heatmap { display: flex; gap: 3px; width: max-content; }
.hm-weekdays, .hm-week { display: grid; grid-template-rows: 16px repeat(7, 11px); gap: 3px; }
.hm-weekdays span { font-size: 10px; line-height: 11px; color: #5c6670; padding-right: 4px; }
.hm-month { font-size: 10px; line-height: 16px; color: #5c6670; white-space: nowrap; width: 11px; overflow: visible; }
.hm-day { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.hm-out { visibility: hidden; }
.hm-l0 { background: #ebedf0; }
.hm-l1 { background: #9be9a8; }
.hm-l2 { background: #40c463; }
.hm-l3 { background: #30a14e; }
.hm-l4 { background: #216e39; }
.hm-legend { display: flex; align-items: center; gap: 3px; margin-top: 6px; font-size: 12px; color: #5c6670; }
.hm-legend .hm-day { margin: 0 1px; }

.by-number .accuracy { display: flex; align-items: center; gap: 8px; }
.by-number meter { width: 140px; height: 12px; }
.by-number td:nth-child(2), .by-number td:nth-child(3) { font-variant-numeric: tabular-nums; }
.card h3 { margin: 0 0 4px; font-size: 18px; }
