/* ============================================================
   AtendeIA — Design System Premium Dark Mode
   ============================================================ */

:root {
  /* Cores principais */
  --bg-primary:    #0a0f1e;
  --bg-secondary:  #111827;
  --bg-card:       #1a2035;
  --bg-card-hover: #1f2847;
  --bg-input:      #0f172a;
  --bg-sidebar:    #080d1a;

  /* Acentos */
  --accent:        #10b981;
  --accent-hover:  #059669;
  --accent-glow:   rgba(16, 185, 129, 0.15);
  --accent-blue:   #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-orange: #f59e0b;
  --accent-red:    #ef4444;
  --accent-red-hover: #dc2626;

  /* Texto */
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #475569;

  /* Bordas */
  --border:        rgba(255,255,255,0.07);
  --border-active: rgba(16, 185, 129, 0.4);

  /* Outros */
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-card:   0 2px 16px rgba(0,0,0,0.3);
  --sidebar-width: 240px;
  --sidebar-collapsed: 68px;
  --topbar-height: 64px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; outline: none; }
img { max-width: 100%; display: block; }
pre { white-space: pre-wrap; word-break: break-word; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: var(--transition);
  z-index: 100;
  overflow: hidden;
  position: relative;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); min-width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .sidebar-status,
.sidebar.collapsed .sidebar-version,
.sidebar.collapsed .nav-item span:not(.nav-badge),
.sidebar.collapsed .status-text { display: none; }
.sidebar.collapsed .logo-icon { margin: 0 auto; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 0 12px; }
.sidebar.collapsed .sidebar-toggle { display: none; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 72px;
}
.logo-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-text { flex: 1; min-width: 0; }
.logo-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.logo-tag {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 1px;
}
.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--border); color: var(--text-primary); }

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.05);
  border-bottom: 1px solid var(--border);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition);
}
.status-dot.connected { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
.status-dot.waiting { background: var(--accent-orange); animation: pulse 1s infinite; }
.status-text { font-size: 12px; color: var(--text-secondary); font-weight: 500; white-space: nowrap; }

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

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border-active);
}
.nav-item.active .nav-icon { stroke: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }
.nav-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-version { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.mobile-menu-btn:hover { background: var(--border); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}
.badge-dot.connected { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.badge-dot.waiting { background: var(--accent-orange); }

/* ── Page Content ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
}
.page { display: none; padding: 28px 24px; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 0 16px var(--accent-glow); }
.btn-danger {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}
.btn-danger:hover { background: var(--accent-red-hover); }
.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent-glow); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.btn-danger-ghost {
  background: transparent;
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger-ghost:hover { background: rgba(239, 68, 68, 0.1); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-large { padding: 13px 28px; font-size: 16px; border-radius: var(--radius); }
.btn-icon { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 10px; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 20px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.card-link {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.card-link:hover { text-decoration: underline; }
.card-title-group { display: flex; align-items: center; gap: 10px; }
.card-title-icon { font-size: 22px; }

/* ============================================================
   DASHBOARD — Stats
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  cursor: default;
}
.stat-card:hover { border-color: var(--border-active); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; stroke: white; }
.stat-icon.green { background: linear-gradient(135deg, #059669, #10b981); }
.stat-icon.blue  { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.stat-icon.purple{ background: linear-gradient(135deg, #7c3aed, #8b5cf6); }
.stat-icon.orange{ background: linear-gradient(135deg, #d97706, #f59e0b); }
.stat-info { flex: 1; min-width: 0; }
.stat-value { display: block; font-size: 26px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.stat-trend { font-size: 18px; color: var(--accent); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}

.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.recent-item:hover { background: rgba(255,255,255,0.04); }
.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}
.contact-avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-msg { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.system-status-list { display: flex; flex-direction: column; gap: 0; }
.system-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.system-row:last-child { border-bottom: none; }
.system-label { font-size: 13px; color: var(--text-secondary); }
.system-val { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.system-val.success { color: var(--accent); }
.system-val.danger { color: var(--accent-red); }
.system-val.warning { color: var(--accent-orange); }

/* ============================================================
   WHATSAPP PAGE
   ============================================================ */
.wa-container { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
.wa-qr-card { display: flex; flex-direction: column; }
.wa-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.qr-area {
  min-height: 280px;
  background: var(--bg-input);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  margin: 8px 0 20px;
  transition: var(--transition);
  overflow: hidden;
  padding: 24px;
}
.qr-area.active { border-color: var(--border-active); background: rgba(16, 185, 129, 0.03); }
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-placeholder p { font-size: 14px; color: var(--text-muted); max-width: 220px; }
.qr-image { width: 220px; height: 220px; border-radius: 12px; border: 8px solid white; }
.connected-info { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.connected-icon { font-size: 48px; }
.connected-info h3 { font-size: 18px; font-weight: 700; color: var(--accent); }
.connected-phone { font-size: 15px; color: var(--text-secondary); font-weight: 500; }
.connected-hint { font-size: 13px; color: var(--text-muted); }
.connecting-info { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-secondary); }

.qr-instructions { margin-bottom: 20px; }
.instruction-steps { display: flex; flex-direction: column; gap: 10px; }
.step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--border-active);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wa-actions { display: flex; gap: 12px; }
.wa-info-card {}
.info-grid { display: flex; flex-direction: column; gap: 0; }
.info-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-item:last-child { border-bottom: none; }
.info-label { font-size: 13px; color: var(--text-secondary); }
.info-value { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ============================================================
   CONVERSAS PAGE
   ============================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--topbar-height));
  margin: -28px -24px;
  overflow: hidden;
}
.contacts-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.contacts-search { padding: 16px; border-bottom: 1px solid var(--border); }
.search-box { position: relative; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px;
  color: var(--text-primary);
  font-size: 13px;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--border-active); }
.search-input::placeholder { color: var(--text-muted); }
.contacts-list { flex: 1; overflow-y: auto; padding: 8px; }

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.contact-item:hover { background: rgba(255,255,255,0.04); }
.contact-item.active { background: var(--accent-glow); }
.contact-item-info { flex: 1; min-width: 0; }
.contact-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-item-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.contact-item-time { font-size: 11px; color: var(--text-muted); }
.contact-unread {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.blocked-tag {
  font-size: 10px;
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  padding: 2px 6px;
  border-radius: 4px;
}
.paused-tag {
  font-size: 10px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  overflow: hidden;
}
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}
.chat-empty-state h3 { font-size: 18px; color: var(--text-secondary); }
.chat-empty-state p { font-size: 14px; }
.chat-view { display: flex; flex-direction: column; height: 100%; }
.chat-header {
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.chat-contact-info { display: flex; align-items: center; gap: 12px; }
.chat-contact-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.chat-contact-phone { font-size: 12px; color: var(--text-secondary); }
.chat-actions { display: flex; gap: 8px; }
.messages-area { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
}
.msg-bubble.in {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  align-self: flex-start;
  color: var(--text-primary);
}
.msg-bubble.out {
  background: linear-gradient(135deg, #059669, #10b981);
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
  color: white;
}
.msg-time { font-size: 10px; opacity: 0.6; margin-top: 4px; text-align: right; }

/* Recibos das mensagens enviadas (visto / entregue / lida) */
.msg-status { font-size: 11px; margin-left: 2px; letter-spacing: -1px; }
.msg-status.lido { color: var(--accent-blue); font-weight: 700; }
.msg-status.erro { color: var(--accent-red); }
.chat-input-area {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 10px 18px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}
.chat-input:focus { border-color: var(--border-active); }
.chat-input::placeholder { color: var(--text-muted); }

/* ============================================================
   TREINAMENTO PAGE
   ============================================================ */
.training-container {}
.scrape-form { margin-bottom: 20px; }
.url-input-group { display: flex; gap: 12px; margin-top: 8px; }
.url-input-wrapper {
  flex: 1;
  position: relative;
}
.url-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}
.form-input:focus { border-color: var(--border-active); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }
.url-input-wrapper .form-input { padding-left: 44px; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-hint-inline { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  transition: var(--transition);
  line-height: 1.6;
}
.form-textarea:focus { border-color: var(--border-active); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-textarea::placeholder { color: var(--text-muted); }

/* Campo de instrucoes longas: area generosa e redimensionavel */
.form-textarea-lg {
  min-height: 360px;
  line-height: 1.65;
  font-size: 13.5px;
}

/* Dica + contador de caracteres na mesma linha */
.form-hint-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
}
.form-hint-row .form-hint { margin-top: 0; }
.form-counter {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.form-counter.limite-alerta { color: var(--accent-orange); }
.form-counter.limite-cheio { color: var(--accent-red); font-weight: 600; }

/* ============================================================
   Tela de acesso ao painel (login / primeira senha)
   ============================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
}

.auth-logo { display: flex; justify-content: center; margin-bottom: 14px; }

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 6px;
}

.auth-sub {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 14px;
  text-align: center;
}

.auth-hint code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* ============================================================
   FONTES DA BASE DE CONHECIMENTO
   Cada link extraído é uma fonte, com incluir/excluir
   ============================================================ */
.fontes-bloco {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.fontes-cabecalho {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.fontes-cabecalho strong { font-size: 14px; color: var(--text-primary); }

.fontes-lista { display: flex; flex-direction: column; gap: 8px; }

.fonte-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  transition: var(--transition);
}

.fonte-item:hover { border-color: var(--border-active); }
.fonte-item.desligada { opacity: 0.55; }
.fonte-item.desligada .fonte-nome { text-decoration: line-through; }

.fonte-toggle { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.fonte-toggle input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); }

.fonte-icone { font-size: 18px; flex-shrink: 0; }

.fonte-info { flex: 1; min-width: 150px; }

.fonte-nome {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.fonte-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.fonte-meta a { color: var(--accent); }

.fonte-acoes { display: flex; gap: 4px; flex-shrink: 0; }

.fonte-editor { width: 100%; margin-top: 10px; }
.fonte-editor .form-textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

.fonte-editor-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.fonte-editor-acoes .form-hint { flex: 1; margin: 0; }

/* Prompt editável no modal */
.prompt-edit-aviso {
  margin: 0 20px 10px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.prompt-preview-editavel {
  width: calc(100% - 40px);
  margin: 0 20px;
  min-height: 320px;
  resize: vertical;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

.prompt-edit-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 20px 20px;
  flex-wrap: wrap;
}

.prompt-edit-acoes .form-hint { flex: 1; margin: 0; color: var(--accent-yellow, #f59e0b); }

/* Dizer de qual empresa é o prompt pré-visualizado */.prompt-de-quem {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 20px 12px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  border: 1px solid var(--border-active);
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.prompt-de-quem strong { color: var(--text-primary); font-size: 13.5px; }
.prompt-de-quem-meta { font-size: 11.5px; color: var(--text-muted); }
.prompt-de-quem code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

/* Aviso: instruções iguais ao conteúdo extraído */
.aviso-campos-duplicados {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
}

/* Empresa ativa e usuário logado, no topo do painel */
.empresa-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  max-width: 200px;
  transition: var(--transition);
}

.empresa-select:focus { border-color: var(--border-active); outline: none; }

.usuario-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-glow);
  border: 1px solid var(--border-active);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   PAINEL DE CHATBOTS (administração multi-empresa)
   Esquerda: a lista de chatbots · Direita: indicadores e detalhe
   ============================================================ */
.painel-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 18px;
  align-items: start;
}

.chatbots-coluna {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 130px);
  padding-bottom: 12px;
}

.chatbots-lista {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
  min-height: 60px;
}

.chatbot-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  transition: var(--transition);
}

.chatbot-item:hover { border-color: var(--border-active); }

.chatbot-item.selecionado {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.chatbot-item.suspensa { opacity: 0.55; }

.chatbot-botao {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  min-width: 0;
}

.chatbot-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  color: #04231a;
  font-weight: 800;
  font-size: 11.5px;
}

.chatbot-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.chatbot-nome {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-ponto {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

.chatbot-ponto.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.chatbot-ponto.off { background: var(--accent-red); }

.chatbot-selo {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.18);
  color: var(--accent-purple);
  align-self: center;
}

.chatbot-config {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.chatbot-config:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.chatbots-rodape {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.painel-conteudo { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Os quadrados de indicadores */
.metricas-grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.metrica {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: var(--transition);
}

.metrica:hover { border-color: var(--border-active); }
.metrica.alerta { border-color: rgba(245, 158, 11, 0.45); }

.metrica-icone { font-size: 17px; margin-bottom: 4px; }

.metrica-valor {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metrica-rotulo {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.metrica-detalhe { font-size: 11px; color: var(--text-muted); }

@media (max-width: 900px) {
  .painel-layout { grid-template-columns: 1fr; }
  .chatbots-coluna { position: static; max-height: none; }
  .metricas-grade { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ============================================================
   EMPRESAS (cartões antigos — mantidos para reuso)
   ============================================================ */
.empresas-grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.empresa-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}

.empresa-card:hover { border-color: var(--border-active); }
.empresa-card.suspensa { opacity: 0.6; }

.empresa-card-topo { display: flex; align-items: center; gap: 12px; }

.empresa-avatar {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  color: #04231a;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.empresa-avatar.pequeno { width: 34px; height: 34px; font-size: 12px; border-radius: 9px; }

.empresa-identidade { flex: 1; min-width: 0; }

.empresa-nome {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empresa-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.empresa-sub code {
  background: var(--bg-input);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.empresa-numeros {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.empresa-numero { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.empresa-numero strong { font-size: 16px; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.empresa-numero span { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.empresa-sinais { display: flex; flex-direction: column; gap: 5px; }

.sinal { font-size: 12px; color: var(--text-muted); }
.sinal.ok { color: var(--text-secondary); }
.sinal.off { color: var(--text-muted); opacity: 0.7; }

.empresa-acoes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.empresa-acoes .btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* QR Code */
.qr-area { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }

.qr-caixa {
  width: 260px;
  height: 260px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 10px;
}

.qr-caixa img { width: 100%; height: 100%; object-fit: contain; }

.qr-instrucoes { flex: 1; min-width: 240px; font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; }
.qr-instrucoes ol { margin: 8px 0 12px 20px; }
.qr-instrucoes strong { color: var(--text-primary); }

/* Usuários */
.usuarios-lista { display: flex; flex-direction: column; gap: 8px; }

.usuario-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.usuario-item.inativo { opacity: 0.55; }

.usuario-info { flex: 1; min-width: 0; }
.usuario-nome { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.usuario-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.usuario-acoes { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

@media (max-width: 700px) {
  .empresa-numeros { grid-template-columns: repeat(2, 1fr); }
  .usuario-item { flex-wrap: wrap; }
  .usuario-acoes { width: 100%; justify-content: flex-end; }
}

/* ============================================================
   Laboratório (teste do bot com clientes simulados)
   ============================================================ */
.lab-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.lab-progress { margin-bottom: 8px; }

.lab-progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
}

.lab-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  transition: width 0.4s ease;
}

.lab-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.lab-score-area {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.lab-score {
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  min-width: 108px;
  text-align: center;
  padding: 10px 6px;
  border-radius: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.lab-score.bom { color: #6ee7b7; }
.lab-score.medio { color: var(--accent-orange); }
.lab-score.ruim { color: var(--accent-red); }

.lab-score-side { flex: 1; min-width: 0; }

.lab-delta { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.lab-delta.sobe { color: var(--accent); }
.lab-delta.desce { color: var(--accent-red); }
.lab-delta.igual { color: var(--text-muted); }

.lab-persona {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--bg-input);
}

.lab-persona-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.lab-persona-nome { font-weight: 600; font-size: 14px; color: var(--text-primary); }

.lab-persona-nota {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  white-space: nowrap;
}

.lab-persona-nota.bom { color: #6ee7b7; }
.lab-persona-nota.medio { color: var(--accent-orange); }
.lab-persona-nota.ruim { color: var(--accent-red); }

.lab-persona-resumo {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

.lab-persona-corpo { display: none; margin-top: 12px; }
.lab-persona.aberta .lab-persona-corpo { display: block; }

.lab-secao {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 12px 0 6px;
}

.lab-problema {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  border-left: 3px solid var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.5;
}

.lab-problema.alta { border-left-color: var(--accent-red); }
.lab-problema.media { border-left-color: var(--accent-orange); }
.lab-problema.baixa { border-left-color: var(--accent-blue); }

.lab-problema .tipo {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 6px;
}

.lab-problema .evidencia {
  display: block;
  margin-top: 4px;
  font-style: italic;
  color: var(--text-secondary);
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

.lab-sugestao {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-card);
  margin-bottom: 6px;
}

.lab-sugestao span { flex: 1; line-height: 1.5; }

.lab-roteiro {
  font-size: 12.5px;
  line-height: 1.6;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 10px 12px;
}

.lab-roteiro .linha { margin-bottom: 6px; }
.lab-roteiro .quem { font-weight: 600; color: var(--text-muted); margin-right: 6px; }
.lab-roteiro .linha.cliente .quem { color: var(--accent-blue); }
.lab-roteiro .linha.bot .quem { color: var(--accent); }

.lab-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-input);
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
}

.lab-history-item:hover { background: var(--bg-card-hover); }
.lab-history-nota { font-weight: 700; }
.lab-history-data { color: var(--text-muted); font-size: 12px; }

/* ============================================================
   AGENDA (calendário + agendamentos)
   ============================================================ */
.agenda-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  align-items: start;
}

.agenda-mes-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.agenda-mes-titulo {
  flex: 1;
  text-align: center;
  font-size: 15px;
  color: var(--text-primary);
  text-transform: capitalize;
}

.agenda-semana {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.agenda-semana span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.agenda-grade {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.agenda-celula {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.agenda-celula:hover { background: var(--bg-card-hover); }
.agenda-celula.vazia { cursor: default; }
.agenda-celula.vazia:hover { background: none; }

.agenda-celula.hoje {
  border-color: var(--border-active);
  color: var(--text-primary);
  font-weight: 700;
}

.agenda-celula.selecionado {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--text-primary);
  font-weight: 700;
}

.agenda-celula.com-agendamento { color: var(--text-primary); }

.agenda-celula-dia { line-height: 1; }

.agenda-celula-marca {
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #04231a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agenda-dia-lista { display: flex; flex-direction: column; gap: 10px; }

.agenda-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--bg-input);
}

.agenda-item-topo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.agenda-item-hora {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.agenda-item-tipo { font-size: 13px; color: var(--text-secondary); flex: 1; }

.agenda-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.agenda-status.confirmado { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.agenda-status.concluido { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }
.agenda-status.cancelado { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

.agenda-item-corpo { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.agenda-item-linha { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.agenda-item-linha.muted { font-size: 11.5px; color: var(--text-muted); }

.agenda-item-acoes { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 1000px) {
  .agenda-layout { grid-template-columns: 1fr; }
}

/* Escolha dos dias atendidos */
.agenda-dias-escolha {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.agenda-dias-escolha label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.agenda-dias-escolha label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text-primary);
  font-weight: 600;
}

.agenda-dias-escolha input { accent-color: var(--accent); }

/* ============================================================
   DOCUMENTOS (base de conhecimento por arquivo)
   ============================================================ */
.doc-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 34px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.doc-drop:hover { border-color: var(--border-active); color: var(--text-secondary); }

.doc-drop.arrastando {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text-primary);
}

.doc-drop-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.doc-drop-sub { font-size: 13px; }
.doc-drop-tip { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; max-width: 620px; line-height: 1.5; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.doc-upload-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border-left: 3px solid var(--accent-blue);
  font-size: 13px;
  color: var(--text-secondary);
}

.doc-upload-status.ok { border-left-color: var(--accent); color: var(--text-primary); }
.doc-upload-status.erro { border-left-color: var(--accent-red); color: var(--text-primary); }
.doc-upload-sub { font-size: 12px; color: var(--text-muted); }

.doc-lista { display: flex; flex-direction: column; gap: 8px; }

.doc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  transition: var(--transition);
}

.doc-item.inativo { opacity: 0.5; }

.doc-item-icone {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.doc-item-info { flex: 1; min-width: 0; }

.doc-item-nome {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.doc-item-erro { font-size: 12px; color: var(--accent-orange); margin-top: 5px; line-height: 1.5; }

.doc-status {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
}

.doc-status.pronto { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.doc-status.erro { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.doc-status.ocr { background: rgba(245, 158, 11, 0.18); color: var(--accent-orange); cursor: help; }
.doc-status.editado { background: rgba(139, 92, 246, 0.18); color: var(--accent-purple); cursor: help; }

/* Editor do texto extraído */
.doc-editor {
  min-height: 46vh;
  max-height: 56vh;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.doc-item-acoes { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.doc-busca { display: flex; gap: 10px; margin-bottom: 14px; }
.doc-busca .form-input { flex: 1; }

.doc-busca-vazio {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  padding: 14px;
}

.doc-trecho {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.doc-trecho-topo {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11.5px;
}

.doc-trecho-doc { color: var(--accent); font-weight: 600; }
.doc-trecho-peso { color: var(--text-muted); }

.doc-trecho-texto {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow-y: auto;
}

@media (max-width: 800px) {
  .doc-item { flex-wrap: wrap; }
  .doc-item-acoes { width: 100%; justify-content: flex-end; }
  .doc-busca { flex-direction: column; }
}
.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}
.form-select:focus { border-color: var(--border-active); }
.form-select option { background: var(--bg-card); }

.scrape-loading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  margin: 16px 0 0;
}
.scrape-result {
  margin-top: 16px;
  padding: 14px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
}
.result-header { display: flex; align-items: center; gap: 12px; }
.result-icon { font-size: 28px; }
.result-type { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.result-url { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.result-badge {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.result-badge.success { background: rgba(16, 185, 129, 0.15); color: var(--accent); }
.result-badge.warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }

.knowledge-form {}
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.form-row { margin-bottom: 20px; }
.form-row:last-child { margin-bottom: 0; }
.form-row-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   CONFIGURAÇÕES PAGE
   ============================================================ */
.settings-container {}
.settings-group { display: flex; flex-direction: column; gap: 0; }
.api-key-input-group { display: flex; gap: 8px; }
.api-key-input-group .form-input { flex: 1; }
.form-range {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  margin-top: 10px;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.badge-info {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--border-active);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

/* Toggle Switch */
.toggle-group { display: flex; flex-direction: column; gap: 0; margin: 8px 0; }
.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.toggle-item:last-child { border-bottom: none; }
.toggle-info { flex: 1; }
.toggle-label { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.toggle-desc { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle-switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 13px;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }
.business-hours-config { padding: 16px; background: var(--bg-input); border-radius: var(--radius-sm); margin-top: 8px; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg-primary); padding: 16px 0 8px; }

/* ============================================================
   BLOQUEADOS PAGE
   ============================================================ */
.blocked-list { display: flex; flex-direction: column; gap: 4px; }
.blocked-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.blocked-phone { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.blocked-name { font-size: 12px; color: var(--text-secondary); }
.blocked-reason { font-size: 12px; color: var(--text-muted); }
.blocked-date { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 460px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
.modal-box.large { width: 720px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.prompt-preview {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  overflow-y: auto;
  max-height: 60vh;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  align-items: flex-start;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-info {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--text-secondary);
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 250px;
  max-width: 380px;
  animation: slideInRight 0.3s ease;
  pointer-events: all;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.warning { border-left: 3px solid var(--accent-orange); }
.toast.info    { border-left: 3px solid var(--accent-blue); }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-out { animation: slideOutRight 0.3s ease forwards; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
}
.empty-state.small { padding: 24px; }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   UTILITIES
   ============================================================ */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.link { color: var(--accent); text-decoration: underline; }
.link:hover { color: var(--accent-hover); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .wa-container { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -100%; transition: left 0.3s ease; z-index: 200; }
  .sidebar.mobile-open { left: 0; }
  .mobile-menu-btn { display: flex; }
  .chat-layout { grid-template-columns: 1fr; }
  .contacts-panel { display: none; }
  .contacts-panel.mobile-open { display: flex; position: fixed; inset: 0; z-index: 100; }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .url-input-group { flex-direction: column; }
  .form-row-inline { grid-template-columns: 1fr; }
  .wa-actions { flex-direction: column; }
}

/* ============================================================
   Alerta de IA no dashboard
   Aparece quando o modelo configurado falha ou quando um modelo
   alternativo está sendo usado.
   ============================================================ */
.ai-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}

.ai-alert.error {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.1);
}

.ai-alert-icon {
  font-size: 20px;
  line-height: 1.2;
}

.ai-alert-body {
  flex: 1;
  min-width: 0;
}

.ai-alert-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ai-alert-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
}

.ai-alert-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.2s;
}

.ai-alert-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}