/* ================================================================= */
/* ESTILO GERAL E DESKTOP                                            */
/* ================================================================= */
body { 
    font-family: Arial, sans-serif; 
    background: #f4f7f6; 
    margin: 0; 
    padding: 20px; 
    color: #333; 
    -webkit-text-size-adjust: 100%;
}

.container { 
    max-width: 1100px; 
    margin: auto; 
}

.card { 
    background: white; 
    padding: 25px; 
    border-radius: 8px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    margin-bottom: 20px; 
}

input, button, select { 
    padding: 12px; 
    margin: 8px 0; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    box-sizing: border-box; 
}

button { 
    background: #007bff; 
    color: white; 
    border: none; 
    cursor: pointer; 
    font-weight: bold; 
}

button:hover { 
    background: #0056b3; 
}

.hidden { 
    display: none; 
}

/* Grid de KPIs */
.kpi-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 15px; 
    margin-bottom: 20px; 
}

.kpi-card { 
    background: white; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    border-left: 5px solid #007bff; 
}

.kpi-card.receita { border-left-color: #28a745; }
.kpi-card.despesa { border-left-color: #dc3545; }
.kpi-card.saldo { border-left-color: #17a2b8; }
.kpi-title { font-size: 13px; color: #666; text-transform: uppercase; font-weight: bold; }
.kpi-value { font-size: 22px; font-weight: bold; margin-top: 5px; }

table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 10px; 
    font-size: 14px; 
}

th, td { 
    padding: 10px; 
    border-bottom: 1px solid #eee; 
    text-align: left; 
}

th { 
    background: #f8f9fa; 
}

.text-green { color: #28a745; font-weight: bold; }
.text-red { color: #dc3545; font-weight: bold; }

.flex-row { 
    display: flex; 
    gap: 20px; 
    flex-wrap: wrap; 
}

.flex-col { 
    flex: 1; 
    min-width: 300px; 
}

/* Estilos para tabelas geradas via Markdown (IA) */
#resultado-ia table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 15px; 
    font-size: 14px; 
}

#resultado-ia th, #resultado-ia td { 
    border: 1px solid #dee2e6; 
    padding: 8px 12px; 
    text-align: right; 
}

#resultado-ia th { 
    background-color: #f8f9fa; 
    text-align: center; 
}

#resultado-ia td:first-child, #resultado-ia th:first-child { 
    text-align: left; 
}

.link-descricao { color: #007bff; cursor: pointer; text-decoration: underline; }
.link-descricao:hover { color: #0056b3; }


/* ================================================================= */
/* ADAPTAÇÃO MOBILE (SMARTPHONES ANDROID E IOS)                      */
/* ================================================================= */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        font-size: 14px;
    }

    .container {
        width: 100%;
        padding: 0;
    }

    h2, h3 {
        font-size: 1.1rem;
        word-break: break-word;
    }

    .card {
        padding: 15px !important;
        margin-bottom: 15px !important;
    }

    /* Gráficos flexíveis em tela pequena */
    canvas {
        max-width: 100% !important;
        height: 230px !important;
    }

    /* Tabelas com rolagem lateral suave */
    div[style*="overflow-x: auto"], .card div[style*="overflow-x: auto"] {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 12px !important;
        min-width: 480px;
    }

    th, td {
        padding: 8px 6px !important;
    }

    /* Inputs, selects e botões amigáveis para toque (touch targets) */
    input, button, select {
        font-size: 14px !important;
        padding: 10px !important;
        width: 100% !important;
        margin-top: 5px;
    }

    td select {
        min-width: 110px;
        padding: 6px !important;
    }

    #btn-carregar-mais, button[type="submit"] {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
        margin-top: 10px;
    }
}