/**
 * MAIN DASHBOARD — Design System V1.0
 * Ultra-dark premium SaaS theme with glassmorphism and neon accents.
 * NEW design system — NOT a copy of Workana CSS.
 * Structural layout replication, independent visual identity.
 */

/* ─── CSS Reset & Design Tokens ──────────────────────────────────────── */
/* =====================================================================
   DESIGN SYSTEM v2 — Arquitetura de tokens em 3 camadas
   CAMADA 1 (:root)  → PRIMITIVAS: escala crua da marca. Fonte única da verdade.
   CAMADA 2 (theme)  → SEMÂNTICAS: --bg-*, --text-*, --accent... por tema.
   CAMADA 3 (comp.)  → tokens de componente (--kpi-*) referenciam as semânticas.
   Refino inspirado no Real Oficial (near-black + roxo minimalista).
   ===================================================================== */
:root {
    /* ===== CAMADA 1 — PRIMITIVAS ===== */
    /* Neutros (near-black levemente azulado → branco) */
    --neutral-950:#08080b; --neutral-900:#0c0c10; --neutral-870:#0f0f14;
    --neutral-850:#111116; --neutral-820:#15151b; --neutral-800:#18181f;
    --neutral-750:#1e1e26; --neutral-700:#26262f; --neutral-650:#2f2f3a;
    --neutral-600:#3a3a46; --neutral-500:#565663; --neutral-400:#8a8a97;
    --neutral-300:#a9a9b6; --neutral-200:#c9c9d4; --neutral-100:#e8e8ee;
    --neutral-50:#fafafa;

    /* Violeta (accent de marca) */
    --violet-300:#c4b5fd; --violet-400:#a78bfa; --violet-500:#8b5cf6;
    --violet-600:#7c3aed; --violet-700:#6d28d9; --violet-800:#5b21b6;

    /* Magenta (gradiente de destaque) */
    --magenta-400:#f0abfc; --magenta-500:#e879f9; --magenta-600:#d946ef;

    /* Gradientes de marca */
    --grad-primary: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --grad-primary-hover: linear-gradient(135deg, #9d6ff8 0%, #8b47f0 100%);
    --grad-heading: linear-gradient(120deg, #f0abfc 0%, #a78bfa 50%, #8b5cf6 100%);

    /* Layout Dimensions */
    --mini-sidebar-width: 60px;
    --sidebar-width: 256px;

    /* Sizing & Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    /* Fonts */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Outfit', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Motion */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: all 0.3s var(--ease);
    --transition-fast: all 0.15s var(--ease);
}

/* Theme Mappings */
html[data-theme="dark"] {
    /* ===== CAMADA 2 — SEMÂNTICAS (DARK / Real Oficial) ===== */
    /* Surfaces */
    --bg-root: var(--neutral-950);
    --bg-body: var(--neutral-900);
    --bg-surface: var(--neutral-850);
    --bg-card: var(--neutral-850);
    --card-bg: var(--neutral-850);
    --bg-card-hover: var(--neutral-820);
    --bg-input: var(--neutral-820);
    --bg-elevated: var(--neutral-800);

    /* ALIASES CURTOS — usados por css/modules/social.css (Automação IG/TikTok).
       Aquele arquivo escreve var(--bg,#0d1117) e var(--card,#161b22) em 41
       lugares. Como --bg e --card nunca existiram em tema nenhum, o fallback
       ESCURO vencia sempre: no dark passava despercebido (por coincidência
       combinava), no light deixava o módulo inteiro com fundo preto.
       Definindo os aliases aqui, os 41 usos passam a seguir o tema. */
    --bg: var(--bg-root);
    --card: var(--bg-card);

    /* Sidebars */
    --mini-sidebar-bg: var(--neutral-950);
    --sidebar-bg: var(--neutral-900);
    --bg-topbar: rgba(12, 12, 16, 0.72);
    --bg-nav-content: rgba(0, 0, 0, 0.2);

    /* Borders */
    --border: var(--neutral-700);
    --border-accent: rgba(139, 92, 246, 0.22);
    --border-hover: var(--neutral-600);
    --border-subtle: var(--neutral-750);

    /* Text */
    --text: var(--neutral-50);
    --text-primary: var(--neutral-50);
    --text-secondary: var(--neutral-300);
    --text-muted: var(--neutral-400);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.6);

    /* Accent & Semantics */
    --accent: var(--violet-500);
    --accent-rgb: 139, 92, 246;
    --accent-hover: var(--violet-600);
    --accent-text: var(--violet-400);
    --accent-dim: rgba(139, 92, 246, 0.12);
    --accent-glow: rgba(139, 92, 246, 0.28);
    --accent-strong: rgba(139, 92, 246, 0.4);

    /* Gradientes & glow (marca) */
    --grad-accent: var(--grad-primary);
    --grad-accent-hover: var(--grad-primary-hover);
    --glow-top: radial-gradient(80% 380px at 50% -120px, rgba(124,58,237,0.30), transparent 70%);

    --cyan: #00f5ff;
    --cyan-dim: rgba(0, 245, 255, 0.1);
    --orange: #ff8c00;
    --orange-dim: rgba(255, 140, 0, 0.1);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.1);
    --purple: #b266ff;
    --purple-dim: rgba(178, 102, 255, 0.1);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245, 158, 11, 0.1);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.1);
    --green: #22c55e;
    --green-rgb: 34, 197, 94;
    --green-dim: rgba(34, 197, 94, 0.1);

    /* Subtle highlights in dark mode */
    --kpi-purple-bg: var(--bg-surface);
    --kpi-purple-border: rgba(139, 92, 246, 0.25);
    --kpi-purple-text: #a78bfa;

    --kpi-cyan-bg: var(--bg-surface);
    --kpi-cyan-border: rgba(6, 182, 212, 0.25);
    --kpi-cyan-text: #22d3ee;

    --kpi-orange-bg: var(--bg-surface);
    --kpi-orange-border: rgba(249, 115, 22, 0.25);
    --kpi-orange-text: #fb923c;

    --kpi-green-bg: var(--bg-surface);
    --kpi-green-border: rgba(34, 197, 94, 0.25);
    --kpi-green-text: #4ade80;

    --kpi-yellow-bg: var(--bg-surface);
    --kpi-yellow-border: rgba(234, 179, 8, 0.25);
    --kpi-yellow-text: #fef08a;

    --kpi-blue-bg: var(--bg-surface);
    --kpi-blue-border: rgba(59, 130, 246, 0.25);
    --kpi-blue-text: #93c5fd;
}

html[data-theme="light"] {
    /* ===== CAMADA 2 — SEMÂNTICAS (LIGHT) ===== */
    /* Surfaces */
    --bg-root: #f2f0fb;
    --bg-body: #f6f5fc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --card-bg: #ffffff;
    --bg-card-hover: #faf9ff;
    --bg-input: #ffffff;
    --bg-elevated: #fbfbfe;

    /* ALIASES CURTOS — ver comentário no bloco dark. É esta linha que conserta
       o Light Mode da Automação (IG/TikTok). */
    --bg: var(--bg-root);
    --card: var(--bg-card);

    /* Sidebars */
    --mini-sidebar-bg: #f2f0fb;
    --sidebar-bg: #ffffff;
    --bg-topbar: rgba(246, 245, 252, 0.8);
    --bg-nav-content: rgba(124, 58, 237, 0.03);

    /* Borders */
    --border: #e4e2f2;
    --border-accent: rgba(124, 58, 237, 0.18);
    --border-hover: #cbd5e1;
    --border-subtle: #eeecf8;

    /* Text */
    --text: #141225;
    --text-primary: #141225;
    --text-secondary: #4b4863;
    --text-muted: #7c7994;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(124, 58, 237, 0.05);
    --shadow-md: 0 10px 25px rgba(124, 58, 237, 0.06), 0 2px 6px rgba(124, 58, 237, 0.03);
    --shadow-lg: 0 16px 40px rgba(124, 58, 237, 0.08), 0 4px 16px rgba(124, 58, 237, 0.05);

    /* Accent & Semantics (roxo — consistente com o dark) */
    --accent: var(--violet-600);
    --accent-rgb: 124, 58, 237;
    --accent-hover: var(--violet-700);
    --accent-text: var(--violet-600);
    --accent-dim: rgba(124, 58, 237, 0.08);
    --accent-glow: rgba(124, 58, 237, 0.15);
    --accent-strong: rgba(124, 58, 237, 0.28);

    /* Gradientes & glow (marca) */
    --grad-accent: linear-gradient(135deg, #8b5cf6, #6d28d9);
    --grad-accent-hover: linear-gradient(135deg, #7c3aed, #5b21b6);
    --glow-top: radial-gradient(80% 380px at 50% -140px, rgba(139,92,246,0.16), transparent 70%);

    --cyan: #0891b2;
    --cyan-dim: rgba(8, 145, 178, 0.1);
    --orange: #ea580c;
    --orange-dim: rgba(234, 88, 12, 0.1);
    --red: #e11d48;
    --red-dim: rgba(225, 29, 72, 0.1);
    --purple: #7c3aed;
    --purple-dim: rgba(124, 58, 237, 0.1);
    --yellow: #d97706;
    --yellow-dim: rgba(217, 119, 6, 0.1);
    --blue: #2563eb;
    --blue-dim: rgba(37, 99, 235, 0.1);
    --green: #16a34a;
    --green-rgb: 22, 163, 74;
    --green-dim: rgba(22, 163, 74, 0.1);

    /* Pastel Accents for KPI cards in light mode */
    --kpi-purple-bg: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 100%);
    --kpi-purple-border: #c7d2fe;
    --kpi-purple-text: #4f46e5;

    --kpi-cyan-bg: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
    --kpi-cyan-border: #a5f3fc;
    --kpi-cyan-text: #0891b2;

    --kpi-orange-bg: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    --kpi-orange-border: #fed7aa;
    --kpi-orange-text: #ea580c;

    --kpi-green-bg: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    --kpi-green-border: #bbf7d0;
    --kpi-green-text: #16a34a;

    --kpi-yellow-bg: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    --kpi-yellow-border: #fde68a;
    --kpi-yellow-text: #b45309;

    --kpi-blue-bg: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    --kpi-blue-border: #bfdbfe;
    --kpi-blue-text: #1d4ed8;
}

/* --- SIDEBAR GROUPS / ACCORDION --- */
.nav-group {
    margin-bottom: 6px;
    border-radius: 12px;
    overflow: hidden;
    transition: var(--transition);
    flex-shrink: 0;
}

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    text-align: left;
    border-radius: 12px;
}

.nav-group-header:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-group-header i.fa-chevron-down {
    font-size: 0.65rem;
    transition: transform 0.3s var(--ease);
    opacity: 0.5;
}

.nav-group.active .nav-group-header i.fa-chevron-down {
    transform: rotate(180deg);
    opacity: 1;
}

.nav-group.active .nav-group-header {
    background: transparent;
    color: var(--text-primary);
}

.nav-group.active .nav-group-header i:first-child {
    color: var(--accent);
}

.nav-group-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s var(--ease), opacity 0.3s var(--ease);
    opacity: 0;
    overflow: hidden;
    background: var(--bg-nav-content);
    border-radius: 0 0 12px 12px;
}

.nav-group.active .nav-group-content {
    grid-template-rows: 1fr;
    opacity: 1;
}

.nav-group-content-inner {
    min-height: 0;
    overflow-y: visible;
    overflow-x: hidden;
    padding: 6px 6px 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Level 1 Items & Level 2 Nested Submenus --- */
.nav-item-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Submenu container (Level 2) */
.sub-nav-content {
    margin-left: 10px;
    padding-left: 8px;
    border-left: 2px solid rgba(139, 92, 246, 0.25);
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    margin-bottom: 5px;
    max-height: 165px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    animation: fadeInSubNav 0.2s ease;
}

.sub-nav-content::-webkit-scrollbar {
    width: 3px;
}

.sub-nav-content::-webkit-scrollbar-track {
    background: transparent;
}

.sub-nav-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sub-nav-content::-webkit-scrollbar-thumb:hover {
    background: var(--nexus-ciano, #00f0ff);
}

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

.sub-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 5px 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 5px;
    transition: all 0.15s ease;
    cursor: pointer;
    min-height: 28px;
}

.sub-nav-item i {
    font-size: 0.74rem;
    opacity: 0.7;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.sub-nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.sub-nav-item:hover i {
    opacity: 1;
    transform: scale(1.1);
}

.sub-nav-item.active {
    color: var(--nexus-ciano, #00f0ff) !important;
    background: rgba(0, 240, 255, 0.08);
    font-weight: 600;
    border: 1px solid rgba(0, 240, 255, 0.15);
}

.sub-nav-item.active i {
    opacity: 1;
    color: var(--nexus-ciano, #00f0ff);
}

/* --- Nav Category Labels (V2 Grouped Sidebar) --- */
/* Rótulos coloridos que separam módulos dentro de uma mesma gaveta.
   Ex: "Google Maps Leads" e "Workana Bot" ambos dentro de "Captação". */
.nav-category-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-text);
    padding: 6px 10px 4px;
    margin-top: 14px;
    margin-bottom: 2px;
    border-bottom: 1px solid var(--border-accent);
}

.nav-category-label:first-child {
    margin-top: 4px;
}

.nav-category-label i {
    font-size: 0.72rem;
    opacity: 0.85;
}

/* --- KANBAN / CRM --- */
.crm-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: start;
    min-height: calc(100vh - 300px);
}

.kanban-column {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 16px;
    min-height: 500px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.kanban-column-header h3 {
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 400px;
}

.lead-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: grab;
    transition: all 0.2s ease;
}

.lead-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.lead-card:active {
    cursor: grabbing;
}

.lead-card-header {
    margin-bottom: 10px;
}

.lead-card-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 2px;
}

.lead-card-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.lead-card-body {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

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

.badge-wa {
    background: #25d36622;
    color: #25d366;
    border: 1px solid #25d36644;
}

.dragging {
    opacity: 0.5;
}

[data-status="captado"] h3 { color: var(--yellow); }
/* --- AI CHAT FLOATING --- */
#ai-chat-trigger {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(var(--accent-rgb), 0.3);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-chat-trigger:hover {
    transform: scale(1.1) rotate(10deg);
}

#ai-chat-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    height: 500px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    z-index: 9998;
    box-shadow: 0 12px 48px rgba(0,0,0,0.4);
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#ai-chat-container.active,
#ai-chat-container.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#ai-chat-trigger.active,
#ai-chat-trigger.open {
    background: var(--bg-surface);
    color: var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.4);
}

.ai-chat-header {
    padding: 16px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    border-bottom-left-radius: 2px;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 2px;
}



.ai-chat-footer button {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: #000;
}

/* ─── Design System v2.0 Standardized Components ─────────────────────── */

/* Buttons */
button:not([class*="orion"]):not([class*="ig-massa"]):not(#orion-support-launcher), .btn:not([class*="orion"]):not([class*="ig-massa"]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-weight: 500;
    font-size: var(--font-size-body);
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: none;
    gap: 8px;
}

.btn-primary, button:not(.btn-secondary):not(.btn-danger):not([background]):not(#ai-chat-close):not(.btn-outline):not(.btn-icon):not([class*="orion"]):not([class*="ig-massa"]):not(#orion-support-launcher) {
    background: var(--grad-accent) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover, button:not(.btn-secondary):not(.btn-danger):not([background]):not(#ai-chat-close):not(.btn-outline):not(.btn-icon):not([class*="orion"]):not([class*="ig-massa"]):not(#orion-support-launcher):hover {
    background: var(--grad-accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 22px var(--accent-glow);
}

.btn-secondary {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

.btn-secondary:hover {
    background: var(--bg-card-hover) !important;
    border-color: var(--border-hover) !important;
}

.btn-danger {
    background: var(--red) !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
    transform: translateY(-1px);
}

/* Cards */
.card, .dashboard-card, .leads-card, .crm-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    padding: var(--space-4);
    box-shadow: var(--shadow-md);
    transition: var(--transition-normal);
}

.card:hover, .dashboard-card:hover, .leads-card:hover:not(.dragging) {
    border-color: var(--border-hover) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Inputs, Selects, Textareas */
input:not([class*="orion"]):not([class*="ig-massa"]):not(#orion-home-file):not(#orion-chat-file), select:not([class*="orion"]):not([class*="ig-massa"]), textarea:not([class*="orion"]):not([class*="ig-massa"]), .input:not([class*="orion"]):not([class*="ig-massa"]) {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) var(--space-3);
    color: var(--text-primary) !important;
    font-family: var(--font);
    outline: none;
    transition: var(--transition-fast);
}

input:not([class*="orion"]):not([class*="ig-massa"]):focus, select:not([class*="orion"]):not([class*="ig-massa"]):focus, textarea:not([class*="orion"]):not([class*="ig-massa"]):focus, .input:not([class*="orion"]):not([class*="ig-massa"]):focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-dim) !important;
}

/* Tables */
table, .table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-body);
}

th, td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    text-align: left;
    color: var(--text-primary);
}

th {
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    background: var(--bg-elevated);
}

th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
th:last-child  { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

tr:hover td {
    background: var(--bg-card-hover);
}

/* Badges / Tags */
.badge, .tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: var(--font-size-small);
    font-weight: 500;
    border-radius: var(--radius-full);
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(22, 163, 74, 0.2); }
.badge-warning { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(217, 119, 6, 0.2); }
.badge-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(220, 38, 38, 0.2); }
.badge-info { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(37, 99, 235, 0.2); }

/* Skeletons */
.skeleton-shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-surface) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-sm);
    height: 18px;
    width: 100%;
    display: inline-block;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ─── CSS Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font-family: var(--font);
    background: var(--bg-root);
    color: var(--text);
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ─── MINI SIDEBAR (Integrations Layer) ──────────────────────────────── */
#mini-sidebar {
    width: var(--mini-sidebar-width);
    min-width: var(--mini-sidebar-width);
    background: var(--mini-sidebar-bg);
    border-right: 1px solid rgba(255,255,255,0.03);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    height: 100vh;
    gap: 8px;
    z-index: 300;
    position: relative;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
}

#mini-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(var(--accent-rgb), 0.08), transparent);
}

.mini-nav-item {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    border: 1px solid transparent;
    position: relative;
    font-size: 1.15rem;
}

/* C1: Workana Colorful Icon Fix (Removing white background via blending) */
.workana-icon-mini {
    width: 20px;
    height: 20px;
    object-fit: contain;
    filter: brightness(1.1) contrast(1.1);
    mix-blend-mode: screen; /* In dark mode, this makes white/light backgrounds disappear */
    transition: var(--transition);
}

.mini-nav-item:hover .workana-icon-mini {
    transform: scale(1.1);
    filter: brightness(1.3) contrast(1.2);
}

.mini-nav-item i {
    transition: var(--transition);
}

.mini-nav-item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.mini-nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: rgba(var(--accent-rgb), 0.15);
    box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.06);
}

.mini-nav-item .tooltip {
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
    border: 1px solid var(--border);
    z-index: 999;
}

.mini-nav-item:hover .tooltip {
    opacity: 1;
}

.mini-divider {
    width: 28px;
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

.mini-spacer { flex: 1; }

/* ─── MODULE SWITCHER ───────────────────────────────────────────────── */
.module-switcher {
    display: flex;
    gap: 8px;
    padding: 0 10px;
    margin-bottom: 24px;
}

.module-opt {
    flex: 1;
    height: 48px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    color: var(--text-muted);
}

.module-opt:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.module-opt.active {
    background: var(--bg-card);
    border-color: rgba(var(--accent-rgb), 0.25);
    color: var(--accent);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.module-opt i { font-size: 1.15rem; }

.module-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    transition: var(--transition);
}

.module-opt.active .module-dot {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* ─── MAIN SIDEBAR (Core System) ─────────────────────────────────────── */
/* ─────────────────────────────────────────────────────────────────────────
   Sidebar SEMPRE escura — mesmo no modo claro. Só o conteúdo da direita muda.
   Reaplica a paleta escura (Camada 2) apenas nos containers das barras laterais,
   então todos os filhos (que usam var(--...)) renderizam escuros.
   ───────────────────────────────────────────────────────────────────────── */
html[data-theme="light"] #sidebar,
html[data-theme="light"] #mini-sidebar {
    --bg-root: var(--neutral-950);
    --bg-body: var(--neutral-900);
    --bg-surface: var(--neutral-850);
    --bg-card: var(--neutral-850);
    --card-bg: var(--neutral-850);
    --bg-card-hover: var(--neutral-820);
    --bg-input: var(--neutral-820);
    --bg-elevated: var(--neutral-800);
    --mini-sidebar-bg: var(--neutral-950);
    --sidebar-bg: var(--neutral-900);
    --sidebar-border: 1px solid var(--neutral-700);
    --bg-nav-content: rgba(0, 0, 0, 0.2);
    --border: var(--neutral-700);
    --border-hover: var(--neutral-600);
    --border-subtle: var(--neutral-750);
    --text: var(--neutral-50);
    --text-primary: var(--neutral-50);
    --text-secondary: var(--neutral-300);
    --text-muted: var(--neutral-400);
    --accent: var(--violet-500);
    --accent-text: var(--violet-400);
    --accent-dim: rgba(139, 92, 246, 0.12);
    --accent-glow: rgba(139, 92, 246, 0.28);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    color: var(--text);
}

#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    height: 100vh;
    z-index: 200;
    box-shadow: 10px 0 40px rgba(0,0,0,0.3);
    transition: margin-left 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.22s ease,
                visibility 0.28s ease,
                box-shadow 0.28s ease;
    will-change: margin-left, opacity;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 11px;
    padding: 0 10px;
    margin-bottom: 36px;
}

.sidebar-collapse-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
    border-color: var(--border, rgba(255, 255, 255, 0.12));
    color: var(--accent);
    transform: translateX(-2px);
}

@media (max-width: 768px) {
    .sidebar-collapse-btn {
        display: none !important;
    }
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-dim), rgba(var(--accent-rgb), 0.02));
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.sidebar-brand-text small {
    font-size: 0.55rem;
    opacity: 0.35;
    letter-spacing: 2px;
    margin-left: 5px;
    font-weight: 500;
}

.sidebar-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 0 12px;
    margin-bottom: 10px;
    margin-top: 8px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.55) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(var(--accent-rgb), 0.45);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.88rem;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.nav-item i {
    font-size: 0.95rem;
    opacity: 0.55;
    transition: var(--transition);
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.025);
    color: var(--text);
}

.nav-item:hover i { opacity: 0.85; }

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.1);
    font-weight: 500;
}

.nav-item.active i { opacity: 1; color: var(--accent); }

.nav-spacer { flex: 1; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

/* ─── Sidebar Profile Card (rodapé) ───────────────────────────────────── */
.sidebar-profile {
    position: relative;
    margin-top: 8px;
}

.sidebar-profile-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.sidebar-profile-card:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
}

.sidebar-profile-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: var(--grad-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-profile-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.sidebar-profile-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-email {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-chevron {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-profile.open .sidebar-profile-chevron {
    transform: rotate(180deg);
}

.sidebar-profile-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-elevated, #14141f);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.4);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 500;
}

.sidebar-profile-popover.open {
    display: flex;
}

.sidebar-profile-popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.sidebar-profile-popover-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.sidebar-profile-popover-item.danger {
    color: var(--red);
}

.sidebar-profile-popover-item.danger:hover {
    background: rgba(255, 56, 96, 0.1);
}

/* ─── Utilitários compartilhados: Perfil / Gestão de Usuários / Monitoramento ── */
.settings-header-label {
    font-size: 0.65rem;
    font-weight: 900;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 14px;
    font-weight: 800;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
}

.action-btn:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    color: var(--accent);
}

/* Linhas de formulário padrão (Meu Perfil, Novo/Editar Usuário) */
.profile-form-row {
    margin-bottom: 18px;
}

.profile-form-row label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.profile-form-row input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
}

.profile-form-row input[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.role-select-row {
    display: flex;
    gap: 20px;
    margin: 4px 0 20px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.role-select-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Checkboxes/radios com acento na cor do sistema (permissões, papel do usuário) */
input[type="checkbox"], input[type="radio"] {
    accent-color: var(--accent);
    cursor: pointer;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ─── Pulse Dot ──────────────────────────────────────────────────────── */
.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
    flex-shrink: 0;
}

.pulse-dot.orange { background: var(--orange); animation-name: pulse-orange; }
.pulse-dot.red { background: var(--red); animation-name: pulse-red; }
.pulse-dot.purple { background: var(--purple); animation-name: pulse-purple; }

@keyframes pulse {
    0%   { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55); }
    70%  { transform: scale(1);   box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

@keyframes pulse-orange {
    0%   { box-shadow: 0 0 0 0 rgba(255, 140, 0, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 140, 0, 0); }
}

@keyframes pulse-red {
    0%   { box-shadow: 0 0 0 0 rgba(255, 56, 96, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(255, 56, 96, 0); }
}

@keyframes pulse-purple {
    0%   { box-shadow: 0 0 0 0 rgba(178, 102, 255, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(178, 102, 255, 0); }
}

#status-label {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

/* ─── Main Content ───────────────────────────────────────────────────── */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-body);
    position: relative;
}

#topbar {
    height: 64px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-topbar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 100;
    flex-shrink: 0;
}

/* ─── Sidebar Toggle Button (Desktop & Base) ─────────────────────────── */
.sidebar-toggle-btn,
#sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    margin-right: 4px;
}

.sidebar-toggle-btn:hover,
#sidebar-toggle:hover {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.06));
    border-color: var(--border, rgba(255, 255, 255, 0.1));
    color: var(--text-primary, #fff);
    transform: translateY(-1px);
}

.sidebar-toggle-btn:active,
#sidebar-toggle:active {
    transform: translateY(0) scale(0.96);
}

html[data-theme="light"] .sidebar-toggle-btn:hover,
html[data-theme="light"] #sidebar-toggle:hover {
    background: #e6e3f3;
    border-color: #dcd8ee;
    color: #141225;
}

/* ─── Desktop Sidebar Collapse Mechanism ─────────────────────────────── */
@media (min-width: 769px) {
    html.sidebar-collapsed #sidebar,
    body.sidebar-collapsed #sidebar {
        margin-left: calc(-1 * var(--sidebar-width, 256px));
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        box-shadow: none;
    }

    #main-content {
        transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                    max-width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }

    html.sidebar-collapsed #main-content,
    body.sidebar-collapsed #main-content {
        width: 100vw;
        max-width: 100vw;
    }

    body.sidebar-collapsed #sidebar-toggle,
    html.sidebar-collapsed #sidebar-toggle {
        color: var(--accent);
        background: var(--accent-dim, rgba(139, 92, 246, 0.12));
        border-color: var(--border-accent, rgba(139, 92, 246, 0.3));
    }

    body.sidebar-collapsed #sidebar-toggle:hover,
    html.sidebar-collapsed #sidebar-toggle:hover {
        background: var(--accent-dim, rgba(139, 92, 246, 0.22));
        border-color: var(--accent);
        color: #fff;
    }
}

#page-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-card);
    padding: 5px 13px;
    border-radius: 50px;
    font-size: 0.68rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.topbar-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

#app {
    flex: 1;
    padding: 34px 40px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ─── Page Transitions ───────────────────────────────────────────────── */
.page-container {
    animation: pageIn 0.35s var(--ease);
}

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

/* ─── KPI Cards ──────────────────────────────────────────────────────── */
.section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.section-label::before {
    content: '';
    width: 3px;
    height: 14px;
    border-radius: 2px;
    background: var(--grad-accent);
    flex-shrink: 0;
}

.section-label i { font-size: 0.82rem; color: var(--accent-text); }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

html[data-theme="light"] .kpi-card:not(.purple):not(.cyan):not(.orange):not(.green):not(.yellow):not(.blue) {
    background: linear-gradient(135deg, #f5f6ff 0%, #ffffff 100%) !important;
    border-color: rgba(99, 102, 241, 0.12) !important;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.25s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-accent);
    box-shadow: 0 12px 36px rgba(var(--accent-rgb), 0.18), 0 0 0 1px var(--accent-strong);
}

.kpi-card:hover::before { opacity: 1; }

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.kpi-icon.green  { background: var(--accent-dim); color: var(--accent); }
.kpi-icon.cyan   { background: var(--cyan-dim); color: var(--cyan); }
.kpi-icon.orange { background: var(--orange-dim); color: var(--orange); }
.kpi-icon.purple { background: var(--purple-dim); color: var(--purple); }
.kpi-icon.yellow { background: var(--yellow-dim); color: var(--yellow); }
.kpi-icon.red    { background: var(--red-dim); color: var(--red); }
.kpi-icon.blue   { background: var(--blue-dim); color: var(--blue); }

.kpi-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.05;
    background: var(--grad-heading);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    width: fit-content;
}

/* Variantes com cor semântica restauram cor sólida (mantêm o significado) */
.kpi-value.accent, .kpi-value.cyan, .kpi-value.orange, .kpi-value.purple,
.kpi-card.purple .kpi-value, .kpi-card.cyan .kpi-value, .kpi-card.orange .kpi-value,
.kpi-card.green .kpi-value, .kpi-card.yellow .kpi-value, .kpi-card.blue .kpi-value {
    background: none;
    -webkit-text-fill-color: currentColor;
}

.kpi-value.accent { color: var(--accent); }
.kpi-value.cyan   { color: var(--cyan); }
.kpi-value.orange { color: var(--orange); }
.kpi-value.purple { color: var(--purple); }

.kpi-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Colorized KPI card variants */
.kpi-card.purple {
    background: var(--kpi-purple-bg) !important;
    border-color: var(--kpi-purple-border) !important;
}
.kpi-card.purple .kpi-value {
    color: var(--kpi-purple-text) !important;
}
.kpi-card.purple .kpi-icon {
    background: var(--kpi-purple-text) !important;
    color: #ffffff !important;
}

.kpi-card.cyan {
    background: var(--kpi-cyan-bg) !important;
    border-color: var(--kpi-cyan-border) !important;
}
.kpi-card.cyan .kpi-value {
    color: var(--kpi-cyan-text) !important;
}
.kpi-card.cyan .kpi-icon {
    background: var(--kpi-cyan-text) !important;
    color: #ffffff !important;
}

.kpi-card.orange {
    background: var(--kpi-orange-bg) !important;
    border-color: var(--kpi-orange-border) !important;
}
.kpi-card.orange .kpi-value {
    color: var(--kpi-orange-text) !important;
}
.kpi-card.orange .kpi-icon {
    background: var(--kpi-orange-text) !important;
    color: #ffffff !important;
}

.kpi-card.green {
    background: var(--kpi-green-bg) !important;
    border-color: var(--kpi-green-border) !important;
}
.kpi-card.green .kpi-value {
    color: var(--kpi-green-text) !important;
}
.kpi-card.green .kpi-icon {
    background: var(--kpi-green-text) !important;
    color: #ffffff !important;
}

.kpi-card.yellow {
    background: var(--kpi-yellow-bg) !important;
    border-color: var(--kpi-yellow-border) !important;
}
.kpi-card.yellow .kpi-value {
    color: var(--kpi-yellow-text) !important;
}
.kpi-card.yellow .kpi-icon {
    background: var(--kpi-yellow-text) !important;
    color: #ffffff !important;
}

.kpi-card.blue {
    background: var(--kpi-blue-bg) !important;
    border-color: var(--kpi-blue-border) !important;
}
.kpi-card.blue .kpi-value {
    color: var(--kpi-blue-text) !important;
}
.kpi-card.blue .kpi-icon {
    background: var(--kpi-blue-text) !important;
    color: #ffffff !important;
}

/* Welcome Banner Gradient Card */
.welcome-banner {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #db2777 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    margin-bottom: 28px;
    color: #ffffff !important;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

html[data-theme="dark"] .welcome-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #311042 50%, #4c0519 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.05);
}

.welcome-banner h2 {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: #ffffff !important;
}

.welcome-banner p {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.9rem;
    margin: 0;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 9px;
}

.card-header h3 i { color: var(--accent-text); }

.card-body { padding: 22px; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.2px;
}

.btn-accent {
    background: var(--accent);
    color: #000;
    box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(var(--accent-rgb), 0.3);
    filter: brightness(1.08);
}

.btn-accent:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(255, 56, 96, 0.18);
}

.btn-danger:hover { background: rgba(255, 56, 96, 0.18); }

.btn-icon-danger {
    color: var(--red);
    background: rgba(255, 56, 96, 0.05);
    border: 1px solid rgba(255, 56, 96, 0.15);
}

.btn-icon-danger:hover {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 56, 96, 0.25);
}

.btn-sm { padding: 5px 13px; font-size: 0.75rem; border-radius: var(--radius-xs); }

/* ─── Form Controls ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Global Reset for Interactive Elements */
input, textarea, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.88rem;
    transition: var(--transition);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Alias for backward compatibility and semantic clarity */
.form-control, .input-field {
    display: block;
    width: 100%;
}

select.form-control, select.input-field, select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a92' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 40px;
}

/* Global fix for dropdown options readability on dark themes */
select option {
    background-color: #12121c; /* Fallback dark */
    background-color: var(--bg-surface, #12121c);
    color: #ffffff;
    color: var(--text, #ffffff);
    padding: 10px;
}

textarea.form-control, textarea.input-field, textarea {
    min-height: 100px;
    resize: vertical;
}

::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}
/* ─── Tables ─────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: 13px 20px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.008);
}

td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.85rem;
}

tr:hover td { background: rgba(255, 255, 255, 0.012); }

/* ─── Badges ─────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-green  { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(var(--accent-rgb), 0.18); }
.badge-cyan   { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0,212,255,0.18); }
.badge-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,140,0,0.18); }
.badge-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,56,96,0.18); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(178,102,255,0.18); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,204,0,0.18); }

/* ─── Score Bar ──────────────────────────────────────────────────────── */
.score-bar-wrap { display: flex; align-items: center; gap: 9px; }

.score-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
.score-bar-fill.high   { background: var(--accent); }
.score-bar-fill.medium { background: var(--orange); }
.score-bar-fill.low    { background: var(--red); }

.score-number {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 28px;
    text-align: right;
}

/* ─── Terminal / Log ─────────────────────────────────────────────────── */
.terminal {
    background: #040407;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.terminal-header {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.015);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.terminal-body {
    padding: 14px 18px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 500px;
    min-height: 280px;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 2px 7px;
    border-left: 2px solid transparent;
    border-radius: 0 3px 3px 0;
}

.log-time { color: var(--text-muted); min-width: 65px; flex-shrink: 0; font-size: 0.7rem; }
.log-msg { color: #b0b0c8; word-break: break-word; }

.log-line.log-success { border-left-color: var(--accent); }
.log-line.log-success .log-msg { color: var(--accent); font-weight: 600; }
.log-line.log-warning { border-left-color: var(--orange); }
.log-line.log-warning .log-msg { color: var(--orange); }
.log-line.log-error { border-left-color: var(--red); background: rgba(255,56,96,0.03); }
.log-line.log-error .log-msg { color: var(--red); font-weight: 700; }
.log-line.log-alert { border-left-color: var(--cyan); background: rgba(0,212,255,0.03); }
.log-line.log-alert .log-msg { color: var(--cyan); font-weight: 700; }

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 28px;
    right: 104px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px 18px;
    z-index: 100000;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastIn 0.35s var(--ease);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    max-width: 380px;
    backdrop-filter: blur(8px);
}

.toast.toast-success { border-left: 3px solid var(--accent); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-info    { border-left: 3px solid var(--cyan); }
.toast.toast-warning { border-left: 3px solid var(--orange); }
.toast.hide { animation: toastOut 0.25s ease-in forwards; }

@keyframes toastIn { from { transform: translateX(80px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateX(80px); opacity: 0; } }

/* ─── Proposal Card ──────────────────────────────────────────────────── */
.proposal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 14px;
    transition: var(--transition);
}

.proposal-card:hover { border-color: var(--border-accent); box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.03); }
.proposal-card.pending { border-left: 3px solid var(--orange); }
.proposal-card.approved { border-left: 3px solid var(--accent); }
.proposal-card.sent { border-left: 3px solid var(--cyan); }
.proposal-card.skipped { border-left: 3px solid var(--text-muted); opacity: 0.6; }

.proposal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.proposal-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.proposal-body {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    max-height: 180px;
    overflow-y: auto;
}

.proposal-actions {
    display: flex;
    gap: 9px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* ─── Progress Ring ──────────────────────────────────────────────────── */
.progress-ring-wrap { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; }
.progress-ring { width: 120px; height: 120px; }
.progress-ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.progress-ring .bg { stroke: rgba(255, 255, 255, 0.05); }
.progress-ring .fg { stroke: var(--accent); transition: stroke-dashoffset 0.7s ease; }

/* ─── Grid Layouts ───────────────────────────────────────────────────── */
.col-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.col-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.col-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.col-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

/* ─── Alert Banner ───────────────────────────────────────────────────── */
.alert-banner {
    background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(var(--accent-rgb),0.06));
    border: 1px solid rgba(var(--accent-rgb), 0.12);
    border-radius: var(--radius);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    animation: alertPulse 3s infinite;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.08); }
    50%      { box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.04); }
}

.alert-banner .alert-icon { font-size: 1.4rem; flex-shrink: 0; }
.alert-banner .alert-text { font-size: 0.85rem; font-weight: 500; }
.alert-banner .alert-text strong { color: var(--accent); }

/* ─── Empty State ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 14px; opacity: 0.25; }
.empty-state h4 { font-family: var(--font-display); font-size: 1.05rem; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 0.82rem; }

/* ─── Stat Boxes (Runner) ────────────────────────────────────────────── */
.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-box:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.2); }

.stat-label { font-size: 0.62rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; }
.stat-val { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1; }

/* ─── Spinner ────────────────────────────────────────────────────────── */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.06);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ─── Chart Container ────────────────────────────────────────────────── */
.chart-container { position: relative; height: 270px; }

/* ─── Tags & Pills ───────────────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 50px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.footer-pills { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.pill {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 50px;
    font-size: 0.68rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Switches & Toggles ─────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    transition: .35s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .35s;
}

input:checked + .slider { background-color: var(--accent-dim); border-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); background-color: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* ─── Scheduling Slots ───────────────────────────────────────────────── */
.sched-slot-card {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.sched-slot-card:hover { border-color: var(--border-hover); background: rgba(255, 255, 255, 0.03); }

.slot-icon {
    width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; flex-shrink: 0;
}

.slot-info { flex: 1; }
.slot-name { font-size: 0.82rem; font-weight: 700; margin-bottom: 2px; }
.slot-time { font-size: 0.7rem; color: var(--text-secondary); }

/* ─── Decorative Elements ─── */
.bg-blur {
    position: absolute;
    width: 600px;
    height: 600px;
    filter: blur(150px);
    z-index: 0;
    opacity: 0.08;
    pointer-events: none;
}

.bg-blur.purple {
    top: -300px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 820px;
    opacity: 0.10;
    background: var(--accent);
}

.bg-blur.cyan {
    bottom: -150px;
    left: 20%;
    background: var(--secondary);
}

/* ─── Responsive: monitores Full HD (1920x1080) e notebooks ──────────────
   Em telas 2K/1440p a sidebar cabe inteira sem rolar. Em Full HD (altura
   ~900-960px de viewport útil) e notebooks (ainda menos), o mesmo conteúdo
   não cabe — aqui reduzimos tipografia e espaçamentos pra sobrar menos rolagem. */
@media (max-height: 960px) {
    #sidebar { padding: 18px 12px; }
    .sidebar-brand { margin-bottom: 22px; }

    .nav-group-header { padding: 9px 12px; }
    .nav-item { padding: 9px 12px; }

    .sidebar-footer { padding: 10px 12px; margin-top: 8px; }
    .sidebar-profile-card { padding: 8px 10px; }
}

@media (max-height: 700px) {
    .nav-group-header { padding: 7px 12px; }
    .nav-item { padding: 7px 12px; }
    .nav-group { margin-bottom: 3px; }
}

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .col-2 { grid-template-columns: 1fr; }
    .col-2-1 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    #mini-sidebar { display: none; }
    #sidebar { width: 200px; min-width: 200px; }
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

/* ─── Modals ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 20px;
    animation: fadeIn 0.3s var(--ease);
}

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

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    position: relative;
    padding: 32px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.6), 0 0 0 1px var(--accent-strong);
    animation: modalIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

/* ─── AI Chat Assistant ──────────────────────────────────────────────── */
#ai-chat-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.3);
    z-index: 4000;
    transition: var(--transition);
}

#ai-chat-trigger:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 32px rgba(var(--accent-rgb), 0.5);
}

#ai-chat-container {
    position: fixed;
    bottom: 94px;
    right: 24px;
    width: 380px;
    height: 550px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: none; /* Controlled by .open class */
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    z-index: 4000;
    overflow: hidden;
    animation: chatIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes chatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-chat-header {
    padding: 16px 20px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.ai-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: #000;
    border-bottom-right-radius: 2px;
    font-weight: 500;
}

.ai-chat-footer textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
    resize: none;
    min-height: 42px;
    max-height: 150px;
    line-height: 1.5;
    transition: var(--transition);
}

.ai-chat-footer textarea:focus {
    border-color: var(--accent);
    outline: none;
}

.ai-chat-footer {
    padding: 16px;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
}

.ai-chat-footer button {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    transition: var(--transition);
}

.ai-chat-footer button:hover { background: #fff; }

/* ─── Toast Notifications ────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 104px;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100000;
    animation: toastIn 0.35s var(--ease);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.hide {
    animation: toastOut 0.3s var(--ease) forwards;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-warning { border-left: 3px solid var(--orange); }

.toast-success i { color: var(--green); }
.toast-error i   { color: var(--red); }
.toast-info i    { color: var(--accent); }
.toast-warning i { color: var(--orange); }

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

@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100px); opacity: 0; }
}

/* ─── Client Card Interactions ───────────────────────────────────────── */
.client-card {
    transition: var(--transition);
}

.client-card:hover {
    border-color: rgba(var(--accent-rgb), 0.25) !important;
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.06);
    transform: translateY(-2px);
}

/* ─── Kanban Drag States ─────────────────────────────────────────────── */
.lead-card {
    cursor: grab;
    transition: var(--transition);
}

.lead-card:active { cursor: grabbing; }

.lead-card.dragging {
    opacity: 0.2;
    transform: scale(0.9) rotate(1deg);
    cursor: grabbing;
}

.kanban-column.drag-over {
    background: rgba(var(--accent-rgb), 0.08) !important;
    border: 1px dashed var(--accent) !important;
    transform: scale(1.01);
}

.kanban-list {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kanban-list {
    transition: background 0.2s ease;
    border-radius: var(--radius-sm);
    padding: 4px;
}

.kanban-list:has(.lead-card.dragging) {
    background: rgba(var(--accent-rgb), 0.03);
}

@keyframes pulse-accent {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* ─── Footer Pills ───────────────────────────────────────────────────── */
.footer-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.pill {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.pill i {
    font-size: 0.8rem;
    color: var(--accent);
}

.pill:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-dim);
    color: var(--text);
    transform: translateY(-1px);
}

/* ─── WhatsApp Hub Panel ────────────────────────────────────────── */
#whatsapp-chat-panel {
    position: fixed;
    top: 0;
    left: 64px; /* Width of mini-sidebar */
    bottom: 0;
    width: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    z-index: 99;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
}

#whatsapp-chat-panel.open {
    width: 800px;
}

.wa-panel-header {
    height: 60px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.wa-panel-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--bg-main);
}

.wa-chats-sidebar {
    width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-surface);
}

.wa-chat-item {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.wa-chat-item:hover { background: rgba(255, 255, 255, 0.02); }
.wa-chat-item.active { background: rgba(var(--accent-rgb), 0.1); border-left: 3px solid var(--accent); }

.wa-chat-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 1.2rem;
}

.wa-chat-info { flex: 1; overflow: hidden; }
.wa-chat-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-last-msg { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-chat-meta { text-align: right; }
.wa-chat-time { font-size: 0.65rem; color: var(--text-muted); }

.wa-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('https://w0.peakpx.com/wallpaper/818/148/HD-wallpaper-whatsapp-dark-stetho-cool-dark-grey-lock-screen-minimal-pattern-scary-skeleton-vector-whatsapp-chat.jpg');
    background-size: cover;
    background-blend-mode: overlay;
    background-color: rgba(10, 10, 18, 0.95);
}

.wa-chat-header {
    height: 60px; padding: 0 20px;
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: center;
    background: rgba(10, 10, 18, 0.8);
    backdrop-filter: blur(10px);
}

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

.wa-msg-bubble {
    max-width: 80%; padding: 10px 14px; border-radius: 12px;
    font-size: 0.85rem; line-height: 1.4; position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wa-msg-bubble.incoming {
    background: var(--bg-surface); align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.wa-msg-bubble.outgoing {
    background: #056162; color: #fff; align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.wa-msg-time {
    font-size: 0.6rem; opacity: 0.6; margin-top: 4px; text-align: right;
}

.wa-chat-input-area {
    padding: 16px; background: var(--bg-surface);
    border-top: 1px solid var(--border);
    display: flex; gap: 12px; align-items: flex-end;
}

#wa-chat-input {
    flex: 1; min-height: 44px; max-height: 120px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 22px; padding: 12px 20px; color: var(--text);
    font-size: 0.85rem; resize: none; overflow-y: auto;
}

#wa-send-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--accent); border: none; color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}

#wa-send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ═══════════════════════════════════════════════════════════════════════ */
/*  WHATSAPP HUB — Module Styles                                         */
/* ═══════════════════════════════════════════════════════════════════════ */

/* ─── 3-Column Inbox Layout ───────────────────────────────────────────── */
.wa-inbox {
    display: grid;
    grid-template-columns: 220px 320px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.wa-col { display: flex; flex-direction: column; overflow: hidden; }
.wa-col + .wa-col { border-left: 1px solid var(--border); }

.wa-col-header {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.wa-col-header i { margin-right: 8px; opacity: 0.7; }

.wa-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ─── Search Bar ──────────────────────────────────────────────────────── */
.wa-search-bar {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.wa-search-bar i { color: var(--text-muted); font-size: 0.8rem; }

.wa-search-bar input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.82rem;
    padding: 6px 0;
    outline: none;
}

/* ─── Instance List ───────────────────────────────────────────────────── */
.wa-instance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.wa-instance-item:hover { background: rgba(255,255,255,0.03); }
.wa-instance-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }

.wa-instance-name { font-weight: 700; font-size: 0.85rem; color: var(--text); }
.wa-instance-status { font-size: 0.68rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }

.wa-instance-actions { display: flex; gap: 4px; }

.pulse-dot-sm {
    width: 6px; height: 6px; border-radius: 50%; display: inline-block;
}
.pulse-dot-sm.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.pulse-dot-sm.orange { background: var(--orange); }
.pulse-dot-sm.red { background: var(--red); }

.btn-icon {
    width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
    background: none; color: var(--text-muted); cursor: pointer; display: flex;
    align-items: center; justify-content: center; font-size: 0.7rem;
    transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ─── Chat List ───────────────────────────────────────────────────────── */
.wa-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.wa-chat-item:hover { background: rgba(255,255,255,0.03); }
.wa-chat-item.active { background: var(--accent-dim); }

.wa-chat-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.06); display: flex;
    align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 0.9rem; flex-shrink: 0;
}

.wa-chat-info { flex: 1; min-width: 0; }
.wa-chat-name { font-weight: 700; font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-preview { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.wa-chat-meta { text-align: right; flex-shrink: 0; }
.wa-chat-time { font-size: 0.62rem; color: var(--text-muted); }

.wa-unread-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; border-radius: 50%;
    background: #25d366; color: #000; font-size: 0.6rem; font-weight: 800;
    margin-top: 4px; padding: 0 4px;
}

/* ─── Messages Area ───────────────────────────────────────────────────── */
.wa-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0,0,0,0.15);
}

.wa-msg { display: flex; }
.wa-msg-sent { justify-content: flex-end; }
.wa-msg-received { justify-content: flex-start; }

.wa-msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.wa-msg-sent .wa-msg-bubble {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.wa-msg-received .wa-msg-bubble {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
}

.wa-msg-time {
    display: block;
    font-size: 0.58rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

.wa-media-badge {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(255,255,255,0.06); padding: 2px 8px;
    border-radius: 4px; font-size: 0.7rem; color: var(--text-muted);
    margin-right: 6px;
}

/* ─── Chat Input ──────────────────────────────────────────────────────── */
.wa-chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.wa-chat-input-area textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    border-radius: 20px;
    padding: 10px 18px;
    resize: none;
    font-size: 0.85rem;
}

/* ─── Empty / Loading States ──────────────────────────────────────────── */
.wa-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    gap: 12px;
    padding: 40px;
    text-align: center;
}

.wa-empty-state i { font-size: 2.5rem; opacity: 0.3; }
.wa-empty-state p { font-size: 0.85rem; }

.wa-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 100px;
}

/* ─── Workflow Cards V2 — Modern Redesign ─────────────────────────────── */
.wa-wf-card-v2 {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.wa-wf-card-v2:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(139, 92, 246, 0.06);
}

.wa-wf-card-v2__glow {
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #f97316, var(--accent));
    background-size: 200% 100%;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.wa-wf-card-v2.is-active .wa-wf-card-v2__glow {
    opacity: 1;
    animation: wf-glow-slide 3s ease infinite;
}

.wa-wf-card-v2.is-paused .wa-wf-card-v2__glow {
    background: linear-gradient(90deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    opacity: 0.3;
}

@keyframes wf-glow-slide {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.wa-wf-card-v2__body {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Header */
.wa-wf-card-v2__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.wa-wf-card-v2__info {
    flex: 1;
    min-width: 0;
}

.wa-wf-card-v2__name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.wa-wf-card-v2__name {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.wa-wf-card-v2__instance {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

/* ─── Pulsing dots indicator for active automations ─────────────────── */
.wa-wf-card-v2__live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
}

.wa-wf-pulse-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
    animation: wf-pulse-bounce 1.4s ease-in-out infinite;
}

.wa-wf-pulse-dot:nth-child(2) { animation-delay: 0.2s; }
.wa-wf-pulse-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes wf-pulse-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Trigger Badge */
.wa-wf-card-v2__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    width: fit-content;
}

.wa-wf-card-v2__trigger i {
    font-size: 0.75rem;
    opacity: 0.8;
}

.wa-wf-card-v2.is-paused .wa-wf-card-v2__trigger {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

/* Actions */
.wa-wf-card-v2__actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.wa-wf-card-v2__btn-metrics {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 10px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.wa-wf-card-v2__btn-metrics:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35), rgba(139, 92, 246, 0.2));
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.15);
}

.wa-wf-card-v2__btn-settings {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.wa-wf-card-v2__btn-settings:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text);
    transform: rotate(45deg);
}

/* Paused state muting */
.wa-wf-card-v2.is-paused {
    opacity: 0.7;
}

.wa-wf-card-v2.is-paused:hover {
    opacity: 1;
}

.wa-wf-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ─── Step Row (Workflow Builder) ─────────────────────────────────────── */
.wa-step-row select,
.wa-step-row input,
.wa-step-row textarea {
    font-size: 0.82rem;
}

/* Media Messages */
.wa-msg-image { margin-bottom: 8px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); transition: transform 0.2s; }
.wa-msg-image:hover { transform: scale(1.02); }
.wa-msg-image img { width: 100%; display: block; max-height: 300px; object-fit: cover; }
.wa-msg-caption { font-size: 0.9rem; line-height: 1.4; color: var(--text); }
.wa-msg-audio { width: 100%; max-width: 250px; height: 32px; filter: invert(0.8) hue-rotate(180deg); margin-top: 4px; }

.wa-attachment-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--accent-dim);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--accent);
    margin-right: 10px;
    border: 1px solid var(--accent);
}
.wa-attachment-preview button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 4px; }
.wa-attachment-preview button:hover { color: var(--red); }

/* Workflow Grid */
.wa-workflows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}
.wa-wf-stat {
    background: rgba(255,255,255,0.05);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}



/* WhatsApp Avatar Fix */
.wa-chat-avatar { overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.wa-chat-avatar-img { width: 100%; height: 100%; object-fit: cover; }

/* WhatsApp Variable Chips */
.wa-var-chip {
    padding: 4px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.wa-var-chip:hover {
    background: var(--accent);
    color: #000 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.wa-var-chip:active {
    transform: translateY(0);
}

/* ─── Global overrides for inline background transparencies ─── */
html[data-theme="light"] div[style*="background:rgba(0,0,0,"], 
html[data-theme="light"] div[style*="background: rgba(0,0,0,"],
html[data-theme="light"] div[style*="background:rgba(0, 0, 0,"], 
html[data-theme="light"] div[style*="background: rgba(0, 0, 0,"],
html[data-theme="light"] div[style*="background:rgba(255,255,255,0.0"], 
html[data-theme="light"] div[style*="background: rgba(255,255,255,0.0"],
html[data-theme="light"] div[style*="background:rgba(255, 255, 255, 0.0"], 
html[data-theme="light"] div[style*="background: rgba(255, 255, 255, 0.0"],
html[data-theme="light"] div[style*="background:rgba(255,255,255,0.1"], 
html[data-theme="light"] div[style*="background: rgba(255,255,255,0.1"],
html[data-theme="light"] div[style*="background:rgba(255, 255, 255, 0.1"], 
html[data-theme="light"] div[style*="background: rgba(255, 255, 255, 0.1"] {
    background: var(--bg-elevated) !important;
    border-color: var(--border) !important;
}

html[data-theme="light"] input[style*="background:rgba(0,0,0,"],
html[data-theme="light"] input[style*="background: rgba(0,0,0,"],
html[data-theme="light"] input[style*="background:rgba(0, 0, 0,"],
html[data-theme="light"] input[style*="background: rgba(0, 0, 0,"],
html[data-theme="light"] select[style*="background:rgba(0,0,0,"],
html[data-theme="light"] select[style*="background: rgba(0,0,0,"],
html[data-theme="light"] select[style*="background:rgba(0, 0, 0,"],
html[data-theme="light"] select[style*="background: rgba(0, 0, 0,"] {
    background: var(--bg-input) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="light"] .sys-info-card,
html[data-theme="light"] .engine-tag,
html[data-theme="light"] .api-card,
html[data-theme="light"] .stack-item,
html[data-theme="light"] .section-card,
html[data-theme="light"] .project-card,
html[data-theme="light"] #gemini-kpis > div,
html[data-theme="light"] #groq-kpis > div {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
}

html[data-theme="light"] .manifesto-card {
    background: linear-gradient(135deg, var(--accent-dim) 0%, var(--bg-surface) 100%) !important;
    border-color: var(--accent) !important;
    box-shadow: var(--shadow-sm) !important;
}

html[data-theme="light"] .modal-overlay,
html[data-theme="light"] #modal-overlay {
    background: rgba(15, 23, 42, 0.4) !important; /* Premium semi-transparent backdrop blur overlay */
    backdrop-filter: blur(8px) !important;
}

html[data-theme="light"] .modal-content {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}

html[data-theme="light"] .modal-header h2 {
    color: var(--text-primary) !important;
}

html[data-theme="light"] table, 
html[data-theme="light"] .table,
html[data-theme="light"] tbody,
html[data-theme="light"] tr,
html[data-theme="light"] td,
html[data-theme="light"] th {
    border-color: var(--border) !important;
}

/* ─── COMPREHENSIVE MOBILE RESPONSIVENESS OVERLAYS & LAYOUTS ─── */
@media (max-width: 768px) {
    /* 1. Sidebar Toggles & Drawer Layout */
    #sidebar-toggle {
        display: block !important;
    }
    
    #mini-sidebar {
        display: none !important;
    }
    
    #sidebar {
        position: fixed;
        top: 0;
        left: -260px; /* Hidden offscreen by default */
        bottom: 0;
        width: 260px;
        min-width: 260px;
        z-index: 5000;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #sidebar.active {
        left: 0; /* Slide in drawer */
    }
    
    #topbar {
        padding: 0 16px !important;
    }
    
    /* 2. Grid & Content Layout Restructuring */
    #app {
        padding: 16px !important;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .col-2, .col-2-1, .grid-3 {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* 3. CRM Kanban Stacking */
    .kanban-board {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    .kanban-column {
        min-height: auto !important;
    }
    
    /* 4. Table Scroll Wrapper — MOVIDO para css/mobile.css
       A regra que estava aqui fazia `table { display: block }`. Isso resolvia o
       estouro horizontal, mas ao trocar o display de `table` para `block` o
       algoritmo de tabela para de rodar e as colunas do cabeçalho perdem o
       alinhamento com as do corpo — a tabela rolava, só que torta.
       Em mobile.css a tabela continua sendo tabela e quem rola é o contêiner. */
    
    /* 5. Modals & Forms scaling */
    .modal-content {
        padding: 20px !important;
        width: 95% !important;
        max-height: 85vh !important;
    }
    
    /* 6. WhatsApp Hub Adaptive Mobile Panel */
    #whatsapp-chat-panel.open {
        width: 100% !important;
        left: 0 !important;
        z-index: 4001 !important; /* Above triggers, below sidebar drawer */
    }
    
    #wa-back-btn {
        display: block !important; /* Visible on mobile active chat */
    }
    
    /* Mobile Chat Switching (chats sidebar vs conversation main) */
    #whatsapp-chat-panel.open .wa-chats-sidebar {
        width: 100% !important;
        display: flex !important;
    }
    
    #whatsapp-chat-panel.open .wa-chat-main {
        display: none !important;
    }
    
    /* When active chat is opened, hide list and show conversation */
    #whatsapp-chat-panel.open.has-active-chat .wa-chats-sidebar {
        display: none !important;
    }
    
    #whatsapp-chat-panel.open.has-active-chat .wa-chat-main {
        display: flex !important;
        flex: 1 !important;
        width: 100% !important;
    }
    
    /* 7. AI Chat floating window adjustments */
    #ai-chat-container {
        width: calc(100% - 32px) !important;
        right: 16px !important;
        left: 16px !important;
        bottom: 90px !important;
        height: 70vh !important;
    }
    
    /* Responsive overrides for page-header and crm-stats-grid */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 20px;
    }
    .page-header .header-left h1 {
        font-size: 1.45rem !important;
        flex-wrap: wrap;
    }
    .page-header .header-left h1 span {
        font-size: 0.9rem !important;
        margin-left: 0 !important;
        display: block;
        width: 100%;
        margin-top: 4px;
    }
    .page-header .header-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-header .header-right .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
    .crm-stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .client-card .card-body {
        padding: 16px !important;
    }
    .proposal-header {
        flex-direction: column;
        gap: 8px;
    }
    .proposal-header > div {
        text-align: left !important;
    }
    .proposal-actions {
        flex-wrap: wrap;
    }
    .proposal-actions > a {
        margin-left: 0 !important;
        width: 100%;
        text-align: center;
    }
    .score-breakdown-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Global Responsive Base Classes */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 16px;
}
.crm-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
}
.score-breakdown-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

@media (max-width: 1200px) {
    .crm-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .score-breakdown-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Estilo antigo/duplicado de rolagem da sidebar removido — consolidado em
   #sidebar .sidebar-nav (ver seção "MAIN SIDEBAR" no topo do arquivo), que
   é a versão completa (min-height:0, padding-right, scrollbar mais visível). */

/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND CENTER V2 — Gamification & Mission System
   ═══════════════════════════════════════════════════════════════════════════ */

/* Mission Hero Card */
.mission-hero {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.03) 100%);
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 28px;
    padding: 32px;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.08);
}
.mission-hero::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(139, 92, 246, 0.05), transparent);
    animation: mission-glow 6s linear infinite;
}
@keyframes mission-glow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.mission-hero:hover {
    border-color: var(--accent);
    box-shadow: 0 0 60px rgba(139, 92, 246, 0.15);
    transform: translateY(-2px);
}
.mission-hero .mission-content { position: relative; z-index: 1; }
html[data-theme="light"] .mission-hero {
    background: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 100%);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.08);
}

/* XP Progress Bar */
.xp-bar-container {
    width: 100%;
    height: 14px;
    background: rgba(255,255,255,0.06);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
    position: relative;
}
html[data-theme="light"] .xp-bar-container {
    background: #e2e8f0;
    border-color: #cbd5e1;
}
.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #4ade80 50%, var(--cyan) 100%);
    border-radius: 20px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}
.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
    animation: xp-shimmer 2s ease-in-out infinite;
}
@keyframes xp-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Streak Badge */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(234, 179, 8, 0.1));
    border: 1px solid rgba(249, 115, 22, 0.3);
    border-radius: 12px;
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--orange);
}
.streak-badge .streak-fire {
    font-size: 1.2rem;
    animation: streak-pulse 1.5s ease-in-out infinite;
}
@keyframes streak-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}
html[data-theme="light"] .streak-badge {
    background: linear-gradient(135deg, #fff7ed, #fffbeb);
    border-color: #fed7aa;
    color: #ea580c;
}

/* Level Badge */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 10px;
    font-weight: 900;
    font-size: 0.8rem;
    color: var(--accent);
}
html[data-theme="light"] .level-badge {
    background: linear-gradient(135deg, #f5f3ff, #e0e7ff);
    border-color: #c7d2fe;
    color: #4f46e5;
}

/* Achievement Card */
.achievement-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 16px;
    transition: 0.3s;
}
.achievement-card:hover {
    background: rgba(139, 92, 246, 0.05);
    border-color: rgba(139, 92, 246, 0.2);
    transform: translateY(-2px);
}
.achievement-card.locked {
    opacity: 0.35;
    filter: grayscale(0.8);
}
.achievement-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
    font-size: 1.2rem;
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent);
}
html[data-theme="light"] .achievement-card {
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

/* Activity Heatmap */
.activity-heatmap {
    display: flex;
    gap: 4px;
    align-items: flex-end;
}
.heatmap-day {
    width: 28px;
    border-radius: 6px;
    min-height: 8px;
    background: rgba(255,255,255,0.06);
    transition: 0.3s;
    position: relative;
}
.heatmap-day.level-1 { background: rgba(139, 92, 246, 0.2); }
.heatmap-day.level-2 { background: rgba(139, 92, 246, 0.4); }
.heatmap-day.level-3 { background: rgba(139, 92, 246, 0.6); }
.heatmap-day.level-4 { background: var(--accent); }
html[data-theme="light"] .heatmap-day { background: #e2e8f0; }
html[data-theme="light"] .heatmap-day.level-1 { background: #c7d2fe; }
html[data-theme="light"] .heatmap-day.level-2 { background: #a5b4fc; }
html[data-theme="light"] .heatmap-day.level-3 { background: #818cf8; }
html[data-theme="light"] .heatmap-day.level-4 { background: #6366f1; }

/* Mission Complete Animation */
@keyframes mission-complete {
    0% { transform: scale(1); }
    25% { transform: scale(1.05); }
    50% { transform: scale(0.98); }
    75% { transform: scale(1.02); }
    100% { transform: scale(1); }
}
.mission-complete-anim {
    animation: mission-complete 0.6s ease-out;
}

/* Gamification Stats Grid */
.gam-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 768px) {
    .gam-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .mission-hero {
        padding: 20px;
        border-radius: 20px;
    }
}

/* Project Progress Bar (CRM) */
.project-progress {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}
.project-progress-fill {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width 0.5s ease;
}
html[data-theme="light"] .project-progress { background: #e2e8f0; }

/* Secondary filters bar */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 8px;
    background: rgba(255,255,255,0.02);
    border-radius: 14px;
    border: 1px solid var(--border);
}
.filter-chip {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    transition: 0.2s;
}
.filter-chip:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.filter-chip.active {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent);
    border-color: var(--accent);
}
html[data-theme="light"] .filter-bar { background: #f8fafc; }
html[data-theme="light"] .filter-chip:hover { background: #f1f5f9; }
html[data-theme="light"] .filter-chip.active { background: #ede9fe; color: #4f46e5; border-color: #a5b4fc; }

/* 📊 ANALYTICS & PERFORMANCE MODULE STYLES */
.analytics-grid {
    animation: fadeIn 0.4s ease-out;
}
.performance-summary-box {
    animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}
.performance-summary-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}
.badge-success {
    background: rgba(34, 197, 94, 0.1) !important;
    color: #4ade80 !important;
    border: 1px solid rgba(34, 197, 94, 0.2) !important;
}
.badge-red {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

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

/* 📅 HEATMAP DE PRODUTIVIDADE (GITHUB STYLE) */
.heatmap-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 24px;
    margin-bottom: 30px;
    overflow-x: auto;
}
.heatmap-grid {
    display: grid;
    grid-template-flow: column;
    grid-template-columns: repeat(18, 1fr); /* 18 semanas de histórico de consistência compacta */
    gap: 6px;
    min-width: 600px;
}
.heatmap-col {
    display: grid;
    grid-template-rows: repeat(7, 1fr);
    gap: 6px;
}
.heatmap-day {
    aspect-ratio: 1;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.heatmap-day:hover {
    transform: scale(1.25);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
    z-index: 10;
}
/* Cores base do Score */
.heatmap-day.score-none { background: rgba(255,255,255,0.03); }
.heatmap-day.score-low { background: rgba(139, 92, 246, 0.15); }
.heatmap-day.score-med { background: rgba(139, 92, 246, 0.4); }
.heatmap-day.score-high { background: rgba(139, 92, 246, 0.7); }
.heatmap-day.score-max { 
    background: var(--accent);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

/* Light Theme overrides para Heatmap */
html[data-theme="light"] .heatmap-day.score-none { background: #e2e8f0; }
html[data-theme="light"] .heatmap-day.score-low { background: #ddd6fe; }
html[data-theme="light"] .heatmap-day.score-med { background: #c084fc; }
html[data-theme="light"] .heatmap-day.score-high { background: #a855f7; }
html[data-theme="light"] .heatmap-day.score-max { background: #7c3aed; }

/* 🏆 SISTEMA DE CONQUISTAS (ACHIEVEMENTS) */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 15px;
}
.achievement-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: all 0.3s ease;
}
.achievement-card.locked {
    opacity: 0.35;
    filter: grayscale(100%);
}
.achievement-card.unlocked {
    opacity: 1;
    filter: none;
    border-color: rgba(var(--accent-rgb), 0.3);
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.05) 0%, rgba(255,255,255,0.01) 100%);
    box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.05);
}
.achievement-card.unlocked:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 6px 25px rgba(var(--accent-rgb), 0.15);
}
.achievement-icon {
    font-size: 1.8rem;
    min-width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
}
.achievement-card.unlocked .achievement-icon {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

/* 📊 SCORE GERAL CARD */
.score-badge-main {
    font-family: 'JetBrains Mono', monospace;
    font-size: 3.5rem;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(to right, #fff 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.3));
}
.double-progress-container {
    position: relative;
    height: 8px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
}
.double-progress-current {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    transition: width 0.4s ease;
}
.double-progress-previous {
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    border-right: 2px dashed rgba(255,255,255,0.3);
    transition: width 0.4s ease;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVIDADE v2 — refino final (celular · tablet · desktop)
   Aditivo: fica no fim do arquivo para prevalecer na cascata.
   ═══════════════════════════════════════════════════════════════════ */

/* Trava overflow horizontal em qualquer viewport */
html, body { max-width: 100%; overflow-x: hidden; }
img, video { max-width: 100%; height: auto; }

/* ---------- TABLET (769–1024px) ---------- */
@media (min-width: 769px) and (max-width: 1024px) {
    #app { padding: 26px 22px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 16px; }
    .crm-stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important; }
    .score-breakdown-grid { grid-template-columns: repeat(3, 1fr); }
    .col-2, .col-2-1 { grid-template-columns: 1fr; }
    /* Kanban: rolagem horizontal em vez de espremer colunas */
    .kanban-board {
        display: flex !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 16px;
        padding-bottom: 10px;
    }
    .kanban-board > .kanban-column { flex: 0 0 300px; min-width: 300px; }
}

/* ---------- CELULAR PEQUENO (≤600px) ---------- */
@media (max-width: 600px) {
    #app { padding: 14px 12px !important; }
    #topbar { padding: 0 12px !important; }
    #page-title { font-size: 1.1rem !important; }
    .kpi-card { padding: 16px 18px !important; }
    .kpi-value { font-size: 1.5rem !important; }
    /* KPIs do CRM em 2 colunas (legível no celular) */
    .crm-stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
    .crm-stats-grid .kpi-value, .crm-stats-grid .kpi-card > div:nth-child(2) { font-size: 1.25rem !important; }
    /* Colunas do kanban ocupam quase a tela cheia (swipe horizontal) */
    .kanban-column { min-width: 82vw !important; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    /* Modais quase full-screen, cantos menores */
    .modal-content { width: 94% !important; padding: 18px !important; border-radius: var(--radius-md) !important; }
    /* Cabeçalhos de página empilham sem estourar */
    .page-header .header-right { flex-wrap: wrap; width: 100%; }
    /* Barras de filtro/chips roláveis na horizontal */
    .filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Janela do AI chat ocupa quase tudo */
    #ai-chat-container { height: 66vh !important; }
    /* Suaviza o glow no celular para não pesar */
    .bg-blur { opacity: 0.05 !important; }
    /* Colapsa grids inline de 4/5/6 colunas (espremidos) para 2 no celular */
    [style*="repeat(4,"], [style*="repeat(5,"], [style*="repeat(6,"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Grids inline largos no tablet: 3 colunas em vez de 4/5/6 */
@media (min-width: 601px) and (max-width: 1024px) {
    [style*="repeat(5,"], [style*="repeat(6,"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}



