body {
    background: #f0f4f8;
    color: #1a202c;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: -0.01em;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Corporativa */
.sidebar {
    width: 290px;
    background: #0f172a;
    padding: 24px 16px;
    flex-shrink: 0;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08);
    z-index: 100;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.brand {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    letter-spacing: 1px;
}

.brand span {
    color: #3b82f6;
}

.brand small {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #94a3b8;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.sidebar .nav-link {
    color: #94a3b8;
    padding: 12px 14px;
    border-radius: 8px;
    margin: 3px 0;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.sidebar .nav-link:hover {
    background: #1e293b;
    color: #f8fafc;
}

.sidebar .nav-link.active {
    background: #2563eb;
    color: #ffffff;
}

.sidebar .nav-link .badge-soft {
    background: rgba(255,255,255,0.1);
    color: #94a3b8;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 12px;
}

.sidebar .nav-link.active .badge-soft {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* Área de trabalho */
.content {
    flex-grow: 1;
    padding: 32px 40px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* Cards de Métricas */
.card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    background-color: #ffffff;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.metric-card {
    padding: 20px 24px;
    border-left: 4px solid #2563eb;
    background: white;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.metric-card .icon-bg {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 42px;
    opacity: 0.08;
    color: #2563eb;
}

.metric-card small {
    display: block;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 4px;
}

.metric-card b {
    font-size: 30px;
    font-weight: 800;
    display: block;
    color: #0f172a;
    line-height: 1.1;
}

.metric-card span {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
    display: block;
}

.metric-card .trend-up { color: #10b981; }
.metric-card .trend-down { color: #ef4444; }
.metric-card .trend-neutral { color: #f59e0b; }

.metric-card.primary { border-left-color: #2563eb; }
.metric-card.success { border-left-color: #10b981; }
.metric-card.warning { border-left-color: #f59e0b; }
.metric-card.danger { border-left-color: #ef4444; }
.metric-card.info { border-left-color: #06b6d4; }
.metric-card.purple { border-left-color: #8b5cf6; }

.metric-card.primary .icon-bg { color: #2563eb; }
.metric-card.success .icon-bg { color: #10b981; }
.metric-card.warning .icon-bg { color: #f59e0b; }
.metric-card.danger .icon-bg { color: #ef4444; }
.metric-card.info .icon-bg { color: #06b6d4; }
.metric-card.purple .icon-bg { color: #8b5cf6; }

/* Painéis */
.panel {
    display: none;
}

.panel:target {
    display: block;
}

section#dashboard:has(~ .panel:target) {
    display: none;
}

/* Gráficos */
.chart-container {
    position: relative;
    height: 240px;
    width: 100%;
}

.chart-container-sm {
    position: relative;
    height: 180px;
    width: 100%;
}

.chart-container-lg {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Tabelas */
.table {
    font-size: 13px;
    vertical-align: middle;
}

.table th {
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    border-bottom-width: 2px;
}

.table td {
    border-bottom: 1px solid #f1f5f9;
}

.status-badge {
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.status-badge.online { background: #d1fae5; color: #065f46; }
.status-badge.offline { background: #fee2e2; color: #991b1b; }
.status-badge.maintenance { background: #fef3c7; color: #92400e; }
.status-badge.update { background: #dbeafe; color: #1e40af; }
.status-badge.critical { background: #fecaca; color: #991b1b; }

/* Mapa */
#map-container {
    height: 480px;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

/* Helpers */
.fw-800 { font-weight: 800; }
.fw-700 { font-weight: 700; }
.fs-11 { font-size: 11px; }
.fs-12 { font-size: 12px; }
.text-muted-soft { color: #94a3b8; }

/* Animações sutis */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.pulse-dot.online { background: #10b981; }
.pulse-dot.warning { background: #f59e0b; }
.pulse-dot.offline { background: #ef4444; }

/* Status bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 12px;
}

.status-bar .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

@media(max-width: 1024px) {
    .app { flex-direction: column; }
    .sidebar { 
        width: 100%; 
        height: auto;
        position: relative;
        padding: 16px;
    }
    #map-container { height: 320px; }
}

@media(max-width: 768px) {
    .content { padding: 16px; }
    .metric-card b { font-size: 22px; }
}

/* ===== NOVOS ESTILOS ===== */

/* Cards de Oportunidades */
.opportunity-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #38bdf8;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.opportunity-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.2);
}

.opportunity-card .badge-opp {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #2563eb;
    color: white;
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
}

.opportunity-card .value {
    font-size: 28px;
    font-weight: 800;
    color: #0f172a;
}

.opportunity-card .label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
}

/* Card de Inatividade */
.inactive-card {
    border-left: 4px solid #ef4444;
}

.inactive-card.warning {
    border-left-color: #f59e0b;
}

.inactive-card.moderate {
    border-left-color: #f97316;
}

.inactive-card .days {
    font-size: 32px;
    font-weight: 800;
}

/* Tabela de Oportunidades */
.opportunity-table .row-opp {
    transition: all 0.2s ease;
}

.opportunity-table .row-opp:hover {
    background: #f0f9ff;
}

.opportunity-table .btn-opp {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.opportunity-table .btn-opp:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* Status de Inatividade */
.inactive-badge {
    padding: 2px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.inactive-badge.critical { background: #fee2e2; color: #991b1b; }
.inactive-badge.warning { background: #fef3c7; color: #92400e; }
.inactive-badge.moderate { background: #fff7ed; color: #9a3412; }
.inactive-badge.active { background: #d1fae5; color: #065f46; }

/* Score de Saúde do Cliente */
.health-score {
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-score .bar {
    width: 80px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.health-score .bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.health-score .bar .fill.good { background: #10b981; }
.health-score .bar .fill.warning { background: #f59e0b; }
.health-score .bar .fill.danger { background: #ef4444; }

/* Card de Ações Recomendadas */
.action-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 18px;
    border-left: 4px solid;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.action-card:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.action-card.urgent { border-left-color: #ef4444; }
.action-card.important { border-left-color: #f59e0b; }
.action-card.normal { border-left-color: #3b82f6; }

.action-card .action-title {
    font-weight: 700;
    font-size: 13px;
    color: #0f172a;
}

.action-card .action-desc {
    font-size: 12px;
    color: #64748b;
}

/* Métricas de Engajamento */
.engagement-ring {
    position: relative;
    display: inline-block;
}

.engagement-ring .number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

/* Alertas no topo */
.alert-bar {
    background: white;
    border-radius: 10px;
    padding: 12px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

.alert-bar .alert-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.alert-bar .alert-item .icon {
    font-size: 18px;
}

.alert-bar .alert-item.critical .icon { color: #ef4444; }
.alert-bar .alert-item.warning .icon { color: #f59e0b; }
.alert-bar .alert-item.info .icon { color: #3b82f6; }

/* Responsivo */
@media(max-width: 768px) {
    .opportunity-card .value { font-size: 22px; }
    .inactive-card .days { font-size: 24px; }
    .alert-bar .alert-item { font-size: 12px; }
}

/* ===== NOVOS ESTILOS PARA ANÁLISE DE CLIENTES ===== */

/* Badge Diamante */
.bg-purple {
    background: #7c3aed !important;
    color: #fff !important;
}

/* Cards de métricas com ícones */
.metric-card .icon-bg i {
    font-size: 38px;
}

/* Ajuste para gráficos horizontais */
.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Tabela de análise consolidada */
#tabelaAnaliseClientes td {
    vertical-align: middle;
}

#tabelaAnaliseClientes .badge {
    font-size: 11px;
    font-weight: 600;
}

/* Responsivo para os gráficos de ranking */
@media(max-width: 768px) {
    .chart-container {
        height: 200px !important;
    }
    #tabelaAnaliseClientes {
        font-size: 12px;
    }
    #tabelaAnaliseClientes td, 
    #tabelaAnaliseClientes th {
        padding: 6px 8px;
    }
}

/* Animações para cards de métricas */
.metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Cores para os diferentes segmentos */
.bg-segmento-municipal { background: #2563eb; }
.bg-segmento-estadual { background: #8b5cf6; }
.bg-segmento-privado { background: #06b6d4; }
.bg-segmento-ong { background: #10b981; }
.bg-segmento-federal { background: #f59e0b; }


/* Estilos para a seção Análise de Clientes */
#analise-clientes .card-header {
    background-color: #f8fafc !important;
}

#analise-clientes .table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
}

#analise-clientes .table td {
    font-size: 13px;
    vertical-align: middle;
}

#analise-clientes .table-responsive::-webkit-scrollbar {
    width: 6px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Badge Diamante */
.bg-purple {
    background: #7c3aed !important;
    color: #fff !important;
}

/* Estilo para os cards de ranking */
#analise-clientes .card {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

#analise-clientes .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Destaque para os primeiros colocados */
#analise-clientes .table-success td {
    background-color: #dcfce7 !important;
}

#analise-clientes .table-info td {
    background-color: #dbeafe !important;
}

#analise-clientes .table-warning td {
    background-color: #fef3c7 !important;
}

/* ===== ESTILOS PARA ANÁLISE DE CLIENTES ===== */

#analise-clientes .card-header {
    background-color: #f8fafc !important;
}

#analise-clientes .table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
}

#analise-clientes .table td {
    font-size: 13px;
    vertical-align: middle;
}

#analise-clientes .table-responsive::-webkit-scrollbar {
    width: 6px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

#analise-clientes .table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Badge Diamante */
.bg-purple {
    background: #7c3aed !important;
    color: #fff !important;
}

/* Estilo para os cards de ranking */
#analise-clientes .card {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

#analise-clientes .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* Destaque para os primeiros colocados */
#analise-clientes .table-success td {
    background-color: #dcfce7 !important;
}

#analise-clientes .table-info td {
    background-color: #dbeafe !important;
}

#analise-clientes .table-warning td {
    background-color: #fef3c7 !important;
}

/* Estilos para o sticky header das tabelas */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
}