/* RAT v3 — стили портала, страниц теста и эссе */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7487;
  --accent: #3457d5;
  --accent-hover: #2a46b0;
  --danger: #d5344f;
  --ok: #1f9d55;
  --border: #e3e7f0;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(26, 34, 51, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}
.card.wide { max-width: 820px; padding: 24px 28px 28px; }
h1 { font-size: 22px; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input, select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
#join-code {
  letter-spacing: 0.35em;
  font-size: 22px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
button {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .55; cursor: default; }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -3px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner.dark { border-color: rgba(0,0,0,.12); border-top-color: var(--accent); }
/* Восстановление сохранённого входа: форма скрыта, показано ожидание (app.js setResuming_). */
.resume-box { display: none; margin-top: 16px; }
.resume-line { font-weight: 600; margin-bottom: 6px; }
#login-card.resuming .resume-box { display: block; }
#login-card.resuming #auth-form,
#login-card.resuming #login-sub,
#login-card.resuming #login-pin-note { display: none; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  margin-top: 10px;
}
.msg { margin-top: 14px; font-size: 14px; display: none; }
.msg.error { color: var(--danger); display: block; }
.msg.ok { color: var(--ok); display: block; }
.hidden { display: none !important; }
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e9eefc;
  color: var(--accent);
}
.badge.pro { background: #e5f7ec; color: var(--ok); }
.list-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tab-bar {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  margin: 18px 0; overflow-x: auto;
}
.tab-btn {
  background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 10px 14px; margin: 0; width: auto; border-radius: 0; cursor: pointer;
  position: relative; white-space: nowrap;
}
.tab-btn.active { color: var(--accent); }
.tab-btn.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.course-block {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 12px;
}
.course-block h3 { font-size: 15px; margin: 0 0 4px; }
.course-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* Вкладка «Курс» — карточка как в v1: дорожки + таблица */
.course-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 16px 18px;
  margin-top: 8px;
  background: #fff;
}
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.course-title { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.3; }
.course-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #e9eefc;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.test-rows { display: flex; flex-direction: column; gap: 8px; }
.test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f6f8fc;
  border-radius: 10px;
}
.test-label {
  font-size: 12px;
  font-weight: 700;
  min-width: 42px;
  width: auto;
  flex-shrink: 0;
}
.test-label-irat { color: #d97706; }
.test-label-grat { color: #059669; }
.test-label-essay { color: #7c3aed; }
.test-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.status-open { background: #e5f7ec; color: var(--ok); }
.status-closed { background: #eef1f6; color: var(--muted); }
.status-done { background: #e8ecfb; color: var(--accent); white-space: normal; }
.test-session {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-dot.pulse { animation: rat-pulse 1.5s ease-in-out infinite; }
@keyframes rat-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.test-score {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--ok);
}
.test-action {
  width: auto;
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}
.test-action:hover { background: var(--accent-hover); }
.test-action:active { background: var(--accent-hover); }
.card-results {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.card-results-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  border-radius: 8px;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table th {
  padding: 6px 8px;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.results-table td {
  padding: 8px;
  border-bottom: 1px solid #f0f2f7;
  color: var(--text);
}
.results-table tr:last-child td { border-bottom: none; }
.score-val { font-weight: 700; color: #d97706; }
.score-warn { font-weight: 700; color: #d97706; }
.score-total { font-weight: 700; color: var(--accent); }
.score-na { color: var(--muted); }

.grades-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.grades-table th, .grades-table td {
  text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border);
}
.grades-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.essay-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 12px;
}
.essay-card .feedback {
  margin-top: 10px; padding: 10px 12px; background: #f6f8fc; border-radius: 8px;
  white-space: pre-wrap; font-size: 13px; line-height: 1.45;
}
.profile-row { margin-top: 10px; font-size: 14px; }
.profile-row b { display: inline-block; min-width: 110px; color: var(--muted); font-weight: 600; }
.empty-note { color: var(--muted); font-size: 14px; margin-top: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.btn-row button { width: auto; margin-top: 0; padding: 10px 16px; }
.banner {
  background: #fff3cd; color: #856404; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.brand-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: block;
  border-radius: 50%;
}
.brand.compact .brand-logo { width: 36px; height: 36px; }
.brand-name {
  font-size: 1.25em;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}
.brand.compact .brand-name { font-size: 1.05em; }
.brand-slogan {
  font-size: 0.72em;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}
.auth-top, .dash-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.auth-top .brand, .dash-top .brand { margin-bottom: 0; }
.lang-pills {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}
.lang-pill {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  margin: 0;
  width: auto;
  border-radius: 0;
  cursor: pointer;
  letter-spacing: .02em;
}
.lang-pill:hover { color: var(--text); background: #f4f6fb; }
.lang-pill.active { background: var(--accent); color: #fff; }
.lang-pill.active:hover { background: var(--accent-hover); color: #fff; }

.portal-header {
  margin-top: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.portal-id { min-width: 0; flex: 1; }
.portal-header h1 { font-size: 20px; margin: 0; }
.portal-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.course-switch-btn {
  flex: none;
  width: auto;
  max-width: 46%;
  margin: 2px 0 0;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.2;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  white-space: nowrap;
}
.course-switch-btn:hover { background: #eef1fc; color: var(--accent); }
body.course-switch-open { overflow: hidden; }
.course-switch-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}
.course-switch-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 34, 51, 0.48);
}
.course-switch-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  max-height: min(80vh, 560px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(26, 34, 51, 0.22);
  padding: 18px 18px 16px;
}
.course-switch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.course-switch-head h2 { font-size: 18px; margin: 0; }
.course-switch-close {
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  flex: none;
  border-radius: 10px;
  background: #f4f6fb;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}
.course-switch-close:hover { background: #e8ecf5; color: var(--text); }
.course-switch-modal .list-item { margin-top: 8px; }
.course-switch-modal .list-item button { margin-top: 0; }
.course-switch-modal .list-item.is-current {
  border-color: #b7e4c7;
  background: #f3fbf6;
}

.install-title {
  font-size: 22px;
  margin: 18px 0 8px;
  line-height: 1.25;
}
.install-steps {
  margin-top: 8px;
  padding: 14px 16px;
  background: #f6f8fc;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.install-steps ol {
  margin: 0;
  padding-left: 1.2em;
}
.install-steps li { margin: 8px 0; }
.install-steps p { margin: 0; color: var(--muted); }

/* Бенчмарки (вкладка «Результаты», как в v1) */
.analytics-intro { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.analytics-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.analytics-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
}
.analytics-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.mini-note { font-size: 12px; color: var(--muted); margin: 6px 0; }
.hist-selector { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.hist-selector select { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
.hist-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 4px 0;
}
.hist-row > span:first-child { min-width: 54px; color: var(--muted); }
.hist-row > span:last-child { min-width: 60px; text-align: right; }
.hist-track {
  flex: 1; height: 10px; background: #eef1f8; border-radius: 6px; overflow: hidden;
}
.hist-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.trend-table, .team-table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 4px;
}
.trend-table th, .trend-table td, .team-table th, .team-table td {
  text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--border);
}
.trend-table th, .team-table th { color: var(--muted); font-weight: 600; font-size: 11px; }
.my-team-row { background: #eef1fc; font-weight: 600; }

/* Список курсов / переключение (шапка портала) */
.list-item .sub { color: var(--muted); }
.install-note {
  margin-top: 16px !important;
  margin-bottom: 0 !important;
  font-size: 12px !important;
}
.ios-share {
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
}
