/* =========================================================
   SpendWise — Design tokens & theme
   ========================================================= */
:root {
  --sw-bg: #f4f7f6;
  --sw-surface: #ffffff;
  --sw-surface-2: #f8faf9;
  --sw-border: #e7ece9;
  --sw-text: #16211c;
  --sw-text-muted: #6b7a72;
  --sw-primary: #0f9d74;
  --sw-primary-dark: #0b7a5a;
  --sw-primary-light: #e3f6ee;
  --sw-accent: #0ea5a3;
  --sw-danger: #e5484d;
  --sw-danger-light: #fdecec;
  --sw-warning: #d9962b;
  --sw-warning-light: #fbf1de;
  --sw-info: #3b82f6;
  --sw-radius-sm: 10px;
  --sw-radius: 16px;
  --sw-radius-lg: 22px;
  --sw-shadow-sm: 0 1px 2px rgba(16, 33, 27, 0.06);
  --sw-shadow: 0 8px 24px rgba(16, 33, 27, 0.08);
  --sw-shadow-lg: 0 16px 40px rgba(16, 33, 27, 0.12);
  --sw-sidebar-w: 264px;
  --sw-gradient: linear-gradient(135deg, #0f9d74 0%, #0ea5a3 100%);
}

[data-theme="dark"] {
  --sw-bg: #0f1613;
  --sw-surface: #161f1b;
  --sw-surface-2: #1c2622;
  --sw-border: #26332d;
  --sw-text: #eef4f1;
  --sw-text-muted: #93a39a;
  --sw-primary: #22c78f;
  --sw-primary-dark: #17a874;
  --sw-primary-light: #123a2c;
  --sw-danger-light: #3a1c1e;
  --sw-warning-light: #382c17;
  --sw-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sw-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sw-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  background: var(--sw-bg);
  color: var(--sw-text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: background-color .25s ease, color .25s ease;
  overflow-x: hidden;
}

a { text-decoration: none; }

::selection { background: var(--sw-primary-light); color: var(--sw-primary-dark); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--sw-border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   Utility surfaces
   ========================================================= */
.sw-card {
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
}
.sw-card:hover { box-shadow: var(--sw-shadow); }

.sw-card-flat {
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
}

.sw-gradient-text {
  background: var(--sw-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sw-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.sw-badge-income { background: var(--sw-primary-light); color: var(--sw-primary-dark); }
.sw-badge-expense { background: var(--sw-danger-light); color: var(--sw-danger); }
.sw-badge-warning { background: var(--sw-warning-light); color: var(--sw-warning); }

.sw-btn-primary {
  background: var(--sw-gradient);
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: var(--sw-radius-sm);
  padding: .55rem 1.2rem;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  box-shadow: 0 6px 16px rgba(15, 157, 116, 0.28);
}
.sw-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(15, 157, 116, 0.34); color: #fff; opacity: .96; }
.sw-btn-primary:active { transform: translateY(0); }

.sw-btn-outline {
  background: transparent;
  border: 1.5px solid var(--sw-border);
  color: var(--sw-text);
  font-weight: 600;
  border-radius: var(--sw-radius-sm);
  padding: .55rem 1.2rem;
  transition: all .15s ease;
}
.sw-btn-outline:hover { border-color: var(--sw-primary); color: var(--sw-primary-dark); background: var(--sw-primary-light); }

.sw-input {
  background: var(--sw-surface-2);
  border: 1.5px solid var(--sw-border);
  border-radius: var(--sw-radius-sm);
  color: var(--sw-text);
  padding: .6rem .9rem;
}
.sw-input:focus {
  background: var(--sw-surface);
  border-color: var(--sw-primary);
  box-shadow: 0 0 0 3px var(--sw-primary-light);
  color: var(--sw-text);
}
.sw-input::placeholder { color: var(--sw-text-muted); }

.sw-text-muted { color: var(--sw-text-muted); }

/* =========================================================
   App shell: sidebar + topbar
   ========================================================= */
.sw-app {
  display: flex;
  min-height: 100vh;
}

.sw-sidebar {
  width: var(--sw-sidebar-w);
  flex-shrink: 0;
  background: var(--sw-surface);
  border-right: 1px solid var(--sw-border);
  padding: 1.5rem 1.1rem;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1030;
  transition: transform .25s ease;
}

.sw-sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.25rem;
  padding: .4rem .5rem 1.4rem;
}
.sw-sidebar-brand .sw-logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--sw-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
  box-shadow: 0 6px 14px rgba(15,157,116,.35);
}

.sw-nav-link {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .68rem .85rem;
  border-radius: var(--sw-radius-sm);
  color: var(--sw-text-muted);
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: .2rem;
  transition: all .15s ease;
}
.sw-nav-link i { width: 20px; text-align: center; font-size: 1.02rem; }
.sw-nav-link:hover { background: var(--sw-surface-2); color: var(--sw-text); }
.sw-nav-link.active {
  background: var(--sw-primary-light);
  color: var(--sw-primary-dark);
}

.sw-main {
  margin-left: var(--sw-sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.75rem 3rem;
}

.sw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.sw-sidebar-toggle { display: none; }

@media (max-width: 991.98px) {
  .sw-sidebar { transform: translateX(-100%); }
  .sw-sidebar.show { transform: translateX(0); box-shadow: var(--sw-shadow-lg); }
  .sw-main { margin-left: 0; padding: 1.1rem 1rem 3rem; }
  .sw-sidebar-toggle { display: inline-flex; }
  .sw-sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1020;
  }
  .sw-sidebar-backdrop.show { display: block; }
}

/* =========================================================
   Stat cards
   ========================================================= */
.sw-stat-card {
  padding: 1.25rem 1.35rem;
  position: relative;
  overflow: hidden;
}
.sw-stat-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  margin-bottom: .9rem;
}
.sw-stat-value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.sw-stat-label { color: var(--sw-text-muted); font-size: .82rem; font-weight: 600; }
.sw-stat-delta { font-size: .78rem; font-weight: 700; }

/* =========================================================
   Landing page
   ========================================================= */
.sw-landing-navbar {
  background: var(--sw-surface);
  border-bottom: 1px solid var(--sw-border);
  position: sticky; top: 0; z-index: 1030;
}

.sw-hero {
  background: radial-gradient(circle at top right, var(--sw-primary-light), transparent 55%);
  padding: 5.5rem 0 4rem;
}
.sw-hero h1 { font-weight: 800; letter-spacing: -.03em; line-height: 1.08; }

.sw-blob-visual {
  background: var(--sw-gradient);
  border-radius: 32px;
  padding: 2.4rem;
  color: #fff;
  box-shadow: var(--sw-shadow-lg);
}

.sw-feature-card {
  padding: 1.6rem;
  height: 100%;
}
.sw-feature-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--sw-primary-light);
  color: var(--sw-primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.sw-step-num {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--sw-gradient);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}

.sw-auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sw-bg);
  padding: 2rem 1rem;
}
.sw-auth-card { max-width: 440px; width: 100%; padding: 2.2rem; }

/* =========================================================
   Tables
   ========================================================= */
.sw-table thead th {
  color: var(--sw-text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  border-bottom: 1px solid var(--sw-border);
  padding-bottom: .8rem;
}
.sw-table tbody td {
  padding: .85rem .5rem;
  border-bottom: 1px solid var(--sw-border);
  vertical-align: middle;
  color: var(--sw-text);
}
.sw-table tbody tr:last-child td { border-bottom: none; }
.sw-table tbody tr { transition: background .15s ease; }
.sw-table tbody tr:hover { background: var(--sw-surface-2); }

.sw-cat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--sw-surface-2);
  border: 1px solid var(--sw-border);
  padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
}

/* =========================================================
   Progress bars
   ========================================================= */
.sw-progress {
  height: 9px;
  border-radius: 999px;
  background: var(--sw-surface-2);
  overflow: hidden;
}
.sw-progress > div {
  height: 100%;
  border-radius: 999px;
  background: var(--sw-gradient);
  transition: width .5s ease;
}
.sw-progress.over > div { background: var(--sw-danger); }
.sw-progress.warn > div { background: var(--sw-warning); }

/* =========================================================
   Skeletons / loading
   ========================================================= */
.sw-skeleton {
  background: linear-gradient(90deg, var(--sw-surface-2) 25%, var(--sw-border) 37%, var(--sw-surface-2) 63%);
  background-size: 400% 100%;
  animation: sw-shimmer 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes sw-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.sw-spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--sw-border);
  border-top-color: var(--sw-primary);
  border-radius: 50%;
  animation: sw-spin .7s linear infinite;
}
@keyframes sw-spin { to { transform: rotate(360deg); } }

.sw-empty-state { padding: 3rem 1.5rem; text-align: center; color: var(--sw-text-muted); }
.sw-empty-state .sw-empty-icon { font-size: 2.6rem; margin-bottom: .75rem; }

/* =========================================================
   Toasts
   ========================================================= */
.sw-toast-container { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 2000; display: flex; flex-direction: column; gap: .6rem; }
.sw-toast {
  min-width: 280px; max-width: 340px;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-left: 4px solid var(--sw-primary);
  border-radius: var(--sw-radius-sm);
  box-shadow: var(--sw-shadow-lg);
  padding: .85rem 1rem;
  display: flex; gap: .7rem; align-items: flex-start;
  animation: sw-toast-in .25s ease;
  color: var(--sw-text);
}
.sw-toast.error { border-left-color: var(--sw-danger); }
.sw-toast.success { border-left-color: var(--sw-primary); }
.sw-toast.warning { border-left-color: var(--sw-warning); }
@keyframes sw-toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.sw-toast .btn-close { margin-left: auto; }

/* =========================================================
   Modals — restyle Bootstrap modal to match theme
   ========================================================= */
.modal-content {
  background: var(--sw-surface);
  color: var(--sw-text);
  border-radius: var(--sw-radius);
  border: 1px solid var(--sw-border);
}
.modal-header, .modal-footer { border-color: var(--sw-border); }
.btn-close { filter: var(--sw-btn-close-filter, none); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* =========================================================
   Misc
   ========================================================= */
.sw-theme-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--sw-border);
  background: var(--sw-surface-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--sw-text);
}

.sw-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--sw-gradient);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}

.sw-fade-in { animation: sw-fade .35s ease; }
@keyframes sw-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.sw-chart-wrap { position: relative; height: 280px; }
.sw-chart-wrap.sm { height: 220px; }

.form-label { font-weight: 600; font-size: .86rem; color: var(--sw-text); }
