/* ═══════════════════════════════════════════════════════
   CashFlow v2.0 — Mobile-First SPA Stylesheet
   ═══════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 250px;
    --transition: .2s ease;
    --nav-h: 64px;
    --header-h: 56px;
    --fab-size: 56px;
}

html { scroll-behavior: smooth; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}
input, select, textarea, button { font-family: inherit; font-size: .95rem; }
a { text-decoration: none; color: var(--primary); }
a:hover { text-decoration: underline; }

/* ─── Screens ────────────────────────────────── */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 1;
    overflow-y: auto;
    animation: fadeIn .25s ease;
}
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── Splash ─────────────────────────────────── */
.splash-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
}
.splash-logo { text-align: center; margin-bottom: 48px; }
.splash-icon { font-size: 80px; display: block; margin-bottom: 16px; }
.splash-title { font-size: 36px; font-weight: 800; margin-bottom: 8px; }
.splash-subtitle { font-size: 16px; opacity: .9; }
.splash-loader { width: 200px; height: 4px; background: rgba(255,255,255,.3); border-radius: 2px; overflow: hidden; }
.loader-bar { height: 100%; background: #fff; width: 0; animation: loadBar 1.8s ease-in-out forwards; border-radius: 2px; }
@keyframes loadBar { 0% { width: 0; } 100% { width: 100%; } }

/* ─── Auth ───────────────────────────────────── */
.auth-screen {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 20px;
}
.auth-screen.active { display: flex; }
.auth-container {
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 36px 28px;
    width: 100%;
    max-width: 420px;
    animation: modalIn .3s ease;
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.auth-header h1 { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.auth-header p { font-size: .95rem; color: var(--text-secondary); }
.auth-form { }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: .85rem; }

/* ─── App Shell ──────────────────────────────── */
.app-shell {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: calc(var(--nav-h) + 16px);
}
.app-shell.active { display: flex; }

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--header-h);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 8px; }
#page-title { font-size: 18px; font-weight: 700; }

/* Main */
.app-main { flex: 1; padding: 16px; max-width: 800px; margin: 0 auto; width: 100%; }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition);
    flex: 1;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 11px; font-weight: 600; }

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    right: 16px;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), background var(--transition);
}
.fab:hover { transform: scale(1.05); background: var(--primary-hover); }

/* ─── Views ──────────────────────────────────── */
.view { display: none; animation: fadeIn .25s ease; }
.view.active { display: block; }

/* ─── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    transition: border var(--transition);
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ─── Buttons ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-size: .95rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.icon-btn:hover { background: var(--border); }

/* ─── Dashboard ──────────────────────────────── */
.dashboard-header { margin-bottom: 20px; }
.greeting { font-size: 1.1rem; font-weight: 600; }
.greeting span { color: var(--primary); }
.date-range { font-size: .85rem; color: var(--text-secondary); margin-top: 4px; }

.balance-card {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.balance-label { font-size: .85rem; opacity: .9; margin-bottom: 4px; }
.balance-amount { font-size: 32px; font-weight: 800; margin-bottom: 12px; }
.balance-change { display: flex; gap: 16px; font-size: .85rem; }
.change-income { opacity: .9; }
.change-expense { opacity: .9; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.dashboard-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.dashboard-card h3 { font-size: .8rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.dashboard-card .amount { font-size: 1.25rem; font-weight: 800; }
.amount.income { color: var(--success); }
.amount.expense { color: var(--danger); }
.amount.warning { color: var(--warning); }

.section { margin-bottom: 24px; }
.section-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }

/* ─── Cards & Lists ──────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.wallet-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wallet-info h4 { font-size: 1rem; font-weight: 700; }
.wallet-info p { font-size: .85rem; color: var(--text-secondary); }
.wallet-balance { font-size: 1.1rem; font-weight: 800; }

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}
.category-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.category-name { flex: 1; font-weight: 500; }
.category-badge { font-size: .75rem; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.category-badge.income { background: var(--success-light); color: #065f46; }
.category-badge.expense { background: var(--danger-light); color: #991b1b; }

.tx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}
.tx-icon { font-size: 24px; }
.tx-info { flex: 1; }
.tx-info h4 { font-size: .95rem; font-weight: 600; }
.tx-info p { font-size: .8rem; color: var(--text-secondary); }
.tx-amount { font-weight: 700; font-size: 1rem; }
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

/* ─── Tabs ───────────────────────────────────── */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.tab {
    padding: 8px 20px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--card);
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    transition: all var(--transition);
    white-space: nowrap;
    color: var(--text-secondary);
}
.tab:hover { border-color: var(--primary); color: var(--primary); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Empty State ────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px 20px;
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }
.empty-state.small { padding: 20px; }

/* ─── Settings ───────────────────────────────── */
.settings-list { max-width: 600px; }
.settings-group {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.settings-group h3 { font-size: .9rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 16px; }
.settings-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.settings-item:last-child { border-bottom: none; }
.settings-item label { font-weight: 500; }
.settings-item input, .settings-item select { width: auto; min-width: 180px; padding: 8px 12px; }

/* ─── Help ───────────────────────────────────── */
.help-container { max-width: 600px; }
.help-section { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.help-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.faq-item { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary { font-weight: 600; cursor: pointer; color: var(--text); }
.faq-item p { margin-top: 8px; color: var(--text-secondary); font-size: .9rem; }

/* ─── More Menu ──────────────────────────────── */
.more-menu { max-width: 600px; }
.more-section { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.more-section h3 { font-size: .85rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: .95rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: var(--danger); }

/* ─── Notifications ──────────────────────────── */
.notification-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.notification-item.unread { background: var(--primary-light); }
.notif-icon { font-size: 24px; }
.notif-content { flex: 1; }
.notif-content h4 { font-size: .95rem; font-weight: 600; margin-bottom: 4px; }
.notif-content p { font-size: .85rem; color: var(--text-secondary); }
.notif-time { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ─── Budget Cards ───────────────────────────── */
.budget-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.budget-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.budget-header h4 { font-size: 1rem; font-weight: 700; }
.budget-progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.budget-progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s ease; }
.budget-progress-bar.warning { background: var(--warning); }
.budget-progress-bar.danger { background: var(--danger); }
.budget-stats { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-secondary); }

/* ─── Recurring ──────────────────────────────── */
.recurring-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}
.recurring-icon { font-size: 24px; }
.recurring-info { flex: 1; }
.recurring-info h4 { font-size: .95rem; font-weight: 600; }
.recurring-info p { font-size: .85rem; color: var(--text-secondary); }
.recurring-amount { font-weight: 700; }

/* ─── Debt ───────────────────────────────────── */
.debt-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.debt-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.debt-header h4 { font-size: 1rem; font-weight: 700; }
.debt-status { font-size: .75rem; padding: 3px 10px; border-radius: 12px; font-weight: 600; }
.debt-status.open { background: var(--danger-light); color: #991b1b; }
.debt-status.settled { background: var(--success-light); color: #065f46; }
.debt-amount { font-size: 1.1rem; font-weight: 800; margin-bottom: 8px; }
.debt-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }

/* ─── Goal ───────────────────────────────────── */
.goal-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.goal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.goal-header h4 { font-size: 1rem; font-weight: 700; }
.goal-progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.goal-progress-bar { height: 100%; background: var(--success); border-radius: 4px; transition: width .3s ease; }
.goal-stats { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-secondary); }

/* ─── Onboarding ─────────────────────────────── */
.onboarding-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.onboarding-header { text-align: center; color: #fff; margin-bottom: 32px; }
.onboarding-header .auth-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.onboarding-header h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.onboarding-header p { opacity: .9; }
.onboarding-form {
    background: var(--card);
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

/* ─── Reports ────────────────────────────────── */
.report-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: flex-end;
}
.filter-input {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    font-size: .9rem;
}
.filter-select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    font-size: .9rem;
}
.report-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.report-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.report-card h3 { font-size: .8rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.report-card .amount { font-size: 1.1rem; font-weight: 800; }

/* ─── Form Container ─────────────────────────── */
.form-container { max-width: 600px; }
.form-container h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 20px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.form-actions .btn { flex: 1; }
.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-group input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
.form-select { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--card); color: var(--text); }

/* ─── Misc ───────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.view-header h2 { font-size: 1.25rem; font-weight: 700; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 480px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .report-summary { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .wallet-card { flex-direction: column; align-items: flex-start; gap: 8px; }
    .settings-item { flex-direction: column; align-items: flex-start; gap: 8px; }
    .settings-item input, .settings-item select { width: 100%; }
}
