@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@300;400;500;600&display=swap');

/* ===== GLOBAL ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== VARIABLES ===== */
:root {
  --bg:           #F5F5F0;
  --card:         #FFFFFF;
  --sidebar:      #FFFFFF;
  --border:       #E6E8EC;
  --border-light: #EFF1F4;
  --primary:      #00A884;
  --primary-hover:#008F72;
  --primary-light: rgba(0,168,132,.08);
  --unread:       #34B7F1;
  --gold-grad:    linear-gradient(135deg, #25D366 0%, #00A884 50%, #008069 100%);
  --btn-grad:     linear-gradient(135deg, #00C29A 0%, #00A884 50%, #008F72 100%);
  --success:      #16794A;
  --warning:      #C4821A;
  --danger:       #B03A2E;
  --text:         #283242;
  --text-2:       #6B7280;
  --text-3:       #9AA0AC;
  --input-bg:     #F7F8FA;
  --shadow-sm:    0 2px 8px rgba(15,23,42,.05);
  --shadow-md:    0 8px 32px rgba(15,23,42,.09);
  --shadow-gold:  0 8px 28px rgba(0,168,132,.20);
  --radius:       14px;
  --radius-sm:    10px;

  /* Emil Kowalski easing curves */
  --ease-out:     cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out:  cubic-bezier(0.77, 0, 0.175, 1);
}

/* ===== RESET ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body, * { font-family: 'Inter', sans-serif; font-weight: 400; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(rgba(245,245,240,.86), rgba(245,245,240,.86)),
    url('/bg.jpg') center / cover fixed no-repeat;
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 400;
}

/* ===== PAGE TRANSITIONS ===== */
#main-content { animation: fadeIn .25s var(--ease-out); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== LOGIN ===== */
#login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(rgba(245,245,240,.86), rgba(245,245,240,.86)),
    url('/bg.jpg') center / cover fixed no-repeat;
  position: relative;
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 44px;
  width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
  backdrop-filter: blur(12px);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--gold-grad);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-gold);
}

.login-logo h1 {
  font-family: 'Manrope', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .02em;
}

.login-logo p {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 6px;
  font-weight: 400;
  letter-spacing: .04em;
}

/* ===== LAYOUT ===== */
#app { display: none; flex-direction: column; min-height: 100vh; }

/* ===== TOPBAR ===== */
.topbar {
  background: linear-gradient(120deg, #0A6E60 0%, #075E54 100%);
  position: sticky;
  top: 0;
  width: 100%;
  height: 62px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 28px;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.14);
}

.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
}

.topbar > * { position: relative; z-index: 1; }

.topbar-logo {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  letter-spacing: .04em;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.topbar-logo { perspective: 800px; }
.topbar-logo-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transform-style: preserve-3d;
  animation: logoSpin 4.5s var(--ease-in-out) infinite;
}
@keyframes logoSpin {
  0%, 60% { transform: rotateY(0deg); }
  100%    { transform: rotateY(360deg); }
}
.topbar-logo-icon { font-size: 20px; display: inline-block; }
.topbar-logo-text { display: flex; flex-direction: column; line-height: 1.05; text-align: left; }
.topbar-logo-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.01em;
}
.topbar-logo-sub {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: .12em;
  color: rgba(255,255,255,.6);
  text-shadow: none;
  margin-top: 2px;
}

.topbar-nav { display: flex; gap: 4px; flex: 1; }

.topbar-nav a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: color 150ms var(--ease-out), background 150ms var(--ease-out);
  cursor: pointer;
  letter-spacing: .02em;
}

.topbar-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.14);
}

.topbar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,.20);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.topbar-user span {
  color: rgba(255,255,255,.8);
  font-size: 13px;
  font-weight: 500;
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

/* ===== BOT SIDEBAR ===== */
.bot-sidebar {
  position: sticky;
  top: 62px;
  height: calc(100vh - 62px);
  width: 230px;
  background: var(--sidebar);
  border-right: 1px solid var(--border-light);
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
  overflow-y: auto;
  box-shadow: 2px 0 16px rgba(44,36,22,.04);
}

.bot-sidebar-title {
  padding: 8px 14px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .10em;
  color: var(--text-3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.bot-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: color 150ms var(--ease-out), background 150ms var(--ease-out);
  cursor: pointer;
  letter-spacing: .01em;
}

.bot-sidebar a:hover {
  background: var(--primary-light);
  color: var(--text);
}

.bot-sidebar a.active {
  background: rgba(51, 65, 85, 0.07);
  color: #1E293B;
  font-weight: 600;
  border-left: 3px solid #475569;
}

.bot-sidebar a:hover {
  background: rgba(51, 65, 85, 0.05);
  color: var(--text);
}

.bot-sidebar a .nav-icon { width: 18px; text-align: center; }

.bot-sidebar a .nav-icon i {
  color: #94A3B8;
  font-size: 17px;
  transition: transform 150ms var(--ease-out), color 150ms var(--ease-out);
  display: block;
}
.bot-sidebar a:hover .nav-icon i {
  transform: scale(1.15);
  color: #475569;
}
.bot-sidebar a.active .nav-icon i {
  color: #334155;
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 36px 40px;
  background: transparent;
}

.content.full { padding: 0; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.page-header h2 {
  font-family: 'Manrope', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .01em;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 10px;
  letter-spacing: .03em;
}

.breadcrumb a {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}

.breadcrumb a:hover { opacity: .75; }
.breadcrumb span { color: var(--text-3); }

/* ===== BOTS GRID ===== */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
}

/* Stagger entrance for bot cards */
.bots-grid > * {
  animation: cardIn 0.3s var(--ease-out) both;
}
.bots-grid > *:nth-child(1) { animation-delay: 0ms; }
.bots-grid > *:nth-child(2) { animation-delay: 50ms; }
.bots-grid > *:nth-child(3) { animation-delay: 100ms; }
.bots-grid > *:nth-child(4) { animation-delay: 150ms; }
.bots-grid > *:nth-child(5) { animation-delay: 200ms; }
.bots-grid > *:nth-child(6) { animation-delay: 250ms; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bot-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-bottom: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 26px;
  cursor: pointer;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.bot-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-gold);
  border-color: var(--primary);
  border-bottom-width: 3px;
}

.bot-card:active {
  transform: translateY(-2px) scale(0.99);
}

.bot-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.bot-card-id { flex: 1; min-width: 0; }
.bot-card-phone {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.bot-avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(140deg, #25D366 0%, #00A884 55%, #008069 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  letter-spacing: -.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.30), 0 4px 14px rgba(0,128,105,.30);
  flex-shrink: 0;
  overflow: hidden;
}

.wa-image-bubble { padding: 4px !important; }
.wa-chat-img { max-width: 240px; max-height: 280px; border-radius: 10px; cursor: pointer; display: block; object-fit: cover; }
.wa-img-caption { font-size: 13px; padding: 5px 6px 2px; color: var(--text); white-space: pre-wrap; }

/* NFgroup integration — карточки ботов */
.nf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 4px; }
.nf-bot-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 16px 14px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.nf-bot-card.on { border-color: var(--primary); box-shadow: 0 4px 18px rgba(0,168,132,.13); }
.nf-bot-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.nf-bot-name { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); }
.nf-bot-name i { color: var(--primary); font-size: 19px; }
.nf-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: none; border: none; padding: 0; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.nf-toggle.on { color: var(--success); }
.nf-toggle-track { width: 40px; height: 23px; border-radius: 12px; background: #D3D7DD; position: relative; transition: background .2s; flex-shrink: 0; }
.nf-toggle.on .nf-toggle-track { background: var(--primary); }
.nf-toggle-thumb { position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28); transition: left .2s; }
.nf-toggle.on .nf-toggle-thumb { left: 18px; }
.nf-field { margin-bottom: 11px; }
.nf-label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 600; }
.nf-label i { font-size: 14px; color: var(--text-3); }
.nf-bot-card .nf-field input { width: 100%; background: var(--input-bg); }
.nf-chip { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: var(--primary-light); color: var(--success); }
.nf-bot-foot { display: flex; align-items: center; gap: 10px; margin-top: 13px; }

.msg-deleted .msg-bubble, .msg-deleted .wa-audio-bubble { background: #FDECEA !important; border: 1px solid #E57373; }
.msg-deleted .msg-bubble { color: #C0392B; }
.msg-deleted-badge { font-size: 10.5px; font-weight: 700; color: #fff; background: #C0392B; padding: 1px 7px; border-radius: 10px; margin-left: 6px; }
.dialog-deleted-flag { font-size: 12px; margin-right: 2px; }
.dialog-has-deleted { border-left: 3px solid #C0392B; }

.wa-trans-wrap { margin-top: 3px; }
.wa-text-btn { background: none; border: none; color: var(--primary); font-size: 11px; font-weight: 600; cursor: pointer; padding: 1px 2px; }
.wa-text-btn:hover { text-decoration: underline; }
.wa-transcript { font-size: 13px; color: var(--text); background: var(--input-bg); border: 1px solid var(--border-light); border-radius: 8px; padding: 8px 11px; margin-top: 4px; line-height: 1.5; max-width: 440px; white-space: pre-wrap; }

.stat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.stat-table th, .stat-table td { padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--border-light); }
.stat-table th { background: var(--input-bg); font-weight: 600; color: var(--text-2); font-size: 12.5px; }
.stat-table td.l, .stat-table th.l { text-align: left; }

.bot-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-3);
  align-self: flex-start;
  flex-shrink: 0;
}

.bot-status-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px rgba(74,124,89,.5);
}

.bot-status-dot.connecting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.bot-status-dot.paused { background: var(--warning); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

.bot-card h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-card p { color: var(--text-2); font-size: 12px; }

.bot-card-meta {
  display: flex;
  gap: 18px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.bot-card-meta-item { font-size: 12px; color: var(--text-2); }

.bot-card-meta-item strong {
  color: var(--text);
  font-size: 22px;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  letter-spacing: -.02em;
  display: block;
}

.add-bot-card {
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 170px;
  transition: transform 200ms var(--ease-out), border-color 200ms var(--ease-out), color 150ms var(--ease-out), background 150ms var(--ease-out);
  color: var(--text-3);
}

.add-bot-card:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.add-bot-card .add-icon { font-size: 34px; }
.add-bot-card span { font-size: 14px; font-weight: 500; letter-spacing: .02em; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 22px; }

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.form-group .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 16px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: all .2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201,162,39,.12);
  background: #fff;
}

textarea { resize: vertical; min-height: 120px; }
select option { background: #fff; color: var(--text); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out), filter 160ms var(--ease-out), background 150ms var(--ease-out), border-color 150ms var(--ease-out), color 150ms var(--ease-out);
  border: none;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  letter-spacing: .03em;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--btn-grad);
  color: #fff;
  box-shadow: 0 4px 16px rgba(26,86,219,.22);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(26,86,219,.30);
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--card);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(176,58,46,.4);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-ai-on {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.35);
  display: flex; align-items: center; gap: 6px;
}
.btn-ai-on:hover { background: rgba(34, 197, 94, 0.2); }
.btn-ai-off {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
  display: flex; align-items: center; gap: 6px;
}
.btn-ai-off:hover { background: rgba(239, 68, 68, 0.18); }
.ai-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: currentColor;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-active   { background: rgba(74,124,89,.12);  color: var(--success); }
.badge-inactive { background: rgba(176,168,152,.15); color: var(--text-3); }
.badge-connecting { background: rgba(196,130,26,.12); color: var(--warning); }
.badge-paused   { background: rgba(196,130,26,.12);  color: var(--warning); }

/* ===== WIZARD ===== */
.wizard-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  border: 1px solid transparent;
  letter-spacing: .02em;
}

.wizard-step.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(201,162,39,.4);
}

.wizard-step.done { color: var(--success); }

.wizard-step .step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.wizard-step.active .step-num {
  background: var(--gold-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(201,162,39,.3);
}

.wizard-step.done .step-num { background: var(--success); color: #fff; }

/* ===== CARD ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  letter-spacing: .01em;
}

/* ===== SCENARIO STEPS ===== */
.steps-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }

.step-item {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color .2s;
}

.step-item:hover { border-color: rgba(201,162,39,.4); }

.step-item .step-num-badge {
  min-width: 28px;
  height: 28px;
  background: var(--gold-grad);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(201,162,39,.25);
}

.step-item textarea {
  flex: 1;
  min-height: 60px;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
}

.step-item textarea:focus { border: none; outline: none; }

.step-actions { display: flex; gap: 6px; align-items: flex-start; }
.step-del { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; padding: 2px 4px; transition: color .15s; }
.step-del:hover { color: var(--danger); }

/* ===== DIALOGS ===== */
.dialogs-layout {
  display: flex;
  height: calc(100vh - 62px);
  overflow: hidden;
}

.dialogs-list {
  width: 310px;
  background: var(--sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.dialogs-resizer {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  margin: 0 -3px;
  z-index: 5;
  position: relative;
  transition: background 120ms var(--ease-out);
}
.dialogs-resizer:hover,
.dialogs-resizer.dragging {
  background: rgba(26,86,219,.18);
}

.dialogs-list-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border-light);
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.dialogs-scroll { flex: 1; overflow-y: auto; }

.dialog-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 120ms var(--ease-out);
  position: relative;
}
.dialog-item:hover { background: rgba(15,23,42,.035); }
.dialog-item.active {
  background: rgba(26,86,219,.06);
  border-left: 3px solid var(--primary);
}
.dialog-item.dialog-unread { background: rgba(52,183,241,.06); }
.dialog-item.dialog-unread:hover { background: rgba(52,183,241,.10); }

.dialog-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 6px;
}
.dialog-item-name-wrap { display: flex; align-items: center; min-width: 0; flex: 1; }
.dialog-item-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialog-item-name.unread { font-weight: 700; }
.dialog-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.dialog-item-time { font-size: 11px; color: var(--text-3); }
.dialog-unread-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--unread);
  flex-shrink: 0;
}
.dialog-item-preview {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 7px;
  line-height: 1.5;
}
.dialog-item-preview.unread { color: var(--text); font-weight: 500; }

/* Теги в строку */
.dialog-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.dtag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.dtag-wa {
  background: rgba(37,211,102,.12);
  color: #16a34a;
}
.dtag-ig {
  background: rgba(131,58,180,.1);
  color: #7c3aed;
}
.dtag-converted {
  background: rgba(22,163,74,.1);
  color: #15803d;
}
.dtag-not-converted {
  background: rgba(220,38,38,.08);
  color: #dc2626;
}
.dtag-active {
  background: rgba(22,163,74,.1);
  color: #15803d;
}
.dtag-ai-on {
  background: rgba(26,86,219,.08);
  color: var(--primary);
}
.dtag-ai-off {
  background: rgba(148,163,184,.15);
  color: #64748b;
}

/* legacy — оставляем для совместимости */
.dialog-status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 20px; padding: 2px 8px;
  font-size: 11px; font-weight: 500; white-space: nowrap; flex-shrink: 0;
}
.dialog-status-badge .badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.badge-converted { background: #ECFDF5; color: #065F46; }
.badge-converted .badge-dot { background: #10B981; }
.badge-in-progress { background: #FFFBEB; color: #92400E; }
.badge-in-progress .badge-dot { background: #F59E0B; }

.dialog-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: transparent; }

.chat-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.chat-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.chat-header p { font-size: 12px; color: var(--text-2); }

.chat-messages { flex: 1; overflow-y: auto; padding: 28px 28px 32px; display: flex; flex-direction: column; gap: 22px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 14px; }

.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 76%;
  align-self: flex-start;
  animation: msgIn .28s var(--ease-out);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  font-family: 'Manrope', sans-serif;
  box-shadow: var(--shadow-sm);
  user-select: none;
}
.msg.client   .msg-avatar { background: linear-gradient(135deg, #94A3B8, #64748B); }
.msg.bot      .msg-avatar { background: var(--btn-grad); }
.msg.operator .msg-avatar { background: var(--gold-grad); color: #4A3608; }

.msg-content { min-width: 0; display: flex; flex-direction: column; }

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  padding-left: 2px;
}
.msg-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.msg.bot      .msg-author { color: var(--primary); }
.msg.operator .msg-author { color: var(--warning); }
.msg-time {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ===== WA AUDIO PLAYER ===== */
.wa-audio-bubble {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px !important;
  min-width: 220px;
}
.wa-play-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 160ms var(--ease-out), filter 160ms;
}
.wa-play-btn:hover { filter: brightness(1.1); }
.wa-play-btn:active { transform: scale(0.93); }
.wa-audio-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wa-waveform {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  cursor: pointer;
}
.wa-bar {
  display: inline-block;
  width: 3px;
  border-radius: 2px;
  background: rgba(0,0,0,0.25);
  transition: background 0.15s;
  flex-shrink: 0;
}
.msg.client .wa-bar { background: rgba(100,116,139,0.35); }
.msg.bot .wa-bar { background: rgba(26,86,219,0.35); }
.msg.operator .wa-bar { background: rgba(201,162,39,0.45); }
.wa-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  pointer-events: none;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(26,86,219,0.15), transparent);
  transition: width 0.1s linear;
}
.wa-duration {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.msg-bubble {
  padding: 11px 15px;
  border-radius: 4px 16px 16px 16px;
  font-size: 14px;
  line-height: 1.55;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  word-break: break-word;
  white-space: pre-wrap;
  width: fit-content;
  max-width: 100%;
  transition: box-shadow 160ms var(--ease-out);
}
.msg-bubble + .msg-bubble { margin-top: 5px; border-radius: 16px; }
.msg-bubble:hover { box-shadow: var(--shadow-sm); }

.msg.client .msg-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg.bot .msg-bubble {
  background: linear-gradient(135deg, rgba(26,86,219,.07), rgba(26,86,219,.035));
  border: 1px solid rgba(26,86,219,.16);
}
.msg.operator .msg-bubble {
  background: linear-gradient(135deg, rgba(212,175,55,.14), rgba(201,162,39,.07));
  border: 1px solid rgba(201,162,39,.30);
}

.chat-input-area {
  padding: 16px 22px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
  background: var(--card);
}

.chat-input-area textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: 10px 14px; }
.chat-input { flex: 1; padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 22px; font-size: 14px; font-family: inherit; background: var(--bg); outline: none; transition: border-color .15s; }
.chat-input:focus { border-color: var(--primary); }

/* ===== SUPPORT CHAT ===== */
.support-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.support-inner {
  max-width: 860px;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 40px 14px;
  flex-shrink: 0;
}
.support-header h2 { font-size: 20px; font-weight: 700; color: var(--text); margin: 0; }
.support-layout .chat-messages { padding: 12px 40px 8px; }
.support-layout .msg-bubble { font-size: 14px; padding: 10px 14px; }
.support-input-area { padding: 10px 40px 16px; border-top: 1px solid var(--border-light); background: var(--bg); flex-shrink: 0; }
.support-input-area .chat-input { padding: 8px 14px; font-size: 14px; }
.support-input-area .btn { padding: 8px 16px; }
.support-msg-body p { margin: 0 0 8px; }
.support-msg-body p:last-child { margin-bottom: 0; }
.support-msg-body ul, .support-msg-body ol { margin: 6px 0 8px; padding-left: 20px; }
.support-msg-body li { margin-bottom: 3px; }
.support-msg-body strong { font-weight: 600; }
.support-msg-body code { background: rgba(0,0,0,0.07); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; font-family: monospace; }
.support-msg-body h1, .support-msg-body h2, .support-msg-body h3 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; }
.support-typing-dots { display: flex; gap: 4px; align-items: center; padding: 4px 2px !important; }
.support-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.support-typing-dots span:nth-child(2) { animation-delay: .2s; }
.support-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

/* ===== TESTING CHAT ===== */
.testing-layout { max-width: 740px; margin: 0 auto; }

.test-chat {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.test-chat-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(201,162,39,.06), transparent);
}

.test-chat-header h3 {
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  color: var(--text);
}

.test-messages { height: 420px; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: transparent; }
.test-input { padding: 16px 22px; border-top: 1px solid var(--border-light); display: flex; gap: 12px; }
.test-input textarea { flex: 1; min-height: 44px; max-height: 100px; resize: none; }

/* ===== QR CODE ===== */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 36px;
}

.qr-image-wrap {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: inline-block;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-md);
}

.qr-image-wrap img { display: block; width: 240px; height: 240px; }

.qr-placeholder {
  width: 240px;
  height: 240px;
  background: var(--input-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: var(--text-3);
}

/* ===== CONNECT PAGE — iPhone Frame ===== */
.ci-wrap { padding:0 0 48px; }
.ci-layout { display:flex; gap:48px; align-items:flex-start; }
.ci-left { display:flex; flex-direction:column; gap:16px; flex-shrink:0; }
.ci-right { flex:1; min-width:0; padding-top:60px; }
.ci-info-panel { display:none; }
.ci-info-panel.active { display:block; }
.ci-info-title { font-size:22px; font-weight:700; color:var(--text); margin-bottom:12px; letter-spacing:-0.3px; }
.ci-info-desc { font-size:14px; color:var(--text-2); line-height:1.65; margin-bottom:28px; }
.ci-steps { display:flex; flex-direction:column; gap:18px; margin-bottom:28px; }
.ci-step { display:flex; gap:14px; align-items:flex-start; }
.ci-step-num { width:30px; height:30px; border-radius:50%; background:var(--primary); color:#fff; font-size:13px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; margin-top:1px; }
.ci-step-body { flex:1; }
.ci-step-title { font-size:14px; font-weight:600; color:var(--text); margin-bottom:3px; }
.ci-step-text { font-size:13px; color:var(--text-2); line-height:1.55; }
.ci-info-note { background:var(--primary-light); border:1px solid rgba(201,168,76,0.25); border-radius:10px; padding:12px 16px; font-size:13px; color:var(--text-2); line-height:1.6; }
.ci-info-note b { color:var(--primary-dark); }
.ci-tabs { display:flex; gap:12px; margin-bottom:0; }
.ci-tab { display:inline-flex; align-items:center; flex-direction:column; gap:8px; padding:16px 28px; border-radius:16px; border:2px solid var(--border); background:var(--card); cursor:pointer; font-size:12px; font-weight:600; color:var(--text-2); transition:all 0.18s; font-family:inherit; line-height:1; }
.ci-tab svg { flex-shrink:0; transition:transform 0.18s; }
.ci-tab:hover svg { transform:scale(1.08); }
.ci-tab-wa.active { background:rgba(37,211,102,0.06); border-color:#25D366; color:#1a9e52; box-shadow:0 4px 16px rgba(37,211,102,0.18); }
.ci-tab-ig.active { background:rgba(131,58,180,0.06); border-color:#833AB4; color:#833AB4; box-shadow:0 4px 16px rgba(131,58,180,0.18); }
.ci-tab-wa:hover:not(.active) { border-color:#25D366; }
.ci-tab-ig:hover:not(.active) { border-color:#833AB4; }
.ci-frame { width:300px; height:560px; background:#1c1c1e; border-radius:52px; overflow:hidden; display:flex; flex-direction:column; box-shadow:0 0 0 1px #3a3a3c, 0 0 0 3.5px #1c1c1e, 0 32px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.07); flex-shrink:0; }
.ci-notch { height:34px; background:#1c1c1e; display:flex; align-items:center; justify-content:center; gap:10px; flex-shrink:0; }
.ci-speaker { width:58px; height:5px; background:#3a3a3c; border-radius:3px; }
.ci-camera { width:10px; height:10px; background:#2c2c2e; border-radius:50%; border:1.5px solid #3a3a3c; }
.ci-screen { flex:1; min-height:0; position:relative; overflow:hidden; }
.ci-home { height:24px; background:#1c1c1e; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.ci-home-bar { width:100px; height:4px; background:rgba(255,255,255,0.28); border-radius:3px; }
/* WhatsApp screen */
.ci-wa-screen { position:absolute; inset:0; background:#f0f2f5; display:flex; flex-direction:column; }
.ci-wa-hdr { background:#075E54; padding:10px 14px; display:flex; align-items:center; gap:10px; flex-shrink:0; }
.ci-wa-avatar { width:34px; height:34px; border-radius:50%; background:#128C7E; display:flex; align-items:center; justify-content:center; font-size:15px; flex-shrink:0; }
.ci-wa-name { font-size:14px; font-weight:600; color:#fff; font-family:-apple-system,sans-serif; line-height:1.2; }
.ci-wa-sub { font-size:11px; color:rgba(255,255,255,0.75); font-family:-apple-system,sans-serif; }
.ci-wa-body { flex:1; min-height:0; overflow-y:auto; padding:14px 12px; display:flex; flex-direction:column; align-items:center; gap:10px; scrollbar-width:none; }
.ci-wa-body::-webkit-scrollbar { display:none; }
.ci-frame .qr-container { padding:10px; gap:8px; }
.ci-frame .qr-image-wrap { padding:8px; }
.ci-frame .qr-image-wrap img { width:184px; height:184px; }
.ci-frame .qr-placeholder { width:184px; height:184px; }
.ci-btn { display:inline-flex; align-items:center; justify-content:center; padding:9px 22px; border-radius:22px; border:none; font-size:13px; font-weight:500; cursor:pointer; transition:all 0.18s; font-family:inherit; }
.ci-btn-wa { background:#25D366; color:#fff; }
.ci-btn-wa:hover { background:#1da952; }
.ci-btn-wa:disabled { opacity:0.6; cursor:not-allowed; }
.ci-btn-danger { background:rgba(220,38,38,.1); color:#dc2626; border:1px solid rgba(220,38,38,.22); }
.ci-btn-danger:hover { background:rgba(220,38,38,.18); }
.ci-instruction { width:100%; background:rgba(255,255,255,0.75); border-radius:10px; padding:10px 12px; font-size:11.5px; line-height:1.75; color:#444; font-family:-apple-system,sans-serif; }
.ci-instruction b { color:#111; font-weight:600; display:block; margin-bottom:3px; }
/* Instagram screen */
.ci-ig-screen { position:absolute; inset:0; background:#fafafa; display:flex; flex-direction:column; overflow-y:auto; scrollbar-width:none; }
.ci-ig-screen::-webkit-scrollbar { display:none; }
.ci-ig-hdr { background:linear-gradient(135deg,#833ab4 0%,#fd1d1d 50%,#fcb045 100%); padding:20px 16px 14px; text-align:center; flex-shrink:0; }
.ci-ig-hdr-logo { font-size:19px; font-weight:700; color:#fff; font-family:-apple-system,sans-serif; letter-spacing:-0.3px; }
.ci-ig-hdr-sub { font-size:11px; color:rgba(255,255,255,0.8); margin-top:2px; font-family:-apple-system,sans-serif; }
.ci-ig-body { flex:1; padding:12px 14px; display:flex; flex-direction:column; gap:10px; }
.ci-warning { background:#fffbeb; border:1px solid #fcd34d; border-radius:10px; padding:10px 12px; font-size:11px; line-height:1.65; color:#78350f; font-family:-apple-system,sans-serif; }
.ci-warning-title { font-weight:700; margin-bottom:5px; display:flex; align-items:center; gap:5px; font-size:11.5px; }
.ci-ig-input { width:100%; padding:9px 12px; border:1.5px solid #dbdbdb; border-radius:8px; font-size:13px; background:#fff; outline:none; font-family:-apple-system,sans-serif; transition:border-color 0.15s; box-sizing:border-box; }
.ci-ig-input:focus { border-color:#833ab4; }
.ci-ig-btn { width:100%; padding:10px; border-radius:8px; border:none; background:linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045); color:#fff; font-size:14px; font-weight:600; cursor:pointer; font-family:-apple-system,sans-serif; transition:opacity 0.18s; }
.ci-ig-btn:hover { opacity:0.88; }
.ci-ig-btn:disabled { opacity:0.55; cursor:not-allowed; }

/* ===== ANALYTICS ===== */
.analytics-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:60px 20px; text-align:center; color:var(--text-2); font-size:14px; }
.analytics-date { font-size:12px; color:var(--text-3); }
.analytics-card-quote { font-size:13px; color:var(--text-2); background:var(--bg); border-left:3px solid var(--border); border-radius:0 6px 6px 0; padding:10px 14px; font-style:italic; line-height:1.55; word-break:break-word; overflow-wrap:break-word; }
.analytics-card-prompt { font-size:13px; color:var(--text-2); background:rgba(201,168,76,.08); border:1px solid rgba(201,168,76,.2); border-radius:8px; padding:10px 14px; line-height:1.55; word-break:break-word; overflow-wrap:break-word; }
/* Metric cards */
.an-metrics-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:20px; }
.an-metric { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; }
.an-metric-loading { height:88px; background:var(--bg); animation:pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:1} }
.an-metric-label { font-size:12px; color:var(--text-3); font-weight:500; margin-bottom:8px; }
.an-metric-val { font-size:30px; font-weight:700; color:var(--text); line-height:1; margin-bottom:6px; }
.an-diff-up { font-size:12px; color:var(--success); font-weight:500; }
.an-diff-down { font-size:12px; color:var(--danger); font-weight:500; }
.an-diff-neutral { font-size:12px; color:var(--text-3); }
/* Chart */
.an-chart-card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:20px 24px; margin-bottom:20px; }
.an-chart-title { font-size:14px; font-weight:600; color:var(--text); margin-bottom:16px; }
.an-chart-wrap { height:220px; position:relative; }
/* Section header */
.an-section-header { display:flex; align-items:center; justify-content:space-between; }
.an-section-title { font-size:15px; font-weight:600; color:var(--text); display:flex; align-items:center; gap:8px; }
/* Problem cards */
.an-cards { display:flex; flex-direction:column; gap:12px; }
.an-card { background:var(--card); border:1px solid var(--border); border-radius:var(--radius); padding:18px 20px; }
.an-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.an-card-problem { font-size:15px; font-weight:600; color:var(--text); flex:1; min-width:0; word-break:break-word; overflow-wrap:break-word; }
.an-card-badges { display:flex; gap:6px; flex-wrap:wrap; flex-shrink:0; }
.an-badge { font-size:11px; font-weight:600; padding:3px 8px; border-radius:6px; border:1px solid; white-space:nowrap; }
.an-badge-freq { background:rgba(201,168,76,.1); color:var(--primary); border-color:rgba(201,168,76,.25); }
.an-card-section { margin-bottom:12px; }
.an-card-section:last-child { margin-bottom:0; }
.an-card-label { font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); margin-bottom:5px; }
.an-card-text { font-size:14px; color:var(--text-2); line-height:1.6; word-break:break-word; overflow-wrap:break-word; }

/* Technical bug badge in analytics cards */
.an-tech-badge {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 8px 12px;
  color: #991B1B;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}

/* Analysis period pills */
.an-period-pills {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px;
}
.an-period-pill {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.an-period-pill:hover { color: var(--text); }
.an-period-pill.active { background: var(--primary); color: #fff; }

/* Final correction block */
.an-correction-card {
  background: var(--card);
  border: 2px solid #C9A84C;
  border-radius: var(--radius);
  padding: 22px 26px;
}
.an-correction-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.an-correction-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
  margin-bottom: 12px;
}
.an-correction-textarea {
  width: 100%;
  min-height: 160px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
}
.an-correction-textarea:focus { border-color: var(--primary); }
.an-correction-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.an-correction-status { font-size: 13px; font-weight: 500; margin-left: 2px; }

/* ===== SIDEBAR TOOLTIPS ===== */
.nav-tooltip {
  position: fixed;
  background: #1a1a1a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 400;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 220px;
  line-height: 1.45;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 150ms ease;
  white-space: normal;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.nav-tooltip.visible { opacity: 1; }

/* ===== CORRECTIONS ===== */
.correction-template {
  background: rgba(201,162,39,.06);
  border: 1px solid rgba(201,162,39,.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
}

/* ===== SETTINGS ===== */

.role-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.role-type-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  text-align: center;
  transition: border-color .15s, background .15s, color .15s;
  line-height: 1.3;
}

.role-type-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.role-type-btn.active {
  border: 2px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

@media (max-width: 600px) {
  .role-type-grid { grid-template-columns: repeat(2, 1fr); }
}

.pause-options { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.pause-option {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
  background: none;
  color: var(--text-2);
  font-family: 'Inter', sans-serif;
  letter-spacing: .02em;
}

.pause-option:hover, .pause-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== ALERTS ===== */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}

.alert-error   { background: rgba(176,58,46,.08);  border: 1px solid rgba(176,58,46,.25);  color: #922B21; }
.alert-success { background: rgba(74,124,89,.08);  border: 1px solid rgba(74,124,89,.25);  color: #1E6B3A; }
.alert-info    { background: rgba(201,162,39,.08); border: 1px solid rgba(201,162,39,.25); color: #8B6914; }

/* ===== RADIO ===== */
.radio-group { display: flex; gap: 10px; flex-wrap: wrap; }

.radio-option {
  flex: 1;
  min-width: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .2s;
  background: var(--card);
}

.radio-option:hover { border-color: rgba(201,162,39,.5); }

.radio-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-option input { display: none; }
.radio-option-label { font-weight: 600; font-size: 13px; margin-bottom: 2px; color: var(--text); }
.radio-option-desc  { font-size: 12px; color: var(--text-2); }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  color: var(--text-3);
  text-align: center;
  gap: 14px;
}

.empty-state .empty-icon { font-size: 52px; opacity: .6; }
.empty-state h3 { font-family: 'Manrope', sans-serif; font-size: 17px; color: var(--text-2); }
.empty-state p  { font-size: 13px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,15,8,.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 32px 80px rgba(0,0,0,.18);
  animation: slideUp .22s var(--ease-out);
}

@keyframes slideUp {
  from { transform: translateY(12px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }

.modal-header h3 {
  font-family: 'Manrope', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.modal-close { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 22px; transition: color .15s; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 26px; }

/* ===== STATS PERIOD FILTER ===== */
.stats-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  position: relative;
}
.stats-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stats-pill {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
}
.stats-pill:hover { border-color: var(--primary); color: var(--primary); }
.stats-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.stats-pill-calendar { margin-left: 6px; }

/* Flatpickr custom theme */
.flatpickr-calendar {
  font-family: 'Inter', sans-serif !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 32px rgba(44,36,22,.14) !important;
  border: 1px solid var(--border) !important;
}
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
  background: #1A56DB !important;
  border-color: #1A56DB !important;
  color: #fff !important;
}
.flatpickr-day.inRange {
  background: rgba(26,86,219,.10) !important;
  border-color: transparent !important;
  box-shadow: -5px 0 0 rgba(26,86,219,.10), 5px 0 0 rgba(26,86,219,.10) !important;
  color: var(--text) !important;
}
.flatpickr-day.today { border-color: #1A56DB !important; }
.flatpickr-day:hover:not(.selected):not(.startRange):not(.endRange) {
  background: rgba(26,86,219,.07) !important;
  border-color: transparent !important;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: #1A56DB !important; }
.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month input.cur-year:hover { background: rgba(26,86,219,.07) !important; }

/* ===== ACTIVE STATES — press feedback ===== */
.role-type-btn:active  { transform: scale(0.97); }
.pause-option:active   { transform: scale(0.97); }
.stats-pill:active     { transform: scale(0.97); }
.an-period-pill:active { transform: scale(0.97); }
.add-bot-card:active   { transform: scale(0.98); }
.ci-tab:active         { transform: scale(0.97); }
.dialog-item:active    { background: var(--primary-light); }

/* ===== PREFERS REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .content { padding: 20px 18px; }
  .bots-grid { grid-template-columns: 1fr; }
  .dialogs-list { width: 100% !important; }
  .dialogs-resizer { display: none; }
  .bot-sidebar { position: static; width: 100%; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; }
  .main-layout { flex-direction: column; }
  .login-card { width: 92%; padding: 36px 28px; }
}
