:root {
    --black: #0a0a0f;
    --black-soft: #12121a;
    --gray-dark: #1a1a24;
    --gray: #2a2a38;
    --gray-muted: #6a6a7a;
    --white: #f0f0f5;
    --white-muted: #b0b0c0;
    --red: #e63946;
    --red-translucent: rgba(230, 57, 70, 0.15);
    --glass: rgba(26, 26, 36, 0.7);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-hover: rgba(42, 42, 56, 0.85);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--black);
    color: var(--white);
    min-height: 100vh;
}

.dashboard-wrapper { position: relative; min-height: 100vh; }
.bg-grid {
    position: fixed; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px; pointer-events: none; z-index: 0;
}
.bg-glow {
    position: fixed; top: -50%; right: -20%; width: 80%; height: 100%;
    background: radial-gradient(ellipse, var(--red-translucent) 0%, transparent 70%);
    pointer-events: none; z-index: 0;
}

.dashboard-header {
    position: relative; z-index: 1;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--glass-border);
}
.logo-section { display: flex; align-items: center; gap: 16px; }
.logo-icon {
    width: 48px; height: 48px; background: var(--red-translucent);
    border: 1px solid rgba(230, 57, 70, 0.3); border-radius: 12px;
    display: flex; align-items: center; justify-content: center; color: var(--red);
}
.logo-icon svg { width: 28px; height: 28px; }
.logo-section h1 { font-size: 1.5rem; font-weight: 700; }
.subtitle { font-size: 0.85rem; color: var(--gray-muted); }
.last-update { font-size: 0.8rem; color: var(--gray-muted); display: flex; align-items: center; gap: 8px; }
.pulse { width: 8px; height: 8px; background: var(--red); border-radius: 50%; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.glass {
    background: var(--glass); backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: 16px;
}

.kpi-grid {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px; margin-bottom: 32px;
}
.kpi-card {
    padding: 20px; display: flex; align-items: center; gap: 16px;
    transition: all 0.3s;
}
.kpi-card:hover {
    background: var(--glass-hover); border-color: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}
.kpi-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 24px; height: 24px; }
.kpi-icon.spend, .kpi-icon.ctr, .kpi-icon.cpm { background: var(--red-translucent); color: var(--red); }
.kpi-icon.impressions, .kpi-icon.reach, .kpi-icon.clicks, .kpi-icon.leads { background: rgba(74, 74, 90, 0.5); color: var(--white-muted); }
.kpi-icon.engagement, .kpi-icon.frequency { background: rgba(74, 74, 90, 0.5); color: var(--white-muted); }
.kpi-content { display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 0.75rem; color: var(--gray-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.25rem; font-weight: 700; }
.kpi-card.highlight .kpi-value { color: var(--red); }

/* Filtros */
.filters-section { position: relative; z-index: 1; padding: 20px 24px; margin-bottom: 28px; }
.filters-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 16px; color: var(--white-muted); }
.filters-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; align-items: end;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 0.7rem; color: var(--gray-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.filter-group select, .filter-group input {
    background: var(--gray-dark); border: 1px solid var(--glass-border); border-radius: 8px;
    color: var(--white); padding: 10px 12px; font-size: 0.85rem;
}
.filter-group select:focus, .filter-group input:focus { outline: none; border-color: rgba(230, 57, 70, 0.4); }
.filter-actions { display: flex; gap: 10px; align-items: flex-end; }
.btn-apply, .btn-reset {
    padding: 10px 18px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; border: none;
}
.btn-apply { background: var(--red); color: var(--white); }
.btn-apply:hover { background: #c92a38; }
.btn-apply:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--white-muted); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: var(--glass-bg); color: var(--white); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-reset { background: var(--gray); color: var(--white-muted); }
.btn-reset:hover { background: var(--gray-muted); color: var(--white); }

/* Seções */
.kpi-section, .charts-section, .table-section { position: relative; z-index: 1; margin-bottom: 32px; }
.section-title { font-size: 1rem; font-weight: 600; color: var(--white-muted); margin-bottom: 8px; }
.period-hint { font-size: 0.8rem; color: var(--gray-muted); margin-bottom: 16px; }

.kpi-grid-compact .kpi-card { padding: 14px 18px; }
.kpi-grid-compact .kpi-icon { width: 40px; height: 40px; }
.kpi-grid-compact .kpi-icon svg { width: 20px; height: 20px; }
.kpi-grid-compact .kpi-value { font-size: 1.1rem; }

/* Hero métricas: animação de fundo + grid de cards ocupando toda a tela, sem sobreposição */
.metrics-hero-section {
    position: relative;
    height: 100vh;
    min-height: 560px;
    overflow: hidden;
    margin-bottom: 24px;
}
.metrics-hero {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}
/* Resumo e período na lateral esquerda */
.metrics-hero-title {
    position: absolute;
    top: 24px;
    left: 24px;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--white-muted);
    z-index: 3;
    pointer-events: none;
}
.metrics-hero-hint {
    position: absolute;
    top: 48px;
    left: 24px;
    margin: 0;
    font-size: 0.78rem;
    color: var(--gray-muted);
    z-index: 3;
    pointer-events: none;
}
.metrics-hero-neon {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}
#orbital-container {
    width: 100%;
    height: 100%;
}
#orbital-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    vertical-align: top;
    pointer-events: auto;
}
.orbital-credits {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    font-family: monospace;
    pointer-events: none;
    z-index: 1;
}
/* Cards nos extremos da animação: posições radiais (pontos de conexão), tamanhos variados, hover aproximação */
.metrics-hero-cards-grid {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.metrics-hero-cards-grid > .metrics-hero-card {
    pointer-events: auto;
}
/* Tamanhos padronizados: S, M, L — retângulos com bordas arredondadas */
.metrics-hero-card.card-size-s { width: 142px; min-height: 74px; padding: 10px 12px; gap: 10px; }
.metrics-hero-card.card-size-s .kpi-icon { width: 34px; height: 34px; min-width: 34px; }
.metrics-hero-card.card-size-s .kpi-icon svg { width: 16px; height: 16px; }
.metrics-hero-card.card-size-s .kpi-label { font-size: 0.62rem; }
.metrics-hero-card.card-size-s .kpi-value { font-size: 0.95rem; }
.metrics-hero-card.card-size-m { width: 168px; min-height: 86px; padding: 12px 14px; gap: 12px; }
.metrics-hero-card.card-size-m .kpi-icon { width: 38px; height: 38px; min-width: 38px; }
.metrics-hero-card.card-size-m .kpi-icon svg { width: 18px; height: 18px; }
.metrics-hero-card.card-size-m .kpi-label { font-size: 0.66rem; }
.metrics-hero-card.card-size-m .kpi-value { font-size: 1.02rem; }
.metrics-hero-card.card-size-l { width: 192px; min-height: 96px; padding: 14px 16px; gap: 14px; }
.metrics-hero-card.card-size-l .kpi-icon { width: 42px; height: 42px; min-width: 42px; }
.metrics-hero-card.card-size-l .kpi-icon svg { width: 20px; height: 20px; }
.metrics-hero-card.card-size-l .kpi-label { font-size: 0.7rem; }
.metrics-hero-card.card-size-l .kpi-value { font-size: 1.1rem; }
/* Base: translúcido, contorno neon, bordas arredondadas */
.metrics-hero-card {
    position: absolute;
    left: 50%;
    top: 50%;
    --tx: 0;
    --ty: 0;
    --angle-in: 180deg;
    transform: translate(calc(-50% + var(--tx) * 1px), calc(-50% + var(--ty) * 1px));
    border-radius: 14px;
    border: 2px solid rgba(230, 57, 70, 0.7);
    box-shadow: 0 0 14px rgba(230, 57, 70, 0.4), 0 0 28px rgba(230, 57, 70, 0.18), inset 0 0 20px rgba(230, 57, 70, 0.05);
    transition: transform 0.25s ease, box-shadow 0.25s, border-color 0.25s;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    background: var(--glass);
    backdrop-filter: blur(20px);
    overflow: visible;
}
/* Fios dos cards são desenhados pela animação (canvas), do centro até cada card */
.metrics-hero-card .kpi-content { min-width: 0; }
.metrics-hero-card .kpi-value { font-weight: 700; }
/* Hover: efeito de aproximação (scale + brilho) nos cards conectados aos extremos */
.metrics-hero-card:hover {
    transform: translate(calc(-50% + var(--tx) * 1px), calc(-50% + var(--ty) * 1px)) scale(1.08);
    border-color: rgba(230, 57, 70, 0.95);
    box-shadow: 0 0 24px rgba(230, 57, 70, 0.6), 0 0 48px rgba(230, 57, 70, 0.25), inset 0 0 24px rgba(230, 57, 70, 0.08);
}
/* Posições radiais: cards nos “pontos” das extremidades da animação (3 anéis) */
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(1) { --tx: 300; --ty: 0; --angle-in: 180deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(2) { --tx: 150; --ty: 260; --angle-in: 240deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(3) { --tx: -150; --ty: 260; --angle-in: 300deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(4) { --tx: -300; --ty: 0; --angle-in: 0deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(5) { --tx: -150; --ty: -260; --angle-in: 60deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(6) { --tx: 150; --ty: -260; --angle-in: 120deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(7) { --tx: 374; --ty: 216; --angle-in: 210deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(8) { --tx: 0; --ty: 432; --angle-in: 270deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(9) { --tx: -374; --ty: 216; --angle-in: 330deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(10) { --tx: -374; --ty: -216; --angle-in: 30deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(11) { --tx: 0; --ty: -432; --angle-in: 90deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(12) { --tx: 374; --ty: -216; --angle-in: 150deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(13) { --tx: 552; --ty: 0; --angle-in: 180deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(14) { --tx: 276; --ty: 478; --angle-in: 240deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(15) { --tx: -276; --ty: 478; --angle-in: 300deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(16) { --tx: -552; --ty: 0; --angle-in: 0deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(17) { --tx: -276; --ty: -478; --angle-in: 60deg; }
.metrics-hero-cards-grid > .metrics-hero-card:nth-child(18) { --tx: 276; --ty: -478; --angle-in: 120deg; }

@media (max-width: 900px) {
    .metrics-hero-section {
        height: auto;
        min-height: auto;
        overflow: visible;
        padding-bottom: 24px;
    }
    .metrics-hero {
        position: relative;
        min-height: auto;
        flex-direction: column;
    }
    .metrics-hero-cards-grid {
        position: relative;
        pointer-events: auto;
        padding: 72px 16px 24px 16px;
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
        max-width: 360px;
        margin: 0 auto;
    }
    .metrics-hero-cards-grid > .metrics-hero-card {
        position: relative;
        left: auto;
        top: auto;
        width: 100% !important;
        min-width: 0;
        transform: none !important;
    }
    .metrics-hero-cards-grid > .metrics-hero-card:hover {
        transform: scale(1.02) !important;
    }
    .metrics-hero-title { position: relative; top: auto; left: auto; margin-bottom: 4px; padding: 0 16px; }
    .metrics-hero-hint { position: relative; top: auto; left: auto; margin-bottom: 16px; padding: 0 16px; }
    .metrics-hero-neon {
        position: relative;
        height: 260px;
        width: 100%;
        flex-shrink: 0;
    }
}

.charts-grid {
    position: relative; z-index: 1;
    display: grid; grid-template-columns: 2fr 1fr; gap: 24px;
}
.chart-card { padding: 24px; }
.chart-card.large { grid-column: span 1; }
.charts-grid .chart-card.large:last-child:nth-child(odd) { grid-column: 1 / -1; }
.chart-header { margin-bottom: 20px; }
.chart-header h3 { font-size: 1rem; font-weight: 600; }
.chart-container { position: relative; height: 280px; }

/* Tabela – colunas roláveis e larguras mínimas para leitura dos títulos */
.table-section { padding: 0; }
.table-wrapper { overflow-x: auto; overflow-y: visible; border-radius: 12px; border: 1px solid var(--glass-border); -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%; min-width: 2400px; border-collapse: collapse; font-size: 0.85rem; background: var(--glass);
}
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--glass-border); }
.data-table th { background: var(--gray-dark); color: var(--gray-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.data-table th.th-campaign { min-width: 160px; }
.data-table th.th-objective { min-width: 120px; }
.data-table th.th-conta { min-width: 140px; }
.data-table th.th-date { min-width: 140px; }
.data-table th.th-num { min-width: 95px; text-align: right; }
.data-table tbody tr:hover { background: var(--glass-hover); }
.data-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; min-width: 95px; }
.data-table .cell-name { min-width: 160px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .cell-objective { min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .cell-date { min-width: 140px; white-space: nowrap; }
.data-table .empty-table { text-align: center; color: var(--gray-muted); padding: 32px; }

/* Abas */
.app-layout {
    position: relative; z-index: 1;
    display: flex; min-height: 100vh;
}
.sidebar {
    width: 56px; flex-shrink: 0;
    position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto; overflow-x: hidden;
    background: var(--glass); backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
    transition: width 0.25s ease;
}
.sidebar:hover { width: 220px; }
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 14px; min-height: 56px;
    border-bottom: 1px solid var(--glass-border);
}
.sidebar-brand-icon {
    width: 36px; height: 36px; flex-shrink: 0;
    background: var(--red-translucent); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; color: var(--red);
}
.sidebar-brand-icon svg { width: 20px; height: 20px; }
.sidebar-brand-text {
    font-size: 1rem; font-weight: 700; color: var(--white);
    white-space: nowrap; opacity: 0;
    transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-brand-text { opacity: 1; }
.sidebar-nav {
    padding: 12px 0; display: flex; flex-direction: column; gap: 4px;
}
.sidebar-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 12px 14px; margin: 0 8px; border: none; border-radius: 10px;
    background: transparent; color: var(--gray-muted);
    font-size: 0.9rem; font-weight: 500; font-family: inherit;
    cursor: pointer; transition: all 0.2s;
    text-align: left;
}
.sidebar-item:hover { color: var(--white); background: var(--glass-hover); }
.sidebar-item.active { background: var(--red-translucent); color: var(--red); }
.sidebar-icon {
    width: 24px; height: 24px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-icon svg { width: 22px; height: 22px; }
.sidebar-label {
    white-space: nowrap; opacity: 0;
    transition: opacity 0.2s ease;
}
.sidebar:hover .sidebar-label { opacity: 1; }
.sidebar-group { margin: 0 8px; }
.sidebar-item-toggle { position: relative; }
.sidebar-chevron {
    margin-left: auto; font-size: 1rem; color: var(--gray-muted);
    transition: transform 0.2s;
}
.sidebar-item-toggle[aria-expanded="true"] .sidebar-chevron { transform: rotate(90deg); }
.sidebar-submenu {
    padding: 4px 0 4px 36px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px;
}
.sidebar-submenu[hidden] { display: none !important; }
.sidebar-subitem {
    padding: 10px 12px; border: none; border-radius: 8px; background: transparent;
    color: var(--gray-muted); font-size: 0.85rem; text-align: left; cursor: pointer;
    transition: all 0.2s;
}
.sidebar-subitem:hover { background: var(--glass-hover); color: var(--white); }
.sidebar-subitem.active { background: rgba(230, 57, 70, 0.15); color: var(--red); }

.main-content {
    flex: 1; min-width: 0; padding: 24px; overflow-x: hidden; overflow-y: auto;
}
.tab-panel.hidden { display: none !important; }

/* Gestão com I.A */
.gestao-section { position: relative; z-index: 1; padding: 24px; margin-bottom: 32px; }
.gestao-levels {
    display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; align-items: center;
}
.gestao-levels .radio-label {
    display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; color: var(--white-muted);
}
.gestao-levels input { accent-color: var(--red); }
.alerts-container { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.alert-banner {
    padding: 14px 18px; border-radius: 12px; display: flex; align-items: flex-start; gap: 12px;
    font-size: 0.9rem; border: 1px solid;
}
.alert-banner.warning {
    background: rgba(230, 180, 50, 0.12); border-color: rgba(230, 180, 50, 0.5); color: #e6b432;
}
.alert-banner.warning .alert-icon { color: #e6b432; }
.alert-banner .alert-icon { flex-shrink: 0; width: 22px; height: 22px; }
.gestao-grid {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin-bottom: 24px;
}
.gestao-block { padding: 24px; }
.gestao-block-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: var(--white-muted); }
.kanban-board {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; min-height: 320px;
}
.kanban-column {
    background: var(--gray-dark); border-radius: 12px; border: 1px solid var(--glass-border);
    display: flex; flex-direction: column; overflow: hidden;
}
.kanban-column-header {
    padding: 12px 14px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
}
.kanban-column-header.alto { background: rgba(230, 57, 70, 0.2); color: var(--red); }
.kanban-column-header.medio { background: rgba(74, 74, 90, 0.5); color: var(--white-muted); }
.kanban-column-header.baixo { background: rgba(74, 74, 90, 0.3); color: var(--gray-muted); }
.kanban-cards {
    flex: 1; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.kanban-card {
    background: var(--glass); border: 1px solid var(--glass-border); border-radius: 10px;
    padding: 0; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; overflow: hidden;
}
.kanban-card:hover { border-color: rgba(230, 57, 70, 0.3); background: var(--glass-hover); }
.kanban-card:focus { outline: none; border-color: rgba(230, 57, 70, 0.5); box-shadow: 0 0 0 2px rgba(230, 57, 70, 0.2); }
.kanban-card-preview { padding: 12px 14px; transition: opacity 0.2s; }
.kanban-card-preview.hidden { display: none; }
.kanban-card-id { font-family: monospace; font-size: 0.7rem; color: var(--gray-muted); margin-bottom: 4px; word-break: break-all; }
.kanban-card-name { font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-meta { font-size: 0.7rem; color: var(--gray-muted); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-metrics { display: flex; flex-wrap: wrap; gap: 6px 10px; color: var(--white-muted); font-size: 0.75rem; }
.kanban-card-metrics span { font-variant-numeric: tabular-nums; }
.kanban-card-toggle { margin-top: 10px; font-size: 0.75rem; color: var(--red); font-weight: 500; }
.kanban-card-toggle.close { margin-top: 12px; }
.kanban-card-detail {
    padding: 14px; border-top: 1px solid var(--glass-border); background: rgba(0,0,0,0.2);
    max-height: 320px; overflow-y: auto;
}
.kanban-card-detail[hidden] { display: none !important; }
.kanban-card-detail-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gray-muted); margin-bottom: 4px; }
.kanban-card-detail-name { font-weight: 600; font-size: 0.85rem; margin-bottom: 12px; word-break: break-word; }
.kanban-detail-grid { display: flex; flex-direction: column; gap: 6px; font-size: 0.78rem; }
.kanban-detail-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline; }
.kanban-detail-row .kanban-detail-label { color: var(--gray-muted); }
.kanban-detail-row .kanban-detail-value { font-variant-numeric: tabular-nums; word-break: break-all; }
.empty-kanban { font-size: 0.85rem; color: var(--gray-muted); padding: 16px; text-align: center; }
.funnel-container { min-height: 280px; }
.funnel-chart {
    display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 0;
}
.funnel-stage {
    width: 100%; max-width: 320px; padding: 14px 18px; border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center;
    background: var(--gray-dark); border: 1px solid var(--glass-border);
    font-size: 0.9rem;
}
.funnel-stage .label { color: var(--white-muted); }
.funnel-stage .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel-stage.impressions .value { color: var(--white); }
.funnel-stage.reach .value { color: var(--white-muted); }
.funnel-stage.clicks .value { color: var(--red); }
.funnel-stage.leads .value { color: var(--red); }
.funnel-stage.mensagens .value { color: var(--white-muted); }
.funnel-stage.seguidores .value { color: var(--white-muted); }
.funnel-stage.spend .value { color: var(--red); }

/* CRM — Pipeline, agente I.A, fluxos, tela conversa + detalhes */
.crm-section { position: relative; z-index: 1; padding: 24px; margin-bottom: 32px; }
.crm-subnav {
    display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap;
}
.crm-subnav-btn {
    padding: 10px 18px; border-radius: 10px; border: 1px solid var(--glass-border);
    background: var(--gray-dark); color: var(--white-muted); font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.crm-subnav-btn:hover { background: var(--glass-hover); color: var(--white); }
.crm-subnav-btn.active { background: var(--red-translucent); border-color: rgba(230, 57, 70, 0.5); color: var(--red); }
.crm-view.hidden { display: none !important; }
.crm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.crm-search-input { flex: 1; min-width: 200px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(0,0,0,0.2); color: var(--white-muted); font-size: 0.9rem; }
.crm-search-input::placeholder { color: var(--gray-muted); }
.crm-btn-sync { margin: 0; }
.crm-btn-new { margin: 0; }
.crm-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); }
.crm-modal.hidden { display: none; }
.crm-modal-content { padding: 24px; border-radius: 12px; min-width: 320px; max-width: 420px; }
.crm-modal-content h3 { margin-bottom: 8px; color: var(--white-muted); }
.crm-modal-desc { font-size: 0.85rem; color: var(--gray-muted); margin-bottom: 16px; }
.crm-modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.crm-form-content .form-row { margin-bottom: 14px; }
.crm-form-content .form-row label { display: block; font-size: 0.85rem; color: var(--white-muted); margin-bottom: 6px; }
.crm-form-content .form-row label .required { color: var(--red); }
.crm-form-content .form-row input, .crm-form-content .form-row select {
    width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--glass-border);
    background: var(--gray-dark); color: var(--white); font-size: 0.9rem; font-family: inherit;
}
.crm-form-content .form-hint { font-size: 0.75rem; color: var(--gray-muted); margin-top: 4px; }
.crm-form-error { font-size: 0.85rem; color: var(--red); margin-top: 8px; }
.crm-form-error.hidden { display: none; }
.crm-status-message { font-size: 0.9rem; margin-top: 8px; margin-bottom: 0; padding: 8px 12px; border-radius: 8px; }
.crm-status-message.hidden { display: none; }
.crm-status-message.crm-status-ok { background: rgba(70, 180, 120, 0.15); color: #46b478; }
.crm-status-message.crm-status-error { background: rgba(230, 57, 70, 0.15); color: var(--red); }
.btn-cancel { padding: 10px 18px; border-radius: 8px; border: 1px solid var(--glass-border); background: transparent; color: var(--gray-muted); cursor: pointer; }
.btn-cancel:hover { color: var(--white-muted); }

.crm-kanban { grid-template-columns: repeat(5, 1fr); min-height: 380px; }
.crm-kanban .kanban-column-header.crm-novo { background: rgba(106, 159, 181, 0.25); color: #6a9fb5; }
.crm-kanban .kanban-column-header.crm-qual { background: rgba(230, 180, 50, 0.2); color: #e6b432; }
.crm-kanban .kanban-column-header.crm-prop { background: rgba(230, 57, 70, 0.2); color: var(--red); }
.crm-kanban .kanban-column-header.crm-neg { background: rgba(74, 74, 90, 0.5); color: var(--white-muted); }
.crm-kanban .kanban-column-header.crm-fechado { background: rgba(70, 180, 120, 0.2); color: #46b478; }
.crm-module { padding: 24px; margin-bottom: 24px; }
.crm-module-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--white-muted); }
.crm-module-desc { font-size: 0.85rem; color: var(--gray-muted); margin-bottom: 20px; }
.crm-agent-form .form-row { margin-bottom: 16px; }
.crm-agent-form label { display: block; font-size: 0.8rem; color: var(--gray-muted); margin-bottom: 6px; }
.crm-agent-form input[type="text"], .crm-agent-form textarea {
    width: 100%; max-width: 480px; padding: 12px 14px; border-radius: 10px;
    background: var(--gray-dark); border: 1px solid var(--glass-border); color: var(--white);
    font-size: 0.9rem; font-family: inherit;
}
.crm-agent-form textarea { resize: vertical; min-height: 100px; }
.channel-toggles { display: flex; flex-wrap: wrap; gap: 16px; }
.channel-toggle { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--white-muted); cursor: pointer; }
.crm-flows-placeholder { padding: 20px; background: var(--gray-dark); border-radius: 12px; border: 1px dashed var(--glass-border); }
.crm-flows-placeholder p { font-size: 0.9rem; color: var(--gray-muted); margin-bottom: 16px; }
.flows-preview {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px;
    background: rgba(0,0,0,0.2); border-radius: 10px;
}
.flow-node {
    padding: 10px 14px; border-radius: 8px; background: var(--glass); border: 1px solid var(--glass-border);
    font-size: 0.8rem; color: var(--white-muted);
}
.flow-arrow { color: var(--red); font-size: 1rem; }

.crm-conversation-panel {
    position: fixed; inset: 0; z-index: 200;
    background: var(--black); display: flex; flex-direction: column;
}
.crm-conversation-panel.hidden { display: none !important; }
.crm-conversation-header {
    padding: 14px 20px; border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; gap: 16px; background: var(--black-soft);
}
.crm-conversation-back {
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--glass-border);
    background: var(--gray-dark); color: var(--white); font-size: 0.9rem; cursor: pointer;
}
.crm-conversation-back:hover { background: var(--glass-hover); }
.crm-conversation-title { font-weight: 600; font-size: 1rem; }
.crm-conversation-body {
    flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0;
}
.crm-conversation-chat {
    display: flex; flex-direction: column; border-right: 1px solid var(--glass-border);
}
.crm-chat-messages {
    flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px;
    min-height: 200px;
}
.crm-chat-msg { max-width: 85%; padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; }
.crm-chat-msg.user { align-self: flex-end; background: var(--red-translucent); border: 1px solid rgba(230, 57, 70, 0.3); }
.crm-chat-msg.contact { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-border); }
.crm-chat-msg .crm-chat-meta { font-size: 0.7rem; color: var(--gray-muted); margin-bottom: 4px; }
.crm-chat-msg.system { align-self: center; background: rgba(230, 57, 70, 0.15); color: var(--red); font-size: 0.85rem; }
.crm-chat-loading, .crm-chat-empty { padding: 24px; text-align: center; color: var(--gray-muted); font-size: 0.9rem; }
.crm-chat-input-wrap {
    padding: 16px; border-top: 1px solid var(--glass-border);
    display: flex; gap: 10px; align-items: flex-end; background: var(--black-soft);
}
.crm-chat-input {
    flex: 1; min-height: 44px; max-height: 120px; padding: 12px 14px; border-radius: 10px;
    background: var(--gray-dark); border: 1px solid var(--glass-border); color: var(--white);
    font-size: 0.9rem; font-family: inherit; resize: none;
}
.crm-chat-send {
    padding: 10px 20px; border-radius: 10px; border: none; background: var(--red); color: var(--white);
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
}
.crm-chat-send:hover { background: #c92a38; }
.crm-conversation-details {
    padding: 20px; overflow-y: auto; background: var(--gray-dark);
}
.crm-details-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 16px; color: var(--white-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.crm-contact-details { display: flex; flex-direction: column; gap: 12px; font-size: 0.85rem; }
.crm-contact-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; }
.crm-contact-row .label { color: var(--gray-muted); }
.crm-contact-row .value { word-break: break-word; }

@media (max-width: 1024px) {
    .crm-kanban { grid-template-columns: repeat(3, 1fr); }
    .crm-conversation-body { grid-template-columns: 1fr; }
    .crm-conversation-details { border-top: 1px solid var(--glass-border); }
}
@media (max-width: 768px) {
    .crm-kanban { grid-template-columns: 1fr; }
}

/* Configurações — sistema e aplicativos de mensagens */
.config-section { position: relative; z-index: 1; padding: 24px; margin-bottom: 32px; }
.config-subnav { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.config-subnav-btn {
    padding: 10px 18px; border-radius: 10px; border: 1px solid var(--glass-border);
    background: var(--gray-dark); color: var(--white-muted); font-size: 0.9rem; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.config-subnav-btn:hover { background: var(--glass-hover); color: var(--white); }
.config-subnav-btn.active { background: var(--red-translucent); border-color: rgba(230, 57, 70, 0.5); color: var(--red); }
.config-view.hidden { display: none !important; }
.config-module { padding: 24px; margin-bottom: 24px; }
.config-module-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--white-muted); }
.config-module-desc { font-size: 0.85rem; color: var(--gray-muted); margin-bottom: 20px; }
.config-form .form-row { margin-bottom: 16px; }
.config-form label { display: block; font-size: 0.8rem; color: var(--gray-muted); margin-bottom: 6px; }
.config-form input[type="text"], .config-form input[type="url"], .config-form input[type="password"], .config-form select {
    width: 100%; max-width: 480px; padding: 12px 14px; border-radius: 10px;
    background: var(--gray-dark); border: 1px solid var(--glass-border); color: var(--white);
    font-size: 0.9rem;
}
.config-form input:focus, .config-form select:focus { outline: none; border-color: rgba(230, 57, 70, 0.4); }
.config-status { margin-left: 12px; font-size: 0.85rem; color: var(--gray-muted); }
.config-status.ok { color: #46b478; }
.config-status.err { color: var(--red); }

.integration-card { }
.integration-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.integration-actions .btn-apply { margin: 0; }
.integration-actions .btn-secondary { margin-left: 0.5rem; }
.integration-qr-box { margin-top: 16px; padding: 20px; background: rgba(0,0,0,0.2); border-radius: 12px; text-align: center; }
.integration-qr-box.hidden { display: none; }
.integration-qr-label { font-size: 0.9rem; color: var(--white-muted); margin-bottom: 12px; }
.integration-qr-wrap { display: inline-block; padding: 12px; background: #fff; border-radius: 8px; }
.integration-qr-wrap img { display: block; width: 220px; height: 220px; }
.integration-qr-hint { font-size: 0.8rem; color: var(--gray-muted); margin-top: 12px; }
.whatsapp-qr-message { font-size: 0.95rem; color: var(--white-muted); margin: 12px 0 16px; }
.whatsapp-qr-modal-content .integration-qr-wrap { margin: 8px 0 16px; }
.integration-pairing-code { margin: 12px 0 16px; padding: 16px; background: rgba(0,0,0,0.2); border-radius: 8px; }
.integration-pairing-code.hidden { display: none; }
.pairing-code-value { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.15em; color: var(--white); margin: 8px 0 0; word-break: break-all; }
.whatsapp-qr-modal-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.whatsapp-qr-modal-actions .btn-apply { margin: 0; }
.whatsapp-qr-modal-actions .btn-cancel { margin: 0; }
.integration-connected { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.integration-connected.hidden { display: none; }
.integration-badge { padding: 6px 14px; border-radius: 20px; background: rgba(70, 180, 120, 0.2); color: #46b478; font-size: 0.9rem; font-weight: 500; }

.modal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); padding: 16px; }
.modal-overlay.hidden { display: none !important; }
.modal-content { border-radius: 12px; padding: 24px; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

/* Login */
.login-page { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { max-width: 380px; width: 100%; padding: 32px; border-radius: 16px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo-icon { margin: 0 auto 12px; }
.login-brand h1 { font-size: 1.35rem; color: var(--white-muted); margin-bottom: 4px; }
.login-subtitle { font-size: 0.9rem; color: var(--gray-muted); }
.login-form .form-row { margin-bottom: 16px; }
.login-form .form-row label { display: block; font-size: 0.85rem; color: var(--white-muted); margin-bottom: 6px; }
.login-form .form-row input { width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--gray-dark); color: var(--white); font-size: 1rem; }
.login-btn { width: 100%; margin-top: 8px; padding: 12px; }
.header-logout { margin-left: 12px; padding: 8px 14px; font-size: 0.85rem; border-radius: 8px; border: 1px solid var(--glass-border); background: transparent; color: var(--gray-muted); cursor: pointer; }
.header-logout:hover { color: var(--white-muted); }

/* Chat flutuante (pop-up) */
.chat-fab-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 1000;
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.chat-balloon {
    background: var(--glass); border: 1px solid var(--glass-border);
    padding: 8px 14px; border-radius: 10px; font-size: 0.85rem; font-weight: 600;
    color: var(--red); white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.chat-fab {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--red); color: var(--white); border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(230, 57, 70, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(230, 57, 70, 0.5); }
.chat-fab svg { width: 28px; height: 28px; }
.chat-popup {
    position: absolute; bottom: 72px; right: 0;
    width: 380px; max-width: calc(100vw - 48px); max-height: 480px;
    background: var(--gray-dark); border: 1px solid var(--glass-border);
    border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-popup[hidden] { display: none !important; }
.chat-popup-header {
    padding: 14px 16px; border-bottom: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; color: var(--white);
}
.chat-popup-close {
    background: none; border: none; color: var(--gray-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0 4px;
}
.chat-popup-close:hover { color: var(--white); }
.chat-popup-desc {
    font-size: 0.8rem; color: var(--gray-muted); padding: 8px 16px;
    border-bottom: 1px solid var(--glass-border);
}
.chat-popup .chat-messages { flex: 1; min-height: 180px; max-height: 280px; }
.chat-popup .chat-input-wrap { padding: 12px; border-top: 1px solid var(--glass-border); }
.chat-popup .chat-hint { padding: 6px 12px 12px; font-size: 0.7rem; }
.gestao-chat-block { margin-top: 0; }
.gestao-chat-desc { font-size: 0.85rem; color: var(--gray-muted); margin-bottom: 16px; }
.chat-container { border: 1px solid var(--glass-border); border-radius: 12px; background: var(--gray-dark); overflow: hidden; }
.chat-messages {
    min-height: 200px; max-height: 360px; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.chat-msg { max-width: 90%; padding: 12px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.45; }
.chat-msg.user { align-self: flex-end; background: var(--red-translucent); border: 1px solid rgba(230, 57, 70, 0.3); }
.chat-msg.assistant { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-border); }
.chat-msg.error { align-self: flex-start; background: rgba(230, 57, 70, 0.1); border-color: rgba(230, 57, 70, 0.4); color: var(--red); }
.chat-msg .chat-msg-meta { font-size: 0.7rem; color: var(--gray-muted); margin-bottom: 4px; }
.chat-input-wrap { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--glass-border); align-items: flex-end; }
.chat-input {
    flex: 1; min-height: 44px; max-height: 120px; padding: 12px 14px; border-radius: 10px;
    background: var(--black-soft); border: 1px solid var(--glass-border); color: var(--white);
    font-size: 0.9rem; font-family: inherit; resize: none;
}
.chat-input:focus { outline: none; border-color: rgba(230, 57, 70, 0.4); }
.chat-send {
    width: 44px; height: 44px; border-radius: 10px; border: none; background: var(--red); color: var(--white);
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-send:hover { background: #c92a38; }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send svg { width: 20px; height: 20px; }
.chat-hint { font-size: 0.75rem; color: var(--gray-muted); padding: 8px 12px 0; }

@media (max-width: 1024px) {
    .gestao-grid { grid-template-columns: 1fr; }
    .kanban-board { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .gestao-levels { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 1200px) { .charts-grid { grid-template-columns: 1fr; } .chart-card.large { grid-column: 1; } }
@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-grid { grid-template-columns: 1fr 1fr; }
    .filter-actions { grid-column: 1 / -1; }
}
