:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --border: #d5dae2;
  --text: #1f2937;
  --muted: #6b7280;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #b45309;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f5f6f8;
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding: 32px 16px 80px;
}

.card {
  max-width: 840px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 8px 24px rgba(16, 24, 40, .06);
  padding: 32px 36px 36px;
}

h1 { font-size: 26px; text-align: center; margin: 4px 0 22px; }

.info {
  background: #e8f2fc;
  border-left: 4px solid var(--blue);
  border-radius: 4px;
  padding: 16px 18px;
  color: #1b4f8a;
  margin-bottom: 26px;
}
.info p { margin: 0 0 10px; }
.info p:last-child { margin-bottom: 0; }

.step-label { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 20px; }

.progress { display: flex; gap: 8px; margin-bottom: 22px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: #e5e7eb; }
.progress span.done { background: var(--blue); }

.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.req { color: var(--red); }

input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
input:disabled, select:disabled { background: #f3f4f6; color: #9ca3af; }
textarea { resize: vertical; min-height: 60px; }

.error-text { color: var(--red); font-size: 13px; margin-top: 5px; display: none; }
.invalid input, .invalid select, .invalid .multiselect { border-color: var(--red); }
.invalid .error-text { display: block; }

.radio-row { display: flex; gap: 22px; padding-top: 4px; }
.radio-row label { display: flex; align-items: center; gap: 7px; font-weight: normal; 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: normal; cursor: pointer; font-size: 14px; }

/* мультиселект */
.multiselect { border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: #fff; cursor: pointer; min-height: 42px; }
.multiselect .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: #eef2ff; color: #3730a3; border-radius: 4px; padding: 3px 7px; font-size: 12.5px; display: inline-flex; gap: 5px; align-items: center; }
.chip b { cursor: pointer; color: #6366f1; font-weight: 700; }
.ms-placeholder { color: #9ca3af; font-size: 14px; padding: 4px 4px; }
.ms-list { border: 1px solid var(--border); border-top: none; border-radius: 0 0 6px 6px; max-height: 220px; overflow: auto; background: #fff; }
.ms-list div { padding: 7px 10px; font-size: 14px; cursor: pointer; }
.ms-list div:hover { background: #f1f5ff; }
.ms-list div.sel { background: #eef2ff; font-weight: 600; }
.hidden { display: none !important; }

/* таблица задач */
table.tasks { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
table.tasks th { background: #f0f4fa; font-size: 12.5px; text-align: left; padding: 9px 8px; border: 1px solid var(--border); font-weight: 600; }
table.tasks td { border: 1px solid var(--border); padding: 8px; vertical-align: top; }
table.tasks td.num { text-align: center; color: var(--muted); width: 34px; }
table.tasks td.act { text-align: center; width: 44px; }
.del { border: none; background: none; cursor: pointer; color: var(--red); font-size: 17px; line-height: 1; }

.add-row {
  width: 100%; margin: 8px 0 18px; padding: 12px;
  border: 2px dashed #9dbcf5; border-radius: 6px;
  background: #fff; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer;
}
.add-row:hover { background: #f5f9ff; }

.total { border-radius: 6px; padding: 12px 14px; font-weight: 600; margin-bottom: 8px; }
.total.low { background: #fef6e7; color: var(--amber); }
.total.ok { background: #e8f7ee; color: var(--green); }
.total.over { background: #fdecec; color: var(--red); }
.bar { height: 6px; border-radius: 3px; background: #e5e7eb; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: currentColor; transition: width .2s; }

.actions { display: flex; gap: 12px; margin-top: 26px; }
button.primary {
  flex: 1; padding: 14px; border: none; border-radius: 6px;
  background: var(--blue); color: #fff; font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
}
button.primary:hover { background: var(--blue-dark); }
button.primary:disabled { background: #a8bde6; cursor: not-allowed; }
button.secondary {
  padding: 14px 22px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--text); font: inherit; cursor: pointer;
}

.summary { border: 1px solid var(--border); border-radius: 6px; padding: 16px; margin-bottom: 16px; }
.summary dl { margin: 0; display: grid; grid-template-columns: 220px 1fr; gap: 6px 14px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; }

.errors { background: #fdecec; border: 1px solid #f5c2c2; color: #991b1b; border-radius: 6px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.errors ul { margin: 6px 0 0; padding-left: 20px; }

.done-screen { text-align: center; padding: 40px 0; }
.done-screen .tick { font-size: 46px; color: var(--green); }

@media (max-width: 760px) {
  body { padding: 12px 8px 60px; }
  .card { padding: 20px 16px 24px; }
  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(--border); border-radius: 6px; margin-bottom: 12px; padding: 8px; }
  table.tasks td { border: none; padding: 6px 4px; }
  table.tasks td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
  .summary dl { grid-template-columns: 1fr; }
}

/* ---------- выпадающий список с поиском ---------- */
.combo { position: relative; }
.combo-input {
  width: 100%; padding: 11px 34px 11px 12px;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
.combo.open .combo-input { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.combo-caret {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: #9ca3af; font-size: 11px; pointer-events: none; transition: transform .15s;
}
.combo.open .combo-caret { transform: translateY(-50%) rotate(180deg); }
.combo-input:disabled { background: #f3f4f6; color: #9ca3af; }
.combo-input:disabled + .combo-caret { opacity: .4; }

.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 5px);
  background: #fff; border: 1px solid #e3e7ee; border-radius: 8px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
  max-height: 292px; overflow-y: auto; padding: 5px;
}
.combo-item {
  padding: 9px 11px; border-radius: 6px; cursor: pointer; font-size: 14.5px; line-height: 1.35;
}
.combo-item:hover { background: #f1f5ff; }
.combo-item.active { background: #e8effd; }
.combo-item.picked { font-weight: 600; color: var(--blue-dark); }
.combo-item mark { background: #fde9a9; color: inherit; border-radius: 2px; padding: 0 1px; }
.combo-empty { padding: 14px 12px; color: var(--muted); font-size: 14px; text-align: center; }
.combo-hint { padding: 7px 11px 9px; color: #9ca3af; font-size: 12px; border-top: 1px solid #eef1f6; margin-top: 4px; }

.combo-list::-webkit-scrollbar { width: 10px; }
.combo-list::-webkit-scrollbar-track { background: #f6f7f9; border-radius: 8px; }
.combo-list::-webkit-scrollbar-thumb { background: #cbd2dc; border-radius: 8px; border: 2px solid #fff; }
.combo-list::-webkit-scrollbar-thumb:hover { background: #aeb7c4; }

/* поиск внутри списка инструментов */
.ms-search { padding: 5px 5px 8px; position: sticky; top: 0; background: #fff; }
.ms-search input { padding: 8px 10px; font-size: 14px; }
.ms-list { position: absolute; z-index: 30; left: 0; right: 0; margin-top: 5px;
  border: 1px solid #e3e7ee; border-radius: 8px; box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
  max-height: 300px; overflow-y: auto; background: #fff; padding: 0 5px 5px; }
.ms-list div.opt { padding: 8px 10px; font-size: 14px; cursor: pointer; border-radius: 6px; display: flex; gap: 9px; align-items: flex-start; }
.ms-list div.opt:hover { background: #f1f5ff; }
.ms-list div.opt.sel { background: #eef2ff; font-weight: 600; }
.ms-list div.opt i { font-style: normal; color: var(--blue); width: 14px; flex: none; }
.ms-list::-webkit-scrollbar { width: 10px; }
.ms-list::-webkit-scrollbar-track { background: #f6f7f9; border-radius: 8px; }
.ms-list::-webkit-scrollbar-thumb { background: #cbd2dc; border-radius: 8px; border: 2px solid #fff; }
td .multiselect, td .combo { position: relative; }
table.tasks td { position: relative; }

/* в таблице задач списки шире ячейки, чтобы длинные названия читались */
table.tasks .combo-list, table.tasks .ms-list { min-width: 430px; }
@media (max-width: 760px) { table.tasks .combo-list, table.tasks .ms-list { min-width: 0; } }

/* ---------- широкая карточка на шаге с таблицей задач ---------- */
.card { transition: max-width .25s ease; }
.card.wide { max-width: 1240px; }
.card.wide .info, .card.wide .step-label, .card.wide .errors { max-width: 100%; }

/* удаление строки — без отдельного столбца «Действия» */
table.tasks td.last { position: relative; }
.row-del {
  position: absolute; right: -30px; top: 12px;
  width: 24px; height: 24px; line-height: 22px; text-align: center;
  border: 1px solid transparent; border-radius: 50%;
  background: none; color: #c2c8d2; font-size: 15px; cursor: pointer; padding: 0;
  transition: color .15s, background .15s, border-color .15s;
}
.row-del:hover { color: var(--red); background: #fdecec; border-color: #f5c2c2; }

/* ---------- сводка перед отправкой ---------- */
.sum-block { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 16px; overflow: hidden; }
.sum-block > h3 {
  margin: 0; padding: 11px 16px; font-size: 14px; background: #f0f4fa;
  border-bottom: 1px solid var(--border); color: #1f3763;
}
.sum-grid { display: grid; grid-template-columns: 260px 1fr; }
.sum-grid > div { padding: 10px 16px; border-bottom: 1px solid #eef1f6; font-size: 14.5px; }
.sum-grid > div.k { color: var(--muted); background: #fcfdfe; }
.sum-grid > div:nth-last-child(-n+2) { border-bottom: none; }

.sum-task { padding: 14px 16px; border-bottom: 1px solid #eef1f6; display: flex; gap: 14px; align-items: flex-start; }
.sum-task:last-child { border-bottom: none; }
.sum-task .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: #e8effd; color: var(--blue-dark);
  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: 4px; }
.sum-task .tools { color: var(--muted); font-size: 13.5px; }
.sum-task .cm { font-size: 13.5px; font-style: italic; color: #4b5563; margin-top: 4px; }
.sum-task .p { flex: none; font-weight: 700; color: var(--blue-dark); font-size: 15px; min-width: 48px; text-align: right; }
.sum-total { display: flex; justify-content: space-between; padding: 12px 16px; background: #e8f7ee; color: var(--green); font-weight: 700; }

@media (max-width: 760px) {
  .card.wide { max-width: 100%; }
  .sum-grid { grid-template-columns: 1fr; }
  .sum-grid > div.k { padding-bottom: 0; background: none; }
  .row-del { position: static; float: right; }
}

/* выбранное значение в несколько строк (длинные названия задач) */
.combo-face {
  min-height: 42px; padding: 10px 30px 10px 12px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer;
  font-size: 14.5px; line-height: 1.35; white-space: normal; overflow-wrap: anywhere;
}
.combo-face:hover { border-color: #b9c4d4; }
.combo-face:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.combo-face.empty { color: #9ca3af; }

/* ---------- овальные кнопки выбора ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 9px; }
.pill {
  border: 1.5px solid var(--border); border-radius: 999px; background: #fff; color: var(--text);
  padding: 10px 20px; font: inherit; font-size: 14.5px; cursor: pointer; line-height: 1.25;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill:hover { border-color: #9db6ea; background: #f7faff; }
.pill.on {
  border-color: var(--blue); background: #e8effd; color: var(--blue-dark); font-weight: 600;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.pill.on::before { content: '✓'; font-size: 13px; }
.pill .sub { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.pill.on .sub { color: #5b78bb; }

.hint { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; }
.other-wrap { margin-top: 12px; }
.link-btn {
  border: none; background: none; color: var(--blue); font: inherit; font-size: 14px;
  cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--blue-dark); }

/* ---------- смысловые блоки шага 2 ---------- */
.block { border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px 20px; margin-bottom: 18px; }
.block > h2 {
  margin: 0 0 4px; font-size: 17px; color: #1f3763;
  padding-bottom: 10px; border-bottom: 1px solid #eef1f6;
}
.block > h2 + .hint, .block > h2 + .field { margin-top: 14px; }
.invalid .pills .pill { border-color: #f0a9a9; }

/* закреплённый сверху пункт «Другой вариант» */
.combo-item.pinned {
  color: var(--blue-dark); font-weight: 600; background: #f5f9ff;
  border-bottom: 1px solid #e6edf9; border-radius: 6px 6px 0 0; margin-bottom: 4px;
}
.combo-item.pinned:hover { background: #e8effd; }
.own-task { border-color: #9db6ea !important; }

/* свой инструмент */
.ms-list .opt.pinned { color: var(--blue-dark); font-weight: 600; background: #f5f9ff; margin-bottom: 4px; }
.ms-list .opt.pinned:hover { background: #e8effd; }
.own-tool-row { display: flex; gap: 8px; padding: 0 5px 8px; }
.own-tool-row input { flex: 1; padding: 8px 10px; font-size: 14px; }
.own-tool-row button { padding: 8px 14px; white-space: nowrap; }
.chip.own { background: #fff4e5; color: #92400e; }
.chip.own b { color: #b45309; }
