/* --- 1. VARIÁVEIS E TEMAS (SEMPRE NO TOPO) --- */
:root {
    --bg-body: #f4f7f6;
    --bg-card: white;
    --text-color: #2c3e50;
    --border-color: #eee;
}

body.dark-mode {
    --bg-body: #1a202c;
    --bg-card: #2d3748;
    --text-color: #edf2f7;
    --border-color: #4a5568;
}

/* --- 2. ESTILOS GERAIS (DESKTOP E BASE) --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-color);
    padding: 10px;
    margin: 0;
    line-height: 1.6;
    transition: 0.3s;
}

/* Títulos e Topo */
.titulo {
    background: #0b3c68;
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 26px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.user-bar,
table {
    background: var(--bg-card) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

/* Resumo de Cabeçalho */
.resumo {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 10px 0;
    gap: 10px;
}

.resumo div {
    padding: 15px 10px;
    text-align: center;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.renda {
    background: #8fda6a;
    color: #1e4611;
}

.gasto {
    background: #f4b183;
    color: #5e3114;
}

.guardado {
    background: #e6a8d7;
    color: #4d1a40;
}

.saldo {
    background: #9dc3e6;
    color: #1a3a5e;
}

/* Tabelas */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

th,
td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

/* Cores das Tabelas */
.verde {
    background: #8fda6a;
}

.rosa {
    background: #e6a8d7;
}

.laranja {
    background: #f4b183;
}

.amarelo {
    background: #ffd966;
}

.vermelho {
    background: #ea9999;
}

/* Inputs e Seletores */
input,
select {
    width: 100%;
    border: 1px solid var(--border-color);
    padding: 8px;
    background: var(--bg-card);
    color: var(--text-color);
    border-radius: 4px;
    transition: all 0.3s ease;
}

input:focus,
select:focus {
    background: #fff;
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Navegação de Meses */
.navegacao-meses {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 15px auto;
    padding: 12px;
    background-color: #fff;
    border-radius: 12px;
    max-width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.btn-mes {
    padding: 10px 18px;
    border: 2px solid #eee;
    background-color: white;
    color: #555;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-mes.ativo {
    background-color: #3498db;
    color: white;
    border-color: #2980b9;
    transform: scale(1.05);
}

/* Alerta visual */
.alerta-gasto {
    background-color: #ffcccc !important;
    color: #b30000 !important;
    font-weight: bold;
}

/* --- VERSÃO MOBILE COMPACTA (NÃO AFETA O PC) --- */
@media screen and (max-width: 768px) {
    body {
        padding: 5px;
        /* Reduz margens externas */
    }

    /* Reduz o título principal */
    .titulo {
        font-size: 18px !important;
        padding: 8px !important;
    }

    /* Reduz os cards de resumo (Rendas, Gastos, etc) */
    .resumo {
        gap: 4px !important;
    }

    .resumo div {
        padding: 8px 2px !important;
        font-size: 10px !important;
        /* Fonte bem pequena para caber os 4 na linha */
    }

    .resumo span {
        font-size: 11px !important;
    }

    /* Mantém as tabelas lado a lado, mas diminui a fonte */
    .grid-2,
    .grid-3 {
        gap: 5px !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        /* Força os dois lados */
    }

    table {
        margin: 5px 0 !important;
    }

    th,
    td {
        padding: 4px 2px !important;
        /* Células bem apertadas */
        font-size: 10px !important;
    }

    /* Diminui os inputs para não estourarem as células */
    input,
    select {
        padding: 4px !important;
        font-size: 11px !important;
        height: 28px !important;
        border-radius: 2px !important;
    }

    /* Esconde o texto dos botões de meses e deixa só o número/sigla se necessário */
    .btn-mes {
        padding: 5px 8px !important;
        font-size: 10px !important;
    }

    /* Ajuste de Meta de Economia */
    .painel-metas h3 {
        font-size: 14px !important;
    }

    .painel-metas input {
        height: 30px !important;
        font-size: 12px !important;
    }

    /* Ajuste do Gráfico para não sumir */
    #graficoGastos {
        height: 200px !important;
    }
}