/* style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    padding: 0;
    margin: 0;
    padding-bottom: 80px;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a237e, #0d47a1);
    color: white;
    padding: 20px 16px 16px;
    border-radius: 0 0 20px 20px;
    margin: -16px -16px 16px;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header .subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: white;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tab-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-btn.active {
    background: #1a237e;
    color: white;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tarjetas */
.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

/* Formularios */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
    background: #fafafa;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a237e;
    background: white;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

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

/* Botones */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-primary {
    background: #1a237e;
    color: white;
}

.btn-primary:active {
    transform: scale(0.98);
    background: #0d47a1;
}

.btn-danger {
    background: red;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
    width: auto;
}

.btn-outline {
    background: transparent;
    border: 2px solid #1a237e;
    color: #1a237e;
}

/* Lista de gastos */
.gasto-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.gasto-item:last-child {
    border-bottom: none;
}

.gasto-info {
    flex: 1;
}

.gasto-categoria {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: blue;
}

.gasto-descripcion {
    font-size: 14px;
    margin: 4px 0 2px;
}

.gasto-fecha {
    font-size: 11px;
    color: #999;
}

.gasto-monto {
    font-weight: 600;
    font-size: 15px;
    margin-right: 8px;
}

.gasto-monto.ingreso {
    color: #28a745;
}

.gasto-monto.gasto {
    color: #dc3545;
}

.gasto-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Saldo */
.saldo-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.saldo-item {
    text-align: center;
    padding: 12px 4px;
    background: #f8f9fa;
    border-radius: 10px;
}

.saldo-item .label {
    font-size: 11px;
    color: #888;
}

.saldo-item .valor {
    font-size: 16px;
    font-weight: 700;
    margin-top: 2px;
}

.saldo-item .valor.ingreso { color: #28a745; }
.saldo-item .valor.gasto { color: #dc3545; }
.saldo-item .valor.saldo { color: #1a237e; }

/* Selector de mes */
.mes-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.mes-selector select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

/* Gráficas de barras */
.bar-chart {
    margin-top: 8px;
}

.bar-item {
    margin-bottom: 12px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 3px;
}

.bar-track {
    height: 24px;
    background: #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 11px;
    color: white;
    font-weight: 600;
    min-width: 30px;
}

.bar-fill.excedido {
    background: #dc3545 !important;
}

/* Mensajes */
.mensaje {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.mensaje-exito {
    background: #d4edda;
    color: #155724;
}

.mensaje-error {
    background: #f8d7da;
    color: #721c24;
}

/* Eliminar modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.modal h3 {
    margin-bottom: 8px;
}

.modal .btn-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal .btn-group .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 400px) {
    .saldo-container {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .container {
        padding: 12px;
    }
}