:root {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --accent-color: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --glass-bg: rgba(30, 41, 59, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 20px;
    --input-bg: rgba(15, 23, 42, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    padding: 40px 20px;
}

/* --- Background Blobs --- */
.background-blobs {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none;
}
.blob {
    position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.4;
    animation: float 12s infinite ease-in-out;
}
.blob-1 { width: 500px; height: 500px; background: #6366f1; top: -150px; left: -150px; }
.blob-2 { width: 400px; height: 400px; background: #ec4899; bottom: -100px; right: -100px; animation-delay: 2s; }
.blob-3 { width: 300px; height: 300px; background: #06b6d4; bottom: 30%; left: 40%; animation-delay: 4s; }

@keyframes float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(40px, -40px); } }

/* --- Layout --- */
.main-container { width: 100%; max-width: 1100px; margin: 0 auto; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; }
.logo { display: flex; align-items: center; gap: 15px; }
.logo-icon { 
    background: var(--accent-gradient); width: 45px; height: 45px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}
.logo h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -1px; }

.header-actions { display: flex; gap: 12px; }
.icon-btn {
    background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-muted);
    width: 44px; height: 44px; border-radius: 12px; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); color: white; transform: translateY(-3px); border-color: rgba(255,255,255,0.2); }
.icon-btn.danger:hover { color: var(--danger-color); background: rgba(239, 68, 68, 0.15); border-color: var(--danger-color); }

/* --- KPI Stats --- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; }
.stat-card { text-align: left; position: relative; overflow: hidden; }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; display: block; margin-bottom: 8px; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: white; }
.main-stat { background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(6, 182, 212, 0.1) 100%); border-color: rgba(56, 189, 248, 0.3); }
.main-stat .value { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* --- Progress Bar --- */
.progress-wrapper { margin-bottom: 2.5rem; }
.progress-info { display: flex; justify-content: flex-end; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.progress-container { height: 8px; background: rgba(255,255,255,0.05); border-radius: 10px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0%; background: var(--success-color); border-radius: 10px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s; box-shadow: 0 0 15px rgba(16, 185, 129, 0.3); }
.progress-bar.warning { background: var(--warning-color); box-shadow: 0 0 15px rgba(245, 158, 11, 0.3); }
.progress-bar.danger { background: var(--danger-color); box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }

/* --- Dashboard Grid --- */
.dashboard-grid { display: grid; grid-template-columns: 350px 1fr; gap: 1.5rem; }
.form-section { grid-column: 1; }

/* --- CORRECTION GRAPHIQUE --- */
.chart-section { 
    grid-column: 2; 
    min-height: 340px; 
    display: flex; flex-direction: column; 
}
.chart-container { 
    position: relative; 
    height: 250px; /* Force la hauteur */
    width: 100%;
    display: flex; justify-content: center; align-items: center; 
}

.list-section { grid-column: 1 / -1; }

/* --- Glass Cards Standard --- */
.glass-card {
    background: var(--glass-bg); backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border); border-radius: 24px; padding: 1.8rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3); transition: transform 0.3s;
}
.card-header { display: flex; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--glass-border); }
.card-header h2 { font-size: 1.1rem; font-weight: 600; color: white; }
.card-header i { color: var(--accent-color); font-size: 1.1rem; margin-right: 12px; }

/* --- Form --- */
.form-row { display: flex; gap: 10px; }
.form-row .input-group { flex: 1; }
.input-group { position: relative; margin-bottom: 1.2rem; }
.input-group i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.9rem; z-index: 2;}

input, select {
    width: 100%; padding: 14px 14px 14px 44px; background: var(--input-bg);
    border: 1px solid var(--glass-border); border-radius: 14px; color: white;
    font-size: 0.95rem; font-family: 'Inter'; transition: 0.3s; appearance: none;
}
input[type="date"] { padding-left: 14px; color-scheme: dark; } 
select { cursor: pointer; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; padding-right: 2.5rem; }

input:focus, select:focus { border-color: var(--accent-color); background: rgba(15, 23, 42, 0.9); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }

button.btn-grad {
    width: 100%; padding: 15px; border: none; border-radius: 14px; font-weight: 600; letter-spacing: 0.5px;
    color: white; background: var(--accent-gradient); cursor: pointer; transition: 0.3s;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4); margin-top: 5px;
}
button.btn-grad:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(59, 130, 246, 0.6); }

/* --- Filters --- */
.header-with-filters { justify-content: space-between; flex-wrap: wrap; gap: 15px; }
.title-group { display: flex; align-items: center; }
.filters-bar { display: flex; gap: 10px; }
.filters-bar input, .filters-bar select {
    padding: 8px 12px 8px 35px; height: 36px; font-size: 0.85rem; border-radius: 10px; background: rgba(0,0,0,0.2);
}
.filters-bar input { width: 150px; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='8'%3e%3c/circle%3e%3cline x1='21' y1='21' x2='16.65' y2='16.65'%3e%3c/line%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: 10px center; background-size: 14px; padding-left: 32px; }

/* --- List --- */
ul.scroller { list-style: none; max-height: 400px; overflow-y: auto; padding-right: 5px; }
.scroller::-webkit-scrollbar { width: 4px; }
.scroller::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.expense-item {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.02); padding: 14px 18px; margin-bottom: 12px;
    border-radius: 16px; border: 1px solid rgba(255,255,255,0.03); transition: all 0.2s;
    border-left: 4px solid #ccc; animation: slideIn 0.3s ease-out forwards;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.expense-item:hover { background: rgba(255, 255, 255, 0.06); transform: translateX(5px); }
.expense-info { display: flex; flex-direction: column; gap: 2px; }
.expense-info strong { font-size: 0.95rem; color: #e2e8f0; }
.expense-info .meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.expense-info .badge { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; }
.expense-amount { font-weight: 700; color: #f87171; font-size: 1rem; }
.delete-btn { background: none; border: none; color: #475569; cursor: pointer; margin-left: 15px; padding: 6px; transition: 0.2s; }
.delete-btn:hover { color: var(--danger-color); background: rgba(239, 68, 68, 0.1); border-radius: 8px; }

.empty-state { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem; }

/* --- TOASTS --- */
#toast-container { position: fixed; bottom: 30px; right: 30px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: rgba(30, 41, 59, 0.9); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,0.1);
    color: white; padding: 12px 20px; border-radius: 12px; font-size: 0.9rem; min-width: 250px;
    display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: toastSlide 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.toast.success { border-left: 4px solid var(--success-color); }
.toast.error { border-left: 4px solid var(--danger-color); }
.toast.info { border-left: 4px solid var(--accent-color); }
.toast i { font-size: 1.1rem; }
.toast.success i { color: var(--success-color); }
.toast.error i { color: var(--danger-color); }
@keyframes toastSlide { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- MODALES --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px);
    z-index: 1000; display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.glass-modal {
    background: #1e293b; border: 1px solid rgba(255, 255, 255, 0.1); padding: 2.5rem; border-radius: 28px;
    width: 90%; max-width: 420px; text-align: center; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9); transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.active .glass-modal { transform: scale(1); }
.modal-icon { font-size: 3rem; color: var(--accent-color); margin-bottom: 20px; }
.modal-icon.danger { color: var(--danger-color); }
.modal-actions { display: flex; gap: 15px; justify-content: center; margin-top: 25px; }
.hidden { display: none; }
.btn-ghost { background: transparent; border: 1px solid #475569; color: #cbd5e1; padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; }
.btn-ghost:hover { border-color: white; color: white; }
.btn-danger { background: var(--danger-color); border: none; color: white; padding: 12px 24px; border-radius: 12px; cursor: pointer; font-weight: 600; box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4); }

/* --- Responsive --- */
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .chart-section { min-height: auto; }
    .chart-container { height: 220px; } /* Ajustement mobile */
    .stats-grid { grid-template-columns: 1fr; gap: 1rem; }
    header { flex-direction: column; gap: 20px; }
    .header-with-filters { flex-direction: column; align-items: flex-start; }
    .filters-bar { width: 100%; }
    .filters-bar input, .filters-bar select { flex: 1; }
    #toast-container { right: 50%; transform: translateX(50%); bottom: 20px; width: 90%; }
}

/* Security Privacy Effect */
.privacy-active .sensitive { filter: blur(10px); user-select: none; transition: 0.3s; }
.text-red { color: var(--danger-color) !important; }
.text-green { color: var(--success-color) !important; }