/* Палитра и кнопки — как в интерфейсе Битрикс24 и соседних приложениях FRBS Labs */
:root {
  --ground: #eef2f4;
  --surface: #fff;
  --ink: #333;
  --ink-2: #525c69;
  --muted: #828b95;
  --line: #e4e8eb;
  --line-strong: #cfd5da;
  --chip-bg: #f5f7f8;
  --accent: #2fc6f6;
  --accent-dark: #11a9d9;
  --link: #2067b0;
  --cta: #bbed21;
  --cta-hover: #d2f95f;
  --ok-bg: #f1fbd0; --ok-ink: #4f7d00;
  --err-bg: #ffe8e8; --err-ink: #d0312b;
  --warn-bg: #fff4d6; --warn-ink: #8a5a00;
  --info-bg: #e5f9ff; --info-ink: #0b8eb6;
  --shadow: 0 1px 2px rgba(20, 24, 30, .06), 0 4px 14px rgba(20, 24, 30, .05);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.45 "Golos Text", "Open Sans", "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
.card-head h2 { margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--err-ink); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.pad { padding: 24px; }
.grow { flex: 1; }

.app { max-width: 960px; margin: 0 auto; padding: 16px clamp(12px, 3vw, 28px) 40px; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.badge { background: var(--ok-bg); color: var(--ok-ink); font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 10px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 14px; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .grid, .grid-2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.field .hint { margin: 0; }
.input { width: 100%; min-height: 38px; padding: 7px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
textarea.input { resize: vertical; }
.input:focus { border-color: var(--accent); outline: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 18px;
  border: 1px solid var(--line-strong); border-radius: 19px; background: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #a8adb4; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-cta { background: var(--cta); border-color: var(--cta); color: var(--ink-2); }
.btn-cta:hover:not(:disabled) { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn-danger { color: var(--err-ink); }
.btn-l { height: 46px; border-radius: 23px; padding: 0 28px; }
.btn-s { height: 30px; padding: 0 12px; border-radius: 15px; font-size: 12px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: 10px; cursor: pointer; font-size: 14px; }
.tile .muted { font-size: 12px; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f3fcff; }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.step { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
.step-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--chip-bg); border-radius: 10px 10px 0 0; }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; flex: none; }
.step-body { padding: 14px; }
.rows { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; width: 100%; align-items: center; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr auto; } .row > :nth-child(2) { grid-row: 2; } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 15px; background: var(--chip-bg);
  border: 1px solid var(--line); font-size: 13px; }
.chip button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.input-add { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; }
.pick { width: 100%; margin-top: 8px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pick-list { width: 100%; max-height: 220px; overflow: auto; display: flex; flex-direction: column; }
.pick-row { text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 6px; }
.pick-row:hover { background: var(--chip-bg); }

.add { position: relative; display: inline-block; }
.add summary { list-style: none; }
.add summary::-webkit-details-marker { display: none; }
.add-menu { position: absolute; z-index: 5; top: 44px; left: 0; width: min(360px, 90vw); background: #fff; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(20, 24, 30, .18); padding: 6px; }
.add-row { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.add-row .muted { font-size: 12px; }
.add-row:hover { background: var(--chip-bg); }
.add-later { border-top: 1px solid var(--line); margin-top: 6px; padding: 8px 10px 4px; font-size: 13px; }

.preview { margin: 0 0 12px; padding-left: 22px; }
.preview li { margin-bottom: 4px; }
.note { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.note-err { background: var(--err-bg); color: var(--err-ink); }
.note-warn { background: var(--warn-bg); color: var(--warn-ink); }
.note-ok { background: var(--ok-bg); color: var(--ok-ink); }
.note-info { background: var(--info-bg); color: var(--info-ink); }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.ai-actions { margin: 10px 0 12px; align-items: center; }
.card-need { box-shadow: 0 0 0 2px var(--warn-ink), var(--shadow); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.json { margin-top: 12px; font-size: 13px; }
.json summary { cursor: pointer; color: var(--muted); }
.json-text { margin: 10px 0 8px; font: 12px/1.4 ui-monospace, Menlo, monospace; background: var(--chip-bg); }

/* ---------- как понят текст ---------- */
.segments { margin-bottom: 12px; }
.seg-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.seg { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 6px; padding: 4px 10px; border-radius: 8px; font-size: 13px; border: 1px solid transparent; }
.seg-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.seg-step { background: var(--ok-bg); color: var(--ok-ink); }
.seg-start { background: var(--info-bg); color: var(--info-ink); }
.seg-later { background: var(--warn-bg); color: var(--warn-ink); }
.seg-unknown { background: var(--err-bg); color: var(--err-ink); border-color: #ffc9c7; }
.seg-miss { color: var(--err-ink); }

/* ---------- галерея ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 760px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .gallery { grid-template-columns: 1fr; } }
.tpl { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: #fff; font-size: 14px; }
.tpl:hover { border-color: var(--accent); background: #f3fcff; }
.tpl .muted { font-size: 12px; }
.tpl-meta { font-size: 11px; color: var(--ink-2); margin-top: auto; padding-top: 4px; }
.tpl-pending { border-color: var(--warn-ink); background: var(--warn-bg); }
.tpl-warn { font-size: 12px; font-weight: 500; color: var(--warn-ink); }
.gallery + .note { margin-top: 12px; margin-bottom: 0; }

/* ---------- согласование ---------- */
.step-approve > .step-head { background: #eef6ff; }
.branches { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.branch { border-left: 3px solid var(--line-strong); padding: 6px 0 6px 12px; }
.branch-yes { border-left-color: var(--ok-ink); }
.branch-no { border-left-color: var(--err-ink); }
.branch-head { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--ink-2); }
.branch .step { margin-bottom: 8px; }
.preview li.sub { list-style: none; color: var(--ink-2); }

/* ---------- мастер ---------- */
.stepper { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; counter-reset: none; }
.stepper li { flex: 1; min-width: 0; }
.stepper button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow); font-size: 13px; color: var(--muted); text-align: left; }
.stepper button:disabled { cursor: default; opacity: .55; box-shadow: none; background: transparent; }
.stepper-num { width: 22px; height: 22px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip-bg); border: 1px solid var(--line-strong); font-size: 12px; font-weight: 600; }
.stepper-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper .on button { color: var(--ink); font-weight: 600; }
.stepper .on .stepper-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper .done .stepper-num { background: var(--ok-bg); border-color: var(--ok-ink); color: var(--ok-ink); }
@media (max-width: 640px) { .stepper-title { display: none; } .stepper .on .stepper-title { display: inline; } .stepper li.on { flex: 3; } }
.wizard-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--line); flex-wrap: wrap; }
.wizard-nav .hint { margin: 0; flex: 1; text-align: right; }
.wizard-check .wizard-nav { border-top: 0; margin-top: 0; }
.summary { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; margin-bottom: 12px; }
.lead { margin: -6px 0 14px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 14px; }
@media (max-width: 640px) { .tiles-3 { grid-template-columns: 1fr; } }
.panel { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
h3 { font-size: 15px; font-weight: 600; margin: 0; }
.ai-result { margin-bottom: 14px; }
.link { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; font-size: inherit; }

.created-actions { margin: 10px 0 0; }
