/* Тест по регламенту оценок. Без сборки и внешних шрифтов: CSP пускает только свой адрес. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6576;
  --line: #dfe2e8;
  --accent: #d2112a;
  --accent-dark: #a80c20;
  --accent-soft: #fdecee;
  --ok: #18794e;
  --ok-soft: #e6f4ec;
  --bad: #b42318;
  --bad-soft: #fdeceb;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --info-soft: #eaf1fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1, h2 { line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
p { margin: 0 0 12px; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 20px; padding-bottom: 48px; }
.muted { color: var(--muted); }
.link { color: var(--accent-dark); }

/* ---------- шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; }
.brand__mark {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__sub { font-size: 13px; color: var(--muted); }

/* ---------- карточки и блоки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }
.lead { font-size: 17px; }

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 16px 0 0;
  background: var(--bg);
  border: 1px solid var(--line);
}
.notice--info { background: var(--info-soft); border-color: #c8d9f2; }
.notice--warn { background: var(--warn-soft); border-color: #f0d58a; }
.notice--bad { background: var(--bad-soft); border-color: #f3c4c0; color: var(--bad); margin: 0 0 16px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--bad { background: var(--bad-soft); color: var(--bad); }

.rules { padding-left: 20px; margin: 0; }
.rules li { margin-bottom: 8px; }
.rules ul { padding-left: 18px; margin-top: 4px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--secondary { background: var(--accent-soft); color: var(--accent-dark); border-color: #f5c6cc; }
.btn--secondary:hover { background: #fadadf; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--bg); }
.btn--lg { min-height: 50px; padding: 12px 24px; font-size: 17px; }
.btn:focus-visible, .input:focus-visible, .qnav__btn:focus-visible { outline: 3px solid #f7a8b2; outline-offset: 2px; }

/* ---------- форма ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; }
.field__label { font-weight: 600; padding: 0; margin-bottom: 4px; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c9ced8;
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
.input:focus { border-color: var(--accent); }
.choice, .option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  margin-bottom: 8px;
}
.choice:hover, .option:hover { border-color: #b9bfcb; }
.choice input, .option input { margin: 3px 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.choice:has(input:checked), .option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice__body { display: flex; flex-direction: column; }
.choice__title { font-weight: 600; }
.choice__hint { font-size: 14px; color: var(--muted); }

/* ---------- тест ---------- */
.timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
  padding: 4px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.timer__label { font-size: 12px; color: var(--muted); }
.timer__value { font-size: 20px; font-weight: 700; }
.timer.is-warn { background: var(--warn-soft); color: var(--warn); }
.timer.is-danger { background: var(--bad-soft); color: var(--bad); }

.quiz-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.quiz-title { font-size: 22px; margin-bottom: 2px; }
.quiz-head .muted { margin: 0; }
.progress { color: var(--muted); }
.save-status { display: block; font-size: 13px; min-height: 18px; text-align: right; }
.save-status.is-ok { color: var(--ok); }
.save-status.is-bad { color: var(--bad); }

.qnav { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-bottom: 16px; }
.qnav__btn {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.qnav__btn.is-answered { background: var(--ok-soft); border-color: #a9d8bf; color: var(--ok); font-weight: 600; }
.qnav__btn.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.question { border: 1px solid var(--line); margin: 0 0 16px; min-width: 0; }
.question__num { float: left; width: 100%; padding: 0; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.question__text { clear: both; font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.question__nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.options { display: flex; flex-direction: column; }

/* С JS на экране один вопрос; без JS видны все сразу */
.js .question { display: none; }
.js .question.is-current { display: block; }

.finish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}
.finish-bar .muted { margin: 0; }

.dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(16, 24, 40, 0.25); }
.dialog::backdrop { background: rgba(16, 24, 40, 0.45); }
.dialog__body { padding: 24px; }

/* ---------- результат ---------- */
.result { text-align: center; }
.result__score { display: flex; justify-content: center; align-items: baseline; gap: 8px; }
.result__big { font-size: 64px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.result__of { font-size: 22px; color: var(--muted); }
.result__verdict { font-size: 22px; font-weight: 700; margin: 8px 0; }
.result--ok .result__verdict, .result--ok .result__big { color: var(--ok); }
.result--bad .result__verdict, .result--bad .result__big { color: var(--bad); }
.result .actions { justify-content: center; }
.result .notice { text-align: left; }

.review { padding-left: 22px; margin: 0; }
.review__item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.review__item:last-child { border-bottom: 0; }
.review__section { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.review__q { font-weight: 600; }
.review__answers { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 10px; }
.review__answers dt { color: var(--muted); }
.review__answers dd { margin: 0; }
.review__answers .is-wrong { color: var(--bad); }
.review__answers .is-right { color: var(--ok); font-weight: 600; }
.review__expl { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 0; }

/* ---------- админка ---------- */
.page-admin .wrap { max-width: 1180px; }
.topbar__logout { margin: 0; }
.btn--sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn--danger { color: var(--bad); border-color: #f3c4c0; }
.btn--danger:hover { background: var(--bad-soft); }
.btn--danger-solid { background: var(--bad); }
.btn--danger-solid:hover { background: #8f1c13; }
.notice--ok { background: var(--ok-soft); border-color: #a9d8bf; color: var(--ok); margin: 0 0 16px; }
.tag--info { background: var(--info-soft); color: #1f4f8f; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 14px; }
h3 { font-size: 16px; margin: 18px 0 8px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs__item {
  padding: 10px 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--accent-dark); border-bottom-color: var(--accent); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.summary { margin: 0 0 12px; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; padding: 16px; }
.filters__field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.filters__field .input { min-height: 40px; padding: 7px 10px; font-size: 15px; }
.filters__check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14px; }
.filters__check input { width: 18px; height: 18px; accent-color: var(--accent); }
.filters__actions { display: flex; gap: 8px; }
.filters__actions .btn { min-height: 40px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--card); }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--bg); }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-admin .table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.page-admin .card .table-wrap { border: 0; border-radius: 0; }
.row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 16px 0; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.review--admin .review__item.is-ok .review__q { color: var(--muted); font-weight: 500; }
.review--admin .review__item.is-bad { border-left: 3px solid var(--bad); padding-left: 12px; }

.bar-col { min-width: 180px; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar__meter { flex: 1; height: 12px; min-width: 80px; }
.bar__value { width: 42px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.card--bad { border-color: #f3c4c0; background: var(--bad-soft); }
.card--ok { border-color: #a9d8bf; background: var(--ok-soft); }
.card--warn { border-color: #f0d58a; background: var(--warn-soft); }
.issues { margin: 8px 0 0; padding-left: 20px; }
.issues li { margin-bottom: 4px; }

.upload { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.upload .input { flex: 1; min-width: 220px; padding: 9px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field__hint { font-size: 13px; color: var(--muted); }
.field__error { font-size: 14px; color: var(--bad); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

/* ---------- телефон ---------- */
@media (max-width: 560px) {
  .card { padding: 18px 16px; }
  h1 { font-size: 22px; }
  .brand__sub { display: none; }
  .brand__title { font-size: 15px; }
  .question__text { font-size: 17px; }
  .finish-bar .btn, .narrow .actions .btn--primary { width: 100%; }
  .review__answers { grid-template-columns: 1fr; }
  .review__answers dd { margin-bottom: 6px; }
  .qnav { grid-template-columns: repeat(8, 1fr); }
  .qnav__btn { height: 36px; }
  .form-row { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: 6px; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters__actions { grid-column: 1 / -1; }
  .tabs__item { padding: 8px 10px; }
}
