/* Панель чат-агента. Спокойный светлый интерфейс: белые карточки на сером фоне,
   один тёмный акцент, никаких теней и рамок ради рамок. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f5f8; --card: #fff; --line: #e8eaf0; --line-soft: #f1f2f6;
  --text: #101828; --muted: #667085; --faint: #98a2b3;
  --dark: #131c2e; --blue: #2b6ef6; --blue-soft: #eef4ff;
  --green: #067647; --green-soft: #ecfdf3; --amber: #b54708; --amber-soft: #fffaeb;
  --red: #d92d20; --red-soft: #fef3f2;
  --r: 12px; --r-lg: 16px;
}
html, body { height: 100%; }
body { font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--blue); text-decoration: none; }
svg { flex: none; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dcdfe6; border-radius: 6px; border: 3px solid transparent;
  background-clip: content-box; }

/* ---------- вход ---------- */
#splash { min-height: 100vh; display: grid; place-items: center; color: var(--faint); }
#login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 32px 28px; }
.login-card h1 { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

/* ---------- каркас ---------- */
#app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
aside { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px 12px;
  display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 16px; font-weight: 600; }
.brand .mark { width: 28px; height: 28px; border-radius: 9px; background: var(--dark); color: #fff;
  display: grid; place-items: center; }

/* переключатель агента */
.agent-box { position: relative; margin-bottom: 14px; }
.agent-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card); text-align: left; }
.agent-btn:hover { background: var(--line-soft); }
.agent-btn .nm { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1; }
.agent-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.agent-btn .dot.off { background: var(--faint); }
.menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); padding: 5px; z-index: 30;
  box-shadow: 0 12px 32px rgba(16,24,40,.12); }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.menu button:hover { background: var(--line-soft); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 0; }
.menu .muted { color: var(--muted); }

.nav { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); font-size: 14.5px; width: 100%; text-align: left; }
.nav:hover { background: var(--line-soft); color: var(--text); }
.nav.on { background: var(--dark); color: #fff; }
.nav.on svg { opacity: 1; }
.nav svg { opacity: .75; }
.nav .n { margin-left: auto; font-size: 11.5px; font-weight: 600; background: var(--blue); color: #fff;
  border-radius: 8px; padding: 1px 7px; min-width: 20px; text-align: center; }
.nav.on .n { background: rgba(255,255,255,.22); }

aside .foot { margin-top: auto; }
.spend { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; }
.spend .v { font-size: 15px; font-weight: 600; }
.spend .l { font-size: 11.5px; color: var(--faint); }
.who { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 12.5px;
  color: var(--muted); }
.who .ava { width: 24px; height: 24px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.who a { margin-left: auto; color: var(--faint); }

/* ---------- страница ---------- */
main { min-width: 0; display: flex; flex-direction: column; }
.page-head { position: sticky; top: 0; z-index: 20; background: rgba(244,245,248,.92);
  backdrop-filter: blur(6px); padding: 22px 30px 0; }
.page-head .line { display: flex; align-items: flex-start; gap: 16px; }
.page-head h1 { font-size: 20px; font-weight: 600; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-head .acts { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 2px; margin-top: 16px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 9px 14px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); font-weight: 500; border-bottom-color: var(--dark); }
.body-wrap { padding: 22px 30px 48px; min-width: 0; }
.narrow { max-width: 760px; }

/* ---------- элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.card + .card { margin-top: 14px; }
.card > h3 { font-size: 15px; font-weight: 600; }
.card > h3 + .hint { margin-top: 3px; }
.hint { color: var(--muted); font-size: 13px; }
.card > .hint { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card); outline: none; font-size: 14px; transition: border-color .15s; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); }
.field input[type=color] { padding: 3px; height: 38px; width: 84px; }
.field textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
.field .tip { font-size: 12px; color: var(--faint); margin-top: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.btn { background: var(--dark); color: #fff; padding: 9px 15px; border-radius: 10px; font-size: 14px;
  font-weight: 500; display: inline-flex; align-items: center; gap: 7px; transition: opacity .15s; }
.btn:hover { opacity: .9; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--line-soft); opacity: 1; }
.btn.danger { background: var(--card); color: var(--red); border: 1px solid var(--line); }
.btn.danger:hover { background: var(--red-soft); opacity: 1; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.icon { padding: 8px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bar .sp { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px; min-width: 0; }
.search input { border: none; outline: none; padding: 9px 0; background: none; width: 100%; font-size: 14px; }
.search svg { color: var(--faint); }

.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 7px; background: var(--line-soft);
  color: var(--muted); white-space: nowrap; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }
.toggle { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted);
  cursor: pointer; }
.toggle input { width: 36px; height: 21px; appearance: none; background: #d5d9e2; border-radius: 12px;
  position: relative; transition: background .18s; cursor: pointer; flex: none; }
.toggle input:checked { background: var(--green); }
.toggle input::after { content: ""; position: absolute; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: left .18s; }
.toggle input:checked::after { left: 17px; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }
.ok { color: var(--green); font-size: 13px; margin-top: 10px; }
.empty { color: var(--faint); font-size: 14px; padding: 40px 20px; text-align: center; }
.empty b { display: block; color: var(--muted); font-weight: 500; margin-bottom: 4px; }

/* ---------- списки ---------- */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft);
  cursor: pointer; min-width: 0; }
.item:first-child { border-top: none; }
.item:hover { background: #fafbfd; }
.item.on { background: var(--blue-soft); }
.item .txt { min-width: 0; flex: 1; }
.item .t { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; flex: none; }
.ava { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-soft); color: var(--blue);
  display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.ava.gray { background: var(--line-soft); color: var(--muted); }

/* ---------- чаты ---------- */
.chats { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 14px; align-items: start; }
.chats .list { height: calc(100vh - 190px); overflow-y: auto; }
.chat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  display: flex; flex-direction: column; height: calc(100vh - 190px); min-width: 0; }
.chat .top { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 12px; min-width: 0; }
.chat .top .who-t { min-width: 0; }
.chat .top b { font-size: 14.5px; }
.chat .top .s { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  background: #fbfcfd; }
.msg { max-width: 74%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.msg .who { display: block; font-size: 11px; margin-bottom: 3px; color: var(--faint); }
.msg.bot .who, .msg.operator .who { color: rgba(255,255,255,.8); }
.msg.user { align-self: flex-start; background: #fff; border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.msg.bot { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.operator { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 5px; }
.msg.fn { align-self: center; max-width: 88%; background: var(--green-soft); color: var(--green);
  border-radius: 10px; font-size: 12.5px; font-family: ui-monospace, Menlo, monospace;
  display: flex; align-items: center; gap: 7px; padding: 7px 12px; }
.dots { align-self: flex-end; background: var(--blue); border-radius: 14px;
  border-bottom-right-radius: 5px; padding: 13px 15px; display: flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.85);
  animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .35; } 40% { opacity: 1; } }
.drawer .top .st { color: var(--muted); font-size: 12.5px; }

.composer { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; gap: 10px;
  align-items: flex-end; }
.composer textarea { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  resize: none; outline: none; max-height: 130px; font-size: 14px; }
.composer textarea:focus { border-color: var(--blue); }

/* ---------- код установки ---------- */
code.snippet { display: block; background: #0f1420; color: #e6e9ef; padding: 14px 16px; border-radius: 12px;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre; }

/* ---------- таблицы ---------- */
table.stat { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stat th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
  padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.stat td { padding: 10px; border-bottom: 1px solid var(--line-soft); }
table.stat tr:last-child td { border-bottom: none; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px;
  margin-bottom: 14px; }
.kpi .card { padding: 16px 18px; }
.kpi .card + .card { margin-top: 0; }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- заглушки на время загрузки ---------- */
.sk { background: linear-gradient(90deg, #eceef2 25%, #f4f5f8 37%, #eceef2 63%);
  background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-top: 1px solid var(--line-soft); }
.sk-row:first-child { border-top: none; }
.sk-ava { width: 36px; height: 36px; border-radius: 50%; flex: none; }
.sk-line { height: 11px; }

/* ---------- интервью мастера ---------- */
.wizard { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 70; display: grid;
  place-items: center; padding: 20px; animation: appear-soft .15s ease both; }
.wizard .box { background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 720px;
  height: min(88vh, 760px); display: flex; flex-direction: column; overflow: hidden;
  animation: pop-in .2s cubic-bezier(.2,.8,.3,1) both; }
.wizard .top { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 12px; }
.wizard .top b { font-size: 16px; }
.wizard .top .x { margin-left: auto; color: var(--faint); }
.wizard .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft); }
.wizard .meta input { width: 100%; padding: 8px 11px; border: 1px solid var(--line);
  border-radius: 9px; outline: none; font-size: 13.5px; }
.wizard .talk { flex: 1; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column;
  gap: 10px; background: #fbfcfd; }
.wizard .bot, .wizard .me { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: 14.5px;
  white-space: pre-wrap; animation: appear .2s ease both; }
.wizard .bot { align-self: flex-start; background: #fff; border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.wizard .me { align-self: flex-end; background: var(--dark); color: #fff; border-bottom-right-radius: 5px; }
.wizard .foot { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 8px;
  align-items: flex-end; }
.wizard .foot textarea { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  resize: none; max-height: 140px; outline: none; font-size: 14px; }
.wizard .actions { padding: 12px 16px; border-top: 1px solid var(--line-soft); display: flex;
  gap: 10px; align-items: center; background: var(--card); }
.mic.on { background: var(--red-soft); color: var(--red); }

/* ---------- микроанимации ----------
   Короткие, 150-220 мс: интерфейс должен казаться живым, а не медленным. */
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }
@keyframes appear-soft { from { opacity: 0; } }
@keyframes gone {
  to { opacity: 0; transform: translateX(-8px); max-height: 0; padding-top: 0; padding-bottom: 0;
       margin-bottom: 0; border-width: 0; }
}
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }

.body-wrap > * { animation: appear-soft .18s ease both; }
.kpi .card, .list .item.fresh, #learn-list .card { animation: appear .2s ease both; }
.msgs > *:last-child { animation: appear .2s ease both; }
.gone { animation: gone .22s ease forwards; overflow: hidden; pointer-events: none; }
.modal { animation: appear-soft .15s ease both; }
.modal .box { animation: pop-in .2s cubic-bezier(.2, .8, .3, 1) both; }
.drawer { animation: slide-in .22s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.toast { animation: pop-in .2s ease both; }
.nav, .item, .btn, .tabs button { transition: background .15s ease, color .15s ease,
  opacity .15s ease, transform .12s ease; }
.btn:active { transform: scale(.97); }
.item:active { transform: scale(.995); }

/* ---------- модалка и ящик ---------- */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.42); display: grid; place-items: center;
  padding: 20px; z-index: 60; }
.modal .box { background: var(--card); border-radius: var(--r-lg); padding: 22px; width: 100%;
  max-width: 620px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-size: 16.5px; font-weight: 600; margin-bottom: 16px; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; background: var(--card);
  border-left: 1px solid var(--line); z-index: 55; display: flex; flex-direction: column;
  box-shadow: -16px 0 40px rgba(16,24,40,.10); }
.drawer .top { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 10px; }
.drawer .top b { font-size: 15px; }
.drawer .top .x { margin-left: auto; color: var(--faint); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--dark);
  color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100; }

/* ---------- студия виджета ---------- */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 430px; gap: 16px; align-items: start; }
.stage { position: sticky; top: 92px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; }
.stage .head { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.stage .head .hint { font-size: 12px; }
.stage .head .sp { flex: 1; }
.stage iframe { width: 100%; height: 620px; border: none; display: block; background: #fff; }
@media (max-width: 1200px) { .studio { grid-template-columns: 1fr; } .stage { position: static; } }

/* ---------- предпросмотр виджета ---------- */
.preview { background: linear-gradient(180deg, #eef0f4, #e7eaf0); min-height: 190px; justify-content: flex-end; border: 1px solid var(--line); border-radius: var(--r); padding: 18px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.preview .pv-bubble { background: #fff; border-radius: 16px; padding: 12px 14px; display: flex; gap: 10px;
  max-width: 300px; box-shadow: 0 6px 18px rgba(16,24,40,.08); }
.preview .pv-bubble .ava { width: 38px; height: 38px; }
.preview .pv-bubble .nm { font-weight: 600; font-size: 13.5px; }
.preview .pv-bubble .tx { font-size: 13px; color: var(--muted); }
.preview .pv-circle { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(16,24,40,.16); }

@media (max-width: 1000px) {
  #app { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto;
    gap: 6px; padding: 10px; }
  aside .brand, aside .foot, .agent-box { display: none; }
  .nav { width: auto; white-space: nowrap; }
  .chats { grid-template-columns: 1fr; }
  .chat { height: 70vh; }
  .page-head, .body-wrap { padding-left: 16px; padding-right: 16px; }
}
