/* ═══════════════════════════════════════════════
   VARIABLES
═══════════════════════════════════════════════ */
:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --sidebar-bg:    #0f172a;
    --sidebar-w:     240px;
    --topbar-h:      62px;
    --income:        #16a34a;
    --income-bg:     #f0fdf4;
    --expense:       #dc2626;
    --expense-bg:    #fef2f2;
    --balance-bg:    #eff6ff;
    --border:        #e2e8f0;
    --text-muted:    #64748b;
    --bg:            #f8fafc;
    --card:          #ffffff;
    --radius:        12px;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #1e293b;
    margin: 0;
}

/* ═══════════════════════════════════════════════
   LAYOUT WRAPPER
═══════════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
#sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform .25s ease;
    z-index: 200;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
    padding: .25rem .5rem;
    margin-bottom: .5rem;
}

.sidebar-brand i { font-size: 1.4rem; color: #60a5fa; }

#sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #94a3b8;
    border-radius: 8px;
    padding: .6rem .85rem;
    font-size: .88rem;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s;
}

#sidebar .nav-link i { font-size: 1rem; width: 18px; text-align: center; }

#sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
#sidebar .nav-link.active { background: var(--primary); color: #fff; }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.07); }
.logout-link { color: #f87171 !important; }
.logout-link:hover { background: rgba(248,113,113,.12) !important; }

/* ═══════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ═══════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════ */
.topbar {
    height: var(--topbar-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: .75rem;
}

.topbar-title { font-weight: 600; font-size: .95rem; color: #1e293b; }

.btn-hamburger {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #475569;
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: 6px;
    line-height: 1;
}
.btn-hamburger:hover { background: #f1f5f9; }

.user-badge {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .82rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: .35rem .75rem;
    border-radius: 20px;
}

/* ═══════════════════════════════════════════════
   PAGE BODY
═══════════════════════════════════════════════ */
.page-body { padding: 1.75rem; flex: 1; }

/* ═══════════════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════════════ */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.06); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-income  .stat-icon { background: var(--income-bg);  color: var(--income); }
.stat-expense .stat-icon { background: var(--expense-bg); color: var(--expense); }
.stat-balance .stat-icon { background: var(--balance-bg); color: var(--primary); }

.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 1.45rem; font-weight: 700; margin-top: .1rem; line-height: 1.2; }

.text-income  { color: var(--income)  !important; }
.text-expense { color: var(--expense) !important; }
.text-balance { color: var(--primary) !important; }

/* ═══════════════════════════════════════════════
   TABLE CARD
═══════════════════════════════════════════════ */
.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.table-card-header h6 {
    font-weight: 600;
    font-size: .9rem;
    margin: 0;
}

.table { margin: 0; }

.table thead th {
    background: #f8fafc;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: .75rem 1rem;
    vertical-align: middle;
    font-size: .88rem;
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }

/* ═══════════════════════════════════════════════
   BADGES TIPO
═══════════════════════════════════════════════ */
.badge-tipo {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-ingreso  { background: var(--income-bg);  color: var(--income); }
.badge-egreso   { background: var(--expense-bg); color: var(--expense); }

/* ═══════════════════════════════════════════════
   FORM CARD
═══════════════════════════════════════════════ */
.form-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 620px;
}

.form-label { font-weight: 500; font-size: .875rem; color: #374151; margin-bottom: .4rem; }

.form-control, .form-select {
    border-radius: 8px;
    border-color: #d1d5db;
    padding: .55rem .9rem;
    font-size: .88rem;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ═══════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════ */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-sm { font-size: .78rem; padding: .3rem .65rem; border-radius: 6px; }

/* ═══════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════ */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 64px rgba(0,0,0,.35);
}

.login-icon {
    width: 64px; height: 64px;
    background: var(--balance-bg);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    color: var(--primary);
    margin: 0 auto 1rem;
}

/* ═══════════════════════════════════════════════
   RESUMEN BAR CHART (dashboard)
═══════════════════════════════════════════════ */
.resumen-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.resumen-bar-fill { height: 100%; border-radius: 4px; }
.bar-ingreso  { background: var(--income); }
.bar-egreso   { background: var(--expense); }

/* ═══════════════════════════════════════════════
   MOBILE OVERLAY
═══════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 190;
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    #sidebar.open { transform: translateX(0); }
    .page-body { padding: 1rem; }
}
