:root {
    /* COLORES & TEMA */
    --bg-color: #f2f2f7;
    --text-color: #000000;
    --accent-blue: #004499; /* Azul oscuro del título */
    --accent-red: #ff3b30;
    --accent-green: #34c759;
    --accent-orange: #ff9500;
    --accent-purple: #af52de;
    --accent-pink: #ff2d55;
    --accent-gray: #8e8e93;
    
    /* Glass / Tarjetas */
    --glass-bg: #ffffff;
    --banner-bg: linear-gradient(180deg, #0055aa 0%, #003377 100%);
    --glass-border: rgba(0, 0, 0, 0.05);
    --input-bg: rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 4px 12px rgba(0,0,0,0.08);
    
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #000000;
        --text-color: #ffffff;
        --accent-blue: #0a84ff;
        --glass-bg: #1c1c1e;
        --banner-bg: linear-gradient(180deg, #0a84ff 0%, #005ecb 100%);
        --glass-border: rgba(255, 255, 255, 0.15);
        --input-bg: #2c2c2e;
        --shadow-soft: 0 4px 12px rgba(0,0,0,0.3);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
    min-height: 100vh;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    position: relative;
}

/* --- UTILIDAD CRÍTICA: VISIBILIDAD --- */
.hidden { display: none !important; }

/* --- GESTIÓN DE VISTAS --- */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- ESTILOS HOME (DASHBOARD) --- */
.home-header { text-align: center; margin-bottom: 25px; padding-top: 10px; }
.home-header h2 {
    color: var(--accent-blue);
    font-size: 1.3rem;
    font-weight: 700;
}

/* BANNER PRINCIPAL (Diseño Tarjeta Azul) */
.main-banner {
    background: var(--banner-bg);
    border-radius: 20px;
    padding: 25px;
    text-align: center;
    color: white;
    box-shadow: 0 8px 25px rgba(0, 68, 153, 0.3);
    margin-bottom: 30px;
}

.banner-top { margin-bottom: 15px; }
.banner-label { font-size: 0.85rem; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.banner-amount { font-size: 3rem; font-weight: 700; margin: 5px 0; }

.banner-divider {
    height: 1px;
    background: rgba(255,255,255,0.2);
    margin: 15px 20px;
}

.banner-footer {
    display: flex;
    justify-content: space-around;
}

.banner-stat { display: flex; flex-direction: column; gap: 5px; }
.stat-label { font-size: 0.8rem; opacity: 0.8; }
.stat-value { font-size: 1.1rem; font-weight: 600; }
.text-warning { color: #ffd60a; }

/* --- MINI BANNER (RESUMEN MENSUAL) --- */
.mini-banner {
    background: var(--banner-bg);
    color: white;
    padding: 15px 20px;
    border-radius: 16px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(0, 68, 153, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mini-label {
    font-size: 0.8rem;
    opacity: 0.9;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mini-banner h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

/* GRID DE NAVEGACIÓN */
.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.home-card {
    background: var(--glass-bg);
    border: none;
    border-radius: 18px;
    padding: 25px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: transform 0.1s;
    height: 140px; 
}

.home-card:active { transform: scale(0.97); }

/* Iconos de colores */
.icon-box {
    width: 55px;
    height: 55px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
}

.bg-blue { background: rgba(0, 122, 255, 0.12); } .bg-blue svg { stroke: var(--accent-blue); }
.bg-purple { background: rgba(175, 82, 222, 0.12); } .bg-purple svg { stroke: var(--accent-purple); }
.bg-orange { background: rgba(255, 149, 0, 0.12); } .bg-orange svg { stroke: var(--accent-orange); }
.bg-green { background: rgba(52, 199, 89, 0.12); } .bg-green svg { stroke: var(--accent-green); fill: none; }
.bg-pink { background: rgba(255, 45, 85, 0.12); } .bg-pink svg { stroke: var(--accent-pink); }
.bg-gray { background: rgba(142, 142, 147, 0.12); } .bg-gray svg { stroke: var(--accent-gray); }

.card-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
}

/* --- CABECERAS INTERNAS --- */
.view-header-inner {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
    padding-top: 10px;
}

.view-header-inner h2 {
    flex: 1;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    margin-right: 20px; 
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--accent-blue);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* --- ESTILOS COMUNES --- */
.glass {
    background: var(--glass-bg);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.card { padding: 20px; }
/* Buscador */
.search-container { display: flex; align-items: center; gap: 10px; padding: 12px; }
.search-container input { background: transparent; border: none; color: var(--text-color); font-size: 1rem; width: 100%; outline: none; }
.search-container svg { stroke: #999; }

/* Formularios */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-color); opacity: 0.6; margin-bottom: 8px; }
.form-group input { width: 100%; background: var(--input-bg); border: none; padding: 14px; border-radius: 12px; font-size: 16px; color: var(--text-color); outline: none; }
.form-row-split { display: flex; align-items: center; justify-content: space-between; gap: 15px; }

/* Switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #e5e5ea; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 24px; width: 24px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
input:checked + .slider { background-color: var(--accent-blue); }
input:checked + .slider:before { transform: translateX(22px); }

/* Listas y Swipe */
.swipe-wrapper { position: relative; overflow: hidden; margin-bottom: 12px; border-radius: 16px; background: var(--bg-color); }
.swipe-actions { position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; z-index: 1; opacity: 0; }
.swipe-wrapper.interacting .swipe-actions { opacity: 1; }
.action-left { background-color: var(--accent-green); width: 100%; height: 100%; display: flex; align-items: center; padding-left: 20px; color: white; font-weight: bold; position: absolute; left: 0; transform: translateX(-100%); transition: transform 0.2s; }
.swipe-wrapper.swiping-right .action-left { transform: translateX(0); }
.action-right { display: flex; height: 100%; position: absolute; right: 0; }
.swipe-btn { border: none; color: white; font-weight: 600; padding: 0 20px; height: 100%; cursor: pointer; }
.btn-swipe-edit { background-color: var(--accent-blue); }
.btn-swipe-delete { background-color: var(--accent-red); }

.item-row { position: relative; z-index: 2; background: var(--glass-bg); display: flex; align-items: center; padding: 16px 20px; border-radius: 16px; transition: transform 0.2s ease-out; box-shadow: var(--shadow-soft); }
.item-name { font-weight: 500; font-size: 1rem; color: var(--text-color); }
.item-amount { font-weight: 700; font-size: 1rem; color: var(--text-color); margin-left: auto; }
.check-indicator { width: 22px; height: 22px; border: 2px solid var(--text-color); opacity: 0.3; border-radius: 50%; margin-right: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.item-row.paid-row .item-info { opacity: 0.5; text-decoration: line-through; }
.item-row.paid-row .check-indicator { background: var(--accent-green); border-color: var(--accent-green); opacity: 1; }
.check-indicator svg { display: none; stroke: white; }
.item-row.paid-row .check-indicator svg { display: block; }

/* Histórico - Pestañas */
.segmented-control { display: flex; padding: 4px; background: var(--input-bg); border-radius: 10px; margin-bottom: 20px; }
.seg-btn { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; font-weight: 600; color: var(--text-color); opacity: 0.6; cursor: pointer; }
.seg-btn.active { background: var(--glass-bg); opacity: 1; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
.subview { display: none; }
.subview.active { display: block; animation: fadeIn 0.2s; }

/* Modales */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-content { width: 85%; max-width: 350px; padding: 25px; background: var(--glass-bg); border-radius: 24px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.modal-actions { display: flex; gap: 10px; margin-top: 25px; }
.btn-primary { flex: 1; background: var(--accent-blue); color: white; padding: 14px; border: none; border-radius: 12px; font-weight: 600; cursor: pointer; }
.btn-secondary { flex: 1; background: transparent; color: var(--text-color); border: 1px solid rgba(0,0,0,0.1); padding: 14px; border-radius: 12px; cursor: pointer; }

/* Botones Ajustes */
.btn-full { width: 100%; background: var(--glass-bg); color: var(--text-color); padding: 16px; border: none; border-radius: 14px; margin-bottom: 10px; text-align: left; cursor: pointer; box-shadow: var(--shadow-soft); font-size: 1rem; display: flex; align-items: center; justify-content: space-between; }
.divider { border: 0; height: 1px; background: rgba(0,0,0,0.05); margin: 20px 0; }
.settings-menu { padding: 10px 0; }

/* Botón Flotante */
.fab { position: fixed; width: 60px; height: 60px; background: var(--accent-blue); border-radius: 50%; box-shadow: 0 4px 15px rgba(0,0,0,0.3); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 100; transition: transform 0.2s; }
.fab:active { transform: scale(0.95); }

/* Toast */
.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; width: 90%; max-width: 400px; pointer-events: none; }
.toast { background: rgba(50, 50, 50, 0.9); backdrop-filter: blur(10px); color: white; padding: 16px 20px; border-radius: 30px; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; animation: fadeIn 0.4s; pointer-events: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
