:root {
  --bg: #fff;
  --fg: #1f2732;
  --muted: #7a8794;
  --line: #e6eaee;
  --soft: #f6f8fa;
  --accent: #2e7cf6;
  --lvl0: #2fc26e;
  --lvl1: #e9a723;
  --lvl2: #eb5757;
}

* { box-sizing: border-box; }

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

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 10px; }
ul { margin: 0; padding-left: 20px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }

.screen { max-width: 680px; margin: 0 auto; padding: 20px 16px 40px; }
.screen--wide { max-width: 1100px; }
.screen--test { display: flex; flex-direction: column; min-height: 60vh; }

/* ---------------------------------------------------------------- навигация */

.nav {
  display: flex; gap: 4px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.nav button {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit;
}
.nav button.is-active { background: var(--soft); color: var(--fg); font-weight: 600; }

/* ---------------------------------------------------------------- карточки */

.card {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin: 0 0 14px;
  min-width: 0; /* иначе широкая таблица распирает карточку и лезет на соседнюю */
}
.card--soft { background: var(--soft); border-color: transparent; }
.cards {
  display: grid; gap: 14px; margin-bottom: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 720px) { .cards { grid-template-columns: 1fr; } }
.cards .card { margin: 0; }
/* карточка на всю ширину строки — для таблиц, которым тесно в колонке */
.card--wide { grid-column: 1 / -1; }

.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.alert--ok { background: #e9f8ef; color: #12703f; }
.alert--error { background: #fdecec; color: #a52020; }

/* ---------------------------------------------------------------- кнопки */

.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.actions--between { justify-content: space-between; }

.btn {
  font: inherit; cursor: pointer; border-radius: 8px;
  padding: 10px 18px; border: 1px solid var(--line); background: #fff; color: var(--fg);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--answer { flex: 1; padding: 18px; font-size: 17px; font-weight: 600; }
.btn--answer.is-selected { border-color: var(--accent); color: var(--accent); background: #f2f7ff; }

.consent { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-size: 14px; }
.consent input { margin-top: 3px; }

/* ---------------------------------------------------------------- тест */

.progress { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.progress__bar { flex: 1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.progress__fill { height: 100%; background: var(--accent); transition: width .2s; }
.progress__label { color: var(--muted); font-size: 13px; white-space: nowrap; }

.question { font-size: 19px; line-height: 1.45; flex: 1; padding: 8px 0 28px; }
.question__num { color: var(--muted); margin-right: 6px; }
.answers { display: flex; gap: 12px; }

/* ---------------------------------------------------------------- шкалы */

.scale { margin-bottom: 16px; }
.scale__head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.scale__score { color: var(--muted); font-weight: 400; }
.scale__bar { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.scale__fill { height: 100%; border-radius: 4px; }
.scale__label { font-size: 13px; margin-top: 4px; }

.lvl0 { color: var(--lvl0); }
.lvl1 { color: var(--lvl1); }
.lvl2 { color: var(--lvl2); }
.scale__fill.lvl0 { background: var(--lvl0); }
.scale__fill.lvl1 { background: var(--lvl1); }
.scale__fill.lvl2 { background: var(--lvl2); }

/* ---------------------------------------------------------------- таблицы */

/* широкая таблица прокручивается внутри своей карточки, а не ломает страницу */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted);
  padding: 6px 8px; border-bottom: 1px solid var(--line);
  vertical-align: bottom;
}
/* числовые колонки: заголовок и значение прижаты друг к другу справа,
   ширина — по содержимому, чтобы между ними не было пропасти */
.table th.num { white-space: normal; text-align: right; }
.table th.num, .table td.num { width: 1%; }
.table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .group td { background: var(--soft); font-weight: 600; color: var(--fg); }
.table--click tbody tr[data-id] { cursor: pointer; }
.table--click tbody tr[data-id]:hover { background: var(--soft); }
.table .details td { background: var(--soft); }

.tag {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  background: #fdecec; color: #a52020; border-radius: 4px; padding: 1px 6px; vertical-align: middle;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  border-left: 3px solid var(--c); background: var(--soft);
  border-radius: 4px; padding: 6px 10px; font-size: 13px;
}
.chip b { font-size: 17px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters select, .filters input {
  font: inherit; font-size: 14px; color: var(--fg);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
}

.interpret {
  white-space: pre-wrap; font: inherit; font-size: 14px;
  margin: 8px 0 0; padding: 0; color: var(--fg);
}

/* ---------------------------------------------------------------- результат */

.result-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.result-head > div { flex: 1 1 260px; min-width: 0; }
.result-head .btn { flex-shrink: 0; }
.result-head h1 { margin-bottom: 4px; }
.result-head p { margin: 0; }

@media (max-width: 560px) {
  .result-head .btn { width: 100%; }
}

/* ---------------------------------------------------------------- настройки */

.userlist { margin-bottom: 14px; }
.userrow {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.userrow__remove {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 8px; border-radius: 6px;
}
.userrow__remove:hover { color: #a52020; background: #fdecec; }

.btn--danger { color: #a52020; border-color: #f0c4c4; }
.btn--danger:hover { background: #fdecec; }
.details__actions { margin-top: 10px; }

.search { position: relative; margin-top: 4px; }
.search input {
  width: 100%; font: inherit; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
}
.search__results {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(31, 39, 50, .1); overflow: hidden;
}
.search__item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 12px; cursor: pointer; font-size: 14px;
}
.search__item:hover { background: var(--soft); }
.search__item.is-muted { cursor: default; opacity: .6; }

/* ---------------------------------------------------------------- печать */

@media print {
  .nav, .actions, .filters, .btn { display: none !important; }
  .card { break-inside: avoid; border-color: #ccc; }
  .screen { max-width: none; padding: 0; }
}

@media (max-width: 560px) {
  .answers { flex-direction: column; }
  .question { font-size: 17px; }
}
