/* ============================================================
   Опрос АУП — единая таблица стилей для всех страниц:
   форма, админка, служебные страницы (404, нет доступа, ошибка).

   Оформление: светлый сине-серый фон, белые карточки со скруглением,
   синий акцент (как на Госуслугах и РПГУ — пользователям привычно).
   Красный — только ошибки и звёздочка обязательного поля.

   Устройство файла:
     1. База          — переменные, сброс, типографика, каркас страницы
     2. Поля ввода
     3. Кнопки
     4. Списки с поиском
     5. Перечень функций и инструменты
     6. Таблицы
     7. Сводка и служебные экраны
     8. Админка
     9. Мобильные

   Новые страницы должны обходиться этими классами, без своих <style>.
   ============================================================ */

/* ---------- 1. База ---------- */
:root {
  --ink: #0b1f33;
  --muted: #5a6b7d;
  --line: #dde5f0;
  --line-strong: #c3d0e0;
  --fill: #eaf1fd;
  --accent: #0d4cd3;
  --accent-dark: #0a3caa;
  --red: #e02b2b;
  --page-bg: #f4f6fa;

  --page-width: 840px;
  --page-width-wide: 1320px;
  --page-width-table: 1120px;
  --gap: 20px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 40px 16px 80px;
}

/* каркас страницы: одна колонка по центру, на фоне страницы */
.card { max-width: var(--page-width); margin: 0 auto; padding: 0; transition: max-width .2s ease; }
.card--wide { max-width: var(--page-width-wide); }
.card--table { max-width: var(--page-width-table); }   /* шаг с таблицей функций: пять колонок */

/* белая карточка: на ней лежит содержимое */
.panel {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: 0 2px 10px rgba(11, 31, 51, .06);
}

h1 { font-size: 22px; font-weight: 700; margin: 0 0 18px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 10px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
a { color: var(--accent); }
b, strong { font-weight: 600; }

/* шапка: логотипы и название формы. Одинаковая на всех страницах */
.page-head {
  display: flex; align-items: center; gap: 20px;
  padding-bottom: 20px; margin-bottom: 20px;
  border-bottom: 2px solid var(--accent);
}
.page-head__logo { height: 52px; width: auto; flex: none; }
.page-head__logo--icto { height: 42px; }
.page-head__text { min-width: 0; }
.page-head h1 { font-size: 20px; margin: 0 0 3px; }
.page-head__org { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

/* вводный текст */
.info { margin: 0 0 16px; color: #40566d; font-size: 14.5px; background: var(--fill); }
.info p { margin: 0 0 8px; }
.info p:last-child { margin-bottom: 0; }
.info b { color: var(--ink); }

.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.hint--lead { margin-bottom: 14px; }
.note { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* смысловой блок внутри шага */
.block { margin-bottom: 30px; }
.block > h2 { margin: 0 0 14px; font-size: 17px; }
.block > h2 + .hint, .block > h2 + .field { margin-top: 12px; }

/* шаги мастера */
.step-label { color: var(--muted); font-size: 13.5px; margin: 12px 0 22px; }
.progress { display: flex; gap: 6px; }
.progress span { flex: 1; height: 6px; background: var(--line); border-radius: 3px; }
.progress span.done { background: var(--accent); }

/* ---------- 2. Поля ввода ---------- */
.field { margin-bottom: var(--gap); }
.field > label { display: block; font-weight: 600; margin-bottom: 7px; font-size: 14.5px; }
.field > .hint { margin: 6px 0 0; }
.req { color: var(--red); font-weight: 400; }

input[type=text], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #ffffff;
  color: var(--ink);
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: #f1f4f9; border-color: var(--line); color: #93a3b4; }
textarea { resize: vertical; min-height: 58px; }
input[type=file] { padding: 10px 12px; font-size: 14px; }

.error-text { color: var(--red); font-size: 13px; margin-top: 6px; display: none; }
.invalid input, .invalid select, .invalid textarea,
.invalid .ms, .invalid .combo-face, .invalid .combo-input, .invalid .picker-btn { border-color: var(--red); }
.invalid .error-text { display: block; }

.radio-row { display: flex; gap: 20px; padding-top: 4px; }
.radio-row label { display: flex; align-items: center; gap: 7px; font-weight: 400; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.checks label { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; cursor: pointer; font-size: 14px; }

/* ---------- 3. Кнопки ---------- */
.actions { display: flex; gap: 12px; margin-top: 28px; }
.btn-row { display: flex; gap: 8px; flex: none; }

button.primary {
  flex: 1; padding: 15px 24px; border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: #ffffff; font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { background: #a9bde8; cursor: not-allowed; }

button.secondary {
  padding: 15px 24px; border: 0; border-radius: var(--radius-sm);
  background: var(--fill); color: var(--accent); font: inherit; font-weight: 600; cursor: pointer;
}
button.secondary:hover { background: #dbe7fb; }

.link-btn {
  border: none; background: none; color: var(--accent); font: inherit; font-size: 13.5px;
  cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--accent-dark); }

/* кнопки-переключатели «Да / Нет» */
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  border: 2px solid var(--line); border-radius: 999px; background: #ffffff; color: var(--ink);
  padding: 10px 22px; font: inherit; font-size: 15px; cursor: pointer; line-height: 1.25;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill:hover { border-color: var(--line-strong); }
.pill.on { border-color: var(--accent); background: var(--accent); color: #ffffff; font-weight: 600; }
.pill .sub { color: var(--muted); font-size: 12.5px; }
.pill.on .sub { color: #cdddf8; }
.invalid .pills .pill { border-color: var(--red); }

/* ---------- 4. Списки с поиском ---------- */
.combo { position: relative; }
.combo-input {
  width: 100%; padding: 12px 34px 12px 13px;
  border: 2px solid var(--line); border-radius: var(--radius-sm); font: inherit; background: #ffffff; color: var(--ink);
}
.combo.open .combo-input { border-color: var(--accent); }
.combo-caret {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 10px; pointer-events: none; transition: transform .15s;
}
.combo.open .combo-caret { transform: translateY(-50%) rotate(180deg); }
.combo-input:disabled { background: #f1f4f9; color: #93a3b4; }

/* выбранное значение в несколько строк — длинные названия школ и функций */
.combo-face {
  min-height: 48px; padding: 12px 32px 12px 13px;
  border: 2px solid var(--line); border-radius: var(--radius-sm); background: #ffffff; cursor: pointer;
  font-size: 15px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere;
}
.combo-face:hover { border-color: var(--line-strong); }
.combo-face:focus { outline: none; border-color: var(--accent); }
.combo-face.empty { color: #93a3b4; }

/* выбор пока невозможен (не выбран округ) — поле выглядит заблокированным */
.combo.disabled .combo-face { background: #f1f4f9; color: #93a3b4; cursor: default; }
.combo.disabled .combo-face:hover { border-color: var(--line); }
.combo.disabled .combo-caret { opacity: .4; }

.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 300px; overflow-y: auto; padding: 4px;
  box-shadow: 0 8px 24px rgba(11, 31, 51, .12);
}
.combo-item { padding: 10px 12px; cursor: pointer; font-size: 14.5px; line-height: 1.4; border-radius: 6px; }
.combo-item:hover, .combo-item.active { background: var(--fill); }
.combo-item.picked { font-weight: 600; color: var(--accent); }
.combo-item.pinned { border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; margin-bottom: 4px; }
.combo-item mark { background: #fff2b8; color: inherit; border-radius: 2px; padding: 0 1px; }
.combo-empty { padding: 14px 12px; color: var(--muted); font-size: 14px; }
.combo-hint { padding: 8px 12px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.combo-list::-webkit-scrollbar, .picker-list::-webkit-scrollbar, .ms-list::-webkit-scrollbar { width: 10px; }
.combo-list::-webkit-scrollbar-thumb, .picker-list::-webkit-scrollbar-thumb, .ms-list::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 6px; border: 2px solid #fff;
}

/* ---------- 5. Перечень функций и инструменты ---------- */
.picker { position: relative; }
.picker-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: #ffffff; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-align: left;
}
.picker-btn:hover { border-color: var(--line-strong); }
.picker.open .picker-btn { border-color: var(--accent); }
.picker.open .combo-caret { transform: rotate(180deg); }
.picker-btn .combo-caret { position: static; transform: none; }

.picker-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
  background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 440px; overflow-y: auto;
  box-shadow: 0 10px 28px rgba(11, 31, 51, .14);
}

.picker-group + .picker-group { border-top: 1px solid var(--line); }
/* направление — заголовок группы */
.picker-group__title {
  padding: 11px 14px; font-size: 14px; font-weight: 700; color: var(--accent);
  background: var(--fill);
}
.picker-item { display: flex; gap: 12px; padding: 11px 14px; cursor: pointer; align-items: flex-start; }
.picker-item:hover { background: #f7faff; }
/* «В перечне нет моей функции» — закреплён сверху */
.picker-item--none { border-bottom: 2px solid var(--line); }
.picker-item--none .picker-item__task { font-weight: 600; }
.picker-item input { width: auto; margin: 3px 0 0; flex: none; accent-color: var(--accent); }
.picker-item__body { min-width: 0; }
.picker-item__task { display: block; font-size: 14.5px; }
.picker-item.on .picker-item__task { font-weight: 600; color: var(--accent); }
.picker-item__details {
  margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.picker-item mark { background: #fff2b8; border-radius: 2px; }

/* инструменты и системы в строке функции */
.ms {
  border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 7px; background: #ffffff;
  cursor: pointer; min-height: 46px;
}
.ms:hover { border-color: var(--line-strong); }
.ms .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: var(--fill); color: var(--accent); border-radius: 999px;
  padding: 3px 11px; font-size: 12.5px; display: inline-flex; gap: 7px; align-items: center; line-height: 1.4;
}
.chip b { cursor: pointer; color: #6f8bc4; font-weight: 600; }
.chip b:hover { color: var(--red); }
.ms-placeholder { color: #93a3b4; font-size: 13.5px; padding: 4px; display: inline-block; }
.ms-other { margin-top: 7px; font-size: 13.5px; }

.ms-list {
  position: absolute; z-index: 30; left: 8px; right: 8px; margin-top: 4px;
  background: #ffffff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 300px; overflow-y: auto; min-width: 340px;
  box-shadow: 0 10px 28px rgba(11, 31, 51, .14);
}
.ms-list .opt { padding: 9px 12px; font-size: 13.5px; cursor: pointer; display: flex; gap: 9px; align-items: flex-start; }
.ms-list .opt:hover { background: #f7faff; }
.ms-list .opt.sel { background: var(--fill); font-weight: 600; color: var(--accent); }
.ms-list .opt i { font-style: normal; width: 13px; flex: none; color: var(--accent); }
.ms-list .opt mark { background: #fff2b8; border-radius: 2px; }
.ms-search { padding: 7px; position: sticky; top: 0; background: #ffffff; border-bottom: 1px solid var(--line); }
.ms-search input { padding: 9px 11px; font-size: 13.5px; border-width: 1px; }

/* ---------- 6. Таблицы ---------- */
/* строки функций; справа жёлоб под кнопку удаления */
table.tasks { width: calc(100% - 28px); border-collapse: collapse; margin-bottom: 6px; }
table.tasks th {
  font-size: 13px; text-align: left; padding: 9px 8px; font-weight: 600;
  border-bottom: 2px solid var(--line); color: var(--muted);
}
table.tasks td { border-bottom: 1px solid #eef2f8; padding: 12px 8px; vertical-align: top; position: relative; }
table.tasks td.num { color: var(--muted); width: 34px; padding-top: 22px; }
table.tasks .combo-list { min-width: 380px; }

.col-num { width: 34px; }
.col-tools { width: 26%; }
.col-hours { width: 110px; }
.col-comment { width: 20%; }
.cell-func .link-btn { margin-top: 6px; display: inline-block; }

/* название выбранной функции в таблице и её описание из справочника */
.func-name { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.func-desc {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.4;
}
.func-dir { display: block; margin-top: 3px; font-size: 12.5px; color: var(--muted); }

/* своя функция: направление из списка + название вручную */
.own-func { display: grid; gap: 7px; }
.own-func .own-dir { font-size: 14px; padding: 10px 12px; }
.own-func .own-name { font-size: 14px; }

.add-row {
  width: 100%; margin: 12px 0 20px; padding: 13px;
  border: 2px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: #ffffff; color: var(--accent); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.add-row:hover { background: #f7faff; border-color: var(--accent); }

.row-del {
  position: absolute; right: -28px; top: 16px;
  width: 24px; height: 24px; line-height: 22px; text-align: center;
  border: none; border-radius: 50%; background: none; color: #a8b6c6; font-size: 15px; cursor: pointer; padding: 0;
}
.row-del:hover { color: var(--red); background: #fdeaea; }

/* счётчик часов */
.total { padding: 14px 0 0; font-size: 14.5px; font-weight: 600; margin-bottom: 8px; color: var(--muted); }
.total.ok { color: var(--accent); }
.total.warn { color: #b26a00; }        /* больше нормированного графика */
.total.over { color: var(--red); }     /* похоже на ошибку в подсчёте */
.total-note { font-weight: 400; font-size: 13.5px; line-height: 1.45; margin-top: 6px; max-width: 720px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: currentColor; transition: width .15s; }

/* реестр ответов */
.grid-wrap { overflow: auto; max-height: 65vh; border-radius: var(--radius-sm); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left; padding: 10px 8px; border-bottom: 2px solid var(--line);
  color: var(--muted); font-weight: 600; position: sticky; top: 0; background: #ffffff;
}
table.grid td { border-bottom: 1px solid #eef2f8; padding: 9px 8px; vertical-align: top; }
.grid-empty { text-align: center; color: var(--muted); padding: 24px; }

/* ---------- 7. Сводка и служебные экраны ---------- */
.errors {
  background: #fdeaea; border: 1px solid #f6bcbc; color: #a01717; border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 18px; font-size: 14.5px;
}
.errors ul { margin: 6px 0 0; padding-left: 20px; }

.sum-block { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 16px; overflow: hidden; }
.sum-block > h3 {
  margin: 0; padding: 12px 16px; font-size: 13px; color: var(--accent); background: var(--fill);
  border-bottom: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em;
}
.sum-grid { display: grid; grid-template-columns: 250px 1fr; }
.sum-grid > div { padding: 11px 16px; border-bottom: 1px solid #eef2f8; font-size: 14.5px; }
.sum-grid > div.k { color: var(--muted); }
.sum-grid > div:nth-last-child(-n+2) { border-bottom: none; }

.sum-task { padding: 13px 16px; border-bottom: 1px solid #eef2f8; display: flex; gap: 14px; align-items: flex-start; }
.sum-task:last-of-type { border-bottom: none; }
.sum-task .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--fill); color: var(--accent);
  font-size: 13px; font-weight: 600; text-align: center; line-height: 26px;
}
.sum-task .body { flex: 1; }
.sum-task .t { font-weight: 600; margin-bottom: 3px; }
.sum-task .tools { font-size: 13px; color: var(--muted); margin-top: 3px; }
.sum-task .cm { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.sum-task .p { flex: none; font-weight: 700; color: var(--accent); min-width: 62px; text-align: right; }
.sum-total {
  display: flex; justify-content: space-between; padding: 13px 16px;
  background: var(--fill); color: var(--accent); font-weight: 700;
}

/* вход по коду доступа */
.gate { max-width: 440px; margin: 10px auto; }
.gate h2 { margin: 0 0 8px; font-size: 19px; }
.gate .hint { margin-bottom: 18px; }
.gate input { width: 100%; font-size: 17px; padding: 14px; text-align: center; text-transform: uppercase; letter-spacing: 1px; }
.gate .primary { margin-top: 16px; width: 100%; }
.gate.invalid input { border-color: var(--red); }
.gate.invalid .error-text { display: block; text-align: center; }

/* экран «форма отправлена» */
.done-screen { padding: 46px 0; }
.done-screen h2 { font-size: 20px; margin: 0 0 10px; color: var(--accent); }
.done-screen p { color: var(--muted); margin: 0 0 6px; }

/* служебные страницы: 404, нет доступа, ошибка сервера */
.page-msg h2 { margin-bottom: 10px; }
.page-msg p { color: var(--muted); margin: 0 0 10px; }
.page-msg .code { color: #93a3b4; font-size: 13px; }

/* ---------- 8. Админка ---------- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.stat { background: var(--fill); border-radius: var(--radius-sm); padding: 14px 18px; min-width: 150px; }
.stat b { display: block; font-size: 26px; font-weight: 700; color: var(--accent); }
.stat span { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: var(--gap); }
.toolbar .field { margin: 0; min-width: 180px; max-width: 300px; flex: 1 1 190px; }
.toolbar .field--narrow { min-width: 150px; flex-basis: 150px; }
.toolbar button { padding: 12px 20px; font-size: 15px; }

.btn-export {
  border: 0; border-radius: var(--radius-sm); padding: 12px 22px;
  background: var(--accent); color: #ffffff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn-export:hover { background: var(--accent-dark); }

.linkbox {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  background: #f7faff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; margin-bottom: 14px;
}
.linkbox p { margin: 4px 0 10px; font-size: 13.5px; color: var(--muted); max-width: 700px; }
.linkbox code {
  display: inline-block; background: #ffffff; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 11px; font-size: 13px; word-break: break-all;
}
.codebox { background: #fff8ef; border-color: #f3ddc0; }
.codebox code { font-size: 17px; font-weight: 700; letter-spacing: 1px; }

.section { margin-bottom: var(--gap); }
.section > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.section p { font-size: 14px; color: var(--muted); }
.section .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.section .row input[type=file] { width: auto; flex: 1 1 260px; }
.section .row input[type=text] { width: 260px; }

.result { font-size: 14px; }
.result.ok { color: #12805c; }
.result.err { color: var(--red); }

.repeat { background: #fff3cd; color: #8a6100; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; white-space: nowrap; }
.del { border: none; background: none; cursor: pointer; color: #a8b6c6; font-size: 16px; }
.del:hover { color: var(--red); }

details.tasks-cell summary { cursor: pointer; color: var(--accent); }
.tasks-cell ol { margin: 6px 0 0; padding-left: 18px; }
.tasks-cell .muted { color: var(--muted); }

/* ---------- 9. Мобильные ---------- */
@media (max-width: 760px) {
  body { padding: 18px 12px 60px; }
  .card, .card--wide, .card--table { max-width: 100%; }
  .panel { padding: 18px 16px; border-radius: var(--radius-sm); }

  .page-head { gap: 12px; padding-bottom: 14px; margin-bottom: 18px; align-items: flex-start; }
  .page-head__logo { height: 40px; }
  .page-head__logo--icto { height: 32px; }
  .page-head h1 { font-size: 17px; }
  .page-head__org { font-size: 12px; }

  table.tasks { width: 100%; }
  table.tasks, table.tasks thead, table.tasks tbody, table.tasks tr, table.tasks td { display: block; width: 100%; }
  table.tasks thead { display: none; }
  table.tasks tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; }
  table.tasks td { border: none; padding: 7px 0; }
  table.tasks td.num { display: none; }
  table.tasks td::before { content: attr(data-label); display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
  table.tasks .combo-list { min-width: 0; }
  .ms-list { position: static; min-width: 0; box-shadow: none; margin-top: 6px; }
  .row-del { position: static; float: right; }

  .sum-grid { grid-template-columns: 1fr; }
  .sum-grid > div.k { padding-bottom: 0; }
  .linkbox { display: block; }
  .section .row input[type=text] { width: 100%; }
  .actions { flex-direction: column-reverse; }
  button.secondary { width: 100%; }
}
