* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1f2937;
    --gray: #6b7280;
    --light: #f3f4f6;
    --border: #e5e7eb;
    --bg: #f9fafb;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--dark);
    line-height: 1.5;
}

.login-bg {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 30px; }

.logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 15px;
    box-shadow: 0 8px 20px rgba(59,130,246,0.3);
}

.login-header h1 { color: var(--dark); margin-bottom: 5px; }
.login-header p { color: var(--gray); font-size: 14px; }

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.login-footer a { color: var(--primary); text-decoration: none; font-size: 14px; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo-icon {
    width: 40px;
    height: 40px;
    font-size: 22px;
    margin: 0;
    border-radius: 10px;
}

.sidebar-header h2 { font-size: 16px; color: var(--dark); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item:hover { background: var(--light); color: var(--dark); }

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

.nav-icon { font-size: 18px; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

.user-info { display: flex; align-items: center; gap: 10px; }

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.user-details { flex: 1; }
.user-name { font-size: 14px; font-weight: 600; }
.logout-link { color: var(--danger); font-size: 12px; text-decoration: none; }

.main-content { flex: 1; margin-left: 260px; min-width: 0; }

.topbar {
    background: var(--white);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 20px; flex: 1; }

.menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

.content-wrapper { padding: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; color: var(--dark); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--white);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.input-lg { font-size: 24px !important; font-weight: 600; text-align: center; padding: 16px !important; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.tipo-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tipo-option {
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    font-weight: 600;
    transition: all 0.2s;
}

.tipo-option input { display: none; }

.tipo-option.tipo-ingreso:has(input:checked) {
    background: #d1fae5;
    border-color: var(--success);
    color: var(--success);
}

.tipo-option.tipo-egreso:has(input:checked) {
    background: #fee2e2;
    border-color: var(--danger);
    color: var(--danger);
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }

.btn-secondary { background: var(--light); color: var(--dark); }
.btn-secondary:hover { background: var(--border); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-link { color: var(--primary); text-decoration: none; font-size: 14px; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

.btn-icon {
    display: inline-block;
    padding: 4px 8px;
    text-decoration: none;
    font-size: 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover { background: var(--light); }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }

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

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid var(--primary);
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: var(--light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-label { font-size: 13px; color: var(--gray); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--dark); }

.stat-income { border-left-color: var(--success); }
.stat-income .stat-value { color: var(--success); }
.stat-expense { border-left-color: var(--danger); }
.stat-expense .stat-value { color: var(--danger); }
.stat-positive { border-left-color: var(--success); }
.stat-positive .stat-value { color: var(--success); }
.stat-negative { border-left-color: var(--danger); }
.stat-negative .stat-value { color: var(--danger); }

.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

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

.card-header h3 { font-size: 16px; color: var(--dark); }

.card-body { padding: 20px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.filter-bar {
    background: var(--white);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 12px; font-weight: 500; color: var(--gray); }

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}

.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: left;
    padding: 12px;
    background: var(--light);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.data-table tr:hover { background: #fafbfc; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-ingreso { background: #d1fae5; color: var(--success); }
.badge-egreso { background: #fee2e2; color: var(--danger); }

.categoria-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }

.cuentas-list { display: flex; flex-direction: column; gap: 10px; }

.cuenta-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    background: var(--light);
    transition: transform 0.2s;
}

.cuenta-item:hover { transform: translateX(4px); }

.cuenta-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
}

.cuenta-info { flex: 1; }
.cuenta-nombre { font-weight: 600; font-size: 14px; }
.cuenta-tipo { font-size: 12px; color: var(--gray); }
.cuenta-saldo { font-weight: 700; font-size: 16px; }

.cuentas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.cuenta-card {
    background: var(--white);
    border-radius: 10px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.cuenta-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.cuenta-icon-lg {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
}

.cuenta-actions { display: flex; gap: 4px; }
.cuenta-actions a { text-decoration: none; font-size: 14px; padding: 4px; }

.cuenta-nombre-lg { font-weight: 600; margin-bottom: 2px; }
.cuenta-tipo-sm { font-size: 12px; color: var(--gray); margin-bottom: 8px; }
.cuenta-saldo-lg { font-size: 20px; font-weight: 700; color: var(--dark); }

.total-badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.transacciones-list { display: flex; flex-direction: column; gap: 8px; }

.transaccion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.transaccion-item:hover { background: var(--light); }

.transaccion-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.transaccion-info { flex: 1; min-width: 0; }
.transaccion-nombre { font-weight: 600; font-size: 14px; }
.transaccion-meta { font-size: 12px; color: var(--gray); }
.transaccion-monto { font-weight: 700; font-size: 15px; }

.categorias-list { display: flex; flex-direction: column; gap: 8px; }

.categoria-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    background: var(--light);
}

.categoria-uso { flex: 1; font-size: 12px; color: var(--gray); }
.categoria-actions { display: flex; gap: 4px; }
.categoria-actions a { text-decoration: none; padding: 4px; }

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray); }
.empty-icon { font-size: 48px; margin-bottom: 10px; }
.empty-state p { margin-bottom: 16px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .content-wrapper { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .dashboard-stats { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 18px; }
    .dashboard-grid, .dashboard-grid-2 { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-group { width: 100%; }
    .filter-group input, .filter-group select { width: 100%; }
    .topbar-actions .btn-sm { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 480px) {
    .dashboard-stats { grid-template-columns: 1fr; }
    .login-card { padding: 30px 20px; }
}
