/* Chloe — Digital Colleague Framework.
   Стеклянный стиль (glassmorphism), узкий тёмный sidebar, градиентный фон,
   палитра OKI-TOKI. Светлая тема. На плотных текстовых экранах (переписка,
   редактор промпта) "громкость" стекла снижается ради читаемости. */
:root {
  --oki-blue: #3b82f6;
  --oki-blue-700: #1d4ed8;
  --oki-dark: #0f172a;
  --oki-accent: #6366f1;

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-solid: #ffffff;           /* плотный фон для текстовых экранов */
  --border-color: rgba(226, 232, 240, 0.8);

  --text: #1e293b;
  --muted: #64748b;

  /* фон страницы (светлая тема) */
  --page-1: hsla(215, 94%, 87%, 1);
  --page-2: hsla(225, 80%, 90%, 1);
  --page-base: #f1f5f9;
  --row-hover: rgba(255, 255, 255, 0.55);
  --row-active: #ffffff;
  --input-bg: #ffffff;
  --subtle: #f8fafc;

  --radius-main: 24px;
  --radius-brick: 16px;
  --radius-sm: 12px;

  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
}

/* ===== Тёмная тема ===== */
[data-theme="dark"] {
  --glass-bg: rgba(30, 41, 59, 0.65);
  --glass-solid: #1e293b;
  --border-color: rgba(71, 85, 105, 0.5);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --page-1: hsla(222, 47%, 16%, 1);
  --page-2: hsla(222, 47%, 11%, 1);
  --page-base: #0f172a;
  --row-hover: rgba(255, 255, 255, 0.04);
  --row-active: rgba(255, 255, 255, 0.07);
  --input-bg: #0f172a;
  --subtle: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--page-base);
  background-image:
    radial-gradient(at 0% 0%, var(--page-1) 0, transparent 50%),
    radial-gradient(at 50% 0%, var(--page-2) 0, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

/* ============ Каркас: sidebar + рабочая зона ============ */
.shell { display: flex; height: 100vh; overflow: hidden; }

aside.sidebar {
  width: 80px; flex-shrink: 0;
  background: var(--oki-dark);
  margin: 20px; border-radius: var(--radius-main);
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 0; gap: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}
/* Sidebar-аватар: полуовал «до пределов рамки» — закруглённый верх,
   прямой низ, лицо+тело вписаны в ширину sidebar, низ уходит за край. */
.sidebar .brand {
  width: 64px; height: 72px; margin: 0 0 14px;
  border-radius: 32px 32px 14px 14px;
  background: radial-gradient(circle at 50% 32%, #fff, #e7edff);
  position: relative; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(59,130,246,0.3);
}
/* внутренний клип под форму полуовала (даёт «обрезку» тела) */
.sidebar .brand-clip {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 32px 32px 14px 14px;
  display: flex; align-items: flex-end; justify-content: center;
  color: var(--oki-blue); font-weight: 800; font-size: 22px;
}
.sidebar .brand-clip svg { width: 118%; height: auto; margin-bottom: -2px; }
/* всплывающая реплика Chloe — выходит вправо от аватара */
.chloe-say {
  position: absolute; left: 74px; top: 8px; z-index: 80;
  background: var(--oki-dark); color: #fff; font-size: 12px; font-weight: 600;
  padding: 8px 12px; border-radius: 12px; white-space: nowrap; line-height: 1.3;
  box-shadow: 0 12px 30px rgba(15,23,42,0.3); animation: fade 0.2s ease; pointer-events: none;
}
.chloe-say::before {
  content: ""; position: absolute; left: -6px; top: 14px;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  border-right: 6px solid var(--oki-dark);
}
/* кольцо настроения по контуру полуовала */
.sidebar .brand::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 32px 32px 14px 14px;
  border: 2.5px solid transparent; pointer-events: none;
}
.sidebar .brand.mood-happy::after, .sidebar .brand.mood-idle::after { border-color: rgba(34,197,94,0.6); }
.sidebar .brand.mood-thinking::after { border-color: rgba(245,158,11,0.7); animation: orb-blink 1.5s ease-in-out infinite; }
.sidebar .brand.mood-alert::after { border-color: rgba(239,68,68,0.8); animation: orb-blink 1s ease-in-out infinite; }
.sidebar .brand.mood-sleep::after { border-color: rgba(148,163,184,0.5); }
.nav-item {
  width: 44px; height: 44px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; cursor: pointer; transition: 0.25s;
  border: none; background: transparent;
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item:hover { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.nav-item.active { background: var(--oki-blue); color: #fff; }
/* подсказка-тултип, т.к. иконки без подписей */
.nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 56px; top: 50%; transform: translateY(-50%);
  background: var(--oki-dark); color: #fff; font-size: 12px;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 50;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.nav-spacer { margin-top: auto; }

main.stage {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  padding: 20px 20px 20px 0; gap: 20px; overflow: visible;
}
/* хедер над контентом — чтобы дропдаун статуса не резался краем .page */
header.topbar { position: relative; z-index: 60; }

/* ============ Хедер ============ */
header.topbar {
  height: 70px; flex-shrink: 0;
  background: var(--glass-bg); backdrop-filter: blur(10px);
  border: 1px solid var(--border-color); border-radius: var(--radius-main);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px;
}
.topbar .title { font-size: 20px; font-weight: 800; color: var(--oki-dark); }
.topbar .title span { font-weight: 400; color: var(--oki-blue); }
.status-pill {
  background: #dcfce7; color: #166534;
  padding: 6px 16px; border-radius: 100px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.status-pill .dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }
.logout { color: var(--muted); cursor: pointer; font-size: 13px; background: none; border: none; }

/* область страницы под хедером */
.page { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* ============ Карточки / стекло ============ */
.card {
  background: var(--glass-bg); backdrop-filter: blur(10px);
  border: 1px solid var(--border-color); border-radius: var(--radius-main);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}
/* плотный вариант для текстовых экранов */
.card.solid { background: var(--glass-solid); backdrop-filter: none; }

.card-pad { padding: 24px; }
.card-head {
  padding: 20px 24px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ============ Кнопки / поля ============ */
.btn {
  background: var(--oki-blue); color: #fff; border: none;
  padding: 10px 18px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px; transition: 0.2s;
}
.btn:hover { background: var(--oki-blue-700); }
.btn.dark { background: var(--oki-dark); }
.btn.ghost { background: rgba(255,255,255,0.5); color: var(--oki-blue-700); border: 1px solid var(--border-color); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

input, textarea, select {
  font: inherit; padding: 10px 12px; width: 100%;
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--oki-blue); }
textarea { resize: vertical; min-height: 90px; }
label.fld { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.mini { font-size: 12px; color: var(--muted); }
.spacer { flex: 1; }

/* ============ Login — Next Gen ============ */
.login-stage {
  height: 100vh; width: 100%; overflow: hidden; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
}
.login-grid {
  position: absolute; inset: 0; z-index: 1;
  background-image:
    linear-gradient(rgba(59,130,246,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 80%);
}

/* летящие пузыри-реплики */
.login-bubbles { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.lb-bubble {
  position: absolute; bottom: -60px;
  background: rgba(255,255,255,0.95); color: #1e293b; font-weight: 600; font-size: 13px;
  padding: 9px 16px; border-radius: 16px; border-bottom-left-radius: 4px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  animation-name: lb-float; animation-timing-function: linear; animation-fill-mode: forwards;
}
.lb-lang { font-size: 9px; padding: 2px 5px; border-radius: 4px; background: #e2e8f0; color: #64748b; font-weight: 800; }
@keyframes lb-float {
  0% { transform: translateY(0) scale(0.85); opacity: 0; }
  12% { opacity: 0.5; }
  88% { opacity: 0.5; }
  100% { transform: translateY(-108vh) scale(1); opacity: 0; }
}

/* карточка логина */
.login-card {
  position: relative; z-index: 10; width: 360px; padding: 40px;
  background: rgba(255,255,255,0.98); backdrop-filter: blur(20px);
  border-radius: 36px; text-align: center;
  box-shadow: 0 50px 100px rgba(0,0,0,0.45); border: 1px solid rgba(255,255,255,0.2);
}
.login-avatar {
  width: 170px; height: 170px; margin: -120px auto 22px;
  background: radial-gradient(circle at 50% 35%, #fff, #eef2ff); border-radius: 50%; overflow: hidden;
  border: 10px solid var(--oki-blue);
  box-shadow: 0 15px 35px rgba(59,130,246,0.35);
  display: flex; align-items: center; justify-content: center;
}
.login-avatar svg { width: 100%; height: 100%; }
.login-h1 { color: #0f172a; font-size: 26px; font-weight: 800; margin: 0; }
.login-h1 span { color: var(--oki-blue); }
.login-sub { color: #64748b; font-size: 14px; margin: 8px 0 26px; }
.login-lbl {
  display: block; text-align: left; color: #94a3b8; font-size: 11px; font-weight: 800;
  text-transform: uppercase; margin: 0 0 6px 10px; letter-spacing: 0.03em;
}
.login-inp {
  width: 100%; background: #f1f5f9; border: 1px solid #e2e8f0; color: #0f172a;
  padding: 14px 16px; border-radius: 14px; font-size: 15px; margin-bottom: 14px; transition: 0.25s;
}
.login-inp:focus { border-color: var(--oki-blue); background: #fff; box-shadow: 0 0 0 4px rgba(59,130,246,0.15); }
.login-err { color: var(--red); font-size: 13px; margin: 2px 0 10px; }
.login-btn {
  width: 100%; background: var(--oki-blue); color: #fff; border: none;
  padding: 16px; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
  margin-top: 8px; transition: 0.25s;
}
.login-btn:hover { background: var(--oki-blue-700); transform: translateY(-2px); }

/* ============ Диалоги ============ */
.dlg-layout { display: grid; grid-template-columns: 380px 1fr; gap: 20px; height: 100%; min-height: 0; }
.dlg-list-card { display: flex; flex-direction: column; min-height: 0; }
.dlg-search { padding: 20px; border-bottom: 1px solid var(--border-color); }
.dlg-scroll { overflow-y: auto; flex: 1; }

.chat-row {
  padding: 18px 20px; border-bottom: 1px solid var(--border-color);
  cursor: pointer; transition: 0.18s; border-left: 4px solid transparent;
}
.chat-row:hover { background: var(--row-hover); }
.chat-row.active { background: var(--row-active); border-left-color: var(--oki-blue); }
.chat-row .row-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; }
.chat-row .name { font-weight: 700; font-size: 14px; }
.chat-row .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .row-meta { margin-top: 8px; display: flex; align-items: center; gap: 8px; }

/* свежесть диалога — точка */
.fresh-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.fresh-dot.green { background: var(--green); }
.fresh-dot.amber { background: var(--amber); }
.fresh-dot.red { background: var(--red); }

/* intent-тег */
.intent-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  padding: 3px 8px; border-radius: 6px; background: #e2e8f0; color: #475569;
}
.intent-tag.buy { background: #dcfce7; color: #166534; }
.intent-tag.objection { background: #fee2e2; color: #991b1b; }
.intent-tag.question { background: #e0e7ff; color: #3730a3; }
.intent-tag.spam { background: #f1f5f9; color: #94a3b8; }

/* бейдж канала (буквенный, без брендовых лого) */
.chan-badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
  padding: 2px 6px; border-radius: 6px; color: #fff; flex-shrink: 0;
}
.chan-badge.lg { font-size: 13px; padding: 8px 10px; border-radius: 10px; }
.chan-badge.fb { background: #1877f2; }
.chan-badge.web { background: #6366f1; }
.chan-badge.wa { background: #25d366; }
.chan-badge.tg { background: #229ed9; }

/* фильтр каналов над списком */
.chan-tabs { display: flex; gap: 6px; margin-top: 10px; }
.chan-tab {
  border: 1px solid var(--border-color); background: var(--glass-solid); color: var(--muted);
  padding: 4px 12px; border-radius: 100px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.chan-tab.on { background: var(--oki-blue); color: #fff; border-color: var(--oki-blue); }

/* ===== Экран Настройки ===== */
.set-tabs { display: flex; gap: 4px; padding: 14px 24px 0; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; }
.set-tab {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600; border-bottom: 2px solid transparent;
}
.set-tab.on { color: var(--oki-blue); border-bottom-color: var(--oki-blue); }
.set-body { flex: 1; overflow-y: auto; padding: 24px; min-height: 0; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.set-grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.channel-card { padding: 18px; }
.channel-card.soon { opacity: 0.85; }
.ch-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ch-title { font-weight: 700; font-size: 15px; }
.ch-status { font-size: 12px; font-weight: 700; color: var(--muted); padding: 3px 10px; border-radius: 100px; background: var(--subtle); }
.ch-status.on { background: #dcfce7; color: #166534; }
.ch-desc { margin-bottom: 14px; line-height: 1.4; }

.set-field { margin-bottom: 18px; max-width: 460px; }

/* селектор режима работы (свобода / спрашивать всё) */
.mode-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 620px; margin-bottom: 8px; }
.mode-opt {
  text-align: left; border: 2px solid var(--border-color); background: var(--glass-solid);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; transition: 0.15s;
}
.mode-opt:hover { border-color: var(--oki-blue); }
.mode-opt.on { border-color: var(--oki-blue); background: rgba(59,130,246,0.06); }
.mode-opt-t { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.key-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.key-dot.on { background: var(--green); }
.key-dot.off { background: #cbd5e1; }
.key-label { font-size: 14px; font-weight: 600; }
.sys-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--border-color); }
.sys-row span { color: var(--muted); }
.sys-row b { font-weight: 700; }
.set-grid2 .card h3 { margin-bottom: 10px; font-size: 15px; }

/* ===== Документация / архитектура ===== */
.docs { display: flex; flex-direction: column; gap: 16px; }
.docs h3 { margin-bottom: 14px; font-size: 15px; }
.arch { display: flex; flex-direction: column; gap: 14px; }
.arch-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.arch-box {
  background: var(--subtle); border: 1px solid var(--border-color); border-radius: 12px;
  padding: 10px 14px; font-size: 13px; font-weight: 700; display: flex; flex-direction: column; gap: 2px;
  min-width: 120px;
}
.arch-box small { font-weight: 500; font-size: 11px; color: var(--muted); }
.arch-box.ch { border-color: var(--oki-blue); }
.arch-box.core { background: var(--oki-blue); color: #fff; border-color: var(--oki-blue); }
.arch-box.core small { color: rgba(255,255,255,0.85); }
.arch-box.sub { background: var(--glass-solid); }
.arch-box.ok { border-color: var(--green); }
.arch-box.warn { border-color: var(--amber); }
.arch-arrow { color: var(--muted); font-weight: 700; font-size: 14px; }

.doc-mod { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.doc-mod:last-child { border-bottom: none; }
.doc-mod-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }

.api-grp { margin-bottom: 16px; }
.api-grp-name { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; margin-bottom: 8px; }
.api-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.api-method { font-size: 10px; font-weight: 800; color: var(--oki-blue); background: rgba(59,130,246,0.12); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.api-path { font-family: 'SF Mono', Consolas, monospace; font-size: 13px; color: var(--text); }
.api-desc { font-size: 12px; color: var(--muted); flex: 1; min-width: 160px; }

/* ===== Рейтинг ответа в чате (слева от пузыря бота) ===== */
.msg.bot, .msg.operator { align-items: flex-end; }
.msg-rate { display: flex; gap: 4px; margin: 0 4px 2px 0; flex-shrink: 0; opacity: 0.55; transition: opacity .2s; }
.msg.bot:hover .msg-rate { opacity: 1; }
.rate-btn {
  border: 1px solid var(--border-color); background: var(--glass-solid); cursor: pointer;
  width: 24px; height: 22px; border-radius: 6px; font-size: 12px; line-height: 1; color: var(--muted);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.rate-btn:hover { border-color: var(--oki-blue); }
.rate-btn.r3.on { background: #dcfce7; border-color: #22c55e; }
.rate-btn.r2.on { background: #fef3c7; border-color: #f59e0b; }
.rate-btn.r1.on { background: #fee2e2; border-color: #ef4444; }

/* ===== Экран Качество ===== */
.q-summary { display: flex; gap: 12px; margin-bottom: 16px; }
.q-stat {
  flex: 1; background: var(--glass-solid); border: 1px solid var(--border-color); border-radius: 14px;
  padding: 14px; text-align: center; font-size: 26px; font-weight: 800;
  display: flex; flex-direction: column; gap: 2px;
}
.q-stat small { font-size: 12px; font-weight: 500; color: var(--muted); }
.q-stat.good { color: #16a34a; } .q-stat.mid { color: #d97706; } .q-stat.bad { color: #dc2626; }
.q-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border-color); }
.q-row:last-child { border-bottom: none; }
.q-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-pill { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.rate-pill.r3 { background: #dcfce7; } .rate-pill.r2 { background: #fef3c7; } .rate-pill.r1 { background: #fee2e2; }
.q-filter { display: flex; gap: 6px; margin-bottom: 14px; }
.q-test-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.q-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.q-dot.ok { background: var(--green); } .q-dot.bad { background: var(--red); }

/* badge-состояние (НЕ проценты) */
.state-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 100px;
  display: inline-flex; align-items: center; gap: 5px;
}
.state-badge.bot { background: #dbeafe; color: #1e40af; }
.state-badge.doubt { background: #fef3c7; color: #92400e; }
.state-badge.human { background: #fee2e2; color: #991b1b; }

/* окно переписки */
.convo { display: flex; flex-direction: column; min-height: 0; }
.convo-head { padding: 18px 24px; border-bottom: 1px solid var(--border-color); }
.convo-head .who { display: flex; align-items: center; gap: 10px; }
.convo-head .who strong { font-size: 15px; }
.convo-scroll {
  flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 10px;
  background-color: #fcfaf7;
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23b4a078' stroke-width='1.2' stroke-opacity='0.25'%3E%3Cg transform='translate(50 50) rotate(15)'%3E%3Cpath d='M0 -10 L10 10 L-10 10 Z M0 10 L10 -10 L-10 -10 Z'/%3E%3C/g%3E%3Cg transform='translate(150 80) rotate(-20)'%3E%3Cpath d='M0 0 Q10 -5 10 10 L10 15 Q5 22 0 16 Q-5 22 -10 15 L-10 10 Q-10 -5 0 0 Z'/%3E%3C/g%3E%3Cg transform='translate(320 60) rotate(40)'%3E%3Cpath d='M0 0 V15 M8 0 L5 15 M0 8 H5'/%3E%3C/g%3E%3Cg transform='translate(60 180) rotate(-10)'%3E%3Ccircle cx='0' cy='0' r='10'/%3E%3Cpath d='M-3 -10 L0 -13 L3 -10'/%3E%3C/g%3E%3Cg transform='translate(220 220) rotate(10)'%3E%3Cpath d='M0 0 V12 M-6 3 V12 M6 3 V12 M-6 12 Q0 16 6 12'/%3E%3C/g%3E%3Cg transform='translate(350 250) rotate(-30)'%3E%3Cpath d='M0 -10 L10 10 L-10 10 Z M0 10 L10 -10 L-10 -10 Z'/%3E%3C/g%3E%3Cg transform='translate(100 350) rotate(20)'%3E%3Cpath d='M0 0 Q10 -5 10 10 L10 15 Q5 22 0 16 Q-5 22 -10 15 L-10 10 Q-10 -5 0 0 Z'/%3E%3C/g%3E%3Cg transform='translate(280 340) rotate(-15)'%3E%3Cpath d='M0 0 V15 M8 0 L5 15 M0 8 H5'/%3E%3C/g%3E%3Cg transform='translate(180 300) rotate(5)'%3E%3Ccircle cx='0' cy='0' r='10'/%3E%3Cpath d='M-3 -10 L0 -13 L3 -10'/%3E%3C/g%3E%3Ccircle cx='30' cy='300' r='1.5'/%3E%3Ccircle cx='200' cy='40' r='1.5'/%3E%3Ccircle cx='380' cy='150' r='1.5'/%3E%3Ccircle cx='120' cy='120' r='1.5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 400px 400px;
}
.empty-hint { margin: auto; color: var(--muted); font-size: 14px; text-align: center; }

.msg { display: flex; }
.msg.client { justify-content: flex-start; }
.msg.bot, .msg.operator { justify-content: flex-end; }
.bubble { max-width: 68%; padding: 10px 14px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.msg.client .bubble { background: var(--subtle); border-bottom-left-radius: 4px; }
.msg.bot .bubble { background: var(--oki-blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.operator .bubble { background: var(--oki-dark); color: #fff; border-bottom-right-radius: 4px; }
.bubble .b-time { font-size: 11px; opacity: 0.65; margin-top: 4px; }

/* инфо-плашка состояния диалога */
.notice {
  margin: 16px 24px 0; padding: 12px 16px; border-radius: var(--radius-sm);
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 13px;
}

/* строка ответа менеджера */
.reply-bar {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border-color); background: var(--glass-solid);
}
.reply-bar textarea { min-height: 44px; max-height: 140px; }
.reply-bar textarea:disabled { background: var(--subtle); color: var(--muted); }

/* ============ Правила: смысловые кубики ============ */
.bricks { display: flex; flex-direction: column; gap: 20px; overflow-y: auto; padding: 24px; flex: 1; min-height: 0; }
.logic-brick {
  background: var(--glass-solid); border: 1px solid var(--border-color); border-radius: var(--radius-brick);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02); overflow: hidden;
}
.logic-brick.disabled { opacity: 0.55; }
.brick-head {
  background: var(--subtle); padding: 12px 20px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-color);
}
.brick-head .b-title { font-weight: 600; font-size: 13px; flex: 1; }
.brick-head input.b-name { border: none; background: transparent; padding: 4px 6px; font-weight: 600; }
.brick-head input.b-name:focus { background: var(--input-bg); border: 1px solid var(--border-color); }
.brick-body { padding: 20px; }

.if-then { display: flex; align-items: stretch; gap: 14px; }
.if-col { flex: 1; }
.then-col { flex: 1; }
.col-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.03em; }
.brick-arrow { display: flex; align-items: center; color: #cbd5e1; font-size: 22px; }

.capsules { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.capsule {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--oki-blue); color: #fff; padding: 7px 12px;
  border-radius: 12px; font-weight: 600; font-size: 13px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}
.capsule select { width: auto; border: none; background: rgba(255,255,255,0.18); color: #fff; padding: 2px 4px; border-radius: 6px; font-weight: 600; font-size: 12px; }
.capsule select option { color: var(--text); }
.capsule .rm { border: none; background: none; color: rgba(255,255,255,0.85); cursor: pointer; font-size: 13px; padding: 0 0 0 2px; }
.add-cap { background: #eff6ff; border: 1px dashed var(--oki-blue); color: var(--oki-blue-700); padding: 6px 12px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 13px; }

.action-card { background: var(--subtle); border: 1px dashed var(--border-color); border-radius: 12px; padding: 12px; }
.action-card textarea { background: var(--input-bg); border-color: var(--border-color); min-height: 70px; }
.tmpl-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tmpl-row select { flex: 1; }

.mode-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.mode-pill { padding: 6px 12px; border-radius: 100px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border-color); background: var(--glass-solid); }
.mode-pill.on-add { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.mode-pill.on-replace { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

.brick-foot { display: flex; gap: 8px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border-color); background: var(--subtle); }

/* ============ Промпт ============ */
.prompt-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; height: 100%; min-height: 0; }
.versions-card { display: flex; flex-direction: column; min-height: 0; }
.versions-scroll { overflow-y: auto; flex: 1; padding: 8px 0; }
.version-row { padding: 12px 20px; border-bottom: 1px solid var(--border-color); }
.version-row .v-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.prompt-editor { display: flex; flex-direction: column; min-height: 0; }
.prompt-editor textarea { flex: 1; min-height: 0; border: none; border-radius: 0; padding: 24px; font-family: 'SF Mono', Consolas, monospace; font-size: 14px; line-height: 1.6; }

/* ============ KB ============ */
.kb-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; height: 100%; min-height: 0; }
.kb-list-card { display: flex; flex-direction: column; min-height: 0; }
.kb-scroll { overflow-y: auto; flex: 1; }
.kb-row { padding: 14px 20px; border-bottom: 1px solid var(--border-color); cursor: pointer; border-left: 4px solid transparent; }
.kb-row:hover { background: rgba(255,255,255,0.55); }
.kb-row.active { background: var(--row-active); border-left-color: var(--oki-blue); }
.kb-row .kb-h { font-weight: 600; font-size: 14px; }
.kb-editor { display: flex; flex-direction: column; min-height: 0; }
.kb-mode-toggle { display: inline-flex; border: 1px solid var(--border-color); border-radius: 100px; overflow: hidden; }
.kb-mode-toggle button { border: none; background: var(--glass-solid); padding: 6px 16px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.kb-mode-toggle button.on { background: var(--oki-blue); color: #fff; }

/* мелкая анимация появления */
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page > * { animation: fade 0.25s ease; }

/* ============ Аватар Chloe ============ */
.chloe-svg { display: block; overflow: visible; }
.chloe-float { animation: chloe-float 4s ease-in-out infinite; }
@keyframes chloe-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.chloe-think { animation: chloe-tilt 3s ease-in-out infinite; transform-origin: 60px 130px; }
@keyframes chloe-tilt { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
/* зрачки чуть смещаются при жесте "осмотрелась" */
.chloe-eyes-look { animation: chloe-look 1.4s ease-in-out; transform-origin: 60px 53px; }
@keyframes chloe-look {
  0%,100% { transform: translateX(0); }
  30% { transform: translateX(2px); }
  65% { transform: translateX(-2px); }
}
/* лёгкий «потягивающийся» наклон при зевке */
.chloe-yawn { animation: chloe-yawn 1.6s ease-in-out; transform-origin: 60px 130px; }
@keyframes chloe-yawn { 0%,100% { transform: rotate(0); } 40% { transform: rotate(-3deg) translateY(-2px); } }
/* приветственный кивок */
.chloe-greet { animation: chloe-greet 1.8s ease-in-out; transform-origin: 60px 90px; }
@keyframes chloe-greet { 0%,100% { transform: rotate(0); } 25% { transform: rotate(6deg) translateY(2px); } 55% { transform: rotate(-3deg); } }
/* удивление — короткий отскок */
.chloe-surprise { animation: chloe-surprise 1.3s ease-out; }
@keyframes chloe-surprise { 0%,100% { transform: translateY(0) scale(1); } 25% { transform: translateY(-4px) scale(1.04); } }
/* «печатает» — мелкое подрагивание (щелчки клавиш) */
.chloe-typing { animation: chloe-typing 0.5s ease-in-out infinite; transform-origin: 60px 130px; }
@keyframes chloe-typing { 0%,100% { transform: rotate(0); } 50% { transform: rotate(1.5deg); } }
/* прячется из кружка вниз */
.chloe-hidden { animation: chloe-hide 10s ease-in-out; }
@keyframes chloe-hide {
  0% { transform: translateY(0); opacity: 1; }
  8% { transform: translateY(115%); opacity: 0.6; }
  92% { transform: translateY(115%); opacity: 0.6; }
  100% { transform: translateY(0); opacity: 1; }
}
.chloe-mic { animation: chloe-mic 2s infinite; }
@keyframes chloe-mic {
  0%,100% { filter: drop-shadow(0 0 1px var(--mic)); opacity: 1; }
  50% { filter: drop-shadow(0 0 6px var(--mic)); opacity: 0.7; }
}

/* кольцо настроения sidebar-аватара использует эту анимацию */
@keyframes orb-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ===== Доводка тёмной темы (жёсткие светлые акценты) ===== */
[data-theme="dark"] .topbar .title { color: #e2e8f0; }
[data-theme="dark"] .status-pill { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="dark"] .notice { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #fcd34d; }
[data-theme="dark"] .btn.ghost { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .intent-tag { background: rgba(148,163,184,0.18); color: #cbd5e1; }
[data-theme="dark"] .intent-tag.buy { background: rgba(34,197,94,0.18); color: #4ade80; }
[data-theme="dark"] .intent-tag.objection { background: rgba(239,68,68,0.18); color: #f87171; }
[data-theme="dark"] .intent-tag.question { background: rgba(99,102,241,0.2); color: #a5b4fc; }
[data-theme="dark"] .state-badge.bot { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .state-badge.doubt { background: rgba(245,158,11,0.2); color: #fcd34d; }
[data-theme="dark"] .state-badge.human { background: rgba(239,68,68,0.2); color: #f87171; }
[data-theme="dark"] .msg.bot .bubble { background: var(--oki-blue); }
[data-theme="dark"] .mode-pill { background: var(--glass-solid); color: var(--muted); }
[data-theme="dark"] .mode-pill.on-add { background: rgba(59,130,246,0.25); color: #93c5fd; border-color: rgba(59,130,246,0.4); }
[data-theme="dark"] .mode-pill.on-replace { background: rgba(245,158,11,0.22); color: #fcd34d; border-color: rgba(245,158,11,0.4); }
[data-theme="dark"] .capsule select option { color: #0f172a; }
[data-theme="dark"] .ch-status.on { background: rgba(34,197,94,0.2); color: #4ade80; }
[data-theme="dark"] .intent-tag.buy { background: rgba(34,197,94,0.18); color: #4ade80; }
[data-theme="dark"] .intent-tag.objection { background: rgba(239,68,68,0.18); color: #f87171; }
[data-theme="dark"] .intent-tag.question { background: rgba(99,102,241,0.2); color: #a5b4fc; }
[data-theme="dark"] .intent-tag.spam { background: rgba(148,163,184,0.18); color: #cbd5e1; }
[data-theme="dark"] .rate-pill.r3, [data-theme="dark"] .rate-btn.r3.on { background: rgba(34,197,94,0.22); }
[data-theme="dark"] .rate-pill.r2, [data-theme="dark"] .rate-btn.r2.on { background: rgba(245,158,11,0.22); }
[data-theme="dark"] .rate-pill.r1, [data-theme="dark"] .rate-btn.r1.on { background: rgba(239,68,68,0.22); }
/* лёгкий тёмный тонировочный градиент под аватаром в sidebar (чтобы не «слепил») */
[data-theme="dark"] .sidebar .brand { background: radial-gradient(circle at 50% 32%, #e7edff, #c7d2fe); }

/* ============ Хедер Dashboard Pro (KPI + статус + режим) ============ */
.topbar { gap: 20px; }
.topbar-left { display: flex; align-items: center; gap: 22px; flex-shrink: 0; }

/* переключатель режима — пилюли */
.mode-switch { background: var(--subtle); padding: 5px; border-radius: 14px; display: flex; gap: 4px; }
.m-btn {
  padding: 8px 16px; border-radius: 10px; border: none; background: transparent;
  font: inherit; font-weight: 700; font-size: 12px; color: var(--muted);
  cursor: pointer; transition: .25s; white-space: nowrap;
}
.m-btn.active { background: var(--oki-blue); color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.m-btn.warn.active { background: var(--amber); box-shadow: 0 4px 12px rgba(245,158,11,0.35); }

/* блок метрик справа */
.header-stats { display: flex; align-items: center; gap: 14px; margin-left: auto; }

/* KPI-виджет: лейбл и значение в одну строку */
.kpi { display: inline-flex; align-items: baseline; gap: 7px; padding: 0 14px; border-right: 1px solid var(--border-color); white-space: nowrap; }
.kpi:first-child { padding-left: 0; }
.kpi-label { font-size: 10px; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 16px; font-weight: 700; color: var(--oki-dark); }
.kpi-value b { color: var(--oki-blue); }

/* дропдаун статуса систем */
.status-dropdown { position: relative; cursor: default; }
.status-pill {
  background: #f0fdf4; color: #166534; border: 1px solid #dcfce7;
  padding: 8px 14px; border-radius: 12px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; gap: 8px; transition: .25s; white-space: nowrap;
}
.status-pill:hover { background: #dcfce7; }
.status-pill.part { background: #fffbeb; color: #92400e; border-color: #fef3c7; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-pill .dot.green { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-pill .dot.amber { background: var(--amber); box-shadow: 0 0 8px rgba(245,158,11,.7); }
.status-content {
  position: absolute; top: 120%; right: 0; width: 240px; background: var(--glass-solid, #fff);
  border-radius: 18px; border: 1px solid var(--border-color); box-shadow: 0 15px 40px rgba(0,0,0,0.12);
  padding: 14px; visibility: hidden; opacity: 0; transform: translateY(8px); transition: .25s; z-index: 100;
}
.status-dropdown:hover .status-content { visibility: visible; opacity: 1; transform: translateY(0); }
.status-title { font-weight: 800; font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.status-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 12px; font-weight: 600; color: var(--text); }
.status-item:last-child { border: none; }
.status-item.off { opacity: .55; }
.status-item .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-item .dot.green { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.status-item .dot.red { background: var(--red); }

/* кнопка тест-чата: текст фиксированный, состояние — точкой (чёрная выкл / зелёная вкл) */
.btn-test {
  background: var(--oki-dark); color: #fff; border: none;
  padding: 11px 18px; border-radius: 14px; font: inherit; font-weight: 700; font-size: 13px;
  cursor: pointer; transition: .25s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-test:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,0.25); }
.btn-test .tc-dot { width: 8px; height: 8px; border-radius: 50%; background: #475569; transition: .25s; }
.btn-test.on { background: #14532d; }
.btn-test.on .tc-dot { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.btn-test.on:hover { box-shadow: 0 8px 20px rgba(34,197,94,0.3); }

/* ============ Живая карточка «Сайт» ============ */
.web-card { display: flex; flex-direction: column; gap: 12px; grid-column: 1 / -1; }
.web-embed .embed-row {
  display: flex; align-items: center; gap: 8px; background: var(--subtle);
  border-radius: 10px; padding: 8px 10px; margin: 4px 0;
}
.web-embed .embed-row code { flex: 1; font-size: 12px; overflow-x: auto; white-space: nowrap; color: var(--oki-dark); }
.web-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.web-settings .set-field { margin-bottom: 0; }
.web-soon { border-top: 1px dashed var(--border-color); padding-top: 10px; opacity: 0.7; }
.web-soon .soon-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 13px; }
.web-soon .soon-row span { min-width: 160px; color: var(--muted); }
.web-soon .soon-row input { flex: 1; }

/* ============ Telegram-оповещения (Поведение) ============ */
.tg-block { border-top: 1px solid var(--border-color); margin-top: 18px; padding-top: 16px; max-width: 620px; }
.tg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tg-notify-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 0; }
.tg-notify-row .tg-lbl { font-weight: 600; font-size: 14px; }
.tgl { width: 40px; height: 22px; border-radius: 100px; background: #cbd5e1; border: none; cursor: pointer; position: relative; flex-shrink: 0; padding: 0; transition: background .15s; }
.tgl .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.tgl.on { background: var(--oki-blue); }
.tgl.on .knob { left: 20px; }

/* ============ SSL-карточка ============ */
.ssl-timer { margin-top: 10px; font-weight: 800; font-size: 15px; padding: 8px 14px; border-radius: 10px; text-align: center; }
.ssl-timer.green { background: #dcfce7; color: #166534; }
.ssl-timer.amber { background: #fef3c7; color: #92400e; }
.ssl-timer.red { background: #fee2e2; color: #991b1b; }

/* dark-доводка новых блоков */
[data-theme="dark"] .mode-switch { background: var(--glass-solid); }
[data-theme="dark"] .kpi-value { color: #e2e8f0; }
[data-theme="dark"] .status-pill { background: rgba(34,197,94,0.14); color: #4ade80; border-color: rgba(34,197,94,0.28); }
[data-theme="dark"] .status-pill:hover { background: rgba(34,197,94,0.22); }
[data-theme="dark"] .status-pill.part { background: rgba(245,158,11,0.14); color: #fcd34d; border-color: rgba(245,158,11,0.28); }
[data-theme="dark"] .status-content { background: var(--glass-solid); }
[data-theme="dark"] .web-embed .embed-row code { color: #e2e8f0; }
[data-theme="dark"] .convo-scroll {
  background-color: #0f172a;
  background-image: url("data:image/svg+xml,%3Csvg width='400' height='400' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='white' stroke-width='1.2' stroke-opacity='0.06'%3E%3Cg transform='translate(50 50) rotate(15)'%3E%3Cpath d='M0 -10 L10 10 L-10 10 Z M0 10 L10 -10 L-10 -10 Z'/%3E%3C/g%3E%3Cg transform='translate(150 80) rotate(-20)'%3E%3Cpath d='M0 0 Q10 -5 10 10 L10 15 Q5 22 0 16 Q-5 22 -10 15 L-10 10 Q-10 -5 0 0 Z'/%3E%3C/g%3E%3Cg transform='translate(320 60) rotate(40)'%3E%3Cpath d='M0 0 V15 M8 0 L5 15 M0 8 H5'/%3E%3C/g%3E%3Cg transform='translate(60 180) rotate(-10)'%3E%3Ccircle cx='0' cy='0' r='10'/%3E%3Cpath d='M-3 -10 L0 -13 L3 -10'/%3E%3C/g%3E%3Cg transform='translate(220 220) rotate(10)'%3E%3Cpath d='M0 0 V12 M-6 3 V12 M6 3 V12 M-6 12 Q0 16 6 12'/%3E%3C/g%3E%3Cg transform='translate(350 250) rotate(-30)'%3E%3Cpath d='M0 -10 L10 10 L-10 10 Z M0 10 L10 -10 L-10 -10 Z'/%3E%3C/g%3E%3Cg transform='translate(100 350) rotate(20)'%3E%3Cpath d='M0 0 Q10 -5 10 10 L10 15 Q5 22 0 16 Q-5 22 -10 15 L-10 10 Q-10 -5 0 0 Z'/%3E%3C/g%3E%3Cg transform='translate(280 340) rotate(-15)'%3E%3Cpath d='M0 0 V15 M8 0 L5 15 M0 8 H5'/%3E%3C/g%3E%3Cg transform='translate(180 300) rotate(5)'%3E%3Ccircle cx='0' cy='0' r='10'/%3E%3Cpath d='M-3 -10 L0 -13 L3 -10'/%3E%3C/g%3E%3Ccircle cx='30' cy='300' r='1.5'/%3E%3Ccircle cx='200' cy='40' r='1.5'/%3E%3Ccircle cx='380' cy='150' r='1.5'/%3E%3Ccircle cx='120' cy='120' r='1.5'/%3E%3C/g%3E%3C/svg%3E");
}
[data-theme="dark"] .ssl-timer.green { background: rgba(34,197,94,0.2); color: #4ade80; }
[data-theme="dark"] .ssl-timer.amber { background: rgba(245,158,11,0.2); color: #fcd34d; }
[data-theme="dark"] .ssl-timer.red { background: rgba(239,68,68,0.2); color: #f87171; }
