/* AI Sell — тёмно-зелёная тема */
:root {
  --bg: #030b07;
  --bg-2: #061510;
  --glass: rgba(14, 38, 27, 0.55);
  --glass-strong: rgba(12, 32, 23, 0.82);
  --line: rgba(110, 231, 183, 0.11);
  --line-strong: rgba(110, 231, 183, 0.24);
  --text: #e3f5ea;
  --muted: #8fb5a1;
  --faint: #5c8270;
  --accent: #34d399;
  --accent-strong: #10b981;
  --accent-deep: #047857;
  --lime: #bef264;
  --warn: #fbbf24;
  --danger: #f87171;
  --glow: 0 0 0 1px rgba(52, 211, 153, 0.18), 0 10px 40px -12px rgba(16, 185, 129, 0.45);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Живой фон: медленно плавающие зелёные пятна + сетка */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(16, 185, 129, 0.16), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(4, 120, 87, 0.22), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}
.bg::after { content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(110, 231, 183, 0.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(110, 231, 183, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 75%);
}
.bg i { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(80px); opacity: .35;
  background: radial-gradient(circle, #10b981, transparent 65%); animation: drift 28s ease-in-out infinite; }
.bg i:nth-child(1) { top: -120px; left: 30%; }
.bg i:nth-child(2) { bottom: -200px; right: 10%; background: radial-gradient(circle, #065f46, transparent 65%); animation-duration: 34s; animation-delay: -8s; }
.bg i:nth-child(3) { top: 40%; left: -180px; width: 380px; height: 380px; background: radial-gradient(circle, #84cc16, transparent 70%); opacity: .12; animation-duration: 40s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(60px, 40px) scale(1.1); }
  66% { transform: translate(-40px, 70px) scale(.92); }
}

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); background: rgba(52, 211, 153, .1); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); }
.empty { color: var(--faint); font-style: italic; margin: 6px 0; }
.link { font-size: 13px; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 20px 50px -30px rgba(0, 0, 0, .8);
}

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 10px 18px; cursor: pointer; color: var(--text);
  background: rgba(52, 211, 153, .06);
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease, border-color .2s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: rgba(52, 211, 153, .12); border-color: rgba(110, 231, 183, .4); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary {
  border-color: transparent; color: #022c1d;
  background: linear-gradient(135deg, #6ee7b7, #10b981 55%, #059669);
  box-shadow: var(--glow);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, .3); }
.btn.wide { width: 100%; }
.btn.warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); }

.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(52, 211, 153, .05); color: var(--text); cursor: pointer; }
.icon-btn svg, .nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: rgba(2, 12, 8, .55);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; margin-top: 6px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, textarea:focus { outline: none; border-color: rgba(52, 211, 153, .55); box-shadow: 0 0 0 4px rgba(16, 185, 129, .14); background: rgba(2, 12, 8, .8); }
input[type="checkbox"] { width: 20px; height: 20px; margin: 0 10px 0 0; accent-color: var(--accent-strong); flex: none; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; font-weight: 500; }
label.check { display: flex; align-items: center; color: var(--text); font-size: 14px; }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--faint); font-weight: 400; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.grid .wide { grid-column: 1 / -1; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list { display: grid; gap: 12px; margin: 14px 0; }

.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(2, 12, 8, .5); border: 1px solid var(--line); }
.segmented button { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 9px; padding: 7px 12px; cursor: pointer; transition: background .2s, color .2s; }
.segmented button.active { background: rgba(52, 211, 153, .16); color: var(--text); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .25); }
.segmented.big button { padding: 9px 16px; font-size: 14px; }
.segmented button span { color: var(--faint); font-weight: 500; margin-left: 4px; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 32px 28px; text-align: center; }
.login-card h1 { font-size: 26px; margin-top: 4px; }
.login-card label { text-align: left; margin-top: 22px; }
.login-head { display: grid; place-items: center; margin: -6px 0 8px; }

/* ---------- Каркас ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 18px 14px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 22, 15, .85), rgba(3, 12, 8, .9));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.brand-head { width: 46px; height: 46px; flex: none; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ecfdf5, #6ee7b7); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; scrollbar-width: none; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 500; font-size: 14px;
  text-decoration: none !important; transition: background .2s, color .2s;
}
.nav a:hover { background: rgba(52, 211, 153, .07); color: var(--text); }
.nav a.active { color: var(--text); background: linear-gradient(90deg, rgba(16, 185, 129, .2), rgba(16, 185, 129, .04)); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .18); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav a.active svg { color: var(--accent); }
.badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--accent-strong); color: #022c1d; }
.badge.warn { background: var(--warn); color: #3b2500; }

.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 99px; background: rgba(2, 12, 8, .6); border: 1px solid var(--line); color: var(--muted); min-width: 0; }
.status-pill .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status-pill.ok { color: #a7f3d0; }
.status-pill.ok .dot { background: var(--accent); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: ping 2s infinite; }
.status-pill.bad { color: var(--warn); }
.status-pill.bad .dot { background: var(--warn); }
.status-pill.paused { color: var(--warn); border-color: rgba(251, 191, 36, .3); }
.status-pill.paused .dot { background: var(--warn); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 80%, 100% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } }

.scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
main#views { padding: 28px 32px 120px; max-width: 1240px; width: 100%; margin: 0 auto; }
.view { animation: fadeUp .35s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.view-head p { margin: 6px 0 0; max-width: 720px; }
.form-card { padding: 20px 22px 8px; margin: 14px 0; }
.form-card .row { margin-bottom: 14px; }

/* ---------- Обзор ---------- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; padding: 26px 30px; overflow: hidden; position: relative; }
.hero::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(500px 220px at 12% 50%, rgba(16, 185, 129, .22), transparent 70%); }
.hero-head { width: 210px; height: 210px; position: relative; }
.hero-body { position: relative; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.hero-title { font-size: 34px; font-weight: 800; margin: 8px 0 6px; letter-spacing: -0.02em; }
.hero-sub { color: var(--muted); margin: 0; font-size: 15px; max-width: 560px; }
.hero-live { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.hero-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: rgba(16, 185, 129, .12); border: 1px solid rgba(52, 211, 153, .25); color: #bbf7d0; cursor: pointer; }
.chip.thinking { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); color: #fde68a; }
.chip .dots { display: inline-flex; gap: 3px; }
.chip .dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.chip .dots i:nth-child(2) { animation-delay: .2s; }
.chip .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.setup { padding: 18px 22px; margin-top: 16px; border-color: rgba(251, 191, 36, .25); background: linear-gradient(90deg, rgba(251, 191, 36, .07), var(--glass)); }
.setup h3 { margin-bottom: 10px; }
.setup ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.setup li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.setup li .tick { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; flex: none; border: 1px solid var(--line-strong); color: var(--faint); }
.setup li.done { color: var(--muted); }
.setup li.done .tick { background: var(--accent-strong); color: #022c1d; border-color: transparent; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin: 18px 0; }
.stat { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 211, 153, .16), transparent 70%); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: clamp(22px, 2.3vw, 32px); font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(180deg, #f0fdf4, #86efac); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-note { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat.warn .stat-value { background: linear-gradient(180deg, #fef9c3, #fbbf24); -webkit-background-clip: text; background-clip: text; }

.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.panel-card { padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: ping 2s infinite; }

.feed { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; scrollbar-width: thin; }
.feed-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start; padding: 10px 4px; border-bottom: 1px solid rgba(110, 231, 183, .06); cursor: pointer; border-radius: 10px; }
.feed-item:hover { background: rgba(52, 211, 153, .05); }
.feed-item.fresh { animation: flash 1.6s ease; }
@keyframes flash { 0% { background: rgba(52, 211, 153, .22); } 100% { background: transparent; } }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 15px; background: rgba(52, 211, 153, .1); }
.feed-icon.in { background: rgba(148, 163, 184, .12); }
.feed-icon.tool { background: rgba(190, 242, 100, .12); }
.feed-text { min-width: 0; }
.feed-who { font-size: 13px; font-weight: 600; }
.feed-msg { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-time { font-size: 11.5px; color: var(--faint); white-space: nowrap; }

/* ---------- Карточки записей ---------- */
.card { padding: 16px 18px; }
.item { transition: border-color .2s; }
.item:focus-within { border-color: rgba(52, 211, 153, .35); }
.item .grid { margin-top: 12px; }
.entry ul { margin: 8px 0; padding-left: 18px; }
.entry .meta { font-size: 12.5px; color: var(--faint); }
.answer { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); background: rgba(16, 185, 129, .08); border-radius: 0 10px 10px 0; }
.tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.tag.open { background: rgba(251, 191, 36, .14); color: #fde68a; }
.tag.answered, .tag.ok { background: rgba(16, 185, 129, .16); color: #a7f3d0; }
.lead-price { font-size: 18px; font-weight: 800; color: #bbf7d0; }

/* ---------- Диалоги ---------- */
.chats-view { height: calc(100vh - 56px); }
main#views:has(.chats-view:not([hidden])) { padding-bottom: 28px; }
.chats { display: grid; grid-template-columns: 340px 1fr; height: 100%; overflow: hidden; }
.chat-list-pane { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.chat-list-head input { margin: 0; }
.chat-list-head .segmented { width: 100%; }
.chat-list-head .segmented button { flex: 1; }
.chat-list { overflow-y: auto; flex: 1; padding: 6px; scrollbar-width: thin; }
.chat-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px; border-radius: 14px; cursor: pointer; transition: background .15s; }
.chat-row:hover { background: rgba(52, 211, 153, .06); }
.chat-row.active { background: rgba(16, 185, 129, .14); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .2); }
.chat-row-main { min-width: 0; }
.chat-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row-last.typing-text { color: var(--warn); }
.chat-row-meta { display: grid; justify-items: end; gap: 4px; font-size: 11.5px; color: var(--faint); }
.owner-tag { font-size: 10.5px; font-weight: 700; color: var(--lime); text-transform: uppercase; letter-spacing: .05em; }

.avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #032016; flex: none; position: relative; }
.avatar.live::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--warn); border: 2px solid var(--bg); }
.avatar.live.speaking::after { background: var(--accent); }

.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); }
.chat-empty > div { width: 150px; height: 150px; }
.chat-thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(3, 14, 9, .5); }
.chat-head .back { display: none; }
.chat-head-info { min-width: 0; flex: 1; }
.chat-head-name { font-weight: 700; }
.chat-head-sub { font-size: 12.5px; color: var(--muted); }
.chat-head-sub.thinking { color: var(--warn); }
.chat-context { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px; }
.chat-context:not(:empty) { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.messages { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin;
  background: radial-gradient(600px 300px at 80% 0%, rgba(16, 185, 129, .06), transparent 70%); }
.day-sep { align-self: center; font-size: 12px; color: var(--faint); padding: 4px 12px; border-radius: 99px; background: rgba(2, 12, 8, .6); border: 1px solid var(--line); margin: 10px 0; }
.bubble { max-width: min(560px, 78%); padding: 9px 13px 6px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; position: relative; animation: pop .25s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble .time { display: block; text-align: right; font-size: 11px; color: var(--faint); margin-top: 3px; }
.bubble.in { align-self: flex-start; background: rgba(30, 41, 37, .85); border: 1px solid rgba(148, 163, 184, .1); border-bottom-left-radius: 6px; }
.bubble.out { align-self: flex-end; background: linear-gradient(135deg, rgba(16, 185, 129, .32), rgba(4, 120, 87, .38)); border: 1px solid rgba(52, 211, 153, .25); border-bottom-right-radius: 6px; }
.bubble.out.manual { background: rgba(190, 242, 100, .12); border-color: rgba(190, 242, 100, .25); }
.bubble.failed { border-color: rgba(248, 113, 113, .5); }
.bubble .who { display: block; font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .04em; }
.tool-chip { align-self: center; display: inline-flex; align-items: center; gap: 8px; max-width: 86%; font-size: 12.5px; color: #d9f99d;
  padding: 6px 12px; border-radius: 99px; background: rgba(190, 242, 100, .07); border: 1px dashed rgba(190, 242, 100, .25); animation: pop .25s ease both; }
.tool-chip.bad { color: #fecaca; border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .07); }
.tool-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--warn); padding: 8px 20px 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; margin-right: 6px; }

/* ---------- Мозг ---------- */
.prompt { white-space: pre-wrap; word-break: break-word; padding: 22px; font: 13px/1.6 var(--mono); color: #c7ead6; margin: 0; }

/* ---------- Плашки ---------- */
.savebar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30;
  width: calc(100% - 32px); max-width: 560px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; background: var(--glass-strong); box-shadow: var(--glow), 0 20px 60px rgba(0, 0, 0, .6); animation: fadeUp .25s ease both; }
.toast { position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px);
  padding: 11px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  background: rgba(6, 30, 20, .95); border: 1px solid rgba(52, 211, 153, .35); box-shadow: var(--glow); animation: fadeUp .25s ease both; }
.toast.error { border-color: rgba(248, 113, 113, .5); color: #fecaca; }

/* ---------- Мобильная версия ---------- */
@media (max-width: 960px) {
  .cols { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 22px 18px; }
  .hero-head { width: 170px; height: 170px; }
  .hero-live, .hero-actions { justify-content: center; }
  .hero-title { font-size: 26px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-102%); transition: transform .28s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, .6); }
  .shell.menu-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 15; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .shell.menu-open .scrim { opacity: 1; pointer-events: auto; }
  .topbar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 10; padding: 10px 16px;
    background: rgba(3, 12, 8, .8); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
  .topbar-title { font-weight: 700; flex: 1; }
  .topbar-head { width: 38px; height: 38px; }
  main#views { padding: 18px 16px 120px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 26px; }
  .view-head { flex-direction: column; }
  .chats-view { height: calc(100vh - 61px - 34px); }
  .chats { grid-template-columns: 1fr; }
  .chats .chat-pane { display: none; }
  .chats.open .chat-list-pane { display: none; }
  .chats.open .chat-pane { display: flex; }
  .chat-head .back { display: inline-grid; }
  #chat-wa { display: none; }
  .bubble { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Голова ИИ ---------- */
.ai-head { width: 100%; height: 100%; overflow: visible; display: block; }
.ai-head * { transform-box: fill-box; transform-origin: center; }
.ai-head .aura { transform-origin: 100px 102px; transform-box: view-box; animation: aura 5s ease-in-out infinite; }
.ai-head .ring { fill: none; stroke: #34d399; stroke-width: 1.2; stroke-dasharray: 3 9; opacity: .35; }
.ai-head .ring.r2 { stroke-dasharray: 26 14 4 14; opacity: .22; }
.ai-head .halo { transform-origin: 100px 102px; transform-box: view-box; animation: spin 40s linear infinite; }
.ai-head .halo .r2 { transform-origin: 100px 102px; transform-box: view-box; animation: spin 26s linear infinite reverse; }
.ai-head .orbit { transform-origin: 100px 102px; transform-box: view-box; animation: spin 14s linear infinite; }
.ai-head .spark { fill: #bef264; filter: drop-shadow(0 0 4px #bef264); }
.ai-head .spark.s2 { fill: #6ee7b7; opacity: .7; }
.ai-head .float { transform-origin: 100px 100px; transform-box: view-box; animation: bob 5s ease-in-out infinite; }
.ai-head .antenna { stroke: #34d399; stroke-width: 3; stroke-linecap: round; opacity: .7; }
.ai-head .antenna-tip { fill: #6ee7b7; filter: drop-shadow(0 0 6px #34d399); animation: tip 2.4s ease-in-out infinite; }
.ai-head .ear { fill: #0d3b29; stroke: rgba(110, 231, 183, .45); stroke-width: 1.2; }
.ai-head .shell { stroke-width: 1.6; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .55)); }
.ai-head .shine { fill: none; stroke: #ecfdf5; stroke-width: 2.4; stroke-linecap: round; opacity: .14; }
.ai-head .visor { stroke: rgba(110, 231, 183, .3); stroke-width: 1; }
.ai-head .scan { opacity: 0; }
.ai-head .eye { fill: #6ee7b7; }
.ai-head .eye-glow rect { fill: #34d399; opacity: .85; }
.ai-head .eyes { animation: blinkEyes 6s infinite; }
.ai-head .bar { fill: #34d399; opacity: .85; transform: scaleY(.3); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes aura { 0%, 100% { opacity: .65; transform: scale(.96); } 50% { opacity: 1; transform: scale(1.03); } }
@keyframes tip { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes blinkEyes { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }

/* Думает: глаза бегают, сканер по визору, кольца быстрее, антенна мигает */
.ai-head[data-state="thinking"] .halo { animation-duration: 6s; }
.ai-head[data-state="thinking"] .ring { opacity: .6; stroke: #fde68a; }
.ai-head[data-state="thinking"] .orbit { animation-duration: 3s; }
.ai-head[data-state="thinking"] .antenna-tip { fill: #fde68a; animation-duration: .6s; filter: drop-shadow(0 0 8px #fbbf24); }
.ai-head[data-state="thinking"] .scan { opacity: 1; animation: scan 1.6s ease-in-out infinite; }
.ai-head[data-state="thinking"] .eyes { animation: look 2.2s ease-in-out infinite; }
.ai-head[data-state="thinking"] .bar { animation: wave 1.4s ease-in-out infinite; }
.ai-head[data-state="thinking"] .bar.b1 { animation-delay: .1s; }
.ai-head[data-state="thinking"] .bar.b2 { animation-delay: .2s; }
.ai-head[data-state="thinking"] .bar.b3 { animation-delay: .3s; }
.ai-head[data-state="thinking"] .bar.b4 { animation-delay: .4s; }
@keyframes scan { 0% { transform: translateX(0); } 50% { transform: translateX(96px); } 100% { transform: translateX(0); } }
@keyframes look { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-7px); } 65% { transform: translateX(7px); } }
@keyframes wave { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(.6); } }

/* Говорит: рот-эквалайзер, яркая аура, «улыбка» глаз */
.ai-head[data-state="speaking"] .aura { animation-duration: 1.1s; }
.ai-head[data-state="speaking"] .ring { opacity: .7; }
.ai-head[data-state="speaking"] .halo { animation-duration: 10s; }
.ai-head[data-state="speaking"] .eyes { animation: none; transform: scaleY(.62); }
.ai-head[data-state="speaking"] .bar { animation: talk .5s ease-in-out infinite alternate; opacity: 1; }
.ai-head[data-state="speaking"] .bar.b0 { animation-delay: -.3s; }
.ai-head[data-state="speaking"] .bar.b1 { animation-delay: -.1s; animation-duration: .38s; }
.ai-head[data-state="speaking"] .bar.b2 { animation-delay: -.45s; animation-duration: .44s; }
.ai-head[data-state="speaking"] .bar.b3 { animation-delay: -.2s; animation-duration: .36s; }
.ai-head[data-state="speaking"] .bar.b4 { animation-delay: -.05s; }
@keyframes talk { from { transform: scaleY(.3); } to { transform: scaleY(1.25); } }

/* Пауза: потускневшая, глаза полуприкрыты */
.ai-head[data-state="paused"] { filter: saturate(.25) brightness(.8); }
.ai-head[data-state="paused"] .eyes { animation: none; transform: scaleY(.25); }
.ai-head[data-state="paused"] .float, .ai-head[data-state="paused"] .halo, .ai-head[data-state="paused"] .orbit { animation-play-state: paused; }

/* Маленькие копии — без орбит и колец, чтобы не рябило */
.ai-head--sm .halo, .ai-head--sm .orbit { display: none; }
.ai-head--sm .aura { opacity: .5; }

.source-status { margin-top: 4px; padding: 10px 12px; border-radius: 12px; background: rgba(2, 12, 8, .45); border: 1px dashed var(--line-strong); }
.source-status .feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.source-status.ok .feed-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.source-status .btn { margin-left: auto; }

select { width: 100%; font: inherit; color: var(--text); background: rgba(2, 12, 8, .55); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 6px; }
select:focus { outline: none; border-color: rgba(52, 211, 153, .55); box-shadow: 0 0 0 4px rgba(16, 185, 129, .14); }
input[type="time"], input[type="date"] { color-scheme: dark; }
.weekdays { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.weekdays label { margin: 0; }
.sched { display: grid; grid-template-columns: 42px 1fr auto auto; gap: 14px; align-items: center; }
.sched.off { opacity: .55; }
.sched-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: rgba(52, 211, 153, .1); }
.sched-text { font-weight: 600; }
.sched label.check { margin: 0; }
@media (max-width: 860px) { .sched { grid-template-columns: 42px 1fr; } }

/* ---------- Заявки и деньги ---------- */
.lead-controls { display: grid; grid-template-columns: 160px 1fr auto; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.lead-controls select, .lead-controls input { margin: 0; }
.tag.lead-new { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
.tag.lead-contacted { background: rgba(56, 189, 248, .14); color: #bae6fd; }
.tag.lead-sold { background: rgba(16, 185, 129, .2); color: #a7f3d0; }
.tag.lead-lost { background: rgba(248, 113, 113, .14); color: #fecaca; }
.lead.lost { opacity: .7; }
.demand { display: grid; grid-template-columns: 70px 1fr; gap: 14px; align-items: center; }
.demand-count { font-size: 26px; font-weight: 800; color: #bbf7d0; display: grid; line-height: 1.1; }
.demand-count span { font-size: 11px; font-weight: 600; color: var(--muted); }
.bubble .who.voice { color: var(--lime); }
#journal-tabs { flex-wrap: wrap; margin-bottom: 4px; }
@media (max-width: 860px) { .lead-controls { grid-template-columns: 1fr 1fr; } .lead-controls .btn { grid-column: 1 / -1; } }

/* ---------- Итоги разговоров ---------- */
.tag[class*="outcome-"] { font-size: 10.5px; padding: 2px 7px; white-space: nowrap; }
.tag.outcome-open { background: rgba(148, 163, 184, .14); color: #cbd5e1; }
.tag.outcome-waiting_owner, .tag.outcome-thinking { background: rgba(251, 191, 36, .14); color: #fde68a; }
.tag.outcome-hotline { background: rgba(56, 189, 248, .14); color: #bae6fd; }
.tag.outcome-lead, .tag.outcome-closed { background: rgba(16, 185, 129, .2); color: #a7f3d0; }
.tag.outcome-declined, .tag.outcome-no_response { background: rgba(248, 113, 113, .14); color: #fecaca; }
.tag.outcome-not_relevant { background: rgba(100, 116, 139, .2); color: #94a3b8; }
#chat-outcome { width: auto; margin: 0; padding: 6px 10px; font-size: 13px; }
.chat-list-head select { margin: 0; }
@media (max-width: 860px) { #chat-outcome { max-width: 140px; } }
.chat-head { flex-wrap: wrap; row-gap: 8px; }
.chat-head-info { flex: 1 1 160px; min-width: 140px; }
.chat-head-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-outcome { max-width: 200px; }

/* ---------- Контакты ---------- */
.contacts-table { overflow: hidden; }
.contacts-head, .contact-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) 130px 1.3fr 140px; gap: 14px; align-items: center; padding: 12px 16px; }
.contacts-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); border-bottom: 1px solid var(--line); }
.contact-row { border-bottom: 1px solid rgba(110, 231, 183, .06); }
.contact-row:hover { background: rgba(52, 211, 153, .04); }
.contact-main { display: flex; align-items: center; gap: 12px; cursor: pointer; min-width: 0; }
.contact-who { min-width: 0; }
.contact-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.contact-edit { grid-column: 1 / -1; padding: 12px 0 4px; border-top: 1px dashed var(--line); }
.contact-edit .row { margin-top: 4px; }
@media (max-width: 860px) {
  .contacts-head { display: none; }
  .contact-row { grid-template-columns: 1fr auto; }
  .contact-row .contact-cell:nth-of-type(2), .contact-row .contact-cell:nth-of-type(3) { display: none; }
}

.health-banner { margin-top: 16px; padding: 14px 18px; border-color: rgba(248, 113, 113, .4); background: linear-gradient(90deg, rgba(248, 113, 113, .12), var(--glass)); display: grid; gap: 6px; }
.steps { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- Голос ---------- */
.voice-list { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; margin-bottom: 14px; scrollbar-width: thin; }
.voice-item { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(2, 12, 8, .35); }
.voice-item.active { border-color: rgba(52, 211, 153, .5); background: rgba(16, 185, 129, .1); }
.voice-info strong { margin-right: 8px; }
.voice-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.voice-tags .chip { cursor: pointer; font-family: var(--mono); font-size: 12px; }
#voice-audio { height: 36px; }
.voice-clip { display: grid; grid-template-columns: 1fr 240px auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(2, 12, 8, .35); }
.voice-clip audio { width: 100%; height: 34px; }
.voice-clip-text { min-width: 0; font-size: 14px; }
@media (max-width: 860px) { .voice-clip { grid-template-columns: 1fr auto auto; } .voice-clip audio { grid-column: 1 / -1; } }

/* Меню компактнее, чтобы все пункты помещались на экране ноутбука */
.nav { gap: 1px; }
.nav a { padding: 7px 12px; font-size: 13.5px; }
.nav-group { padding: 10px 12px 4px; }
.brand { padding-bottom: 12px; margin-bottom: 6px; }
@media (max-height: 760px) { .nav a { padding: 5px 12px; } .brand-head { width: 38px; height: 38px; } }
.free-note { color: #fde68a; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .25); border-radius: 10px; padding: 8px 12px; margin: 0 0 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
