:root {
  --bg-dark: #090D16;
  --bg-sidebar: #060911;
  --bg-card: #111726;
  --bg-card-hover: #161F33;
  --border-color: rgba(255, 255, 255, 0.07);
  --purple-primary: #7C3AED;
  --purple-glow: rgba(124, 58, 237, 0.25);
  --blue-accent: #3B82F6;
  --green-success: #10B981;
  --amber-warning: #F59E0B;
  --text-white: #FFFFFF;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, sans-serif;
}

body {
  background: var(--bg-dark);
  color: var(--text-white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Telas */
.screen {
  display: none !important;
  width: 100%;
}
.screen.active {
  display: flex !important;
}

/* ============================
   TELA DE LOGIN
============================ */
#login-screen {
  min-height: 100vh;
  width: 100vw;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(124, 58, 237, 0.12) 0%, transparent 70%), var(--bg-dark);
  padding: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
}
#login-screen:not(.active) {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--purple-primary), #5B21B6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px var(--purple-glow);
}
.brand-icon svg { width: 22px; height: 22px; }

.brand-badge h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.brand-badge h2 span { color: #A78BFA; }

.login-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 2rem;
}

.input-group {
  text-align: left;
  margin-bottom: 1.25rem;
}
.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.input-group input, .input-group select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
}
.input-group input:focus, .input-group select:focus {
  border-color: var(--purple-primary);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

.btn-primary {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: linear-gradient(135deg, var(--purple-primary), #6D28D9);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--purple-glow);
  transition: all 0.2s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--purple-glow);
}

.btn-outline {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: transparent;
  color: #A78BFA;
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover {
  background: rgba(167, 139, 250, 0.08);
}

.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #F87171;
  font-size: 0.85rem;
}

/* ============================
   APLICAÇÃO DASHBOARD
============================ */
#app-screen {
  min-height: 100vh;
  width: 100%;
}
#app-screen:not(.active) {
  display: none !important;
}

/* SIDEBAR */
.sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 50;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.brand-icon-sm {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--purple-primary), #5B21B6);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.brand-icon-sm svg { width: 18px; height: 18px; }
.brand-titles h3 {
  font-size: 1.15rem;
  font-weight: 800;
}
.brand-titles h3 span { color: #A78BFA; }
.badge-version {
  font-size: 0.65rem;
  background: rgba(124, 58, 237, 0.18);
  color: #A78BFA;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  text-align: left;
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.25) 0%, rgba(124, 58, 237, 0.05) 100%);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--purple-primary);
  border-radius: 0 3px 3px 0;
}

.badge-sub {
  margin-left: auto;
  font-size: 0.62rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-success);
  padding: 0.15rem 0.45rem;
  border-radius: 99px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: auto;
}
.status-dot.connected { background: var(--green-success); box-shadow: 0 0 8px var(--green-success); }
.status-dot.disconnected { background: #EF4444; }

.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.user-avatar {
  width: 34px;
  height: 34px;
  background: rgba(124, 58, 237, 0.2);
  color: #A78BFA;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}
.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: all 0.2s;
}
.btn-logout:hover { color: #EF4444; background: rgba(239, 68, 68, 0.1); }
.btn-logout svg { width: 16px; height: 16px; }

/* MAIN CONTENT */
.main-content {
  margin-left: 250px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.topbar-title h2 {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.topbar-title p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.topbar-kpis {
  display: flex;
  gap: 1rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  display: flex;
  flex-direction: column;
}
.kpi-card.highlight {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}
.kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-value {
  font-size: 1.25rem;
  font-weight: 800;
  margin-top: 0.15rem;
}
.kpi-card.highlight .kpi-value { color: var(--green-success); }

/* TAB PANES */
.tab-pane {
  display: none !important;
  padding: 2rem;
  flex: 1;
}
.tab-pane.active {
  display: block !important;
}

/* ============================
   KANBAN BOARD (ESTILO OKTTO / HOVEDO)
============================ */
.kanban-board {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding-bottom: 1.5rem;
  min-height: calc(100vh - 160px);
}

.kanban-column {
  width: 310px;
  flex-shrink: 0;
  background: rgba(17, 23, 38, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 170px);
}

.col-header {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.col-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.col-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.col-title {
  font-size: 0.92rem;
  font-weight: 700;
}
.col-count {
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}
.col-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green-success);
}

.col-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* LEAD CARD */
.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.lead-card:hover {
  border-color: rgba(124, 58, 237, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.lead-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.lead-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
}
.lead-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.lead-phone {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.lead-last-msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lead-origin-chip {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}
.lead-origin-chip.meta { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.lead-origin-chip.google { background: rgba(245, 158, 11, 0.15); color: #FBBF24; }
.lead-origin-chip.organico { background: rgba(148, 163, 184, 0.15); color: #94A3B8; }

.lead-val {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--green-success);
}

/* ============================
   CONEXÕES WHATSAPP
============================ */
.connections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.conn-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  position: relative;
}
.conn-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}
.conn-badge.normal { background: rgba(59, 130, 246, 0.15); color: #60A5FA; }
.conn-badge.official { background: rgba(16, 185, 129, 0.15); color: var(--green-success); }

.conn-card h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}
.conn-card p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.qr-container {
  width: 200px;
  height: 200px;
  background: #fff;
  border-radius: var(--radius-md);
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.qr-container img { width: 100%; height: 100%; }
.qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: #64748B;
  text-align: center;
  padding: 1rem;
}
.qr-placeholder svg { width: 36px; height: 36px; }
.qr-placeholder span { font-size: 0.75rem; font-weight: 600; }

.conn-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-indicator.connected { background: var(--green-success); box-shadow: 0 0 8px var(--green-success); }
.status-indicator.disconnected { background: #EF4444; }

/* CHAT DRAWER */
.chat-drawer {
  position: fixed;
  top: 0; right: -420px; bottom: 0;
  width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chat-drawer.open {
  right: 0;
}

.chat-drawer-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-lead-info h4 { font-size: 1.05rem; font-weight: 700; }
.chat-lead-info span { font-size: 0.78rem; color: var(--text-muted); display: block; margin-top: 0.15rem; }
.btn-close-drawer {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.chat-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.chat-bubble.in {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
}
.chat-bubble.out {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--purple-primary), #6D28D9);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-drawer-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
}
.chat-drawer-footer input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: #fff;
  outline: none;
}
.btn-send {
  background: var(--purple-primary);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-send svg { width: 18px; height: 18px; }

/* PAINEL DE INTEGRAÇÃO */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 750px;
}
.card-panel h3 { font-size: 1.35rem; font-weight: 800; margin-bottom: 0.4rem; }
.panel-sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

.code-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.code-box label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #A78BFA;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}
.copy-row {
  display: flex;
  gap: 0.5rem;
}
.copy-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: monospace;
  font-size: 0.88rem;
  outline: none;
}
.btn-copy {
  background: var(--purple-primary);
  border: none;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

.instructions-card {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border-left: 3px solid var(--purple-primary);
}
.instructions-card h4 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.instructions-card ul { padding-left: 1.25rem; color: var(--text-muted); font-size: 0.85rem; line-height: 1.6; }
