:root {
  --accent: #1f5fbf;
  --accent-soft: #e8f0fc;
  --text: #1d1f23;
  --muted: #5f6672;
  --line: #d9dde3;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --warn: #b3261e;
  --warn-soft: #fdecea;
  --ok: #1e7a3c;
  --radius: 10px;
}

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

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

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

.page { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.page-wide { max-width: 1200px; }

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.15rem; line-height: 1.3; }
h3 { font-size: 1.05rem; margin: 0 0 0.3em; }
p { margin: 0 0 0.8em; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: var(--radius); }
.notice { background: var(--accent-soft); padding: 10px 14px; border-radius: var(--radius); }
[hidden] { display: none !important; }

/* ---------- кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--bg); color: var(--accent);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary:hover, .btn-secondary.selected { background: var(--accent-soft); }
.btn-secondary.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-wide { width: 100%; margin-top: 8px; }

.link {
  background: none; border: none; padding: 0; min-height: 44px;
  font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer;
}
.link.quiet { color: var(--muted); font-size: 0.9rem; }
.link.quiet.selected { color: var(--text); font-weight: 600; }
.link.more { min-height: 32px; font-size: 0.9rem; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- карточки-описания */
.info-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 12px;
}
.info-card h3 { font-size: 1.1rem; }
.info-card p:last-child { margin-bottom: 0; }

/* ---------- формы */
.form fieldset { border: none; padding: 0; margin: 0 0 20px; }
.form legend { font-weight: 600; margin-bottom: 6px; }
.option {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 6px 12px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--accent); }
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input[type=text], .field textarea {
  width: 100%; padding: 10px 12px; min-height: 44px;
  font: inherit; border: 1px solid var(--line); border-radius: var(--radius);
}
.field textarea { resize: vertical; }

/* ---------- опрос */
.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-text { font-weight: 600; }
.progress { height: 6px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin: 2px 0 16px; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.2s; }
.question-head { margin-bottom: 14px; }
.context { color: var(--muted); margin-bottom: 6px; }
.question { margin: 0; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card {
  position: relative; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px 6px; cursor: pointer; background: var(--bg);
  transition: border-color 0.1s, background 0.1s;
}
.choice-card:hover { border-color: var(--accent); }
.choice-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice-card p { margin-bottom: 4px; }
.choice-card .details { font-size: 0.875rem; padding-bottom: 8px; }
.choice-card .details p { margin-bottom: 6px; }
.card-mark {
  display: none; position: absolute; top: -11px; right: 10px;
  background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 600;
  padding: 1px 8px; border-radius: 10px;
}
.choice-card.selected .card-mark { display: inline-block; }

.alt { display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 12px 0 4px; }

.scale { margin-top: 10px; }
.scale-title { font-weight: 600; margin-bottom: 6px; }
.scale-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.scale-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  min-height: 56px; padding: 6px 0 4px; min-width: 0;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--bg); color: var(--accent);
  font: inherit; cursor: pointer;
}
.scale-btn:hover { background: var(--accent-soft); }
.scale-btn.selected { background: var(--accent); color: #fff; }
.scale-num { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.scale-word { font-size: 0.62rem; line-height: 1.15; hyphens: manual; overflow-wrap: normal; word-break: normal; text-align: center; max-width: 100%; }
.scale + .confirm, .confirm { min-height: 1.5em; margin: 12px 0 0; }
.scale .small { margin: 6px 0 0; }

.nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.nav .btn-primary { margin-left: auto; min-width: 140px; }

/* ---------- проверка */
.review-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.level-good strong { color: var(--ok); }
.level-low strong { color: var(--warn); }

/* ---------- полосы весов */
.bars { margin: 18px 0; }
.bar-row { margin-bottom: 12px; }
.bar-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.bar-label strong { flex: none; white-space: nowrap; }
.bar-track { height: 14px; background: var(--bg-soft); border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 7px; }

/* ---------- окно */
.dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  border: none; border-radius: var(--radius); padding: 16px; color: var(--text);
}
.dialog::backdrop { background: rgba(20, 24, 30, 0.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.dialog-close { background: none; border: none; font-size: 1.8rem; width: 44px; height: 44px; cursor: pointer; color: var(--muted); }

/* ---------- организатор */
.admin h2 { margin-top: 1.6em; padding-top: 0.6em; border-top: 1px solid var(--line); }
.plate { background: var(--warn-soft); color: var(--warn); padding: 12px 16px; border-radius: var(--radius); font-weight: 600; }
.plate code { font-weight: 400; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.col { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.col h3 { margin-bottom: 10px; }
.wbar { display: grid; grid-template-columns: minmax(0, 1fr) 4.5em; gap: 2px 10px; align-items: center; margin-bottom: 10px; }
.wbar .t { font-size: 0.9rem; }
.wbar .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.wbar .bar-track { grid-column: 1 / -1; height: 10px; }
.wbar .sub { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); }
.flag { color: var(--warn); font-weight: 600; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--bg-soft); font-weight: 600; white-space: nowrap; }
table.data td.n { text-align: right; white-space: nowrap; }
table.data tr[data-href] { cursor: pointer; }
table.data tr[data-href]:hover { background: var(--bg-soft); }
table.data tr.warn { background: var(--warn-soft); }
table.data tr.dim { color: var(--muted); }
table.matrix td, table.matrix th { text-align: center; }
.first { display: block; font-size: 0.75rem; color: var(--warn); }
.tag { display: inline-block; font-size: 0.72rem; padding: 0 6px; border-radius: 8px; background: var(--bg-soft); color: var(--muted); }
.comments li { margin-bottom: 10px; white-space: pre-wrap; }

@media (max-width: 640px) {
  .page { padding: 14px 12px 40px; }
  h1 { font-size: 1.3rem; }
  .cards { grid-template-columns: 1fr; }
  .columns { grid-template-columns: 1fr; }
  .scale-grid { gap: 3px; }
  .nav .btn { flex: 1 1 0; min-width: 0; }
}
