/* =========================================================
           1. VARIÁVEIS DE TEMA (LIGHT / DARK)
           ========================================================= */
        :root { 
            --primary: #15D6C9; 
            
            /* TEMA LIGHT (Padrão do PDF) */
            --bg-geral: #d9dfe1;       
            --bg-card: #eceff0;        
            --bg-intel: #0c1322;
            --bg-content: #e3e7e7;       
            
            --text-main: #333333;
            --text-intel: #ffffff;
            --icon-light: #888888;
            --icon-dark: #8E9BAE;      
            --border-color: #cdd4d8;
            --contrasting: #0a0a0f;
            
            --bg-table-head: #d9dfe1;
            --bg-table-row: #f2f7fa;
            --negative: #F00C3B; 
            --alert: #F0960C; 
            
            --gap-size: 9px;           
            --border-rad: 9px;         
            --font-main: 'Nexa', 'Segoe UI', sans-serif; 

            --logo-url: url('Wall-Light.png');
            --bi-pattern: url('bg-pattern.png');
        }

        body.dark-mode {
            /* TEMA DARK */
            --bg-geral: #0a0a0f;
            --bg-card: #111827;
            --bg-intel: #283b80;
            --text-main: #F7FAFC;
            --border-color: #1F2937;
            --bg-table-head: #0a0a0f;
            --bg-table-row: #1A202C;
            --icon-light: #A0AEC0;
            --bg-content: #0f1522; 
            --contrasting: #d9dfe1;

            --logo-url: url('Wall-Dark.png');
            --bi-pattern: url('bg-pattern-dark.png');
        }

        /* 1. LAYOUT GERAL FLUTUANTE */
        body { 
            margin: 0; 
            font-family: var(--font-main); 
            background-color: var(--bg-geral); 
            color: var(--text-main); 
            display: flex; 
            height: 100vh; 
            box-sizing: border-box;
            padding: var(--gap-size); 
            gap: var(--gap-size);     
            overflow: hidden; 
            transition: background-color 0.3s;
            filter: drop-shadow(-6px 6px 10px rgba(0, 0, 0, 0.2));
        }
        
        /* 2. BARRA LATERAL (MENU & SETTINGS) */
        .sidebar-wrapper {
            display: flex;
            flex-direction: column;
            gap: var(--gap-size);     
            width: 240px; 
            height: 100%;
            transition: width 0.35s ease-in-out/*cubic-bezier(0.4, 0, 0.2, 1)*/;
            z-index: 500;
            flex-shrink: 0;
        }
        .sidebar-wrapper::-webkit-scrollbar {
            display: none;
        }
        .sidebar-wrapper.compact { width: 64px; } 

        .sidebar-card {
            background-color: var(--bg-card);
            border-radius: var(--border-rad);
            display: flex;
            flex-direction: column;
            transition: 0.3s;
        }

        .main-menu-card {
            flex: 1;                  
            padding: 5px 0;             
            /*display: flex;
            flex-direction: column;*/
            overflow: visible;
            box-shadow: 
                inset -1px 1px 1px rgba(255, 255, 255, 0.05), 
                inset 1px -1px 1px rgba(0, 0, 0, 0.25); 
        }
        
        
        .settings-card {
            height: auto;
            padding: 6px 0 0px 0;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            flex-shrink: 0;
            overflow: visible !important;
            box-shadow: 
                inset -1px 1px 1px rgba(255, 255, 255, 0.05), 
                inset 1px -1px 1px rgba(0, 0, 0, 0.25);
        }

        /* ÁREA DO LOGOTIPO */
        .logo-container {
            width: 50px;
            height: 50px;
            margin-bottom: 5px;
            padding-left: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: 0.3s;
            flex-shrink: 0;
        }
        .logo-img {
            width: 100%;
            height: 100%;
            background-image: var(--logo-url);
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            transition: 0.3s;
        }
        .sidebar-wrapper.compact .logo-img {
            width: 40px; /* Versão reduzida ou apenas o ícone quadrado no modo compacto */
        }

        /* SEÇÕES DO MENU */
        .menu-section {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
            padding: 9px 0 9px 0;
            margin-bottom: 0px;
            overflow: visible;
        }

        .section-intel { 
            background-color: var(--bg-intel); 
            color: var(--text-intel); 
            border-radius: 6px; 
            width: 90%; 
            margin: 0 auto 9px auto;
            filter: drop-shadow(-6px 6px 6px rgba(0, 0, 0, 0.3));
            box-shadow: 
                inset -1px 1px 1px rgba(255, 255, 255, 0.1), 
                inset 1px -1px 1px rgba(0, 0, 0, 0.25); 
        }
        .sidebar-wrapper.compact .section-intel { width: 80%; border-radius: 6px; }

        /* TÍTULOS DAS SEÇÕES */
        .section-title {
            font-size: 8px;
            letter-spacing: 1px;
            text-transform: uppercase;
            font-weight: regular;
            opacity: 0.6;
            margin-top: auto !important;
            margin-bottom: 6px !important;
            width: 100%;
            text-align: left;
            padding-left: 20px;
            box-sizing: border-box;
            white-space: nowrap;
            overflow: hidden;
        }
        
        .sidebar-wrapper.compact .section-title {
            writing-mode: vertical-rl;
            transform: rotate(180deg);
            font-size: 4pt;
            letter-spacing: 2px;
            padding-left: 0;
            text-align: left;
            width: 80%;
            display: flex;

            justify-content: center;
            align-items: center;
            margin-top: auto !important;
            margin-bottom: 9px !important;
        }

        /* ITENS DO MENU */
        .menu-item {
            position: relative;
            width: 90%;
            height: 38px;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            padding-left: 9px;
            border-radius: 6px;
            margin-bottom: 4px;
            cursor: pointer;
            transition: background-color 0.2s, padding 0.35s ease-in-out;
            text-decoration: none;
            color: inherit;
            box-sizing: border-box;
            overflow: visible;
        }
        
        .sidebar-wrapper.compact .menu-item {
            width: 40px;
            padding-left: 0;
            justify-content: center;
        }

        @media (max-height: 720px) {
            .logo-container {height: 35px; margin-bottom: 2px;}
            .menu-section {padding: 5px 0; }
            .menu-item { height: 34px; margin-bottom: 2px;}
            .sidebar-wrapper.compact .section-title {margin-bottom: 10px;}
        }

        .menu-item svg { width: 18px; height: 18px; fill: none; stroke-width: 1.5; transition: 0.2s; flex-shrink: 0; }
        .menu-text { font-size: 13px; font-weight: 500; margin-left: 15px; white-space: nowrap; transition: opacity 0.2s ease-in-out 0.15s, visibility 0.35s ease-in-out; opacity: 1; visibility: visible; overflow: hidden;}
        .sidebar-wrapper.compact .menu-text { display: none; opacity: 0; visibility: hidden; transition: opacity 0.1s ease-in-out 1s, visibility 0.1s ease-in-out 0s;}

        .section-intel .menu-item svg { stroke: var(--icon-dark); }
        .section-intel .menu-item { color: var(--text-intel); }
        .section-intel .menu-item:hover { background-color: rgba(255,255,255,0.1); }
        .section-intel .menu-item:hover svg { stroke: var(--primary); }

        .menu-section:not(.section-intel) .menu-item svg { stroke: var(--icon-light); }
        .menu-section:not(.section-intel) .menu-item { color: var(--text-main); }
        .menu-section:not(.section-intel) .menu-item:hover { background-color: rgba(120,120,120,0.10); }
        .menu-section:not(.section-intel) .menu-item:hover svg { stroke: var(--primary); }
        
        #sidebar-container {
            position: relative;
            z-index: 9998; 
        }

        /* 4. FLYOUT / SUBMENUS */
        .flyout {
            position: absolute;
            left: calc(100%); 
            top: auto;
            background-color: var(--bg-card);
            border-radius: 6px;
            box-shadow: 4px 4px 15px rgba(0,0,0,0.2);
            padding: 10px 0;
            width: max-content;
            min-width: 180px;
            display: none;
            flex-direction: column;
            z-index: 9999;
        }
        .section-intel .flyout { background-color: var(--bg-intel); color: var(--text-intel); border-left: 2px solid var(--primary); }
        .menu-section:not(.section-intel) .flyout { border-left: 2px solid var(--primary); color: var(--text-main); z-index: 10000;}
        
        .menu-item:hover { z-index: 10001; }
        .menu-item:hover .flyout { display: flex; animation: fadeIn 0.2s; z-index: 10002;}
        
        .flyout-title { font-size: 10px; font-weight: bold; text-transform: uppercase; padding: 0 15px 10px; opacity: 0.7; border-bottom: 1px solid rgba(128,128,128,0.2); margin-bottom: 5px; }
        .flyout a { padding: 8px 15px; text-decoration: none; color: inherit; font-size: 12px; transition: 0.2s; }
        .flyout a:hover { color: var(--primary); padding-left: 20px; background-color: rgba(128,128,128,0.1); z-index: 10004;}

        @keyframes fadeIn { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: translateX(0); } }

        .settings-card .menu-item:hover .flyout {
            display: flex;
            top: auto;        /* Cancela o top antigo */
            bottom: 0;        /* Alinha perfeitamente com a base inferior do ícone */
            animation: fadeInBottom 0.2s ease-in-out;
        }

        @keyframes fadeInBottom { 
            from { opacity: 0; transform: translate(-5px, 5px); } 
            to { opacity: 1; transform: translate(0, 0); } 
        }

        /* 5. ÁREA DE CONTEÚDO PRINCIPAL (Main Content) */
        .main-content { 
            flex: 1; 
            background-color: var(--bg-card); 
            border-radius: var(--border-rad); 
            padding: 9px; 
            overflow-y: auto; 
            position: relative;
            z-index: 10;
            transition: 0.3s;
            box-shadow: 
                inset -1px 1px 1px rgba(255, 255, 255, 0.05), 
                inset 1px -1px 1px rgba(0, 0, 0, 0.25);
        }
        .main-content::-webkit-scrollbar {
            display: none;
        }

        .header-title { 
            font-size: 18px; 
            font-weight: bold; 
            margin-top: 0px; 
            margin-bottom: 11px; 
            display: grid; 
            grid-template-columns: 1fr auto 1fr;
            align-items: center;
            flex-shrink: 0;
            position: relative; 
        }
        .btn-icon { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); cursor: pointer; padding: 6px 10px; border-radius: 6px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: bold; transition: 0.2s;}
        .btn-icon:hover { background: rgba(0,0,0,0.25); color: var(--primary); }

        .header-left {
            display: flex;
            align-items: center;
            gap: 12px;
            justify-content: flex-start;
        }

        /* Estilo discreto do caminho da navegação */
        .breadcrumb {
            display: flex;
            align-items: center;
            gap: 6px;
            color: var(--text-main);
            opacity: 0.6;
            font-size: 10px;
            font-weight: 300;
        }

        /* O link ativo/botão que dispara o Flyout Superior */
        .breadcrumb-page-trigger {
            position: relative;
            
            padding: 4px 10px;
            border-radius: 4px;
            cursor: pointer;
            color: var(--text-main);
            font-weight: bold;
            transition: 0.2s;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            border: 1px solid var(--border-color);
        }
        body.dark-mode .breadcrumb-page-trigger {
            background: rgba(255, 255, 255, 0.05);
        }
        .breadcrumb-page-trigger:hover {
            background: rgba(21, 214, 201, 0.15);
            color: var(--primary);
        }

        /* Seta indicadora discreta ao lado do botão */
        .breadcrumb-page-trigger::after {
            content: '▾';
            font-size: 10px;
            opacity: 0.7;
        }

        /* FLYOUT DO HEADER (Abre para baixo do botão) */
        .header-flyout {
            position: absolute;
            top: -100%;
            left: 100%;
            margin-top: 5px;
            background-color: var(--bg-card);
            border-radius: 6px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.15);
            padding: 8px 0;
            width: max-content;
            min-width: 160px;
            display: none;
            flex-direction: column;
            z-index: 1010;
            border: 1px solid var(--border-color);
        }
        /* Adaptação de cor caso esteja dentro da inteligência financeira (opcional, aqui segue o padrão claro/escuro geral) */
        .breadcrumb-page-trigger:hover .header-flyout {
            display: flex;
            animation: fadeInHeaderFlyout 0.2s ease-in-out;
        }
        
        .header-flyout a {
            padding: 8px 16px;
            text-decoration: none;
            color: var(--text-main);
            font-size: 12px;
            font-weight: 500;
            transition: 0.2s;
            text-align: left;
        }
        .header-flyout a:hover {
            color: var(--primary);
            background-color: rgba(128,128,128,0.1);
            padding-left: 20px;
        }

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

        /* BLOCO CENTRO: Nome da Página em Destaque */
        .header-center {
            font-size: 18px;
            font-weight: bold;
            color: var(--text-main);
            text-align: center;
            opacity: 0.75;
        }

        /* BLOCO DIREITA: Logótipo do Cliente */
        .header-right {
            display: flex;
            justify-content: flex-end;
            align-items: center;
        }
        .client-logo {
            height: 18px; /* Altura ideal discreta para barra superior */
            max-width: 140px;
            object-fit: contain;
            opacity: 0.8;
            transition: 0.2s;
            margin-right: 9px;
        }
        .client-logo:hover { opacity: 1; }

        /* CONTAINER PARA EMBED DO POWER BI */
        .bi-iframe-container {
            flex: 1;
            width: 100%;
            height: 100%;
            background-color: var(--bg-geral); 
            background-image: var(--bi-pattern);
            background-repeat: repeat;           /* Faz a imagem se repetir como padrão */
            background-position: center;         /* Centraliza o início do padrão */
            background-size: auto;
            border-radius: 6px;
            border: 0px solid var(--border-color);
            overflow: hidden;
            box-shadow: 
                inset 1px -1px 1px rgba(255, 255, 255, 0.1), 
                inset -1px 1px 1px rgba(0, 0, 0, 0.15);
        }
        .bi-iframe-container iframe {
            width: 100%;
            margin-top: -40px;
            height: calc(100% + 40px) !important;
            border: none;
            position: relative;
            aspect-ratio: 16 / 9;
        }

        .card { 
            background-color: var(--bg-content); 
            border-radius: 8px; 
            padding: 18px; 
            margin-bottom: 9px; 
            border: 0px solid var(--border-color);
            box-shadow: 
                inset 1px -1px 1px rgba(255, 255, 255, 0.1), 
                inset -1px 1px 1px rgba(0, 0, 0, 0.15);
        }
        .card h3 { margin-top: 0; margin-bottom: 15px; font-size: 16px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
        .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
        .input-group { display: flex; flex-direction: column; }
        .input-group label { font-size: 11px; font-weight: bold; margin-bottom: 4px; opacity: 0.7; text-transform: uppercase; }
        .input-group input, .input-group select { padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 13px; outline: none; background-color: transparent; color: var(--text-main); }
        
        .btn { padding: 8px 16px; border: none; border-radius: 4px; font-weight: bold; cursor: pointer; transition: 0.3s; font-size: 13px; margin-top: 15px; }
        .btn-primary { background-color: var(--primary); color: #0a0a0f; }
        .btn-secondary { background-color: var(--border-color); color: var(--contrasting); }
        .msg-box { font-size: 13px; font-weight: bold; margin-left: 10px; display: inline-block; }

        table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
        th, td { padding: 8px; border: 1px solid var(--border-color); text-align: left; }
        th { background-color: var(--bg-table-head); color: var(--text-main); }
        
        /* Modal do CSV */
        .modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); justify-content: center; align-items: center; z-index: 1000; }
        .modal-content { background: var(--bg-card); padding: 25px; border-radius: 8px; width: 500px; color: var(--text-main); }
        .mapping-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
        .mapping-row select { padding: 4px; border-radius: 4px; background: transparent; color: var(--text-main); border: 1px solid var(--border-color); }