@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Cores de marca — Pino suite */
    --teal: #1E9BAA;
    --teal-dark: #167682;
    --teal-light: #E3F2F4;
    --gold: #C68F3F;
    --gold-light: #F7EEDE;
    --bg: #EAF3FC;
    --surface: #FFFFFF;
    --surface-2: #F4F8FD;
    --border: #D9E5F2;

    /* Hierarquia de texto (nunca preto puro) */
    --text-hi: #16232E;
    --text-mid: #47586A;
    --text-low: #8598AA;

    /* Semânticas financeiras */
    --receita: #1E9B6E;
    --receita-bg: #E4F5EE;
    --despesa: #C0392B;
    --despesa-bg: #FBEAE8;
    --alerta: #C68F3F;
    --alerta-bg: #F7EEDE;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 2px 10px rgba(22, 35, 46, 0.06);
    --shadow-lg: 0 12px 32px rgba(22, 35, 46, 0.12);

    --font-display: 'Baloo 2', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-hi);
    font-family: var(--font-body);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .display {
    font-family: var(--font-display);
    color: var(--text-hi);
    font-weight: 700;
    margin: 0 0 4px;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font-family: var(--font-body); }

/* ---------- Layout ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar .brand-mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(155deg, var(--teal), var(--teal-dark));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 16px;
}

.sidebar .brand-text .app-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.1; }
.sidebar .brand-text .app-sub { font-size: 11px; color: var(--text-low); }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-mid);
    font-weight: 500;
    font-size: 14px;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text-hi); }
.nav-item.active { background: var(--teal-light); color: var(--teal-dark); font-weight: 600; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }

.nav-section-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-low); padding: 16px 12px 4px;
}

.sidebar-footer {
    margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; font-size: 13px;
}

.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}

/* ---------- Main ---------- */
.main {
    padding: 28px 36px;
    max-width: 1400px;
}

.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header p { color: var(--text-mid); margin: 4px 0 0; font-size: 14px; }

/* ---------- Componentes ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 12.5px; color: var(--text-mid); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.kpi-sub { font-size: 12.5px; color: var(--text-low); }
.kpi-value.positivo { color: var(--receita); }
.kpi-value.negativo { color: var(--despesa); }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: none;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); text-decoration: none; }
.btn-secondary { background: var(--surface-2); color: var(--text-hi); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-mid); padding: 8px 12px; }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-danger { background: var(--despesa-bg); color: var(--despesa); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-low); padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text-hi); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-receita { background: var(--receita-bg); color: var(--receita); }
.badge-despesa { background: var(--despesa-bg); color: var(--despesa); }
.badge-previsto { background: var(--alerta-bg); color: var(--alerta); }
.badge-realizado { background: var(--receita-bg); color: var(--receita); }
.badge-atrasado { background: var(--despesa-bg); color: var(--despesa); }

.valor-receita { color: var(--receita); font-weight: 600; }
.valor-despesa { color: var(--despesa); font-weight: 600; }

.tag-color { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

/* Filtros / toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar select, .toolbar input[type=text], .toolbar input[type=date], .toolbar input[type=month] {
    padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-hi); font-size: 13.5px;
}

.seletor-periodo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seletor-periodo select, .seletor-periodo input[type=date] {
    padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-hi); font-size: 13.5px;
}
.seletor-periodo .separador { color: var(--text-low); font-size: 13px; }
.seletor-periodo .atalhos { display: flex; gap: 4px; margin-left: 4px; }
.seletor-periodo .atalho {
    padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-mid); font-size: 12.5px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
}
.seletor-periodo .atalho:hover { background: var(--border); }
.seletor-periodo .atalho.ativo { background: var(--teal); color: #fff; border-color: var(--teal); }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-mid); }
.field input, .field select, .field textarea {
    padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text-hi); font-size: 14px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal);
}
.field-hint { font-size: 12px; color: var(--text-low); }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(22, 35, 46, 0.45);
    display: none; align-items: flex-start; justify-content: center;
    padding: 48px 20px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius); padding: 26px;
    width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-low); cursor: pointer; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-mid); }
.empty-state .display { font-size: 18px; margin-bottom: 6px; }

.toast {
    position: fixed; bottom: 24px; right: 24px; background: var(--text-hi); color: #fff;
    padding: 12px 18px; border-radius: var(--radius-sm); font-size: 14px; box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateY(8px); transition: all .2s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.erro { background: var(--despesa); }

/* Login */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 380px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .main { padding: 20px; }
    .form-grid { grid-template-columns: 1fr; }
}
