/* ==========================================================================
   Super Empresa - Design System & Stylesheet (Dark Theme / Glassmorphism)
   ========================================================================== */

:root {
  /* Paleta de Cores Primária - Engenharia & Alta Tecnologia */
  --bg-main: #0B0F19;
  --bg-surface: #111827;
  --bg-surface-elevated: #1F2937;
  --bg-surface-hover: #263346;
  --bg-glass: rgba(17, 24, 39, 0.75);
  --bg-glass-card: rgba(31, 41, 55, 0.6);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: #10B981;
  --border-highlight: rgba(16, 185, 129, 0.3);

  /* Cores de Acento */
  --emerald-primary: #10B981;
  --emerald-dark: #059669;
  --emerald-light: #34D399;
  --emerald-glow: rgba(16, 185, 129, 0.25);

  --blue-primary: #3B82F6;
  --blue-light: #60A5FA;
  --blue-glow: rgba(59, 130, 246, 0.25);

  --gold-primary: #F59E0B;
  --gold-light: #FBBF24;
  --gold-glow: rgba(245, 158, 11, 0.25);

  --purple-primary: #8B5CF6;
  --purple-light: #A78BFA;

  --red-alert: #EF4444;

  /* Tipografia */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Texto */
  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --text-inverse: #0B0F19;

  /* Sombras */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);

  /* Raios de Borda */
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 0px;
  --radius-full: 9999px;

  /* Transições */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset Global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.dark-theme {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Efeitos Luminosos de Fundo (Background Glows) */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}
.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--emerald-primary), transparent 70%);
  top: -100px;
  right: -100px;
}
.bg-glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--blue-primary), transparent 70%);
  bottom: 50px;
  left: -150px;
}
.bg-glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--purple-primary), transparent 70%);
  top: 40%;
  left: 40%;
}

/* ==========================================================================
   Header & Top Navbar
   ========================================================================== */
.top-navbar {
  position: relative;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
}

.navbar-container {
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--emerald-primary), var(--emerald-dark));
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 15px var(--emerald-glow);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-highlight {
  color: var(--emerald-primary);
}

.brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-light);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-highlight);
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.navbar-center-info {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.api-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--emerald-primary);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--emerald-primary);
}

.status-dot.pulse {
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 14px var(--emerald-primary); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.last-sync-badge {
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-primary), var(--emerald-dark));
  color: #FFFFFF;
  box-shadow: 0 4px 15px var(--emerald-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--emerald-light), var(--emerald-primary));
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Dropdown Menu */
.dropdown-export {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 120;
  backdrop-filter: blur(16px);
}
.dropdown-menu.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast);
}
.dropdown-item:hover {
  background: var(--bg-surface-elevated);
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  width: 100%;
  max-width: 100%;
  padding: 1.25rem 1.5rem 3rem;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   KPI Cards Grid
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0px;
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1.15rem;
  box-shadow: none;
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}
.kpi-icon-wrap.icon-gold {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold-primary);
}
.kpi-icon-wrap.icon-purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--purple-primary);
}
.kpi-icon-wrap.icon-amber {
  background: rgba(249, 115, 22, 0.15);
  color: #F97316;
}

.kpi-info {
  flex-grow: 1;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 0.35rem;
}

.kpi-trend {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.text-emerald { color: var(--emerald-light) !important; }
.text-gold { color: var(--gold-light) !important; }
.text-purple { color: var(--purple-light) !important; }
.text-amber { color: #FB923C !important; }
.text-blue { color: var(--blue-light) !important; }
.text-green { color: #22C55E !important; }

/* ==========================================================================
   Toolbar & View Tabs
   ========================================================================== */
.toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 0.5rem 0 1rem 0;
  margin-bottom: 1.25rem;
  width: 100%;
}

.view-tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface-elevated);
  padding: 0.3rem;
  border-radius: var(--radius-md);
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.view-tab:hover {
  color: var(--text-primary);
}
.view-tab.active {
  background: var(--emerald-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 10px var(--emerald-glow);
}

.search-bar-wrap {
  position: relative;
  min-width: 340px;
  flex-grow: 1;
  max-width: 500px;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

#global-search-input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.65rem 2.4rem 0.65rem 2.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
#global-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-clear-search {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  font-size: 0.85rem;
}
.btn-clear-search:hover { color: var(--text-primary); }

/* ==========================================================================
   Filters Panel
   ========================================================================== */
.filters-panel {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 0 0 1.25rem 0;
  margin-bottom: 1.5rem;
  width: 100%;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-select, .form-control {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  width: 100%;
}
.filter-select:focus, .form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}
.form-hint i {
  margin-top: 2px;
  flex-shrink: 0;
  color: var(--blue-light);
}

.filter-results-bar {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.quick-category-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.category-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.category-pill:hover, .category-pill.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-light);
  border-color: var(--border-highlight);
}

/* ==========================================================================
   Views Toggle System
   ========================================================================== */
.view-content {
  display: none;
}
.view-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   VIEW 1: Cards Grid & Licitação Card
   ========================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 1.25rem;
}

.licitacao-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.licitacao-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--emerald-primary), var(--blue-primary));
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.licitacao-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-md);
}
.licitacao-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-badges-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}
.badge-uf {
  background: rgba(59, 130, 246, 0.15);
  color: var(--blue-light);
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-modalidade {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.badge-urgente {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.card-orgao-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.card-orgao-nome {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-municipio {
  font-size: 0.775rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-objeto {
  font-size: 0.85rem;
  color: #D1D5DB;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--emerald-primary);
}

.card-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.tag-categoria {
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-light);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.card-meta-financial {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.card-valor-box {
  display: flex;
  flex-direction: column;
}
.card-valor-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.card-valor-num {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--emerald-light);
}

.card-abertura-box {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.card-abertura-date {
  font-weight: 600;
  color: var(--text-primary);
}

.card-actions-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   VIEW 2: Tabela Dinâmica
   ========================================================================== */
.table-card {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  width: 100%;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 280px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-surface-elevated);
  padding: 0.85rem 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table thead th:hover {
  color: var(--text-primary);
}

.data-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: #E5E7EB;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.td-objeto {
  max-width: 450px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  white-space: normal;
  font-size: 0.8rem;
  line-height: 1.3;
}
.td-objeto mark {
  background-color: #facc15;
  color: #0f172a;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 4px;
  box-shadow: 0 0 6px rgba(250, 204, 21, 0.5);
}

.td-valor {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--emerald-light);
  white-space: nowrap;
}

/* ==========================================================================
   VIEW 3: Funil CRM (Kanban)
   ========================================================================== */
.kanban-header-info {
  margin-bottom: 1rem;
}
.kanban-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kanban-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(280px, 1fr));
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1.5rem;
}

.kanban-col {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.kanban-col-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.85rem;
  border-top: 3px solid transparent;
}
.col-blue { border-top-color: var(--blue-primary); }
.col-amber { border-top-color: var(--gold-primary); }
.col-purple { border-top-color: var(--purple-primary); }
.col-cyan { border-top-color: #06B6D4; }
.col-emerald { border-top-color: var(--emerald-primary); }

.col-metrics {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.col-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}
.col-val {
  font-size: 0.75rem;
  color: var(--emerald-light);
}

.kanban-cards-wrap {
  padding: 0.75rem;
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 120px;
}

.kanban-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: grab;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}
.kanban-card:active {
  cursor: grabbing;
}

.k-card-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.k-card-val {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--emerald-light);
  font-size: 0.95rem;
}

.k-card-footer {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.725rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   VIEW 4: Analytics & Charts
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0px;
  padding: 1.25rem;
  box-shadow: none;
}
.chart-full {
  grid-column: 1 / -1;
}

.chart-header {
  margin-bottom: 1rem;
}
.chart-header h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-body {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ==========================================================================
   Modais (Raio-X, Sincronização & Sheets)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  position: relative;
}
.modal-container.modal-lg {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.modal-title-wrap h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
}
.btn-close-modal:hover { color: var(--text-primary); }

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.detalhes-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.hero-valor {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--emerald-light);
}
.hero-score {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-light);
}

.detalhes-section {
  margin-bottom: 1.25rem;
}
.detalhes-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  background: var(--bg-surface-elevated);
  padding: 0.85rem;
  border-radius: var(--radius-md);
}
.info-item {
  display: flex;
  flex-direction: column;
}
.info-label {
  font-size: 0.725rem;
  color: var(--text-muted);
}
.info-val {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}
.font-mono { font-family: monospace; }
.font-bold { font-weight: 700; }

.objeto-box {
  background: var(--bg-surface-elevated);
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.6;
  color: #E5E7EB;
  max-height: 180px;
  overflow-y: auto;
}

.pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pncp-id-code {
  font-family: monospace;
  background: #06090F;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--blue-light);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 1rem;
}

/* Spinner & Progress Box */
.sync-progress-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface-elevated);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-highlight);
  margin: 1rem 0;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top-color: var(--emerald-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.progress-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}
.progress-desc {
  font-size: 0.775rem;
  color: var(--text-secondary);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  animation: slideInRight 0.3s ease;
  min-width: 300px;
}
.toast-success { border-left: 4px solid var(--emerald-primary); }
.toast-warning { border-left: 4px solid var(--gold-primary); }
.toast-error { border-left: 4px solid var(--red-alert); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-top: 1rem;
}
.empty-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto 1.5rem;
}

/* Responsividade */
@media (max-width: 992px) {
  .navbar-container { flex-direction: column; align-items: stretch; }
  .navbar-center-info { justify-content: space-between; }
  .navbar-actions { justify-content: flex-end; }
  .toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: 0.5rem 0 1rem 0;
  margin-bottom: 1.25rem;
  width: 100%;
}
  .search-bar-wrap { max-width: 100%; min-width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .cards-grid { grid-template-columns: 1fr; }
  .view-tabs { flex-wrap: wrap; }
}

/* ==========================================================================
   APP LAYOUT & SIDEBAR (SPA MODULE)
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-body);
}

.app-sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  z-index: 100;
  position: relative;
}

.app-sidebar.collapsed {
  width: 80px;
}

.sidebar-header {
  height: 80px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-header {
  padding: 0;
  justify-content: center;
}

.app-sidebar.collapsed .brand-text {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-group {
  margin-bottom: 2rem;
}

.nav-group-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
  font-weight: 600;
  white-space: nowrap;
}

.app-sidebar.collapsed .nav-group-title {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  color: #d1d5db;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-item i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-subitem:hover {
  color: #fff !important;
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15); /* var(--primary-color) with opacity */
  color: var(--primary-light);
  border-left: 3px solid var(--primary-color);
}

.app-sidebar.collapsed .nav-item {
  padding: 0.75rem;
  justify-content: center;
}

.app-sidebar.collapsed .nav-text {
  display: none;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

.app-sidebar.collapsed .sidebar-footer {
  justify-content: center;
}

.btn-sidebar-toggle {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.app-sidebar.collapsed .btn-sidebar-toggle i {
  transform: rotate(180deg);
}

.app-main-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Update top navbar for new layout */
.top-navbar {
  /* It is now inside a flex column, so it can just be block/flex. 
     We can remove sticky if we want, or keep it. */
  width: 100%;
}
.top-navbar .navbar-container {
  /* Make sure it justifies content correctly now that brand is gone */
  justify-content: space-between;
}

/* The actual scrollable content */
.main-content {
  width: 100%;
  max-width: 100%;
  padding: 1.25rem 1.5rem 3rem;
  position: relative;
  z-index: 1;
}

.app-module {
  display: none;
  animation: fadeIn 0.3s ease;
}

.app-module.active-module {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.module-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
  color: #9ca3af;
  background: var(--bg-surface);
  border-radius: 16px;
  border: 1px dashed var(--border-color);
  padding: 2rem;
  margin-top: 2rem;
}

.module-placeholder h2 {
  color: #fff;
  margin-bottom: 0.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   MÓDULO WHATSAPP
   ========================================================================== */

/* Toggle Switch para IA */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #374151;
  transition: .4s;
  border-radius: 24px;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
.switch input:checked + .slider {
  background-color: #a855f7;
}
.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Chat Items */
.wa-chat-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}
.wa-chat-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}
.wa-chat-item.active {
  background: rgba(56, 189, 248, 0.12);
  border-left: 3px solid #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}
.wa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #334155, #475569);
  color: #f8fafc;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  margin-right: 0.75rem;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.wa-chat-info {
  flex: 1;
  min-width: 0;
}
.wa-chat-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}
.wa-chat-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-time {
  font-size: 0.72rem;
  color: #64748b;
}
.wa-chat-preview {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-badges {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.wa-badge-ai {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
  border: 1px solid rgba(168, 85, 247, 0.3);
}
.wa-badge-unread {
  background: #10b981;
  color: #FFF;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}

/* Chat Bubbles */
.wa-bubble {
  max-width: 72%;
  padding: 0.7rem 1rem;
  border-radius: 14px;
  position: relative;
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 0.3rem;
  clear: both;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  word-break: break-word;
}
.wa-bubble-them {
  background: #1e293b;
  color: #f8fafc;
  align-self: flex-start;
  border-top-left-radius: 3px;
  border: 1px solid rgba(255,255,255,0.06);
}
.wa-bubble-me {
  background: #005c4b;
  color: #f8fafc;
  align-self: flex-end;
  border-top-right-radius: 3px;
}
.wa-bubble-time {
  display: block;
  font-size: 0.64rem;
  color: rgba(255,255,255,0.65);
  text-align: right;
  margin-top: 4px;
}

.wa-filter-btn.active {
  background: rgba(56, 189, 248, 0.2) !important;
  color: #38bdf8 !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  font-weight: 600;
}
