/* CSS Vaapty — Premium Dark */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-dark: #0A0E1A;
  --card-bg: #141A29;
  --card-hover: #1A2133;
  --border: #2A344A;
  --brand-primary: #582786;
  --brand-accent: #EE245E;
  --bg-highlight: rgba(88, 39, 134, 0.1);
  --text-main: #FFFFFF;
  --text-sec: #9CA3AF;
  --text-muted: #6B7280;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --header-h: 70px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 14px;
  overflow-x: hidden;
}

/* ─── AUTH ─── */
#login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 16px;
  width: 400px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-logo {
  height: 50px;
  margin-bottom: 24px;
  filter: drop-shadow(0 0 10px rgba(238, 36, 94, 0.3));
}

.input-group {
  margin-bottom: 16px;
}

.input-group input {
  width: 100%;
  padding: 14px;
  background: #0F1420;
  border: 1px solid var(--border);
  color: white;
  border-radius: 8px;
  outline: none;
  transition: 0.2s;
  font-size: 15px;
}

.input-group input:focus {
  border-color: var(--brand-accent);
}

.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--brand-accent);
  color: white;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.btn-login:hover {
  background: #D91E54;
  transform: translateY(-2px);
}

/* ─── APP SHELL ─── */
.top-nav {
  height: var(--header-h);
  background: #111827;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.nav-brand img {
  height: 32px;
  vertical-align: middle;
}

.nav-links {
  display: flex;
  gap: 4px;
  height: 100%;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-sec);
  font-weight: 600;
  font-size: 14px;
  padding: 0 16px;
  height: 100%;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: 0.2s;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  border-bottom-color: var(--brand-accent);
  background: linear-gradient(to top, rgba(238, 36, 94, 0.1), transparent);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.btn-logout:hover {
  background: var(--danger);
  color: white;
}

.main-content {
  padding: 20px;
  max-width: 100%;
  margin: 0;
  width: 100%;
}

.view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── VAAPTY INTELLIGENCE GRID ─── */
.intel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 992px) {
  .intel-grid {
    grid-template-columns: 1fr;
  }
}

.highlight-header {
  background: linear-gradient(90deg, rgba(88, 39, 134, 0.1), transparent);
  padding: 30px;
  border-radius: 20px;
  border: 1px solid rgba(88, 39, 134, 0.2);
  margin-bottom: 40px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* KPI CARDS ENHANCED */
.kpi-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-card:hover {
  border-color: var(--brand-accent);
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.kpi-growth {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.growth-up {
  background: rgba(16, 185, 129, 0.1);
  color: #10B981;
}

.growth-down {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

.kpi-label {
  color: var(--text-sec);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: white;
  line-height: 1;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* FUNNEL MODERN */
.funnel-container-modern {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 10px;
}

.funnel-step {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.funnel-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.funnel-bar-bg {
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
}

.chart-wrapper {
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* KPI INDICATORS */
.kpi-value-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 600;
}

.kpi-trend.positive {
  color: #10B981;
}

.kpi-trend.negative {
  color: #EF4444;
}

.content-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 30px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.data-table th {
  text-align: left;
  padding: 18px 24px;
  color: var(--text-sec);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.data-table td {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 14px;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ─── MASTER DETAL CONFIGS (SIDEBAR ESQUERDA) ─── */
.config-master-detail {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}

.config-sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid var(--border);
  padding-right: 20px;
  min-height: 400px;
}

.config-menu-btn {
  padding: 14px 18px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-sec);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.config-menu-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.config-menu-btn.active {
  background: var(--brand-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(88, 39, 134, 0.3);
}

.config-menu-btn.active::after {
  content: '→';
  font-weight: 800;
  opacity: 0.5;
}

.config-content-panel {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  min-height: 400px;
}

.config-field {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px dashed var(--border);
}

.config-field:last-child {
  border-bottom: none;
}

.config-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 15px;
  color: white;
}

.config-desc {
  color: var(--text-sec);
  font-size: 13px;
  margin-bottom: 12px;
}

.config-input {
  width: 100%;
  background: #0F1420;
  border: 1px solid var(--border);
  color: white;
  padding: 12px;
  border-radius: 8px;
  outline: none;
  transition: 0.2s;
  font-size: 14px;
}

.config-input:focus {
  border-color: var(--brand-primary);
}

/* HORARIOS COMPONENT */
.horario-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.horario-check {
  width: 20px;
  height: 20px;
  accent-color: var(--brand-accent);
}

.horario-day {
  flex: 1;
  font-weight: 600;
  color: var(--text-main);
}

.horario-time {
  width: 100px;
  background: #0F1420;
  border: 1px solid var(--border);
  color: white;
  padding: 6px;
  border-radius: 4px;
  text-align: center;
}

.disabled-overlay {
  opacity: 0.3;
  pointer-events: none;
}

/* ─── KNOWLEDGE BASE ─── */
.header-actions {
  display: flex;
  gap: 10px;
}

.btn-action {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: white;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.cards-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.kb-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  position: relative;
  transition: 0.3s;
}

.kb-card:hover {
  border-color: var(--text-sec);
  transform: translateY(-3px);
}

.kb-type-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.kb-title {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
  padding-right: 50px;
  color: white;
}

.kb-content {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 5000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--card-bg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  border-radius: 16px;
  border: 1px solid var(--border);
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-close-corner {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: white;
  margin-bottom: 24px;
}

.btn-save-modal {
  width: 100%;
  padding: 12px;
  background: var(--brand-accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 20px;
}

/* TOAST */
#toast-container {
  position: fixed;
  top: 90px;
  right: 30px;
  z-index: 6000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 16px 24px;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* UTILS */
/* TAGS & BADGES - Professional Sizing */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: default;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.badge-purple {
  background: rgba(88, 39, 134, 0.2);
  color: #BE9DF2;
}

.badge-pink {
  background: rgba(238, 36, 94, 0.2);
  color: #F8719D;
}

.text-area-large {
  width: 100%;
  min-height: 300px;
  background: #0F1420;
  border: 1px solid var(--border);
  color: white;
  padding: 15px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  resize: vertical;
  margin-bottom: 20px;
}

/* SWITCH IA e BADGES ADICIONAIS */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4B5563;
  transition: .4s;
  border-radius: 20px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: #10B981;
}

input:checked+.slider:before {
  transform: translateX(16px);
}

.badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #60A5FA;
}

.badge-secondary {
  background: rgba(107, 114, 128, 0.2);
  color: #9CA3AF;
}

.badge-compareceu {
  background: rgba(16, 185, 129, 0.25);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-weight: bold;
}

.badge-noshow {
  background: rgba(245, 158, 11, 0.25);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: bold;
}

.badge-lojista {
  background: rgba(139, 92, 246, 0.25);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.4);
  font-weight: bold;
}

.badge-vendido {
  background: rgba(234, 179, 8, 0.25);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.5);
  font-weight: bold;
}

.badge-meta {
  background: rgba(8, 102, 255, 0.15);
  color: #0866FF;
  border: 1px solid rgba(8, 102, 255, 0.3);
}

.badge-facebook {
  background: rgba(24, 119, 242, 0.15);
  color: #1877F2;
  border: 1px solid rgba(24, 119, 242, 0.4);
  box-shadow: 0 2px 10px rgba(24, 119, 242, 0.1);
}

.badge-instagram {
  background: linear-gradient(45deg, rgba(225, 48, 108, 0.15), rgba(253, 29, 29, 0.15));
  color: #FF4D8D;
  border: 1px solid rgba(225, 48, 108, 0.4);
  box-shadow: 0 2px 10px rgba(225, 48, 108, 0.1);
}

.badge-google {
  background: rgba(234, 67, 53, 0.1);
  color: #EA4335;
  border: 1px solid rgba(234, 67, 53, 0.3);
}

.badge-site {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.1);
}

/* Tooltips de Origem Premium */
.origin-tooltip {
  position: relative;
  cursor: help;
}

.origin-tooltip .tooltip-box {
  visibility: hidden;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 0;
  background: #1A2133;
  color: white;
  padding: 12px;
  border-radius: 8px;
  width: 250px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(10px);
  pointer-events: none;
}

.origin-tooltip:hover .tooltip-box {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  /* Permitir clicar no link */
}

/* Padding de segurança para não fechar ao mover mouse */
.origin-tooltip .tooltip-box::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 20px;
  background: transparent;
}

.tooltip-thumb {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.dash-thumb-mini {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.tooltip-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
  color: var(--brand-accent);
}

.tooltip-link {
  font-size: 11px;
  color: #3B82F6;
  text-decoration: none;
  font-weight: 600;
  display: block;
  margin-top: 10px;
  padding: 6px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 4px;
  text-align: center;
  transition: 0.2s;
}

.tooltip-link:hover {
  background: rgba(59, 130, 246, 0.2);
}

.kpi-card:hover {
  border-color: var(--brand-accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.kpi-card .origin-icon-bg {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  opacity: 0.1;
  transition: 0.3s;
}

.kpi-card:hover .origin-icon-bg {
  opacity: 0.3;
  transform: translateY(-50%) scale(1.1);
}

/* Garante que tags no dashboard não estiquem */
#dashboard-origens .badge {
  width: fit-content !important;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action Buttons Enhanced */
.btn-action-group {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  color: white;
}

.btn-icon.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon.success:hover {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}

.btn-icon.info:hover, .badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* BADGES DE STATUS DA IA COM SUPER DESTAQUE */
.ia-badge-on {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.5px;
}

.ia-badge-transbordo {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border: 1px solid #ef4444;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
  transition: all 0.2s;
}

.ia-badge-transbordo:hover {
  background: rgba(239, 68, 68, 0.4);
  transform: scale(1.05);
}

.ia-badge-manual {
  background: rgba(245, 158, 11, 0.25);
  color: #fcd34d;
  border: 1px solid #f59e0b;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.5px;
}

.btn-marcar-tratado {
  background: #10b981;
  color: #042f2e;
  font-weight: 800;
  border-radius: 6px;
  border: none;
  padding: 0 10px;
  height: 32px;
  font-size: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-marcar-tratado:hover {
  background: #34d399;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* FILTROS AGENDAMENTOS */
.active-filter {
  background: rgba(255, 255, 255, 0.05);
  /* Lighter bg */
  border-color: var(--brand-accent) !important;
  box-shadow: 0 0 10px rgba(238, 36, 94, 0.2);
}

.filter-row th {
  background: #111827;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
}

.filter-row input {
  width: 100%;
  background: #1F2937;
  border: 1px solid #4B5563;
  color: white;
  padding: 5px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.filter-row input:focus {
  border-color: var(--brand-primary);
}

.th-sort {
  cursor: pointer;
  user-select: none;
}

.th-sort:hover {
  color: white;
  background: rgba(255, 255, 255, 0.05);
}

.th-sort i {
  font-size: 10px;
  margin-left: 5px;
  opacity: 0.5;
}

/* LIMITES DE AGENDAMENTOS INLINE */
.limite-card-input-inline {
  width: 70px !important;
  text-align: center;
  padding: 6px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.limite-card-input-inline:focus {
  border-color: var(--brand-accent) !important;
}

/* GRIDS DO FORMULÁRIO */
.form-grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
}

@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* SUB-ABAS (SUB-TABS) */
.sub-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-sec);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-tab-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.sub-tab-btn.active {
  background: rgba(238, 36, 94, 0.1);
  color: var(--brand-accent);
  border: 1px solid rgba(238, 36, 94, 0.2) !important;
}

/* CAMPOS MENORES */
.config-field-small {
  margin-bottom: 12px !important;
  padding-bottom: 0 !important;
  border-bottom: none !important;
}

.config-label-small {
  font-size: 13px !important;
  margin-bottom: 4px !important;
}

.config-desc-small {
  font-size: 11px !important;
  margin-bottom: 6px !important;
}

.config-input-small {
  padding: 8px 12px !important;
  font-size: 13px !important;
}

/* Transbordo Urgente Highlight */
.row-transbordo-urgente {
  background: rgba(239, 68, 68, 0.09) !important;
  border-left: 4px solid var(--danger) !important;
  animation: pulse-transbordo 3s infinite ease-in-out;
}

@keyframes pulse-transbordo {
  0% { background: rgba(239, 68, 68, 0.05); }
  50% { background: rgba(239, 68, 68, 0.16); }
  100% { background: rgba(239, 68, 68, 0.05); }
}

/* ─── RESPONSIVIDADE E AJUSTES MOBILE (MANDATÓRIO) ─── */

/* Botão de Menu Hambúrguer Móvel */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 20px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--brand-accent);
}

/* Container de tabelas rolantes */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

/* Regras para telas menores que 992px (Gaveta de Navegação Mobile) */
@media (max-width: 992px) {
  .mobile-menu-toggle {
    display: block; /* Revela o botão */
  }

  .top-nav {
    padding: 0 20px;
    justify-content: space-between;
  }

  /* Gaveta do Menu */
  .nav-links {
    display: none; /* Oculta em desktop */
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    background: #111827;
    flex-direction: column;
    height: calc(100vh - var(--header-h));
    padding: 20px 20px 100px 20px; /* Padding extra embaixo por causa do logout */
    gap: 10px;
    z-index: 999;
    border-top: 1px solid var(--border);
    overflow-y: auto;
  }

  .nav-links.mobile-open {
    display: flex; /* Abre o menu */
    animation: slideDownMenu 0.3s ease-out forwards;
  }

  .nav-item {
    width: 100%;
    height: 50px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    padding: 0 15px;
    text-align: left;
    display: flex;
    align-items: center;
    border-radius: 6px;
  }

  .nav-item:hover,
  .nav-item.active {
    border-left-color: var(--brand-accent);
    border-bottom-color: var(--border);
    background: rgba(238, 36, 94, 0.05);
  }

  /* Botão de Logout e Status WA no Menu Móvel */
  .nav-user {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #141A29;
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.4);
    justify-content: space-between;
    align-items: center;
  }

  .nav-user.mobile-open {
    display: flex;
    animation: fadeInUp 0.3s ease-out forwards;
  }

  .btn-logout {
    flex: 1;
    text-align: center;
    padding: 12px;
  }
}

@keyframes slideDownMenu {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Regras específicas para celulares (< 768px) */
@media (max-width: 768px) {
  /* Espaçamento geral */
  .main-content {
    padding: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  /* Dashboard Header e Filtros */
  .dashboard-filter-bar,
  .leads-filter-bar {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .dashboard-filter-bar > div,
  .leads-filter-bar > div {
    width: 100% !important;
    justify-content: space-between;
  }

  .dashboard-filter-bar input[type="date"],
  .leads-filter-bar input[type="date"] {
    flex: 1;
    width: 100% !important;
  }

  /* Inputs de Busca e selects do Lead */
  .search-bar {
    width: 100% !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .search-bar input,
  .search-bar select {
    width: 100% !important;
    min-width: 100% !important;
  }

  /* Master-Detail Configs (Carrossel Horizontal Premium) */
  .config-master-detail {
    flex-direction: column;
    gap: 20px;
  }

  .config-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
    min-height: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
  }

  .config-sidebar::-webkit-scrollbar {
    height: 4px;
  }

  .config-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  .config-menu-btn {
    padding: 10px 16px;
    font-size: 13px;
    display: inline-flex;
    flex-shrink: 0;
    border: 1px solid var(--border);
  }

  .config-menu-btn.active {
    box-shadow: none;
  }

  .config-menu-btn.active::after {
    display: none; /* Remove a seta lateral */
  }

  .config-content-panel {
    padding: 20px;
    width: 100%;
  }

  /* Grid KPIs */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  /* Horarios de Atendimento Configs */
  .horario-row {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .horario-day {
    min-width: 120px;
  }

  .horario-time {
    width: calc(50% - 10px);
  }
}

/* Celulares pequenos (< 480px) */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .btn-action {
    width: 100%;
    justify-content: center;
  }

  .cards-grid-3 {
    grid-template-columns: 1fr;
  }
}@keyframes pulse-green {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}
.wa-online {
  color: var(--success) !important;
  animation: pulse-green 2s infinite ease-in-out;
}
.wa-offline {
  color: var(--danger) !important;
  animation: none;
}

/* ─── MENU TRANSBORDOS ─── */
.tb-tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tb-tabs .sub-tab-btn { border: 1px solid transparent; }
.tb-count { background: rgba(255,255,255,0.08); color: var(--text-sec); border-radius: 999px; padding: 0 8px; font-size: 11px; font-weight: 800; line-height: 18px; }
.tb-count-alerta { background: var(--danger); color: #fff; }
.tb-busca { margin-left: auto; min-width: 260px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-main); border-radius: 8px; padding: 8px 12px; font-size: 13px; outline: none; }
.tb-busca:focus { border-color: var(--brand-accent); }
.tb-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
#tb-lista-resolvidos { display: block; }
.tb-vazio { grid-column: 1 / -1; text-align: center; color: var(--text-sec); padding: 48px 16px; background: var(--card-bg); border: 1px dashed var(--border); border-radius: 12px; }
.tb-vazio i { color: var(--success); margin-right: 6px; }
.tb-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tb-card-pendente { border-left: 4px solid var(--warning); }
.tb-card-urgente { border-left-color: var(--danger); background: linear-gradient(180deg, rgba(239,68,68,0.08), var(--card-bg) 60%); box-shadow: 0 0 0 1px rgba(239,68,68,0.25); }
.tb-card-topo { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.tb-nome { font-weight: 800; font-size: 15px; }
.tb-id { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.tb-meta { color: var(--text-sec); font-size: 12px; margin-top: 2px; }
.tb-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tb-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.06); color: var(--text-sec); white-space: nowrap; }
.tb-tag-alerta { background: rgba(239,68,68,0.18); color: #fca5a5; border: 1px solid rgba(239,68,68,0.5); }
.tb-tag-cobranca { background: rgba(245,158,11,0.15); color: #fcd34d; }
.tb-rotulo { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.tb-motivo { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.tb-motivo p { font-size: 14px; line-height: 1.5; color: var(--text-main); }
.tb-motivo em { color: var(--text-sec); }
.tb-citacao { font-size: 13px; color: var(--text-main); border-left: 2px solid var(--border); padding-left: 10px; font-style: italic; }
.tb-linha-sec { font-size: 12px; color: var(--text-sec); }
.tb-linha-sec i { margin-right: 4px; }
.tb-sem-resposta { color: #fca5a5; }
.tb-acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: auto; flex-wrap: wrap; }
.tb-acoes .btn-action { height: 32px; padding: 0 12px; font-size: 12px; }
.tb-btn-resolver { height: 32px; font-size: 11px; padding: 0 12px; }
@media (max-width: 768px) {
  .tb-lista { grid-template-columns: 1fr; }
  .tb-busca { margin-left: 0; min-width: 0; width: 100%; }
  .tb-card-topo { flex-direction: column; }
  .tb-tags { justify-content: flex-start; }
}
.tb-tag-escuta { background: rgba(88,39,134,0.25); color: #c4b5fd; }

/* ─── WHATSAPP DESCONECTADO: faixa de aviso, ícone do topo e selo da Rede de Lojas ─── */
.wa-queda-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px 0;
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #991b1b, #ef4444);
  border: 2px solid #fecaca;
  color: #fff;
  animation: wa-queda-pulso 1.8s infinite;
}
.wa-queda-banner[hidden] { display: none !important; }
.wa-queda-icone { font-size: 40px; line-height: 1; flex-shrink: 0; }
.wa-queda-corpo { flex: 1; min-width: 0; }
.wa-queda-titulo { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; margin-bottom: 4px; }
.wa-queda-texto { font-size: 14px; line-height: 1.45; }
.wa-queda-botao {
  flex-shrink: 0;
  background: #fff;
  color: #991b1b;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.wa-queda-botao:hover { background: #fee2e2; }
@keyframes wa-queda-pulso {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.75); }
  70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* Ícone do topo: desconectado passa a piscar (antes ficava parado) */
.wa-offline { animation: wa-off-pisca 1.2s infinite ease-in-out; }
@keyframes wa-off-pisca {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.rede-wa { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 11px; white-space: nowrap; }
.rede-wa-on { color: #25D366; }
.rede-wa-nd { color: #888; }
.rede-wa-off { color: #fff; background: #dc2626; padding: 3px 8px; border-radius: 20px; animation: wa-off-pisca 1.2s infinite ease-in-out; }
@media (max-width: 768px) {
  .wa-queda-banner { flex-direction: column; align-items: flex-start; }
  .wa-queda-botao { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .wa-queda-banner, .wa-offline, .rede-wa-off { animation: none; }
}

/* ─── AVISO DE NOVA VERSÃO DO PAINEL ─── */
.painel-atualizacao {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 440px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #1e293b;
  border: 1px solid #38bdf8;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: #fff;
}
.painel-atualizacao[hidden] { display: none !important; }
.painel-atualizacao-texto { display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.4; }
.painel-atualizacao-texto strong { font-size: 14px; color: #7dd3fc; }
.painel-atualizacao-botao {
  flex-shrink: 0;
  background: #38bdf8;
  color: #0f172a;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.painel-atualizacao-botao:hover { background: #7dd3fc; }
@media (max-width: 768px) {
  .painel-atualizacao { left: 12px; right: 12px; bottom: 12px; max-width: none; flex-direction: column; align-items: stretch; }
}

/* ─── CABEÇALHO: NADA SAI DA TELA ───
   O menu tem muitos itens. Em telas de computador ele fica mais compacto e, se mesmo assim não couber
   (medido pelo painel em app.js: ajustarCabecalho), vira um menu de gaveta, como no celular.
   A área do usuário (loja, sino, WhatsApp, Sair) fica sempre visível. */
.top-nav { gap: 12px; }
.nav-brand { flex-shrink: 0; }
.nav-item { white-space: nowrap; }
@media (min-width: 993px) {
  .top-nav { padding: 0 20px; }
  .nav-links { flex: 1 1 auto; min-width: 0; gap: 2px; }
  .nav-item { padding: 0 11px; font-size: 13px; flex-shrink: 0; }

  body.nav-gaveta .mobile-menu-toggle { display: block; margin-right: auto; flex-shrink: 0; }
  body.nav-gaveta .nav-links {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 300px;
    max-width: 90vw;
    max-height: calc(100vh - var(--header-h));
    height: auto;
    flex: none;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    background: #111827;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 14px 0;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    z-index: 999;
  }
  body.nav-gaveta .nav-links.mobile-open { display: flex; animation: slideDownMenu 0.2s ease-out forwards; }
  body.nav-gaveta .nav-item {
    width: 100%;
    height: 44px;
    flex-shrink: 0;
    font-size: 14px;
    padding: 0 14px;
    text-align: left;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
    border-radius: 6px;
  }
  body.nav-gaveta .nav-item:hover,
  body.nav-gaveta .nav-item.active {
    border-left-color: var(--brand-accent);
    border-bottom-color: var(--border);
    background: rgba(238, 36, 94, 0.05);
  }
}
@media (min-width: 993px) {
  body.nav-gaveta .mobile-menu-toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; padding: 8px 14px; }
  body.nav-gaveta .mobile-menu-toggle::after { content: attr(data-atual); font-size: 14px; font-weight: 700; color: var(--text-main); font-family: inherit; white-space: nowrap; }
}

/* ─── TABELAS DE LEADS E AGENDAMENTOS: CABEM MELHOR NA TELA E AS AÇÕES FICAM SEMPRE À VISTA ───
   As duas tabelas têm muitas colunas. Em telas de notebook o espaçamento fica mais justo, e a coluna de ações
   fica presa à direita: mesmo quando a tabela rola para o lado, os botões continuam visíveis. */
@media (min-width: 993px) and (max-width: 1700px) {
  #leads-table th, #leads-table td,
  #agendamentos-table th, #agendamentos-table td { padding: 12px 10px; }
  #leads-table td, #agendamentos-table td { font-size: 13px; }
}
@media (min-width: 993px) {
  #leads-table th:last-child, #leads-table td:last-child,
  #agendamentos-table th:last-child, #agendamentos-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--card-bg);
    box-shadow: -10px 0 14px -10px rgba(0, 0, 0, 0.6);
  }
  #leads-table tr:hover td:last-child,
  #agendamentos-table tr:hover td:last-child { background: #1a2133; }
}
/* Passo intermediário do cabeçalho: antes de virar gaveta, o menu tenta caber com os nomes em duas linhas. */
@media (min-width: 993px) {
  body.nav-duas-linhas .nav-links { gap: 0; }
  body.nav-duas-linhas .nav-item { white-space: normal; max-width: 96px; padding: 0 8px; font-size: 12px; line-height: 1.2; text-align: center; }
}
