:root {
    /* Paleta Clean SaaS */
    /*
    * Core Y.MA-UI-v1.03 Module - Rev. 2.4.11 2025 # GAJ Connect #
    */ 
    --bg-body: #F4F7FE; /* Fundo geral cinza-azulado claro */
    --bg-card: #FFFFFF; /* Cartões Brancos */
    --bg-sidebar: #FFFFFF; /* Sidebar Branca */

    --text-primary: #2B3674; /* Azul marinho escuro para títulos */
    --text-secondary: #A3AED0; /* Cinza para legendas */
    --text-body: #707EAE; /* Texto comum */

    --accent-blue: #4318FF; /* Azul vibrante */
    --accent-light: #F4F7FE;
    --radius-card: 20px;
    --radius-sm: 10px;
    --shadow-soft: 0px 18px 40px rgba(112, 144, 176, 0.12);
    --shadow-hover: 0px 18px 40px rgba(112, 144, 176, 0.20);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* --- LAYOUT GRID --- */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr; /* Sidebar fixa 280px */
    min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    background: var(--bg-sidebar);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(0,0,0,0.05);
}

.sidebar-footer a {
    color: #e06262;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 50px;
    padding: 0 10px;
}

.brand-icon {
    color: var(--accent-blue);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

    .nav-item:hover, .nav-item.active {
        color: var(--text-primary);
        background: rgba(67, 24, 255, 0.05);
        font-weight: 600;
    }

    .nav-item.active {
        border-right: 4px solid var(--accent-blue);
    }

.nav-divider {
    height: 1px;
    background: #eee;
    margin: 10px 0;
}

/* --- MAIN CONTENT --- */
.main-content {
    padding: 30px 40px;
    overflow-y: auto;
}

/* Top Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}

.header-title h1 {
    font-size: 2.1rem;
    color: var(--text-primary);
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.period-badge {
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}

/* Filters Card */
.filters-card {
    background: var(--bg-card);
    padding: 20px 25px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 200px;
}

    .filter-group label {
        font-size: 0.75rem;
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
    }

    .filter-group select {
        border: 1px solid #E0E5F2;
        background: #F9FAFC;
        padding: 10px;
        border-radius: 10px;
        color: var(--text-primary);
        font-weight: 500;
        outline: none;
    }

/* --- KPI GRID --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 colunas principais */
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s;
}

    .kpi-card:hover {
        transform: translateY(-5px);
        box-shadow: var(--shadow-hover);
    }

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.icon-blue {
    background: #EFF4FB;
    color: var(--accent-blue);
}

.icon-purple {
    background: #F4E7FF;
    color: #9F21E3;
}

.icon-green {
    background: #E6F9F0;
    color: #05CD99;
}

.icon-orange {
    background: #FFF7E6;
    color: #FFB547;
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-info h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

/* Mini KPIs */
.kpi-card.mini {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 15px 20px;
}

    .kpi-card.mini h4 {
        margin: 0;
        font-size: 1.1rem;
        color: var(--text-primary);
    }

/* --- CHARTS SECTION --- */
.charts-section {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Gráfico grande + Pequenos */
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 25px;
    box-shadow: var(--shadow-soft);
    height: 100%;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

    .card-header h3 {
        margin: 0;
        color: var(--text-primary);
        font-size: 1.2rem;
        font-weight: 700;
    }

.btn-icon {
    border: none;
    background: #F4F7FE;
    color: var(--accent-blue);
    width: 35px;
    height: 35px;
    border-radius: 10px;
    cursor: pointer;
}

.side-charts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-body {
    position: relative;
    width: 100%;
}

    .chart-body.small {
        height: 200px;
    }

.main-chart .chart-body {
    height: 350px;
}

/* --- TABLE SECTION --- */
.table-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 25px;
    box-shadow: var(--shadow-soft);
}

.btn-export {
    background: #F4F7FE;
    color: var(--accent-blue);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 15px;
    border-bottom: 1px solid #F2F4F8;
    text-transform: uppercase;
}

td {
    padding: 15px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #F2F4F8;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #FAFCFE;
}

/* Thumbnails */
.ad-thumbnail {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

    .ad-thumbnail:hover {
        transform: scale(1.1);
    }

/* --- MODAL & LOADER --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(43, 54, 116, 0.4); /* Backdrop azulado */
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #FFF;
    border-radius: 20px;
    padding: 20px;
    max-width: 600px;
    width: 95%;
    box-shadow: var(--shadow-hover);
}

/* Botão de Fechar com Texto (Estilo Pílula) */
.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background-color: #FFFFFF;
    color: #FF4D4D; /* Vermelho */
    /* Ajuste para caber o texto */
    width: auto;
    height: auto;
    padding: 10px 20px; /* Mais espaço nas laterais */
    border-radius: 30px; /* Formato Pílula */

    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase; /* Texto em CAIXA ALTA */

    display: flex;
    align-items: center;
    gap: 8px; /* Espaço entre a palavra FECHAR e o X */

    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1010;
    transition: all 0.2s ease;
}

    .modal-close-btn:hover {
        background-color: #FF4D4D;
        color: #FFFFFF;
        transform: translateY(-2px); /* Sobe um pouquinho */
        box-shadow: 0 8px 25px rgba(255, 77, 77, 0.5); /* Brilho vermelho intenso */
    }

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #F4F7FE;
    border-top: 4px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    /* OPCIONAL: Adicione um fundo se quiser que o centro seja opaco */
    background-color: #FFFFFF;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* --- RESPONSIVIDADE & MOBILE ---------------------------------------------------------------------------------------------- */
/* --- RESPONSIVIDADE & MOBILE --- */

/* Esconde o botão de menu no Desktop */
#mobile-menu-btn {
    display: none;
}

/* Overlay para escurecer o fundo */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 998;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    /* --- SIDEBAR MOBILE (Correção do botão Sair) --- */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh; /* Altura total da tela */
        width: 260px;
        z-index: 999;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
        transition: left 0.3s ease-in-out;
        display: flex;
        /* [CORREÇÃO] Permite rolar se a tela for pequena */
        overflow-y: auto;
        /* [CORREÇÃO] Espaço extra embaixo para o botão não colar na borda */
        padding-bottom: 80px;
    }

        .sidebar.active {
            left: 0;
        }

    #mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        padding: 8px;
        border-radius: 8px;
        cursor: pointer;
        box-shadow: var(--shadow-soft);
        margin-right: 15px;
    }

    /* 4. Ajustes no Header para caber o botão e quebrar linha */
    .top-header {
        flex-wrap: wrap;
        gap: 15px;
    }

    .header-title {
        display: block; /* Mantém o botão e o texto lado a lado */
        align-items: center;
        width: 100%;
        flex-wrap: nowrap;
    }

        /* O DIV WRAPPER (que segura o texto) */
        .header-title > div {
            display: block; /* Simplesmente force o bloco, permitindo o fluxo vertical */
            width: 100%;
        }

        .header-title h1 {
            font-size: 1.5rem; /* Ajusta tamanho do título no mobile */
            line-height: 1.2;
            margin-top: 0; /* Remove margem extra */
        }

    .main-content {
        padding: 20px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- CORREÇÃO DOS FILTROS (Estourando) --- */
    .filters-card {
        flex-direction: column; /* Um embaixo do outro */
        align-items: stretch; /* Estica para ocupar a largura */
        gap: 15px;
    }

    .filter-group {
        width: 100%;
        min-width: 0; /* Truque de CSS: impede que flex items estourem */
    }

        .filter-group select {
            width: 100%;
            max-width: 100%; /* Garante que nunca passe da tela */
            text-overflow: ellipsis; /* Corta texto longo com ... */
        }

    /* --- CORREÇÃO DO MODAL NO MOBILE --- */
    .modal-content {
        width: 95%;
        padding: 15px;
        margin: 10px;
    }
}

/* --- CORREÇÃO DO IFRAME (PREVIEW) --- */

.iframe-wrapper {
    width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    background: #fff; /* Fundo branco para mesclar */
    border-radius: 8px;
    padding: 10px 0; /* Um pouco de respiro vertical */
}

    /* Regra Padrão (Desktop) */
    .iframe-wrapper iframe {
        border: none !important;
        min-height: 500px; /* Garante altura suficiente */
    }

/* --- REGRA MÁGICA PARA MOBILE (Encolhe o Iframe) --- */
@media (max-width: 768px) {
    .iframe-wrapper {
        /* Garante que o wrapper segure o conteúdo */
        align-items: flex-start;
        min-height: 400px; /* Espaço reservado para o modal não colapsar */
    }

        .iframe-wrapper iframe {
            /* 1. Força o Iframe a ter a largura "Original" do Facebook (500px) 
           para que o layout interno (texto, botão) não quebre */
            width: 500px !important;
            min-width: 500px !important;
            /* 2. ENCOLHE visualmente para 68% do tamanho */
            /* Isso faz 500px virarem 340px (cabe em qualquer celular) */
            transform: scale(0.68);
            /* 3. Define o ponto de origem da redução (Topo e Centro) */
            transform-origin: top center;
            /* 4. Ajuste fino de margem negativa para remover o espaço vazio 
           que sobra embaixo quando a gente encolhe o elemento */
            margin-bottom: -150px;
        }
}

/* --- TELA DE LOGIN / REGISTRO ---------------------------------------------------------------------------------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #F4F7FE 0%, #E0E7FF 100%);
}

.auth-card {
    background: #FFFFFF;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0px 20px 50px rgba(112, 144, 176, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

    .auth-card h1 {
        color: var(--text-primary);
        font-size: 1.8rem;
        margin-bottom: 10px;
        font-weight: 700;
    }

    .auth-card p {
        color: var(--text-secondary);
        margin-bottom: 30px;
        font-size: 0.95rem;
    }

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

    .form-group label {
        display: block;
        color: var(--text-primary);
        font-weight: 600;
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #E0E5F2;
    border-radius: 12px;
    background: #F9FAFC;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    outline: none;
}

    .form-control:focus {
        border-color: var(--accent-blue);
        background: #fff;
        box-shadow: 0 0 0 3px rgba(67, 24, 255, 0.1);
    }

.btn-auth {
    width: 100%;
    background: var(--accent-blue);
    color: #fff;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

    .btn-auth:hover {
        background: #3311DB;
        transform: translateY(-2px);
        box-shadow: 0 10px 20px rgba(67, 24, 255, 0.2);
    }

.auth-links {
    margin-top: 25px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

    .auth-links a {
        color: var(--accent-blue);
        text-decoration: none;
        font-weight: 600;
    }

        .auth-links a:hover {
            text-decoration: underline;
        }

/* Mensagens de Erro/Sucesso */
.msg-box {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.msg-erro {
    background-color: #FFF5F5;
    color: #E53E3E;
    border: 1px solid #FED7D7;
}

.msg-sucesso {
    background-color: #F0FFF4;
    color: #38A169;
    border: 1px solid #C6F6D5;
}

#global-loader-overlay {
    /* 1. POSICIONAMENTO: Garante que cubra a tela e fique por cima */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999; /* Z-index bem alto para garantir que fique em cima de tudo */
    /* 2. CENTRALIZAÇÃO: Usa Flexbox para colocar o spinner no centro */
    display: flex;
    justify-content: center; /* Centraliza horizontalmente */
    align-items: center; /* Centraliza verticalmente */
    /* 3. EFEITO BLUR (Desfoque) */
    background: rgba(255, 255, 255, 0.6); /* Fundo branco semi-transparente */
    backdrop-filter: blur(4px); /* Aplica o desfoque ao que está ATRÁS do overlay */
    /* Nota: Se o seu loader aparece inicialmente escondido, mantenha ou adicione 'display: none;' 
       e use JavaScript para alternar para 'display: flex;' quando o carregamento iniciar. */
}

/* --- ESTILOS DA LISTA DE RELATÓRIOS (Adicionar ao final do style.css) --- */

.report-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 20px;
}

.report-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 25px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid transparent;
}

    .report-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-hover);
        border-color: rgba(67, 24, 255, 0.1);
    }

.report-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.report-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: #EFF4FB;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.report-details h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 700;
}

.report-details p {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.report-tag {
    background: #E6F9F0;
    color: #05CD99;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.report-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-view {
    background: var(--accent-blue);
    color: #fff;
    padding: 10px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .btn-view:hover {
        background: #3311DB;
        box-shadow: 0 5px 15px rgba(67, 24, 255, 0.3);
    }

.btn-delete {
    background: #FFF5F5;
    color: #E53E3E;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 1.1rem;
}

    .btn-delete:hover {
        background: #FED7D7;
    }

/* Responsivo para os cards (Mobile) */
@media (max-width: 768px) {
    .report-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .report-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-view {
        flex: 1;
        justify-content: center;
    }
}

/* --- ACCORDION LIST (Substitui a Tabela) --- *****************************************************************************************/

.sort-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 20px;
    border-bottom: 1px solid #F2F4F8;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sort-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

.btn-sort {
    background: #F4F7FE;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

    .btn-sort:hover {
        background: #E0E5F2;
        color: var(--text-primary);
    }

    .btn-sort.active {
        background: var(--accent-blue);
        color: #fff;
    }

/* O Item da Lista (Card) */
.accordion-item {
    border: 1px solid #F2F4F8;
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.2s;
    overflow: hidden; /* Garante que o conteúdo oculto não vaze */
}

    .accordion-item:hover {
        border-color: #E0E7FF;
        box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    }

/* Cabeçalho do Item (Sempre visível) */
.accordion-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    background: #fff;
}

.acc-main-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.acc-thumb {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    background: #eee;
}

.acc-title h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.acc-title span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.acc-metrics {
    display: flex;
    gap: 30px;
    margin-right: 20px;
    text-align: right;
}

.acc-metric-box label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.acc-metric-box strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.acc-toggle-icon {
    color: var(--accent-blue);
    font-size: 1.2rem;
    transition: transform 0.3s;
}

/* Estado Aberto */
.accordion-item.open .acc-toggle-icon {
    transform: rotate(180deg);
}

.accordion-item.open {
    border-color: var(--accent-blue);
}

/* Corpo do Item (Detalhes Ocultos) */
.accordion-body {
    display: none; /* Escondido por padrão */
    padding: 20px;
    background: #F8FAFC;
    border-top: 1px solid #F2F4F8;
}

.accordion-item.open .accordion-body {
    display: block; /* Mostra quando tem a classe open */
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
}

.detail-box {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

    .detail-box span {
        display: block;
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin-bottom: 5px;
    }

    .detail-box h5 {
        margin: 0;
        font-size: 1.1rem;
        color: var(--text-primary);
    }

.btn-preview-full {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 10px 20px;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Responsivo Mobile */
@media (max-width: 768px) {
    .accordion-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .acc-metrics {
        width: 100%;
        justify-content: space-between;
        margin-right: 0;
    }

    .acc-toggle-icon {
        position: absolute;
        top: 20px;
        right: 20px;
    }

    .accordion-item {
        position: relative;
    }
}

/* --- TELA DE ORGANIZAÇÕES (Admin Orgs) --- *****************************************/

/* Ajuste do Grid para ficar mais largo se tiver poucas orgs */
#org-list.user-list-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* O Cartão da Organização (Refinamento do user-card) */
#org-list .user-card {
    border-left: 4px solid var(--accent-blue); /* Detalhe azul na esquerda */
    transition: all 0.2s ease;
}

#org-list .user-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(112, 144, 176, 0.15);
}

/* Ícone de Prédio */
.org-icon-wrapper {
    width: 45px;
    height: 45px;
    background: #F4F7FE;
    color: var(--accent-blue);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-right: 15px;
}

/* Badge do ID (Aquele span pequeno) */
.org-id-badge {
    font-size: 0.75rem;
    background: #E2E8F0;
    color: #4A5568;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 700;
    margin-left: 10px;
    letter-spacing: 0.5px;
}

/* Título da Org */
.org-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
}

/* Área de Ações (Botões) */
.org-actions {
    display: flex;
    gap: 8px;
}

.org-actions button {
    width: 35px;
    height: 35px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

/* Botão Editar (Azul suave) */
.btn-edit-org {
    background: #EFF4FB;
    color: var(--accent-blue);
}
.btn-edit-org:hover {
    background: var(--accent-blue);
    color: #fff;
}

/* Botão Excluir (Vermelho suave) */
.btn-del-org {
    background: #FFF5F5;
    color: #E53E3E;
}
.btn-del-org:hover {
    background: #E53E3E;
    color: #fff;
}

/* --- PAINEL GOD MODE (Select de Organização) --- */

/* O Container Amarelo */
#div-organizacao {
    background-color: #FFF7E6 !important;
    border: 1px solid #FBD38D;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    animation: fadeIn 0.3s ease-in-out;
}

/* O Label do God Mode */
#div-organizacao label {
    color: #975A16 !important;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    display: block;
}

/* O Select do God Mode */
#select-organizacao {
    width: 100%;
    padding: 12px;
    border: 1px solid #FBD38D;
    border-radius: 8px;
    background-color: #fff;
    color: #2D3748;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    /* Remove a seta padrão feia e coloca uma customizada (opcional) */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23975A16%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
}

#select-organizacao:focus {
    border-color: #DD6B20;
    box-shadow: 0 0 0 3px rgba(221, 107, 32, 0.2);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Botão de Filtro Toggle (Admin Home) */
.btn-filter-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #E0E5F2;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter-toggle:hover {
    background: #F4F7FE;
    color: var(--text-primary);
}

/* Estado Ativo (Escondendo Admins) */
.btn-filter-toggle.active {
    background: #FFF5F5;     /* Fundo avermelhado suave */
    color: #C53030;          /* Texto vermelho */
    border-color: #FEB2B2;
}

.btn-filter-toggle.active i:last-child {
    /* Troca visualmente o ícone se quiser via CSS ou JS (vamos via JS) */
}

/* --- ACTIVE ADS (Agrupado por Conjunto) --- */

/* Removemos o grid do container pai, pois agora ele segura seções */
#ads-container {
    display: block; 
}

.adset-section {
    margin-bottom: 40px;
    background: #fff;
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-soft);
    border: 1px solid #F2F4F8;
}

.adset-title {
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 700;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #F2F4F8;
    display: flex;
    align-items: center;
    gap: 10px;
}

.adset-title i {
    color: var(--accent-blue);
}

.adset-count {
    font-size: 0.8rem;
    background: #EFF4FB;
    color: var(--accent-blue);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* O Grid Interno (Dentro de cada conjunto) */
.ads-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

/* Ajustes no Card */
.ad-card {
    border: 1px solid #eee;
    box-shadow: none; /* Remove a sombra do card pra não brigar com a sombra da seção */
}
.ad-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border-color: var(--accent-blue);
}