/* =====================================================================
   Money Agent System — Design tokens & layout
   ===================================================================== */
:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e7e9f3;
  --text: #1f2437;
  --text-muted: #7c8194;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(23, 26, 47, 0.06);
  --shadow-md: 0 10px 30px rgba(23, 26, 47, 0.08);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.925rem;
}

a { text-decoration: none; }

/* ---------- App Shell / Layout ------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-w);
  background: #161a2e;
  color: #cfd2e6;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
  flex-shrink: 0;
}
.sidebar-brand-title { font-weight: 700; color: #fff; font-size: .95rem; line-height: 1.2; }
.sidebar-brand-sub { font-size: .72rem; color: #8a8fb0; }

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: #b6b9d6;
  font-weight: 500;
  font-size: .875rem;
  margin-bottom: 3px;
  transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active {
  background: linear-gradient(135deg, var(--brand), #6366f1);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .74rem;
  color: #767ba0;
  display: flex; align-items: center; gap: 8px;
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,17,32,.5);
  z-index: 1030;
}

.app-main {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.app-topbar-title { font-size: 1.15rem; font-weight: 700; margin: 0; flex: 1; }
.app-topbar-right { display: flex; align-items: center; gap: 14px; }

.btn-icon {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.btn-icon:hover { background: #f1f2fb; color: var(--text); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: #f4f5fb;
  border: 1px solid var(--border);
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  font-weight: 600;
  font-size: .85rem;
  color: var(--text);
}
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}

.app-content {
  padding: 24px;
  flex: 1;
}

/* ---------- Cards / Panels ------------------------------------------ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card-sm { padding: 14px; }
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.25rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }

.bg-primary-soft { background: #eef0fe; }
.bg-success-soft { background: #e9fbf1; }
.bg-danger-soft  { background: #fdedee; }
.bg-warning-soft { background: #fff7e6; }
.bg-info-soft    { background: #e9f6ff; }
.text-primary { color: var(--brand) !important; }

.mini-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.mini-stat-label { font-size: .72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.mini-stat-value { font-weight: 800; font-size: 1.02rem; margin-top: 2px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-wrap: wrap;
}
.panel-header h2 { font-size: .98rem; font-weight: 700; margin: 0; }
.panel-body { padding: 18px 20px; }
.panel-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
.panel-tabbed { border-top-left-radius: 0; }

.pill-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: .85rem;
  display: inline-flex; align-items: center; gap: 8px;
}

/* ---------- Tables ---------------------------------------------------- */
.table-clean { font-size: .875rem; margin-bottom: 0; }
.table-clean thead th {
  background: #fafbff;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  white-space: nowrap;
}
.table-clean tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: #fafbff; }

.badge-soft {
  font-size: .72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  display: inline-block;
}
.badge-soft-success { background: #e9fbf1; color: #16a34a; }
.badge-soft-danger  { background: #fdedee; color: #dc2626; }
.badge-soft-info    { background: #e9f6ff; color: #0284c7; }
.badge-soft-warning { background: #fff7e6; color: #b45309; }
.badge-soft-primary { background: #eef0fe; color: #4f46e5; }
.badge-soft-secondary { background: #f1f2f6; color: #64748b; }

/* ---------- Nav tabs -------------------------------------------------- */
.nav-tabs { border-bottom: none; gap: 4px; }
.nav-tabs .nav-link {
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .875rem;
  background: #f5f6fb;
}
.nav-tabs .nav-link.active {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--border);
}

/* ---------- Auth (login/setup) ---------------------------------------- */
.auth-body {
  background: linear-gradient(135deg, #161a2e 0%, #2b2f57 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
}
.auth-wrap { width: 100%; max-width: 420px; padding: 20px; }
.auth-card {
  background: #fff;
  border-radius: 18px;
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), #818cf8);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 14px;
}
.auth-brand h1 { font-size: 1.2rem; font-weight: 800; margin: 0 0 4px; }
.auth-brand p { color: var(--text-muted); font-size: .82rem; margin: 0; }

/* ---------- Buttons ----------------------------------------------------- */
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

/* ---------- Responsive -------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; width: 100%; }
  .sidebar-backdrop.open { display: block; }
}

@media (max-width: 575.98px) {
  .app-content { padding: 16px; }
  .app-topbar { padding: 0 16px; }
  .stat-value { font-size: 1.05rem; }
}