/* WhatsApp Bot Platform - Main Stylesheet */
:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --secondary: #34B7F1;
  --dark: #1a1a2e;
  --darker: #16213e;
  --light: #f8f9fa;
  --gray: #6c757d;
  --danger: #dc3545;
  --warning: #ffc107;
  --success: #28a745;
  --sidebar-width: 260px;
  --border-radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);

  /* Professor Tech brand palette, from the Mega-Mind logo — used for the
     platform's own chrome (sidebar, brand gradient, primary CTAs). WhatsApp
     green stays reserved for "connected/active" bot-status indicators only,
     so the two meanings never visually collide. */
  --brand-navy: #0d0a1f;
  --brand-purple: #7c3aed;
  --brand-purple-light: #a78bfa;
  --brand-pink: #d946ef;
  --brand-cyan: #22d3ee;
  --brand-gradient: linear-gradient(135deg, var(--brand-purple) 0%, var(--brand-pink) 100%);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f0f2f5;
  color: var(--dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== AUTH PAGE ========== */
.auth-page {
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--dark) 50%, #241b3d 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-container { width: 100%; max-width: 420px; }

.auth-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 40px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  animation: slideUp 0.5s ease;
}

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

.auth-header { text-align: center; margin-bottom: 30px; }

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-purple);
  margin-bottom: 20px;
}

.logo i { font-size: 36px; }
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(217, 70, 239, 0.35), 0 0 16px rgba(124, 58, 237, 0.45);
}

.auth-header h1 { font-size: 24px; margin-bottom: 8px; color: var(--dark); }
.auth-header p { color: var(--gray); font-size: 15px; }

.auth-form { display: none; }
.auth-form.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--dark);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 15px;
  transition: all 0.2s;
  font-family: inherit;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--gray);
  font-size: 12px;
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  text-decoration: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(217, 70, 239, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--gray);
}

.btn-ghost:hover { background: #f8f9fa; color: var(--dark); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover { background: var(--primary); color: white; }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--gray);
}

.auth-switch a { 
  color: var(--primary); 
  text-decoration: none; 
  font-weight: 600;
  transition: opacity 0.2s;
}

.auth-switch a:hover { opacity: 0.8; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

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

.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.hidden { display: none !important; }

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--brand-navy) 0%, var(--dark) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header .logo { 
  margin-bottom: 0; 
  font-size: 18px; 
  color: white; 
}

.sidebar-header .logo i { color: var(--brand-purple-light); }

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  margin-bottom: 4px;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(217,70,239,0.08));
  color: var(--brand-purple-light);
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
}

.user-details {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}

.user-name { font-weight: 600; color: white; }
.user-plan {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 24px 32px;
  transition: margin-left 0.3s;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e9ecef;
}

.top-bar h2 { font-size: 24px; font-weight: 700; color: var(--dark); }

.top-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-bar-left h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Hamburger — hidden on desktop, shown in the top bar on phones */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  color: var(--dark);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.mobile-menu-btn:hover { background: #f3f4f6; border-color: #d1d5db; }
.mobile-menu-btn:active { transform: scale(0.95); }

/* Dimmed screen behind the open mobile menu */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.top-bar-actions { display: flex; gap: 12px; }

/* ========== PAGES ========== */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}

.stat-icon.blue { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-icon.green { background: linear-gradient(135deg, #11998e, #38ef7d); }
.stat-icon.purple { background: linear-gradient(135deg, #a855f7, #6366f1); }
.stat-icon.orange { background: linear-gradient(135deg, #f97316, #fbbf24); }
.stat-icon.red { background: linear-gradient(135deg, #ef4444, #f87171); }

.stat-info h3 { font-size: 28px; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-info p { color: var(--gray); font-size: 14px; margin-top: 4px; }

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* ========== CARDS ========== */
.card {
  background: white;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

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

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

.card-header h3 { font-size: 18px; font-weight: 600; color: var(--dark); }

.link { 
  color: var(--primary); 
  text-decoration: none; 
  font-size: 14px; 
  font-weight: 500;
  transition: opacity 0.2s;
}

.link:hover { opacity: 0.8; }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--gray);
}

.empty-state i { 
  font-size: 48px; 
  margin-bottom: 16px; 
  opacity: 0.4;
  color: var(--gray);
}

.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--dark); }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

.empty-state.full {
  grid-column: 1 / -1;
  padding: 80px 40px;
}

/* ========== QUICK ACTIONS ========== */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
}

.quick-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f0fdf4;
  transform: translateY(-2px);
}

.quick-action-btn i { font-size: 24px; }

/* ========== ACTIVITY LIST ========== */
.activity-list { max-height: 320px; overflow-y: auto; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--primary);
  flex-shrink: 0;
}

.activity-content { flex: 1; min-width: 0; }
.activity-content p { font-size: 14px; margin-bottom: 2px; color: var(--dark); }
.activity-content span { font-size: 12px; color: var(--gray); }

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

.bot-card {
  background: white;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  border: 2px solid transparent;
  transition: all 0.3s;
}

.bot-card:hover { 
  border-color: var(--primary); 
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.bot-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.bot-card h3 { font-size: 18px; font-weight: 600; color: var(--dark); }

.bot-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.bot-status.active { background: #d1fae5; color: #065f46; }
.bot-status.draft { background: #e0e7ff; color: #3730a3; }
.bot-status.paused { background: #fef3c7; color: #92400e; }
.bot-status.error { background: #fdecea; color: #b42318; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.bot-card > p { 
  color: var(--gray); 
  font-size: 14px; 
  margin-bottom: 16px;
  line-height: 1.5;
  min-height: 42px;
}

.bot-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--gray);
}

.bot-card-stats span { display: flex; align-items: center; gap: 6px; }

.bot-card-actions {
  display: flex;
  gap: 8px;
}

.bot-card-actions .btn { flex: 1; }

/* ========== BUILDER ========== */
.builder-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.builder-sidebar {
  background: white;
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.builder-sidebar h3 { 
  margin-bottom: 20px; 
  font-size: 16px; 
  font-weight: 600;
  color: var(--dark);
}

.step-types { display: flex; flex-direction: column; gap: 10px; }

.step-type {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  cursor: grab;
  transition: all 0.2s;
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: var(--dark);
}

.step-type:hover { 
  border-color: var(--primary); 
  background: #f0fdf4;
  transform: translateX(4px);
}

.step-type i { 
  color: var(--primary); 
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.builder-canvas {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  gap: 12px;
  align-items: center;
  background: #fafafa;
}

.builder-header select { 
  flex: 1; 
  padding: 10px 14px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.flow-canvas {
  flex: 1;
  padding: 24px;
  overflow: auto;
  background: #f8f9fa;
  background-image: 
    radial-gradient(#dee2e6 1.5px, transparent 1.5px);
  background-size: 24px 24px;
}

.flow-step {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  max-width: 400px;
  box-shadow: var(--shadow);
  position: relative;
}

.flow-step::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 16px;
  background: #e9ecef;
}

.flow-step:last-child::after { display: none; }

.flow-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}

.flow-step-header i { color: var(--primary); }

.flow-step-header .step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.flow-step-header .step-title { flex: 1; }

.flow-step-header .step-controls { display: flex; gap: 4px; }

.step-icon-btn {
  border: none;
  background: transparent;
  color: var(--gray);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.step-icon-btn:hover { background: #f0f2f5; color: var(--dark); }
.step-icon-btn.danger:hover { background: #fdecea; color: var(--danger); }

.flow-step-body { display: flex; flex-direction: column; gap: 12px; }

.flow-step-body .form-group { margin-bottom: 0; }
.flow-step-body label { font-size: 12px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 6px; display: block; }
.flow-step-body input,
.flow-step-body textarea,
.flow-step-body select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.flow-step-body textarea { min-height: 60px; resize: vertical; }

.step-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dark);
}
.step-checkbox-row input { width: auto; }

.interactive-buttons { display: flex; flex-direction: column; gap: 8px; }
.interactive-button-row { display: flex; gap: 8px; align-items: center; }
.interactive-button-row input { flex: 1; }

.flow-canvas-inner { display: flex; flex-direction: column; align-items: flex-start; }

.flow-canvas.drag-over { background-color: #f0fdf4; outline: 2px dashed var(--primary); outline-offset: -8px; }

.flow-trigger-bar {
  padding: 14px 20px;
  border-bottom: 1px solid #e9ecef;
  background: white;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.flow-trigger-bar label { font-size: 12px; font-weight: 600; color: var(--gray); }
.flow-trigger-bar select,
.flow-trigger-bar input {
  padding: 8px 12px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 13px;
}
.flow-trigger-bar input[type="text"] { flex: 1; min-width: 200px; }

.btn-danger {
  background: var(--danger);
  color: white;
  border: 2px solid var(--danger);
}
.btn-danger:hover { background: #c82333; border-color: #c82333; }

.danger-zone {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid #f3c2c5;
  background: #fdf5f5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.danger-zone h4 { font-size: 14px; color: var(--danger); margin-bottom: 4px; }
.danger-zone p { font-size: 12px; color: var(--gray); }
.danger-zone .btn { flex-shrink: 0; }

.optional-tag { font-weight: 400; color: var(--gray); font-size: 12px; text-transform: none; }

.tab-subtitle { font-size: 13px; color: var(--gray); margin-bottom: 16px; }

.modal-flow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 10px;
}
.modal-flow-item h4 { font-size: 14px; margin-bottom: 2px; }
.modal-flow-item p { font-size: 12px; color: var(--gray); }
.modal-flow-item .btn { flex-shrink: 0; }

/* ========== CONVERSATIONS ========== */
.conversations-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
}

.conversations-list {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.conversations-search {
  padding: 14px 16px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fafafa;
}

.conversations-search i { color: var(--gray); font-size: 14px; }

.conversations-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  font-family: inherit;
}

.conversations-items { flex: 1; overflow-y: auto; }

.conversation-item {
  padding: 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s;
}

.conversation-item:hover,
.conversation-item.active { 
  background: #f8f9fa; 
}

.conversation-item.active {
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

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

.conv-name { font-weight: 600; font-size: 14px; color: var(--dark); }
.conv-time { font-size: 12px; color: var(--gray); }
.conv-preview {
  font-size: 13px;
  color: var(--gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.chat-area {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  padding: 40px;
}

.chat-empty i { font-size: 56px; margin-bottom: 16px; opacity: 0.3; }

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.chat-header h4 { font-size: 16px; font-weight: 600; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f0f2f5;
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.message.inbound {
  align-self: flex-start;
  background: white;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.outbound {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

.chat-input {
  padding: 16px 20px;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 12px;
  background: white;
}

.chat-input input {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid #e9ecef;
  border-radius: 24px;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chat-input input:focus { border-color: var(--primary); }

/* ========== ANALYTICS ========== */
.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.analytics-grid .card.wide { grid-column: 1 / -1; }

.chart-container { 
  height: 320px; 
  position: relative;
  padding: 10px 0;
}

.chart-container.small { height: 220px; }

.top-bots-list { max-height: 300px; overflow-y: auto; }

.top-bot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.top-bot-item:last-child { border-bottom: none; }

.top-bot-rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
}

.top-bot-rank.top { 
  background: linear-gradient(135deg, #fbbf24, #f59e0b); 
  color: white; 
}

.top-bot-info { flex: 1; }
.top-bot-info h4 { font-size: 14px; font-weight: 600; }
.top-bot-info p { font-size: 12px; color: var(--gray); }
.top-bot-count { font-weight: 600; color: var(--primary); }

/* ========== SETTINGS ========== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 900px;
}

.settings-form .form-group { margin-bottom: 20px; }

.plan-info { text-align: center; padding: 10px 0; }

.plan-badge {
  display: inline-block;
  padding: 10px 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 24px;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
}

.plan-details { 
  text-align: left; 
  margin-bottom: 24px;
  background: #f8f9fa;
  padding: 16px;
  border-radius: 10px;
}

.plan-details p { 
  margin-bottom: 10px; 
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}

.plan-details p strong { color: var(--dark); }

.api-key-section p { margin-bottom: 16px; font-size: 14px; color: var(--gray); }

.api-key-display {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.api-key-display code {
  flex: 1;
  padding: 14px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
  border: 1px solid #e9ecef;
  font-family: 'SF Mono', monospace;
  display: flex;
  align-items: center;
}

/* ========== MODALS ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active { display: flex; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content.large { max-width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--gray);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close:hover { background: #f0f2f5; color: var(--dark); }

.modal-body { padding: 24px; }

.modal form { padding: 24px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e9ecef;
}

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid #e9ecef;
}

.tab-btn {
  padding: 12px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-family: inherit;
}

.tab-btn:hover { color: var(--dark); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

/* ========== WEBHOOK INFO ========== */
.webhook-info { padding: 10px 0; }

.webhook-instructions {
  margin-top: 24px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e9ecef;
}

.webhook-instructions h4 { 
  margin-bottom: 16px; 
  font-size: 15px;
  color: var(--dark);
}

.webhook-instructions ol {
  padding-left: 20px;
  font-size: 14px;
  line-height: 2.2;
  color: var(--gray);
}

.webhook-instructions li { margin-bottom: 4px; }

.webhook-instructions a { 
  color: var(--primary); 
  text-decoration: none;
  font-weight: 500;
}

.webhook-instructions a:hover { text-decoration: underline; }

.copy-field {
  display: flex;
  gap: 8px;
}

.copy-field input {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 13px;
  background: #f8f9fa;
  font-family: 'SF Mono', monospace;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 16px 20px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  pointer-events: auto;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { background: linear-gradient(135deg, #10b981, #059669); }
.toast.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }

@keyframes toastIn {
  from { transform: translateX(100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ========== LOADING ========== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  z-index: 3000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  backdrop-filter: blur(4px);
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e9ecef;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay p { color: var(--gray); font-size: 15px; }

/* ========== FORM SECTION ========== */
.form-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 2px solid #e9ecef;
}

.form-section h4 { 
  margin-bottom: 20px; 
  font-size: 16px;
  font-weight: 600;
  color: var(--dark);
}

/* ========== FLOWS LIST ========== */
.flows-list { margin-bottom: 20px; }

.flow-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  margin-bottom: 10px;
  transition: all 0.2s;
  cursor: pointer;
}

.flow-item:hover { border-color: var(--primary); background: #f0fdf4; }

.flow-item i { color: var(--primary); font-size: 18px; }
.flow-item-info { flex: 1; }
.flow-item-info h4 { font-size: 14px; font-weight: 600; }
.flow-item-info p { font-size: 12px; color: var(--gray); }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .analytics-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .sidebar-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr; }
  .bots-grid { grid-template-columns: 1fr; }
  .builder-container { grid-template-columns: 1fr; height: auto; }
  .conversations-layout { grid-template-columns: 1fr; height: auto; }
  .top-bar { gap: 12px; }
  .top-bar h2 { font-size: 19px; }
  .mobile-menu-btn { display: inline-flex; }
  .modal-content { max-width: 100%; }
}

/* ========== UTILITY ========== */
.text-center { text-align: center; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ==================== Deploy Page ==================== */
.deploy-section { margin-bottom: 32px; }
.section-heading { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: var(--dark); }
.section-subheading { font-size: 13px; color: var(--gray, #6b7280); margin: -8px 0 16px; }
.section-subheading a { color: var(--primary); font-weight: 600; }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.template-card {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.template-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.template-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.template-icon img,
.template-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.repo-pull-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.repo-pull-row input { flex: 1; }
.repo-pull-row .btn { white-space: nowrap; }

.template-files-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fafafa;
}
.template-file-row {
  font-size: 12px;
  color: var(--gray, #6b7280);
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: monospace;
}
.template-file-row i { color: #9ca3af; }

.new-bot-scratch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #e5e7eb);
}
.new-bot-scratch h4 { font-size: 15px; margin-bottom: 4px; }
.new-bot-scratch p { font-size: 13px; color: var(--gray, #6b7280); }

.template-logo-preview {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: #eef2ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid #e9ecef;
}

.template-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-upload-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.logo-upload-controls small { color: var(--gray); }

.admin-template-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
}

.template-card-header h4 { font-size: 14px; margin-bottom: 4px; }
.template-card p { font-size: 13px; color: var(--gray); flex: 1; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge-ready { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }

.deployments-list { display: flex; flex-direction: column; gap: 10px; }

.deployment-card {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.deployment-card-info h4 { font-size: 14px; margin-bottom: 4px; }
.deployment-card-info p { font-size: 12px; color: var(--gray); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.deployment-error { color: var(--danger) !important; margin-top: 4px; }

.deployment-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-state.full { grid-column: 1 / -1; text-align: center; padding: 40px 20px; color: var(--gray); }
.empty-state.full i { font-size: 28px; margin-bottom: 10px; opacity: 0.5; }

.logs-viewer {
  background: #0d1117;
  color: #c9d1d9;
  padding: 16px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==================== Admin Page ==================== */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

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

.table-wrap {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  overflow-x: auto;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left;
  padding: 12px 16px;
  background: #f8f9fb;
  color: var(--gray);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #e9ecef;
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover { background: #fafbfc; }

.admin-inline-select {
  padding: 6px 10px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  font-size: 12px;
  background: white;
  cursor: pointer;
}

/* ==================== Admin: Bot Template Catalog ==================== */
.env-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 100px 90px 32px;
  grid-template-rows: auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  margin-bottom: 8px;
}
.env-field-row input,
.env-field-row select {
  padding: 8px 10px;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  font-size: 12px;
}
.env-field-row .env-help { grid-column: 1 / -1; }
.env-required-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gray);
  white-space: nowrap;
}
.env-required-label input { width: auto; }

.session-link-box {
  background: #eef2ff;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.session-link-text {
  color: #3730a3;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}
.session-link-box .btn { flex-shrink: 0; white-space: nowrap; }

.deploy-modal-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border-bottom: 1px solid #eef0f3;
}
.deploy-modal-banner img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.deploy-modal-banner h4 { font-size: 16px; font-weight: 700; color: var(--dark); margin-bottom: 2px; }
.deploy-modal-banner p { font-size: 13px; color: var(--gray); }

/* ==================== Professional polish: buttons, tables, cards ==================== */
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-icon { padding: 8px 10px; }

.card, .bot-card, .template-card, .stat-card {
  border: 1px solid #edf0f3;
}

.admin-table thead { position: sticky; top: 0; z-index: 1; }
.admin-table tbody tr:nth-child(even) { background: #fbfbfd; }
.admin-table tbody tr:hover { background: #f3f6fa; }
.admin-table td, .admin-table th { border-bottom: 1px solid #eef1f4; }

.admin-section-header, .tab-subtitle { margin-bottom: 16px; }

/* ==================== Admin: a single user's bots ==================== */
.user-bots-section { margin-bottom: 28px; }
.user-bots-section:last-child { margin-bottom: 0; }
.user-bots-section h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 12px;
}
.user-bots-section h4 i { color: var(--primary); }

/* ==================== Logs panel — slides in from the right ==================== */
.logs-panel-modal { justify-content: flex-end; padding: 0; align-items: stretch; }

.logs-panel-modal .modal-overlay {
  background: rgba(10, 12, 18, 0.55);
}

.logs-panel-modal .modal-content.logs-panel {
  width: 100%;
  max-width: 620px;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: #0b0d12;
  color: #e5e7eb;
  animation: logsSlideIn 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -20px 0 60px -20px rgba(0, 0, 0, 0.6);
}

@keyframes logsSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.logs-panel-header {
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
}

.logs-panel-heading h3 { color: #fff; font-size: 16px; font-weight: 600; margin-bottom: 8px; }

.logs-panel-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logs-panel-actions .modal-close { color: #9ca3af; }
.logs-panel-actions .modal-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.logs-panel-actions .btn-icon { background: rgba(255, 255, 255, 0.06); color: #d1d5db; box-shadow: none; }
.logs-panel-actions .btn-icon:hover { background: rgba(255, 255, 255, 0.12); }

.logs-panel-error {
  margin: 14px 22px 0;
  padding: 10px 14px;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.35);
  color: #fca5a5;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.logs-viewer-wrap { flex: 1; min-height: 0; padding: 16px 22px; display: flex; }

.logs-viewer {
  flex: 1;
  overflow-y: auto;
  background: #05060a;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 16px 18px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line { padding: 1px 0; }
.log-ts { color: #565f75; margin-right: 8px; }
.log-line-err { color: #fca5a5; }
.log-line-err .log-ts { color: #a15c5c; }

.logs-panel-footer {
  padding: 14px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #8b93a7;
  flex-shrink: 0;
}

.logs-autoscroll-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.logs-autoscroll-toggle input { accent-color: var(--primary); cursor: pointer; }

@media (max-width: 640px) {
  .logs-panel-modal .modal-content.logs-panel { max-width: 100%; }
}

/* ==================== Wallet / Plans / Recovery ==================== */
.wallet-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.wallet-balance-card, .wallet-referral-card {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 14px;
  padding: 20px;
}

.wallet-balance-label, .wallet-referral-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--gray);
  font-weight: 600;
  margin-bottom: 8px;
}

.wallet-balance-value {
  font-size: 32px;
  font-weight: 800;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 14px;
}

.wallet-referral-code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--brand-purple);
  margin-bottom: 10px;
  font-family: 'Courier New', monospace;
}

.wallet-referral-earnings { margin-top: 10px; font-size: 13px; color: var(--gray); }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.plan-card {
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}

.plan-card:hover { border-color: var(--brand-purple-light); }

.plan-card.selected {
  border-color: var(--brand-purple);
  background: linear-gradient(135deg, rgba(124,58,237,0.06), rgba(217,70,239,0.04));
}

.plan-card .plan-label { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.plan-card .plan-cost { font-size: 12px; color: var(--gray); }

#deploy-wallet-note { display: block; margin-top: 8px; }
#deploy-wallet-note.insufficient { color: var(--danger); font-weight: 600; }

.plan-expiry-note { font-size: 12px; color: var(--gray); margin-top: 6px; }
.plan-expiry-note.expired { color: var(--danger); font-weight: 600; }
.wallet-cell-balance { font-weight: 600; margin-right: 6px; }

/* ==================== XMEGA Coins: Till payment box, forms, status badges ==================== */

.till-info-box {
  background: linear-gradient(135deg, rgba(124,58,237,0.07), rgba(217,70,239,0.05));
  border: 1px solid var(--brand-purple-light);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.6;
}

.till-info-box .till-number {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand-purple);
  letter-spacing: 0.5px;
}

.till-info-box .till-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.till-info-box .till-row span:first-child { color: var(--gray); }
.till-info-box .till-instructions { margin-top: 10px; font-size: 13px; color: var(--gray); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.tabs-mini {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.tab-mini-btn {
  background: none;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-mini-btn:hover { border-color: var(--brand-purple-light); }
.tab-mini-btn.active {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.pending { background: rgba(245,158,11,0.15); color: #b45309; }
.status-badge.approved { background: rgba(16,185,129,0.15); color: #047857; }
.status-badge.rejected { background: rgba(239,68,68,0.15); color: #b91c1c; }

/* ========== DEPLOY HELP (scripted assistant) ========== */
.help-chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  height: calc(100vh - 140px);
  min-height: 520px;
}

.help-topics { padding: 20px; display: flex; flex-direction: column; overflow: hidden; }
.help-topics .card-header { padding: 0 0 8px; }
.help-topic-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; margin-top: 8px; }

.help-topic-btn {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  background: white;
  font: inherit;
  font-size: 13px;
  color: var(--dark);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: all 0.15s;
}
.help-topic-btn i { color: var(--brand-purple); margin-top: 2px; }
.help-topic-btn:hover { border-color: var(--brand-purple-light); background: #faf5ff; }

.help-chat-area {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.help-chat-header { display: flex; align-items: center; gap: 12px; }
.help-chat-header small { color: var(--gray); font-size: 12px; }
.help-chat-header .btn { margin-left: auto; }

.help-bot-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.help-message ol, .help-message ul { margin: 8px 0 0 18px; }
.help-message li { margin-bottom: 4px; }
.help-message.inbound { max-width: 85%; }

.help-typing { display: flex; gap: 4px; padding: 14px 18px; }
.help-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gray);
  animation: helpBlink 1.2s infinite;
}
.help-typing span:nth-child(2) { animation-delay: 0.2s; }
.help-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes helpBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.help-quick-replies {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 10px 20px;
  background: #f0f2f5;
  border-top: 1px solid #e9ecef;
}
.help-quick-replies:empty { display: none; }

.help-chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--brand-purple-light);
  background: white;
  color: var(--brand-purple);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.help-chip:hover { background: var(--brand-purple); color: white; }

/* ========== PLANS PAGE ========== */
.plans-current { padding: 24px; margin-bottom: 24px; }
.plans-current-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.plans-current-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray); margin-bottom: 4px; }
.plans-current h3 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.plans-current-meta { color: var(--gray); font-size: 13px; margin-top: 4px; }
.plans-usage { text-align: center; }
.plans-usage-num { font-size: 36px; font-weight: 800; line-height: 1; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plans-usage-num span { font-size: 18px; font-weight: 600; }
.plans-usage p { font-size: 12px; color: var(--gray); margin-top: 4px; }

.account-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.account-plan-card {
  position: relative;
  background: white;
  border: 2px solid #e9ecef;
  border-radius: var(--border-radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}
.account-plan-card:hover { transform: translateY(-3px); }
.account-plan-card.current { border-color: var(--brand-purple); }
.account-plan-current-tag {
  position: absolute; top: -12px; left: 24px;
  background: var(--brand-gradient); color: white;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 999px;
}
.account-plan-card h3 { font-size: 20px; margin-bottom: 8px; }
.account-plan-price { font-size: 30px; font-weight: 800; margin-bottom: 12px; }
.account-plan-price small { font-size: 13px; font-weight: 500; color: var(--gray); }
.account-plan-limit {
  background: #faf5ff; color: var(--brand-purple);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
  display: flex; gap: 8px; align-items: center; margin-bottom: 16px;
}
.account-plan-perks { list-style: none; margin: 0 0 20px; padding: 0; flex: 1; }
.account-plan-perks li { font-size: 14px; color: var(--dark); margin-bottom: 8px; display: flex; gap: 8px; }
.account-plan-perks li i { color: var(--primary); margin-top: 3px; font-size: 12px; }
.plans-footnote { margin-top: 20px; font-size: 13px; color: var(--gray); text-align: center; }

/* Admin inline number input (Max Bots) */
.admin-inline-input {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}
.admin-inline-input:focus { outline: none; border-color: var(--brand-purple-light); }

@media (max-width: 900px) {
  .help-chat-layout { grid-template-columns: 1fr; height: auto; }
  .help-topics { max-height: 260px; }
  .help-chat-area { height: 70vh; }
}

/* Hosting plan cards — richer prefilled plan picker */
.plan-card { position: relative; }
.plan-card .plan-meta { font-size: 11px; color: var(--gray); margin-top: 4px; }
.plan-card .plan-meta.warn { color: var(--danger); }
.plan-card.unaffordable { opacity: 0.75; }
.plan-card .plan-tag {
  position: absolute; top: -9px; right: 8px;
  background: var(--brand-purple); color: #fff;
  font-size: 9px; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase; padding: 2px 6px; border-radius: 999px;
}
.plan-empty { grid-column: 1 / -1; font-size: 13px; color: var(--gray); display: flex; align-items: center; gap: 8px; }
.till-instructions.auto-verify { color: var(--success); font-weight: 600; }

/* ===== Account plan banner on the deploy form ===== */
.deploy-plan-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  margin-bottom: 16px;
}
.deploy-plan-banner i { font-size: 16px; color: var(--gray); }
.deploy-plan-banner.ok { border-color: var(--success); }
.deploy-plan-banner.ok i { color: var(--success); }
.deploy-plan-banner.warn { border-color: var(--warning, #f59e0b); }
.deploy-plan-banner.warn i { color: var(--warning, #f59e0b); }
.deploy-plan-banner-text { line-height: 1.5; }
.deploy-plan-banner-text a { color: var(--brand-purple-light); font-weight: 600; }

/* ===== Plan cards: description + most popular ===== */
.account-plan-desc { font-size: 13px; color: var(--gray); margin-bottom: 10px; line-height: 1.5; }
.account-plan-card.featured { border-color: var(--brand-purple-light); box-shadow: 0 12px 32px rgba(124, 58, 237, 0.18); }
.account-plan-current-tag.featured-tag { background: var(--brand-purple-light); }

/* ===== Admin tables: status rows and small notes ===== */
.admin-table tr.row-banned { background: rgba(239, 68, 68, 0.07); }
.admin-table tr.row-inactive { opacity: 0.6; }
.admin-cell-note { display: block; font-size: 10px; color: var(--gray); margin-top: 3px; }
.admin-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--light, #e5e7eb);
  margin-bottom: 8px;
  cursor: pointer;
}
label.checkbox input { width: 16px; height: 16px; accent-color: var(--brand-purple); }

.btn-pinned { background: rgba(124,58,237,0.15); color: var(--brand-purple); border-color: var(--brand-purple-light); }
.btn-pinned:hover { background: rgba(124,58,237,0.25); }

/* ==================== Password visibility toggle + forgot/reset password forms ==================== */

.password-field { position: relative; }
.password-field input { padding-right: 44px !important; }

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  padding: 8px 10px;
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
}

.password-toggle-btn:hover { color: var(--brand-purple); }

.auth-forgot-link { text-align: right; margin: -10px 0 18px; }
.auth-forgot-link a { font-size: 13px; color: var(--brand-purple); text-decoration: none; font-weight: 600; }
.auth-forgot-link a:hover { text-decoration: underline; }

.auth-form-hint { font-size: 13.5px; color: var(--gray); margin-bottom: 18px; line-height: 1.5; }
