/* Джей-Чат. Палитра и раскладка в духе WhatsApp Web. Все цвета — через переменные, для двух тем. */
:root {
  --bg-app: #f0f2f5;
  --bg-panel: #ffffff;
  --bg-header: #f0f2f5;
  --bg-hover: #f5f6f6;
  --bg-active: #e9edef;
  --bg-input: #f0f2f5;
  --bg-chat: #efeae2;
  --chat-dot: rgba(11, 20, 26, 0.05);
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-ai: #e4efff;
  --bubble-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --text: #111b21;
  --text-2: #54656f;
  --text-3: #667781;
  --line: #e9edef;
  --line-2: #d1d7db;
  --accent: #00a884;
  --accent-strong: #008069;
  --accent-soft: #d9fdd3;
  --on-accent: #ffffff;
  --rail: #f0f2f5;
  --rail-icon: #54656f;
  --danger: #d32f2f;
  --danger-soft: #fde8e8;
  --warn: #b26a00;
  --warn-soft: #fff4dd;
  --info: #0b6bcb;
  --info-soft: #e5f1fd;
  --ok: #128c5e;
  --ok-soft: #e0f7ec;
  --ai: #3b5bdb;
  --ai-soft: #e7ecff;
  --online: #25d366;
  --break: #f5a623;
  --offline: #a4b0b8;
  --shadow: 0 4px 22px rgba(11, 20, 26, 0.18);
  --radius: 8px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg-app: #0b141a;
  --bg-panel: #111b21;
  --bg-header: #202c33;
  --bg-hover: #202c33;
  --bg-active: #2a3942;
  --bg-input: #202c33;
  --bg-chat: #0b141a;
  --chat-dot: rgba(233, 237, 239, 0.035);
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-ai: #24345e;
  --bubble-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.3);
  --text: #e9edef;
  --text-2: #aebac1;
  --text-3: #8696a0;
  --line: #222d34;
  --line-2: #3b4a54;
  --accent: #00a884;
  --accent-strong: #00a884;
  --accent-soft: #0a3d33;
  --on-accent: #ffffff;
  --rail: #202c33;
  --rail-icon: #aebac1;
  --danger: #f15c6d;
  --danger-soft: #3d2023;
  --warn: #f0b552;
  --warn-soft: #3a2f17;
  --info: #68b5fb;
  --info-soft: #17304a;
  --ok: #46d39a;
  --ok-soft: #123a2a;
  --ai: #9db2ff;
  --ai-soft: #252f52;
  --shadow: 0 4px 22px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg-app);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: 0.55; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ico { flex: none; display: block; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.pad { padding: 12px; }
.pad-top { padding-top: 8px; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Каркас */
.app-shell { height: 100%; display: flex; flex-direction: column; }
.app { flex: 1; min-height: 0; display: flex; height: 100%; background: var(--bg-panel); }
.app.popout { height: 100vh; }
.splash { display: grid; place-items: center; height: 100%; color: var(--text-3); }
.chats-layout { flex: 1; min-width: 0; display: flex; }

/* Подсказка о статусе */
.status-strip { display: flex; align-items: center; gap: 12px; padding: 6px 16px; background: var(--warn-soft); color: var(--text); font-size: 13px; border-bottom: 1px solid var(--line); }
.status-strip.offline { background: var(--bg-active); }
.status-strip .icon-btn { margin-left: auto; }

/* Боковая панель */
.nav-rail { width: 62px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--rail); border-right: 1px solid var(--line); }
.rail-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--rail-icon); transition: background 0.12s; }
.rail-btn:hover { background: var(--bg-active); }
.rail-btn.active { background: var(--bg-active); color: var(--accent-strong); }
.rail-badge { position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.profile-host { position: relative; }
.rail-avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 600; font-size: 14px; display: grid; place-items: center; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--offline); flex: none; }
.status-dot.online { background: var(--online); }
.status-dot.break { background: var(--break); }
.status-dot.ring { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border: 2px solid var(--rail); }
.profile-menu { position: absolute; left: 50px; bottom: 0; z-index: 50; width: 300px; background: var(--bg-panel); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
.profile-head { padding: 8px 10px; display: flex; flex-direction: column; }
.status-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; }
.status-choice { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px; border-radius: 8px; border: 1px solid var(--line-2); font-size: 13px; }
.status-choice.active { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.menu-hint { padding: 6px 10px 8px; }
.menu-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; text-align: left; color: var(--text); }
.menu-row:hover { background: var(--bg-hover); }

/* Кнопки и поля */
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--text-2); flex: none; position: relative; transition: background 0.12s; }
.icon-btn:hover { background: var(--bg-active); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.active { color: var(--accent-strong); background: var(--bg-active); }
.icon-btn.has-mark::after { content: ""; position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--break); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--bg-panel); color: var(--text); font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
.btn:hover:not(:disabled) { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 4px 11px; font-size: 12.5px; }
.btn.wide { width: 100%; padding: 10px; }
.btn.close-question { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.close-question:hover { background: var(--accent-strong) !important; }
.link-btn { color: var(--info); font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.chip-btn { padding: 4px 10px; border-radius: 14px; border: 1px solid var(--line-2); font-size: 12.5px; background: var(--bg-panel); }
.chip-btn:hover { background: var(--bg-hover); }
.input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-panel); color: var(--text); font: inherit; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.check input { margin-top: 3px; }

/* Метки */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 10px; background: var(--bg-active); color: var(--text-2); font-size: 11.5px; line-height: 16px; white-space: nowrap; }
.tag.muted { background: transparent; color: var(--text-3); padding-left: 0; }
.tag.danger { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.big { padding: 5px 10px; font-size: 13px; white-space: normal; }

/* Список чатов */
.chat-list-pane { width: 400px; flex: none; display: flex; flex-direction: column; background: var(--bg-panel); border-right: 1px solid var(--line); min-width: 0; }
.list-header { display: flex; align-items: center; gap: 8px; height: 58px; padding: 0 16px; flex: none; }
.list-header h1 { font-size: 22px; font-weight: 700; }
.list-search { padding: 0 12px 8px; flex: none; }
.search-box { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--bg-input); color: var(--text-3); flex: 1; min-width: 0; }
.search-box input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font: inherit; }
.search-box input::placeholder { color: var(--text-3); }
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; flex: none; border-bottom: 1px solid var(--line); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 15px; background: var(--bg-input); color: var(--text-2); font-size: 13px; white-space: nowrap; }
.pill:hover { background: var(--bg-active); }
.pill.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.pill.more { background: none; color: var(--info); }
.pill-count { font-size: 11.5px; opacity: 0.8; }
.pill.warn:not(.active) .pill-count { color: var(--danger); font-weight: 700; opacity: 1; }
.chat-rows { flex: 1; overflow-y: auto; min-height: 0; }
.chat-row { position: relative; display: flex; gap: 12px; padding: 10px 14px 10px 12px; cursor: pointer; align-items: flex-start; }
.chat-row::after { content: ""; position: absolute; left: 74px; right: 0; bottom: 0; border-bottom: 1px solid var(--line); }
.chat-row:hover { background: var(--bg-hover); }
.chat-row.active { background: var(--bg-active); }
.chat-row.closed .row-name, .chat-row.closed .row-preview { color: var(--text-3); font-weight: 400; }
.avatar { position: relative; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.messenger-dot { position: absolute; right: -3px; bottom: -3px; min-width: 19px; height: 19px; padding: 0 3px; border-radius: 10px; border: 2px solid var(--bg-panel); color: #fff; font-size: 8.5px; font-weight: 700; line-height: 15px; text-align: center; text-transform: uppercase; letter-spacing: 0.02em; z-index: 1; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 6px; }
.row-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15.5px; }
.row-icon { display: inline-flex; flex: none; }
.row-icon.bell { color: var(--break); }
.row-icon.closed-mark { color: var(--ok); }
.row-icon.ai { color: var(--ai); }
.row-icon.warn { color: var(--warn); vertical-align: -2px; }
.row-time { margin-left: auto; flex: none; font-size: 12px; color: var(--text-3); padding-left: 6px; }
.has-unread .row-time { color: var(--accent-strong); font-weight: 600; }
.has-unread .row-name { font-weight: 600; }
.row-mid { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--text-3); font-size: 13.5px; min-height: 20px; }
.row-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-ai { color: var(--ai); font-weight: 500; }
.has-unread .row-preview { color: var(--text); }
.unread-badge { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; }
.row-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; min-height: 18px; }
.tag.assignee { background: var(--bg-input); color: var(--text-2); }
.tag.assignee .status-dot { width: 7px; height: 7px; }
.row-open { position: absolute; right: 6px; bottom: 6px; opacity: 0; background: var(--bg-panel); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.chat-row:hover .row-open, .row-open:focus-visible { opacity: 1; }
.empty-list { padding: 30px 24px; text-align: center; color: var(--text-3); }
.ticks { display: inline-flex; color: var(--text-3); flex: none; vertical-align: -1px; }
.ticks.viewed { color: #53bdeb; }
.ticks.failed { color: var(--danger); }

/* Чат */
.chat-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-chat); position: relative; }
.chat-header { display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 14px; background: var(--bg-header); flex: none; z-index: 5; }
.chat-title { min-width: 110px; flex: 1 1 0; }
.chat-name { font-size: 15.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub b { color: var(--text-2); font-weight: 600; }
.typing { color: var(--accent-strong); font-weight: 500; }
.viewers { color: var(--warn); }
.back-btn { display: none; }
.popover-host { position: relative; }
.popover { position: absolute; top: 44px; right: -40px; z-index: 40; background: var(--bg-panel); border-radius: 10px; box-shadow: var(--shadow); padding: 12px; }
.popover-title { font-weight: 600; margin-bottom: 8px; }
.user-pick { display: flex; flex-direction: column; margin-bottom: 8px; max-height: 260px; overflow-y: auto; }
.user-pick-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; text-align: left; }
.user-pick-row:hover { background: var(--bg-hover); }
.user-pick-row.current { background: var(--accent-soft); }
.user-pick-name { flex: 1; font-weight: 500; }
.reminder-form { display: flex; flex-direction: column; gap: 8px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 5px; }
.custom-row { display: flex; gap: 6px; }
.custom-row .btn { flex: none; }
.ai-switch { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 16px; cursor: pointer; color: var(--text-2); user-select: none; }
.ai-switch:hover { background: var(--bg-active); }
.ai-switch.on { color: var(--ai); }
.ai-switch input, .set-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--line-2); transition: background 0.15s; flex: none; display: inline-block; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
input:checked + .switch-track { background: var(--accent); }
.ai-switch input:checked + .switch-track { background: var(--ai); }
input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: 13px; font-weight: 600; }

/* Полосы над лентой */
.banner { display: flex; align-items: center; gap: 10px; padding: 7px 16px; font-size: 13px; flex: none; border-bottom: 1px solid var(--line); background: var(--bg-panel); }
.banner .ico { flex: none; }
.banner-text { flex: 1; min-width: 0; }
.banner.warn { background: var(--warn-soft); }
.banner.warn > .ico { color: var(--warn); }
.banner.danger { background: var(--danger-soft); }
.banner.danger > .ico { color: var(--danger); }
.banner.ok { background: var(--ok-soft); }
.banner.ok > .ico { color: var(--ok); }
.banner.info { background: var(--info-soft); }
.banner.info > .ico { color: var(--info); }
.banner.ai { background: var(--ai-soft); }
.banner.ai > .ico { color: var(--ai); }
.banner.closed { background: var(--bg-panel); color: var(--text-2); }
.banner.closed > .ico { color: var(--ok); }

/* Лента */
.messages { flex: 1; min-height: 0; overflow-y: auto; position: relative; background-color: var(--bg-chat); background-image: radial-gradient(var(--chat-dot) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.messages-inner { padding: 14px 6% 10px; display: flex; flex-direction: column; gap: 3px; min-height: 100%; justify-content: flex-end; }
.day-sep { display: flex; justify-content: center; margin: 12px 0 8px; }
.day-sep span { padding: 4px 12px; border-radius: 8px; background: var(--bg-panel); color: var(--text-3); font-size: 12px; box-shadow: var(--bubble-shadow); }
.event-line { display: flex; justify-content: center; margin: 6px 0; }
.event-line span { max-width: 80%; padding: 4px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--text-2); font-size: 12px; text-align: center; box-shadow: var(--bubble-shadow); }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: min(68%, 620px); padding: 6px 9px 5px; border-radius: 8px; box-shadow: var(--bubble-shadow); position: relative; min-width: 76px; }
.bubble.in { background: var(--bubble-in); border-top-left-radius: 2px; }
.bubble.out { background: var(--bubble-out); border-top-right-radius: 2px; }
.bubble.ai { background: var(--bubble-ai); }
.bubble.failed { outline: 1px solid var(--danger); }
.bubble-name { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--accent-strong); margin-bottom: 2px; }
.bubble-name.ai { color: var(--ai); }
.bubble-text { white-space: pre-wrap; word-break: break-word; font-size: 14.2px; line-height: 19px; }
.bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--text-3); font-size: 11px; margin-top: 1px; height: 15px; }
.meta-tag { display: inline-flex; color: var(--ai); }
.bubble-error { font-size: 12px; color: var(--danger); margin-top: 3px; }
.msg-image img { display: block; max-width: 300px; max-height: 300px; border-radius: 6px; margin-bottom: 3px; }
.msg-audio { width: 260px; max-width: 100%; }
.msg-video { max-width: 320px; border-radius: 6px; display: block; }
.msg-file { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; background: rgba(11, 20, 26, 0.05); color: var(--text); margin-bottom: 3px; }
.msg-file span { display: flex; flex-direction: column; min-width: 0; }
.msg-file b { font-weight: 500; word-break: break-all; }
.msg-file small { color: var(--text-3); }
.jump-down { position: sticky; float: right; bottom: 14px; right: 14px; margin: 0 14px 14px 0; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-panel); color: var(--text-2); box-shadow: var(--shadow); display: grid; place-items: center; }

/* Поле ввода */
.composer-wrap { position: relative; flex: none; background: var(--bg-header); }
.composer { display: flex; align-items: flex-end; gap: 2px; padding: 8px 12px; }
.composer-input { flex: 1; min-width: 0; margin: 0 6px; padding: 9px 12px; border: 0; border-radius: 8px; background: var(--bg-panel); color: var(--text); font: inherit; font-size: 14.5px; line-height: 20px; resize: none; max-height: 200px; outline: none; }
.composer-input::placeholder { color: var(--text-3); }
.send-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); flex: none; }
.send-btn:hover:not(:disabled) { background: var(--accent-strong); }
.send-btn:disabled { background: var(--line-2); opacity: 1; }
.placeholder-hint { display: flex; align-items: center; gap: 6px; padding: 5px 16px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }
.demo-client { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 1px dashed var(--line-2); background: var(--warn-soft); }
.demo-label { font-size: 12px; color: var(--warn); white-space: nowrap; font-weight: 600; }
.demo-client .input { padding: 4px 8px; font-size: 13px; }

.suggest-strip { border-top: 1px solid var(--line); padding: 7px 12px 8px; background: var(--ai-soft); }
.suggest-head { display: flex; align-items: center; gap: 6px; color: var(--ai); font-size: 12.5px; font-weight: 500; min-height: 22px; }
.suggest-head.error { color: var(--danger); }
.suggest-warning { font-size: 12px; color: var(--warn); margin-top: 3px; }
.suggest-cards { display: flex; gap: 8px; margin-top: 6px; overflow-x: auto; padding-bottom: 2px; }
.suggest-card { flex: 1 1 0; min-width: 200px; max-width: 420px; display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 8px; background: var(--bg-panel); border: 1px solid transparent; text-align: left; box-shadow: var(--bubble-shadow); }
.suggest-card:hover { border-color: var(--ai); }
.suggest-title { font-size: 12px; font-weight: 600; color: var(--ai); }
.suggest-text { font-size: 13px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }

/* Поиск скрипта над полем ввода */
.script-picker { position: absolute; left: 12px; right: 12px; bottom: 100%; margin-bottom: 8px; height: 340px; max-height: 60vh; display: flex; background: var(--bg-panel); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; z-index: 30; }
.picker-list-col { width: 44%; min-width: 220px; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.picker-search { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.picker-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--text); font: inherit; }
.picker-query { flex: 1; color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list { flex: 1; overflow-y: auto; }
.picker-row { display: flex; flex-direction: column; width: 100%; text-align: left; padding: 7px 12px; }
.picker-row.active { background: var(--bg-active); }
.picker-title { font-size: 13.5px; font-weight: 500; }
.picker-section { font-size: 11.5px; color: var(--text-3); }
.picker-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px 14px; overflow-y: auto; }
.picker-preview-title { font-weight: 600; margin-bottom: 6px; }
.picker-preview-text { flex: 1; white-space: pre-wrap; font-size: 13.5px; line-height: 19px; }
.picker-hint { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.var-chip { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); font-size: 0.95em; }
mark { background: var(--warn-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
.review-note { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--text); font-size: 12.5px; margin-bottom: 8px; }
.review-note .ico { color: var(--warn); margin-top: 1px; }
.service-note { padding: 6px 10px; border-radius: 8px; background: var(--bg-input); color: var(--text-2); font-size: 12.5px; font-style: italic; margin-bottom: 8px; }

/* Пустой экран */
.empty-pane { display: grid; place-items: center; background: var(--bg-header); }
.empty-card { max-width: 420px; text-align: center; color: var(--text-2); padding: 20px; }
.empty-card h2 { font-weight: 400; font-size: 26px; margin-bottom: 10px; color: var(--text); }
.empty-card .ico { display: inline-block; vertical-align: -2px; }
.empty-logo { display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 16px; }

/* Правая панель */
.side-panel { width: 360px; flex: none; display: flex; flex-direction: column; background: var(--bg-panel); border-left: 1px solid var(--line); min-width: 0; }
.panel-tabs { display: flex; align-items: center; gap: 2px; padding: 0 8px; height: 60px; background: var(--bg-header); flex: none; }
.panel-tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 16px; color: var(--text-2); font-size: 13.5px; }
.panel-tab:hover { background: var(--bg-active); }
.panel-tab.active { background: var(--bg-panel); color: var(--accent-strong); font-weight: 600; box-shadow: var(--bubble-shadow); }
.panel-close { margin-left: auto; display: none; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; }
.panel-empty { padding: 30px; text-align: center; color: var(--text-3); }
.panel-section { padding: 14px 16px; border-bottom: 6px solid var(--bg-app); }
.section-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; color: var(--text-2); flex-wrap: wrap; }
.section-title b { color: var(--text); }
.warn-title { color: var(--warn); }
.client-name { font-size: 17px; font-weight: 600; }
.client-sub { margin: 2px 0 10px; }
.info-row { display: flex; gap: 10px; padding: 3px 0; font-size: 13.5px; }
.info-label { flex: 0 0 104px; color: var(--text-3); }
.info-value { flex: 1; min-width: 0; word-break: break-word; }
.section-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.status-line { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 4px; }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-text { font-size: 13.5px; margin-bottom: 8px; }
.timeline { list-style: none; display: flex; margin: 4px 0 2px; padding: 0; }
.timeline li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.timeline li::before { content: ""; position: absolute; top: 5px; left: -50%; width: 100%; height: 2px; background: var(--line-2); }
.timeline li:first-child::before { display: none; }
.timeline li.done::before, .timeline li.current::before { background: var(--accent); }
.tl-dot { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--bg-panel); border: 2px solid var(--line-2); z-index: 1; }
.timeline .done .tl-dot { background: var(--accent); border-color: var(--accent); }
.timeline .current .tl-dot { background: var(--bg-panel); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tl-name { font-size: 10px; line-height: 12px; text-align: center; color: var(--text-3); }
.timeline .current .tl-name { color: var(--accent-strong); font-weight: 700; }
.sub-block { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sub-title { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.doc-missing { color: var(--danger); font-size: 13px; }
.link-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; }
.bind-results { display: flex; flex-direction: column; margin-top: 6px; }
.bind-row { display: flex; flex-direction: column; text-align: left; padding: 7px 8px; border-radius: 8px; }
.bind-row:hover { background: var(--bg-hover); }
.right-row { display: flex; justify-content: flex-end; margin-top: 6px; }
.note { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); }
.note-text { white-space: pre-wrap; font-size: 13.5px; }
.note-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 11.5px; color: var(--text-3); }
.reminder { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg-input); margin-top: 8px; font-size: 13px; }
.reminder.fired { background: var(--warn-soft); }
.reminder-when { font-weight: 600; font-size: 12.5px; }
.related-order { display: flex; flex-direction: column; padding: 6px 0; border-top: 1px solid var(--line); }
.related-order .link-row { margin-top: 2px; }
.ai-state { margin-top: 8px; padding: 7px 10px; border-radius: 8px; background: var(--bg-input); font-size: 13px; }
.ai-state.on { background: var(--ai-soft); color: var(--ai); }
.ai-option { padding: 9px 10px; border-radius: 8px; background: var(--bg-input); margin-top: 8px; }
.ai-option-title { font-size: 12px; font-weight: 600; color: var(--ai); margin-bottom: 3px; }
.ai-option-text { white-space: pre-wrap; font-size: 13.5px; }
.ai-run { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }

/* Скрипты в карточке */
.scripts-compact { display: flex; flex-direction: column; height: 100%; }
.compact-search { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex: none; }
.compact-search .search-box { flex: none; }
.compact-list { flex: 1; overflow-y: auto; }
.compact-script { border-bottom: 1px solid var(--line); }
.compact-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 14px; text-align: left; font-size: 13.5px; }
.compact-title:hover { background: var(--bg-hover); }
.compact-script.open .compact-title { font-weight: 600; background: var(--bg-hover); }
.compact-script .script-preview-body { padding: 8px 14px 14px; }
.compact-script .script-preview-head { display: none; }
.compact-script .script-text { font-size: 13.5px; }

/* Раздел «Скрипты» */
.scripts-page { flex: 1; min-width: 0; display: flex; background: var(--bg-panel); }
.scripts-sections { width: 270px; flex: none; border-right: 1px solid var(--line); overflow-y: auto; padding-bottom: 12px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: calc(100% - 16px); margin: 1px 8px; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 13.5px; }
.section-row span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.section-row:hover { background: var(--bg-hover); }
.section-row.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.section-row.review span:first-child { color: var(--warn); }
.count { font-size: 12px; color: var(--text-3); font-weight: 400; }
.section-divider { height: 1px; background: var(--line); margin: 8px 16px; }
.scripts-list { width: 380px; flex: none; display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; }
.scripts-search { display: flex; gap: 8px; padding-top: 12px; }
.scripts-count { padding: 0 16px 6px; }
.scripts-rows { flex: 1; overflow-y: auto; }
.script-row { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 9px 16px; border-bottom: 1px solid var(--line); }
.script-row:hover { background: var(--bg-hover); }
.script-row.active { background: var(--bg-active); }
.script-row-title { font-weight: 500; font-size: 14px; }
.script-row-snippet { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-row-section { color: var(--text-3); font-size: 11.5px; }
.scripts-preview { flex: 1; min-width: 0; overflow-y: auto; }
.scripts-preview .script-preview-body { max-width: 720px; padding: 22px 28px; }
.script-preview-head h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.script-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.script-text { white-space: pre-wrap; font-size: 14.5px; line-height: 21px; padding: 12px 14px; border-radius: 8px; background: var(--bg-input); margin-bottom: 10px; }
.script-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.var-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: -6px 0 12px; }

/* Настройки */
.settings-page { flex: 1; min-width: 0; display: flex; background: var(--bg-app); }
.settings-nav { width: 250px; flex: none; background: var(--bg-panel); border-right: 1px solid var(--line); overflow-y: auto; }
.settings-group { padding: 14px 18px 4px; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.settings-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.settings-inner { flex: 1; overflow-y: auto; padding: 18px 28px 28px; }
.settings-inner > * { max-width: 780px; }
.settings-title { font-size: 21px; font-weight: 600; margin-bottom: 14px; }
.set-card { background: var(--bg-panel); border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(11, 20, 26, 0.06); }
.set-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.set-intro { color: var(--text-2); font-size: 13px; margin-bottom: 12px; }
.set-label { font-weight: 500; font-size: 13.5px; display: block; }
.set-hint { color: var(--text-3); font-size: 12.5px; margin-top: 2px; display: block; }
.set-field { display: block; margin-bottom: 12px; }
.set-field .input { margin-top: 4px; }
.set-field.narrow { max-width: 340px; }
.num-wrap { display: flex; align-items: center; gap: 8px; }
.num-wrap .input { max-width: 110px; }
.set-toggle { position: relative; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.set-toggle .switch-track { margin-top: 2px; }
.set-toggle.compact { margin: 0; }
.set-choice { border: 0; padding: 0; margin: 0 0 12px; }
.set-choice legend { padding: 0; margin-bottom: 6px; }
.choice-row { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 6px; cursor: pointer; }
.choice-row.active { border-color: var(--accent); background: var(--accent-soft); }
.choice-row b { font-weight: 500; }
.choice-row input { margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.days-table { border-collapse: collapse; }
.days-table td { padding: 3px 8px 3px 0; }
.days-table .check { margin: 0; min-width: 130px; }
.days-table .input { width: 110px; }
.days-table tr.off { color: var(--text-3); }
.holiday-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.holiday-row .input[type="date"] { width: 150px; flex: none; }
.data-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13.5px; }
.data-table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--text-3); padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.data-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr.off { color: var(--text-3); }
.table-scroll { overflow-x: auto; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; font-size: 13.5px; }
.notice { display: flex; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.notice .ico { margin-top: 1px; }
.notice.warn { background: var(--warn-soft); }
.notice.warn > .ico { color: var(--warn); }
.notice.info { background: var(--info-soft); }
.notice.info > .ico { color: var(--info); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 10px; }
.copy-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: var(--bg-input); }
.copy-row code { flex: 1; min-width: 0; word-break: break-all; font-size: 12.5px; }
.line-row { padding: 6px 0; margin: 0; }
.type-list { margin-bottom: 12px; }
.type-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.type-row.off .type-main { opacity: 0.55; }
.type-main { flex: 1; min-width: 0; }
.type-main b { font-weight: 500; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.status-texts { display: flex; flex-direction: column; gap: 6px; }
.status-text-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; }
.status-text-row .status-pill { justify-self: start; }
.stats-row { display: flex; flex-wrap: wrap; gap: 28px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 22px; font-weight: 600; }
.stat span { color: var(--text-3); font-size: 12.5px; }
.save-bar { display: flex; align-items: center; gap: 10px; padding: 10px 28px; background: var(--bg-panel); border-top: 1px solid var(--line); flex: none; }
.save-bar.dirty { background: var(--warn-soft); }

/* Окна */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(11, 20, 26, 0.45); display: grid; place-items: center; padding: 20px; }
.modal { width: 680px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--bg-panel); border-radius: 12px; box-shadow: var(--shadow); }
.modal.small { width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 20px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 4px 20px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px 16px; }

/* Уведомления */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg-panel); box-shadow: var(--shadow); font-size: 13.5px; cursor: pointer; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--accent-strong); color: #fff; }
.toast.warn { background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--break); }

/* Вход */
.login-page { min-height: 100%; display: grid; place-items: center; padding: 20px; background: var(--bg-app); }
.login-card { width: 380px; max-width: 100%; padding: 28px; background: var(--bg-panel); border-radius: 14px; box-shadow: var(--shadow); text-align: center; }
.login-card form { text-align: left; margin-top: 18px; }
.login-logo { display: inline-grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff; margin-bottom: 10px; }
.login-card h1 { font-size: 24px; font-weight: 600; }
.form-error { color: var(--danger); font-size: 13px; margin-bottom: 10px; }
.demo-login { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); text-align: left; }
.demo-login-title { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.demo-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 8px; text-align: left; }
.demo-user:hover { background: var(--bg-hover); }
.demo-user .muted { margin-left: auto; }
.mini-avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 600; flex: none; }

/* Узкие экраны */
@media (max-width: 1600px) {
  .chat-list-pane { width: 350px; }
  .side-panel { width: 340px; }
}
@media (max-width: 1400px) {
  .chat-list-pane { width: 300px; }
  .side-panel { width: 310px; }
  .chat-header { gap: 6px; padding: 0 10px; }
  .chat-header .icon-btn { width: 34px; height: 34px; }
  .messages-inner { padding-left: 3%; padding-right: 3%; }
}
@media (max-width: 1120px) {
  .side-panel { position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); }
  .chats-layout, .app.popout { position: relative; }
  .panel-close { display: inline-grid; }
  .btn.close-question { padding: 7px 10px; }
}
@media (max-width: 860px) {
  .app:has(.chats-layout.has-chat) .nav-rail { display: none; }
  .chats-layout.has-chat .chat-list-pane { display: none; }
  .chats-layout:not(.has-chat) .empty-pane { display: none; }
  .chat-list-pane { flex: 1; width: auto; }
  .back-btn { display: inline-grid; }
  .side-panel { width: 100%; }
  .chat-header { height: auto; flex-wrap: wrap; padding: 8px 10px; }
  .chat-title { flex: 1 1 60%; }
  .scripts-page, .settings-page { flex-direction: column; overflow-y: auto; }
  .scripts-sections, .settings-nav { width: 100%; max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line); }
  .scripts-list { width: 100%; max-height: 50vh; }
  .grid-2, .field-row, .check-grid { grid-template-columns: 1fr; }
  .script-picker { flex-direction: column; height: 60vh; }
  .picker-list-col { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); max-height: 45%; }
  .bubble { max-width: 88%; }
  .demo-client { flex-wrap: wrap; }
}
