:root {
    /* Variables de Color - Modo Claro */
    --bg-body: #f4f6f8;
    --bg-card: #ffffff;
    --text-main: #1a1a1a;
    --text-secondary: #666666;
    --accent: #007AFF;
    --danger: #ff3b30;
    --warning: #ff9500;
    --border: #e0e0e0;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Modo Oscuro Automático */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #121212;
        --bg-card: #1e1e1e;
        --text-main: #ffffff;
        --text-secondary: #a0a0a0;
        --border: #333333;
        --shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
}

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

/* CORRECCIÓN SCROLL HORIZONTAL */
html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Esto bloquea el desplazamiento lateral */
    position: relative;
}

body { 
    font-family: var(--font-family); 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    padding-bottom: 50px; 
}

.container { 
    width: 100%; /* Asegura que no exceda el ancho */
    max-width: 600px; 
    margin: 0 auto; 
    padding: 20px; 
}

/* HEADER */
header { margin-bottom: 20px; }
h1 { font-size: 1.2rem; font-weight: 600; margin-bottom: 15px; color: var(--text-secondary); }
.total-card { background-color: var(--bg-card); padding: 30px 20px; border-radius: 16px; text-align: center; box-shadow: var(--shadow); margin-bottom: 25px; }
.label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); }
.big-number { font-size: 3rem; font-weight: 700; margin-top: 5px; letter-spacing: -1px; }

/* Proyección anual */
.yearly-label { margin-top: 8px; font-size: 0.95rem; color: var(--text-secondary); font-weight: 500; opacity: 0.8; }

/* INPUTS Y FORMULARIO */
.input-section { background-color: var(--bg-card); padding: 20px; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 25px; }
.input-group { margin-bottom: 12px; display: flex; gap: 10px; }
.input-group:last-child { margin-bottom: 0; }
input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-body); color: var(--text-main); font-size: 1rem; outline: none; }
input:focus { border-color: var(--accent); }

/* Estilo especial para el buscador */
.search-input { background-color: rgba(0,0,0,0.03); border-radius: 8px; font-size: 0.95rem; }
.separator { border: 0; border-top: 1px solid var(--border); margin: 15px 0; opacity: 0.5; }

/* BOTONES */
button { cursor: pointer; border: none; border-radius: 10px; font-weight: 600; transition: 0.2s; }
.btn-primary { background-color: var(--accent); color: white; padding: 0 20px; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; min-width: 50px;}
.btn-secondary { background-color: var(--bg-body); color: var(--text-main); padding: 10px 15px; width: 100%; border: 1px solid var(--border); }
.btn-outline { background: transparent; border: 1px solid var(--accent); color: var(--accent); padding: 10px; flex: 1; }

/* LISTA DE GASTOS */
.list-section h3, .settings-section h3 { margin-bottom: 15px; font-size: 1.1rem; color: var(--text-secondary); }
.gastos-list { display: flex; flex-direction: column; gap: 15px; }

.gasto-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 15px;
    background-color: rgba(0,0,0,0.03);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column; 
}
.card-header h4 { font-size: 1.1rem; font-weight: 700; }
.group-total { font-weight: 600; font-size: 1rem; opacity: 0.8; }

/* Barra de progreso visual */
.progress-bg {
    height: 4px;
    background-color: rgba(0,0,0,0.05); 
    width: 100%;
    margin-top: 10px;
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background-color: var(--accent);
    opacity: 0.6;
    border-radius: 2px;
    transition: width 0.6s ease; 
}

/* FILAS DE DETALLE (Alineación Centrada) */
.detail-row {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}
.detail-row:last-child { border-bottom: none; }

.detail-info { 
    flex: 1; 
    min-width: 0;
    padding-right: 10px;
}
.detail-name { font-size: 0.95rem; margin-bottom: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Importe centrado con ancho fijo */
.detail-amount { 
    flex: 0 0 110px; 
    text-align: center; 
    font-weight: 600; 
    font-size: 1rem; 
}

.row-actions { 
    flex: 0 0 auto; 
    display: flex; 
    gap: 5px; 
    margin-left: 5px; 
}

/* Iconos de acción */
.icon-btn { 
    background: none; 
    border: none; 
    font-size: 1.2rem; 
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.edit-btn { color: var(--warning); }
.delete-btn { color: var(--danger); }

/* ESTADOS VACÍOS Y AJUSTES */
.empty-state { text-align: center; color: var(--text-secondary); padding: 20px; font-style: italic; }
.settings-section { margin-top: 40px; border-top: 1px solid var(--border); padding-top: 20px; }
.setting-item { margin-bottom: 15px; }
.actions { display: flex; gap: 10px; }
