/* ========== RESET & BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0b0f19;
    --bg-secondary: #111827;
    --surface: rgba(17, 24, 39, 0.7);
    --surface-solid: #111827;
    --surface-hover: rgba(30, 41, 59, 0.6);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.06);
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.15);
    --green: #34d399;
    --green-glow: rgba(52, 211, 153, 0.15);
    --amber: #fbbf24;
    --amber-glow: rgba(251, 191, 36, 0.15);
    --purple: #a78bfa;
    --purple-glow: rgba(167, 139, 250, 0.15);
    --rose: #fb7185;
    --cyan: #22d3ee;
    --radius: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(56, 189, 248, 0.06);
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Fundo animado com gradiente */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 0%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(167, 139, 250, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 50% 50%, rgba(52, 211, 153, 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }

/* ========== ANIMAÇÕES ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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


@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ========== HEADER ========== */
.header {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
    border-bottom: 1px solid var(--glass-border);
    padding: 28px 0;
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), var(--purple), var(--green), transparent);
    background-size: 200% auto;
    animation: gradient-shift 4s ease infinite;
}

.header::after {
    content: '';
    position: absolute;
    top: -50%; right: -10%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.header-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    position: relative;
    z-index: 1;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.logo {
    position: relative;
}
.logo::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    opacity: 0.3;
    filter: blur(8px);
    z-index: -1;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle { font-size: 0.875rem; color: var(--text-secondary); font-weight: 400; }
.header-right { display: flex; gap: 8px; }

.badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(56, 189, 248, 0.2);
    backdrop-filter: blur(8px);
}
.badge-outline {
    background: rgba(167, 139, 250, 0.08);
    color: var(--purple);
    border: 1px solid rgba(167, 139, 250, 0.2);
}

/* ========== FILTROS ========== */
.filters-section {
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
}

.filters-bar {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.filter-group select {
    padding: 9px 14px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    cursor: pointer;
    transition: all .25s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), 0 0 20px var(--primary-glow);
}
.filter-group select option {
    background: var(--surface-solid);
    color: var(--text);
}

.btn-limpar {
    padding: 9px 22px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all .25s;
    white-space: nowrap;
}
.btn-limpar:hover {
    background: rgba(251, 113, 133, 0.1);
    color: var(--rose);
    border-color: rgba(251, 113, 133, 0.3);
    box-shadow: 0 0 20px rgba(251, 113, 133, 0.1);
}

/* ========== EXPORT BUTTONS ========== */
.export-group {
    display: flex;
    gap: 8px;
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn-pdf {
    background: rgba(251, 113, 133, 0.08);
    color: var(--rose);
    border-color: rgba(251, 113, 133, 0.2);
}
.btn-pdf:hover {
    background: rgba(251, 113, 133, 0.15);
    box-shadow: 0 0 20px rgba(251, 113, 133, 0.1);
    border-color: rgba(251, 113, 133, 0.4);
}

.btn-excel {
    background: rgba(52, 211, 153, 0.08);
    color: var(--green);
    border-color: rgba(52, 211, 153, 0.2);
}
.btn-excel:hover {
    background: rgba(52, 211, 153, 0.15);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.4);
}

/* ========== KPIs ========== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 24px 0;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    position: relative;
    overflow: hidden;
    animation: fadeInUp .6s ease both;
}
.kpi-card:nth-child(1) { animation-delay: .05s; }
.kpi-card:nth-child(2) { animation-delay: .1s; }
.kpi-card:nth-child(3) { animation-delay: .15s; }
.kpi-card:nth-child(4) { animation-delay: .2s; }

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.1), transparent);
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow), var(--shadow-glow);
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}
.kpi-icon::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 16px;
    opacity: 0.35;
    filter: blur(10px);
    z-index: -1;
}

.kpi-receita { background: var(--green-glow); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.15); }
.kpi-receita::after { background: var(--green); }
.kpi-clientes { background: var(--primary-glow); color: var(--primary); border: 1px solid rgba(56, 189, 248, 0.15); }
.kpi-clientes::after { background: var(--primary); }
.kpi-ocupacao { background: var(--amber-glow); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.15); }
.kpi-ocupacao::after { background: var(--amber); }
.kpi-avaliacao { background: var(--purple-glow); color: var(--purple); border: 1px solid rgba(167, 139, 250, 0.15); }
.kpi-avaliacao::after { background: var(--purple); }

.kpi-info { display: flex; flex-direction: column; }
.kpi-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }

/* Indicador de variação KPI */
.kpi-variacao {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
    min-height: 1em;
}
.var-melhor { color: #34d399; font-weight: 500; }
.var-pior { color: #fb7185; font-weight: 500; }

/* ========== CHARTS ========== */
.charts-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Grid 3 colunas para donuts */
.charts-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Donut body menor */
.chart-body-donut {
    height: 240px !important;
}

/* Resumo Rápido card */
.resumo-rapido-card { display: flex; flex-direction: column; }
.resumo-rapido-body {
    padding: 12px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    justify-content: center;
}
.resumo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    transition: background .2s;
}
.resumo-item:hover { background: rgba(255,255,255,.06); }
.resumo-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.resumo-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.resumo-valor { font-size: 0.85rem; color: var(--text); font-weight: 600; }
.resumo-valor span { color: var(--text-secondary); font-weight: 400; font-size: .8rem; }

/* PDF Overlay */
.pdf-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11,15,25,.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.pdf-overlay.ativo { display: flex; }
.pdf-overlay-inner {
    background: var(--surface-solid);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px 56px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.pdf-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(56,189,248,.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pdf-overlay-inner p { font-size: 1rem; font-weight: 600; color: var(--text); }
.pdf-overlay-inner span { font-size: .8rem; color: var(--text-muted); }

.chart-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    position: relative;
    animation: fadeInUp .6s ease both;
    animation-delay: .25s;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent);
}

.chart-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
}

.chart-header { padding: 22px 24px 0; }
.chart-header h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.chart-header p { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }

.chart-body { padding: 16px 20px 20px; position: relative; height: 300px; }

/* ========== INSIGHTS ========== */
.insights-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    margin-bottom: 24px;
    overflow: hidden;
    animation: fadeInUp .6s ease both;
    animation-delay: .35s;
    position: relative;
}

.insights-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.2), transparent);
}

.insights-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--primary);
}
.insights-header h3 { font-size: 1rem; font-weight: 600; color: var(--text); }

.insights-body { padding: 20px 24px; }

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: background .2s;
}
.insight-item:last-child { border-bottom: none; }
.insight-item:hover { background: var(--glass); margin: 0 -24px; padding-left: 24px; padding-right: 24px; }

.insight-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 7px;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.insight-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.7; }
.insight-highlight { font-weight: 600; color: var(--primary); }

/* Seção Analítica Estática — borda gradiente dourada */
.insights-analitica {
    border-color: rgba(251, 191, 36, 0.2);
}
.insights-analitica::before {
    background: linear-gradient(90deg, transparent, rgba(251,191,36,0.5), rgba(167,139,250,0.3), transparent) !important;
}
.insights-analitica .insights-header {
    color: var(--amber);
    border-bottom-color: rgba(251,191,36,.15);
}
.analitica-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.85;
    text-align: justify;
}

/* ========== FOOTER ========== */
.footer {
    text-align: center;
    padding: 36px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: 16px;
    position: relative;
    z-index: 1;
}
.footer-small { font-size: 0.75rem; margin-top: 6px; opacity: .5; }

/* ========== RESPONSIVE ========== */

/* Tablet landscape / iPad (1024px) */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid-2 { grid-template-columns: 1fr; }
    .charts-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .resumo-rapido-card { grid-column: span 2; }
    .container { padding: 0 16px; }
}

/* Tablet portrait / iPad mini (768px) */
@media (max-width: 768px) {
    .header { padding: 20px 0; }
    .header h1 { font-size: 1.25rem; }
    .subtitle { font-size: 0.8rem; }
    .header-content { gap: 12px; }

    .filters-section { padding: 12px 0; }
    .filters-bar { flex-direction: column; gap: 10px; }
    .filter-group { min-width: 100%; }
    .filter-group select { padding: 10px 12px; font-size: 1rem; }
    .btn-limpar { width: 100%; padding: 10px; text-align: center; }
    .export-group { width: 100%; }
    .btn-export { flex: 1; justify-content: center; padding: 10px; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0; }
    .kpi-card { padding: 16px; gap: 12px; }
    .kpi-value { font-size: 1.25rem; }
    .kpi-icon { width: 42px; height: 42px; }

    .chart-body { height: 280px; padding: 12px 16px 16px; }
    .chart-header { padding: 16px 16px 0; }
    .chart-header h3 { font-size: 0.95rem; }

    .insights-header { padding: 16px; }
    .insights-body { padding: 16px; }
    .insight-text { font-size: 0.85rem; }
    .insight-item:hover { margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
}

/* Smartphone (480px) */
@media (max-width: 480px) {
    .container { padding: 0 12px; }

    .header { padding: 16px 0; }
    .header-content { flex-direction: column; align-items: flex-start; padding: 0 12px; }
    .header h1 { font-size: 1.1rem; }
    .header-left { gap: 12px; }
    .logo svg { width: 28px; height: 28px; }
    .header-right { width: 100%; }
    .badge { font-size: 0.7rem; padding: 3px 10px; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
    .kpi-card { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
    .kpi-icon { width: 36px; height: 36px; }
    .kpi-icon svg { width: 18px; height: 18px; }
    .kpi-label { font-size: 0.65rem; }
    .kpi-value { font-size: 1.15rem; }
    .kpi-variacao { font-size: 0.6rem; }

    .charts-grid-2 { gap: 12px; margin-bottom: 12px; }
    .charts-grid-3 { grid-template-columns: 1fr; }
    .resumo-rapido-card { grid-column: auto; }
    .chart-body { height: 260px; padding: 10px 12px 14px; }
    .chart-header { padding: 14px 14px 0; }
    .chart-header h3 { font-size: 0.9rem; }
    .chart-header p { font-size: 0.75rem; }

    .insights-header { padding: 14px; }
    .insights-body { padding: 14px; }
    .insight-text { font-size: 0.82rem; line-height: 1.5; }
    .insight-item { padding: 8px 0; }
    .insight-item:hover { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }

    .footer { padding: 24px 12px; font-size: 0.8rem; }
    .footer-small { font-size: 0.7rem; }
}

/* Smartphone pequeno (360px) */
@media (max-width: 360px) {
    .header h1 { font-size: 1rem; }
    .kpi-grid { grid-template-columns: 1fr; gap: 8px; }
    .kpi-card { flex-direction: row; align-items: center; }
    .kpi-value { font-size: 1.1rem; }
    .chart-body { height: 240px; }
}

/* ========== PRINT ========== */
@media print {
    body, body::before { background: #0b0f19 !important; }
    .filters-section { position: static; backdrop-filter: none; }
    .kpi-card, .chart-card, .insights-card { break-inside: avoid; backdrop-filter: none; }
    .header { backdrop-filter: none; }
    .btn-limpar, .export-group { display: none; }
    .footer { margin-top: 32px; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
