/* ── Reset & Tokens ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0e0f11;
  --bg2:       #16181c;
  --bg3:       #1e2127;
  --border:    #2a2d35;
  --text:      #e8e9ec;
  --muted:     #6b7280;
  --accent:    #c8f04a;
  --accent2:   #4af0a0;
  --red:       #f0614a;
  --green:     #4af0a0;
  --sidebar-w: 220px;
  --radius:    10px;
  --font-head: 'Fraunces', Georgia, serif;
  --font-mono: 'DM Mono', monospace;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font-mono); font-size: 14px; }

.hidden { display: none !important; }

/* ── Login ──────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 340px; padding: 48px 40px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { font-family: var(--font-head); font-size: 28px; font-weight: 300; color: var(--text); }
.login-card h1 em { font-style: italic; color: var(--accent); }
.login-sub { color: var(--muted); font-size: 13px; }
.login-card input { padding: 10px 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-family: var(--font-mono); font-size: 14px; width: 100%; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button { padding: 10px; background: var(--accent); color: #0e0f11; font-family: var(--font-mono); font-weight: 500; font-size: 14px; border: none; border-radius: 6px; cursor: pointer; transition: opacity .15s; }
.login-card button:hover { opacity: .85; }
.login-error { color: var(--red); font-size: 12px; }

/* ── App Shell ──────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 24px 0; flex-shrink: 0;
}
.sidebar-logo {
  font-family: var(--font-head); font-size: 20px; font-weight: 300;
  padding: 0 20px 24px; color: var(--text); border-bottom: 1px solid var(--border);
}
.sidebar-logo em { font-style: italic; color: var(--accent); }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  color: var(--muted); text-decoration: none; border-radius: 6px;
  font-size: 13px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--accent); }
.nav-icon { font-size: 14px; }
.logout-btn {
  margin: 0 10px; padding: 8px 12px; background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; transition: border-color .15s, color .15s; text-align: left;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* ── Main ───────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; padding: 32px; }

.view { display: none; }
.view.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.view-header h2 { font-family: var(--font-head); font-size: 28px; font-weight: 300; }
.view-header h2 em { font-style: italic; color: var(--accent); }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 32px; font-weight: 300; }
.stat-income .stat-value { color: var(--green); }
.stat-expense .stat-value { color: var(--red); }
.stat-net .stat-value { color: var(--text); }

/* ── Charts ─────────────────────────────────────────────────── */
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 28px; }
.chart-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.chart-card h3 { font-family: var(--font-head); font-weight: 300; font-size: 16px; margin-bottom: 16px; color: var(--muted); }

/* ── Section header ─────────────────────────────────────────── */
.section-header { margin-bottom: 12px; }
.section-header h3 { font-family: var(--font-head); font-weight: 300; font-size: 18px; color: var(--muted); }

/* ── Transaction List ───────────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: 2px; }
.tx-item {
  display: grid; grid-template-columns: 36px 1fr auto auto;
  align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  transition: border-color .15s;
}
.tx-item:hover { border-color: var(--accent); }
.tx-icon { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 16px; flex-shrink: 0; }
.tx-meta { min-width: 0; }
.tx-desc { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.tx-date { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.tx-amount { font-family: var(--font-head); font-size: 18px; font-weight: 300; white-space: nowrap; text-align: right; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.tx-actions { display: none; gap: 6px; }
.tx-item:hover .tx-actions { display: flex; }
.tx-actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 6px; font-size: 12px; border-radius: 4px; }
.tx-actions button:hover { color: var(--text); background: var(--bg3); }
.tx-actions .del:hover { color: var(--red); }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar select, .filter-bar input {
  padding: 7px 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: var(--font-mono); font-size: 13px;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--accent); }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
#tx-page-info { font-size: 12px; color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  padding: 8px 18px; background: var(--accent); color: #0e0f11;
  border: none; border-radius: 6px; font-family: var(--font-mono); font-size: 13px;
  cursor: pointer; font-weight: 500; transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-ghost {
  padding: 8px 14px; background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 13px;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-danger { padding: 6px 12px; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--red); font-family: var(--font-mono); font-size: 12px; cursor: pointer; }
.btn-danger:hover { border-color: var(--red); }

/* ── Budget Grid ────────────────────────────────────────────── */
.budget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.budget-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.budget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.budget-label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.budget-amounts { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.budget-amounts span { color: var(--text); }
.progress-bar { height: 4px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }

/* ── Account Grid ───────────────────────────────────────────── */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.account-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.account-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.account-name { font-family: var(--font-head); font-size: 18px; font-weight: 300; }
.account-type { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.account-balance { font-family: var(--font-head); font-size: 28px; font-weight: 300; }
.account-balance.positive { color: var(--green); }
.account-balance.negative { color: var(--red); }
.account-currency { font-size: 11px; color: var(--muted); margin-top: 2px; }
.account-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Category Grid ──────────────────────────────────────────── */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.category-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; align-items: center; justify-content: space-between; }
.cat-label { display: flex; align-items: center; gap: 10px; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-name { font-size: 13px; }
.cat-type { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(4px);
}
.modal-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); width: 420px; max-width: 95vw; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-family: var(--font-head); font-weight: 300; font-size: 20px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.form-row input, .form-row select {
  padding: 9px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: var(--font-mono); font-size: 14px;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent); }

/* Segmented control */
.seg-control { display: flex; background: var(--bg3); border-radius: 6px; padding: 3px; gap: 3px; }
.seg { flex: 1; padding: 7px; background: none; border: none; color: var(--muted); font-family: var(--font-mono); font-size: 13px; cursor: pointer; border-radius: 4px; transition: background .15s, color .15s; }
.seg.active { background: var(--bg2); color: var(--accent); }

/* ── Date picker for dashboard ──────────────────────────────── */
.date-range input {
  padding: 7px 12px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: var(--font-mono); font-size: 13px;
}
.date-range input:focus { outline: none; border-color: var(--accent); }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  padding: 12px 20px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; animation: slideUp .2s ease;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .chart-row { grid-template-columns: 1fr; }
}