:root {
  --bg-base: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-hover: rgba(0,0,0,0.04);
  --border: rgba(0,0,0,0.08);
  --text-primary: #0f172a;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: rgba(99,102,241,0.10);
  --green: #059669;
  --red: #dc2626;
  --yellow: #d97706;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--bg-base); color: var(--text-primary); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar { width: 220px; background: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 22px; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { display: block; padding: 14px 20px 4px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--text-muted); text-transform: uppercase; }
.sidebar-nav .nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: 13px; color: #475569; text-decoration: none; border-right: 2px solid transparent; transition: all 0.15s; }
.sidebar-nav .nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav .nav-link.active { background: var(--accent-light); color: var(--accent); border-right-color: var(--accent); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }
.nav-badge { margin-left: auto; background: var(--red); color: white; font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600; }
.sidebar-user { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; flex-shrink: 0; }
.user-info .user-name { font-size: 13px; font-weight: 500; }
.btn-logout { background: none; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.btn-logout:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Main Content ── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { padding: 14px 28px; background: var(--bg-surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.page-title { font-size: 17px; font-weight: 600; margin: 0; color: var(--text-primary); }
.btn-add-top { background: var(--accent); color: white; border: none; padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; text-decoration: none; }
.content-area { padding: 24px 28px; padding-bottom: 80px; }

/* ── Cards ── */
.stat-card { background: var(--bg-surface); border-radius: 12px; padding: 20px; border: 1px solid var(--border); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; }
.stat-trend { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.card-panel { background: var(--bg-surface); border-radius: 12px; border: 1px solid var(--border); }
.card-header { padding: 16px 20px 0; display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; margin: 0; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 16px 20px 20px; }

/* ── Transaction Row ── */
.tx-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: none; }
.tx-cat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.tx-info { flex: 1; min-width: 0; }
.tx-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.tx-amount { font-size: 15px; font-weight: 600; flex-shrink: 0; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; }
.tag-reimburse { background: rgba(251,191,36,0.12); color: var(--yellow); }
.tag-reimbursed { background: rgba(16,185,129,0.12); color: var(--green); }
.tag-attach { background: var(--accent-light); color: var(--accent); }

/* ── Forms ── */
.form-label { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 5px; display: block; }
.form-control { width: 100%; background: #ffffff; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; color: var(--text-primary); outline: none; }
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: #94a3b8; }
select.form-control { cursor: pointer; }
.form-group { margin-bottom: 16px; }
.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary:hover { background: #4f46e5; }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border); padding: 9px 18px; border-radius: 8px; font-size: 14px; text-decoration: none; display: inline-block; cursor: pointer; }

/* ── Type Toggle ── */
.type-toggle { display: flex; background: #f1f5f9; border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.type-btn { flex: 1; padding: 9px; border-radius: 7px; text-align: center; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text-muted); border: none; background: none; transition: all 0.15s; }
.type-btn.active-expense { background: rgba(248,113,113,0.15); color: var(--red); }
.type-btn.active-income { background: rgba(16,185,129,0.15); color: var(--green); }

/* ── Upload ── */
.upload-area { border: 1.5px dashed var(--border); border-radius: 10px; padding: 20px; text-align: center; cursor: pointer; background: #f8fafc; position: relative; }
.upload-area:hover { border-color: var(--accent); }

/* ── Auth Pages ── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-base); }
.auth-card { width: 100%; max-width: 380px; background: var(--bg-surface); border-radius: 16px; padding: 32px; border: 1px solid var(--border); }
.auth-logo { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-title { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 24px; color: var(--text-primary); }
.auth-link { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 16px; }
.auth-link a { color: var(--accent); text-decoration: none; }
.btn-primary-full { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--red); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ── Category grid ── */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-item { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px; text-align: center; cursor: pointer; transition: all 0.15s; }
.cat-item:hover, .cat-item.selected { border-color: var(--accent); background: var(--accent-light); }
.cat-icon { font-size: 20px; margin-bottom: 4px; }
.cat-name { font-size: 11px; color: var(--text-muted); }
.cat-item.selected .cat-name { color: var(--accent); }

/* ── Mobile bottom nav ── */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-surface); border-top: 1px solid var(--border); padding: 6px 0 env(safe-area-inset-bottom); z-index: 100; justify-content: space-around; }
.mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 18px; color: var(--text-muted); text-decoration: none; padding: 4px 0; }
.mobile-nav-item span { font-size: 10px; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-add { background: var(--accent); color: white; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; display: flex; align-items: center; justify-content: center; margin-top: -16px; box-shadow: 0 4px 12px rgba(99,102,241,0.4); flex: 0; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  .content-area { padding: 16px; padding-bottom: 90px; }
  .topbar { padding: 12px 16px; }
  .btn-add-top { display: none; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
}
