/* Палитра sektor-k.ru + layout как Salebot (светлая рабочая зона) */
:root {
  --bg: #07080d;
  --bg-2: #0d1018;
  --bg-3: #131826;
  --accent: #5ee0b5;
  --accent-2: #8b7cff;
  --accent-hover: #4cc99f;
  --text: #1a1f2e;
  --muted: #6b7280;
  --line: #e5e9f0;
  --panel: #ffffff;
  --chat-bg: #f4f6f9;
  --active-row: #e8f7f2;
  --active-row-border: rgba(94, 224, 181, 0.45);
  --bot-bubble: #eef0ff;
  --operator-bubble: #e8f7f2;
  --salebot-rail: #2c52be;
  --rail-w: 52px;
  --inbox-w: 300px;
  --crm-w: 368px;
  --font: "Manrope", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--chat-bg);
  font-size: 14px;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: var(--accent-2);
}

.hidden {
  display: none !important;
}

/* ——— Login ——— */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(94, 224, 181, 0.12), transparent),
    radial-gradient(ellipse 60% 50% at 100% 50%, rgba(139, 124, 255, 0.08), transparent);
}

.login-card {
  width: min(400px, calc(100vw - 32px));
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px;
  color: #eef2f8;
}

.login-brand {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-card p {
  margin: 0 0 20px;
  color: #9aa3b8;
  font-size: 13px;
}

.login-foot {
  margin: 16px 0 0;
  font-size: 13px;
}

.login-foot a {
  color: var(--accent);
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field-compact {
  margin-bottom: 10px;
}

.field input,
.field textarea,
.field select,
.search,
.composer-wrap textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

.login-card .field input {
  background: var(--bg-3);
  border-color: rgba(255, 255, 255, 0.1);
  color: #eef2f8;
}

.error {
  color: #ff7a8a;
  min-height: 18px;
  font-size: 13px;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn-block {
  width: 100%;
}

.btn-accent {
  background: var(--accent);
  color: var(--bg);
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ——— Shell (Salebot grid) ——— */
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-w) var(--inbox-w) 1fr var(--crm-w);
  grid-template-rows: 44px 1fr;
  min-height: 0;
}

.icon-rail {
  grid-row: 1 / -1;
  background: var(--bg-3);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 12px;
  gap: 4px;
}

.rail-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg);
  font-weight: 800;
  font-size: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.rail-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(238, 242, 248, 0.75);
  cursor: pointer;
  text-decoration: none;
  display: grid;
  place-items: center;
}

.rail-btn.active,
.rail-btn:hover {
  background: rgba(94, 224, 181, 0.15);
  color: var(--accent);
}

.rail-spacer {
  flex: 1;
}

.rail-user {
  font-size: 10px;
  color: #9aa3b8;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}

.appbar {
  grid-column: 2 / -1;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
}

.appbar-link {
  color: var(--accent-2);
  text-decoration: none;
}

.appbar-link:hover {
  text-decoration: underline;
}

.appbar-tag {
  color: var(--muted);
  font-size: 12px;
}

.inbox-pane,
.chat-pane,
.client-pane {
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.inbox-pane {
  display: flex;
  flex-direction: column;
}

.inbox-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.search {
  width: 100%;
}

.tabs {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.tab.active {
  background: var(--active-row);
  color: #0d5c45;
  font-weight: 600;
}

.dialog-list {
  overflow: auto;
  flex: 1;
}

.dialog-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 8px 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  align-items: start;
}

.dialog-item:hover {
  background: #fafbfc;
}

.dialog-item.active {
  background: var(--active-row);
  box-shadow: inset 3px 0 0 var(--accent);
}

.dialog-item-body {
  min-width: 0;
}

.dialog-item-body strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.dialog-tag {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.dialog-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.channel-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chat-bg);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  align-self: center;
  flex-shrink: 0;
}

.channel-badge svg {
  width: 16px;
  height: 16px;
  display: block;
}

.channel-badge--telegram {
  background: #e8f4fc;
  border-color: #b8ddf5;
  color: #229ed9;
}

.channel-badge--max {
  background: #f0ebff;
  border-color: #d4c4ff;
  color: #6b4eff;
}

.today-stats-wrap {
  margin-right: 12px;
  max-width: min(560px, 46vw);
  text-align: right;
}

.today-stats {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.35;
  margin: 0;
}

.today-stats-details {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.today-stats-details summary {
  cursor: pointer;
  list-style: none;
}

.today-stats-details summary::-webkit-details-marker {
  display: none;
}

.today-stats-extra {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-2);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin-bottom: 8px;
}

.stats-grid dt {
  color: var(--muted);
  font-weight: 500;
}

.stats-grid dd {
  margin: 0;
  font-weight: 600;
}

.stats-days-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.stats-days-table th,
.stats-days-table td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.stats-days-table th:first-child,
.stats-days-table td:first-child {
  text-align: left;
}

.badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--muted);
}

.badge.unread {
  background: #ffe8ec;
  color: #c41e3a;
  font-weight: 600;
}

.avatar {
  position: relative;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-3), #2a3348);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.avatar-xl {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  font-size: 22px;
}

/* ——— Chat ——— */
.chat-pane {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  background: var(--chat-bg);
  border-right: 0;
}

.chat-head {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--chat-bg);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn--muted {
  cursor: default;
  color: var(--muted);
}

.composer-hint {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  padding: 8px 14px;
  font-size: 13px;
}

.messages {
  overflow: auto;
  padding: 20px 16px;
}

.msg-row {
  display: flex;
  margin-bottom: 10px;
}

.msg-row.user {
  justify-content: flex-start;
}

.msg-row.bot,
.msg-row.operator {
  justify-content: flex-end;
}

.msg-row.system {
  justify-content: center;
}

.bubble {
  max-width: min(72%, 640px);
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  font-size: 14px;
}

.msg-row.user .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
}

.msg-row.bot .bubble {
  background: var(--bot-bubble);
}

.msg-row.operator .bubble {
  background: var(--operator-bubble);
  border: 1px solid var(--active-row-border);
}

.msg-row.system .bubble {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.msg-meta {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.composer-wrap {
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px 12px 8px;
}

.composer-wrap textarea {
  width: 100%;
  resize: none;
  min-height: 52px;
  max-height: 120px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.composer-wrap textarea:focus {
  outline: 2px solid rgba(94, 224, 181, 0.35);
  border-color: var(--accent);
}

.composer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 2px;
}

.composer-tools {
  display: flex;
  gap: 12px;
}

.tool-icon {
  cursor: default;
  opacity: 0.55;
  font-size: 18px;
}

.mic-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-2);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.mic-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ——— CRM sidebar ——— */
.client-pane {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--panel);
}

.client-top {
  text-align: center;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.client-top h3 {
  margin: 0;
  font-size: 16px;
}

.client-subtitle {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.client-link {
  display: inline-block;
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--accent-2);
  text-decoration: none;
}

.client-tabs {
  display: flex;
  gap: 0;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.client-tab {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  padding: 10px 10px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.client-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.client-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.client-scroll {
  overflow: auto;
  flex: 1;
  padding: 12px 14px 16px;
}

.crm-block {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.crm-block-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.crm-muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--chat-bg);
  border: 1px solid var(--line);
}

.var-list {
  margin: 0;
  font-size: 12px;
}

.var-list dt {
  color: var(--muted);
  margin-top: 8px;
}

.var-list dt:first-child {
  margin-top: 0;
}

.var-list dd {
  margin: 2px 0 0;
  color: var(--text);
}

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.empty-state small {
  display: block;
  margin-top: 8px;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: var(--rail-w) var(--inbox-w) 1fr;
  }

  .client-pane {
    display: none;
  }

  #take-btn {
    /* duplicate take in chat hint only on mobile - keep in DOM hidden with client */
  }
}


/* ——— AVMOLL extras ——— */
.rail-btn.rail-link { text-decoration: none; }
.kb-pane {
  grid-column: 2 / -1;
  grid-row: 2;
  display: none;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  padding: 16px;
}
.kb-pane.active { display: flex; }
.kb-pane textarea {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}
.kb-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.kb-hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.app-shell.mode-kb .inbox-pane,
.app-shell.mode-kb .chat-pane,
.app-shell.mode-kb .client-pane { display: none; }
.app-shell.mode-kb .kb-pane { display: flex; }
.badge.lead {
  background: #e8f7f2;
  color: #0d5c45;
  font-weight: 600;
}
.channel-badge--widget {
  background: #e8f7f2;
  border-color: rgba(94, 224, 181, 0.45);
  color: #0d5c45;
}
.test-widget-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 14px;
  background: #eef0ff;
  border-bottom: 1px solid #d9dcff;
  font-size: 13px;
}
.test-widget-banner a {
  color: var(--accent-2);
  font-weight: 600;
  text-decoration: none;
}
