/* styles.css — LoveFinance */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Tokens ───────────────────────────────────────────────────── */
:root {
  --font: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --green: #22c55e;
  --green-dim: rgba(34,197,94,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96,165,250,0.12);
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #252525;
  --bg4: #2f2f2f;
  --text: #f5f5f5;
  --text2: #a0a0a0;
  --text3: #606060;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg2: #ffffff;
  --bg3: #f3f3f3;
  --bg4: #ebebeb;
  --text: #111111;
  --text2: #555555;
  --text3: #999999;
  --border: rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.13);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100%; max-width: 430px; margin: 0 auto; overscroll-behavior: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select { font-family: var(--font); }
#app { min-height: 100dvh; }

/* ── Screen ───────────────────────────────────────────────────── */
.screen { padding: 0 16px; padding-top: env(safe-area-inset-top, 16px); padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
.screen-header { display: flex; align-items: center; gap: 10px; padding: 16px 0 20px; }
.screen-title { font-size: 20px; font-weight: 600; flex: 1; }
.screen-subtitle { font-size: 13px; color: var(--text2); }
.back-btn { font-size: 22px; color: var(--text2); padding: 4px 8px 4px 0; line-height: 1; }
.back-btn:hover { color: var(--text); }
.icon-btn { font-size: 22px; color: var(--text2); padding: 4px; }
.icon-btn:hover { color: var(--text); }

/* ── Lock Screen ──────────────────────────────────────────────── */
.lock-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 32px 24px; }
.lock-logo { font-size: 48px; font-weight: 600; font-family: var(--font-mono); background: var(--text); color: var(--bg); width: 80px; height: 80px; border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 28px; letter-spacing: -1px; margin-bottom: 16px; }
.lock-title { font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.lock-sub { font-size: 14px; color: var(--text2); margin-bottom: 36px; text-align: center; }
.pin-dots { display: flex; gap: 16px; margin-bottom: 8px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border2); background: transparent; transition: background var(--transition); }
.pin-dot.filled { background: var(--text); border-color: var(--text); }
.lock-error { font-size: 13px; color: var(--red); min-height: 18px; margin: 8px 0 24px; text-align: center; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; }
.pin-key { width: 72px; height: 72px; border-radius: 50%; background: var(--bg3); color: var(--text); font-size: 22px; font-weight: 400; transition: background var(--transition), transform 0.08s; }
.pin-key:active { background: var(--bg4); transform: scale(0.94); }
.pin-key-empty { background: transparent !important; }
.lock-bio { margin-top: 28px; font-size: 14px; color: var(--blue); padding: 8px 20px; border: 1px solid var(--blue-dim); border-radius: 100px; }

/* ── Overview ─────────────────────────────────────────────────── */
.overview-header { display: flex; align-items: flex-start; justify-content: space-between; padding-top: calc(env(safe-area-inset-top,16px) + 8px); padding-bottom: 20px; }
.greeting { font-size: 22px; font-weight: 600; }
.greeting-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }
.avatar-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg3); color: var(--text2); font-size: 12px; font-weight: 600; letter-spacing: 0.5px; border: 1px solid var(--border); }

.balance-hero { margin-bottom: 16px; }
.balance-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); margin-bottom: 4px; }
.balance-big { font-size: 40px; font-weight: 300; letter-spacing: -1px; }
.balance-big.pos { color: var(--green); }
.balance-big.neg { color: var(--red); }
.balance-big.blue { color: var(--blue); }
.balance-sub { font-size: 13px; color: var(--text3); margin-top: 4px; }

.stats-row { display: flex; gap: 8px; margin-bottom: 28px; }
.stat-pill { flex: 1; background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 10px; }
.stat-pill-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 4px; }
.stat-pill-val { font-size: 13px; font-weight: 500; }
.stat-pill.green .stat-pill-val { color: var(--green); }
.stat-pill.red .stat-pill-val { color: var(--red); }
.stat-pill.blue .stat-pill-val { color: var(--blue); }

.section-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); }
.section-link { font-size: 13px; color: var(--blue); }

.recent-list { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.recent-item:last-child { border-bottom: none; }
.recent-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.recent-dot.income { background: var(--green); }
.recent-dot.expense { background: var(--red); }
.recent-info { flex: 1; min-width: 0; }
.recent-note { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
.recent-amount { font-size: 14px; font-weight: 500; flex-shrink: 0; }
.recent-amount.income { color: var(--green); }
.recent-amount.expense { color: var(--red); }

.goal-mini { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px; }
.goal-mini-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.goal-mini-name { font-size: 14px; font-weight: 500; }
.goal-mini-pct { font-size: 13px; color: var(--blue); font-weight: 500; }
.goal-mini-amounts { font-size: 11px; color: var(--text3); margin-top: 5px; }

/* ── Fab ──────────────────────────────────────────────────────── */
.fab { position: fixed; right: 20px; bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 16px); width: 56px; height: 56px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 28px; font-weight: 300; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; z-index: 50; transition: transform 0.15s, box-shadow 0.15s; line-height: 1; }
.fab:active { transform: scale(0.94); }

/* ── Tab Bar ──────────────────────────────────────────────────── */
#tab-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 430px; display: flex; background: var(--bg2); border-top: 0.5px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0); z-index: 100; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 10px; color: var(--text3); transition: color var(--transition); }
.tab-btn.active { color: var(--text); }
.tab-icon { font-size: 18px; line-height: 1; margin-bottom: 2px; }
.tab-label { font-size: 10px; }

/* ── Modal / Sheet ────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: flex-end; z-index: 200; }
.modal-sheet { background: var(--bg2); border-radius: 20px 20px 0 0; padding: 16px 20px calc(20px + env(safe-area-inset-bottom,0px)); width: 100%; max-height: 90dvh; overflow-y: auto; }
.modal-handle { width: 36px; height: 4px; background: var(--bg4); border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* ── Quick Add ────────────────────────────────────────────────── */
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.type-btn { padding: 9px; border-radius: var(--radius-sm); border: 0.5px solid var(--border2); background: var(--bg3); color: var(--text2); font-size: 14px; font-weight: 500; transition: all var(--transition); }
.type-btn.active-income { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.type-btn.active-expense { background: var(--red-dim); border-color: var(--red); color: var(--red); }

.amount-big-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.amount-big-input { flex: 1; font-size: 36px; font-weight: 300; background: transparent; border: none; outline: none; color: var(--text); width: 100%; }
.amount-currency { font-size: 20px; color: var(--text3); flex-shrink: 0; }

.cat-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.cat-chip { padding: 6px 12px; border-radius: 100px; border: 0.5px solid var(--border2); background: var(--bg3); color: var(--text2); font-size: 13px; transition: all var(--transition); }
.cat-chip.active { background: var(--bg4); color: var(--text); border-color: var(--border2); }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-field label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); }
.form-field input, .form-field select { background: var(--bg3); border: 0.5px solid var(--border2); border-radius: var(--radius-xs); color: var(--text); font-size: 14px; padding: 9px 11px; outline: none; width: 100%; }
.form-field input:focus, .form-field select:focus { border-color: var(--blue); }
.form-field select option { background: var(--bg3); }

.submit-btn { width: 100%; padding: 13px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600; margin-top: 4px; transition: opacity var(--transition); }
.submit-btn:active { opacity: 0.85; }
.cancel-btn { width: 100%; padding: 11px; border-radius: var(--radius-sm); background: transparent; color: var(--text2); font-size: 14px; margin-top: 8px; }
.add-full-btn { width: 100%; padding: 11px; border-radius: var(--radius-sm); background: var(--bg2); border: 0.5px solid var(--border2); color: var(--text); font-size: 14px; font-weight: 500; margin-bottom: 14px; }

/* ── Filters ──────────────────────────────────────────────────── */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-chip { padding: 5px 13px; border-radius: 100px; border: 0.5px solid var(--border); background: transparent; color: var(--text2); font-size: 12px; transition: all var(--transition); }
.filter-chip.active { background: var(--bg3); color: var(--text); border-color: var(--border2); }

/* ── Transaction list ─────────────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; }
.tx-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 0.5px solid var(--border); }
.tx-item:last-child { border-bottom: none; }
.tx-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tx-dot.income { background: var(--green); }
.tx-dot.expense { background: var(--red); }
.tx-info { flex: 1; min-width: 0; }
.tx-note { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }
.tx-amount { font-size: 14px; font-weight: 500; flex-shrink: 0; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.del-btn { color: var(--text3); font-size: 14px; padding: 4px 6px; flex-shrink: 0; }
.del-btn:hover { color: var(--red); }
.who-tag { display: inline; background: var(--bg3); color: var(--text3); font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.auto-tag { font-size: 10px; background: var(--blue-dim); color: var(--blue); padding: 1px 5px; border-radius: 4px; }

/* ── Savings ──────────────────────────────────────────────────── */
.goals-list { display: flex; flex-direction: column; gap: 10px; }
.goal-card { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px; }
.goal-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.goal-name { font-size: 15px; font-weight: 600; }
.goal-deadline { font-size: 11px; margin-top: 3px; }
.goal-deadline.on-track { color: var(--green); }
.goal-deadline.behind { color: var(--red); }
.goal-amounts-row { display: flex; gap: 6px; align-items: baseline; margin-bottom: 8px; }
.goal-saved { font-size: 20px; font-weight: 500; color: var(--blue); }
.goal-target { font-size: 13px; color: var(--text3); }
.goal-bar-bg { height: 5px; background: var(--bg4); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.goal-bar-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width 0.4s ease; }
.goal-bar-fill.complete { background: var(--green); }
.goal-pct-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text3); margin-bottom: 10px; }
.monthly-tag { color: var(--blue); }
.goal-actions { display: flex; gap: 8px; }
.goal-deposit-btn { flex: 1; padding: 8px; border-radius: var(--radius-xs); background: var(--blue-dim); color: var(--blue); font-size: 13px; font-weight: 500; border: 0.5px solid transparent; }
.goal-deposit-info { font-size: 13px; color: var(--text2); margin-bottom: 16px; }

/* ── Forecast ─────────────────────────────────────────────────── */
.forecast-section { margin-bottom: 4px; }
.forecast-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px; }
.forecast-section-title.green { color: var(--green); }
.forecast-section-title.red { color: var(--red); }
.forecast-section-title.blue { color: var(--blue); }
.forecast-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 0.5px solid var(--border); font-size: 14px; }
.forecast-label { color: var(--text2); }
.forecast-val { font-weight: 500; }
.forecast-val.green { color: var(--green); }
.forecast-val.red { color: var(--red); }
.forecast-val.blue { color: var(--blue); }
.forecast-total-row { display: flex; justify-content: space-between; padding: 10px 0 16px; font-size: 14px; font-weight: 600; }
.forecast-divider { height: 0.5px; background: var(--border2); margin: 4px 0 16px; }
.forecast-result-card { background: var(--bg2); border: 0.5px solid var(--border2); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; text-align: center; }
.forecast-result-card.pos { border-color: rgba(34,197,94,0.3); }
.forecast-result-card.neg { border-color: rgba(248,113,113,0.3); }
.forecast-result-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); margin-bottom: 6px; }
.forecast-result-amount { font-size: 36px; font-weight: 300; letter-spacing: -1px; }
.forecast-result-card.pos .forecast-result-amount { color: var(--green); }
.forecast-result-card.neg .forecast-result-amount { color: var(--red); }
.forecast-result-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }
.forecast-realistic-card { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 16px; }
.forecast-realistic-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.forecast-realistic-body { font-size: 13px; color: var(--text2); line-height: 1.6; margin-bottom: 12px; }
.forecast-realistic-result { font-size: 15px; font-weight: 600; padding-top: 10px; border-top: 0.5px solid var(--border); }
.forecast-realistic-result.pos { color: var(--green); }
.forecast-realistic-result.neg { color: var(--red); }
.forecast-empty { font-size: 13px; color: var(--text3); padding: 8px 0 14px; line-height: 1.6; }

/* ── Charts ───────────────────────────────────────────────────── */
.chart-section-title { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 14px; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-bottom: 24px; position: relative; }
.bar-group { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 2px; align-items: flex-end; }
.bar { min-height: 4px; width: 14px; border-radius: 3px 3px 0 0; position: relative; cursor: pointer; transition: opacity 0.15s; }
.bar:hover .bar-tooltip { display: block; }
.bar-tooltip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--bg4); color: var(--text); font-size: 10px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; z-index: 10; }
.income-bar { background: var(--green); opacity: 0.8; }
.expense-bar { background: var(--red); opacity: 0.8; }
.bar-label { font-size: 10px; color: var(--text3); margin-top: 6px; position: absolute; bottom: 0; }
.bar-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); margin-top: 8px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.income-dot { background: var(--green); }
.expense-dot { background: var(--red); }
.donut-wrap { display: flex; justify-content: center; margin: 16px 0; }
.donut-svg { overflow: visible; }
.donut-center-label { font-size: 13px; fill: var(--text3); font-family: var(--font); }
.donut-center-amount { font-size: 16px; fill: var(--text); font-family: var(--font); font-weight: 600; }
.breakdown-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.breakdown-row { display: flex; align-items: center; gap: 8px; }
.breakdown-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.breakdown-cat { font-size: 13px; width: 90px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-bar-wrap { flex: 1; height: 5px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.breakdown-bar-fill { height: 100%; border-radius: 3px; }
.breakdown-pct { font-size: 11px; color: var(--text3); width: 30px; text-align: right; flex-shrink: 0; }
.breakdown-val { font-size: 12px; font-weight: 500; width: 70px; text-align: right; flex-shrink: 0; }

/* ── Settings ─────────────────────────────────────────────────── */
.settings-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text3); margin: 20px 0 8px; }
.settings-card { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 0.5px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: 14px; }
.settings-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.settings-btn { font-size: 13px; color: var(--blue); padding: 6px 12px; border-radius: var(--radius-xs); background: var(--blue-dim); }
.settings-btn.danger { color: var(--red); background: var(--red-dim); }
.settings-version { font-size: 12px; color: var(--text3); text-align: center; margin-top: 24px; }

.segmented { display: flex; background: var(--bg3); border-radius: var(--radius-xs); padding: 2px; gap: 2px; }
.seg-btn { padding: 5px 10px; border-radius: 6px; font-size: 13px; color: var(--text2); transition: all var(--transition); }
.seg-btn.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg4); border-radius: 24px; transition: background var(--transition); }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: transform var(--transition); }
input:checked + .toggle-slider { background: var(--green); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Suggest recurring ────────────────────────────────────────── */
.suggest-icon { font-size: 32px; text-align: center; margin-bottom: 8px; }
.suggest-body { font-size: 14px; color: var(--text2); line-height: 1.6; margin-bottom: 8px; }

/* ── Misc ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; color: var(--text3); font-size: 14px; padding: 28px 0; line-height: 1.7; }
.green { color: var(--green); }
.red { color: var(--red); }
.blue { color: var(--blue); }
