:root {
  --bg: #090b0d; --panel: #0f1216; --panel2: #161a20; --border: rgba(255,255,255,0.08);
  --text: #eef0f3; --muted: #7d8796; --accent: #c8f542; --accent2: #9de600;
  --accent-dim: rgba(200, 245, 66, 0.14); --accent-glow: rgba(200, 245, 66, 0.35);
  --green: #5cdb7a; --red: #ff6b6b; --orange: #ff9f43;
  --surface-glass: rgba(12, 15, 19, 0.78);
  --surface-glass-border: rgba(255, 255, 255, 0.06);
  --sidebar-glow: rgba(200, 245, 66, 0.07);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --radius-md: 12px;
  --radius-lg: 14px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 68px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

/* ── shell ── */
.app-shell { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar-width, 220px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 0 8px;
  position: relative;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(16, 19, 24, 0.94) 0%, rgba(9, 11, 13, 0.98) 100%);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-right: 1px solid var(--surface-glass-border);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.03),
    4px 0 28px rgba(0, 0, 0, 0.28);
  transition: width .28s var(--ease-out-expo);
}
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 140px;
  background: radial-gradient(ellipse 90% 80% at 10% -10%, var(--sidebar-glow), transparent 68%);
  pointer-events: none;
  z-index: 0;
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar-resize-handle {
  position: absolute; top: 0; right: -3px; width: 6px; height: 100%;
  cursor: col-resize; z-index: 20; user-select: none;
}
.sidebar-resize-handle:hover { background: var(--accent-dim); }
.sidebar-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  color: var(--muted);
  padding: 9px 12px;
  margin: 8px 10px 0;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition:
    background .22s var(--ease-out-expo),
    color .22s var(--ease-out-expo),
    border-color .22s var(--ease-out-expo),
    transform .22s var(--ease-out-expo);
}
.sidebar-collapse-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--surface-glass-border);
  color: var(--text);
  transform: translateX(1px);
}
.sidebar-collapse-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.brand {
  font-weight: 800;
  font-size: 15px;
  padding: 6px 16px 14px;
  letter-spacing: 0.35px;
  line-height: 1.2;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  margin-bottom: 4px;
}
.brand-mark {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
}
.nav-section {
  padding: 12px 16px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a6472;
}
.nav-section-motion {
  animation: sidebar-section-enter .4s var(--ease-out-expo) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
#sidebarNav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
#sidebarNav::-webkit-scrollbar { width: 4px; }
#sidebarNav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
#sidebarNav button[data-tab],
#sidebarNav .sidebar-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: #9aa3b2;
  padding: 9px 12px;
  margin: 0 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  transition:
    background .22s var(--ease-out-expo),
    color .22s var(--ease-out-expo),
    border-color .22s var(--ease-out-expo),
    box-shadow .22s var(--ease-out-expo),
    transform .22s var(--ease-out-expo);
}
.nav-item-motion {
  animation: sidebar-nav-enter .38s var(--ease-out-expo) backwards;
  animation-delay: calc(var(--i, 0) * 32ms);
}
#sidebarNav button .nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.82;
  transition: opacity .22s var(--ease-out-expo), transform .22s var(--ease-out-expo);
}
#sidebarNav button span { flex: 1; min-width: 0; }
#sidebarNav button[data-tab]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 56%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  transition: transform .22s var(--ease-out-expo);
  opacity: 0;
}
#sidebarNav button[data-tab]:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--text);
  transform: translateX(2px);
}
#sidebarNav button[data-tab]:hover::before {
  opacity: 0.55;
  transform: translateY(-50%) scaleY(0.55);
}
#sidebarNav button[data-tab]:hover .nav-ico {
  opacity: 1;
  transform: scale(1.04);
}
#sidebarNav button[data-tab]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#sidebarNav button[data-tab].active {
  color: #101208;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow:
    0 4px 18px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transform: none;
}
#sidebarNav button[data-tab].active::before {
  opacity: 0;
  transform: translateY(-50%) scaleY(0);
}
#sidebarNav button[data-tab].active .nav-ico {
  opacity: 1;
  stroke: #101208;
  transform: none;
}
.nav-item-group { display: flex; flex-direction: column; gap: 1px; }
.nav-item-group > button[data-tab] { width: 100%; }
#sidebarNav .nav-sub {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 10px 6px 34px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
#sidebarNav .nav-sub .nav-ico-sub { width: 14px; height: 14px; opacity: 0.65; flex-shrink: 0; }
#sidebarNav .nav-sub:hover { background: rgba(255,255,255,0.04); color: var(--accent); }
#sidebarNav .nav-sub:hover .nav-ico-sub { opacity: 1; stroke: var(--accent); }
#sidebarNav .nav-sub.active,
.nav-item-group.nav-add-open .nav-sub {
  background: var(--accent-dim); color: var(--accent); font-weight: 600;
}
#sidebarNav .nav-sub.active .nav-ico-sub,
.nav-item-group.nav-add-open .nav-sub .nav-ico-sub { opacity: 1; stroke: var(--accent); }
.sidebar-foot {
  padding: 10px 12px 12px;
  margin-top: auto;
  border-top: 1px solid var(--surface-glass-border);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.22));
}
.stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: background .2s var(--ease-out-expo), border-color .2s var(--ease-out-expo);
}
.stat-row:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}
.stat-row-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.stat-row-value {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.stat-row-value.ok { color: var(--green); }
.stat-row-value.warn { color: var(--orange); }
.stat-row-value.accent { color: var(--accent); }
.stat-row-value.muted { color: #8b95a5; }
@keyframes sidebar-nav-enter {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}
@keyframes sidebar-section-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  #sidebarNav button[data-tab],
  .sidebar-collapse-toggle,
  .stat-row { transition: none; }
  .nav-item-motion,
  .nav-section-motion,
  .chat-item-motion { animation: none; }
  #tab-inbox .chat-item,
  #tab-inbox .composer-icon,
  #tab-inbox .composer-send,
  #tab-inbox .icon-btn { transition: none; }
}
.sidebar.is-collapsed {
  width: 92px !important;
}
.sidebar.is-collapsed .sidebar-resize-handle {
  display: none;
}
.sidebar.is-collapsed .brand {
  display: none;
}
.sidebar.is-collapsed .nav-section {
  display: none;
}
.nav-section { display: none; }
.sidebar-foot { display: none !important; }
/* SortableJS режим C: двигается сам пункт (видимый заполнитель), плавающая копия скрыта — без дубля */
#sidebarNav button[data-tab].nav-ghost {
  opacity: 1;
  background: rgba(40,46,56,.98);
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
#sidebarNav button[data-tab].nav-chosen { cursor: grabbing; }
.nav-drag {
  opacity: 0 !important;
}
#sidebarNav button[data-tab] { cursor: grab; }
.sidebar.is-collapsed #sidebarNav .sidebar-collapse-toggle span,
.sidebar.is-collapsed .sidebar-foot {
  display: none;
}
.sidebar.is-collapsed #sidebarNav {
  align-items: stretch;
  overflow-y: auto;
  padding: 0 6px;
}
/* Рейка: иконка сверху + полное слово под ней */
.sidebar.is-collapsed #sidebarNav button[data-tab] {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 52px;
  margin: 0 0 2px;
  padding: 8px 2px;
  border-radius: 14px;
}
.sidebar.is-collapsed #sidebarNav button[data-tab] span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 0 0 auto;
  width: 100%;
  text-align: center;
  font-size: 10px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: .01em;
  color: #c6cedb;
  opacity: 1;
}
.sidebar.is-collapsed #sidebarNav .nav-ico {
  width: 24px;
  height: 24px;
}
.sidebar.is-collapsed #sidebarNav button[data-tab]:hover {
  transform: none;
}
.sidebar.is-collapsed #sidebarNav button[data-tab]:hover .nav-ico {
  transform: translateY(-1px) scale(1.06);
}
.sidebar.is-collapsed #sidebarNav .sidebar-collapse-toggle {
  display: flex;
  justify-content: center;
  width: 100%;
  height: 38px;
  margin: 4px 0 0;
  padding: 0;
}
.sidebar.is-collapsed #sidebarNav .sidebar-collapse-toggle .nav-ico {
  transform: rotate(180deg);
}
/* Рейка: модерн-вид — мягкий тинт вместо тяжёлого блока, лайм-иконка */
.sidebar.is-collapsed #sidebarNav button[data-tab] {
  gap: 5px;
}
.sidebar.is-collapsed #sidebarNav button[data-tab] .nav-ico {
  opacity: .82;
}
.sidebar.is-collapsed #sidebarNav button[data-tab] span {
  letter-spacing: .01em;
  opacity: 1;
}
.sidebar.is-collapsed #sidebarNav button[data-tab]:hover {
  background: rgba(255,255,255,.05);
}
.sidebar.is-collapsed #sidebarNav button[data-tab]:hover .nav-ico { opacity: 1; }
/* Активный пункт: без фона-блока — переливается сама иконка (lime→мята→cyan), слово не красим */
.sidebar.is-collapsed #sidebarNav button[data-tab].active {
  background: transparent;
  box-shadow: none;
  transform: none;
}
.sidebar.is-collapsed #sidebarNav button[data-tab].active .nav-ico {
  stroke: none;
  opacity: 1;
  transform: scale(1.1);
  filter: drop-shadow(0 0 7px rgba(110,228,170,.5));
}
.sidebar.is-collapsed #sidebarNav button[data-tab].active .nav-ico path {
  fill: url(#navGrad);
}
.sidebar.is-collapsed #sidebarNav button[data-tab].active span {
  opacity: 1;
}
.main-area { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tab { display: none; flex: 1; min-height: 0; overflow: hidden; }
.tab.active:not(#tab-inbox) { display: flex; flex-direction: column; }

/* ── messenger: 3 колонки ── */
#tab-inbox.tab.active {
  display: grid !important;
  grid-template-columns: 320px 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns .28s var(--ease-out-expo);
  background:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(200, 245, 66, 0.04), transparent 55%),
    var(--bg);
}
/* Свёрнутая карточка клиента — средняя колонка уезжает, переписка расширяется */
#tab-inbox.lead-collapsed.tab.active {
  grid-template-columns: 320px 0px minmax(0, 1fr);
}
#tab-inbox.lead-collapsed > .lead-panel {
  opacity: 0;
  border-right: none;
  pointer-events: none;
}
/* Язычок-стрелка на рамке: скрыть/показать карточку клиента */
.lead-edge-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--muted);
  background: rgba(20, 24, 30, 0.96);
  border: 1px solid var(--surface-glass-border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  z-index: 7;
  transition: color .18s var(--ease-out-expo), background .18s var(--ease-out-expo);
}
.lead-edge-toggle:hover { color: var(--accent); background: rgba(28, 34, 42, 0.98); }
.lead-edge-toggle svg { transition: transform .26s var(--ease-out-expo); }
#tab-inbox.lead-collapsed .lead-edge-toggle svg { transform: rotate(180deg); }
#tab-inbox > .chat-list-panel,
#tab-inbox > .lead-panel,
#tab-inbox > .chat-main {
  grid-row: 1;
  min-height: 0;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.chat-list-panel {
  border-right: 1px solid var(--surface-glass-border);
  background:
    linear-gradient(180deg, rgba(14, 17, 22, 0.96) 0%, rgba(11, 13, 16, 0.98) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
}
#tab-inbox .panel-head {
  padding: 0;
  border-bottom: 1px solid var(--surface-glass-border);
  background: rgba(255, 255, 255, 0.02);
}
.inbox-toolbar {
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.inbox-toolbar-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  min-width: 0;
}
.inbox-toolbar .inbox-search {
  width: 100%;
  padding: 9px 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 12px;
  margin: 0;
  transition:
    border-color .22s var(--ease-out-expo),
    box-shadow .22s var(--ease-out-expo),
    background .22s var(--ease-out-expo);
}
.inbox-toolbar .inbox-search::placeholder { color: #667080; }
.inbox-toolbar .inbox-search:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.34);
}
.inbox-toolbar .inbox-search:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.1);
  background: rgba(0, 0, 0, 0.38);
}
.inbox-toolbar .inbox-side-toggle { width: 100%; }
.inbox-toolbar .inbox-side-toggle .side-toggle-btn {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  font-size: 11px;
}
#tab-inbox .panel-head input[type=search] {
  width: 100%;
  padding: 9px 11px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  margin-bottom: 0;
}
.inbox-toolbar-filters .status-filter,
.inbox-toolbar .status-filter {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 7px 28px 7px 9px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--surface-glass-border);
  border-radius: 10px;
  color: var(--text);
  font-size: 11px;
  margin: 0;
  cursor: pointer;
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8796' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color .2s var(--ease-out-expo), background-color .2s var(--ease-out-expo);
}
.inbox-toolbar .status-filter option {
  background: #12161c;
  color: var(--text);
}
.inbox-toolbar .status-filter:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: rgba(0, 0, 0, 0.32);
}
.inbox-toolbar .status-filter:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.08);
}
.inbox-side-toggle {
  display: flex;
  border: 1px solid var(--surface-glass-border);
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.22);
  padding: 2px;
  gap: 2px;
}
.side-toggle-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background .22s var(--ease-out-expo),
    color .22s var(--ease-out-expo),
    box-shadow .22s var(--ease-out-expo);
}
.side-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.side-toggle-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #101208;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.chat-side-tag {
  display: inline-block;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 4px;
  border: 1px solid transparent;
}
.chat-side-tag.wait {
  background: rgba(100, 181, 246, 0.12);
  border-color: rgba(100, 181, 246, 0.22);
  color: #64b5f6;
}
.chat-side-tag.cold {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
  color: #9aa3b2;
}
.chat-list-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  width: 100%;
  margin-top: 0;
}
.inbox-toolbar .chat-list-actions .chat-act-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 7px;
  font-size: 10px;
  border-radius: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid var(--surface-glass-border);
  background: rgba(255, 255, 255, 0.02);
  transition:
    background .2s var(--ease-out-expo),
    border-color .2s var(--ease-out-expo),
    color .2s var(--ease-out-expo),
    transform .2s var(--ease-out-expo);
}
.inbox-toolbar .chat-list-actions .chat-act-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
  transform: translateY(-1px);
}
.inbox-toolbar .chat-list-actions .chat-act-btn span {
  font-weight: 700;
  margin-left: 2px;
  color: var(--accent);
}
.inbox-toolbar .chat-list-actions .chat-del-btn:hover:not(:disabled) {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.1);
  color: var(--red);
}
.inbox-toolbar .chat-list-actions .chat-block-btn:hover:not(:disabled) {
  border-color: rgba(255, 169, 77, 0.4);
  background: rgba(255, 169, 77, 0.12);
  color: #ffa94d;
}
.chat-act-btn {
  padding: 5px 10px;
  font-size: 0.72rem;
  border-radius: 9px;
}
.chat-act-btn:disabled { opacity: 0.42; cursor: not-allowed; }
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.chat-item {
  display: flex;
  gap: 10px;
  padding: 9px 10px;
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  position: relative;
  transition:
    background .22s var(--ease-out-expo),
    border-color .22s var(--ease-out-expo),
    transform .22s var(--ease-out-expo),
    box-shadow .22s var(--ease-out-expo);
}
.chat-item-motion {
  animation: inbox-item-enter .34s var(--ease-out-expo) backwards;
  animation-delay: calc(min(var(--i, 0), 14) * 24ms);
}
.chat-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  transform: translateY(-50%);
  transition: height .22s var(--ease-out-expo), opacity .22s var(--ease-out-expo);
  opacity: 0;
}
.chat-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
  transform: translateX(2px);
}
.chat-item:hover::before {
  height: 42%;
  opacity: 0.45;
}
.chat-item.active {
  background: rgba(200, 245, 66, 0.1);
  border-color: rgba(200, 245, 66, 0.22);
  box-shadow: inset 0 0 0 1px rgba(200, 245, 66, 0.08);
}
.chat-item.active::before {
  height: 58%;
  opacity: 1;
}
.chat-item.unread { background: rgba(124, 108, 255, 0.06); }
.chat-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  color: #101208;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: box-shadow .22s var(--ease-out-expo), transform .22s var(--ease-out-expo);
}
.chat-item.active .chat-av {
  box-shadow: 0 0 0 2px rgba(200, 245, 66, 0.35), 0 4px 14px rgba(0, 0, 0, 0.3);
}
.chat-av img, .lead-avatar img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.chat-av .av-fallback, .lead-avatar .av-fallback { position: relative; z-index: 0; }
.chat-body { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.chat-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item.has-unread {
  background: rgba(200, 245, 66, 0.06);
  border-color: rgba(200, 245, 66, 0.12);
}
.chat-item.has-unread .chat-name,
.chat-item.has-unread .chat-preview { color: var(--text); font-weight: 600; }
.chat-av-bot {
  background: rgba(46, 213, 115, 0.16) !important;
  color: #6fdc8c !important;
  border: 1px solid rgba(46, 213, 115, 0.35);
  box-shadow: none;
}
.chat-av-bot .av-fallback { color: #6fdc8c; font-weight: 700; }
.chat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #101208;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  vertical-align: middle;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.chat-time {
  font-size: 10px;
  color: #667080;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chat-time .chat-list-checks { margin-left: 2px; }
.chat-time .chat-list-checks.sent svg { width: 10px; height: 10px; }
.chat-time .chat-list-checks.read svg { width: 15px; height: 11px; }
.chat-time .chat-list-checks.sent { color: rgba(255,255,255,0.45); }
.chat-time .chat-list-checks.read { color: #4fae4e; }
.chat-time .chat-badge { margin-left: 2px; }
.chat-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  line-height: 1.35;
}
.chat-from {
  font-size: 10px;
  color: var(--accent);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
@keyframes inbox-item-enter {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}
.filter-chk { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.status-filter {
  width: 100%; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 12px; margin-bottom: 6px;
}
.status-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}
.status-tag.new { background: rgba(104, 109, 224, 0.25); color: #9aa4ff; }
.status-tag.work { background: rgba(255, 159, 67, 0.2); color: #ff9f43; }
.status-tag.sale { background: rgba(46, 213, 115, 0.2); color: #2ed573; }
.status-tag.reject { background: rgba(120, 120, 130, 0.25); color: #aaa; }
.status-tag:not(.new):not(.work):not(.sale):not(.reject) {
  background: rgba(124, 108, 255, 0.2); color: #b8a8ff;
}
.tpl-category-tab-status { flex: 0 0 auto; min-width: 72px; }
.templates-layout[data-mode="statuses"] {
  grid-template-columns: 1fr;
}
.templates-layout[data-mode="statuses"] .templates-list-panel,
.templates-layout[data-mode="statuses"] .templates-editor-panel {
  display: none !important;
}
.templates-layout[data-mode="playbook"] {
  grid-template-columns: 1fr !important;
}
.templates-layout[data-mode="playbook"] .templates-list-panel,
.templates-layout[data-mode="playbook"] .templates-editor-panel,
.templates-layout[data-mode="playbook"] #tplStatusPanel {
  display: none !important;
}
.templates-layout[data-mode="playbook"] #tplPlaybookPanel {
  display: block !important;
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow-x: hidden;
}
.templates-page.sales-learning-mode .templates-list-panel,
.templates-page.sales-learning-mode .templates-editor-panel {
  display: none !important;
}
.templates-page.sales-learning-mode .templates-layout {
  grid-template-columns: 1fr !important;
}
.templates-page.sales-learning-mode #tplPlaybookPanel {
  display: block !important;
  width: 100%;
  max-width: none;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}
.templates-layout[data-mode="job"] {
  grid-template-columns: 1fr;
}
.templates-layout[data-mode="job"] .templates-list-panel {
  display: none !important;
}
.templates-layout[data-mode="job"] .templates-editor-panel {
  background: transparent; border: none; padding: 0;
}
.templates-layout[data-mode="presets"] {
  grid-template-columns: 1fr;
}
.templates-layout[data-mode="presets"] .templates-editor-panel {
  display: none !important;
}
.templates-layout[data-mode="presets"] .templates-list-panel {
  max-width: none; margin: 0; width: 100%;
}
/* Сетка карточек AI-шаблонов на всю ширину */
.templates-layout[data-mode="presets"] .tpl-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  align-content: start;
  padding-right: 4px;
}
.templates-layout[data-mode="presets"] .tpl-list-item-wrap { gap: 0; }
.templates-layout[data-mode="presets"] .tpl-list-item {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.templates-layout[data-mode="presets"] .tpl-list-item:hover {
  border-color: rgba(124,108,255,.5);
  background: rgba(124,108,255,.10);
}
.templates-layout[data-mode="presets"] .tpl-list-item > span {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 28px;
}
.templates-layout[data-mode="presets"] .empty { grid-column: 1 / -1; }

/* Панель фильтров библиотеки AI-шаблонов — в стиле funnel-bar проекта */
.tpl-preset-filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 2px 2px 10px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tpl-preset-filters[hidden] { display: none !important; }
.tpl-filter-group { display: inline-flex; align-items: center; gap: 6px; }
.tpl-filter-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
}
/* сегмент-переключатель как .tpl-flow-mode-switch */
.tpl-seg {
  display: inline-flex; gap: 3px; padding: 3px;
  border: 1px solid var(--border); border-radius: 9px;
  background: rgba(255,255,255,.03);
}
.tpl-pf-chip {
  border: 0; border-radius: 7px; padding: 5px 11px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 11px; font-weight: 600; line-height: 1.4;
  transition: background .12s, color .12s;
}
.tpl-pf-chip:hover { color: var(--text); }
.tpl-pf-chip.active {
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: inset 0 0 0 1px rgba(200,245,66,.45);
}
.tpl-filter-sort {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.tpl-filter-sort select {
  min-width: 130px; padding: 6px 8px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-size: 12px; text-transform: none; letter-spacing: normal; cursor: pointer;
}
.tpl-filter-count {
  margin-left: auto; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: var(--accent); padding: 4px 9px; border-radius: 999px;
  border: 1px solid rgba(200,245,66,.32); background: rgba(200,245,66,.08);
}
.tpl-filter-group-muted { opacity: 0.4; pointer-events: none; }
.tpl-status-full-panel {
  grid-column: 1 / -1;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; min-height: 0; display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
}
.tpl-status-full-panel[hidden] { display: none !important; }
.tpl-status-head h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.tpl-status-head .hint { margin: 0; font-size: 12px; line-height: 1.4; }
.tpl-status-rows {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; padding-right: 4px; align-content: start;
}
.tpl-st-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.tpl-st-card-top {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.tpl-st-card-top .tpl-st-preview { flex: 0 1 auto; }
.tpl-st-card-top .tpl-st-meta { margin-left: auto; }
.tpl-st-preview {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 4px 10px;
  border-radius: 6px; text-transform: uppercase; letter-spacing: 0.3px;
}
.tpl-st-meta {
  display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap;
}
.tpl-st-badge-base {
  font-size: 10px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px;
}
.tpl-st-clients { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tpl-st-del {
  font-size: 11px; padding: 3px 8px; color: #ff6b6b;
}
.tpl-st-field { display: flex; flex-direction: column; gap: 4px; }
.tpl-st-field > span {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.tpl-st-field input[type="text"],
.tpl-st-field textarea {
  width: 100%; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; box-sizing: border-box;
  font-family: inherit; resize: vertical;
}
.tpl-st-field textarea { min-height: 56px; line-height: 1.4; }
.tpl-st-colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tpl-st-colors > span { font-size: 10px; color: var(--muted); margin-right: 2px; }
.tpl-st-color-dot {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; flex-shrink: 0;
}
.tpl-st-color-dot:hover { transform: scale(1.08); }
.tpl-st-color-dot.active { border-color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.tpl-status-foot {
  flex-shrink: 0; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding-top: 8px; border-top: 1px solid var(--border);
}
#tplListTools[hidden] { display: none !important; }

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(200, 245, 66, 0.03), transparent 60%),
    #0b1018;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(200, 245, 66, 0.03), transparent 60%),
    url("data:image/svg+xml,%3Csvg width='400' height='400' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.016'%3E%3Ccircle cx='20' cy='20' r='1.5'/%3E%3Ccircle cx='120' cy='80' r='1'/%3E%3Ccircle cx='240' cy='40' r='1.2'/%3E%3Ccircle cx='320' cy='140' r='1'/%3E%3Ccircle cx='60' cy='200' r='1.3'/%3E%3Ccircle cx='180' cy='280' r='1'/%3E%3Ccircle cx='300' cy='220' r='1.5'/%3E%3Ccircle cx='380' cy='340' r='1'/%3E%3C/g%3E%3C/svg%3E");
}
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--surface-glass-border);
  background: rgba(14, 18, 24, 0.82);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  min-height: 58px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}
.chat-header-peer { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; cursor: default; }
.chat-header-av {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(200, 245, 66, 0.35), rgba(106, 159, 210, 0.45));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 0 2px rgba(200, 245, 66, 0.15);
}
.chat-header-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-header-text { min-width: 0; }
.chat-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #f5f5f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.chat-header-sub {
  font-size: 12px;
  color: #7d8796;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.thread-filter {
  font-weight: 500;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  color: #7d8796;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--surface-glass-border);
  background: rgba(255, 255, 255, 0.03);
  transition: background .2s var(--ease-out-expo), border-color .2s var(--ease-out-expo);
}
.thread-filter:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.thread-filter input { cursor: pointer; accent-color: var(--accent); }
.icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: #7d8796;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition:
    background .22s var(--ease-out-expo),
    color .22s var(--ease-out-expo),
    border-color .22s var(--ease-out-expo),
    transform .22s var(--ease-out-expo);
}
.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--surface-glass-border);
  color: var(--text);
  transform: translateY(-1px);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.ghost-icon:hover:not(:disabled) {
  color: var(--red);
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
}
.chat-item-chk { flex-shrink: 0; display: flex; align-items: center; padding-right: 2px; }
.chat-item-chk input { cursor: pointer; accent-color: var(--accent); }

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.messages-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}
.scroll-bottom-btn {
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(22, 26, 32, 0.92);
  border: 1px solid var(--surface-glass-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 5;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  transition: opacity .2s var(--ease-out-expo), transform .2s var(--ease-out-expo);
  pointer-events: none;
}
.scroll-bottom-btn:not([hidden]) {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.scroll-bottom-btn:hover { border-color: rgba(200,245,66,.4); color: var(--accent); }
.empty-state, .messages > .empty {
  margin: auto;
  text-align: center;
  color: #7d8796;
  font-size: 14px;
  max-width: 300px;
  line-height: 1.55;
  padding: 28px 24px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}

/* ── Telegram message bubbles ── */
.tg-date-sep {
  align-self: center;
  margin: 14px 0 10px;
  padding: 5px 12px;
  background: rgba(14, 18, 24, 0.78);
  border: 1px solid var(--surface-glass-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #b8c0cc;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  user-select: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tg-msg {
  display: flex; max-width: min(480px, 85%); margin-bottom: 2px;
}
.tg-msg.in { align-self: flex-start; }
.tg-msg.out { align-self: flex-end; }
.tg-bubble {
  position: relative; border-radius: 12px; padding: 6px 9px 5px;
  box-shadow: 0 1px 2px rgba(16, 35, 47, 0.15);
  min-width: 60px;
}
/* Сообщение + inline-клавиатура бота (как в Telegram Desktop) */
.tg-msg-stack {
  display: flex; flex-direction: column; align-self: flex-start;
  max-width: min(360px, 88%); margin-bottom: 8px;
}
.tg-msg-stack.out { align-self: flex-end; }
.tg-msg-stack .tg-msg { margin-bottom: 0; max-width: 100%; }
.tg-bubble-above-kb {
  border-bottom-left-radius: 4px !important;
  border-bottom-right-radius: 4px !important;
}
.tg-inline-keyboard {
  width: 100%;
  min-width: 260px;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
  background: #2b3949;
  box-shadow: 0 1px 2px rgba(16, 35, 47, 0.2);
}
.tg-bot-row {
  display: grid;
  grid-template-columns: repeat(var(--tg-kb-row-cols, 1), 1fr);
  width: 100%;
}
.tg-bot-row + .tg-bot-row { border-top: 1px solid rgba(0, 0, 0, 0.28); }
.tg-bot-btn {
  appearance: none; -webkit-appearance: none;
  display: flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 12px; margin: 0;
  border: none; border-radius: 0;
  background: #2b3949;
  color: #6ab2f2;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1.25;
  text-align: center; text-decoration: none;
  cursor: pointer; user-select: none;
  transition: background 0.12s ease;
}
.tg-bot-row .tg-bot-btn + .tg-bot-btn { border-left: 1px solid rgba(0, 0, 0, 0.28); }
.tg-bot-btn:hover:not(:disabled) { background: #32485e; color: #7ec0ff; }
.tg-bot-btn:active:not(:disabled) { background: #3a5470; }
.tg-bot-btn:disabled { opacity: 0.5; cursor: wait; }
.tg-bot-btn-link { color: #6ab2f2; }

.reply-keyboard-bar {
  padding: 6px 10px 8px;
  border-top: 1px solid var(--surface-glass-border);
  background: rgba(14, 18, 24, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.reply-keyboard-bar[hidden] { display: none !important; }
.tg-reply-kb-grid {
  display: grid;
  grid-template-columns: repeat(var(--tg-rk-cols, 3), 1fr);
  gap: 6px;
}
.tg-reply-kb-btn {
  appearance: none; -webkit-appearance: none;
  min-height: 40px; padding: 8px 10px; margin: 0;
  border: none; border-radius: 8px;
  background: #2b3949;
  color: #f5f5f5;
  font-family: inherit; font-size: 14px; line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.15);
}
.tg-reply-kb-btn:hover { background: #32485e; }

.tg-msg.in .tg-bubble {
  background: #182533; color: #f5f5f5;
  border-bottom-left-radius: 4px;
}
.tg-msg.out .tg-bubble {
  background: #2b5278; color: #fff;
  border-bottom-right-radius: 4px;
}
.tg-bubble-inner { position: relative; }
.tg-bubble-inner.tg-text-layout { display: block; }
.tg-bubble-inner.tg-text-layout > .tg-text {
  font-size: 15px; line-height: 1.3125; white-space: pre-wrap; word-break: break-word;
}
.tg-bubble-inner.tg-text-layout > .tg-text::after {
  content: ''; display: table; clear: both;
}
.tg-bubble-inner.tg-text-layout .tg-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  margin-top: 5px;
  margin-bottom: -2px;
  position: relative;
  top: 2px;
  user-select: none;
  pointer-events: none;
  height: 15px;
}
.tg-bubble-inner.tg-media-layout > .tg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  user-select: none;
  height: 18px;
}
.tg-time {
  font-size: 11px; line-height: 18px; color: rgba(255,255,255,0.45);
  white-space: nowrap;
}
.tg-msg.in .tg-time { color: rgba(112,132,153,0.9); }
.tg-checks {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 15px; flex-shrink: 0; margin-left: 1px;
}
.tg-checks.sent { color: rgba(255,255,255,0.55); }
.tg-checks.read { color: #4fae4e; }
.tg-checks svg { display: block; width: 16px; height: 15px; }
.tg-checks.sent svg { width: 11px; height: 11px; }

.tg-bubble.media-voice, .tg-bubble.media-audio { min-width: 240px; padding: 6px 10px 4px; }
.tg-voice-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.tg-voice-icon {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: rgba(106,178,242,0.15); color: #6ab2f2;
  display: flex; align-items: center; justify-content: center;
}
.tg-msg.out .tg-voice-icon { background: rgba(255,255,255,0.12); color: #fff; }
.tg-bubble audio {
  flex: 1; min-width: 0; height: 36px;
}
.tg-msg.in .tg-bubble audio { filter: invert(0.82) hue-rotate(180deg); opacity: 0.9; }

.tg-bubble.media-photo {
  padding: 3px; background: transparent !important; box-shadow: none;
  border-radius: 12px; overflow: hidden;
}
.tg-bubble.media-photo .tg-bubble-inner { position: relative; display: inline-block; }
.tg-bubble.media-photo .msg-photo {
  display: block; max-width: 320px; max-height: 400px; border-radius: 10px;
}
.tg-bubble.media-photo.has-caption {
  padding: 3px 3px 0;
  background: #182533 !important;
  box-shadow: 0 1px 2px rgba(16, 35, 47, 0.15);
}
.tg-bubble.media-photo.has-caption .msg-photo {
  border-radius: 10px 10px 0 0;
}
.tg-caption {
  padding: 6px 8px 4px;
  font-size: 15px;
  line-height: 1.35;
  color: #f5f5f5;
  white-space: normal;
  word-break: break-word;
}
.tg-caption a { color: #6ab2f2; text-decoration: none; }
.tg-caption a:hover { text-decoration: underline; }
.tg-caption-meta {
  display: flex; justify-content: flex-end;
  padding: 0 8px 4px;
}
.tg-caption-meta .tg-meta { position: static; background: none; padding: 0; }
.tg-bubble.media-photo .tg-meta {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.55); padding: 1px 7px 1px 9px; border-radius: 11px;
  height: auto; margin: 0;
}
.tg-bubble.media-photo.has-caption .tg-meta { display: none; }
.tg-bubble.media-photo .tg-time { color: rgba(255,255,255,0.9); line-height: 16px; }
.tg-bubble.media-photo .tg-checks { width: 16px; height: 16px; }
.tg-bubble.media-photo .tg-checks svg { width: 16px; height: 16px; }

.tg-bubble.media-video video {
  max-width: 320px; border-radius: 8px; display: block; margin-bottom: 2px;
}
.tg-doc-row { display: flex; align-items: center; gap: 12px; margin-bottom: 2px; }
.tg-doc-icon {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  background: #8774e1; color: #fff; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.tg-doc-name { font-size: 14px; font-weight: 500; word-break: break-all; }
.tg-doc-link { font-size: 13px; color: #6ab2f2; text-decoration: none; display: block; margin-top: 2px; }
.tg-doc-link:hover { text-decoration: underline; }

/* legacy bubble aliases (fallback) */
.bubble { max-width: min(480px, 85%); padding: 6px 9px; border-radius: 12px; font-size: 15px; line-height: 1.3125; }
.bubble.in { align-self: flex-start; background: #182533; color: #f5f5f5; border-bottom-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #2b5278; color: #fff; border-bottom-right-radius: 4px; }

/* ── composer ── */
.composer-wrap {
  flex-shrink: 0;
  background: rgba(14, 18, 24, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--surface-glass-border);
  position: relative;
  overflow: visible;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
}
.composer-wrap [hidden] { display: none !important; }
.attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--surface-glass-border);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  color: #f5f5f5;
}
.attach-preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--surface-glass-border);
}
.attach-preview-info { flex: 1; min-width: 0; }
.attach-preview-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-preview-size { color: #7d8796; font-size: 11px; margin-top: 2px; }
.attach-preview .attach-clear {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--surface-glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: #7d8796;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .2s var(--ease-out-expo), color .2s var(--ease-out-expo);
}
.attach-preview .attach-clear:hover {
  background: rgba(255, 107, 107, 0.15);
  color: var(--red);
  border-color: rgba(255, 107, 107, 0.3);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px 10px;
}
.composer-left { position: relative; flex-shrink: 0; }
.composer-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--surface-glass-border);
  border-radius: 22px;
  padding: 0 4px 0 12px;
  min-height: 44px;
  transition: border-color .22s var(--ease-out-expo), box-shadow .22s var(--ease-out-expo);
}
.composer-field:focus-within {
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.08);
}
.composer-field textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: #f5f5f5;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  padding: 10px 6px 10px 0;
  max-height: 150px;
  min-height: 22px;
  width: 100%;
  outline: none;
  box-sizing: border-box;
}
.composer-field textarea::placeholder { color: #667080; }
.composer-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #7d8796;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color .22s var(--ease-out-expo), background .22s var(--ease-out-expo), transform .22s var(--ease-out-expo);
}
.composer-icon:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.04);
}
.composer-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.composer-emoji { width: 38px; height: 42px; margin-right: 2px; }
.composer-svg { width: 24px; height: 24px; display: block; }
.composer-send {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: rgba(200, 245, 66, 0.08);
  color: #7d8796;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    color .22s var(--ease-out-expo),
    background .22s var(--ease-out-expo),
    border-color .22s var(--ease-out-expo),
    box-shadow .22s var(--ease-out-expo),
    transform .22s var(--ease-out-expo);
  padding: 0;
}
.composer-send .send-icon { color: var(--accent); transition: color .22s var(--ease-out-expo); }
.composer-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}
.composer-send:hover:not(:disabled) .send-icon { color: #101208; }
.composer-send:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; background: transparent; }

.attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  background: rgba(14, 18, 24, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  overflow: hidden;
  animation: attachPop 0.22s var(--ease-out-expo);
}
@keyframes attachPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.attach-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: transparent;
  border: none;
  color: #f5f5f5;
  font-size: 14px;
  cursor: pointer;
  transition: background .18s var(--ease-out-expo), color .18s var(--ease-out-expo);
}
.attach-menu button:hover {
  background: rgba(200, 245, 66, 0.1);
  color: var(--accent);
}
.attach-menu button + button { border-top: 1px solid var(--surface-glass-border); }

.emoji-panel {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  z-index: 60;
  background: rgba(14, 18, 24, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  padding: 10px;
  max-height: 220px;
  overflow-y: auto;
  animation: attachPop 0.22s var(--ease-out-expo);
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}
.emoji-grid button {
  width: 100%;
  aspect-ratio: 1;
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  border-radius: 8px;
  line-height: 1;
  transition: background .12s, transform .12s;
}
.emoji-grid button:hover {
  background: rgba(200, 245, 66, 0.12);
  transform: scale(1.12);
}

/* ── Быстрые ответы (шаблоны в композере) ── */
.quick-reply-panel {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  z-index: 60;
  background: rgba(14, 18, 24, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
  animation: attachPop 0.22s var(--ease-out-expo);
}
.qr-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin-bottom: 8px;
}
.qr-link {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  font-size: 11px; font-weight: 600; color: var(--accent); text-transform: none;
  letter-spacing: 0;
}
.qr-link:hover { text-decoration: underline; }
.qr-list { display: flex; flex-direction: column; gap: 5px; }
.qr-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; font-size: 12.5px; line-height: 1.3; color: var(--text);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 9px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s var(--ease-out-expo), border-color .15s var(--ease-out-expo);
}
.qr-item:hover { background: rgba(200,245,66,0.1); border-color: rgba(200,245,66,0.35); }
.qr-empty { font-size: 12px; color: var(--muted); line-height: 1.4; padding: 6px 2px; }
.qr-edit {
  width: 100%; min-height: 120px; resize: vertical; padding: 9px 11px;
  background: rgba(0,0,0,0.28); border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md); color: var(--text); color-scheme: dark;
  font: inherit; font-size: 12.5px; line-height: 1.4;
}
.qr-edit-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.qr-hint { font-size: 11px; color: var(--muted); }
.qr-save {
  padding: 6px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
  color: #0c0f12; background: var(--accent); border: none; border-radius: 8px;
}
.qr-save:hover { filter: brightness(1.05); }

.preset-btn { margin-top: 8px; margin-right: 8px; font-size: 12px; }
.primary, .btn { background: linear-gradient(135deg, #8774e1, #6c9fd2); color: #fff; border: none; font-weight: 600; cursor: pointer; font-size: 13px; }

.lead-panel {
  border-right: 1px solid var(--surface-glass-border);
  background:
    linear-gradient(180deg, rgba(14, 17, 22, 0.96) 0%, rgba(11, 13, 16, 0.98) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.02);
  transition: opacity .2s var(--ease-out-expo);
}
.lead-panel-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.lead-empty:not([hidden]) {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 16px;
  line-height: 1.55;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
}
.lead-empty[hidden],
.lead-body[hidden] {
  display: none !important;
}
.lead-body:not([hidden]) {
  width: 100%;
}
.lead-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 14px;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(200, 245, 66, 0.35), rgba(104, 109, 224, 0.45));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.12), 0 8px 24px rgba(0, 0, 0, 0.28);
}
.lead-saved { text-align: center; font-size: 11px; color: var(--muted); margin: -8px 0 12px; min-height: 16px; }
.lead-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.lead-body h3 { text-align: center; margin: 0; font-size: 17px; font-weight: 700; }
.lead-star-btn {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  opacity: 0.55;
  flex-shrink: 0;
  transition: opacity .2s var(--ease-out-expo), border-color .2s var(--ease-out-expo), transform .2s var(--ease-out-expo);
}
.lead-star-btn:hover { opacity: 0.9; border-color: rgba(254, 202, 87, 0.35); transform: scale(1.05); }
.lead-star-btn.active { color: #feca57; opacity: 1; border-color: rgba(254, 202, 87, 0.4); background: rgba(254, 202, 87, 0.08); }
.lead-handle { text-align: center; color: var(--accent); font-size: 13px; margin: 0 0 14px; font-weight: 500; }
.chat-star-inline { color: #feca57; font-size: 11px; margin-right: 3px; }
.client-st-starred-quick.active { border-color: #feca57 !important; color: #feca57 !important; }
.lead-meta {
  margin-bottom: 14px;
}
.lead-acc-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: background .18s var(--ease-out-expo), border-color .18s var(--ease-out-expo);
}
.lead-acc-chip:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.18); }
.lead-acc-chip-av {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #101208; font-weight: 700; font-size: 13px;
}
.lead-acc-chip-av img { width: 100%; height: 100%; object-fit: cover; }
.lead-acc-chip-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lead-acc-chip-cap { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lead-acc-chip-name { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-acc-chip-arr { flex-shrink: 0; color: var(--muted); transition: color .18s; }
.lead-acc-chip:hover .lead-acc-chip-arr { color: var(--accent); }
/* Модалка «Наш аккаунт» */
.our-acc-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.our-acc-av {
  width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #101208; font-weight: 700; font-size: 22px;
}
.our-acc-av img { width: 100%; height: 100%; object-fit: cover; }
.our-acc-name { font-size: 17px; font-weight: 700; color: var(--text); }
.our-acc-handle { font-size: 13px; color: var(--accent); margin: 2px 0 4px; }
.our-acc-state { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.our-acc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.our-acc-grid > div {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--surface-glass-border); border-radius: var(--radius-md);
}
.our-acc-grid b { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.our-acc-grid span { font-size: 13px; color: var(--text); }
.copyable { cursor: pointer; transition: color .15s var(--ease-out-expo); border-radius: 4px; }
.copyable:hover { color: var(--accent); text-decoration: underline dotted; text-underline-offset: 2px; }
@keyframes copyFlash {
  0% { background: rgba(200, 245, 66, 0.45); box-shadow: 0 0 0 4px rgba(200, 245, 66, 0.18); }
  100% { background: transparent; box-shadow: 0 0 0 4px rgba(200, 245, 66, 0); }
}
.copied-flash { animation: copyFlash .6s var(--ease-out-expo); }
.copy-tip {
  position: fixed;
  z-index: 100000;
  transform: translate(-50%, -90%);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #101208;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: opacity .2s var(--ease-out-expo), transform .2s var(--ease-out-expo);
}
.copy-tip.show { opacity: 1; transform: translate(-50%, -120%); }
/* ── Действия над диалогом (блок / контакт / удаление в TG) ── */
.lead-actions { margin-bottom: 14px; }
.lead-peer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  min-height: 16px;
}
.lead-peer-status .peer-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6b7280; flex-shrink: 0;
}
.lead-peer-status .peer-dot.on { background: var(--green); box-shadow: 0 0 6px rgba(92,219,122,.6); }
.peer-tag {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em;
}
.peer-tag.bot { color: #62b6ff; border-color: rgba(98,182,255,.4); background: rgba(98,182,255,.1); }
.lead-action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.lead-act {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 3px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: -.1px;
  line-height: 1.05;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: background .18s var(--ease-out-expo), border-color .18s var(--ease-out-expo), color .18s var(--ease-out-expo);
}
.lead-act svg { flex-shrink: 0; width: 15px; height: 15px; opacity: .8; }
.lead-act:hover:not(:disabled) { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: var(--text); }
.lead-act:disabled { opacity: .5; cursor: not-allowed; }
.lead-act.is-active {
  color: var(--accent);
  border-color: rgba(200,245,66,.4);
  background: rgba(200,245,66,.1);
}
.lead-act.is-active svg { opacity: 1; }
.lead-act.danger:hover:not(:disabled) {
  color: var(--red);
  border-color: rgba(255,107,107,.45);
  background: rgba(255,107,107,.1);
}
.chat-header-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.2;
}
.chat-header-status.is-online { color: var(--green); }
.lead-field {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.lead-field input[type=text] {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  font-size: 13px;
  transition: border-color .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo);
}
.lead-field input[type=text]:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.08);
}
.lead-tpl-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.lead-tpl-row select { flex: 1; min-width: 0; }
.lead-ar-hint { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.35; }
.lead-ar-group {
  margin-bottom: 12px;
  padding: 10px 12px 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--radius-md);
}
.lead-ar-group .lead-field { margin-bottom: 10px; }
.lead-ar-group .lead-field:last-of-type { margin-bottom: 0; }
.lead-ar-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.tpl-apply-btn { flex-shrink: 0; padding: 7px 10px; font-size: 11px; white-space: nowrap; }
.lead-ai-context {
  margin: 0 0 12px;
  padding: 10px 11px;
  border: 1px solid rgba(255, 180, 60, 0.35);
  border-left: 3px solid var(--warning);
  border-radius: 10px;
  background: rgba(255, 180, 60, 0.08);
}
.lead-ai-title {
  color: var(--warning);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .35px;
  margin-bottom: 5px;
}
.lead-ai-source {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}
.lead-ai-text {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 130px;
  overflow-y: auto;
}
.lead-ai-msgs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
}
.client-card-ai-msgs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.templates-page {
  height: 100%; min-height: 0; display: flex; flex-direction: column;
  padding: 10px 12px; box-sizing: border-box; overflow: hidden; gap: 8px;
}
.tpl-category-tabs {
  display: flex; gap: 6px; flex-shrink: 0;
}
.tpl-category-tab {
  flex: 1; padding: 8px 10px; font-size: 12px; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  color: var(--muted); cursor: pointer;
}
.tpl-category-tab.active {
  border-color: rgba(124, 108, 255, 0.5); color: var(--text);
  background: rgba(124, 108, 255, 0.14);
}
.tpl-category-tab[data-tpl-category="global"].active {
  border-color: rgba(61, 214, 140, 0.45); background: rgba(61, 214, 140, 0.1);
}
.tpl-category-tab[data-tpl-category="job"].active {
  border-color: rgba(124, 108, 255, 0.5); background: rgba(124, 108, 255, 0.14);
}
.tpl-list-new-btn {
  width: 100%; margin-bottom: 8px; padding: 9px 12px; font-size: 12px; font-weight: 600;
}
.primary.tpl-list-new-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #101208;
}
.primary.tpl-list-new-btn:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
}
.tpl-editor-empty {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
#tplEditorEmpty[hidden] { display: none !important; }
.tpl-empty-inner { max-width: 280px; }
.tpl-empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.tpl-editor-form {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
#tplEditorDock { min-height: 0; }
#tplEditorForm[hidden] { display: none !important; }
.tpl-toolbar {
  flex-shrink: 0; display: flex; flex-direction: column; gap: 6px;
  padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
}
.tpl-toolbar-compact { gap: 5px; }
.tpl-toolbar-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tpl-toolbar-mid { align-items: flex-end; }
.tpl-ar-inline { min-width: 100px; flex: 0 1 auto; }
.tpl-editor-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.tpl-editor-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  flex: 0 0 clamp(160px, 32vh, 240px);
  min-height: 160px;
}
.tpl-field-compact {
  display: flex; flex-direction: column; min-height: 0; margin: 0;
}
.tpl-field-compact textarea {
  flex: 1; min-height: 0; width: 100%; box-sizing: border-box;
  resize: none; line-height: 1.45; font-size: 13px;
}
.tpl-variants-pane {
  flex: 1; min-height: 100px; overflow-y: auto; margin: 0;
  padding-right: 2px;
}
.tpl-variants-pane::-webkit-scrollbar { width: 8px; }
.tpl-variants-pane::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14); border-radius: 999px;
}
.tpl-job-header {
  margin-bottom: 10px; padding: 10px; border-radius: 10px;
  background: rgba(124, 108, 255, 0.08); border: 1px solid rgba(124, 108, 255, 0.22);
}
.tpl-job-header[hidden] { display: none !important; }
.tpl-job-status-line {
  margin: 8px 0 4px; font-size: 12px; line-height: 1.45; color: var(--text);
}
.tpl-job-status-line .tpl-job-on { color: var(--green); font-weight: 600; }
.tpl-job-status-line .tpl-job-off { color: var(--muted); }
.tpl-job-playbook-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.tpl-job-playbook-tools button {
  width: 100%;
  min-height: 32px;
  padding: 7px 8px;
  white-space: nowrap;
}
.tpl-job-playbook-tools .tpl-job-auto-safe-btn {
  grid-column: 1 / -1;
}
.tpl-job-rules-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
/* ── Funnel constructor (ИИ для задач) ── */
.tpl-funnel-board {
  --fl-line: rgba(141, 198, 255, 0.45);
  flex: 1; min-height: 0; overflow: auto;
  border: 1px solid rgba(124, 108, 255, 0.28);
  border-radius: 12px;
  padding: 10px 12px 14px;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(124, 108, 255, 0.16), rgba(124, 108, 255, 0.015)),
    var(--panel);
}
.tpl-funnel-board[hidden] { display: none !important; }

/* top control bar */
.tpl-funnel-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.tpl-funnel-bar .tpl-funnel-job-field {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
.tpl-funnel-bar select {
  min-width: 160px; padding: 6px 8px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 12px;
}
.tpl-funnel-bar .tpl-funnel-count {
  font-size: 11px; color: var(--green); font-weight: 700;
  padding: 4px 8px; border-radius: 999px; border: 1px solid rgba(61,214,140,.3);
  background: rgba(61,214,140,.08); white-space: nowrap;
}
.tpl-funnel-bar .tpl-funnel-count.off { color: var(--muted); border-color: var(--border); background: transparent; }
.tpl-funnel-bar .tpl-funnel-schema-badge {
  font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px;
  border: 1px solid rgba(200,245,66,.32); background: rgba(200,245,66,.08);
  color: var(--accent); white-space: nowrap;
}
.tpl-funnel-bar .tpl-funnel-schema-badge.empty {
  color: var(--muted); border-color: var(--border); background: rgba(255,255,255,.03); font-weight: 600;
}
.tpl-funnel-bar .tpl-funnel-learning-btn {
  border-color: rgba(200,245,66,.28);
  white-space: nowrap;
}
.tpl-funnel-bar .tpl-funnel-learning-btn.primary {
  box-shadow: 0 0 0 1px rgba(200,245,66,.24), 0 0 18px rgba(200,245,66,.12);
}
.tpl-funnel-bar .tpl-funnel-bar-spacer { flex: 1; min-width: 8px; }
.tpl-funnel-bar .ghost, .tpl-funnel-bar .primary { padding: 6px 10px; font-size: 11px; }
.tpl-flow-mode-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255,255,255,.03);
}
.tpl-flow-mode-switch button {
  border: 0;
  border-radius: 7px;
  padding: 5px 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.tpl-flow-mode-switch button.active {
  color: var(--text);
  background: rgba(124,108,255,.28);
  box-shadow: inset 0 0 0 1px rgba(124,108,255,.35);
}

/* node-builder workspace */
.tpl-flow-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  height: 66vh;
  min-height: 460px;
  max-height: 780px;
}
.tpl-flow-layout.no-panel {
  grid-template-columns: minmax(0, 1fr);
}
.tpl-flow-canvas-shell {
  min-width: 0;
  overflow: auto;
  height: 100%;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(0,0,0,.12);
  position: relative;
  cursor: grab;
}
.tpl-flow-canvas-shell.panning { cursor: grabbing; }
.tpl-flow-workspace {
  position: relative;
  overflow: hidden;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(rgba(124,108,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,108,255,.06) 1px, transparent 1px);
  background-size: 22px 22px, 88px 88px, 88px 88px;
  background-position: 0 0;
}
.tpl-flow-lines {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.tpl-flow-line-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  pointer-events: stroke;
  cursor: pointer;
}
.tpl-flow-line {
  fill: none;
  stroke: var(--flow-color, rgba(141,198,255,.76));
  stroke-width: 2.2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--flow-color, #8dc6ff) 35%, transparent));
  pointer-events: none;
  transition: stroke-width .12s ease, opacity .15s ease;
}
.tpl-flow-line.hover,
.tpl-flow-line.selected {
  stroke-width: 4;
  filter: drop-shadow(0 0 9px var(--flow-color, rgba(141,198,255,.6)));
}
.tpl-flow-line.muted { opacity: .16; }
.tpl-flow-line.duplicate { stroke-dasharray: 7 5; }
/* Перекрёстные (не-остовные) связи: в покое еле видны → холст читается как
   чистое дерево. Подсвечиваются при наведении на связанный узел. */
.tpl-flow-line--cross { opacity: .1; }
.tpl-flow-line--cross.selected { opacity: 1; }
/* Фокус по наведению на карточку: гасим все нити кроме связанных с узлом,
   связанные — ярко. Делает плотный граф (много переходов) читаемым. */
.tpl-flow-workspace.tpl-flow-focus .tpl-flow-line { opacity: .05; }
.tpl-flow-workspace.tpl-flow-focus .tpl-flow-line.lit {
  opacity: 1;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 8px var(--flow-color, rgba(141,198,255,.6)));
}
.tpl-flow-workspace.tpl-flow-focus .tpl-flow-line-badge { opacity: 0; }
.tpl-flow-arrow-interest { fill: #7ee787; }
.tpl-flow-arrow-objection { fill: #ffc857; }
.tpl-flow-arrow-human { fill: #57b7ff; }
.tpl-flow-arrow-reject { fill: #ff5b6b; }
.tpl-flow-arrow-sale { fill: #35e58f; }
.tpl-flow-arrow-neutral { fill: #b8a8ff; }
/* Бейджи скрыты по умолчанию — canvas без текстового шума. */
.tpl-flow-line-badge {
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}
.tpl-flow-line-badge.hover,
.tpl-flow-line-badge.selected { opacity: 1; }
.tpl-flow-line-badge.muted { opacity: 0; }
.tpl-flow-line-badge rect {
  fill: rgba(8,10,18,.92);
  stroke: var(--flow-color, rgba(255,255,255,.2));
  stroke-width: 1.2;
}
.tpl-flow-line-badge text {
  fill: var(--text);
  font-size: 10px;
  text-anchor: middle;
  font-weight: 700;
}
.tpl-flow-temp-line {
  fill: none;
  stroke: #c4b5fd;
  stroke-width: 2.4;
  stroke-dasharray: 8 6;
  pointer-events: none;
  filter: drop-shadow(0 0 7px rgba(196,181,253,.5));
}
.tpl-flow-node {
  position: absolute;
  z-index: 2;
  width: 146px;
  min-width: 118px;
  max-width: 190px;
  height: auto;
  cursor: grab;
  user-select: none;
  --node-color: #b8a8ff;
}
.tpl-flow-node:active { cursor: grabbing; }
.tpl-flow-node.selected .tpl-flow-node-card {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--node-color) 75%, transparent), 0 14px 36px rgba(0,0,0,.32);
}
.tpl-flow-node.connect-target .tpl-flow-node-card {
  box-shadow: 0 0 0 2px #c4b5fd, 0 0 22px rgba(196,181,253,.45);
}
.tpl-flow-node-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--node-color) 55%, rgba(255,255,255,.12));
  border-top: 3px solid var(--node-color);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--node-color) 16%, transparent), rgba(255,255,255,.03)),
    rgba(14,16,28,.92);
  border-radius: 10px;
  padding: 7px 8px;
  box-shadow: 0 0 14px color-mix(in srgb, var(--node-color) 14%, transparent);
}
/* Статус без AI-шаблона: приглушённый, пунктирная рамка. */
.tpl-flow-node.empty .tpl-flow-node-card {
  border-style: dashed;
  border-top-style: solid;
  opacity: .72;
  background: rgba(14,16,28,.84);
  box-shadow: none;
}
.tpl-flow-node.empty:hover .tpl-flow-node-card { opacity: 1; }
.tpl-flow-node-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tpl-flow-tpl-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.tpl-flow-tpl-title.empty { color: var(--muted); font-weight: 500; }

/* Компактные карточки статусов на холсте (не трогаем list-режим) */
.tpl-flow-node .tpl-funnel-agent {
  min-height: 0;
  padding: 5px 6px;
  gap: 2px;
  border-radius: 8px;
}
.tpl-flow-node .tpl-funnel-agent .tpl-funnel-agent-kind { font-size: 8px; }
.tpl-flow-node .tpl-funnel-agent strong,
.tpl-flow-node .tpl-flow-tpl-title {
  font-size: 10px; line-height: 1.25; -webkit-line-clamp: 1;
}
.tpl-flow-node .tpl-flow-pb-badge {
  font-size: 8px; padding: 1px 6px; margin-top: 2px;
}
.tpl-flow-node .tpl-funnel-agent-actions { gap: 3px; }
.tpl-flow-node .tpl-funnel-agent-actions button { font-size: 9px; padding: 3px 4px; border-radius: 5px; }
.tpl-flow-node .tpl-flow-node-title { font-size: 11px; }
.tpl-flow-node .tpl-funnel-start-toggle span { font-size: 8px; }
.tpl-flow-start-flag {
  flex-shrink: 0; margin-left: auto;
  font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: #a78bfa; padding: 1px 6px; border-radius: 999px;
  border: 1px solid rgba(167,139,250,.5); background: rgba(167,139,250,.14);
}
.tpl-flow-resize {
  position: absolute;
  z-index: 5;
  width: 14px;
  height: 14px;
  opacity: 0;
  background: transparent;
}
.tpl-flow-resize-nw { left: -3px; top: -3px; cursor: nwse-resize; }
.tpl-flow-resize-ne { right: -3px; top: -3px; cursor: nesw-resize; }
.tpl-flow-resize-sw { left: -3px; bottom: -3px; cursor: nesw-resize; }
.tpl-flow-resize-se { right: -3px; bottom: -3px; cursor: nwse-resize; }
/* Режим «+ Нить»: карточки — цели, любая точка карточки = attachment point. */
.tpl-flow-workspace.drawing,
.tpl-flow-workspace.drawing .tpl-flow-node { cursor: crosshair; }
.tpl-flow-workspace.drawing .tpl-flow-node:hover .tpl-flow-node-card {
  box-shadow: 0 0 0 2px #c4b5fd, 0 0 22px rgba(196,181,253,.4);
}
.tpl-flow-anchor-handle {
  fill: #0f1320;
  stroke: var(--flow-color, #c4b5fd);
  stroke-width: 2.5;
  cursor: grab;
  pointer-events: auto;
  filter: drop-shadow(0 0 6px var(--flow-color, rgba(196,181,253,.6)));
}
.tpl-flow-anchor-handle:active { cursor: grabbing; }
.tpl-flow-line-menu {
  position: fixed;
  z-index: 10020;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: rgba(11,14,25,.96);
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tpl-flow-line-menu button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  text-align: left;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}
.tpl-flow-line-menu button:hover {
  border-color: rgba(124,108,255,.45);
  background: rgba(124,108,255,.18);
}
.tpl-flow-panel {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  background: rgba(0,0,0,.16);
  padding: 12px;
  min-height: 240px;
  max-height: 640px;
  overflow: auto;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.tpl-flow-panel-title,
.tpl-flow-panel-subtitle {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.tpl-flow-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}
.tpl-flow-panel input,
.tpl-flow-panel textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 7px 8px;
  font-size: 11px;
}
.tpl-flow-warning {
  border: 1px solid rgba(255,200,87,.35);
  border-radius: 8px;
  background: rgba(255,200,87,.1);
  color: #ffc857;
  padding: 7px 8px;
  font-size: 11px;
}
.tpl-flow-warning.err {
  border-color: rgba(255,91,107,.4);
  background: rgba(255,91,107,.1);
  color: #ff8a96;
}
.tpl-flow-warning.soft {
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  color: var(--muted);
}
.tpl-flow-ok {
  border: 1px solid rgba(53,229,143,.35);
  border-radius: 8px;
  background: rgba(53,229,143,.1);
  color: #35e58f;
  padding: 7px 8px;
  font-size: 11px;
}
.tpl-flow-lib-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px dashed rgba(255,255,255,.14);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
}
[data-flow-lib-status],
[data-flow-lib-tpl],
[data-flow-lib-transition] {
  cursor: grab;
}
.tpl-flow-lib-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tpl-flow-lib-row button {
  flex: none;
  padding: 4px 8px !important;
}
.tpl-flow-lib-type {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--badge-color, #b8a8ff);
  border: 1px solid color-mix(in srgb, var(--badge-color, #b8a8ff) 55%, transparent);
}
.tpl-flow-panel button.danger {
  border-color: rgba(255,91,107,.45);
  background: rgba(255,91,107,.12);
  color: #ff8a96;
}
.tpl-flow-panel select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,.18);
  color: var(--text);
  padding: 6px 8px;
  font-size: 11px;
}
.tpl-flow-undo {
  min-width: 30px;
  font-size: 14px;
  padding: 4px 8px !important;
}
.tpl-flow-undo:disabled {
  opacity: .35;
  cursor: default;
}
.tpl-flow-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-flow-panel button,
.tpl-flow-panel-transition {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 7px 9px;
  text-align: left;
  cursor: pointer;
  font-size: 11px;
}
.tpl-flow-panel button.primary {
  background: rgba(124,108,255,.28);
  border-color: rgba(124,108,255,.45);
}
/* Мини-схема: свёрнута в кнопку, открывается по клику. */
.tpl-flow-minimap-wrap {
  position: sticky;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: fit-content;
  max-width: min(520px, calc(100% - 20px));
  margin: -40px 0 10px 10px;
}
.tpl-flow-minimap-toggle {
  align-self: flex-start;
  border: 1px solid rgba(124,108,255,.35);
  border-radius: 999px;
  background: rgba(12,14,24,.88);
  color: var(--muted);
  padding: 5px 11px;
  font-size: 10px;
  cursor: pointer;
}
.tpl-flow-minimap-toggle:hover { color: var(--text); border-color: rgba(124,108,255,.6); }
.tpl-flow-minimap {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(12,14,24,.92);
  backdrop-filter: blur(8px);
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  color: var(--muted);
  font-size: 10px;
  max-height: 140px;
  overflow: auto;
}
.tpl-flow-minimap[hidden] { display: none; }
.tpl-flow-minimap span {
  border: 1px solid rgba(124,108,255,.18);
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(124,108,255,.08);
}
.tpl-flow-type-badge {
  align-self: flex-start;
  border: 1px solid var(--badge-color, #b8a8ff);
  color: var(--badge-color, #b8a8ff);
  background: color-mix(in srgb, var(--badge-color, #b8a8ff) 12%, transparent);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 700;
}

/* Sales playbook (База техник) */
.pb-toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 10px;
}
.pb-toolbar input[type="text"] { flex: 1; min-width: 220px; }
.pb-toolbar select { min-width: 150px; }
.pb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; margin-top: 10px; }
.pb-card {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  padding: 10px 12px;
  overflow-wrap: anywhere;
}
.pb-card-selectable { cursor: pointer; }
.pb-card-selected { border-color: rgba(124,108,255,.55); background: rgba(124,108,255,.1); }
.pb-card.pb-inactive { opacity: .45; }
.pb-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 4px; }
.pb-badges { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }
.pb-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.pb-badge.pb-cat { border-color: rgba(124,108,255,.45); color: #b8a8ff; }
.pb-badge.pb-obj { border-color: rgba(255,200,87,.45); color: #ffc857; }
.pb-badge.pb-ok { border-color: rgba(126,231,135,.45); color: #7ee787; }
.pb-badge.pb-pending { border-color: rgba(255,160,87,.45); color: #ffa057; }
.pb-situation { color: var(--muted); font-size: 12px; margin: 4px 0 6px; }
.pb-card details summary { cursor: pointer; color: #b8a8ff; font-size: 12px; }
.pb-card details p { font-size: 12px; margin: 5px 0; }
.pb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pb-tabs-sticky {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 8px 0;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.pb-tab {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(255,255,255,.03); color: var(--muted); cursor: pointer;
}
.pb-tab.active { color: #fff; border-color: rgba(124,108,255,.55); background: rgba(124,108,255,.15); }
.pb-pane { margin-bottom: 12px; }
.pb-subtitle { font-size: 14px; margin: 8px 0; color: #ddd; }
.pb-head h2 { margin: 0 0 4px; font-size: 22px; }
.pb-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.9fr);
  gap: 12px;
  align-items: start;
}
.pb-list-compact {
  grid-template-columns: 1fr;
  max-height: calc(100vh - 360px);
  overflow-y: auto;
}
.pb-detail-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  padding: 12px;
  position: sticky;
  top: 56px;
  min-height: 220px;
}
.pb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
  margin: 8px 0;
}
.pb-kpi {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.03);
  padding: 8px;
}
.pb-kpi b { display: block; font-size: 16px; }
.pb-result {
  white-space: pre-wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  padding: 10px;
  max-height: 280px;
  overflow-y: auto;
}
.pb-result[hidden] { display: none !important; }
.tpl-test-reply-block { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 8px 0 10px; background: rgba(255,255,255,.02); }
.tpl-test-reply-samples { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.tpl-test-reply-samples .ghost { font-size: 12px; padding: 4px 8px; }
#tplPlaybookPanel {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding-right: 6px;
}
.tpl-sales-debug {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tpl-sales-debug input {
  flex: 1;
}
#tplPlaybookDebugResult {
  white-space: pre-wrap;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  max-height: 240px;
  overflow: auto;
}

/* ChatGPT wizard modal */
.gpt-wizard-tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.gpt-wizard-tab {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; font-weight: 600; text-align: center;
}
.gpt-wizard-tab.active { background: rgba(124,108,255,.15); color: #b8a8ff; border-color: rgba(124,108,255,.4); }
.gpt-wizard-hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.gpt-wizard-scope-line {
  margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--accent);
}
.gpt-wizard-scope-line.empty { color: var(--muted); font-weight: 500; }
.gpt-wizard-scope-line.warn { color: #ffc857; }
.gpt-wizard-pane textarea { width: 100%; font-size: 12px; resize: vertical; }
.gpt-wizard-pane textarea[readonly] { opacity: .85; }
.gpt-wizard-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.gpt-wizard-errors {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px;
  background: rgba(255,60,60,.1); border: 1px solid rgba(255,60,60,.3);
  color: #ff7b7b; font-size: 12px; white-space: pre-wrap;
}
.gpt-wizard-preview {
  margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  background: rgba(124,108,255,.06); border: 1px solid rgba(124,108,255,.2);
  font-size: 12px; max-height: 260px; overflow: auto;
}
.gpt-wizard-preview h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .05em; }
.gpt-wizard-preview ul { margin: 0 0 8px; padding-left: 16px; }
.gpt-wizard-preview li { margin-bottom: 2px; }
.gpt-wizard-preview .warn { color: #ffc857; }
.gpt-wizard-preview .ok { color: #7ee787; }

/* flow status modal */
.flow-modal-section { margin-bottom: 14px; }
.flow-modal-section:last-child { margin-bottom: 0; }
.flow-modal-section-title {
  color: var(--muted); font-size: 10px; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 6px;
}
.flow-modal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.flow-modal-transition-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 8px;
  background: rgba(255,255,255,.04); margin-bottom: 4px;
}
.flow-modal-transition-row span:first-child { font-weight: 600; min-width: 100px; }
.flow-modal-transition-row .hint { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ub-btn-sm {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; line-height: 1;
}
.ub-btn-sm:hover { background: rgba(255,255,255,.08); color: #fff; }
.ub-btn-sm.danger:hover { background: rgba(255,60,60,.18); color: #ff5c5c; }

/* task node on top */
.tpl-funnel-task {
  max-width: 260px; margin: 0 auto;
  text-align: center; padding: 7px 10px;
  border-radius: 10px; font-size: 12px; font-weight: 700; color: var(--text);
  border: 1px solid rgba(124, 108, 255, 0.5);
  background: linear-gradient(180deg, rgba(124,108,255,.22), rgba(124,108,255,.08));
}
.tpl-funnel-task small { display: block; font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.tpl-funnel-stem { width: 2px; height: 12px; margin: 0 auto; background: var(--fl-line); }

/* ── manual chain: start status + nodes added via transitions ── */
.tpl-funnel-empty {
  margin: 18px auto; max-width: 420px; text-align: center;
  font-size: 12px; color: var(--muted);
}
.tpl-funnel-chain {
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; padding-top: 14px;
}
.tpl-funnel-node {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.tpl-funnel-node:not(:first-child)::before {
  content: ''; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 14px; background: var(--fl-line);
}
.tpl-funnel-start-badge {
  font-size: 8px; text-transform: uppercase; letter-spacing: .05em;
  color: #c4b5fd; border: 1px solid rgba(124,108,255,.45);
  border-radius: 999px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}
.tpl-funnel-start-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--muted); cursor: pointer; user-select: none;
  margin-left: auto; flex-shrink: 0;
}
.tpl-funnel-start-toggle input { accent-color: #a78bfa; cursor: pointer; }
.tpl-funnel-start-toggle span { text-transform: uppercase; letter-spacing: .04em; font-size: 9px; }
.tpl-flow-node.is-funnel-start .tpl-flow-node-card {
  box-shadow: 0 0 0 1px rgba(167,139,250,.55), 0 8px 24px rgba(124,108,255,.12);
}
.tpl-funnel-status-top { display: flex; align-items: center; gap: 8px; width: 100%; }
.tpl-flow-panel-transition.is-start { border-color: rgba(167,139,250,.45); }
.tpl-funnel-transitions {
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px 8px; border-radius: 9px;
  border: 1px dashed rgba(255,255,255,0.14); background: rgba(255,255,255,0.01);
}
.tpl-funnel-transitions-title {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 1px 2px 2px;
}
.tpl-funnel-transition {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(141,198,255,.22);
  background: rgba(141,198,255,.05);
}
.tpl-funnel-transition-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}
.tpl-funnel-transition-cond {
  max-height: 56px;
  overflow: auto;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.35;
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(0,0,0,.18);
  word-break: break-word;
  scrollbar-width: thin;
}
.tpl-funnel-transition-cond::-webkit-scrollbar { width: 4px; }
.tpl-funnel-transition-cond::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.18);
  border-radius: 4px;
}
.tpl-funnel-transition-to { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tpl-funnel-transition-to strong { color: #c4b5fd; }
.tpl-funnel-transition-acts { display: flex; gap: 4px; }
.tpl-funnel-transition-acts button {
  width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 6px;
  background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; font-size: 11px;
}
.tpl-funnel-transition-acts button:hover { border-color: rgba(124,108,255,.55); }
.tpl-funnel-transition-empty { font-size: 10px; color: var(--muted); padding: 2px 4px; }
.tpl-funnel-add-transition {
  align-self: flex-start; margin-top: 2px;
  padding: 4px 10px; font-size: 11px; border-radius: 7px;
  border: 1px dashed var(--border); background: transparent; color: var(--muted); cursor: pointer;
}
.tpl-funnel-add-transition:hover { color: var(--text); border-color: rgba(124,108,255,.5); }
.tpl-funnel-add-transition-row {
  margin-top: 6px;
  display: flex;
  justify-content: flex-start;
}
.tpl-funnel-node .tpl-funnel-agent { min-height: 64px; margin-top: 4px; }
.tpl-funnel-node .tpl-funnel-status-card { padding: 8px 10px; }

/* lanes grid with connector bus */
.tpl-funnel-lanes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--lane-count, 1), minmax(0, 1fr));
  gap: 8px;
  padding-top: 14px;
}
.tpl-funnel-lanes::before {
  content: ''; position: absolute; top: 0; height: 2px; background: var(--fl-line);
  left: calc((100% / var(--lane-count, 1)) / 2);
  right: calc((100% / var(--lane-count, 1)) / 2);
}
.tpl-funnel-lanes.single::before { display: none; }
.tpl-funnel-lane { position: relative; display: flex; flex-direction: column; gap: 0; }
.tpl-funnel-lane::before {
  content: ''; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 2px; height: 14px; background: var(--fl-line);
}

/* status card */
.tpl-funnel-status-card {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px; padding: 7px 8px;
}
.tpl-funnel-status-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.tpl-funnel-status-top strong { font-size: 11px; line-height: 1.25; }
.tpl-funnel-status-actions { display: flex; gap: 3px; flex-shrink: 0; }
.tpl-funnel-status-actions button {
  width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 6px;
  background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tpl-funnel-status-actions button:hover { border-color: rgba(124,108,255,.55); }
.tpl-funnel-status-card .tpl-funnel-insert {
  width: 100%; margin-top: 6px; padding: 3px 4px; font-size: 10px; border-radius: 6px;
  border: 1px dashed var(--border); background: transparent; color: var(--muted); cursor: pointer;
}
.tpl-funnel-status-card .tpl-funnel-insert:hover { color: var(--text); border-color: rgba(124,108,255,.5); }

/* down arrow between status and agent */
.tpl-funnel-arrow { text-align: center; color: var(--fl-line); font-size: 13px; line-height: 1; padding: 3px 0; }

/* agent card */
.tpl-funnel-agent {
  min-height: 86px; border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.22); padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.tpl-funnel-agent.active {
  border-style: solid; border-color: rgba(124, 108, 255, 0.7);
  background: linear-gradient(180deg, rgba(124,108,255,.2), rgba(124,108,255,.07));
}
.tpl-funnel-agent .tpl-funnel-agent-kind { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: #c4b5fd; }
.tpl-funnel-agent strong {
  font-size: 11px; line-height: 1.3; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tpl-funnel-agent-actions { display: flex; gap: 4px; margin-top: auto; }
.tpl-funnel-agent-actions button {
  flex: 1; border: 1px solid var(--border); border-radius: 6px;
  background: rgba(255,255,255,0.05); color: var(--text); font-size: 10px; padding: 4px 5px; cursor: pointer;
}
.tpl-funnel-agent-actions button:hover { border-color: rgba(124,108,255,.55); }
.tpl-funnel-agent-actions .primary { background: rgba(124,108,255,.2); border-color: rgba(124,108,255,.5); }
.tpl-funnel-agent select.tpl-funnel-pick {
  width: 100%; padding: 5px 6px; border-radius: 7px; font-size: 11px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
}

/* agent edit modal — override .modal-xl (860px) */
#modalTplEditor.tpl-editor-modal {
  width: 96vw !important;
  max-width: 96vw !important;
  height: 92vh;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
#modalTplEditor .ub-modal-head { flex-shrink: 0; }
#modalTplEditor .tpl-editor-modal-body {
  display: flex;
  flex-direction: column;
  flex: 1; min-height: 0; max-height: none;
  overflow: hidden; padding: 8px 14px 10px; gap: 0;
}
#modalTplEditor .tpl-editor-modal-mount {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
#modalTplEditor .tpl-editor-modal-mount .tpl-editor-form {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
#modalTplEditor .tpl-editor-modal-mount .tpl-toolbar-mid { display: none !important; }
#modalTplEditor .tpl-editor-modal-mount .tpl-editor-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}
#modalTplEditor .tpl-editor-modal-mount .tpl-editor-fields {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  flex: 0 0 auto; min-height: 0; height: auto;
  align-content: stretch;
  gap: 10px;
}
#modalTplEditor .lead-field.tpl-field-compact {
  display: flex; flex-direction: column; min-height: 0; height: 100%;
}
#modalTplEditor .tpl-field-compact textarea {
  flex: 1 1 auto; min-height: 0; height: auto;
  font-size: 14px; line-height: 1.55;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
}
#modalTplEditor #tplVariantsResult { display: none !important; }

/* Минималистичный редактор агента — шапка с названием */
#modalTplEditor .ub-modal-head.tpl-editor-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#modalTplEditor .tpl-editor-modal-head-mount {
  flex: 1;
  min-width: 0;
}
#modalTplEditor .tpl-editor-modal-head-mount .tpl-toolbar-main {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
}
#modalTplEditor .tpl-editor-modal-head-mount .tpl-title-field {
  flex: 1;
  min-width: 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  white-space: nowrap;
}
#modalTplEditor .tpl-editor-modal-head-mount .tpl-title-field input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  padding: 6px 10px;
  font-size: 13px;
}
#modalTplEditor .tpl-editor-modal-head-mount .tpl-toolbar-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
#modalTplEditor .tpl-editor-modal-mount .tpl-toolbar { display: none !important; }
#modalTplEditor .tpl-editor-modal-body { padding: 8px 14px 10px; }
#modalTplEditor .tpl-sales-playbook-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid rgba(124,108,255,.24);
  border-radius: 8px;
  background: rgba(124,108,255,.08);
}
#modalTplEditor .tpl-sales-playbook-toggle .chk-row { margin: 0; }
#modalTplEditor .tpl-sales-playbook-toggle .hint { margin: 0; font-size: 11px; }
#modalTplEditor .tpl-test-reply-block { margin-bottom: 0; }
#modalTplEditor #tplTestReplyResult { max-height: 220px; overflow-y: auto; }
#modalTplEditor .tpl-inline-field,
#modalTplEditor .lead-field.tpl-field-compact {
  font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.45);
  text-transform: none; letter-spacing: normal; margin-bottom: 0;
}
#modalTplEditor .tpl-inline-field input,
#modalTplEditor .lead-field textarea {
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: none;
  outline: none;
}
#modalTplEditor .tpl-inline-field input:focus,
#modalTplEditor .lead-field textarea:focus {
  border-color: rgba(124, 108, 255, 0.35);
}
#modalTplEditor .tpl-toolbar-actions .ghost,
#modalTplEditor .tpl-toolbar-actions .primary {
  padding: 5px 10px; font-size: 11px; border-radius: 6px; white-space: nowrap;
}
#modalTplEditor .tpl-editor-modal-head-mount .tpl-save-head-btn { padding: 5px 12px; }
#modalTplEditor .tpl-del-btn {
  border: none; color: #ff8a8a; padding: 6px 8px;
}
#modalTplEditor .tpl-del-btn:hover { background: rgba(255,100,100,0.08); }
#modalTplEditor .tpl-save-head-btn { border-width: 1px; }
.tpl-agent-flow {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px; margin-bottom: 8px;
}
.tpl-agent-node {
  min-height: 70px; padding: 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid rgba(124, 108, 255, 0.28);
  background: rgba(124, 108, 255, 0.1); color: var(--text);
  text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.tpl-agent-node:hover { border-color: rgba(124, 108, 255, 0.55); }
.tpl-agent-node.empty {
  border-style: dashed; background: rgba(255, 255, 255, 0.03); color: var(--muted);
}
.tpl-agent-node span {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.tpl-agent-node strong {
  font-size: 11px; line-height: 1.25; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tpl-agent-node em { font-style: normal; font-size: 10px; color: #c4b5fd; margin-top: auto; }
.tpl-job-rule-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.08); font-size: 11px;
}
.tpl-job-rule-row button {
  padding: 3px 7px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 10px;
}
.tpl-job-rule-status { min-width: 72px; color: var(--muted); font-weight: 700; }
.tpl-job-rule-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-job-pick-field {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 0;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.tpl-job-pick-field[hidden],
.tpl-global-ar-toggle[hidden],
.tpl-ar-inline[hidden],
.tpl-job-editor-block[hidden],
.tpl-job-attach-bar[hidden] {
  display: none !important;
}
.tpl-job-editor-block {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px;
}
.tpl-mode-switch {
  display: flex; gap: 6px; padding: 4px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
}
.tpl-mode-btn {
  flex: 1; padding: 8px 10px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
}
.tpl-mode-btn.active {
  color: var(--text); border-color: rgba(124, 108, 255, 0.45);
  background: rgba(124, 108, 255, 0.16);
}
.tpl-job-rules-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.tpl-job-attach-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.tpl-job-attach-hint { font-size: 11px; color: var(--muted); line-height: 1.35; flex: 1 1 180px; }
.tpl-list-item-wrap.active-job .tpl-list-item {
  border-color: rgba(61, 214, 140, 0.55);
  box-shadow: 0 0 0 1px rgba(61, 214, 140, 0.2);
}
.tpl-preset-meta {
  display: block; margin-top: 3px; font-size: 10px; color: var(--muted); line-height: 1.3;
}
.tpl-preset-badge {
  display: inline-flex; align-items: center; font-size: 9px; padding: 1px 6px;
  border-radius: 999px; font-weight: 700; vertical-align: middle;
  letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
  line-height: 1.5;
}
.tpl-preset-badge-ai { background: rgba(124, 108, 255, 0.25); color: #c4b5fd; }
.tpl-preset-badge-text { background: rgba(96, 165, 250, 0.2); color: #93c5fd; }
.tpl-preset-badge-on { background: rgba(61, 214, 140, 0.22); color: var(--green); }
.tpl-flow-pb-badge {
  display: inline-flex; align-self: flex-start; margin-top: 4px; padding: 2px 7px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.12);
  font-size: 11px; color: var(--muted);
}
.tpl-flow-pb-badge.on {
  border-color: rgba(61,214,140,.45); background: rgba(61,214,140,.16); color: var(--green);
}
.tpl-job-pick-field select {
  width: 100%; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 12px; text-transform: none; letter-spacing: normal;
}
.tpl-toolbar-main { justify-content: space-between; }
.tpl-title-field { flex: 1; min-width: 160px; margin: 0; }
.tpl-toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tpl-toolbar-gen { align-items: center; }
.tpl-toolbar-gen select {
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 12px; min-width: 120px;
}
.tpl-toolbar-ar {
  padding: 8px 10px; border-radius: 8px; background: rgba(124, 108, 255, 0.06);
  border: 1px solid rgba(124, 108, 255, 0.2); gap: 10px;
}
.tpl-toolbar-label {
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em; margin-right: 4px;
}
.tpl-inline-field {
  display: flex; flex-direction: column; gap: 4px; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0;
}
.tpl-inline-field input {
  margin: 0; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; text-transform: none; letter-spacing: normal;
}
.tpl-pause-field { min-width: 72px; }
.tpl-pause-field input { width: 56px; }
.tpl-ar-status-field { min-width: 118px; }
.tpl-ar-status-field select {
  width: 100%; min-width: 108px; padding: 5px 7px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text);
}
.tpl-chk-compact { font-size: 12px; white-space: nowrap; margin: 0; }
.tpl-save-head-btn { white-space: nowrap; padding: 8px 14px; }
.templates-layout {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: 240px minmax(0, 1fr); gap: 10px;
}
.templates-list-panel,
.templates-editor-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
#tab-templates.tab.active { min-height: 0; overflow: hidden; }
.tpl-editor-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-gutter: stable;
  padding-right: 2px;
}
.tpl-editor-scroll::-webkit-scrollbar { width: 8px; }
.tpl-editor-scroll::-webkit-scrollbar-track { background: transparent; }
.tpl-editor-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
.tpl-editor-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }
.tpl-field-hint {
  display: block; margin: 2px 0 4px; font-size: 11px; color: var(--muted);
  line-height: 1.35; font-weight: normal; text-transform: none; letter-spacing: normal;
}
.tpl-section {
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
}
.tpl-section:first-child { border-top: none; padding-top: 0; }
.tpl-section-title { margin: 0 0 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.tpl-list-item .tpl-ar-badge {
  display: inline-block; font-size: 9px; margin-left: 4px; padding: 1px 5px;
  border-radius: 4px; font-weight: 600;
}
.tpl-ar-badge-global { background: rgba(61, 214, 140, 0.2); color: var(--green); }
.tpl-ar-badge-job { background: rgba(124, 108, 255, 0.22); color: #b8a8ff; }
.tpl-filter-chips {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
}
.tpl-filter-chip {
  flex: 1 1 auto; min-width: 0; padding: 5px 6px; font-size: 10px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--bg);
  color: var(--muted); cursor: pointer;
}
.tpl-filter-chip.active {
  border-color: rgba(124, 108, 255, 0.45); color: var(--text);
  background: rgba(124, 108, 255, 0.12);
}
.tpl-ar-scope-field { min-width: 100%; flex: 1 1 100%; }
.tpl-ar-scope-hint, .tpl-job-usage-hint { margin: 4px 0 8px; font-size: 11px; line-height: 1.4; }
.tpl-global-ar-toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; padding: 8px 10px;
  border-radius: 8px; background: rgba(124, 108, 255, 0.08);
  border: 1px solid rgba(124, 108, 255, 0.22);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tpl-global-ar-toggle input { width: 16px; height: 16px; margin: 0; cursor: pointer; }
.tpl-search {
  width: 100%; padding: 7px 9px; margin-bottom: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 12px;
}
.tpl-list {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  scrollbar-gutter: stable;
}
.tpl-list::-webkit-scrollbar { width: 8px; }
.tpl-list::-webkit-scrollbar-track { background: transparent; }
.tpl-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
.tpl-list-item-wrap {
  display: flex; align-items: stretch; gap: 6px;
}
.tpl-list-enable {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  width: 28px; padding: 0; margin: 0; cursor: pointer;
}
.tpl-list-enable input {
  width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--green);
}
.tpl-list-item-wrap .tpl-list-item { flex: 1; min-width: 0; }
.tpl-list-item {
  text-align: left; padding: 9px 11px; border-radius: 8px; border: 1px solid transparent;
  background: var(--panel2); cursor: pointer; transition: border-color .12s, background .12s;
}
.tpl-list-item:hover { border-color: var(--border); background: #1a1f26; }
.tpl-list-item.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.tpl-list-item strong {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: var(--text);
  line-height: 1.3;
}
.tpl-list-item > span {
  display: block; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tpl-save-inline {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px;
}
.tpl-save-inline-btn, .tpl-save-foot-btn, .tpl-save-head-btn {
  font-weight: 600; white-space: nowrap;
}
.tpl-del-btn { color: var(--red) !important; border-color: rgba(255,107,107,.35) !important; }
.tpl-preview-box {
  margin-top: 10px; padding: 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 12px; line-height: 1.45;
}
.tpl-preview-box ul { margin: 6px 0 0; padding-left: 18px; }
.tpl-section-first { border-top: none; padding-top: 0; }
.tpl-top-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.tpl-grow { flex: 1; min-width: 140px; }
.tpl-load-field { min-width: 160px; max-width: 220px; }
.tpl-load-field select { margin-top: 6px; width: 100%; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: inherit; font-size: 13px; }
.tpl-mode-switch { display: flex; gap: 8px; margin-bottom: 10px; }
.tpl-mode-btn {
  flex: 1; padding: 9px 12px; border-radius: 8px; border: 2px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 12px; font-weight: 600;
}
.tpl-mode-btn.active {
  border-color: var(--accent);
  background: rgba(124, 108, 255, 0.15);
}
.tpl-mode-panel { display: flex; flex-direction: column; gap: 10px; }
.tpl-ai-result-line {
  padding: 8px 10px; border-radius: 8px; font-size: 11px; line-height: 1.4;
  background: var(--bg); border: 1px dashed var(--border); color: var(--muted);
}
.tpl-ai-result-line strong { color: var(--text); }
.tpl-add-var-btn {
  display: inline; padding: 2px 7px !important; font-size: 10px !important;
  margin-left: 4px; vertical-align: baseline;
}
.tpl-ai-hint { margin: 0 0 8px; font-size: 11px; line-height: 1.4; }
.tpl-ai-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.tpl-ai-controls select {
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 12px; min-width: 130px;
}
.tpl-variant-count { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.tpl-variant-count input {
  width: 48px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px;
}
.tpl-ai-buttons {
  display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; margin-top: 4px;
}
.tpl-ai-buttons .tpl-ai-gen-btn { flex-shrink: 0; }
.tpl-ai-buttons .tpl-spintax-btn,
.tpl-ai-buttons .ghost { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 640px) { .tpl-ai-buttons { flex-wrap: wrap; } }
.tpl-ai-gen-btn {
  padding: 8px 16px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 2px solid #7c4dff; border-radius: 8px;
  background: linear-gradient(135deg, rgba(124, 77, 255, 0.35), rgba(124, 77, 255, 0.12));
  color: #fff;
}
.tpl-ai-gen-btn:disabled { opacity: 0.55; cursor: wait; }
.tpl-ai-variants-result {
  margin-top: 8px; min-height: 18px; font-size: 12px; line-height: 1.45;
}
.tpl-ai-status { font-size: 11px; line-height: 1.4; color: var(--muted); }
.tpl-ai-variant-row {
  display: flex; gap: 7px; align-items: flex-start; padding: 6px 8px; margin-bottom: 4px;
  border-radius: 6px; border: 1px solid var(--border); font-size: 12px; line-height: 1.4;
}
.tpl-ai-variant-row.selected { border-color: rgba(61, 214, 140, 0.85); background: rgba(61, 214, 140, 0.08); }
.tpl-ai-variant-row button.tpl-var-pick {
  width: 22px; height: 22px; line-height: 18px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer;
}
.tpl-ai-variant-row.selected button.tpl-var-pick { border-color: var(--green); color: var(--green); }
.tpl-ai-variant-row .tpl-var-body { flex: 1; cursor: pointer; }
.tpl-ai-variant-row button.tpl-var-del {
  border: 0; background: transparent; color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.tpl-ar-mode { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.tpl-final-preview {
  margin-top: 6px; padding: 8px 10px; border-radius: 8px; font-size: 11px; line-height: 1.4;
  background: var(--bg); border: 1px dashed var(--border); color: var(--muted);
}
.tpl-final-preview strong { color: var(--text); }
@media (max-width: 900px) {
  .templates-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .templates-list-panel, .templates-editor-panel { min-height: 200px; }
  .pb-grid { grid-template-columns: 1fr; }
  .pb-detail-card { position: static; top: auto; }
  .pb-kpi-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}
.lead-field select, .lead-field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 28px 10px 10px;
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
  color-scheme: dark;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8796' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo);
}
.lead-field textarea {
  padding: 10px;
  background-image: none;
  appearance: auto;
  -webkit-appearance: auto;
}
.lead-field select option {
  background: #12161c;
  color: var(--text);
}
.lead-field select:focus, .lead-field textarea:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.08);
}
.lead-save-wrap {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--surface-glass-border);
  background: rgba(0, 0, 0, 0.16);
  flex-shrink: 0;
}
.primary.wide { width: 100%; padding: 12px; border-radius: 12px; font-size: 14px; }
.primary.wide.saved { background: linear-gradient(135deg, #2ed573, #26a65b); }
.primary.wide.saving { opacity: 0.7; cursor: wait; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 25001;
  background: #1f2430; border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  transition: opacity 0.25s;
}
.toast.ok, .toast.success { border-color: #2ed573; }
.toast.err, .toast.error { border-color: #ff6b6b; }
.toast.warning { border-color: #ffa502; }
.toast .toast-action {
  margin-left: 12px; padding: 4px 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--accent); background: rgba(200,245,66,.14); color: var(--accent);
  font-size: 12px; font-weight: 700;
}
.toast .toast-action:hover { background: rgba(200,245,66,.24); }

.ai-key-prov {
  display: inline-block; margin-top: 3px; font-size: 10px; font-weight: 700;
  letter-spacing: .02em; color: var(--muted); min-height: 12px;
}
.ai-key-prov.is-set { color: var(--accent); }
.ai-key-hint { font-size: 10px; font-weight: 400; color: var(--muted); }
.ai-keys-help { line-height: 1.5; }
.ai-keys-help code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; font-size: 11px; }

/* ── clients ── */
.clients-wrap { padding: 12px; height: 100%; display: flex; flex-direction: column; min-height: 0; box-sizing: border-box; }
.clients-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px;
}
.clients-toolbar input[type=search] {
  flex: 1; min-width: 200px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.clients-toolbar select {
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.client-status-quick {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: -2px 0 10px; min-height: 0;
}
.client-status-quick[hidden] { display: none !important; }
.client-st-quick {
  max-width: 160px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--muted); font-size: 12px; cursor: pointer; font-family: inherit;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.client-st-quick:hover { background: var(--bg); color: var(--text); }
.client-st-quick.active {
  background: rgba(124, 108, 255, 0.12); border-color: var(--accent); color: var(--text); font-weight: 600;
}
.client-st-pin-btn {
  width: 32px; height: 32px; padding: 0; background: var(--panel); border: 1px dashed var(--border);
  border-radius: 8px; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; font-family: inherit;
}
.client-st-pin-btn:hover { background: var(--bg); color: var(--text); border-style: solid; }
.client-st-pin-menu {
  position: fixed; z-index: 12000; min-width: 180px; max-width: 280px; max-height: 280px; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45); padding: 6px;
}
.client-st-pin-menu[hidden] { display: none !important; }
.client-st-pin-menu-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; background: transparent; border: none; border-radius: 8px;
  color: var(--text); font-size: 13px; cursor: pointer; font-family: inherit; text-align: left;
}
.client-st-pin-menu-item:hover { background: rgba(124, 108, 255, 0.1); }
.client-st-pin-menu-item .hint { color: var(--muted); font-size: 12px; }
.client-st-pin-menu-empty { padding: 10px 12px; color: var(--muted); font-size: 12px; }
.tpl-st-fav {
  border: none; background: transparent; padding: 2px 4px; font-size: 18px; line-height: 1;
  cursor: pointer; color: var(--muted); opacity: 0.45;
}
.tpl-st-fav:hover { opacity: 0.85; }
.tpl-st-fav.active { color: #feca57; opacity: 1; }
.clients-grid-wrap { flex: 1; min-height: 0; overflow: auto; }
.clients-grid { min-width: 1040px; }
.clients-grid.clients-grid-bulk-mode { min-width: 1072px; }
.clients-grid-head,
.clients-grid-row {
  display: grid;
  grid-template-columns: 152px 120px 96px 150px minmax(180px, 1.4fr) minmax(120px, 1fr) 168px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.clients-grid.clients-grid-bulk-mode .clients-grid-head,
.clients-grid.clients-grid-bulk-mode .clients-grid-row {
  grid-template-columns: 32px 152px 120px 96px 150px minmax(180px, 1.4fr) minmax(120px, 1fr) 168px;
}
.clients-grid .cg-sel {
  display: flex;
  justify-content: center;
  align-items: center;
}
.clients-grid .cg-sel[hidden] { display: none !important; }
.client-bulk-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin: 0 0 10px; padding: 10px 12px;
  background: rgba(124, 108, 255, 0.08); border: 1px solid rgba(124, 108, 255, 0.25); border-radius: 10px;
}
.client-bulk-bar[hidden] { display: none !important; }
.client-bulk-sel-all {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer;
}
.client-bulk-count { font-size: 13px; color: var(--muted); }
.client-bulk-status {
  min-width: 150px; padding: 6px 10px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.client-bulk-btn { padding: 6px 12px; font-size: 13px; }
.client-bulk-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.client-sel-chk { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
.clients-grid-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.clients-grid-row:hover { background: rgba(255,255,255,0.02); }
.clients-grid-row.has-unread .cg-first { font-weight: 700; }
.clients-grid .cg-first,
.clients-grid .cg-last,
.clients-grid .cg-tag,
.clients-grid .cg-note,
.clients-grid .cg-preview {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clients-grid .cg-first {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  overflow: visible;
  white-space: normal;
}
.cg-first-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clients-row-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  position: relative;
  overflow: hidden;
  color: #fff;
}
.clients-row-av img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.clients-row-av .av-fallback { font-size: 10px; }
.clients-grid .cg-preview,
.clients-grid .cg-note { color: var(--muted); font-size: 12px; }
.clients-grid .cg-preview .hint { display: block; margin-top: 2px; font-size: 11px; opacity: 0.85; }
.clients-grid .cg-actions { display: flex; gap: 6px; justify-content: flex-end; }
.clients-grid .empty-row { grid-column: 1 / -1; padding: 24px 12px; color: var(--muted); }

.clients-grid .open-btn, .clients-grid .card-btn {
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  padding: 4px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.clients-grid .open-btn:hover, .clients-grid .card-btn:hover { background: rgba(124,108,255,.12); }
.clients-grid .card-btn { color: var(--text); }
.clients-grid .client-user-tag {
  display: inline-block; max-width: 100%; padding: 2px 8px; border-radius: 999px;
  color: #9be7ff; border: 1px solid rgba(155, 231, 255, 0.35); background: rgba(155, 231, 255, 0.08);
  font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.clients-grid .client-tag-empty { color: var(--muted); }

.client-card-body { display: flex; flex-direction: column; gap: 14px; }
.client-card-loading { color: var(--muted); font-size: 13px; padding: 8px 0; }
.client-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .client-card-grid { grid-template-columns: 1fr; } }
.client-card-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
}
.client-card-section.wide { grid-column: 1 / -1; }
.client-card-section h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
.client-card-hero { display: flex; gap: 12px; align-items: center; }
.client-card-av {
  width: 56px; height: 56px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: rgba(124, 108, 255, 0.2); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: var(--accent);
}
.client-card-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.client-card-title { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.client-card-handle { margin: 0; font-size: 13px; color: var(--muted); }
.client-card-meta { margin-top: 10px; display: grid; gap: 6px; font-size: 13px; }
.client-card-meta div { display: flex; gap: 8px; }
.client-card-meta b { min-width: 88px; color: var(--muted); font-weight: 500; }
.client-card-ai {
  margin-top: 4px; padding: 10px 12px; border-radius: 8px; background: rgba(0,0,0,.2);
  border: 1px solid var(--border); font-size: 13px; line-height: 1.45; white-space: pre-wrap;
}
.client-card-msg {
  padding: 10px 12px; border-radius: 8px; background: rgba(0,0,0,.2); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.45; white-space: pre-wrap;
}
.client-card-foot { justify-content: space-between; }

#modalOverlay .client-card-modal.modal.ub-modal,
.client-card-modal.modal.ub-modal {
  width: min(1120px, 96vw);
  max-width: min(1120px, 96vw);
  max-height: 94vh;
  overflow: hidden;
}
.client-card-modal .ub-modal-head,
.client-card-modal .client-card-foot { flex-shrink: 0; }
.client-card-modal .client-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 20px;
}

.settings-checks { margin-bottom: 12px; }
.chk-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.chk-row.block { display: flex; margin-bottom: 10px; }
.lead-field.block { text-transform: none; letter-spacing: normal; }
.auto-work { align-self: end; padding-bottom: 6px; }

/* ── анкета ниши (настройка ИИ-продавца) ── */
.anketa-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.anketa-fields .lead-field.block { margin-bottom: 0; }
.anketa-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.42);
  text-transform: none;
  letter-spacing: normal;
  margin: 2px 0 0;
}
#modalAgentConfig .modal-body { max-height: 70vh; overflow-y: auto; }

/* ── переключатель режима агента в шапке задачи ── */
.tpl-mode-switch { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px; border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.12)); border-radius: var(--radius-md); }
.tpl-mode-label { font-size: 11px; color: rgba(255,255,255,0.5); margin: 0 2px; }
.tpl-mode-btn { font-size: 12px; padding: 4px 10px; border: none; border-radius: 6px; background: transparent; color: rgba(255,255,255,0.62); cursor: pointer; transition: background .15s, color .15s; }
.tpl-mode-btn:hover { color: var(--text); }
.tpl-mode-btn.active { background: var(--accent, #c8f542); color: #0c0e10; font-weight: 600; }
.tpl-mode-note { font-size: 12px; color: #b8a8ff; align-self: center; padding: 0 4px; }

/* ── вкладка «Простой агент» ── */
.templates-layout[data-mode="agent"] { grid-template-columns: 1fr !important; }
.templates-layout[data-mode="agent"] .templates-list-panel,
.templates-layout[data-mode="agent"] .templates-editor-panel,
.templates-layout[data-mode="agent"] #tplStatusPanel,
.templates-layout[data-mode="agent"] #tplPlaybookPanel { display: none !important; }
.templates-layout[data-mode="agent"] #tplAgentPanel {
  display: block !important; width: 100%; max-width: none; min-width: 0;
  height: 100%; min-height: 0; overflow-y: auto;
}
#tplAgentPanel[hidden] { display: none !important; }
.agent-workspace {
  padding: 14px 22px 18px; display: flex; flex-direction: column; gap: 12px;
}
.agent-head h1 { margin: 0 0 2px; font-size: 18px; font-weight: 700; }
.agent-head .hint { margin: 0; max-width: 820px; line-height: 1.4; font-size: 12px; }
.agent-top-bar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  padding: 10px 14px; border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-lg); background: linear-gradient(180deg, rgba(16,19,24,0.9), rgba(11,13,16,0.96));
}
.agent-job-field { min-width: 240px; flex: 0 1 300px; margin: 0; }
.agent-mode-block { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.agent-mode-caption { font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.agent-mode-seg {
  display: inline-flex; gap: 4px; padding: 3px;
  border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.12)); border-radius: var(--radius-md);
  background: rgba(0,0,0,0.25); width: fit-content;
}
.agent-mode-btn {
  font-size: 12px; padding: 6px 14px; border: none; border-radius: 8px;
  background: transparent; color: rgba(255,255,255,0.62); cursor: pointer;
  transition: background .15s, color .15s;
}
.agent-mode-btn:hover { color: var(--text); }
.agent-mode-btn.active { background: var(--accent); color: #0c0e10; font-weight: 600; }
.agent-mode-hint { font-size: 10px; color: var(--muted); max-width: 340px; line-height: 1.3; flex-basis: 100%; }
.agent-grid {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start;
}
.agent-card {
  border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-lg); padding: 16px 18px;
  background: linear-gradient(180deg, rgba(15,18,22,0.92), rgba(11,13,16,0.96));
  display: flex; flex-direction: column; gap: 14px;
}
.agent-card-head h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.agent-card-head .hint { margin: 0; line-height: 1.45; }
.agent-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.agent-field { display: flex; flex-direction: column; font-size: 11px; font-weight: 600; color: var(--text); gap: 0; }
.agent-field.agent-field-wide { grid-column: 1 / -1; }
.agent-hint { font-size: 11px; font-weight: 400; color: rgba(255,255,255,0.42); margin: 2px 0; }
.agent-field textarea {
  margin-top: 4px; width: 100%; padding: 9px 11px;
  background: rgba(0,0,0,0.28); border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08));
  border-radius: var(--radius-md); color: var(--text); font: inherit; font-size: 13px; resize: vertical;
  color-scheme: dark; transition: border-color .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo);
}
.agent-field textarea:focus {
  outline: none; border-color: rgba(200,245,66,0.35); box-shadow: 0 0 0 3px rgba(200,245,66,0.1);
}
.agent-save-row { display: flex; justify-content: flex-end; }
@media (max-width: 1080px) {
  .agent-grid { grid-template-columns: 1fr; }
  .agent-form-grid { grid-template-columns: 1fr; }
}
.agent-mode-status {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; width: fit-content;
}
.agent-mode-status.is-simple { background: var(--accent-dim, rgba(200,245,66,0.16)); color: var(--accent, #c8f542); }
.agent-mode-status.is-funnel { background: rgba(124,108,255,0.18); color: #b8a8ff; }
.agent-funnel-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; border: 1px solid rgba(124,108,255,0.3); border-radius: var(--radius-lg);
  background: rgba(124,108,255,0.08);
}
.agent-funnel-notice strong { font-size: 14px; }
.agent-funnel-notice[hidden] { display: none; }
.agent-funnel-notice .hint { margin: 4px 0 0; max-width: 560px; }
.agent-funnel-notice button { white-space: nowrap; }

/* Простой агент — карточки полей + модалка чтения/правки */
.agent-section { display: flex; flex-direction: column; gap: 8px; }
.agent-section-head h2 { margin: 0 0 1px; font-size: 14px; font-weight: 700; }
.agent-section-head .hint { margin: 0; line-height: 1.35; max-width: 820px; font-size: 11px; }
.agent-fields-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.agent-field-card {
  text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  padding: 13px 14px; border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08));
  background: linear-gradient(180deg, rgba(15,18,22,0.92), rgba(11,13,16,0.96));
  transition: border-color .15s, background .15s, transform .15s;
}
.agent-field-card:hover { border-color: rgba(200,245,66,0.4); background: rgba(200,245,66,0.05); transform: translateY(-1px); }
.agent-field-card.is-filled { border-color: rgba(200,245,66,0.22); }
.agent-field-card-wide { grid-column: 1 / -1; }
.agent-field-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-field-card-label { font-size: 13px; font-weight: 700; color: var(--text); }
.agent-field-card-badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.agent-field-card-badge.ok { background: rgba(200,245,66,0.14); color: var(--accent); }
.agent-field-card-hint { font-size: 11px; color: rgba(255,255,255,0.42); line-height: 1.35; }
.agent-field-card-preview {
  font-size: 12px; color: var(--text); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.agent-field-card-preview.empty { color: rgba(255,255,255,0.3); font-style: italic; }

.agent-field-modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); padding: 24px;
}
.agent-field-modal-overlay[hidden] { display: none !important; }
.agent-field-modal {
  width: min(720px, 100%); max-height: 86vh; display: flex; flex-direction: column; gap: 12px;
  background: var(--panel, #0f1216); border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.12));
  border-radius: 16px; padding: 18px 20px; box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.agent-field-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.agent-field-modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.agent-field-modal-x {
  border: none; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; transition: background .15s, color .15s; flex-shrink: 0;
}
.agent-field-modal-x:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.agent-field-modal .hint { margin: 0; }
.agent-field-modal textarea {
  flex: 1; min-height: 280px; width: 100%; box-sizing: border-box; padding: 12px 14px; resize: vertical;
  background: rgba(0,0,0,0.32); border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.1));
  border-radius: 10px; color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; color-scheme: dark;
}
.agent-field-modal textarea:focus { outline: none; border-color: rgba(200,245,66,0.4); box-shadow: 0 0 0 3px rgba(200,245,66,0.1); }
.agent-field-modal-foot { display: flex; justify-content: flex-end; gap: 10px; }


/* ── broadcast ── */
#tab-broadcast.tab.active {
  display: flex !important;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.bc-page {
  display: flex; flex-direction: column; height: 100%; width: 100%; max-width: none;
  padding: 20px 24px; min-height: 0; box-sizing: border-box; gap: 12px;
  flex: 1; overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable;
}
#broadcastJobsList { flex: 1; min-height: 120px; width: 100%; max-width: 1280px; }
.bc-editor-page {
  display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%;
  background: var(--bg);
}
.bc-editor-top {
  display: flex; align-items: flex-start; gap: 16px; padding: 14px 20px;
  border-bottom: 1px solid var(--border); background: var(--panel); flex-shrink: 0;
}
.bc-editor-head-text { flex: 1; min-width: 0; }
.bc-editor-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }
.bc-editor-card {
  max-width: 920px; margin: 0 auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px;
}
.bc-editor-foot {
  flex-shrink: 0; display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--panel);
}
.bc-account-picker-wrap {
  max-height: 320px; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; background: rgba(0,0,0,.2);
}
.bc-accounts-block { margin-top: 8px; }
.glow-btn-create {
  background: linear-gradient(135deg, var(--ub-gold, #d4a853), #b8923f) !important;
  color: #111 !important; font-weight: 700; border: none !important;
}
.bc-editor-card textarea, .bc-editor-card input[type=text], .bc-editor-card input[type=number], .bc-editor-card select {
  width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font: inherit; box-sizing: border-box;
}
.bc-editor-card textarea { min-height: 100px; resize: vertical; }
.bc-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bc-page-title { margin: 0; font-size: 1.25rem; font-weight: 700; }
.bc-page-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.bc-page-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bc-jobs-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-xl { max-width: 860px; width: 96vw; }

/* Рассылка — компактная сводка-статистика */
.bc-summary-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1280px;
}
.bc-summary-chip {
  flex: 1 1 0;
  min-width: 120px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.bc-summary-chip .val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.bc-summary-chip .lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
/* Шапка и фильтры — на всю ширину */
#tab-broadcast .bc-page-header { width: 100%; max-width: 1280px; }
#tab-broadcast .bc-page-header h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
#tab-broadcast .bc-page > div[style*="margin-bottom:12px"] { width: 100%; max-width: 1280px; }
/* Командная панель рассылки — единый стиль с панелью «Аккаунты» */
.bc-cmd-panel {
  width: 100%; max-width: 1280px; flex-shrink: 0; margin-bottom: 12px;
  border: 1px solid rgba(200,245,66,0.14); border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent), #11151b;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
/* Компактная тулбар-линия (фильтр + поиск + Обновить + Создать) */
.bc-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  width: 100%;
}
.bc-tb-spacer { flex: 1; }
.bc-tb-select,
.bc-tb-btn {
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: rgba(255,255,255,.04); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s, background .15s, color .15s;
}
.bc-tb-select { padding: 0 28px 0 12px; min-width: 160px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%237d8796' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.bc-tb-select:hover, .bc-tb-btn:hover {
  cursor: pointer;
  border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.07); color: var(--text);
}
/* Опции нативного дропдауна на тёмной теме — иначе тёмный текст на тёмном фоне */
.bc-tb-select option,
.bases-input option {
  background: #15171c;
  color: var(--text, #e7ebf0);
}
.bc-tb-btn--primary {
  background: linear-gradient(135deg, var(--accent), #a9d92e);
  border-color: transparent; color: #10130a;
  box-shadow: 0 4px 14px rgba(200,245,66,.20);
}
.bc-tb-btn--primary:hover {
  background: linear-gradient(135deg, #d8ff5a, var(--accent));
  border-color: transparent; color: #10130a;
  box-shadow: 0 6px 18px rgba(200,245,66,.30);
}
/* Карточка задачи — единый стиль (без оранжевых обводок) */
.job-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.job-card:hover {
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.05);
}
.job-card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.job-card-main { flex: 1; min-width: 0; }
.job-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.job-card-icon { display: inline-flex; color: var(--muted); }
.job-card-icon .bc-ico { width: 16px; height: 16px; }
.job-card-title { font-weight: 600; font-size: 13px; color: var(--text); }
.job-card-meta {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
}
.bc-mi { display: inline-flex; align-items: center; gap: 4px; }
.bc-ico { width: 13px; height: 13px; flex-shrink: 0; opacity: .8; }
.bc-mi--ok { color: #6ee7a7; }
.bc-mi--err { color: #ff8a8a; }
.bc-mi--warn { color: #ffce6b; }
.bc-meta-del { opacity: .55; }
/* Бейджи статуса — единый приглушённый стиль с цветной точкой */
.bc-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 9px 0 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
  background: rgba(255,255,255,.06); color: var(--muted);
  border: 1px solid rgba(255,255,255,.08);
  text-transform: none; line-height: 1;
}
.bc-badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.bc-badge--draft   { color: #8b95a5; }
.bc-badge--pending { color: #c0a55a; }
.bc-badge--waiting { color: #c0a55a; }
.bc-badge--running { color: var(--accent); background: rgba(200,245,66,.08); border-color: rgba(200,245,66,.20); }
.bc-badge--paused  { color: #ffb24d; background: rgba(255,178,77,.08); border-color: rgba(255,178,77,.22); }
.bc-badge--done    { color: #6ee7a7; background: rgba(110,231,167,.08); border-color: rgba(110,231,167,.22); }
.bc-badge--fail    { color: #ff8a8a; background: rgba(255,138,138,.08); border-color: rgba(255,138,138,.22); }
.job-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.job-card-progress {
  height: 3px; background: rgba(255,255,255,.06); border-radius: 3px;
  margin-top: 10px; overflow: hidden;
}
.job-card-progress-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.job-card-progress-row .job-card-progress { flex: 1; margin-top: 0; }
.job-card-progress-pct {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  min-width: 34px; text-align: right; flex-shrink: 0;
}
.job-card-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #9be814);
  border-radius: 3px;
  transition: width .3s;
}
/* Кнопки внутри карточки — в стиле тулбара */
.bc-card-btn {
  height: 28px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  background: rgba(255,255,255,.04); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; line-height: 1;
  transition: border-color .15s, background .15s, color .15s;
}
.bc-card-btn:hover {
  border-color: rgba(255,255,255,.20);
  background: rgba(255,255,255,.08);
}
.bc-card-btn--icon { padding: 0 8px; color: var(--muted); }
.bc-card-btn--icon:hover { color: var(--text); }
.bc-card-btn--primary {
  background: linear-gradient(135deg, var(--accent), #a9d92e);
  border-color: transparent; color: #10130a;
  box-shadow: 0 2px 10px rgba(200,245,66,.18);
}
.bc-card-btn--primary:hover {
  background: linear-gradient(135deg, #d8ff5a, var(--accent));
  border-color: transparent; color: #10130a;
}
.bc-card-btn--danger { color: #ff8a8a; border-color: rgba(255,138,138,.25); }
.bc-card-btn--danger:hover { color: #ffb0b0; border-color: rgba(255,138,138,.45); background: rgba(255,138,138,.08); }
.bc-form-body { max-height: calc(90vh - 120px); overflow-y: auto; }
.bc-field { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.bc-field input, .bc-field textarea { width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font: inherit; box-sizing: border-box; }
.bc-field .lbl.block { display: block; margin-bottom: 6px; }
.bc-form-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bc-form-grid { display: grid; grid-template-columns: repeat(5, minmax(72px, 1fr)); gap: 10px; margin-bottom: 12px; }
.bc-form-grid-2 { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
.bc-type-tabs, .bc-src-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.bc-type-tab, .bc-src-tab {
  flex: 1; min-width: 100px; padding: 8px 10px; font-size: 12px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--panel2); color: var(--text); cursor: pointer;
}
.bc-type-tab.active, .bc-src-tab.active { border-color: var(--accent); background: rgba(124,108,255,.15); color: #fff; }
.bc-help-box { font-size: 11px; color: var(--muted); background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; line-height: 1.45; }
.bc-post-block { margin-bottom: 12px; }
.bc-post-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.bc-post-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: center; }
.bc-post-row input[type=text] { flex: 1; }
.bc-post-row input[type=number] { width: 72px; }
.bc-post-opts { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.bc-form-opts { margin-bottom: 10px; }
.danger-chk { color: #ff8a8a; }
.primary-mini { color: var(--accent) !important; border-color: var(--accent) !important; }
.bc-logs { max-height: 160px; overflow-y: auto; font-size: 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.bc-log-line { padding: 4px 0; border-bottom: 1px solid var(--border); }
.bc-log-line.warn { color: var(--orange); }
.bc-log-line.error { color: var(--red); }
.hint.warn { color: var(--orange); }
.bc-form-grid label { font-size: 10px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.bc-form-grid input { padding: 6px 8px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; }
.bc-detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.bc-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; text-align: center; }
.bc-stat b { display: block; font-size: 1.25rem; }
.bc-stat.ok b { color: var(--green); }
.bc-stat.bad b { color: var(--red); }
.bc-stat.warn b { color: var(--orange); }
.bc-stat span { font-size: 10px; color: var(--muted); }
.bc-detail-section h3 { margin: 12px 0 8px; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.bc-detail-accounts { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.bc-acc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg); border-radius: 6px; font-size: 12px; }
.bc-acc-row .sub { color: var(--muted); font-size: 11px; }
.bc-acc-metrics { display: flex; gap: 8px; font-size: 11px; }
.bc-acc-metrics .ok { color: var(--green); }
.bc-acc-metrics .bad { color: var(--red); }
.bc-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.bc-detail-actions button { flex: 1; min-width: 100px; }
.ap-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; padding: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.ap-search-wrap { position: relative; flex: 1; min-width: 140px; max-width: 220px; }
.ap-search { width: 100%; padding: 6px 28px 6px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12px; box-sizing: border-box; }
.ap-count { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--muted); }
.ap-filter { padding: 6px 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 12px; }
.ap-table-head, .ap-row { display: grid; grid-template-columns: 32px 1fr 90px 70px 90px; gap: 6px; align-items: center; padding: 6px 8px; font-size: 12px; }
.ap-table-head { color: var(--muted); font-size: 10px; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.ap-rows { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.ap-row { cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.04); margin: 0; }
.ap-row:hover { background: rgba(124, 92, 255, .06); }
.ap-row-selected { background: rgba(124, 92, 255, .12); }
.ap-row .sub { display: block; color: var(--muted); font-size: 10px; }
.ap-col-chk input { cursor: pointer; }
.ap-empty { padding: 16px; text-align: center; }
.ap-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 11px; }
.ap-selinfo { color: var(--muted); margin-right: 4px; }
.ap-pager { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ap-pp { padding: 4px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; color: var(--text); font-size: 11px; }
.job-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.job-card .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.job-card .row button { font-size: 12px; padding: 5px 10px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.job-card .row button.start { border-color: var(--green); color: var(--green); }
.job-card .row button.danger { border-color: var(--red); color: var(--red); }
.job-card .row button.settings { border-color: rgba(124,92,255,.5); color: #a78bfa; }
.bc-layout { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 12px; min-height: 0; box-sizing: border-box; }
.bc-form { flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.bc-form .bc-top, .bc-form .bc-main, .bc-form .bc-bottom { padding: 0 12px; }
.bc-top { display: flex; align-items: center; gap: 10px; padding-top: 10px !important; flex-wrap: wrap; }
.bc-top #bcName { flex: 1; min-width: 140px; margin: 0; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.bc-top .chk { font-size: 12px; color: var(--muted); white-space: nowrap; }
.bc-main { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 8px 12px !important; }
.bc-col .lbl { font-size: 11px; color: var(--muted); margin-bottom: 4px; display: block; }
.bc-col textarea { width: 100%; min-height: 72px; max-height: 100px; resize: vertical; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 8px; font: inherit; font-size: 13px; }
.preview-out.compact { margin: 6px 0 0; max-height: 120px; font-size: 11px; padding: 8px; background: #0a0c10; border: 1px solid var(--border); border-radius: 6px; white-space: pre-wrap; overflow: auto; }
.preview-out.ok { border-color: rgba(46, 213, 115, 0.35); }
.preview-out.warn { border-color: rgba(255, 159, 67, 0.45); color: #ddd; }
.bc-bottom { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 12px 12px !important; border-top: 1px solid var(--border); }
.bc-advanced-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; text-align: left;
}
.bc-advanced-toggle:hover { color: var(--text); border-color: rgba(124, 92, 255, 0.35); }
.bc-advanced-chevron { font-size: 10px; opacity: 0.75; flex-shrink: 0; }
.bc-advanced-panel { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.2s ease, opacity 0.15s ease; opacity: 1; }
.bc-advanced-panel.collapsed { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.bc-advanced-inner { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.bc-hint-inline { margin: 0; font-size: 11px; color: var(--muted); }
.bc-settings { display: grid; grid-template-columns: repeat(5, minmax(72px, 1fr)); gap: 10px; }
.bc-actions { display: flex; justify-content: flex-end; position: relative; z-index: 2; }
#bcCreate { padding: 10px 22px; border-radius: 8px; flex-shrink: 0; pointer-events: auto; }
#bcCreate:disabled { opacity: 0.45; cursor: not-allowed; }
#bcPoolHint.warn { color: var(--orange); }
#bcPoolHint.bad { color: var(--red); font-weight: 600; }
.bc-settings label { font-size: 10px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.bc-form .bc-settings input[type="number"] { width: 100%; margin: 0; padding: 5px 6px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 4px; font: inherit; font-size: 13px; }
.bc-hint { margin: 0 12px 10px; font-size: 11px; color: var(--muted); }
.bc-jobs { flex: 1; min-height: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.preflight-box { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; line-height: 1.45; }
.pf-ok { color: #3dd68c; }
.pf-bad { color: #ff6b6b; font-weight: 600; }
.pf-issues { color: #ff6b6b; margin-top: 4px; }
.bc-projects-chk { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 6px 0 8px; max-height: 72px; overflow-y: auto; }
.bc-proj-chk { font-size: 12px; margin: 0; }
.bc-pool-row { margin: 8px 0 10px; }
.bc-jobs h2, .box h2 { margin: 0; padding: 10px 12px; font-size: 11px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.box-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }

/* ── settings hub + modals ── */
.settings-hub { padding: 28px 32px; height: 100%; overflow: auto; }
.settings-hub-title { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.settings-hub-summary {
  font-size: 13px; color: var(--muted); margin: 0 0 24px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; max-width: 720px;
}
.settings-hub-summary strong { color: var(--text); }
.settings-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; max-width: 900px;
}
.settings-tile {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; color: var(--text); transition: border-color .15s, transform .1s;
}
.settings-tile:hover { border-color: #be2edd; transform: translateY(-1px); }
.settings-tile-icon { font-size: 26px; margin-bottom: 10px; line-height: 1; }
.settings-tile-title { font-size: 15px; font-weight: 600; }
.settings-tile-desc { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.settings-tile-action {
  margin-top: 12px; color: var(--ub-gold, #d4a853); font-size: 12px; font-weight: 600;
}
.settings-modal .settings-callout {
  font-size: 13px; line-height: 1.55; color: var(--muted); margin-bottom: 16px;
  padding: 12px 14px; background: rgba(190, 46, 221, 0.08); border-radius: 8px;
  border: 1px solid rgba(190, 46, 221, 0.2);
}
.settings-modal .settings-grid-wide { grid-template-columns: 1fr 1fr; }
.settings-modal .span-2 { grid-column: span 2; }
.settings-modal select { width: 100%; margin-top: 6px; padding: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; }

/* legacy settings (modals reuse) ── */
.settings-wrap { padding: 16px; overflow: auto; height: 100%; }
.settings-card { max-width: 520px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.settings-card h2 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 16px 0 10px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.settings-grid label { font-size: 11px; color: var(--muted); }
.settings-grid input { width: 100%; margin-top: 4px; padding: 7px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; }
.panel { padding: 12px; flex: 1; overflow: auto; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.box:not(.bc-form) input, .box:not(.bc-form) textarea { width: calc(100% - 24px); margin: 8px 12px; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 8px; font: inherit; }
.hint { font-size: 12px; color: var(--muted); }
.api-ok { color: var(--green); font-size: 13px; }
.toolbar { padding: 12px; display: flex; gap: 12px; align-items: center; }
.btn { display: inline-block; }
.scroll-table { overflow: auto; max-height: calc(100vh - 100px); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot.online { background: var(--green); }
.dot.error { background: var(--red); }
.dot.offline { background: #555; }
.dot.resting { background: var(--orange); }
.dot.pending { background: var(--accent, #8b5cf6); animation: dot-pulse 1.2s ease-in-out infinite; }
.dot.warn { background: var(--orange); }
.acc-status-cell { display: inline-flex; align-items: center; gap: 0; max-width: 100%; }
.acc-status-cell .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}
.acc-row.row-pending { background: rgba(200, 245, 66, 0.04); }
.empty { padding: 24px; color: var(--muted); text-align: center; font-size: 13px; }
.job-card { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.job-card .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.job-card button { background: #333; color: #fff; border: none; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.job-card button.start { background: var(--green); color: #000; }
.job-card .err { color: var(--orange); font-size: 11px; margin-top: 4px; line-height: 1.35; }
.job-card .err.bad { color: var(--red); }
.job-status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.job-status-badge.running { background: rgba(80, 200, 120, 0.2); color: #6fdc8c; }
.job-status-badge.running_busy { background: rgba(255, 193, 7, 0.2); color: #ffc107; }
.job-status-badge.waiting_accounts { background: rgba(255, 152, 60, 0.22); color: #ffb347; }
.job-status-badge.paused { background: rgba(140, 140, 160, 0.25); color: #b0b0c0; }
.job-status-badge.completed { background: rgba(100, 180, 255, 0.18); color: #8ab4ff; }
.job-status-badge.draft { background: rgba(120, 100, 255, 0.15); color: #a78bfa; }
.job-status-badge.waiting { background: rgba(120, 100, 255, 0.2); color: #c4b5fd; }
.job-pool-mini { font-size: 11px; color: var(--muted); margin-top: 4px; }
.job-card button.settings { background: var(--accent, #7c6cf0); color: #fff; }
.bc-pool-mode { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.bc-acc-picker-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bc-acc-picker {
  max-height: 160px; overflow: auto; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px;
}
.bc-acc-picker label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.job-detail-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.job-tab {
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.job-tab.active { background: var(--accent, #7c6cf0); color: #fff; border-color: transparent; }
.job-status-box {
  padding: 10px 12px; border-radius: 8px; background: var(--surface2); font-size: 13px; margin-bottom: 10px;
}
.job-pool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px;
}
.job-pool-cell {
  padding: 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); font-size: 12px;
}
.job-pool-cell b { display: block; font-size: 18px; }
.job-pool-cell.ok b { color: var(--green); }
.job-pool-cell.warn b { color: var(--orange); }
.job-pool-cell.bad b { color: var(--red); }
.job-pool-tips {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.job-pool-tips li { margin-bottom: 4px; }
.tbl tr.row-warn td { background: rgba(255, 107, 107, 0.08); }
.tbl .err { color: var(--red); font-size: 12px; }
.tag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; background: var(--surface2); }
.tag-ok { background: rgba(80, 200, 120, 0.15); color: #6fdc8c; }
.tag-spam { background: rgba(255, 160, 60, 0.2); color: #ffb347; }
.tag-warn { background: rgba(100, 160, 255, 0.15); color: #8ab4ff; }
.tag-bad { background: rgba(255, 80, 80, 0.2); color: #ff6b6b; }
.accounts-toolbar { flex-wrap: wrap; gap: 8px; align-items: center; }
.acc-search-input {
  min-width: 200px;
  max-width: 280px;
  flex: 1 1 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.acc-search-input::placeholder { color: var(--muted); }
.acc-search-input:focus { outline: none; border-color: rgba(124, 108, 255, 0.55); }
.accounts-tbl {
  width: 100%;
  table-layout: fixed;
}
.acc-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
}
.acc-table-wrap.is-loading {
  opacity: 0.88;
}
.acc-table-wrap.is-loading::after {
  content: 'Обновление списка…';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: block;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--accent);
  background: rgba(9, 11, 13, 0.92);
  border-bottom: 1px solid rgba(200, 245, 66, 0.2);
}
.accounts-tbl th, .accounts-tbl td {
  padding: 5px 8px;
  vertical-align: middle;
  box-sizing: border-box;
}
.acc-cell { white-space: normal; width: auto; }
.accounts-tbl .status-col { width: 13%; }
.accounts-tbl .spam-col { width: 8%; }
.accounts-tbl .project-col { width: 9%; }
.accounts-tbl .today-col { width: 6%; }
.accounts-tbl .device-col { width: 40px; text-align: center; }
.accounts-tbl .proxy-col { width: 10%; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accounts-tbl .job-col { width: 15%; min-width: 130px; }
.acc-job-name {
  display: block; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acc-cell-inner { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.acc-row-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #171b23;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.acc-row-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acc-row-meta { min-width: 0; line-height: 1.25; flex: 1; }
.acc-row-name-line {
  display: flex; align-items: center; gap: 5px; min-width: 0; flex-wrap: nowrap;
}
.acc-row-name-line .acc-row-name {
  font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acc-row-name { font-weight: 600; word-break: break-word; }
.acc-premium-star {
  color: #ffd86b;
  margin-right: 3px;
  font-size: 12px;
  line-height: 1;
  text-shadow: 0 0 6px rgba(255, 193, 7, .45);
}
.acc-warmup-fire {
  display: inline-block;
  flex-shrink: 0;
  font-size: 11px;
  line-height: 1;
  margin-right: 3px;
  filter: drop-shadow(0 0 5px rgba(255, 110, 35, .55));
  transform-origin: center bottom;
  cursor: help;
}
@media (prefers-reduced-motion: no-preference) {
  .acc-warmup-fire {
    animation: acc-warmup-fire-flicker 1.15s ease-in-out infinite;
  }
}
@keyframes acc-warmup-fire-flicker {
  0%, 100% { transform: scale(1) translateY(0); opacity: 1; }
  35% { transform: scale(1.14) translateY(-1px); opacity: .86; }
  55% { transform: scale(.92) translateY(0); opacity: 1; }
  78% { transform: scale(1.08) translateY(-1px); opacity: .9; }
}
.acc-row-phone, .acc-row-user { font-size: 11px; color: var(--muted); word-break: break-all; }
.acc-row-user { color: #8ab4ff; }
.accounts-toolbar .chk-row.compact { font-size: 12px; margin: 0; }
.acc-pool-sep {
  width: 1px; height: 22px; background: var(--border); flex-shrink: 0; margin: 0 2px;
}
.acc-pool-autostart { color: var(--muted); white-space: nowrap; }
.acc-pool-autostart-state { font-size: 11px; white-space: nowrap; }
.acc-pool-autostart-state.on { color: var(--green); }
.acc-pool-autostart-state.off { color: var(--muted); }
.acc-pool-status { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 72px; }
.pool-btn-start {
  padding: 6px 10px; font-size: 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(61, 214, 140, 0.45); background: rgba(61, 214, 140, 0.12); color: var(--green);
}
.pool-btn-start:disabled { opacity: 0.5; cursor: wait; }
.pool-btn-stop {
  padding: 6px 10px; font-size: 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(255, 159, 67, 0.4); background: rgba(255, 159, 67, 0.1); color: #ffb347;
}
.pool-btn-stop:disabled { opacity: 0.5; cursor: wait; }
.pool-btn-cancel {
  padding: 6px 10px; font-size: 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid rgba(255, 107, 107, 0.45); background: rgba(255, 107, 107, 0.12); color: #ff8a8a;
}
.pool-btn-cancel:disabled { opacity: 0.5; cursor: wait; }
.pool-btn-cancel-inline { margin-left: auto; flex-shrink: 0; }
.acc-pool-banner { border-color: rgba(124, 108, 255, 0.35); background: rgba(124, 108, 255, 0.08); display: flex; align-items: center; gap: 10px; }
button.mini, .acc-actions .mini { padding: 2px 6px; font-size: 12px; min-width: 28px; }
button.warn { border-color: #ffb347; }
.proxy-sel { max-width: 140px; font-size: 11px; }
.device-col { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted); text-align: center; }
.device-chip { font-size: 15px; line-height: 1; cursor: help; display: inline-block; }
.device-empty { color: var(--muted); }
.project-col, .proxy-col, .spam-col, .status-col, .num-col {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spam-col { font-size: 11px; }
.spam-detail { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.status-col { font-size: 11px; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.tag-ok { background: rgba(46, 213, 115, 0.15); color: #2ed573; }
.tag-warn { background: rgba(255, 165, 2, 0.15); color: #ffa502; }
.tag-bad { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.tag-dead { background: rgba(255, 70, 70, 0.22); color: #ff4757; }
.tag-rest { background: rgba(116, 125, 140, 0.2); color: #a4b0be; }
.tag-rotate { background: rgba(100, 149, 237, 0.18); color: #9ec5ff; }
.tag-muted { background: rgba(116, 125, 140, 0.12); color: var(--text-secondary); }
.ok-text { color: #2ed573; }

.acc-check-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px; padding: 10px 14px;
  background: rgba(33, 150, 243, 0.12);
  border: 1px solid rgba(33, 150, 243, 0.35);
  border-radius: 8px; color: #5bc0de; font-size: 13px; font-weight: 500;
}
.acc-check-cancel { margin-left: auto; padding: 5px 12px; font-size: 12px; flex-shrink: 0; }
.acc-check-banner[hidden] { display: none !important; }
.tag-checking { background: rgba(33, 150, 243, 0.15); color: #5bc0de; display: inline-flex; align-items: center; gap: 6px; }

.status-spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(91, 192, 222, 0.25);
  border-top-color: #5bc0de; border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.accounts-tbl { font-size: 12px; }
.tbl .sub { font-size: 11px; color: var(--muted); }
button.danger, .mini.danger { border-color: #ff6b6b; color: #ff8a8a; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.filter-select { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 12px; }
.bulk-bar { position: sticky; bottom: 0; background: #1a1a24; border-top: 1px solid var(--border); padding: 10px 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; z-index: 5; }
#modalOverlay.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 20000; padding: 16px; }
#modalOverlay.modal-overlay[hidden] { display: none !important; }
#modalOverlay.modal-overlay:not([hidden]) { display: block; }
#modalOverlay .modal,
.modal.ub-modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  width: min(520px, 96vw); max-height: 90vh; overflow: auto;
  display: flex; flex-direction: column; z-index: 20001;
}
#modalOverlay .modal[hidden],
.modal.ub-modal[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }
.modal-sm { width: min(400px, 96vw); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal header h2 { margin: 0; font-size: 15px; }
.modal-x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.delete-chats-lead { margin: 0; font-size: 15px; line-height: 1.45; }
.delete-chats-hint { margin: 0; font-size: 12px; line-height: 1.4; }
.modal-body label { font-size: 12px; color: var(--muted); display: block; }
.modal-body input:not([type=checkbox]):not([type=radio]), .modal-body select, .modal-body textarea {
  width: 100%; margin-top: 4px; padding: 8px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; font: inherit;
}
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-subbox { padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; display: flex; flex-direction: column; gap: 10px; }
.modal-hint { margin: 0; font-size: 11px; }
.drop-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; }
.drop-zone.drag { border-color: var(--accent); background: rgba(120,100,255,.08); }
.file-queue { list-style: none; margin: 0; padding: 0; max-height: 120px; overflow: auto; font-size: 12px; }
.file-queue li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); }
.group-list { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
/* ── Proxy groups (Underground accordion) ── */
.px-toolbar {
  flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.px-toolbar .ub-btn-primary { padding: 9px 16px; font-size: 13px; }
.px-toolbar .ub-btn-outline { padding: 9px 14px; font-size: 13px; }
.px-group-list {
  padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; flex: 1; min-height: 0;
}
.px-group-list .empty, .px-group-list .err {
  border: 1px dashed var(--border); border-radius: 10px; padding: 18px;
  color: var(--muted); background: rgba(255,255,255,.02);
}
.px-group-list .err { color: var(--red); border-color: rgba(255,107,107,.35); }
.px-group {
  flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.px-group-head {
  display: grid;
  grid-template-columns: 18px minmax(140px, 320px) 1fr auto auto;
  gap: 8px 12px;
  align-items: center;
  min-height: 56px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.px-group-head:hover { background: rgba(255,255,255,.03); }
.px-chevron {
  width: 18px; font-size: 10px; color: var(--muted); text-align: center;
  transition: transform .15s; line-height: 1;
}
.px-group-open .px-chevron { transform: rotate(90deg); }
.px-group-info { min-width: 0; overflow: hidden; }
.px-group-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.px-flag { font-size: 18px; line-height: 1; flex-shrink: 0; }
.px-group-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.px-group-sub {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.px-group-badges {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.px-badge {
  font-size: 11px; padding: 3px 7px; border-radius: 6px; background: #1c212b;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap; line-height: 1.3;
}
.px-badge.ok { border-color: var(--ub-gold-border); color: var(--ub-gold); background: var(--ub-gold-dim); }
.px-group-btns { display: flex; gap: 4px; flex-shrink: 0; }
.px-icon-btn {
  width: 30px; height: 30px; padding: 0; border-radius: 6px; border: 1px solid var(--border);
  background: #1a1f28; color: var(--text); font-size: 13px; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.px-icon-btn:hover { border-color: #444; background: #252b38; }
.px-icon-btn.danger:hover { border-color: rgba(255,107,107,.5); color: #ff8a8a; }
.px-icon-btn.add:hover { border-color: var(--ub-gold-border); color: var(--ub-gold); }
.px-group-body { border-top: 1px solid var(--border); background: #0e1014; }
.px-group-body[hidden] { display: none !important; }
.px-table-wrap { max-height: min(420px, 45vh); overflow: auto; }
.px-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.px-table th {
  position: sticky; top: 0; z-index: 1; background: #151820;
  padding: 8px 12px; text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: .3px; color: var(--muted); border-bottom: 1px solid var(--border);
}
.px-table td { padding: 8px 12px; border-bottom: 1px solid rgba(42,49,64,.6); vertical-align: middle; }
.px-table tr:hover td { background: rgba(124,108,255,.04); }
.px-type-badge {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 4px; background: rgba(100,160,255,.15); color: #8ab4ff; text-transform: uppercase;
}
.px-status-dot {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%; align-items: center;
  justify-content: center; font-size: 11px; background: rgba(61,214,140,.15); color: var(--green);
}
.px-status-dot.off { background: rgba(255,107,107,.12); color: var(--red); }
.px-row-actions { display: flex; gap: 4px; }
.px-row-actions .px-icon-btn { width: 28px; height: 28px; font-size: 12px; }
.px-loading, .px-empty-inner { padding: 24px; text-align: center; color: var(--muted); font-size: 12px; }
.px-country-cell { display: flex; align-items: center; gap: 6px; }
#tab-proxies.tab.active { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.proxies-panel {
  display: flex; flex-direction: column; min-height: 0; height: 100%;
  padding: 0 !important; overflow: hidden; flex: 1;
}
.group-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.group-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.group-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 12px; background: #2a2a35; }
.badge.ok { background: rgba(80,200,120,.15); color: #6fdc8c; }
.group-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.group-actions button { font-size: 12px; padding: 5px 10px; }
.proxy-row { display: flex; justify-content: space-between; font-size: 11px; padding: 3px 0; color: var(--muted); }
.proxy-col { font-size: 11px; max-width: 160px; }
.accounts-panel, .proxies-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.accounts-panel.panel {
  overflow: hidden;
  padding-bottom: 0;
}
.accounts-panel .acc-table-wrap {
  flex: 1;
  min-height: 0;
}
.accounts-panel .acc-panel-footer {
  flex-shrink: 0;
  margin: 0 -12px;
  background: #12151c;
  border-top: 1px solid var(--border);
}
.accounts-panel .acc-bulk-bar.ub-bulk-bar {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: #151820;
  border-top: none;
  padding: 10px 12px 12px;
  box-shadow: none;
}
.accounts-panel .ub-bulk-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 1100px) {
  .px-group-head {
    grid-template-columns: 18px 1fr auto;
    grid-template-rows: auto auto;
  }
  .px-group-badges { grid-column: 2 / 4; justify-content: flex-start; }
  .px-group-btns { grid-column: 3; grid-row: 1; }
}
.accounts-panel .scroll-table { flex: 1; }
.status-running { color: var(--green); }
.status-paused { color: var(--orange); }
.status-waiting { color: var(--ub-gold, #e6c547); }
.status-completed { color: var(--muted); }
.item.compact { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }

/* ── Warmup tab ── */
#tab-warmup.tab.active { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#tab-warmup .glass {
  background: linear-gradient(180deg, rgba(14, 17, 22, 0.96), rgba(11, 13, 16, 0.98));
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  border: 1px solid var(--surface-glass-border);
  box-shadow: var(--shadow-lg);
}
.warmup-native-hidden {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  clip: rect(0,0,0,0); overflow: hidden;
}
.warmup-shell {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding: 12px 14px 14px; gap: 10px; overflow: hidden;
  background:
    radial-gradient(ellipse 85% 55% at 100% 0%, rgba(255, 159, 67, 0.06), transparent 50%),
    radial-gradient(ellipse 70% 45% at 0% 100%, rgba(200, 245, 66, 0.04), transparent 55%),
    var(--bg);
}
.warmup-topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.warmup-topbar-copy { min-width: 0; }
.warmup-topbar-title {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
}
.warmup-topbar-sub {
  margin: 4px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); max-width: 520px;
}
.warmup-topbar-meta { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.warmup-engine-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .02em; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04); color: var(--muted);
  transition: border-color .2s, background .2s, color .2s;
}
.warmup-engine-badge--idle { color: var(--muted); }
.warmup-engine-badge--run {
  color: var(--green); border-color: rgba(92,219,122,.35);
  background: rgba(92,219,122,.1); box-shadow: 0 0 20px rgba(92,219,122,.08);
}
.warmup-engine-badge--pause {
  color: var(--orange); border-color: rgba(255,159,67,.35); background: rgba(255,159,67,.1);
}
.warmup-engine-badge--focus {
  color: var(--accent); border-color: rgba(200,245,66,.4); background: rgba(200,245,66,.1);
}
.warmup-stats-strip {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
@media (max-width: 900px) {
  .warmup-stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.warmup-stat {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(14,17,22,.92), rgba(11,13,16,.96));
}
.warmup-stat-val {
  font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  color: var(--text);
}
.warmup-stat-lbl {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.warmup-stat--run .warmup-stat-val { color: var(--green); }
.warmup-stat--pause .warmup-stat-val { color: var(--orange); }
.warmup-stat--pairs .warmup-stat-val { color: var(--accent); }
.warmup-pane--main { flex: 1; min-height: 0; }
.warmup-pane {
  min-height: 0; display: flex; flex-direction: column;
  border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--surface-glass-border, rgba(255,255,255,.08));
  box-shadow: var(--shadow-lg);
}
.warmup-section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.warmup-section-head--compact { margin-bottom: 6px; padding: 0 2px; }
.warmup-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text);
}
.warmup-section-hint { font-size: 10px; color: var(--muted); }
.warmup-config-card {
  margin: 0; border-bottom: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(255,255,255,.02), transparent);
}
.warmup-actions-wrap {
  flex-shrink: 0; padding: 8px 12px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.1);
}
.warmup-pane-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px; scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(200,245,66,.38) rgba(255,255,255,.04);
}
.warmup-pane-scroll::-webkit-scrollbar { width: 9px; }
.warmup-pane-scroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,.04); border-radius: 999px; margin: 4px 0;
}
.warmup-pane-scroll::-webkit-scrollbar-thumb {
  background: rgba(200,245,66,.32); border-radius: 999px;
  border: 2px solid transparent; background-clip: padding-box;
}
.warmup-pane-scroll::-webkit-scrollbar-thumb:hover { background: rgba(200,245,66,.48); }

#tab-warmup .wu-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 9px;
  background: rgba(255,255,255,.04); color: var(--text);
  font-size: 11px; font-weight: 600; line-height: 1.2;
  padding: 7px 11px; cursor: pointer; user-select: none;
  transition: background .18s var(--ease-out-expo), border-color .18s, color .18s, transform .15s var(--ease-out-expo);
}
#tab-warmup .wu-btn:hover:not(:disabled) {
  border-color: rgba(255,255,255,.14); background: rgba(255,255,255,.07);
  transform: translateY(-1px);
}
#tab-warmup .wu-btn:active:not(:disabled) { transform: translateY(0); }
#tab-warmup .wu-btn:disabled { opacity: .34; cursor: not-allowed; pointer-events: none; }
#tab-warmup .wu-btn--sm { padding: 5px 9px; font-size: 10px; border-radius: 8px; }
#tab-warmup .wu-btn--ghost { background: rgba(255,255,255,.03); color: var(--muted); }
#tab-warmup .wu-btn--ghost:hover:not(:disabled) { color: var(--text); }
#tab-warmup .wu-btn--primary {
  background: rgba(200,245,66,.14); border-color: rgba(200,245,66,.38); color: var(--accent);
}
#tab-warmup .wu-btn--primary:hover:not(:disabled) {
  background: rgba(200,245,66,.2); border-color: rgba(200,245,66,.52);
}
#tab-warmup .wu-btn--warn {
  background: rgba(255,159,67,.1); border-color: rgba(255,159,67,.35); color: #ffb347;
}
#tab-warmup .wu-btn--danger {
  background: rgba(255,107,107,.08); border-color: rgba(255,107,107,.32); color: #ff9a9a;
}
#tab-warmup .wu-btn--focus {
  background: rgba(255,193,7,.1); border-color: rgba(255,193,7,.32); color: #ffd86b;
}
#tab-warmup .wu-btn--focus.is-active {
  background: rgba(200,245,66,.12); border-color: rgba(200,245,66,.4); color: var(--accent);
}
.warmup-import-btn { cursor: pointer; flex-shrink: 0; margin: 0; }

.warmup-config {
  flex-shrink: 0; padding: 12px 12px 10px;
}
.warmup-config-grid { display: flex; flex-direction: column; gap: 6px; }
.warmup-config-chips-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
}
.warmup-setting-inline {
  display: flex; align-items: center; gap: 6px;
  flex: 1 1 0; min-width: 0;
}
.warmup-setting-inline .warmup-setting-lbl {
  flex-shrink: 0; min-width: 46px;
}
.warmup-setting-inline .warmup-chips {
  flex: 1 1 auto; flex-wrap: nowrap; min-width: 0;
}
.warmup-setting-row {
  display: grid; grid-template-columns: 58px 1fr auto; gap: 4px 8px; align-items: center;
}
.warmup-setting-row--delay { grid-template-columns: 58px 1fr 62px; }
.warmup-setting-lbl {
  font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.warmup-range { position: relative; height: 24px; }
.warmup-range-track {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 5px; border-radius: 999px; background: rgba(255,255,255,.07); pointer-events: none;
}
.warmup-range-fill {
  position: absolute; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  box-shadow: 0 0 10px var(--accent-glow);
}
.warmup-range-inp {
  position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 24px;
  margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none;
}
.warmup-range-inp::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  pointer-events: auto; cursor: grab; box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
.warmup-range-inp::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); pointer-events: auto; cursor: grab;
}
.warmup-range-min { z-index: 2; }
.warmup-range-max { z-index: 3; }
.warmup-range-val {
  font-size: 10px; color: var(--accent); font-weight: 700;
  text-align: right; font-variant-numeric: tabular-nums;
}
.warmup-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.warmup-chip {
  min-width: 24px; padding: 3px 6px; border-radius: 7px;
  border: 1px solid var(--border); background: rgba(0,0,0,.22);
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s, transform .12s;
}
.warmup-chip:hover { color: var(--text); border-color: rgba(255,255,255,.16); transform: translateY(-1px); }
.warmup-chip.active {
  color: #0d1117; border-color: transparent; background: var(--accent);
  box-shadow: 0 0 0 1px rgba(200,245,66,.25);
}
.warmup-apply-par { margin: 0; flex-shrink: 0; }
.warmup-mode-tools {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; align-items: center;
}
.warmup-mode-tools .wu-btn { flex: 0 1 auto; min-width: 0; }
.warmup-mode-seg-lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.warmup-mode-seg {
  display: inline-flex; gap: 3px; padding: 3px;
  border: 1px solid var(--border); border-radius: 9px; background: rgba(255,255,255,.03);
}
.warmup-mode-seg .wu-seg-btn {
  border: 0; border-radius: 6px; padding: 5px 12px; background: transparent;
  color: rgba(255,255,255,.62); font-size: 11px; font-weight: 600; cursor: pointer; line-height: 1.2;
  transition: background .15s, color .15s;
}
.warmup-mode-seg .wu-seg-btn:hover:not(:disabled) { color: var(--text); }
.warmup-mode-seg .wu-seg-btn:disabled { cursor: default; }
#warmupBtnNormal.is-active { background: rgba(255,255,255,.1); color: var(--text); }
#warmupBtnFocus.is-active {
  background: rgba(200,245,66,.16); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(200,245,66,.4);
}

.warmup-task-ctrl {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px;
  padding: 0; border-bottom: none;
}
@media (max-width: 1180px) {
  .warmup-task-ctrl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.warmup-task-ctrl .wu-btn { width: 100%; min-height: 30px; padding: 6px 4px; font-size: 10px; }

.warmup-inline-note {
  flex-shrink: 0; margin: 0 12px 6px; padding: 7px 10px; border-radius: 9px;
  font-size: 11px; line-height: 1.35; color: var(--muted);
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.warmup-inline-note[hidden] { display: none !important; }
.warmup-inline-note--warn {
  color: #ffd9a8; background: rgba(255,159,67,.08); border-color: rgba(255,159,67,.22);
}

.warmup-split {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: minmax(220px, 268px) minmax(0, 1fr);
}
@media (max-width: 1180px) {
  .warmup-split { grid-template-columns: minmax(196px, 240px) minmax(0, 1fr); }
}
.warmup-split-col { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.warmup-split-col--list { border-right: 1px solid rgba(255,255,255,.06); }
.warmup-list-toolbar {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.05);
  background: rgba(0,0,0,.12);
}
.warmup-list-toggle { flex: 1; min-width: 0; }
.warmup-import-btn--toolbar { flex-shrink: 0; }
.warmup-import-btn--toolbar[hidden] { display: none !important; }
.warmup-list-panel[hidden] { display: none !important; }
.warmup-split-head {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; font-size: 10px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: rgba(0,0,0,.14); border-bottom: 1px solid rgba(255,255,255,.05);
}
.warmup-split-head-title { color: var(--muted); }
.warmup-detail-job-label {
  font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0;
  color: var(--accent); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.warmup-empty {
  padding: 32px 16px; text-align: center; font-size: 12px; color: var(--muted);
}
.warmup-empty--hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 180px; gap: 6px; padding: 40px 20px;
}
.warmup-empty-icon {
  font-size: 28px; line-height: 1; margin-bottom: 4px; opacity: .85;
  filter: drop-shadow(0 0 12px rgba(255,159,67,.35));
}
.warmup-empty-title { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.warmup-empty-hint { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); max-width: 280px; }

.warmup-dialogue-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px; margin-bottom: 5px;
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; font-size: 11px; background: rgba(0,0,0,.15);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.warmup-dialogue-item:hover { border-color: rgba(255,255,255,.12); }
.warmup-dialogue-item.active {
  border-color: rgba(200,245,66,.42); background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(200,245,66,.08);
}
.warmup-dialogue-item input { flex-shrink: 0; accent-color: var(--accent); }
.warmup-dialogue-body { flex: 1; min-width: 0; }
.warmup-dialogue-title {
  font-weight: 600; font-size: 12px; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; white-space: normal; word-break: break-word;
}
.warmup-dialogue-meta { font-size: 10px; color: var(--muted); margin-top: 4px; }
.warmup-del-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 2px 5px; border-radius: 6px; line-height: 1;
}
.warmup-del-btn:hover { color: var(--red); background: rgba(255,107,107,.1); }
.warmup-row-actions {
  display: flex; align-items: flex-start; gap: 2px; flex-shrink: 0; padding-top: 1px;
}
.warmup-icon-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 2px 5px; border-radius: 6px; line-height: 1; font-size: 12px;
}
.warmup-icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.warmup-icon-btn--danger:hover { color: var(--red); background: rgba(255,107,107,.1); }
.warmup-create-project-opt {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.warmup-create-project-opt input { accent-color: var(--accent); }
.warmup-dlg-preview-scroll {
  max-height: min(68vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 2px; scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: rgba(200,245,66,.38) rgba(255,255,255,.04);
}
.warmup-dlg-preview-scroll::-webkit-scrollbar { width: 9px; }
.warmup-dlg-preview-scroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,.04); border-radius: 999px; margin: 4px 0;
}
.warmup-dlg-preview-scroll::-webkit-scrollbar-thumb {
  background: rgba(200,245,66,.32); border-radius: 999px;
}
.warmup-dlg-preview-msg {
  padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.05);
}
.warmup-dlg-preview-msg:last-child { border-bottom: none; }
.warmup-dlg-preview-author {
  font-size: 11px; font-weight: 700; color: var(--accent); margin-bottom: 3px;
}
.warmup-dlg-preview-text {
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.warmup-dlg-preview-empty {
  padding: 24px 12px; text-align: center; color: var(--muted); font-size: 12px;
}

.warmup-task-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px; margin-bottom: 5px;
  border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; font-size: 11px; background: rgba(0,0,0,.14);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.warmup-task-row:hover { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.12); }
.warmup-task-row.active {
  border-color: rgba(200,245,66,.42); background: var(--accent-dim);
  box-shadow: 0 0 0 1px rgba(200,245,66,.08);
}
.warmup-task-row.is-running { box-shadow: inset 0 0 0 1px rgba(92,219,122,.1); }
.warmup-task-row.is-checked { border-color: rgba(120,180,255,.35); }
.warmup-task-check-wrap {
  flex-shrink: 0; display: flex; align-items: flex-start; padding-top: 2px;
  cursor: pointer;
}
.warmup-task-check {
  width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--accent, #c8f542);
}
.warmup-task-body { flex: 1; min-width: 0; }
.warmup-task-title {
  font-weight: 600; font-size: 12px; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; white-space: normal; word-break: break-word;
}
.warmup-task-meta-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.warmup-task-meta { font-size: 10px; color: var(--muted); }

.warmup-job-item {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; font-size: 12px; overflow: hidden; background: rgba(0,0,0,.12);
}
.warmup-job-item.is-running { box-shadow: inset 0 0 0 1px rgba(92,219,122,.1); }
.warmup-job-row1 {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.warmup-job-id { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.warmup-job-title {
  flex: 1; min-width: 80px; font-weight: 600; font-size: 13px; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; white-space: normal; word-break: break-word;
}
.warmup-job-st {
  font-size: 9px; font-weight: 700; padding: 3px 7px; border-radius: 999px;
  background: rgba(255,255,255,.06); text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0;
}
.warmup-st-running { color: var(--green); background: rgba(92,219,122,.12); }
.warmup-st-paused { color: var(--orange); background: rgba(255,159,67,.12); }
.warmup-st-error { color: #f88; background: rgba(255,107,107,.12); }
.warmup-st-draft { color: var(--muted); }
.warmup-job-stats { font-size: 10px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.warmup-job-stats:empty { display: none; }
.warmup-job-pairs { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.warmup-pair-card {
  position: relative; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(0,0,0,.16); overflow: hidden; display: flex; flex-direction: column;
}
.warmup-pair-card.is-hold { opacity: .72; }
.warmup-pair-card.is-active {
  border-color: rgba(200,245,66,.45); background: rgba(200,245,66,.06);
  box-shadow: inset 0 0 0 1px rgba(200,245,66,.15);
}
.warmup-pair-card.is-queued { border-color: rgba(126,200,255,.35); background: rgba(126,200,255,.04); }
.warmup-pair-card.is-error { border-color: rgba(255,107,107,.35); }
.warmup-pair-head {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) minmax(64px, 120px) auto auto auto;
  align-items: center; gap: 8px; padding: 8px 10px; font-size: 11px;
}
.warmup-pair-num { font-size: 10px; color: var(--muted); font-weight: 700; }
.warmup-pair-names { min-width: 0; white-space: normal; line-height: 1.35; font-weight: 600; }
.warmup-pair-phone {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  user-select: all;
  cursor: text;
}
.warmup-pair-names .warmup-pair-arrow { color: var(--accent); margin: 0 4px; opacity: .85; white-space: nowrap; }
.warmup-pair-bar { height: 5px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.warmup-pair-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--green));
  transition: width .35s var(--ease-out-expo);
}
.warmup-pair-prog { color: var(--accent); font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.warmup-pair-st {
  font-size: 9px; padding: 3px 6px; border-radius: 999px; text-transform: uppercase;
  font-weight: 700; background: rgba(255,255,255,.06); color: var(--muted); white-space: nowrap;
}
.warmup-pair-st-running { color: var(--green); }
.warmup-pair-st-paused, .warmup-pair-st-waiting, .warmup-pair-st-offline-wait { color: var(--orange); }
.warmup-pair-st-starting, .warmup-pair-st-queue { color: #7ec8ff; }
.warmup-pair-st-done, .warmup-pair-st-hold { color: var(--muted); }
.warmup-pair-st-error { color: #f88; }
.warmup-pair-ctrl { display: flex; gap: 4px; flex-shrink: 0; }
.warmup-pair-ctrl-btn, .warmup-pair-log-btn {
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
  color: var(--text); font-size: 10px; line-height: 1; cursor: pointer;
  padding: 4px 7px; border-radius: 7px; transition: border-color .15s, color .15s, background .15s;
}
.warmup-pair-ctrl-btn:hover:not(:disabled), .warmup-pair-log-btn:hover {
  border-color: rgba(200,245,66,.38); color: var(--accent);
}
.warmup-pair-ctrl-btn:disabled { opacity: .3; cursor: not-allowed; }
.warmup-pair-log-btn { border-color: rgba(200,245,66,.28); color: var(--accent); background: rgba(200,245,66,.06); }
.warmup-pair-log-btn.open { background: var(--accent); color: #0d1117; border-color: var(--accent); }
.warmup-pair-err {
  font-size: 10px; color: #f99; padding: 6px 10px;
  border-top: 1px dashed rgba(255,100,100,.18); background: rgba(255,80,80,.06);
}
.warmup-job-err {
  font-size: 10px; color: var(--orange); margin-top: 6px;
  padding: 6px 8px; background: rgba(255,159,67,.08); border-radius: 8px;
}
.warmup-job-running-strip {
  position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden;
  background: rgba(200,245,66,.12);
}
.warmup-job-running-strip::after {
  content: ''; position: absolute; top: 0; left: -40%; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: warmup-strip-run 1.4s linear infinite;
}
@keyframes warmup-strip-run { 0% { left: -40%; } 100% { left: 100%; } }

.warmup-log-inline {
  width: 100%; max-height: 160px; overflow-y: auto;
  border-top: 1px solid var(--border); background: rgba(0,0,0,.22); font-size: 10px;
}
.warmup-log-empty, .warmup-log-err { padding: 8px 10px; font-size: 11px; line-height: 1.4; }
.warmup-log-err { color: #f99; background: rgba(255,80,80,.08); }
.warmup-pair-err--wait { color: var(--muted); background: rgba(255,255,255,.04); }
.warmup-log-line {
  padding: 3px 8px; border-bottom: 1px solid rgba(255,255,255,.04);
  display: grid; grid-template-columns: 48px 1fr; gap: 5px;
}
.warmup-log-line.err { color: #f88; }
.warmup-log-time { color: var(--muted); font-size: 10px; }
.warmup-log-dir { color: var(--accent); font-weight: 600; font-family: ui-monospace, Consolas, monospace; user-select: all; }

.warmup-connect-loading {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.12);
}

.warmup-pool-alert { display: none !important; }

@media (max-width: 1280px) {
  .warmup-pair-head {
    grid-template-columns: 20px minmax(0, 1fr) auto auto;
    grid-template-areas: "num names prog st" "bar bar bar ctrl";
  }
  .warmup-pair-num { grid-area: num; }
  .warmup-pair-names { grid-area: names; }
  .warmup-pair-bar { grid-area: bar; }
  .warmup-pair-prog { grid-area: prog; }
  .warmup-pair-st { grid-area: st; }
  .warmup-pair-ctrl { grid-area: ctrl; justify-self: end; }
}
@media (prefers-reduced-motion: reduce) {
  #tab-warmup .warmup-chip:hover, #tab-warmup .wu-btn:hover:not(:disabled) { transform: none; }
  .warmup-job-running-strip::after { animation: none !important; }
}

/* ── Underground-style modals & accounts ── */
:root {
  --ub-gold: #d4a853;
  --ub-gold-dim: rgba(212, 168, 83, 0.15);
  --ub-gold-border: rgba(212, 168, 83, 0.35);
}
.modal-lg { width: min(640px, 96vw); }
.modal-md { width: min(480px, 96vw); }
.ub-modal { border-color: #2e3340; box-shadow: 0 24px 64px rgba(0,0,0,.55); }
.ub-modal-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.ub-modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.ub-sub { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.ub-sub code { font-size: 11px; color: var(--ub-gold); background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 4px; }
.ub-modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.account-profile-foot {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.account-profile-foot-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.account-profile-body {
  min-height: 320px;
  max-height: min(68vh, 560px);
  overflow-y: auto;
}
.account-profile-pane[hidden] { display: none !important; }
.account-profile-tips-pane {
  padding: 4px 2px 8px;
}
.account-profile-tips-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 184, 77, 0.14), rgba(124, 108, 255, 0.1));
  border: 1px solid rgba(255, 184, 77, 0.28);
}
.account-profile-tips-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.account-profile-tips-btn {
  font-size: 13px;
  font-weight: 600;
  color: #1a1408;
  background: linear-gradient(180deg, #ffd978 0%, #f0b429 100%);
  border: 1px solid rgba(255, 210, 96, 0.9);
  border-radius: 8px;
  padding: 9px 16px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset, 0 2px 10px rgba(240, 180, 41, 0.28);
  cursor: pointer;
  transition: filter .15s, transform .12s;
}
.account-profile-tips-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.account-profile-tips-btn.is-active {
  color: var(--text);
  background: rgba(124, 108, 255, 0.18);
  border-color: rgba(124, 108, 255, 0.45);
  box-shadow: none;
}
.account-profile-tips-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.account-profile-tips-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.58;
}
.account-profile-tips-list li { margin-bottom: 8px; }
.account-profile-tips-list li:last-child { margin-bottom: 0; }
.account-profile-tips-foot {
  margin: 14px 0 0;
  font-size: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.ub-btn-primary {
  background: #f0f0f0; color: #111; border: none; padding: 10px 18px;
  border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer;
}
.ub-btn-primary:hover { background: #fff; }
.ub-btn-secondary {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.ub-btn-secondary:hover { color: var(--text); border-color: #444; }
.ub-btn-outline {
  background: transparent; border: 1px solid var(--ub-gold-border); color: var(--ub-gold);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 500;
}
.ub-btn-outline:hover { background: var(--ub-gold-dim); }
.ub-btn-danger {
  background: rgba(255, 107, 107, 0.14); border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ff6b6b; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  cursor: pointer; font-weight: 600;
}
.ub-btn-danger:hover { background: rgba(255, 107, 107, 0.26); }
.account-profile-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 6px 2px 2px;
}
.account-profile-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #171b23;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}
.account-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.account-profile-meta {
  min-width: 0;
}
.account-profile-phone {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
}
.account-profile-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.account-profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.account-profile-actions .ghost {
  padding: 6px 10px;
  font-size: 12px;
}
.account-profile-offline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 159, 67, .35);
  border-radius: 10px;
  background: rgba(255, 159, 67, .08);
  color: var(--text);
  font-size: 13px;
}
.account-profile-busy {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 107, .35);
  border-radius: 10px;
  background: rgba(255, 107, 107, .08);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}
.account-profile-offline[hidden],
.account-profile-busy[hidden] {
  display: none !important;
}
.account-profile-import {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0,0,0,.12);
}
.account-profile-import-head,
.account-profile-import-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.account-profile-import-head {
  margin-bottom: 8px;
  font-size: 13px;
}
.account-profile-import-row select {
  min-width: 0;
  flex: 1;
}
.account-profile-import .ghost {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.account-profile-import-selected {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0,0,0,.16);
  font-size: 12px;
  color: var(--text);
}
.account-profile-import-hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.account-profile-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 22000;
  background: rgba(0, 0, 0, .72);
  padding: 16px;
}
.account-profile-picker-overlay[hidden] {
  display: none !important;
}
.account-profile-picker-modal {
  width: 100%;
  height: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}
.account-profile-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.account-profile-picker-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.account-profile-picker-head .hint {
  margin: 0;
}
.account-profile-picker-filters {
  display: grid;
  grid-template-columns: 180px 220px 220px minmax(0, 1fr);
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.account-profile-picker-filter-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
}
.account-profile-picker-filters select,
.account-profile-picker-filters input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.account-profile-picker-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}
.account-profile-picker-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #12151c;
  padding: 10px;
  cursor: pointer;
}
.account-profile-picker-card:hover {
  border-color: rgba(124,108,255,.45);
}
.account-profile-picker-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(124,108,255,.35);
}
.account-profile-picker-top {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.account-profile-picker-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  overflow: hidden;
}
.account-profile-picker-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.account-profile-picker-name {
  font-size: 13px;
  font-weight: 700;
}
.account-profile-picker-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}
.account-profile-picker-status {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}
.account-profile-picker-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.account-profile-picker-actions {
  display: flex;
  gap: 8px;
}
.ub-drop {
  border: 2px dashed #3a4050; border-radius: 12px; padding: 28px 20px; text-align: center;
  background: rgba(0,0,0,.15); transition: border-color .15s, background .15s;
}
.ub-drop.drag { border-color: var(--ub-gold); background: var(--ub-gold-dim); }
.ub-drop-icon { font-size: 32px; margin-bottom: 8px; opacity: .85; }
.ub-drop p { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.ub-settings-box {
  background: #12151c; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.ub-settings-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ub-gold); font-weight: 600; margin-bottom: 2px;
}
.ub-label { font-size: 12px; color: var(--muted); display: block; }
.ub-label input, .ub-label select, .ub-label textarea { margin-top: 6px; }
.ub-chk { font-size: 13px; color: var(--text); }
.ub-queue-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); margin-top: 4px;
}
.link-btn {
  background: none; border: none; color: var(--ub-gold); font-size: 12px;
  cursor: pointer; padding: 0; text-decoration: underline;
}
.ub-queue {
  max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
}
.ub-queue-empty {
  padding: 16px; text-align: center; font-size: 12px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 8px;
}
.ub-queue-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #12151c; border: 1px solid var(--border); border-radius: 8px;
}
.ub-queue-icon { font-size: 20px; flex-shrink: 0; }
.ub-queue-main { flex: 1; min-width: 0; }
.ub-queue-name { font-size: 13px; font-weight: 500; font-family: ui-monospace, monospace; }
.ub-queue-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ub-status-wait { color: var(--ub-gold); }
.ub-queue-rm {
  background: transparent; border: none; color: var(--muted); font-size: 18px;
  cursor: pointer; padding: 4px 8px; line-height: 1;
}
.ub-queue-rm:hover { color: var(--red); }
.ub-file-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.ub-file-name { font-size: 12px; color: var(--muted); }
.ub-tabs { display: flex; gap: 4px; margin-bottom: 14px; background: #0e1014; padding: 4px; border-radius: 8px; }
.ub-tab {
  flex: 1; background: transparent; border: none; color: var(--muted);
  padding: 8px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;
}
.ub-tab.active { background: var(--panel2); color: var(--text); font-weight: 600; }
.ub-tab:hover:not(.active) { color: var(--text); }
.ub-bulk-bar {
  border-top: 1px solid var(--ub-gold-border);
}
.ub-bulk-count { font-size: 13px; font-weight: 600; min-width: 90px; color: var(--ub-gold); }
.ub-bulk-btn {
  background: #1c212b; border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 12px; cursor: pointer;
}
.ub-bulk-btn:hover { border-color: #444; background: #252b38; }
.ub-bulk-btn.ub-bulk-warn { border-color: rgba(255,159,67,.4); color: #ffb347; }
.ub-bulk-btn.ub-bulk-danger { border-color: rgba(255,107,107,.4); color: #ff8a8a; }
.accounts-tbl tr.acc-row { cursor: pointer; transition: background .1s; }
.accounts-tbl tr.acc-row:hover td { background: rgba(200, 245, 66, 0.05); }
.accounts-tbl tr.acc-row-selected td { background: rgba(200, 245, 66, 0.12) !important; }
.accounts-tbl tr.acc-row-selected:hover td { background: rgba(200, 245, 66, 0.16) !important; }
.num-col { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.num-at-limit { color: var(--orange, #ffb347); font-weight: 600; }
.accounts-tbl .col-chk { width: 36px; }
#tab-accounts.tab.active { display: flex; flex-direction: column; min-height: 0; }

/* ── profile templates ── */
#tab-profiles.tab.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    radial-gradient(ellipse 90% 60% at 0% 0%, rgba(200, 245, 66, 0.05), transparent 55%),
    var(--bg);
}
.profiles-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  gap: 10px;
  overflow: hidden;
}
.profiles-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.profiles-topbar-copy h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.profiles-topbar-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.profiles-templates-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  background: rgba(255, 255, 255, 0.03);
  transition: border-color .2s var(--ease-out-expo), background .2s var(--ease-out-expo), transform .2s var(--ease-out-expo);
}
.profiles-templates-toggle:hover {
  border-color: rgba(200, 245, 66, 0.28);
  background: rgba(200, 245, 66, 0.06);
  transform: translateY(-1px);
}
.profiles-templates-toggle-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.profiles-shell.templates-collapsed .profiles-templates-toggle-ico {
  transform: scaleX(-1);
}
.profiles-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}
.profiles-shell.templates-collapsed .profiles-layout {
  grid-template-columns: minmax(0, 1fr);
}
.profiles-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  background: linear-gradient(180deg, rgba(14, 17, 22, 0.96), rgba(11, 13, 16, 0.98));
  min-height: 0;
  flex: 1;
}
.profiles-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  padding: 9px 13px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s var(--ease-out-expo), background .2s var(--ease-out-expo), border-color .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo);
}
.profiles-nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.06);
}
.profiles-nav-btn.active {
  color: #101208;
  background: linear-gradient(135deg, rgba(200, 245, 66, 0.95), rgba(168, 220, 48, 0.88));
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 1px rgba(200, 245, 66, 0.12), 0 8px 20px rgba(0, 0, 0, 0.22);
}
.profiles-nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.profiles-shell select,
.account-profile-picker-filters select,
.account-profile-picker-filters input[type=search] {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(0, 0, 0, 0.28);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
  color-scheme: dark;
  padding: 8px 30px 8px 11px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .18s var(--ease-out-expo), background-color .18s var(--ease-out-expo);
}
.account-profile-picker-filters input[type=search] {
  background-image: none;
  padding-right: 11px;
  cursor: text;
}
.profiles-shell select:hover,
.account-profile-picker-filters select:hover {
  border-color: rgba(200, 245, 66, 0.28);
  background-color: rgba(200, 245, 66, 0.04);
}
.profiles-shell select:focus,
.account-profile-picker-filters select:focus,
.account-profile-picker-filters input[type=search]:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.5);
  box-shadow: 0 0 0 2px rgba(200, 245, 66, 0.12);
}
.profiles-shell select option,
.account-profile-picker-filters select option {
  background: #12151c;
  color: var(--text);
}
.profiles-main {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.profiles-templates {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.profiles-shell.templates-collapsed .profiles-templates {
  display: none;
}
.profile-card {
  background: linear-gradient(180deg, rgba(14, 17, 22, 0.96), rgba(11, 13, 16, 0.98));
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 0;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.profile-form-card,
.profile-import-card,
.profile-guide-card,
.profile-list-card {
  height: 100%;
  min-height: 0;
}
.profile-card[hidden],
[data-profile-mode-panel][hidden] {
  display: none !important;
}
.profile-card h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}
.profile-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}
.profile-form-card,
.profile-import-card,
.profile-guide-card,
.profile-list-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-form-card,
.profile-import-card,
.profile-guide-card {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.profile-guide-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
}
.profile-guide-card-head h2 { margin: 0 0 4px; }
.profile-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(200, 245, 66, 0.12);
  border: 1px solid rgba(200, 245, 66, 0.22);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#tab-profiles .primary,
#tab-profiles .profile-gen-submit {
  background: linear-gradient(135deg, rgba(200, 245, 66, 0.95), rgba(168, 220, 48, 0.88));
  color: #101208;
  border: 1px solid rgba(200, 245, 66, 0.35);
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(200, 245, 66, 0.12);
  transition: transform .2s var(--ease-out-expo), box-shadow .2s var(--ease-out-expo), filter .2s;
}
#tab-profiles .primary:hover,
#tab-profiles .profile-gen-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(200, 245, 66, 0.18);
  filter: brightness(1.03);
}
#tab-profiles .ghost {
  transition: border-color .2s var(--ease-out-expo), background .2s var(--ease-out-expo), color .2s var(--ease-out-expo);
}
#tab-profiles .ghost:hover {
  border-color: rgba(200, 245, 66, 0.22);
  background: rgba(200, 245, 66, 0.05);
}
.profile-section-divider { height: 1px; background: var(--border); margin: 4px 0; }
.profile-import-card textarea {
  width: 100%; height: 88px; min-height: 88px; resize: vertical; padding: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  color-scheme: dark;
}
.profile-import-card textarea:focus,
.profile-import-card select:focus,
.profile-form-card select:focus,
.profile-list-tools input:focus,
.profile-bulk-actions input:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.35);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.08);
}
.profile-file-row { display: flex; align-items: center; gap: 8px; min-height: 32px; flex-wrap: wrap; }
.profile-file-row .hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-import-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  flex-wrap: wrap;
}
.profile-import-foot .hint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-import-foot .primary { flex-shrink: 0; padding: 8px 14px; }
.profile-parser-import {
  border-top: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  margin-top: 2px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-parser-import h3 { margin: 0; font-size: 13px; }
.profile-parser-options { display: flex; flex-direction: column; gap: 5px; }
.profile-parser-import select,
.profile-form-card select,
.profile-set-block select,
.profile-gen-options select {
  width: 100%;
  padding: 8px 34px 8px 10px;
  background-color: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 12px;
  color-scheme: dark;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c8f542' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color .15s, box-shadow .15s;
}
.profile-parser-import select:hover,
.profile-form-card select:hover,
.profile-set-block select:hover,
.profile-gen-options select:hover {
  border-color: rgba(200, 245, 66, 0.45);
}
.profile-parser-import select:focus,
.profile-form-card select:focus,
.profile-set-block select:focus,
.profile-gen-options select:focus {
  outline: none;
  border-color: rgba(200, 245, 66, 0.55);
  box-shadow: 0 0 0 2px rgba(200, 245, 66, 0.15);
}
.profile-parser-single {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-inline-error {
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
  color: #ffb3b3;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
}
.profile-gen-row { display: flex; gap: 8px; align-items: stretch; }
.profile-gen-row input {
  width: 64px;
  flex-shrink: 0;
  padding: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
  text-align: center;
}
.profile-gen-submit { flex: 1; padding: 9px 12px; text-align: center; }
.profile-set-block { display: flex; flex-direction: column; gap: 6px; }
.profile-set-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.profile-set-actions .ghost {
  padding: 6px 4px;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}
.profile-set-actions .danger {
  color: #ffb3b3;
  border-color: rgba(255,107,107,.35);
}
.profile-gen-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.profile-form-card .lead-field {
  gap: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted);
}
.profile-gen-chk { margin: 0; font-size: 12px; }
.profile-asset-folders { display: flex; flex-direction: column; gap: 5px; }
.profile-asset-pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.profile-asset-pair-grid .ghost,
.profile-asset-common-row .ghost {
  padding: 7px 6px;
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.profile-asset-btn-male { border-color: rgba(96, 165, 250, .28); }
.profile-asset-btn-female { border-color: rgba(244, 114, 182, .28); }
.profile-asset-common-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.profile-asset-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, .22);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  font-size: 11px;
  line-height: 1.35;
  margin-top: auto;
  flex-shrink: 0;
}
.profile-asset-stats .profile-asset-stat-line:first-child { grid-column: 1 / -1; }
.profile-asset-stat-line { color: var(--text); }
.profile-asset-stat-line.muted { color: var(--muted); }
.profile-asset-stat-line strong { color: #fff; font-weight: 600; }
.profile-guide-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.profile-guide-section {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-guide-section h3 {
  margin: 0;
  font-size: 14px;
  color: #fff;
}
.profile-guide-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}
.profile-guide-steps ul {
  margin: 4px 0 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-guide-steps code { font-size: 11px; }
.profile-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 21000;
  background: rgba(0,0,0,.48);
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}
.profile-drawer-overlay[hidden] {
  display: none !important;
}
.profile-drawer {
  width: min(420px, 94vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -22px 0 60px rgba(0,0,0,.42);
  display: flex;
  flex-direction: column;
  animation: profile-drawer-in .18s ease-out;
}
@keyframes profile-drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.profile-drawer header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.profile-drawer header h2 {
  margin: 0 0 4px;
  font-size: 17px;
}
.profile-drawer header .hint,
.profile-drawer-body .hint {
  margin: 0;
}
.profile-drawer-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.profile-drawer-body code {
  color: var(--text);
}
.profile-drawer footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.profile-list-card {
  flex: 1;
  min-width: 0;
  height: 100%;
  min-height: 0;
}
.profile-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.profile-list-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  flex: 1;
  justify-content: flex-end;
}
.profile-list-tools input[type=search] {
  width: min(180px, 100%);
  flex: 1;
  max-width: 220px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
  color-scheme: dark;
}
.profile-list-tools select {
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
  color-scheme: dark;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
}
.profile-bulk-actions {
  display: grid;
  grid-template-columns: auto 76px 1fr;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.profile-bulk-actions input {
  padding: 7px 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  color: var(--text);
}
.profile-bulk-actions .danger {
  color: #ffb3b3;
  border-color: rgba(255,107,107,.35);
}
.profile-list {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  align-content: start;
  gap: 10px;
  padding-right: 4px;
  min-height: 0;
  flex: 1;
}
.profile-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 14px 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--surface-glass-border, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-md);
  transition: border-color .2s var(--ease-out-expo), background .2s var(--ease-out-expo), transform .2s var(--ease-out-expo);
}
.profile-row:hover {
  border-color: rgba(200, 245, 66, 0.18);
  background: rgba(200, 245, 66, 0.04);
  transform: translateY(-1px);
}
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-row-main { width: 100%; min-width: 0; }
.profile-row-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-row-status {
  font-size: 12px;
  color: var(--text);
  margin-top: 3px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.profile-row-meta {
  font-size: 10px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-row-actions { display: flex; gap: 6px; width: 100%; margin-top: 2px; }
.profile-row-actions button { flex: 1; padding: 6px 8px; font-size: 11px; }

.acc-sess-inline {
  display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0;
}
.acc-sess-warn, .acc-sess-2fa, .acc-sess-rotate {
  font-size: 9px; font-weight: 700; padding: 0 5px; border-radius: 999px; line-height: 16px;
  white-space: nowrap;
}
.acc-sess-warn {
  color: #ffb3c6; background: rgba(255, 77, 130, .15); border: 1px solid rgba(255, 77, 130, .35);
}
.acc-sess-2fa {
  color: #ffd59a; background: rgba(255, 159, 67, .12); border: 1px solid rgba(255, 159, 67, .3);
}
.acc-sess-rotate {
  color: #9ec5ff; background: rgba(100, 149, 237, .12); border: 1px solid rgba(100, 149, 237, .35);
}
.acc-sess-rotate.busy {
  color: #ffb4b4; background: rgba(255, 80, 80, .12); border: 1px solid rgba(255, 80, 80, .35);
}
.sess-sec-rotate-actions [hidden] { display: none !important; }
#sessSecRotateFinish:disabled,
.rotate-finish-locked {
  opacity: 0.65;
  cursor: not-allowed !important;
  pointer-events: none !important;
  color: var(--muted) !important;
  background: transparent !important;
  border: 1px dashed #444 !important;
}
.sess-sec-hint { margin-bottom: 12px; line-height: 1.45; }
.sess-sec-summary {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.sess-sec-chip {
  font-size: 12px; padding: 6px 10px; border-radius: 8px;
  background: #12151c; border: 1px solid var(--border);
}
.sess-sec-chip.warn { border-color: rgba(255, 107, 107, .45); color: #ffb3b3; }
.sess-sec-chip.ok { border-color: rgba(46, 213, 115, .35); color: #9dffc8; }
.sess-sec-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.sess-sec-item {
  padding: 10px 12px; border-radius: 10px; background: #12151c; border: 1px solid var(--border);
}
.sess-sec-item.current { border-color: rgba(106, 130, 255, .55); box-shadow: inset 0 0 0 1px rgba(106, 130, 255, .15); }
.sess-sec-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-weight: 700; font-size: 13px; }
.sess-sec-item-tags { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; flex-shrink: 0; }
.sess-sec-kick-one { font-size: 11px; padding: 2px 8px; }
.sess-sec-2fa-vault {
  margin: 12px 0 14px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid rgba(106, 130, 255, .25); background: rgba(106, 130, 255, .06);
}
.sess-sec-2fa-vault-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sess-sec-2fa-vault-title { font-weight: 700; font-size: 13px; }
.sess-sec-2fa-vault-actions { display: flex; gap: 8px; margin-top: 8px; }
.sess-sec-item-meta { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.sess-sec-rotate {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sess-sec-rotate-title { font-size: 14px; margin: 0 0 8px; }
.sess-sec-rotate-state { margin: 10px 0; font-size: 13px; }
.sess-sec-rotate-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sess-sec-rotate-actions .ub-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.sess-sec-rotate-code { margin-top: 8px; max-width: 220px; }
.sess-sec-tools, .sess-sec-2fa-setup, .sess-sec-privacy {
  margin: 12px 0; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; background: rgba(0,0,0,.12);
}
.sess-sec-tools-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.sess-sec-ttl-field { min-width: 140px; flex: 0 1 auto; }
.sess-sec-web-list { margin-top: 8px; font-size: 12px; color: var(--muted); }
.sess-sec-web-item { padding: 6px 0; border-top: 1px solid var(--border); }
.sess-sec-2fa-grid, .sess-sec-privacy-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-top: 8px;
}
.modal-body label.sess-sec-check,
label.sess-sec-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  max-width: 100%;
  margin: 8px 0;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.modal-body label.sess-sec-check input[type=checkbox],
label.sess-sec-check input[type=checkbox] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.sess-sec-hide-row { margin: 4px 0 10px; font-weight: 500; }
.sess-sec-readonly { color: var(--muted); cursor: default; }
.sess-sec-field-hint {
  display: block; margin-top: 4px; font-size: 10px; line-height: 1.35;
  color: var(--muted); text-transform: none; letter-spacing: normal; font-weight: 400;
}
.sess-sec-sensitive.sess-sec-masked {
  -webkit-text-security: disc;
  text-security: disc;
  font-family: inherit;
}
.sess-sec-recovery { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.warn-text { color: #ffb3b3 !important; }

/* ── DarkTelegram-inspired accounts UI ── */
.dt-accounts-panel { padding: 12px 14px 0; background: var(--bg); }
.acc-cmd-panel {
  flex-shrink: 0; margin-bottom: 10px;
  border: 1px solid rgba(200,245,66,0.14); border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent), #11151b;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.acc-cmd-filters {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; width: 100%;
}
.acc-cmd-actions {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  row-gap: 6px; width: 100%;
  padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.06);
}
.acc-cmd-seg {
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
  padding: 0 7px;
}
.acc-cmd-seg:first-child { padding-left: 0; }
.acc-cmd-seg-bulk { flex: 1; min-width: 0; justify-content: flex-start; }
.acc-cmd-sep {
  width: 1px; height: 22px; background: rgba(255,255,255,0.08); flex-shrink: 0;
  margin: 0 3px;
}
.acc-cmd-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: rgba(200,245,66,0.1); border: 1px solid rgba(200,245,66,0.22);
}
.acc-bulk-clear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12); background: #181d26;
  color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.acc-bulk-clear:hover { color: #fff; border-color: rgba(255,255,255,0.22); background: #222833; }
/* Крестик «снять выбор» всегда занимает место (visibility вместо display),
   иначе при выборе аккаунта он добавляет ширину и кнопка «Удалить» переезжает на 2-ю строку. */
.acc-bulk-clear[hidden] { display: inline-flex !important; visibility: hidden; }
.acc-cmd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 28px; min-width: 28px; padding: 0 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08); background: #181d26; color: #d8dee9;
  font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; transition: border-color .12s, background .12s, color .12s, box-shadow .12s;
}
.acc-cmd-btn:hover:not(:disabled) { border-color: rgba(255,255,255,0.16); background: #222833; }
.acc-cmd-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.acc-cmd-btn--start { border-color: rgba(200,245,66,0.4); color: var(--accent); background: rgba(200,245,66,0.1); }
.acc-cmd-btn--start:hover:not(:disabled) { background: rgba(200,245,66,0.16); box-shadow: 0 0 0 1px rgba(200,245,66,0.12); }
.acc-cmd-btn--stop { border-color: rgba(255,159,67,0.42); color: #ffb347; background: rgba(255,159,67,0.1); }
.acc-cmd-btn--stop:hover:not(:disabled) { background: rgba(255,159,67,0.16); }
.acc-cmd-btn--warn { border-color: rgba(255,159,67,0.32); color: #ffb347; }
.acc-cmd-btn--danger { border-color: rgba(255,107,107,0.38); color: #ff8a8a; }
.acc-cmd-btn--danger:hover:not(:disabled) { background: rgba(255,107,107,0.1); }
.acc-cmd-toggle { color: var(--muted); border-color: rgba(255,255,255,0.07); background: #141820; }
.acc-cmd-toggle:hover:not(:disabled) { color: var(--text); }
.acc-cmd-toggle.acc-cmd-toggle--on {
  color: #101208; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 12px rgba(200,245,66,0.2);
}
.acc-cmd-pool-toggle { min-width: 72px; font-variant-numeric: tabular-nums; padding: 0 12px; }
.acc-cmd-pool-toggle--start { border-color: rgba(200,245,66,0.45); color: var(--accent); background: rgba(200,245,66,0.12); }
.acc-cmd-pool-toggle--stop { border-color: rgba(255,159,67,0.48); color: #ffb347; background: rgba(255,159,67,0.12); }
.acc-cmd-pool-toggle--busy { border-color: rgba(255,107,107,0.45); color: #ff8a8a; background: rgba(255,107,107,0.1); }
.acc-cmd-select {
  height: 28px; padding: 0 28px 0 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08); background: #0c0f12; color: var(--text);
  font-size: 11px; max-width: 130px; flex-shrink: 0;
}
.acc-cmd-search {
  height: 28px; flex: 1 1 180px; min-width: 140px;
  padding: 0 10px; border-radius: 8px; font-size: 11px;
  background: #0c0f12; border: 1px solid rgba(255,255,255,0.08); color: var(--text);
}
.acc-cmd-search:focus { border-color: var(--accent-glow); outline: none; }
.dt-btn-add, .dt-btn-primary, .dt-btn-outline, .dt-btn-ghost {
  border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.dt-btn-add {
  padding: 10px 18px; border: 1px solid var(--accent-glow);
  background: transparent; color: var(--accent);
}
.dt-btn-add:hover, .dt-btn-add.active {
  background: var(--accent-dim); color: #eaff9a; border-color: var(--accent);
}
.dt-btn-primary {
  padding: 10px 20px; border: none; background: var(--accent); color: #101208;
}
.dt-btn-primary:hover { filter: brightness(1.06); }
.dt-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.dt-btn-outline {
  padding: 8px 14px; border: 1px solid var(--border); background: var(--panel2);
  color: var(--text);
}
.dt-btn-outline:hover { border-color: var(--accent-glow); color: var(--accent); }
.dt-btn-ghost {
  padding: 10px 16px; border: 1px solid var(--border); background: transparent; color: var(--muted);
}
.dt-btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.16); }
.acc-accounts-body {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column;
  overflow: hidden;
}
.acc-accounts-list {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.accounts-panel.acc-add-open .acc-accounts-list {
  pointer-events: none; user-select: none;
}
.acc-add-drawer {
  position: absolute; inset: 0; z-index: 12;
  display: flex; flex-direction: column;
  margin: 0; border: none; border-top: 1px solid var(--border); border-radius: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg);
  overflow: hidden;
  transform: translateY(-100%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none; visibility: hidden;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.35);
}
.acc-add-drawer:not([hidden]) { visibility: visible; }
.acc-add-drawer.is-open {
  transform: translateY(0);
  pointer-events: auto;
}
.acc-add-drawer-head {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  padding: 10px 14px 0; border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
}
.acc-add-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.acc-add-tab {
  padding: 8px 16px; border: none; border-radius: 10px 10px 0 0;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.acc-add-tab.active {
  background: var(--accent); color: #101208;
}
.acc-add-tab:disabled { opacity: 0.35; cursor: not-allowed; }
.acc-add-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.acc-add-layout {
  display: grid; grid-template-columns: minmax(240px, 1fr) minmax(280px, 1.2fr);
  gap: 14px; align-items: stretch;
}
.acc-add-col { min-width: 0; }
.acc-add-col-upload { display: flex; flex-direction: column; }
.acc-add-col-upload[hidden] { display: none !important; }
.acc-add-body [hidden] { display: none !important; }
.acc-add-col-settings {
  padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: rgba(0,0,0,0.22); display: flex; flex-direction: column; gap: 10px;
}
.acc-add-section-title {
  margin: 0; font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: 0.02em;
}
.acc-add-subtitle {
  margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.acc-add-hint {
  margin: 0; font-size: 11px; line-height: 1.45; color: var(--muted);
}
.acc-add-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.acc-add-field {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.acc-add-label {
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em;
}
.acc-add-drawer .acc-add-field input,
.acc-add-drawer .acc-add-field select {
  width: 100%; margin: 0; padding: 9px 10px;
  background: #0c0f12; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.acc-add-drawer .acc-add-field input::placeholder { color: #5a6472; }
.acc-add-drawer .acc-add-field input:focus,
.acc-add-drawer .acc-add-field select:focus {
  outline: none; border-color: var(--accent-glow);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.acc-add-drawer .acc-add-field select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d8796' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}
.acc-add-subbox {
  padding: 10px 12px; border: 1px dashed rgba(200, 245, 66, 0.22);
  border-radius: 10px; background: rgba(200, 245, 66, 0.04);
}
.acc-add-checks {
  display: flex; flex-direction: column; gap: 8px; margin-top: 2px;
}
.acc-add-checks[hidden] { display: none !important; }

.acc-import-result {
  margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--panel2); font-size: 13px;
}
.acc-import-result[hidden] { display: none !important; }
.air-head { font-weight: 600; color: var(--text); margin-bottom: 8px; }
.air-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.air-stat { padding: 4px 10px; border-radius: 8px; font-size: 12.5px; border: 1px solid var(--border); }
.air-stat.air-ok { color: var(--green); border-color: rgba(92,219,122,.4); background: rgba(92,219,122,.08); }
.air-stat.air-warn { color: var(--orange); border-color: rgba(255,159,67,.4); background: rgba(255,159,67,.08); }
.air-stat.air-err { color: var(--red); border-color: rgba(255,107,107,.4); background: rgba(255,107,107,.08); }
.air-formats { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.air-chip {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(200,245,66,.3);
}
.air-details { margin-top: 8px; }
.air-details > summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }
.air-details ul { margin: 4px 0 0; padding-left: 18px; max-height: 180px; overflow-y: auto; }
.air-details li { font-size: 12px; color: var(--text); margin: 2px 0; word-break: break-word; }

.acc-add-paste { margin-top: 10px; }
.acc-add-paste > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 6px 0; }
.acc-add-paste > summary:hover { color: var(--accent); }
.acc-add-paste textarea {
  width: 100%; box-sizing: border-box; margin-top: 6px; padding: 9px 11px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: 12px; font-family: monospace; resize: vertical;
}
.acc-add-check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text); cursor: pointer; user-select: none;
}
.acc-add-check input[type=checkbox] {
  width: 16px; height: 16px; min-width: 16px; margin: 0; padding: 0;
  accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.acc-add-drop-title { margin: 0 0 4px !important; font-size: 14px !important; color: var(--text) !important; font-weight: 600; }
.acc-add-drop-hint { margin: 0 0 14px !important; font-size: 12px !important; color: var(--muted) !important; }
.acc-add-phone-flow { display: flex; flex-direction: column; gap: 12px; }
.acc-add-phone-status {
  margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 12px; line-height: 1.45;
  background: #12161c; border: 1px solid var(--border); color: var(--muted);
}
.acc-add-phone-status.is-ok { color: #b8f090; border-color: rgba(184,240,144,.25); }
.acc-add-phone-status.is-warn { color: #ffd48a; border-color: rgba(255,212,138,.25); }
.acc-add-phone-status.is-err { color: #ff9a9a; border-color: rgba(255,154,154,.25); }
.acc-add-queue-wrap {
  border: 1px solid var(--border); border-radius: 12px; background: rgba(0,0,0,0.18);
  padding: 10px 12px;
}
.acc-add-queue-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px; font-size: 12px; color: var(--muted);
}
.acc-add-queue-head strong { color: var(--accent); font-weight: 700; }
.acc-add-link {
  background: none; border: none; padding: 0; font-size: 12px; color: var(--accent);
  cursor: pointer; text-decoration: none;
}
.acc-add-link:hover { text-decoration: underline; color: #eaff9a; }
.acc-add-queue { max-height: min(220px, 28vh); margin: 0; overflow-y: auto; }
.acc-add-drawer .ub-queue-item { background: #0c0f12; border-color: var(--border); }
.acc-add-foot {
  flex-shrink: 0;
  display: flex; align-items: stretch; gap: 10px;
  padding: 12px 16px 14px; border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.28);
}
.acc-add-foot-actions {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.acc-add-collapse {
  flex: 1; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent), #141820;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-color .18s, color .18s, background .18s, box-shadow .18s;
}
.acc-add-collapse:hover {
  border-color: rgba(200,245,66,0.38); color: var(--accent);
  background: rgba(200,245,66,0.07);
  box-shadow: inset 0 1px 0 rgba(200,245,66,0.08);
}
.acc-add-collapse-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: inherit;
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1), background .18s;
}
.acc-add-collapse:hover .acc-add-collapse-icon {
  background: rgba(200,245,66,0.14);
  transform: translateY(-2px);
}
.acc-add-collapse-text { letter-spacing: 0.02em; }
.acc-cmd-btn--add {
  border-color: rgba(200,245,66,0.35); color: var(--accent);
  background: rgba(200,245,66,0.08);
}
.acc-cmd-btn--add:hover:not(:disabled) {
  background: rgba(200,245,66,0.14); border-color: rgba(200,245,66,0.5);
}
.acc-cmd-btn--add.active {
  color: #101208; background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 12px rgba(200,245,66,0.22);
}
.dt-drop {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px dashed rgba(200, 245, 66, 0.28); border-radius: 12px;
  background: rgba(0,0,0,0.22); text-align: center; padding: 32px 16px; min-height: 200px;
}
.dt-drop.drag { border-color: var(--accent); background: var(--accent-dim); }
.dt-drop .dt-btn-outline { margin-top: 4px; }
.accounts-panel .toolbar button.primary {
  background: var(--accent); color: #101208; border: none; font-weight: 700;
}
.accounts-panel .acc-table-wrap {
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
}
.accounts-panel .accounts-tbl thead th {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: #5f6878;
  background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border);
}
.acc-search-input:focus { border-color: var(--accent-glow); }

@media (max-width: 960px) {
  .ub-bulk-bar { left: 0; }
  #tab-inbox.tab.active { grid-template-columns: 280px minmax(0, 1fr); }
  #tab-inbox > .lead-panel { display: none; }
  .profiles-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow-y: auto;
  }
  .profiles-shell.templates-collapsed .profiles-layout {
    grid-template-columns: 1fr;
  }
  .profiles-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .profiles-nav-btn {
    flex: 1 1 140px;
  }
  .profiles-shell.templates-collapsed .profiles-layout {
    grid-template-columns: 1fr;
  }
  .profiles-topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .acc-add-layout { grid-template-columns: 1fr; }
  .acc-add-fields { grid-template-columns: 1fr; }
  .dt-drop { min-height: 140px; }
  .acc-cmd-sep { display: none; }
  .acc-cmd-seg { padding: 0; flex: 1 1 100%; }
  .acc-add-foot { flex-direction: column; align-items: stretch; }
  .acc-add-foot-actions { justify-content: flex-end; }
  .acc-cmd-filters { flex-wrap: wrap; }
}

.tpl-st-badge-job {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #3b82f6;
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
}
.tpl-st-badge-global {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #6b7280;
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
}
.tpl-preset-badge-job {
  background: rgba(124, 108, 255, 0.22) !important;
  color: #b8a8ff !important;
}
.tpl-preset-badge-global {
  background: rgba(61, 214, 140, 0.2) !important;
  color: var(--green) !important;
}
.tpl-scope-filter {
  display: flex;
  gap: 8px;
  padding: 4px 12px;
  align-items: center;
}
.tpl-scope-filter[hidden] {
  display: none !important;
}
.gpt-wizard-import-options {
  padding: 6px 0;
  font-size: 0.9rem;
}
.gpt-wizard-import-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.gpt-preview-scope {
  padding: 4px 0;
  color: #94a3b8;
  font-size: 0.88rem;
}
.gpt-preview-warnings li {
  color: #f59e0b;
}
.gpt-preview-summary {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 6px;
  font-size: 0.9rem;
}

/* Preset editor modal — после .modal.ub-modal, иначе стили не применяются */
#modalTplEditor.modal.ub-modal.tpl-editor-modal {
  position: fixed;
  inset: 3vh 2vw;
  left: 2vw;
  top: 3vh;
  right: 2vw;
  bottom: 3vh;
  transform: none;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  overflow: hidden;
}


/* ── Тренинг агентов ── */
#tab-training.tab.active { display: flex; min-height: 0; overflow: hidden; }
.training-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 14px 14px; gap: 10px; overflow: hidden; }
.training-topbar h1 { margin: 0 0 2px; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.training-topbar .hint { margin: 0; max-width: 900px; }
.training-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); gap: 12px; overflow: hidden; }
.training-side { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08)); border-radius: var(--radius-lg); background: linear-gradient(180deg, rgba(14,17,22,0.96), rgba(11,13,16,0.98)); }
.training-side .lead-field { margin: 0; }
.training-side-row { display: flex; gap: 10px; align-items: flex-end; }
.training-side-row .lead-field { flex: 1; }
.train-pb-chk { white-space: nowrap; }
.training-side select, .training-side textarea { width: 100%; padding: 7px 10px; background: rgba(0,0,0,0.28); border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08)); border-radius: var(--radius-md); color: var(--text); color-scheme: dark; }
.training-side-actions { display: flex; gap: 8px; }
.training-scenarios { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 8px; min-height: 0; }
.training-scenarios-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.training-scenarios-head h3 { margin: 0; font-size: 13px; }
.training-scenario-list { display: flex; flex-direction: column; gap: 8px; }
.train-scenario { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.train-scenario-title { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.train-scenario-line { display: block; width: 100%; text-align: left; padding: 5px 7px; margin-bottom: 3px; font-size: 12px; background: rgba(0,0,0,0.22); border: 1px solid transparent; border-radius: 6px; color: var(--text); cursor: pointer; }
.train-scenario-line:hover { border-color: rgba(200,245,66,0.28); background: rgba(200,245,66,0.05); }
.training-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.training-chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08)); border-radius: var(--radius-lg); background: rgba(0,0,0,0.18); }
.training-empty { margin: auto; color: var(--muted); text-align: center; max-width: 460px; }
.train-msg { display: flex; flex-direction: column; max-width: 78%; }
.train-msg-client { align-self: flex-start; align-items: flex-start; }
.train-msg-agent { align-self: flex-end; align-items: flex-end; }
.train-bubble { padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.train-msg-client .train-bubble { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-bottom-left-radius: 4px; }
.train-msg-agent .train-bubble { background: linear-gradient(135deg, rgba(200,245,66,0.16), rgba(168,220,48,0.12)); border: 1px solid rgba(200,245,66,0.25); border-bottom-right-radius: 4px; }
.train-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; }
.train-badge { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; background: rgba(0,0,0,0.3); border: 1px solid var(--border); color: var(--muted); }
.train-badge-status { color: #c8f542; border-color: rgba(200,245,66,0.3); }
.train-badge-tech { color: #9ec5ff; border-color: rgba(100,149,237,0.3); }
.train-rate { padding: 2px 8px; font-size: 13px; background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.train-rate:hover { border-color: rgba(200,245,66,0.35); }
.train-rate.active { background: rgba(200,245,66,0.18); border-color: rgba(200,245,66,0.5); }
.train-dbg-toggle { padding: 2px 8px; font-size: 10.5px; }
.train-note-row { display: flex; gap: 6px; margin-top: 6px; width: 100%; }
.train-note { flex: 1; padding: 5px 8px; font-size: 12px; background: rgba(0,0,0,0.28); border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.train-debug { margin-top: 6px; max-width: 100%; max-height: 220px; overflow: auto; font-size: 10.5px; line-height: 1.35; background: rgba(0,0,0,0.4); border: 1px solid var(--border); border-radius: 8px; padding: 8px; color: var(--muted); white-space: pre; }
.training-compose { display: flex; gap: 8px; align-items: flex-end; }
.training-compose textarea { flex: 1; resize: vertical; min-height: 42px; padding: 9px 11px; background: rgba(0,0,0,0.28); border: 1px solid var(--surface-glass-border, rgba(255,255,255,0.08)); border-radius: var(--radius-md); color: var(--text); }
.training-compose .primary { white-space: nowrap; }
@media (max-width: 960px) {
  .training-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); overflow-y: auto; }
}

/* Тренинг: переключатель режимов + разбор готовых диалогов */
.training-mode-switch { display: flex; gap: 6px; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 4px; }
.training-mode-switch button { flex: 1; padding: 6px 8px; font-size: 12px; background: transparent; border: 1px solid transparent; border-radius: 7px; color: var(--muted); cursor: pointer; }
.training-mode-switch button.active { background: rgba(200,245,66,0.12); border-color: rgba(200,245,66,0.32); color: var(--text); }
.train-dialog-pick { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 9px; margin-bottom: 4px; font-size: 12px; background: rgba(0,0,0,0.22); border: 1px solid transparent; border-radius: 7px; color: var(--text); cursor: pointer; }
.train-dialog-pick:hover { border-color: rgba(200,245,66,0.28); background: rgba(200,245,66,0.05); }
.train-dialog-pick.active { border-color: rgba(200,245,66,0.45); background: rgba(200,245,66,0.10); }
.train-dialog-count { font-size: 10px; color: var(--muted); background: rgba(255,255,255,0.06); border-radius: 10px; padding: 1px 7px; }
.train-review-head { font-size: 12px; color: var(--muted); padding: 4px 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* Тренинг: кнопки строки ввода (отправить / перегенерировать / заново) */
.training-compose-btns { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.training-compose-btns button { white-space: nowrap; font-size: 12px; padding: 7px 10px; }
.training-compose-btns .primary { font-size: 13px; }


/* ===================== Конвертер сессий ===================== */
#tab-converter { overflow-y: auto; }
#tab-converter [hidden] { display: none !important; }
.conv-shell {
  width: 100%; max-width: 1240px; margin: 0 auto;
  padding: 18px clamp(20px, 4vw, 48px) 24px;
  box-sizing: border-box;
}
.conv-grid {
  display: grid; grid-template-columns: 1fr 44px 1fr; gap: 16px; align-items: stretch;
}
.conv-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.conv-card-head {
  font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--text);
}
.conv-fmt-group {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 8px;
}
.conv-fmt {
  padding: 11px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font-size: 12.5px; font-weight: 600;
  cursor: pointer; text-align: center; transition: all .16s ease; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-fmt:hover { border-color: rgba(200,245,66,.35); color: var(--accent); }
.conv-fmt.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #101208; border-color: rgba(255,255,255,.14); box-shadow: 0 3px 14px var(--accent-glow);
}
.conv-disabled { opacity: .4; pointer-events: none; filter: grayscale(.6); }
.conv-drop {
  flex: 1; min-height: 96px;
  border: 1.5px dashed var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; background: var(--bg); transition: all .16s ease; text-align: center;
}
.conv-drop:hover, .conv-drop-over { border-color: var(--accent); background: var(--accent-dim); }
.conv-drop-ico { font-size: 28px; color: var(--accent); line-height: 1; }
.conv-drop-text { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.conv-drop-sm { min-height: 0; padding: 16px; flex: none; }
.conv-arrow {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--accent); font-weight: 700;
}
.conv-import-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text);
  cursor: pointer; padding: 4px 2px 0;
}
.conv-import-row input, .conv-check input { accent-color: var(--accent); cursor: pointer; }
.conv-import-opts { display: flex; flex-direction: column; gap: 10px; }
.conv-import-opts[hidden] { display: none !important; }
.conv-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.conv-select {
  width: 100%; padding: 10px 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13px; box-sizing: border-box;
}
.conv-go { margin-top: auto; width: 100%; }
.conv-go:disabled { opacity: .45; cursor: not-allowed; }
.conv-bottom {
  display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px;
  align-items: start; margin-top: 14px;
}
.conv-batch {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 16px; align-self: start;
}
.conv-batch > summary {
  cursor: pointer; padding: 13px 0; font-size: 13px; font-weight: 600; color: var(--text);
  list-style: none;
}
.conv-batch > summary::-webkit-details-marker { display: none; }
.conv-batch > summary::before { content: '▶ '; color: var(--accent); font-size: 10px; }
.conv-batch[open] > summary::before { content: '▼ '; }
.conv-batch-body { padding: 4px 0 16px; display: flex; flex-direction: column; gap: 12px; }
.conv-batch-hint { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }
.conv-status {
  padding: 14px 16px; border-radius: 12px; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  align-self: start; word-break: break-word;
}
.conv-status-ok { border-color: rgba(92,219,122,.4); background: rgba(92,219,122,.08); }
.conv-status-warn { border-color: rgba(255,159,67,.4); background: rgba(255,159,67,.08); }
.conv-status-err { border-color: rgba(255,107,107,.4); background: rgba(255,107,107,.08); }
.conv-status-wait { border-color: rgba(200,245,66,.3); background: var(--accent-dim); }
@media (max-width: 920px) {
  .conv-grid { grid-template-columns: 1fr; }
  .conv-arrow { transform: rotate(90deg); height: 26px; }
  .conv-bottom { grid-template-columns: 1fr; }
}

/* === Вкладка «Базы получателей» === */
#tab-bases .bc-page { display: flex; flex-direction: column; gap: 14px; }
.bases-create {
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 10px;
  max-height: 0;
  opacity: 0;
  border-width: 0;
  overflow: hidden;
  transition: max-height .28s ease, opacity .2s ease, padding .2s ease, border-width .2s ease;
}
.bases-create.open {
  max-height: 760px;
  opacity: 1;
  padding: 14px;
  border-width: 1px;
}
.base-merge-section { display: flex; flex-direction: column; gap: 6px; }
.base-merge-toggle {
  align-self: flex-start;
  background: none; border: 1px dashed rgba(255,255,255,0.18); cursor: pointer;
  color: var(--text-secondary, #b6bcc6); font-size: 0.82rem;
  padding: 6px 12px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 8px;
}
.base-merge-toggle:hover { border-color: var(--accent, #c8f542); color: var(--text); }
.base-merge-count {
  background: var(--accent, #c8f542); color: #15171c;
  font-weight: 700; font-size: 0.72rem; padding: 0 7px; border-radius: 999px;
}
.base-merge-picker {
  max-height: 190px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 9px; padding: 6px;
  background: rgba(0,0,0,0.18);
}
.base-merge-picker[hidden] { display: none; }
.base-merge-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 0.84rem;
}
.base-merge-item:hover { background: rgba(255,255,255,0.05); }
.base-merge-item input { width: 15px; height: 15px; accent-color: var(--accent, #c8f542); flex: none; }
.base-merge-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.base-merge-meta { color: var(--muted, #8a909c); font-size: 0.74rem; flex: none; }

/* Мультивыбор баз в мастере рассылки */
.bc-parsed-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 0.84rem;
}
.bc-parsed-item:hover { background: rgba(255,255,255,0.05); }
.bc-parsed-item input { width: 15px; height: 15px; accent-color: var(--accent, #c8f542); flex: none; }
.bc-parsed-name { color: var(--text-primary, #e7ebf0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bc-parsed-meta { color: var(--text-secondary, #8a909c); font-size: 0.74rem; flex: none; }
.bases-create-row { display: flex; gap: 10px; flex-wrap: wrap; }
.bases-input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  background: var(--bg-dark, #15171c);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  box-sizing: border-box;
  font-family: inherit;
}
textarea.bases-input { resize: vertical; min-height: 90px; }
.bases-create-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bases-list { display: flex; flex-direction: column; gap: 10px; }
.bases-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px;
  text-align: center;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 12px;
}
.base-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: border-color .15s, background .15s;
}
.base-card:hover { border-color: rgba(200,245,66,0.3); }
.base-card-name { font-weight: 600; color: var(--text); font-size: 0.92rem; }
.base-card-meta { color: var(--muted); font-size: 0.76rem; margin-top: 3px; }
.base-card-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.base-card-actions .base-del:hover { border-color: rgba(255,107,107,0.4); color: var(--red); background: rgba(255,107,107,0.1); }
.base-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: var(--text);
}
.base-badge--parser { background: rgba(120,170,255,0.18); color: #8db4ff; }
.base-badge--contacts { background: rgba(200,245,66,0.16); color: #c8f542; }
.base-badge--phones { background: rgba(255,169,77,0.16); color: #ffa94d; }
.base-badge--manual { background: rgba(255,255,255,0.1); color: var(--muted); }
.bases-modal {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.bases-modal[hidden] { display: none; }
.bases-modal-box {
  background: var(--bg, #15171c);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex; flex-direction: column;
  padding: 16px 18px;
}
.bases-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.bases-modal-head h3 { margin: 0; font-size: 1rem; color: var(--text); }
.bases-modal-x {
  background: none; border: none; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.bases-modal-x:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.bases-items {
  margin-top: 10px;
  overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-content: flex-start;
}
.base-item {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 0.78rem;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}
.base-item--phone { color: #ffa94d; border-color: rgba(255,169,77,0.25); }
.base-item--username { color: #8db4ff; border-color: rgba(120,170,255,0.25); }

.base-clients {
  margin-top: 10px;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.bcl-row {
  display: grid;
  grid-template-columns: 34px minmax(120px, 1.2fr) minmax(140px, 1.6fr) 44px 96px;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  border-radius: 8px;
}
.bcl-row:hover { background: rgba(255,255,255,0.04); }
.bcl-av {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #3a4252, #525c70);
  flex: none;
}
.bcl-av--lg { width: 44px; height: 44px; font-size: 15px; }
.bcl-main { min-width: 0; }
.bcl-name {
  font-weight: 600; font-size: 0.86rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bcl-tag { font-size: 0.76rem; color: #8db4ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcl-reason-preview {
  font-size: 0.78rem; color: var(--text-secondary, #b6bcc6);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bcl-cnt {
  min-width: 26px; text-align: center;
  padding: 1px 7px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700;
  background: rgba(200,245,66,0.14); color: var(--accent, #c8f542);
  justify-self: center;
}
.bcl-card-btn { white-space: nowrap; }
.bcl-card-btn:disabled { opacity: 0.4; cursor: default; }

/* AI-карточка клиента из базы */
.bcl-card-box { max-width: 560px; }
.bcl-card-head { align-items: flex-start; }
.bcl-card-title { display: flex; align-items: center; gap: 12px; }
.bcl-card-id { min-width: 0; }
.bcl-card-name { font-size: 1.02rem; font-weight: 700; color: var(--text); }
.bcl-card-tag {
  font-size: 0.82rem; color: #8db4ff; cursor: pointer; margin-top: 2px;
}
.bcl-card-tag:hover { text-decoration: underline; }
.bcl-card-body { margin-top: 12px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.bcl-card-block {}
.bcl-card-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted, #8a909c); margin-bottom: 5px;
}
.bcl-card-reason {
  font-size: 0.88rem; line-height: 1.45; color: var(--text);
  background: rgba(200,245,66,0.07);
  border-left: 2px solid var(--accent, #c8f542);
  padding: 8px 11px; border-radius: 0 8px 8px 0;
}
.bcl-msg {
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 9px; margin-bottom: 6px;
  background: rgba(255,255,255,0.04); border-radius: 8px;
  font-size: 0.82rem; line-height: 1.4;
}
.bcl-msg-date { font-size: 0.72rem; color: var(--muted, #8a909c); }
.bcl-msg-text { color: var(--text); }
.bcl-msg--key {
  background: rgba(200,245,66,0.10);
  border: 1px solid rgba(200,245,66,0.45);
}
.bcl-msg--key .bcl-msg-text { color: var(--accent, #c8f542); font-weight: 600; }
.bcl-msg-key-badge {
  display: inline-block; align-self: flex-start;
  font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #15171c; background: var(--accent, #c8f542);
  padding: 1px 6px; border-radius: 999px; margin-bottom: 2px;
}
.bcl-head-actions { display: flex; align-items: center; gap: 6px; }

.base-export-wrap { position: relative; display: inline-block; }
.base-export-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 50;
  display: flex; flex-direction: column; min-width: 170px;
  background: var(--bg, #15171c);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 9px; padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.base-export-menu[hidden] { display: none; }
.base-export-opt {
  text-align: left; background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 0.82rem; padding: 7px 10px; border-radius: 6px;
}
.base-export-opt:hover { background: rgba(255,255,255,0.08); color: var(--accent, #c8f542); }

/* AI    */
#freemodelKeyStatus.is-ok { color: var(--accent, #c8f542); font-weight: 600; }
