/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
    color: #e2e8f0;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; }
button { font-family: inherit; }

/* ---------- Auth pages ---------- */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}
.auth-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}
.auth-subtitle { color: #94a3b8; margin-bottom: 1.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: #cbd5e1; }

/* ---------- Form controls ---------- */
input, select, textarea {
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    padding: .65rem .75rem;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #6366f1;
}
label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: #cbd5e1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.1rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 600;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-secondary { background: #334155; color: #e2e8f0; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; }
.btn-block { width: 100%; }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: none;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem .75rem; border-radius: 8px; color: #cbd5e1; font-size: .95rem;
}
.nav-link:hover { background: #334155; }
.nav-link.active { background: #6366f1; color: #fff; }
.nav-icon { font-size: 1.1rem; }
.sidebar-footer { display: flex; flex-direction: column; gap: .5rem; border-top: 1px solid #334155; padding-top: 1rem; }
.user-name { font-size: .85rem; color: #94a3b8; padding: 0 .75rem; }
.logout-link { color: #f87171; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #334155;
    position: sticky; top: 0; background: #0f172a; z-index: 10;
}
.topbar h1 { font-size: 1.25rem; }
.topbar-logout { font-size: 1.3rem; }

.content { flex: 1; padding: 1rem 1.25rem 5.5rem; }

.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around;
    background: #1e293b; border-top: 1px solid #334155;
    padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom));
    z-index: 20;
}
.bottom-nav-link { display: flex; flex-direction: column; align-items: center; gap: .15rem; color: #94a3b8; font-size: .68rem; padding: .25rem .5rem; border-radius: 8px; }
.bottom-nav-link.active { color: #818cf8; }
.bottom-nav-link .nav-icon { font-size: 1.3rem; }

@media (min-width: 860px) {
    .sidebar { display: flex; }
    .bottom-nav { display: none; }
    .content { padding-bottom: 1.5rem; }
}

/* ---------- Cards / grids ---------- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: .85rem;
    margin-bottom: 1.5rem;
}
.summary-card {
    background: #1e293b; border: 1px solid #334155; border-radius: 12px;
    padding: 1rem 1.1rem;
}
.summary-card .label { color: #94a3b8; font-size: .8rem; margin-bottom: .35rem; }
.summary-card .value { font-size: 1.35rem; font-weight: 700; }
.summary-card.income .value { color: #4ade80; }
.summary-card.expense .value { color: #f87171; }
.summary-card.balance .value.positive { color: #4ade80; }
.summary-card.balance .value.negative { color: #f87171; }

.panel {
    background: #1e293b; border: 1px solid #334155; border-radius: 12px;
    padding: 1.1rem; margin-bottom: 1.25rem;
}
.panel-title { font-size: 1rem; margin-bottom: .9rem; color: #cbd5e1; }

.charts-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
@media (min-width: 860px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
}
.chart-wrap { position: relative; height: 280px; }

/* ---------- Cards (cartões de crédito / investimentos) ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.credit-card {
    border-radius: 14px; padding: 1.2rem; color: #fff; position: relative; min-height: 130px;
    display: flex; flex-direction: column; justify-content: space-between; gap: .6rem;
    box-shadow: 0 4px 14px rgba(0,0,0,.35);
    overflow-wrap: anywhere;
}
.credit-card .card-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.credit-card .card-meta { font-size: .78rem; opacity: .85; }
.credit-card .card-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.credit-card .card-actions .btn { background: rgba(255,255,255,.2); color: #fff; flex: 1 1 auto; white-space: nowrap; }
.credit-card .card-actions .btn:hover { background: rgba(255,255,255,.32); }

/* Cards de investimento têm mais linhas de conteúdo — colunas um pouco mais largas. */
#investments-grid.cards-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .65rem .6rem; text-align: left; border-bottom: 1px solid #334155; white-space: nowrap; }
th { color: #94a3b8; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: rgba(255,255,255,.02); }
td.amount.income { color: #4ade80; font-weight: 600; }
td.amount.expense { color: #f87171; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-pago { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-pendente { background: rgba(234,179,8,.15); color: #eab308; }

.row-actions { display: flex; gap: .35rem; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.1rem; justify-content: space-between; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; }
.filters select, .filters input { width: auto; min-width: 130px; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.55);
    display: none; align-items: flex-end; justify-content: center; z-index: 50; padding: 0;
}
.modal-overlay.open { display: flex; }
.modal {
    background: #1e293b; border: 1px solid #334155; border-radius: 16px 16px 0 0;
    width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
    padding: 1.25rem;
}
@media (min-width: 860px) {
    .modal-overlay { align-items: center; }
    .modal { border-radius: 16px; }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-close { background: none; border: none; color: #94a3b8; font-size: 1.4rem; cursor: pointer; line-height: 1; }
.modal-form { display: flex; flex-direction: column; gap: .9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .5rem; }

.empty-state { text-align: center; color: #64748b; padding: 2.5rem 1rem; }

.fab {
    position: fixed; bottom: calc(4.6rem + env(safe-area-inset-bottom)); right: 1.1rem;
    width: 54px; height: 54px; border-radius: 50%; background: #6366f1; color: #fff;
    font-size: 1.6rem; border: none; box-shadow: 0 6px 16px rgba(99,102,241,.5);
    display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 30;
}
@media (min-width: 860px) {
    .fab { bottom: 1.5rem; }
}

.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .4rem; }
