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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e5ed;
  --primary: #4361ee;
  --primary-hover: #3451d1;
  --danger: #ef476f;
  --success: #06d6a0;
  --warning: #ffd166;
  --text: #1a1d2e;
  --text-muted: #6b7280;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── Layout ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 { font-size: 17px; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 16px; }

.user-name { color: var(--text-muted); font-size: 14px; }

.main { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ── Buttons ── */
button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  transition: background .15s, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea { min-height: 80px; resize: vertical; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-neutral { background: #f3f4f6; color: #374151; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  background: none;
  border: none;
  border-radius: 0;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Assignment list ── */
.assignment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.assignment-item:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,.07);
}
.assignment-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.assignment-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Task view ── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.task-num {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--primary);
  margin-bottom: 10px;
}
.task-question { font-size: 15px; line-height: 1.6; margin-bottom: 18px; white-space: pre-line; }
.task-options { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.task-option {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
}
.task-answer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.task-answer-row input {
  width: 120px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  text-align: center;
  letter-spacing: 4px;
  outline: none;
}
.task-answer-row input:focus { border-color: var(--primary); }

.task-result {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 7px;
  font-size: 14px;
  line-height: 1.5;
}
.task-result.correct { background: #d1fae5; color: #065f46; }
.task-result.wrong { background: #fee2e2; color: #991b1b; }
.task-result.pending { background: #fef3c7; color: #92400e; }
.task-result .tip { margin-top: 6px; font-size: 13px; opacity: .85; }

/* ── Progress bar ── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .4s;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px 30px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Results view ── */
.result-task {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.result-task.correct { border-left: 3px solid var(--success); }
.result-task.wrong { border-left: 3px solid var(--danger); }
.result-task.pending { border-left: 3px solid var(--warning); }

/* ── Checkboxes in task selector ── */
.task-selector { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.task-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.task-check:hover { background: var(--bg); }
.task-check input[type=checkbox] { margin-top: 2px; flex-shrink: 0; cursor: pointer; }
.task-check-label { font-size: 13px; line-height: 1.4; }
.task-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
}

/* ── Student selector ── */
.student-selector { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.student-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.student-check:hover { background: var(--bg); }
.student-check input { cursor: pointer; }

/* ── Score ── */
.score-big {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin: 8px 0;
}
.score-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }

/* ── Comment ── */
.comment-block {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 8px;
  color: #92400e;
}

/* ── Word-gap tasks ── */
.word-task-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0 4px;
}

.word-gap-wrap {
  display: inline-flex;
  align-items: baseline;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.2;
}

.word-part { color: var(--text); }

.word-gap-select {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  border: none;
  border-bottom: 2px solid var(--primary);
  background: transparent;
  padding: 0 4px;
  outline: none;
  cursor: pointer;
  min-width: 48px;
  text-align: center;
}

.word-gap-input {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  border: none;
  border-bottom: 2px solid var(--primary);
  background: transparent;
  padding: 0 4px;
  outline: none;
}

.word-gap-filled {
  font-size: 28px;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 4px;
}

.word-gap-filled.correct-fill { color: #065f46; background: #d1fae5; }
.word-gap-filled.wrong-fill   { color: #991b1b; background: #fee2e2; }

/* default (during test, already answered) */
.word-gap-filled:not(.correct-fill):not(.wrong-fill) {
  color: var(--primary);
}

.result-word .word-gap-wrap { font-size: 22px; }
.result-word .word-gap-filled { font-size: 22px; }

/* ── Task type selector ── */
.task-type-selector {
  display: flex;
  gap: 10px;
}
.type-radio {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.type-radio:has(input:checked) {
  border-color: var(--primary);
  background: #eef2ff;
}
.type-radio input[type=radio] { display: none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .main { padding: 16px 12px; }
  .card { padding: 16px; }
  .assignment-item { flex-direction: column; align-items: flex-start; }
}

/* ─── Статистика / графики ─────────────────────────────────────────────── */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--text, #111827); }
.stat-label { font-size: 13px; color: var(--text-muted, #6b7280); margin-top: 4px; }
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.chart-box {
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-box canvas { max-height: 300px; }

/* ─── Тренировка ───────────────────────────────────────────────────────────── */
.training-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.training-type-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, transform .1s;
}
.training-type-btn:hover { border-color: var(--primary); transform: translateY(-2px); }
.tt-label { font-weight: 600; font-size: 14px; color: var(--text); }
.tt-count { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.record-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.record-type { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.record-streak { font-size: 24px; font-weight: 700; color: var(--text); margin: 6px 0; }
.record-meta { font-size: 11px; color: var(--text-muted); }

.training-hud {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.hud-item {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.hud-num { font-size: 28px; font-weight: 700; color: var(--text); transition: transform .2s; }
.hud-num.streak-hot { color: #f97316; transform: scale(1.1); }
.hud-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Чип дедлайна ──────────────────────────────────────────────────────────── */
.deadline-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
}
.deadline-normal  { background: #eef2ff; color: #4361ee; }
.deadline-soon    { background: #fff7e6; color: #b45309; }
.deadline-urgent  { background: #ffe9ec; color: #dc2626; }
.deadline-overdue { background: #f3f4f6; color: #6b7280; }

/* ─── Success message ──────────────────────────────────────────────────────── */
.success-msg {
  background: #d1fae5;
  color: #065f46;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
}
