/* Лайнер CRM — вид как у Пачки и по цветам макетов Студии: светлый серо-голубой фон, белые панели, индиго-кнопка.
   Тёмная тема — тона MacBook Midnight. Переключатель внизу меню (запоминается в браузере). */
:root {
  --bg: #EEF0F5; --panel: #FFFFFF; --panel-2: #F7F8FB; --side: #FFFFFF; --line: #E2E5EC; --line-2: #EDEFF4;
  --ink: #1C1F26; --ink-2: #5E6573; --ink-3: #8D94A3;
  --accent: #4F46E5; --accent-ink: #FFFFFF; --accent-soft: #E7E8FD; --nav-on: #6EA8F7;
  --green: #1F9D55; --green-soft: #E3F4EA; --orange: #F5A55B; --orange-soft: #FFF1E3; --orange-line: #F3B87C;
  --red: #D64545; --red-soft: #FBE4E4; --blue-soft: #E5EEFC; --violet-soft: #EEEAFD;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 14px rgba(20, 24, 40, .04);
  --r: 14px; --r-s: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0F17; --panel: #151A24; --panel-2: #1B2130; --side: #11151E; --line: #262D3B; --line-2: #1F2533;
    --ink: #E8EBF2; --ink-2: #A3AABA; --ink-3: #6E7687;
    --accent: #6C63FF; --accent-soft: #24234A; --nav-on: #2B3F66;
    --green: #34C47A; --green-soft: #12301F; --orange: #F5A55B; --orange-soft: #3A2814; --orange-line: #7A4E22;
    --red: #F06A6A; --red-soft: #3A1A1D; --blue-soft: #18263D; --violet-soft: #231F3D;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0F17; --panel: #151A24; --panel-2: #1B2130; --side: #11151E; --line: #262D3B; --line-2: #1F2533;
  --ink: #E8EBF2; --ink-2: #A3AABA; --ink-3: #6E7687;
  --accent: #6C63FF; --accent-soft: #24234A; --nav-on: #2B3F66;
  --green: #34C47A; --green-soft: #12301F; --orange: #F5A55B; --orange-soft: #3A2814; --orange-line: #7A4E22;
  --red: #F06A6A; --red-soft: #3A1A1D; --blue-soft: #18263D; --violet-soft: #231F3D;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }

/* ── каркас ── */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 14px 16px; }
.logo { font-weight: 800; letter-spacing: .02em; font-size: 16px; padding: 0 10px 26px; }
.logo span { color: var(--ink-3); font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--r-s); color: var(--ink-2); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.on { background: var(--nav-on); color: #fff; }
.nav .badge { margin-left: auto; background: var(--orange); color: #fff; border-radius: 20px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.side-foot { margin-top: auto; padding: 0 10px; font-size: 12px; color: var(--ink-3); }
.side-foot b { display: block; color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.side-foot .row { display: flex; gap: 6px; margin-top: 12px; }
.main { min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── кнопки и поля ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.green { background: var(--green-soft); border-color: transparent; color: var(--green); }
.btn.danger { background: var(--red-soft); border-color: transparent; color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.inp, select.inp, textarea.inp { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--panel); outline: none; }
textarea.inp { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lbl { display: block; font-size: 12px; color: var(--ink-3); margin: 12px 0 5px; }
.chip { height: 28px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); cursor: pointer; font-size: 12.5px; }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.muted { color: var(--ink-3); }
.err { color: var(--red); font-size: 13px; }

/* ── шапка канбана ── */
.bar { display: flex; align-items: center; gap: 10px; padding: 18px 22px 8px; flex-wrap: wrap; }
.search { flex: 1; min-width: 240px; max-width: 520px; position: relative; }
.search .inp { padding-left: 36px; }
.search svg { position: absolute; left: 12px; top: 11px; width: 16px; height: 16px; color: var(--ink-3); }
.bar .sp { flex: 1; }
.views { display: flex; gap: 6px; padding: 4px 22px 12px; flex-wrap: wrap; align-items: center; }
.filters { margin: 0 22px 12px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; align-items: end; }
.filters .lbl { margin-top: 0; }
.check { display: flex; align-items: center; gap: 8px; height: 38px; cursor: pointer; }

/* ── канбан ── */
.board { flex: 1; min-height: 0; display: flex; gap: 12px; overflow-x: auto; padding: 4px 22px 22px; align-items: flex-start; }
.col { width: 232px; flex: none;   /* #187: было 310 — Иван хочет больше этапов на экране (≈4 вместо 3) */ display: flex; flex-direction: column; max-height: 100%; }
.col-head { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 10px 16px; position: relative;
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; overflow: hidden; }
.col-head::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--c, #9AA3B5); }
.col-head b { display: block; font-size: 14px; }
.col-head small { color: var(--ink-2); font-size: 12px; }
.col-head small .o { color: var(--orange); }
.col-head small span { white-space: nowrap; }   /* узкая колонка: переносим между счётчиками, а не «просрочено ⏎ 1» */
.col-head .btn { margin-left: auto; }
.col-body { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 80px; padding: 2px 2px 10px; border-radius: var(--r); }
.col-body.over { background: var(--accent-soft); }
.more { align-self: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; }
.card:hover { border-color: var(--ink-3); }
.card.overdue { border-color: var(--orange-line); box-shadow: 0 0 0 3px var(--orange-soft); }
.card.dragging { opacity: .4; }
.card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 650; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .who { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-2); font-size: 13px; }
.card .own { color: var(--ink-3); font-size: 12px; margin-top: 6px; }
.stickers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.st { font-size: 11.5px; padding: 3px 9px; border-radius: 6px; font-weight: 500; }
.st.unread { background: var(--green); color: #fff; }
.st.late { background: var(--orange); color: #fff; }
.st.rem { background: var(--blue-soft); color: var(--ink-2); }
.add-col { width: 220px; flex: none; }
.empty { color: var(--ink-3); font-size: 13px; padding: 8px 4px; }

/* ── карточка лида ── */
.lead { flex: 1; min-height: 0; display: grid; grid-template-columns: 360px 1fr; }
.lead-side { border-right: 1px solid var(--line); background: var(--panel-2); overflow-y: auto; padding: 18px 18px 28px; }
.lead-side .title { font-size: 16px; font-weight: 650; height: auto; min-height: 44px; padding: 10px 12px; }
.lead-side h4 { margin: 18px 0 6px; font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.lead-side .stack { display: flex; flex-direction: column; gap: 8px; }
.contact { display: grid; grid-template-columns: 112px 1fr 34px; gap: 6px; }
.contact select { padding: 0 6px; font-size: 13px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: 13px; margin-bottom: 10px; cursor: pointer; }
.lead-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 16px 22px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs .tab { padding: 7px 12px; border-radius: var(--r-s); cursor: pointer; font-weight: 600; color: var(--ink-2); border: 0; background: none; font-size: 15px; }
.tabs .tab.on { background: var(--accent-soft); color: var(--accent); }
.tabs .tab sup { color: var(--orange); font-size: 11px; }
.tabs .sp { flex: 1; }
.feed { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; max-width: 820px; }
.note .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; display: flex; gap: 8px; }
.note .meta .x { margin-left: auto; cursor: pointer; }
.note .txt { white-space: pre-wrap; word-wrap: break-word; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tile { border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--panel-2); max-width: 260px; }
.tile img, .tile video { display: block; max-width: 260px; max-height: 200px; }
.tile audio { display: block; width: 260px; }
.tile a.f { display: block; padding: 10px 12px; font-size: 13px; }
.lead-main.top #composer { order: -1; }
.lead-main.top .tabs { order: -2; }
.lead-main.top .composer { border-top: 0; border-bottom: 1px solid var(--line); }
.composer { border-top: 1px solid var(--line); padding: 12px 22px 16px; background: var(--panel); }
.composer textarea { border: 0; outline: none; resize: none; width: 100%; min-height: 54px; background: none; }
.composer .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer .tools .sp { flex: 1; }
.composer .ln-files { font-size: 12px; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--ink); color: var(--panel); cursor: pointer; display: grid; place-items: center; }
.send svg { width: 16px; height: 16px; }
.rem { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; max-width: 860px; }
.rem .box { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; background: var(--panel); }
.rem.late .box { background: var(--orange-soft); border-color: var(--orange-line); }
.rem.done .box { background: var(--green-soft); border-color: transparent; }
.rem .box b { display: block; }
.rem .acts { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.log { display: grid; grid-template-columns: 1fr auto; gap: 10px; max-width: 860px; }
.log .box { border-radius: var(--r); padding: 10px 16px; background: var(--panel); border: 1px solid var(--line); font-size: 13.5px; }
.log.stage .box { background: var(--blue-soft); border-color: transparent; }
.log.owner .box { background: var(--violet-soft); border-color: transparent; }
.log.merge .box, .log.create .box { background: var(--green-soft); border-color: transparent; }
.log.delete .box { background: var(--red-soft); border-color: transparent; }
.log .meta { font-size: 12px; color: var(--ink-3); }
.stub { margin: 40px auto; max-width: 520px; text-align: center; color: var(--ink-2); }
.stub h2 { color: var(--ink); }

/* ── списки (напоминания, настройки) ── */
.page { flex: 1; overflow-y: auto; padding: 22px; }
.page h1 { font-size: 22px; margin: 0 0 14px; }
.rows { display: flex; flex-direction: column; gap: 8px; max-width: 980px; }
.row-item { display: grid; grid-template-columns: 130px 1fr auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 16px; }
.row-item.late { background: var(--orange-soft); border-color: var(--orange-line); }
.row-item .when { font-weight: 600; font-size: 13px; }
.settings { display: grid; grid-template-columns: 320px 1fr; gap: 22px; align-items: start; max-width: 1200px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.ulist { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.ulist a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--r-s); color: var(--ink); }
.ulist a.on, .ulist a:hover { background: var(--accent-soft); }
.ulist small { color: var(--ink-3); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); max-width: 460px; }
.sw { position: relative; width: 40px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span { position: absolute; inset: 0; background: var(--line); border-radius: 20px; cursor: pointer; transition: .15s; }
.sw span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.sw input:checked + span { background: var(--green); }
.sw input:checked + span::after { left: 21px; }
.sw input:disabled + span { opacity: .5; }
.stage-row { display: grid; grid-template-columns: 44px 1fr 30px 30px 34px; gap: 6px; align-items: center; margin-bottom: 8px; max-width: 560px; }
.stage-row input[type=color] { width: 44px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-s); padding: 3px; background: var(--panel); }

/* ── модалка, тосты, мозг ── */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 14, 24, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 18px; width: min(560px, 100%); max-height: 92vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dups { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-s); background: var(--orange-soft); border: 1px solid var(--orange-line); font-size: 13px; }
.dups b { display: block; margin-bottom: 4px; }
.mg-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 0; font-size: 13px; cursor: pointer; }
.mg-row input { flex: none; }
.lead-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 18px; border-radius: 12px; z-index: 60; font-size: 13.5px; max-width: 90vw; }
.toast.bad { background: var(--red); color: #fff; }
.brain { position: fixed; right: 26px; bottom: 26px; width: 58px; height: 58px; border-radius: 50%; background: #11151E; border: 0; cursor: pointer; font-size: 28px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 40; }
.menu { position: absolute; right: 8px; top: 40px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s); box-shadow: var(--shadow); z-index: 20; padding: 4px; min-width: 180px; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }

/* ── вход ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login .btn { width: 100%; margin-top: 18px; }

/* ── телефон: меню снизу, одна колонка (полноценная мобильная версия — отдельным этапом) ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 100dvh; }
  .side { order: 2; flex-direction: row; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); }
  .logo, .side-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 8px; }
  .nav a.kb { display: none; }
  .bar, .views { padding-left: 16px; padding-right: 16px; }
  .board { padding: 4px 16px 16px; scroll-snap-type: x mandatory; }
  .col { width: calc(100vw - 48px); scroll-snap-align: start; }
  .lead { grid-template-columns: 1fr; overflow-y: auto; display: block; }
  .lead-side { border-right: 0; }
  .lead-main { min-height: 70vh; }
  .settings { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .row-item { grid-template-columns: 1fr; }
  .rem, .log { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .brain { bottom: 80px; right: 16px; }
}
/* в карточке лида «мозг» не должен закрывать кнопку отправки */
body.on-lead .brain, body.on-chat .brain { bottom: 104px; }

/* плашка «вышло обновление» */
.upd { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 100; display: flex; align-items: center;
  gap: 12px; padding: 10px 12px 10px 18px; border-radius: 100px; background: var(--ink); color: var(--panel);
  box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 14px; max-width: calc(100% - 32px); }

/* полоска лимитов Codex под логотипом (админам) — как в шапке пульта */
.logo { position: relative; }
.codex { position: relative; display: block; width: 100%; height: 5px; margin-top: 8px; padding: 0; border: 0; border-radius: 3px;
  background: var(--line); cursor: pointer; }
.codex > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; transition: width .4s ease, background-color .4s ease; }
.codex.is-off > i { width: 100% !important; background: repeating-linear-gradient(45deg, var(--line) 0 4px, var(--line-2) 4px 8px) !important; }
.codex.is-busy > i { animation: codex-pulse 1s ease-in-out infinite; }
@keyframes codex-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .codex > i { transition: none; } .codex.is-busy > i { animation: none; } }
.codex:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.codex-tip { position: absolute; left: 0; top: calc(100% + 10px); z-index: 50; min-width: 230px; padding: 10px 12px; border-radius: 10px;
  background: #12151E; color: #fff; border: 1px solid #2E3546; font-size: 12.5px; font-weight: 500; letter-spacing: 0; line-height: 1.55; text-align: left;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity .15s, transform .15s; }
.codex:hover .codex-tip, .codex:focus-visible .codex-tip, .codex.tip-on .codex-tip { opacity: 1; visibility: visible; transform: none; }
.codex-tip b { color: #B7B2FF; font-weight: 600; }
.codex-tip .row { display: flex; justify-content: space-between; gap: 14px; }
.codex-tip .sub { color: #A9AFBA; }

/* разбор работы менеджера — только админу */
.note.review { border-color: var(--orange-line); background: var(--orange-soft); }

/* оформленный текст комментариев (common/web/md.js) — в цветах CRM, в обеих темах */
.note .txt.md { white-space: normal; }
.note .md h4 { font-family: inherit; text-transform: none; font-size: 15px; font-weight: 700; color: var(--ink); margin: .8em 0 .3em; }
.note .md h4.md-h1 { font-size: 16px; }
.note .md b { color: var(--ink); }
.note .md .md-verdict { background: var(--accent-soft); border-left-color: var(--accent); }
.note .md code { background: var(--panel-2); }
.note .md a { color: var(--accent); }
.note .md td { background: var(--panel); border-top-color: var(--line-2); }
.note .md tbody tr:nth-child(even) td { background: var(--panel-2); }
.note .md td.c-first { color: var(--ink); }

/* #125: лого ведёт в пульт */
.logo a.home { color: inherit; text-decoration: none; }
.logo span a.home { color: inherit; }
.logo a.home:hover, .logo span a.home:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ───────── база знаний «Обучение» — common/web/kb.css (общая с Цехом видео) ───────── */

/* ───── #182: запись звонка — строка под вкладками и плавающая панель, CRM не блокируется ───── */
.callbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.lead-main.top .callbar { order: -2; }
.callbar .cb-title { font-weight: 600; font-size: 14px; color: var(--ink-2); margin-right: 4px; }
.callbar .cb-title.rec { color: var(--red); }
.callbar label.btn { cursor: pointer; }
body.rec-on::after { content: ''; position: fixed; inset: 0; border: 3px solid var(--red); pointer-events: none; z-index: 58; }
.recdock { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 59; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px 8px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  max-width: calc(100vw - 120px); flex-wrap: nowrap; white-space: nowrap; }   /* #186: «В карточку» не уезжает вниз */
.recdock b { font-variant-numeric: tabular-nums; }
.recdock .rd-who { color: var(--ink-2); font-size: 13px; max-width: 220px; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recdock .btn { flex: none; }
.recdock .rd-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: rd-blink 1.2s ease-in-out infinite; }
@keyframes rd-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .recdock .rd-dot { animation: none; } }
body.rec-on .toast { bottom: 86px; }
.recdock .rd-short { display: none; }
@media (max-width: 860px) {
  .callbar { padding: 10px 14px; }
  /* телефон: одна строка над нижним меню, левее «мозга» */
  .recdock { left: 10px; right: 84px; bottom: calc(72px + env(safe-area-inset-bottom)); transform: none; max-width: none;
    flex-wrap: nowrap; gap: 8px; padding: 6px 8px 6px 12px; }
  .recdock .rd-who, .recdock .rd-long { display: none; }
  .recdock .rd-short { display: inline; }
  body.rec-on .toast { bottom: 140px; }
}

/* #132: записи встречи — плеер пошире, подпись под ним */
.tile.tile-video { width: 360px; max-width: 100%; }
.tile.tile-video video { width: 100%; max-width: 100%; max-height: 240px; background: #000; border-radius: 8px; display: block; }

/* ── переписка: ЧатБоты, Корп чаты, вкладка «Переписка» (#148) ── */
.nav .badge.g { background: var(--green); }
.tabs .tab sup.g { color: var(--green); }
.chats { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px 1fr; }
.ch-list { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.ch-top { padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--line-2); }
.ch-top .search { max-width: none; min-width: 0; }
.ch-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-chips .chip b { font-weight: 600; opacity: .7; margin-left: 2px; }
.ch-items { flex: 1; overflow-y: auto; }
.ch-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; color: var(--ink);
  border-bottom: 1px solid var(--line-2); }
.ch-item:hover { background: var(--panel-2); }
.ch-item.on { background: var(--accent-soft); }
.ava { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 14px;
  color: hsl(var(--h) 45% 30%); background: hsl(var(--h) 70% 88%); flex: none; }
:root[data-theme="dark"] .ava { color: hsl(var(--h) 70% 85%); background: hsl(var(--h) 35% 26%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ava { color: hsl(var(--h) 70% 85%); background: hsl(var(--h) 35% 26%); } }
.ava.big { width: 44px; height: 44px; }
.ch-ic { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; font: 700 9px/17px sans-serif; text-align: center;
  font-style: normal; color: #fff; background: var(--ink-3); border: 2px solid var(--panel); }
.ch-ic.tg { background: #2AABEE; } .ch-ic.max { background: #6C4CF5; } .ch-ic.wa { background: #25D366; }
.ch-ic.ig { background: #E1306C; } .ch-ic.vk { background: #0077FF; }
.ch-mid { min-width: 0; display: flex; flex-direction: column; }
.ch-mid b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-mid small { color: var(--ink-3); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.ch-lead { color: var(--green); font-weight: 600; }
.ch-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; align-self: start; padding-top: 2px; }
.ch-end time { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.ub { background: var(--green); color: #fff; border-radius: 20px; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; line-height: 20px;
  text-align: center; padding: 0 6px; }
.wt { color: var(--orange); font-size: 12px; line-height: 1; }
.ch-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.ch-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ch-back { display: none; }
.ch-who { min-width: 200px; flex: 1; }
.ch-acts .btn { max-width: 340px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 28px; }
.ch-who h2 { margin: 0; font-size: 17px; }
.ch-who .muted { font-size: 12.5px; }
.ch-state { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.ch-state .s-asked { color: var(--orange); } .ch-state .s-lead { color: var(--green); } .ch-state .s-funnel { color: var(--ink-2); }
.ch-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-feed, .lead-main .feed:has(.ch-tabs) { gap: 6px; }
.ch-feed { flex: 1; overflow-y: auto; padding: 16px 22px; display: flex; flex-direction: column; gap: 6px; }
.ch-pane #composer .composer { border-top: 1px solid var(--line); }
.ch-ro { padding: 12px 22px; font-size: 13px; color: var(--ink-3); background: var(--panel); border-top: 1px solid var(--line); }
.ch-warn { padding: 10px 84px 10px 22px; font-size: 13px; line-height: 1.45; color: #7a4a00; background: #fff6e0; border-top: 1px solid #f0d9a4; }
.ch-hint { padding: 6px 84px 6px 22px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
:root[data-theme="dark"] .ch-warn { color: #f3d08a; background: #3a2c10; border-top-color: #5a4418; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ch-warn { color: #f3d08a; background: #3a2c10; border-top-color: #5a4418; } }
.b-row { display: flex; }
.b-row.out { justify-content: flex-end; }
.b { max-width: min(560px, 78%); padding: 8px 12px 6px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
  border-bottom-left-radius: 6px; overflow-wrap: anywhere; }
.b.out { background: var(--accent-soft); border-color: transparent; border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }
.b.out.bot { background: var(--panel-2); border: 1px dashed var(--line); }
.b-who { font-size: 11.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.b.bot .b-who { color: var(--ink-3); }
.b-txt { white-space: pre-wrap; }
.b-txt p { margin: 0 0 4px; } .b-txt p:last-child { margin: 0; }
.b-txt blockquote, .b-txt .md-verdict { margin: 4px 0; padding: 0 0 0 10px; border: 0; border-left: 3px solid var(--line); border-radius: 0;
  background: none; color: var(--ink-2); box-shadow: none; }
.b-time { font-size: 10.5px; color: var(--ink-3); text-align: right; margin-top: 2px; }
.b-files { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 4px; }
.b-files img, .b-files video { display: block; max-width: 280px; max-height: 320px; border-radius: 10px; }
.b-files video.round { width: 220px; height: 220px; object-fit: cover; border-radius: 50%; }
.b-files audio { width: 260px; max-width: 100%; }
.b-files a.f { font-size: 13px; }
.b-act { font-size: 12.5px; color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 3px 10px; }
.b-act i { font-style: normal; color: var(--ink-3); font-size: 10.5px; margin-left: 4px; }
.b-sys { align-self: center; font-size: 11.5px; color: var(--ink-3); text-align: center; max-width: 80%; }
.b-day { display: flex; justify-content: center; margin: 8px 0 2px; }
.b-day span { font-size: 11.5px; color: var(--ink-3); background: var(--panel-2); border-radius: 10px; padding: 2px 10px; }
.ch-tabs { position: sticky; top: -18px; z-index: 2; display: flex; gap: 6px; flex-wrap: wrap; background: var(--bg); padding: 6px 0 8px; margin-top: -6px; }
.ch-tabs .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-left: 4px; vertical-align: middle; }
.ch-sub { font-size: 12.5px; margin-bottom: 6px; }
.bind-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 50vh; overflow-y: auto; }
.bind-row { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--panel); cursor: pointer; }
.bind-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.bind-row .muted { font-size: 12.5px; }
@media (max-width: 860px) {
  .chats { grid-template-columns: 1fr; }
  .chats .ch-pane { display: none; }
  .chats.has-open .ch-list { display: none; }
  .chats.has-open .ch-pane { display: flex; }
  .ch-back { display: inline-flex; }
  .ch-head { padding: 10px 16px; gap: 10px; }
  .ch-who { flex: 1 1 200px; }
  .ch-state { order: 3; width: 100%; }
  .ch-acts { order: 4; width: 100%; }
  .ch-feed { padding: 12px 16px; }
  .b { max-width: 88%; }
  .ch-top { padding: 12px 16px 8px; }
  .ch-item { padding: 10px 16px; }
  .nav a { padding: 6px 4px; }
}

/* ── ИИ в карточке лида (этап 4) ── */
body.ai-on .brain { display: none; }
.ai-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 100vw; z-index: 70; background: var(--panel);
  border-left: 1px solid var(--line); box-shadow: -10px 0 34px rgba(20, 24, 40, .14); display: flex; flex-direction: column; }
.ai-head { display: flex; align-items: center; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ai-head b { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ai-head > :not(b):not(.sp) { flex-shrink: 0; }     /* #241: кнопки и крестик из панели не выталкиваются никогда */
.ai-head .chip { height: 22px; font-size: 11.5px; cursor: default; }
.ai-head .sp { flex: 1; }
.ai-model { position: relative; display: inline-flex; flex-shrink: 0; }
.ai-model select { -webkit-appearance: none; appearance: none; height: 24px; padding: 0 18px 0 8px; border: 0; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  field-sizing: content; }    /* ширина — по выбранной модели, а не по самой длинной подписи */
.ai-model::after { content: '▾'; position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--accent); pointer-events: none; }
.ai-mem { padding: 10px 14px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; gap: 8px; }
.ai-mem-h { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.ai-mem-h .muted { font-size: 12px; }
.ai-mem textarea { min-height: 130px; font-size: 13px; }
.ai-mem .row { display: flex; gap: 8px; justify-content: flex-end; }
.ai-feed { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-empty { color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.ai-empty .muted { font-size: 13px; }
.ai-m { max-width: 94%; padding: 9px 12px; border-radius: 14px; overflow-wrap: anywhere; }
.ai-m.user { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 6px; }
.ai-m.user .txt { white-space: pre-wrap; }
.ai-m.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line-2); border-bottom-left-radius: 6px; }
.ai-m .md p { margin: 0 0 6px; } .ai-m .md p:last-child { margin: 0; }
.ai-m .md ul, .ai-m .md ol { margin: 4px 0; padding-left: 20px; }
.ai-who { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; }
.ai-thinking { color: var(--ink-3); font-size: 13px; }
.ai-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.ai-files img { max-width: 200px; max-height: 150px; border-radius: 8px; display: block; }
.ai-files a.f { font-size: 13px; }
.ai-acts { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ai-act { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--panel); }
.ai-act-h { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.ai-act-b { font-size: 13.5px; white-space: pre-wrap; margin: 3px 0 7px; }
.ai-act-btns { display: flex; gap: 6px; }
.ai-act-res { font-size: 12.5px; color: var(--ink-2); }
.ai-act.applied { border-color: var(--green); } .ai-act.applied .ai-act-res { color: var(--green); font-weight: 600; }
.ai-act.declined { opacity: .55; } .ai-act.failed { border-color: var(--red); } .ai-act.failed .ai-act-res { color: var(--red); }
.ai-comp { border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.ai-comp textarea { border: 0; outline: none; resize: none; width: 100%; min-height: 64px; background: none; }
.ai-comp .tools { display: flex; align-items: center; gap: 8px; }
.ai-comp .tools .sp { flex: 1; }
.ai-short { display: none; }
@media (max-width: 860px) {
  .ai-panel { width: 100vw; border-left: 0; }
  .ai-head { padding: 10px 10px; gap: 4px; }
  .ai-head .chip, .ai-long { display: none; }
  .ai-short { display: inline; }
}
