/* --- style.css --- */
:root {
    --bg-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary-color: #3b82f6; 
    --primary-dark: #2563eb;
    --accent-color: #ef4444;
    --income-color: #10b981;
    --expense-color: #ef4444;
    --warning-color: #f59e0b;
    --border-color: #e2e8f0;
    --nav-bg: rgba(255, 255, 255, 0.85);
    --nav-inactive: #94a3b8;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
    --radius-md: 16px;
    --radius-lg: 24px;
    --glass-blur: blur(12px);
}

body.dark-mode {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --nav-bg: rgba(30, 41, 59, 0.85);
    --nav-inactive: #64748b;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, sans-serif; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--bg-color); color: var(--text-primary); display: flex; justify-content: center; overflow-x: hidden; transition: background-color 0.4s ease, color 0.4s ease; line-height: 1.5; }
#app { width: 100%; max-width: 480px; min-height: 100vh; position: relative; padding-bottom: 90px; padding-top: 70px; background-color: var(--bg-color); box-shadow: var(--shadow-lg); overflow-x: hidden;}

h1, h2, h3 { font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.1rem, 4vw, 1.25rem); margin-bottom: 16px; }
p { color: var(--text-secondary); }

/* --- Header --- */
header { position: fixed; top: 0; width: 100%; max-width: 480px; height: 64px; background-color: var(--nav-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); display: flex; justify-content: space-between; align-items: center; padding: 0 24px; z-index: 100; box-shadow: var(--shadow-sm); border-bottom: 1px solid rgba(0,0,0,0.05); }
.logo { font-size: 1.25rem; font-weight: 800; color: var(--primary-color); display:flex; align-items:center; gap:10px; letter-spacing: -0.03em;}
.settings-btn { font-size: 1.4rem; color: var(--text-primary); cursor: pointer; background: none; border: none; transition: transform 0.2s; }
.settings-btn:active { transform: rotate(45deg); }

/* --- Views & Animations --- */
.view { display: none; padding: 20px 24px; animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; transform: translateY(15px); }
.view.active { display: block; }
@keyframes slideUpFade { to { opacity: 1; transform: translateY(0); } }

/* --- Cards --- */
.card { background-color: var(--surface-color); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-md); transition: transform 0.2s ease, box-shadow 0.2s ease; border: 1px solid rgba(255,255,255,0.05); }

.balance-card { text-align: center; color: white; background: linear-gradient(135deg, var(--primary-color), #8b5cf6, var(--primary-dark), var(--primary-color)); background-size: 300% 300%; animation: gradientPan 8s ease infinite; border: none;}
@keyframes gradientPan { 0% {background-position: 0% 50%} 50% {background-position: 100% 50%} 100% {background-position: 0% 50%} }
.balance-card h3 { font-size: 0.95rem; font-weight: 500; opacity: 0.9; margin-bottom: 8px; color: white;}
.balance-card h1 { font-size: clamp(2rem, 8vw, 2.5rem); margin-bottom: 20px; font-weight: 800; letter-spacing: -0.04em; color: white;}
.balance-row { display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,0.25); padding-top: 16px; }
.balance-col { flex: 1; text-align: left; padding: 0 10px;}
.balance-col:last-child { text-align: right; }
.balance-col span { display: block; font-size: 0.8rem; opacity: 0.9; font-weight: 500;}
.balance-col strong { font-size: 1.1rem; font-weight: 700; color: white !important;}

.quote-box { font-style: italic; text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 20px; padding: 12px 16px; border-left: 4px solid var(--primary-color); background: var(--surface-color); border-radius: 0 var(--radius-md) var(--radius-md) 0; box-shadow: var(--shadow-sm); }
.ai-advisor { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2); border-radius: var(--radius-md); padding: 16px; margin-top: 20px; display: flex; gap: 16px; align-items: flex-start; }
.ai-advisor i { font-size: 1.8rem; color: var(--primary-color); animation: float 3s ease-in-out infinite; }
@keyframes float { 0% {transform: translateY(0px);} 50% {transform: translateY(-5px);} 100% {transform: translateY(0px);} }
.ai-advisor p { font-size: 0.85rem; margin: 0; line-height: 1.5; color: var(--text-primary); }

.progress-wrapper { margin-bottom: 16px; }
.progress-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 8px; font-weight: 600;}
.progress-bar-bg { width: 100%; height: 8px; background: var(--border-color); border-radius: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary-color); transition: width 1s cubic-bezier(0.16, 1, 0.3, 1); border-radius: 8px;}

.h-scroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; -ms-overflow-style: none; scroll-snap-type: x mandatory;}
.h-scroll::-webkit-scrollbar { display: none; }
.wallet-item { min-width: 130px; background: var(--surface-color); border: 1px solid var(--border-color); padding: 16px; border-radius: var(--radius-md); text-align: center; cursor: pointer; scroll-snap-align: start; transition: transform 0.2s, box-shadow 0.2s;}
.wallet-item:active { transform: scale(0.96); }
.template-badge { background: var(--surface-color); border: 1px solid var(--border-color); color: var(--text-primary); padding: 10px 16px; border-radius: 30px; font-size: 0.85rem; font-weight: 500; white-space: nowrap; cursor: pointer; transition: 0.2s; box-shadow: var(--shadow-sm);}
.template-badge:active { transform: scale(0.95); background: var(--primary-color); color: white; border-color: var(--primary-color); }

.tx-list { list-style: none; margin: 0; padding: 0;}
.tx-item { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border-color); position: relative; cursor: pointer; transition: background 0.2s; }
.tx-item:hover { background: rgba(0,0,0,0.02); }
.tx-item:last-child { border-bottom: none; }
.tx-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; margin-right: 16px; flex-shrink: 0; }
.tx-icon.income { background-color: rgba(16, 185, 129, 0.15); color: var(--income-color); }
.tx-icon.expense { background-color: rgba(239, 68, 68, 0.15); color: var(--expense-color); }
.tx-icon.transfer { background-color: rgba(59, 130, 246, 0.15); color: var(--primary-color); }
.tx-details { flex: 1; overflow: hidden; }
.tx-title { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; margin-bottom: 4px;}
.tx-date { font-size: 0.8rem; color: var(--text-secondary); }
.tx-amount { font-weight: 800; font-size: 1rem; text-align: right; letter-spacing: -0.02em;}
.tx-amount.income { color: var(--income-color); }
.tx-amount.expense { color: var(--expense-color); }
.action-icon { color: var(--text-secondary); font-size: 1rem; margin-left: 10px; cursor:pointer; padding:4px;}
.action-icon.trash:hover { color: var(--expense-color); }
.bookmark-icon { color: #f59e0b; }

/* Empty States */
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-secondary); display:flex; flex-direction:column; align-items:center;}
.empty-state i { font-size: 3.5rem; color: var(--border-color); margin-bottom: 16px; animation: pulse 2s infinite; }
@keyframes pulse { 0% {transform: scale(1); opacity: 0.8;} 50% {transform: scale(1.05); opacity: 1;} 100% {transform: scale(1); opacity: 0.8;} }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-secondary); font-weight:600;}
input, select, textarea { width: 100%; padding: 14px 16px; border: 1px solid var(--border-color); border-radius: 12px; background-color: var(--bg-color); color: var(--text-primary); font-size: 1rem; outline: none; transition: all 0.3s; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
input:focus, select:focus, textarea:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); background-color: var(--surface-color);}

.type-selector { display: flex; gap: 8px; margin-bottom: 24px; background: var(--bg-color); padding: 4px; border-radius: 14px; }
.type-btn { flex: 1; padding: 12px 10px; border: none; border-radius: 10px; background: transparent; color: var(--text-secondary); font-weight: 600; cursor: pointer; transition: all 0.3s; font-size:0.9rem;}
.type-btn.active { background: var(--surface-color); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.type-btn.active[data-type="income"] { color: var(--income-color); }
.type-btn.active[data-type="expense"] { color: var(--expense-color); }

.btn-primary { width: 100%; padding: 16px; background: var(--primary-color); color: white; border: none; border-radius: 14px; font-size: 1.1rem; font-weight: 700; cursor: pointer; margin-top: 10px; transition: all 0.2s; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }
.btn-primary:active { transform: scale(0.97); box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3); }

/* Bottom Navigation */
.bottom-nav { position: fixed; bottom: 0; width: 100%; max-width: 480px; height: 72px; background-color: var(--nav-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); display: flex; justify-content: space-around; align-items: center; box-shadow: 0 -4px 20px rgba(0,0,0,0.06); z-index: 100; border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid rgba(255,255,255,0.1); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);}
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--nav-inactive); text-decoration: none; font-size: 0.7rem; font-weight: 600; flex: 1; height: 100%; cursor: pointer; transition: color 0.3s; }
.nav-item i { font-size: 1.4rem; margin-bottom: 4px; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.nav-item.active { color: var(--primary-color); }
.nav-item.active i { transform: translateY(-4px) scale(1.1); }

/* FAB */
.fab-container { position: relative; width: 64px; height: 64px; }
.fab { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); width: 64px; height: 64px; background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)); color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.6rem; box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4); border: 6px solid var(--surface-color); cursor: pointer; z-index: 101; transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); animation: fabEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards; }
.fab:active { transform: translateX(-50%) scale(0.9); }
.fab i { transition: transform 0.3s; }
.fab:hover i { transform: rotate(90deg); }
@keyframes fabEnter { from { transform: translateX(-50%) scale(0); } to { transform: translateX(-50%) scale(1); } }

/* Toast Notifications */
#toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: 90%; max-width: 400px;}
.toast { background: var(--surface-color); color: var(--text-primary); padding: 16px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 0.9rem; animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; border-left: 4px solid var(--primary-color);}
.toast.success { border-left-color: var(--income-color); }
.toast.error { border-left-color: var(--expense-color); }
.toast.fade-out { animation: toastFadeOut 0.3s ease forwards; }
.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--income-color); }
@keyframes toastSlideIn { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastFadeOut { to { transform: translateY(-20px); opacity: 0; } }

/* Modals (Settings, etc) */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; display: flex; justify-content: center; align-items: flex-end; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--surface-color); width: 100%; max-width: 480px; border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); padding: 30px 24px; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); max-height: 85vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(0,0,0,0.1);}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.close-modal { background: var(--bg-color); width: 36px; height: 36px; border-radius: 50%; border: none; font-size: 1.2rem; color: var(--text-primary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s;}
.close-modal:active { transform: scale(0.9); background: var(--border-color);}

/* Buttons & Utils */
.btn-outline { background: transparent; border: 2px solid var(--border-color); color: var(--text-primary); padding: 10px 16px; border-radius: 12px; cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: 0.2s;}
.btn-outline:active { background: var(--bg-color); transform: scale(0.97); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--expense-color); padding: 12px; border: none; border-radius: 12px; cursor: pointer; font-weight: 600; transition: 0.2s;}
.btn-danger:active { background: rgba(239, 68, 68, 0.2); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mb-1 { margin-bottom: 12px; } .mt-1 { margin-top: 12px; }

/* Tabs */
.tabs { display: flex; margin-bottom: 20px; background: var(--bg-color); padding: 4px; border-radius: 14px; overflow-x: auto; scrollbar-width: none;}
.tab { padding: 10px 16px; cursor: pointer; color: var(--text-secondary); font-weight: 600; border-radius: 10px; white-space: nowrap; flex: 1; text-align: center; transition: 0.3s; font-size: 0.85rem;}
.tab.active { background: var(--surface-color); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease;}

/* Settings Layout Fixes */
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border-color); gap:12px;}
.setting-row.col { flex-direction: column; align-items: stretch; }
.setting-row.col > span { margin-bottom: 8px; }

/* Chart Wrapper to prevent resize loops */
.chart-wrapper { position: relative; height: 220px; width: 100%; }

/* --- Fullscreen Overlays (PIN & Onboarding) --- */
.fullscreen-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background:var(--bg-color); z-index: 3000; display:flex; flex-direction:column; justify-content:center; align-items:center; padding: 24px; transition: opacity 0.4s; }

/* PIN Pad */
.pin-display { font-size: 2rem; letter-spacing: 10px; font-weight: 800; margin-bottom: 30px; color: var(--primary-color); height: 40px;}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; width: 280px;}
.pin-btn { width: 70px; height: 70px; border-radius: 50%; background: var(--surface-color); border: 1px solid var(--border-color); font-size: 1.5rem; font-weight: 600; color: var(--text-primary); display: flex; justify-content: center; align-items: center; cursor: pointer; box-shadow: var(--shadow-sm); transition: 0.1s;}
.pin-btn:active { background: var(--border-color); transform: scale(0.9); }

/* Onboarding */
.onb-slide { display:none; flex-direction:column; align-items:center; text-align:center; animation: fadeIn 0.4s; }
.onb-slide.active { display:flex; }
.onb-slide i { font-size: 6rem; color: var(--primary-color); margin-bottom: 30px; }
.onb-dots { display:flex; gap:8px; margin-top:40px; margin-bottom: 30px;}
.onb-dot { width:10px; height:10px; border-radius:50%; background:var(--border-color); transition:0.3s;}
.onb-dot.active { background:var(--primary-color); width: 20px; }