/* ============================================================
   Finance Manager — Premium Fintech UI
   Mobile-first. Inspired by Wallet / CRED / Spendee.
   ============================================================ */

:root {
  --bg:        #F8FAFC;
  --bg-soft:   #F1F5F9;
  --card:      #FFFFFF;
  --text:      #0F172A;
  --muted:     #64748B;
  --muted-2:   #94A3B8;
  --line:      #E2E8F0;

  --primary:   #2563EB;
  --primary-50:#EFF6FF;
  --primary-100:#DBEAFE;
  --success:   #22C55E;
  --success-50:#ECFDF5;
  --danger:    #EF4444;
  --danger-50: #FEF2F2;
  --warning:   #F59E0B;
  --warning-50:#FFFBEB;
  --purple:    #8B5CF6;
  --purple-50: #F5F3FF;

  --radius:        20px;
  --radius-sm:     14px;
  --radius-xs:     10px;
  --shadow-sm:     0 1px 2px rgba(15,23,42,.04);
  --shadow:        0 4px 24px rgba(15,23,42,.06);
  --shadow-lg:     0 10px 40px rgba(15,23,42,.10);

  --bottom-nav-h:  72px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
          Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg:        #0B1220;
  --bg-soft:   #111827;
  --card:      #131C2E;
  --text:      #E5E7EB;
  --muted:     #94A3B8;
  --muted-2:   #64748B;
  --line:      #1F2937;
  --primary-50:#0B2447;
  --primary-100:#143C7A;
  --success-50:#0E2A1E;
  --danger-50: #2A1212;
  --warning-50:#2A1F0A;
  --purple-50: #1B153A;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.50);
}

/* Base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 18px calc(var(--bottom-nav-h) + 28px);
  position: relative;
}

/* Greeting / Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.topbar .user {
  display: flex; align-items: center; gap: 12px;
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary-100); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; overflow: hidden;
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.hi { font-size: 13px; color: var(--muted); }
.name { font-weight: 700; font-size: 16px; }
.bell {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--card); display: grid; place-items: center;
  position: relative; box-shadow: var(--shadow-sm); color: var(--text);
  border: 1px solid var(--line);
}
.bell .dot {
  position: absolute; top: 10px; right: 11px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  border: 2px solid var(--card);
}

.month-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--text); font-size: 15px;
  padding: 4px 4px; margin-bottom: 14px;
}
.month-pill i { color: var(--muted); font-size: 12px; }

/* Balance Card */
.balance-card {
  background: linear-gradient(135deg, #3B6BF5 0%, #2552E2 100%);
  color: #fff; border-radius: var(--radius);
  padding: 22px 22px 18px; position: relative; overflow: hidden;
  box-shadow: 0 10px 30px rgba(37,99,235,.25);
}
.balance-card::after {
  content: ""; position: absolute; right: -40px; bottom: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.balance-card::before {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.balance-card .lbl {
  font-size: 14px; opacity: .9; display: flex; justify-content: space-between; align-items: center;
}
.balance-card .eye { color: #fff; opacity: .85; cursor: pointer; }
.balance-card .amt {
  font-size: 34px; font-weight: 800; margin: 8px 0 16px; letter-spacing: -.5px;
}
.balance-inner {
  background: rgba(255,255,255,.14);
  border-radius: 16px; padding: 12px 14px;
  display: grid; grid-template-columns: 1fr 1px 1fr; gap: 10px; align-items: center;
  backdrop-filter: blur(2px);
}
.balance-inner .sep { width: 1px; background: rgba(255,255,255,.25); height: 38px; }
.balance-inner .ttl { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.balance-inner .ttl i { font-size: 11px; }
.balance-inner .v { font-weight: 700; font-size: 17px; margin-top: 2px; }

/* Section heading */
.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin: 22px 2px 12px;
}
.section-title h2 { font-size: 17px; font-weight: 700; margin: 0; }
.section-title a { font-size: 13px; color: var(--primary); font-weight: 600; }

/* Quick actions */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-tile {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 8px 10px; text-align: center;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  transition: transform .15s ease;
}
.quick-tile:active { transform: scale(.97); }
.quick-tile .ico {
  width: 42px; height: 42px; border-radius: 12px;
  margin: 0 auto 8px; display: grid; place-items: center;
  font-size: 17px;
}
.quick-tile.income .ico  { background: var(--success-50); color: var(--success); }
.quick-tile.expense .ico { background: var(--danger-50);  color: var(--danger); }
.quick-tile.transfer .ico{ background: var(--primary-50); color: var(--primary); }
.quick-tile.budget .ico  { background: var(--purple-50);  color: var(--purple); }
.quick-tile .lbl { font-size: 13px; color: var(--text); font-weight: 600; }

/* Overview cards (Income / Expense / Savings) */
.overview-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.ov-card {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 14px 12px 12px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  min-height: 110px; display: flex; flex-direction: column; justify-content: space-between;
}
.ov-card .t { font-size: 12px; color: var(--muted); font-weight: 600; }
.ov-card .v { font-weight: 800; font-size: 16px; margin-top: 4px; letter-spacing: -.3px; }
.ov-card.income   { background: var(--success-50); }
.ov-card.expense  { background: var(--danger-50);  }
.ov-card.savings  { background: var(--primary-50); }
.ov-card .spark { height: 28px; margin-top: 6px; }

/* Donut + category list */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.split { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: center; }
.cat-list { display: flex; flex-direction: column; gap: 10px; }
.cat-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.cat-row .ico {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px;
}
.cat-row .nm { flex: 1; font-weight: 600; }
.cat-row .am { color: var(--text); font-weight: 700; font-size: 14px; }

/* Transaction rows */
.txn-list { display: flex; flex-direction: column; gap: 8px; }
.txn {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.txn .badge-ico {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
  background: var(--danger-50); color: var(--danger);
  flex-shrink: 0;
}
.txn.income .badge-ico { background: var(--success-50); color: var(--success); }
.txn .body { flex: 1; min-width: 0; }
.txn .ttl { font-weight: 700; font-size: 14px; }
.txn .meta { font-size: 12px; color: var(--muted); }
.txn .amt { font-weight: 700; font-size: 15px; color: var(--danger); white-space: nowrap; }
.txn.income .amt { color: var(--success); }

.day-label {
  font-size: 13px; color: var(--muted); font-weight: 600;
  margin: 14px 4px 8px;
}

/* Pills (filters) */
.pill-group { display: flex; gap: 8px; margin: 12px 0 6px; }
.pill {
  flex: 1; padding: 10px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; text-align: center;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill.income.active { background: var(--success-50); color: var(--success); border-color: var(--success-50); }
.pill.expense.active { background: var(--danger-50); color: var(--danger); border-color: var(--danger-50); }

/* Search */
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 999px; box-shadow: var(--shadow-sm);
}
.search-wrap i { color: var(--muted); }
.search-wrap input {
  border: 0; background: transparent; flex: 1; outline: none; font-size: 14px;
  color: var(--text);
}

/* Forms */
.form-card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; background: var(--bg); color: var(--text);
  outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); background: var(--card);
}
.field textarea { min-height: 84px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 14px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  border: 1px solid transparent; transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost   { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-block   { width: 100%; }

/* Floating Add */
.fab {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 18px);
  left: 50%; transform: translateX(calc(240px - 38px));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 12px 28px rgba(37,99,235,.4);
  border: none; cursor: pointer; z-index: 30;
}
@media (max-width: 480px) {
  .fab { transform: none; left: auto; right: 22px; }
}

/* Bottom Nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 40; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex; justify-content: space-around; align-items: center;
  width: 100%; max-width: 480px; margin: 0 auto; padding: 8px 6px 6px;
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted-2); font-size: 11px; font-weight: 600;
}
.bn-item i { font-size: 18px; }
.bn-item.active { color: var(--primary); }

/* Budget rows */
.budget-row {
  background: var(--card); padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.budget-row .head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.budget-row .ico {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary);
}
.budget-row .nm { flex: 1; font-weight: 700; font-size: 14px; }
.budget-row .vals { font-weight: 700; font-size: 13px; }
.bar { width: 100%; height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.bar.green > span  { background: var(--success); }
.bar.orange > span { background: var(--warning); }
.bar.red > span    { background: var(--danger); }
.budget-row .pct { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: right; font-weight: 600; }

/* Settings list */
.settings-list { display: flex; flex-direction: column; gap: 10px; }
.set-row {
  background: var(--card); border-radius: var(--radius-sm);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  padding: 14px; display: flex; align-items: center; gap: 14px;
}
.set-row .ico {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary);
}
.set-row .body { flex: 1; }
.set-row .ttl { font-weight: 700; font-size: 14px; }
.set-row .sub { font-size: 12px; color: var(--muted); }
.set-row .chev { color: var(--muted-2); }

/* Switch */
.switch { width: 44px; height: 26px; background: var(--bg-soft); border-radius: 999px; position: relative; cursor: pointer; border: 1px solid var(--line); }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s;
}
.switch.on { background: var(--primary); border-color: var(--primary); }
.switch.on::after { left: 20px; }

/* Empty state */
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty i { font-size: 36px; color: var(--muted-2); margin-bottom: 10px; }
.empty p { margin: 6px 0; }

/* Auth pages */
.auth-shell {
  max-width: 420px; margin: 0 auto; padding: 30px 22px;
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
}
.auth-logo {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 24px;
  margin: 0 auto 18px; box-shadow: 0 10px 24px rgba(37,99,235,.3);
}
.auth-shell h1 { text-align: center; font-size: 24px; font-weight: 800; margin: 0 0 6px; }
.auth-shell .sub { text-align: center; color: var(--muted); margin-bottom: 28px; }
.auth-shell .alt { text-align: center; color: var(--muted); margin-top: 18px; font-size: 14px; }
.auth-shell .alt a { color: var(--primary); font-weight: 700; }

/* Alert */
.alert {
  padding: 12px 14px; border-radius: 12px; font-size: 14px;
  margin-bottom: 14px; border: 1px solid transparent;
}
.alert-error   { background: var(--danger-50); color: var(--danger); border-color: var(--danger-50); }
.alert-success { background: var(--success-50); color: var(--success); border-color: var(--success-50); }
.alert-info    { background: var(--primary-50); color: var(--primary); border-color: var(--primary-50); }

/* Sidebar (desktop) */
@media (min-width: 992px) {
  .desktop-sidebar { display: block !important; }
  .app-shell { margin-left: 260px; max-width: 720px; }
  .bottom-nav { display: none; }
  .fab { left: 260px; transform: none; right: auto; margin-left: 18px; bottom: 26px; }
}
.desktop-sidebar {
  display: none;
  position: fixed; top: 0; left: 0; bottom: 0; width: 240px;
  background: var(--card); border-right: 1px solid var(--line);
  padding: 24px 16px; z-index: 50;
}
.desktop-sidebar .brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
  font-weight: 800; font-size: 18px;
}
.desktop-sidebar .brand .b {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: #fff; display: grid; place-items: center;
}
.ds-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-radius: 12px; margin-bottom: 4px; color: var(--muted); font-weight: 600;
  font-size: 14px;
}
.ds-link i { width: 18px; text-align: center; }
.ds-link.active, .ds-link:hover { background: var(--primary-50); color: var(--primary); }

/* Page heading */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--text);
}

/* Chart wrappers */
.chart-wrap { width: 100%; height: 220px; }
.chart-wrap-sm { width: 100%; height: 140px; }

/* Goal card */
.goal-card { background: var(--card); border-radius: var(--radius-sm); border: 1px solid var(--line); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.goal-card .h { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.goal-card .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.goal-card .nm { font-weight: 700; }
.goal-card .meta { font-size: 12px; color: var(--muted); }

/* Reminder */
.rem-row { background: var(--card); padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.rem-row .ico { width: 38px; height: 38px; border-radius: 12px; background: var(--warning-50); color: var(--warning); display: grid; place-items: center; }
.rem-row .body { flex: 1; }
.rem-row .ttl { font-weight: 700; font-size: 14px; }
.rem-row .sub { font-size: 12px; color: var(--muted); }
.rem-row .badge { font-size: 11px; padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.badge-pending { background: var(--warning-50); color: var(--warning); }
.badge-paid    { background: var(--success-50); color: var(--success); }
.badge-overdue { background: var(--danger-50); color: var(--danger); }

/* Modal-ish bottom sheet (optional small) */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: none; z-index: 60; align-items: flex-end; justify-content: center;
}
.sheet-overlay.open { display: flex; }
.sheet {
  width: 100%; max-width: 480px; background: var(--card);
  border-radius: 24px 24px 0 0; padding: 18px;
  animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0;} to { transform: none; opacity: 1; } }

/* Utility */
.muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.w-100 { width: 100%; }

/* ============================================================
   PROFESSIONAL DARK MODE — v2.1
   Add this at the very end of app.css. Overrides everything.
   ============================================================ */
[data-theme="dark"] {
  --bg:           #0B1220;
  --bg-soft:      #131C2E;
  --card:         #1A2335;
  --text:         #E6EAF2;
  --muted:        #94A3B8;
  --muted-2:      #64748B;
  --line:         #25324A;
  --primary:      #3B82F6;
  --primary-soft: #1E3A8A;
}

[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select { background: var(--card); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus { background: var(--card); color: var(--text); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
[data-theme="dark"] .form-control::placeholder { color: var(--muted-2); }

[data-theme="dark"] .text-muted { color: var(--muted) !important; }
[data-theme="dark"] hr { border-color: var(--line); }

[data-theme="dark"] .bottom-nav,
[data-theme="dark"] .desktop-sidebar { background: var(--card); border-color: var(--line); }
[data-theme="dark"] .bn-item { color: var(--muted); }
[data-theme="dark"] .bn-item.active { color: var(--primary); }
[data-theme="dark"] .ds-link { color: var(--muted); }
[data-theme="dark"] .ds-link:hover,
[data-theme="dark"] .ds-link.active { background: var(--bg-soft); color: var(--text); }

[data-theme="dark"] .topbar .bell,
[data-theme="dark"] .icon-btn { background: var(--card); border-color: var(--line); color: var(--text); }
[data-theme="dark"] .switch { background: var(--bg-soft); border-color: var(--line); }
[data-theme="dark"] .switch::after { background: #E6EAF2; }

[data-theme="dark"] .alert-success { background: rgba(34,197,94,.12); color: #4ADE80; border-color: rgba(34,197,94,.25); }
[data-theme="dark"] .alert-danger  { background: rgba(239,68,68,.12); color: #FCA5A5; border-color: rgba(239,68,68,.25); }
[data-theme="dark"] .alert-warning { background: rgba(245,158,11,.12); color: #FDE68A; border-color: rgba(245,158,11,.25); }

[data-theme="dark"] .btn-soft { background: var(--bg-soft); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .btn-soft:hover { background: var(--line); }
[data-theme="dark"] .btn-outline-primary { color: var(--primary); border-color: var(--primary); }
[data-theme="dark"] .btn-outline-primary:hover { background: var(--primary); color: #fff; }

[data-theme="dark"] .badge-ico { filter: brightness(1.1); }

/* Soft borders look better in dark */
[data-theme="dark"] details summary { color: var(--muted); }
[data-theme="dark"] code { background: var(--bg-soft); color: #93C5FD; }

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }