/* Дополнения AgentDO к site.css. Только то, чего нет в UI-ките. */

/* Поля с длинным текстом: база знаний, инструкции */
textarea.tall { min-height: 320px; font-family: inherit; }
textarea.mid { min-height: 160px; }
.stack.wide { max-width: none; justify-items: stretch; }
.stack.wide .actions, .stack.wide .button { justify-self: start; }
.field-note { font-size: 13px; color: var(--muted); margin: -4px 0 4px; }

/* Поле «только чтение» с кнопкой копирования */
.copy-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 12px; }
.copy-row input { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.copy-row .button { white-space: nowrap; }

pre.code-block { font-size: 13px; white-space: pre; margin: 8px 0 16px; }

/* Переписка: журнал и песочница */
.chat-log { display: flex; flex-direction: column; gap: 2px; }
.chat-log .bubble { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.op { margin-left: auto; background: var(--white); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
.bubble.handoff { box-shadow: inset 0 0 0 2px var(--wait); }
.bubble .who { display: block; font-size: 11px; font-weight: 600; opacity: .65; margin-bottom: 2px; }
.turn-meta { font-size: 12px; color: var(--muted); margin: -4px 0 12px auto; max-width: 80%; text-align: right; }
.turn-meta.left { margin-left: 0; text-align: left; }
.turn-meta b { color: var(--text-soft); font-weight: 600; }
.turn-meta .bad { color: var(--bad); }
.day-sep { text-align: center; font-size: 12px; color: var(--muted); margin: 12px 0; }

/* Песочница */
.sandbox { display: grid; gap: 12px; }
.sandbox-log { min-height: 300px; max-height: 60vh; overflow-y: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sandbox-log .empty-hint { color: var(--muted); font-size: 14px; margin: auto; text-align: center; }
.sandbox-input textarea { min-height: 70px; }
.sandbox-input .actions { margin-top: 8px; }
.typing { color: var(--muted); font-size: 13px; margin: 0 0 8px; }

/* Таблица журнала */
td.nowrap, th.nowrap { white-space: nowrap; }
td .muted { font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.filters label { margin: 0; }

/* Вход */
body.auth { min-height: 100vh; display: grid; align-content: center; padding: 16px; }
body.auth .brand { justify-content: center; margin-bottom: 4px; }

.inline-form { display: inline; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

/* Значок агента в списках: как значок канала, только в цветах AgentDO */
.chan-tag.agent-tag { display: inline-flex; align-items: center; justify-content: center; width: 40px; min-width: 40px; height: 40px; padding: 0; border-radius: 11px; border-color: transparent; background: #16181d; color: #ffc400; font-size: 18px; margin: 0; }
.chan-tag.brand-universal { --brand: #3b3f46; }
.chan-tag.brand-universal svg { width: 20px; height: 20px; }
:root[data-theme=dark] .chan-tag.agent-tag { box-shadow: inset 0 0 0 1px #3a3d44; }

/* Подсказки в пустых полях не должны выглядеть как заполненные данные */
textarea::placeholder, input::placeholder { color: var(--off); font-style: italic; opacity: 1; }
#site-result > * { margin-top: 12px; }
#site-result ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }

/* Адрес сайта: протокол списком + домен */
.url-row { display: flex; gap: 8px; align-items: stretch; margin-top: 6px; }
.url-row select { flex: 0 0 auto; width: auto; }
.url-row input { flex: 1; min-width: 0; }
.url-row .button { flex: 0 0 auto; }
@media (max-width: 520px) { .url-row { flex-wrap: wrap; } .url-row input { flex: 1 1 0; } .url-row .button { flex: 1 0 100%; } }

/* Песочница: строка состояния и переключатель */
.sandbox-status:empty { display: none; }
.sandbox-status .typing, .sandbox-status .error { margin: 0; }
.sandbox-status .notice { margin: 0; }
.sandbox-status .notice p { margin: 0 0 6px; } .sandbox-status .notice p:last-child { margin: 0; }
.sandbox-instant { align-self: center; font-size: 14px; margin: 0 4px; width: auto; }

/* Значок источника данных */
.chan-tag.source-tag { display: inline-flex; align-items: center; justify-content: center; width: 40px; min-width: 40px; height: 40px; padding: 0; border-radius: 11px; border-color: transparent; background: #3b3f46; color: #fff; margin: 0; }
.sandbox-phone { margin: 0; align-items: end; }
.sandbox-phone label { flex: 0 1 320px; }
.sandbox-phone .muted { font-size: 13px; flex: 1 1 240px; padding-bottom: 10px; }
.crm-details { text-align: left; margin-top: 4px; }
.crm-details summary { cursor: pointer; text-align: right; }
.crm-details pre { font-size: 12px; max-height: 260px; overflow: auto; text-align: left; margin: 6px 0 0; }

/* Заказы */
.card h3 { margin: 18px 0 8px; font-size: 16px; }
.order-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.order-list li { padding: 8px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); font-size: 14px; }
.order-card { margin-top: 8px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line, rgba(127,127,127,.25)); font-size: 14px; text-align: left; }
.order-lines { white-space: pre-wrap; margin: 6px 0 0; }
.order-card details { margin-top: 6px; }
.tool-step { margin: 6px 0; font-size: 13px; }
.tool-step b { font-family: ui-monospace, monospace; }
.sb-files a { display: inline-block; margin-top: 6px; }
.tool-step pre { white-space: pre-wrap; word-break: break-word; }
.catalog-table td, .catalog-table th { padding: 8px 10px; vertical-align: top; text-align: left; border-bottom: 1px solid var(--line, rgba(127,127,127,.2)); }
.catalog-table .num { text-align: right; white-space: nowrap; }
.catalog-table .small { font-size: 12px; margin-top: 2px; }
.label-like { margin: 8px 0 0; font-weight: 600; font-size: 14px; }
.day-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.chan-logo { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.plain-list { margin: 4px 0 8px; padding-left: 18px; }

/* Черновик с сайта: выбор частей */
.draft-pick { border: 1px solid var(--line, #ddd); border-radius: 10px; padding: 12px 16px; margin: 12px 0; }
.draft-pick details { margin: 2px 0 10px 26px; }
.draft-pick pre { max-height: 260px; overflow: auto; white-space: pre-wrap; }
.draft-mode { display: flex; gap: 16px; margin: 2px 0 2px 26px; }

/* Обучение, тесты, отчёт */
/* список в отчёте */
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { padding: 6px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.15)); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.sug-item { padding: 12px 0; border-bottom: 1px solid var(--line, rgba(127,127,127,.15)); }

/* ---- Версия 1.1: вёрстка кабинета ---- */

/* Фильтры: списки по ширине содержимого, а не на всю строку */
.filters select, .filters input { width: auto; min-width: 0; max-width: 100%; }
.filters input { width: 220px; }
@media (max-width: 640px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters label { font-size: 13px; } .filters select, .filters input { width: 100%; }
  .filters label:has(input) { grid-column: 1 / -1; }
  .filters .button { grid-column: 1 / -1; }
}

/* Короткие числа не растягиваем на всю карточку */
input[type=number], input[type=time], .short { max-width: 220px; }

/* Шапка агента: статус и включение в одной строке */
.head-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; }
.head-status .big-status { margin: 0; }
.head-status form { display: inline; }
.button.small { padding: 7px 12px; font-size: 14px; }

/* Вкладки внутри страницы */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 8px 0 20px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 10px 12px; font-size: 15px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-selected=true] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent-deep); }
.tabs a .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent); color: #16181d; font-size: 12px; text-align: center; }
.tabs a .count.bad { background: var(--bad); color: #fff; }
.js-tabs [data-tab][hidden] { display: none !important; }

/* Кнопка «Сохранить» прилипает к низу экрана, пока форма длиннее экрана */
.save-bar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 0; margin-top: 4px; background: linear-gradient(to bottom, transparent, var(--page) 30%); }

/* Ссылки-разделы под статистикой */
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }

/* Журнал: строка диалога карточкой, как список каналов */
.chat-list .profile-name { gap: 2px; }
.chat-list .last { color: var(--text-soft); font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.chat-list .side-info { display: grid; justify-items: end; gap: 4px; flex: none; font-size: 13px; color: var(--muted); text-align: right; }
@media (max-width: 860px) {
  .chat-list a { gap: 6px 14px; padding: 12px 14px; }
  .chat-list .side-info { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-left: 54px; text-align: left; }
  .chat-list .side-info .status { flex: none; padding-left: 0; }
  .chat-list .side-info .cnt { display: none; }
}
.chat-list .avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--tile); font-weight: 600; color: var(--text-soft); }

/* Отчёт: число справа */
.report-list li { display: flex; justify-content: space-between; gap: 12px; }
.report-list li .n { color: var(--muted); white-space: nowrap; }
.grid-2 > .card { margin: 0; }
.grid-2 { margin-bottom: 20px; }

/* Шапка кабинета на телефоне: всё помещается в одну строку */
@media (max-width: 860px) {
  .side-out { gap: 8px; }
  .side-out .side-balance { margin: 0; padding: 6px 10px; }
  .side-out .side-balance .muted { display: none; }
  .side nav { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); scrollbar-width: none; }
  .side nav::-webkit-scrollbar { display: none; }
  .save-bar .button { flex: 1 1 auto; text-align: center; }
}
@media (max-width: 860px) {
  .side { gap: 8px 12px; } .side .brand { padding: 0; }
  .tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
}
.report-list li:last-child { border-bottom: 0; }

/* Главная: на телефоне чат без наложений, цифры столбиком */
@media (max-width: 860px) {
  body.site .hero-art { min-height: 0; }
  body.site .hero-glow, body.site .float { display: none; }
  body.site .hero-chat { position: relative; left: 0; right: 0; top: 0; }
}
@media (max-width: 560px) {
  body.site .unlimited ul { grid-template-columns: minmax(0, 1fr); }
  body.site .unlimited li { display: flex; align-items: baseline; gap: 12px; padding: 14px; }
  body.site .unlimited b { flex: 0 0 96px; font-size: 22px; }
}

/* Главная: журнал действий агента рядом с примером продажи */
.sale-log { padding: 22px 24px; }
.sale-log .eyebrow { display: block; margin-bottom: 10px; }
.sale-steps { list-style: none; counter-reset: ss; margin: 0 0 12px; padding: 0; display: grid; gap: 0; }
.sale-steps li { counter-increment: ss; display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.sale-steps li:first-child { border-top: 0; }
.sale-steps li::before { content: counter(ss); grid-row: span 2; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); font-size: 12px; font-weight: 700; }
.sale-steps b { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; font-weight: 600; }
.sale-steps span { color: var(--muted); }
.checks li b { color: var(--ink); }
.calc-row > b { white-space: nowrap; font-size: 18px; }
.calc-total p { margin: 0 0 14px; }
.tile.tall > a { font-size: 14px; }
@media (min-width: 861px) {
  body.site .hero-art { min-height: 560px; }
  body.site .hero-chat { top: 60px; }
  body.site .float-c { top: auto; bottom: 0; left: 0; right: auto; }
}
.sale-steps li::before { align-self: start; margin-top: 1px; }

/* Страница во фрейме кабинета WabaDO: белая карточка кабинета, без своего меню */
html:has(body.frame), body.frame { background: var(--white); }
body.frame { padding: 24px; min-height: 400px; }
body.frame .frame-nav { margin-top: 0; }
body.frame .frame-main { max-width: none; }
body.frame .save-bar { background: linear-gradient(to bottom, transparent, var(--white) 30%); }
@media (max-width: 860px) { body.frame { padding: 16px; } }
