/* Dialogue workspace — the daily operating screen.
 *
 * Three regions, full height, one right panel. The page itself never scrolls:
 * the queue, the message history and the context rail each scroll on their own,
 * so a long transcript cannot push the composer off the window — which is
 * exactly what the previous layout did (composer top 887 in a 900px window,
 * 13px of it visible).
 *
 * Own file. cabinet-system.css and redesign.css both style .chatpane, between
 * them 113 rules; this screen uses its own .dw- namespace so nothing inherits
 * the four-column grid it replaces.
 */

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

.dw {
  display: flex;
  /* 100% of the CONTENT COLUMN, not of the window. At 100vh this screen was as
     tall as the viewport while starting below a topbar and a header, so its
     bottom — the composer — hung off the end of the page. Measured inside the
     real shell on 2026-08-13: page top 94, height 900, bottom 994 in a 900px
     window, and 124px of page scroll on a screen that must never scroll. */
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--rp-bg, #070b12);
  color: var(--rp-ink, var(--lw-ink));
}

/* ── queue ─────────────────────────────────────────────────────────────── */
.dw-queue {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-inline-end: 1px solid rgb(var(--ch-line) / .16);
}
/* THE COLLAPSED SLIVERS ARE GONE.
   A closed panel is 0px and its grid track disappears; the layout contract in
   src/pack-design.css declares all four states. A 48-56px strip with a chevron
   in it is neither the panel nor out of the way, which is the one thing that
   contract names outright — and the way back is now a labelled button in the
   header of whatever took the space, not a glyph on a stub. */
.dw-queue-head { padding: 12px; border-bottom: 1px solid rgb(var(--ch-line) / .12); position: relative; }
.dw-queue-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* СТРОКА НАЗЫВАЕТ СДЕЛКУ (26.09.2026): под именем клиента — стадия · сумма ·
   ответственный карточки (main.js, ChatDealLine). Строки без карточки её не
   рисуют вовсе. Каждая часть сокращается сама и не распирает очередь. */
.chatrow-deal {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 0;
  min-width: 0; max-width: 100%;
  font-size: 11px; line-height: 1.35; color: var(--lw-ink-soft, var(--rp-ink-2));
}
.chatrow-deal > span {
  min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chatrow-deal > span + span::before {
  content: "·"; margin-inline: 5px; color: var(--lw-ink-dim, var(--rp-ink-3));
}
.chatrow-deal-stage { font-weight: 600; color: var(--lw-ink, var(--rp-ink)); }
.chatrow-deal-stage.is-won { color: var(--rp-green, var(--lw-ink)); }
.chatrow-deal-stage.is-lost { color: var(--lw-ink-dim, var(--rp-ink-3)); }
.chatrow-deal-value { font-variant-numeric: tabular-nums; }
.chatrow-deal-value.is-default { color: var(--lw-ink-dim, var(--rp-ink-3)); }

.dw-search { position: relative; margin-bottom: 10px; }
/* Was the Unicode glyph "⌕" in the JSX — not universally covered by every
   font, and where it falls back it renders as an unrelated dingbat sitting
   hard against the placeholder text. Drawn instead: a circle + a handle,
   the same technique .rp-search-glyph/.crm-search-glyph already use
   elsewhere in this codebase, which cannot fail to render. */
.dw-search-ico {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  width: 11px; height: 11px; border-radius: 50%;
  border: 1.5px solid var(--lw-ink-dim);
}
.dw-search-ico::after {
  content: ""; position: absolute; inset-inline-end: -4px; bottom: -3px;
  width: 5px; height: 1.5px; background: var(--lw-ink-dim);
  transform: rotate(45deg);
}
.dw-search-input {
  width: 100%; height: 34px; padding-block: 0 0; padding-inline: 28px 10px; border-radius: 9px;
  background: rgb(var(--ch-lift) / .04); border: 1px solid rgb(var(--ch-line) / .22);
  color: var(--lw-ink); font: inherit; font-size: 13px;
}
.dw-tabs { display: flex; flex-wrap: wrap; gap: 5px; }

/* CHANNELS ARE A GRID, NOT A WRAPPING ROW.
   Flex-wrap packed them by width, so «WhatsApp 9» and «Website 2» ended up
   different sizes on ragged rows and the channel marks — round tiles, the most
   regular thing on the panel — landed at six different x-positions. Two equal
   columns put every mark on the same two lines down the panel, which is what
   «поставить симметрично кружочки» asks for and what a grid is for. */
.dw-channels {
  margin-top: 7px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px;
}
.dw-tab, .dw-ch {
  height: 27px; padding: 0 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgb(var(--ch-line) / .2); background: rgb(var(--ch-lift) / .03);
  color: var(--lw-ink-soft); font: inherit; font-size: 12px;
  display: inline-flex; align-items: center; gap: 5px;
}
/* The chip is a fixed cell now, so its parts have to place themselves rather
   than let the widest name push the count off the end: the mark is rigid, the
   name takes the slack and ellipsises, the count sits against the right edge
   at a constant distance on every row. */
.dw-ch { padding: 0 8px; min-width: 0; }
.dw-ch .chan-mark { flex: 0 0 auto; }
.dw-ch-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start;
}
.dw-ch .dw-tab-n { flex: 0 0 auto; }
.dw-tab.is-on, .dw-ch.is-on {
  color: var(--lw-ink); border-color: rgb(var(--ch-accent) / .5); background: rgb(var(--ch-blue) / .16);
}
.dw-tab-n { color: var(--lw-ink-dim); font-size: 11px; }
.dw-queue-head .dw-search { padding-inline-end: 34px; }

/* ── centre ────────────────────────────────────────────────────────────── */
.dw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

.dw-head {
  height: 56px; min-height: 56px; display: flex; align-items: center; gap: 9px;
  padding: 0 16px; border-bottom: 1px solid rgb(var(--ch-line) / .16);
}
.dw-avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: rgb(var(--ch-accent) / .16); color: var(--lw-ink-bright); font-weight: 600; font-size: 13px;
}
.dw-head-name { font-size: 15px; color: var(--lw-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
.dw-spacer { flex: 1; }

/* The only scrolling region in the centre column. */
.dw-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 14px 16px; }
.dw-empty-state { display: grid; place-items: center; height: 100%; color: var(--lw-ink-dim); }

/* The composer lives in src/composer-kit.css and is shared with the Lead
   Workspace. Nothing here may restyle .ck-* — one composer, one set of rules. */

/* ── rail ──────────────────────────────────────────────────────────────── */
.dw-rail {
  width: 264px; min-width: 264px; overflow-y: auto; min-height: 0;
  padding: 12px; border-inline-start: 1px solid rgb(var(--ch-line) / .16);
}
.dw-rail-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dw-rail-title {
  margin: 0; font-size: 14px; color: var(--lw-ink); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dw-facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; margin: 0 0 12px; }
.dw-facts dt { color: var(--lw-ink-soft); font-size: 12px; }
.dw-facts dd { margin: 0; color: var(--lw-ink); font-size: 13px; min-width: 0; }
.dw-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dw-actions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.dw-btn-row { display: flex; gap: 6px; align-items: center; }
.dw-btn-row .dw-btn { flex: 1; }
.dw-btn {
  height: 34px; padding: 0 12px; border-radius: 10px; cursor: pointer; text-align: start;
  border: 1px solid rgb(var(--ch-line) / .24); background: rgb(var(--ch-lift) / .03);
  color: var(--lw-ink-bright); font: inherit; font-size: 13px;
}
.dw-btn[disabled] { opacity: .45; cursor: not-allowed; }
.dw-btn-primary { border-color: rgb(var(--ch-accent) / .5); background: rgb(var(--ch-blue) / .18); color: var(--lw-ink); font-weight: 600; }

.dw-sec { border-top: 1px solid rgb(var(--ch-line) / .1); padding: 8px 0; }
.dw-sec summary { cursor: pointer; color: var(--lw-ink-soft); font-size: 12px; list-style: none; }
.dw-sec summary::-webkit-details-marker { display: none; }
.dw-sec summary::before { content: "▸ "; }
.dw-sec[open] summary::before { content: "▾ "; }
.dw-tech p { margin: 6px 0 0; font-size: 12px; color: var(--lw-ink-bright); word-break: break-all; }

/* ── shared ────────────────────────────────────────────────────────────── */


/* Small shared bits this screen still owns. The composer's equivalents live in
   composer-kit.css under .ck-; these are for the queue and the rail. */
.dw-empty { color: var(--lw-ink-dim); font-size: 12px; margin: 8px 0 0; line-height: 1.45; }
.dw-warn { color: var(--lw-warm); }
.dw-dim { color: var(--lw-ink-dim); }

/* Пустая середина с дверями — 1 сентября. Одна строка «Выберите диалог
   слева» занимала полтора экрана высотой; блок дверей встал ровно туда,
   где смотреть было не на что, и только пока диалог не выбран. */
.dw-empty-doors {
  place-items: start stretch;
  align-content: start;
  overflow-y: auto;
  padding: 22px 20px 26px;
  min-width: 0;
}
.dw-empty-doors .dw-empty-lead { margin: 0; font-size: 14px; }
.dw-empty-doors .bd-doors { margin-top: 14px; }

/* ЗНАЧОК ЛУПЫ НАЛЕЗАЛ НА ТЕКСТ (9 сентября 2026).
   Владелец прислал скриншот: в поле «Поиск по диалогам» слева артефакт,
   налезающий на первую букву. Артефакт — это сам значок поиска.

   Причина в весе правил, а не в разметке. Выше задано
   padding-inline: 28px 10px — ровно чтобы освободить место под кружок,
   который стоит в 10px от края и занимает 11px. Но общее правило кабинета
   `.workspace input[type="search"] { padding: 11px 13px }` весит больше
   (класс + атрибут против одного класса) и выигрывает: текст начинается с
   13px и садится прямо на значок.

   Поэтому вес поднят до трёх классов — этого хватает, чтобы перебить
   общее правило, и ни одно другое поле кабинета не затронуто. */
.workspace .dw-search .dw-search-input {
  padding-block: 0;
  padding-inline: 30px 10px;
}

/* ОЖИДАНИЕ ПРОТИВ НОРМЫ ОТВЕТА (23 сентября 2026, аудит C §2.5).
   «Ждёт ответа · 44 д» было покрашено так же, как «Отвечено · 45 д». Теперь
   время у строки, которая ждёт ответа, — плашка: дольше нормы первого ответа
   янтарная, дольше двух норм красная. Строку рисует ChatRow из main.js; отметку
   несёт обёртка .dw-row (data-sla), поэтому разметка строки прежняя. Цвет —
   не единственный знак: у обёртки подсказка, у диктора — .dw-sr с тем же текстом. */
.dw-row { position: relative; }
.dw-row[data-sla="late"] .chatrow-time,
.dw-row[data-sla="breach"] .chatrow-time {
  padding: 0 7px;
  border-radius: 999px;
  font-weight: 650;
  line-height: 17px;
}
.dw-row[data-sla="late"] .chatrow-time {
  color: var(--bd-warn);
  background: rgb(var(--ch-warm4) / .16);
  box-shadow: inset 0 0 0 1px rgb(var(--ch-warm4) / .38);
}
.dw-row[data-sla="breach"] .chatrow-time {
  color: var(--bd-risk);
  background: rgb(var(--ch-red2) / .16);
  box-shadow: inset 0 0 0 1px rgb(var(--ch-red2) / .42);
}
.dw-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Порядок на «Ждут ответа»: «Дольше всех ждут» / «Сначала новые». Пунктир —
   чтобы переключатель порядка не читался как ещё одна вкладка. */
.dw-sort { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.dw-sort-btn {
  height: 25px; padding: 0 9px; border-radius: 999px; cursor: pointer;
  border: 1px dashed rgb(var(--ch-line) / .3); background: transparent;
  color: var(--lw-ink-soft); font: inherit; font-size: 11.5px;
}
.dw-sort-btn.is-on {
  color: var(--lw-ink); border-style: solid;
  border-color: rgb(var(--ch-accent) / .5); background: rgb(var(--ch-blue) / .12);
}

/* Что агент уже понял про человека — длинный текст переносится, а не режется. */
.dw-fact-long { overflow-wrap: anywhere; line-height: 1.4; }

/* ОПАСНАЯ ЗОНА — последняя в панели, за красной чертой (аудит C §1 G11).
   Без letter-spacing: разрядка рвёт связное арабское письмо. */
.dw-danger {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgb(var(--ch-red2) / .45);
}
.dw-danger-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  color: var(--bd-risk);
}
.dw-danger .dw-del { margin-top: 0; }

/* «← НАЗАД» (24 сентября 2026, владелец: «нет нигде стрелочки назад»). Первой
   в шапке переписки, на любой ширине: уводит туда, откуда человек пришёл, или
   на «Обзор»; на телефоне, пока открыта переписка, — сначала к очереди. Та же
   кнопка над поиском очереди (dw-back-queue) видна только на телефоне — там
   очередь во весь экран, и шапки переписки нет. Вид — как у соседних кнопок
   шапки («Очередь», «Контекст клиента»), только текст ярче: это выход. */
.dw-back {
  display: inline-flex; align-items: center; flex: 0 0 auto;
  height: 32px; min-height: 0; padding: 0 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid rgb(var(--ch-line) / .24); background: rgb(var(--ch-lift) / .04);
  color: var(--lw-ink); font: inherit; font-size: 13px; white-space: nowrap;
}
.dw-back:hover { border-color: rgb(var(--ch-accent) / .5); color: var(--lw-ink-bright); }
.dw-back:focus-visible { outline: 2px solid rgb(var(--ch-accent) / .85); outline-offset: 2px; }
.dw-back-queue { display: none; }
/* Обёртки чипов шапки и заметка о сохранённом списке — для телефона. На
   широком экране заметки нет, а обёртки не участвуют в раскладке
   (display: contents) — шапка та же, что была. */
.dw-head-chips, .dw-head-status { display: contents; }
.dw-queue-stale { display: none; }

/* ОДНА ПАНЕЛЬ НА ТЕЛЕФОНЕ (23 сентября 2026, аудит C §1 G2).
   Замер на 390 px: очередь фиксированные 300 px, переписке оставалось 40 px, и
   текст ломался по букве — у этого файла не было ни одного @media. Ниже 760 px
   видна одна панель: очередь во весь экран; тап по строке — переписка во весь
   экран с «← Диалоги»; «Контекст клиента» — панель во весь экран со своей
   кнопкой «Закрыть». Какая панель видна, решает класс dw-pane-* на .dw (его
   ставит DialogueWorkspace.js). Селекторы тяжелее правил pack-design.css,
   который грузится позже и задаёт колонки. */
@media (max-width: 760px) {
  .dw.dw-pane-queue, .dw.dw-pane-chat,
  .dw.has-queue.dw-pane-queue, .dw.has-queue.dw-pane-chat,
  .dw.has-context.dw-pane-queue, .dw.has-context.dw-pane-chat,
  .dw.has-queue.has-context.dw-pane-queue, .dw.has-queue.has-context.dw-pane-chat {
    grid-template-columns: minmax(0, 1fr);
  }
  .dw.dw-pane-queue > .dw-main,
  .dw.dw-pane-queue > .dw-rail { display: none; }
  .dw.has-queue.has-context.dw-pane-queue > .dw-queue { display: flex; }
  .dw.dw-pane-chat > .dw-queue { display: none; }
  .dw.has-context.dw-pane-chat > .dw-main { display: none; }

  .dw .dw-head .dw-back { padding: 0 8px; font-size: 12.5px; }
  /* В очереди во весь экран шапки переписки нет — «← Назад» над поиском. */
  .dw .dw-queue-head .dw-back-queue { display: inline-flex; margin-bottom: 10px; }
  /* Шапка переписки: назад · аватар · имя · «Контекст клиента». Имя берёт
     остаток и сокращается; полное — первой строкой в «Контексте клиента». */
  .dw .dw-head { padding: 0 10px; gap: 7px; }
  .dw .dw-avatar { flex: 0 0 auto; }
  .dw .dw-head-name { flex: 1 1 auto; min-width: 0; max-width: none; }
  .dw .dw-head .dw-spacer { display: none; }
  .dw .dw-head-chips, .dw .dw-head-status { display: none; }
  .dw .dw-head .dw-panel-context { padding: 0 8px; font-size: 12.5px; }
  .dw .dw-queue-stale { display: block; }
  .dw .dw-queue-head .dw-panel-hide { display: none; }
  .dw .dw-queue-head .dw-search { padding-inline-end: 0; }
}
