/* ==========================================================================
   Benzyo Finance — Design System
   Dark SaaS theme. Tailwind CDN handles utilities; this file defines tokens,
   the signature ledger-style numerics, and hand-built components that
   Tailwind's CDN build can't express via config alone.
   ========================================================================== */

:root {
  --bg-base: #0a0d14;
  --bg-surface: #12161f;
  --bg-surface-2: #1a1f2c;
  --bg-surface-hover: #1f2533;
  --border-subtle: #232838;
  --border-strong: #2e3548;

  --text-primary: #e7e9ee;
  --text-secondary: #9aa1b4;
  --text-muted: #636b80;

  --brand: #6c5ce7;
  --brand-hover: #7d6ff0;
  --brand-soft: rgba(108, 92, 231, 0.14);

  --money-positive: #22c55e;
  --money-positive-soft: rgba(34, 197, 94, 0.12);
  --money-negative: #f43f5e;
  --money-negative-soft: rgba(244, 63, 94, 0.12);
  --money-salary: #f59e0b;
  --money-salary-soft: rgba(245, 158, 11, 0.12);
  --money-info: #38bdf8;
  --money-info-soft: rgba(56, 189, 248, 0.12);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Ledger numerics — the signature treatment for every monetary figure */
.figure {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4259; }

/* ---------- Layout shell ---------- */
.app-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.app-topbar {
  background: rgba(10, 13, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

/* ---------- Nav items ---------- */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--brand-soft);
  color: #d6d1fb;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.4rem;
  border-radius: 0 4px 4px 0;
  background: var(--brand);
}
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0.9rem;
}

.stat-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 0.9rem;
  padding: 1.25rem;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent, var(--brand)), transparent);
}
.stat-card.accent-income { --accent: var(--money-positive); }
.stat-card.accent-expense { --accent: var(--money-negative); }
.stat-card.accent-salary { --accent: var(--money-salary); }
.stat-card.accent-profit { --accent: var(--brand); }
.stat-card.accent-info { --accent: var(--money-info); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 0.55rem;
  transition: all .15s ease;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-surface-hover); }
.btn-danger { background: var(--money-negative-soft); color: #fca5b1; border-color: rgba(244,63,94,0.3); }
.btn-danger:hover { background: rgba(244,63,94,0.2); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Form controls ---------- */
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 0.55rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--text-muted); }
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

/* ---------- Table ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr { transition: background-color .12s ease; }
.data-table tbody tr:hover { background: var(--bg-surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.badge-green { background: var(--money-positive-soft); color: #4ade80; }
.badge-red { background: var(--money-negative-soft); color: #fb7185; }
.badge-amber { background: var(--money-salary-soft); color: #fbbf24; }
.badge-blue { background: var(--money-info-soft); color: #38bdf8; }
.badge-gray { background: var(--bg-surface-2); color: var(--text-secondary); }
.badge-purple { background: var(--brand-soft); color: #c4b8fb; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 7, 12, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem;
  overflow-y: auto;
  z-index: 100;
}
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  width: 100%;
  max-width: 32rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: modal-in .18s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-width: 280px;
  max-width: 360px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--brand);
  border-radius: 0.6rem;
  padding: 0.8rem 1rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: toast-in .2s ease;
}
.toast.success { border-left-color: var(--money-positive); }
.toast.error { border-left-color: var(--money-negative); }
.toast.warning { border-left-color: var(--money-salary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast.closing { animation: toast-out .18s ease forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ---------- Empty / loading states ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { width: 44px; height: 44px; margin-bottom: 0.85rem; opacity: 0.5; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-surface-hover) 50%, var(--bg-surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 0.4rem;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Mobile sidebar drawer ---------- */
.sidebar-drawer {
  transform: translateX(-100%);
  transition: transform .22s ease;
}
.sidebar-drawer.open { transform: translateX(0); }
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Misc ---------- */
.scroll-thin { scrollbar-width: thin; }
.divider { border-color: var(--border-subtle); }

@media (max-width: 768px) {
  .data-table-wrap { overflow-x: auto; }
}
