/* ─── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --primary-subtle: #eef2ff;
  --gradient: linear-gradient(135deg, #22d3ee, #6366f1);
  --gradient-soft: linear-gradient(135deg, rgba(34,211,238,0.12), rgba(99,102,241,0.12));

  --bg: #f1f4f9;
  --bg-secondary: #e8ecf4;
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --info: #3b82f6;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --shadow: 0 1px 4px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.05);

  --sidebar-bg: #0c1220;
  --sidebar-w: 248px;
  --header-h: 64px;

  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --surface: #1a2030;
  --surface-hover: #212840;
  --border: #2d3748;
  --border-light: #1a2030;

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary-subtle: #1e1b4b;
  --success-bg: #064e3b;
  --danger-bg: #450a0a;
  --warning-bg: #451a03;

  --sidebar-bg: #070c14;

  --shadow: 0 1px 4px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button { cursor: pointer; font-family: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ─── Typography ─────────────────────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }

/* ─── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }

/* ─── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99,102,241,0.4); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { background: #fecaca; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1.0625rem;
  border-radius: var(--radius);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Form ───────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--danger);
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Badge ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-primary { background: var(--primary-subtle); color: var(--primary); }
.badge-gray { background: var(--bg-secondary); color: var(--text-secondary); }

/* ─── Progress Bar ────────────────────────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient);
  transition: width 0.5s ease;
}

.progress-fill.warning { background: var(--warning); }
.progress-fill.danger { background: var(--danger); }

/* ─── Alert ─────────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.alert-warning {
  background: var(--warning-bg);
  color: #92400e;
  border-left: 3px solid var(--warning);
}

[data-theme="dark"] .alert-warning { color: #fcd34d; }

.alert-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border-left: 3px solid var(--danger);
}

[data-theme="dark"] .alert-danger { color: #fca5a5; }

/* ─── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 6px;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--surface-hover); color: var(--text); }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

/* ─── Toast ─────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  animation: toastIn 0.25s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #fff; }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

/* ══════════════════════════════════════════════════════════════════════════════
   LANDING PAGE
══════════════════════════════════════════════════════════════════════════════ */

.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.landing-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.125rem;
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Hero */
.landing-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem;
  background: linear-gradient(135deg, var(--primary-subtle) 0%, var(--bg) 60%);
}

.landing-hero-content {
  max-width: 640px;
}

.landing-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  background: var(--primary-subtle);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.landing-hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.025em;
}

.landing-hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.landing-hero-btns {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Features */
.landing-features {
  padding: 5rem 2rem;
  background: var(--bg-secondary);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  max-width: 960px;
  margin: 2.5rem auto 0;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  margin-bottom: 1rem;
}

.feature-card h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.feature-card p { font-size: 0.9rem; color: var(--text-secondary); }

/* Pricing */
.landing-pricing {
  padding: 5rem 2rem;
  text-align: center;
}

.pricing-card {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 400px;
  margin: 2rem auto 0;
  box-shadow: var(--shadow-md);
}

.price-tag { font-size: 3rem; font-weight: 800; color: var(--primary); }
.price-tag span { font-size: 1rem; font-weight: 400; color: var(--text-secondary); }

.price-trial {
  font-size: 0.9rem;
  color: var(--success);
  font-weight: 600;
  margin: 0.5rem 0 1.5rem;
}

.price-features {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 2rem;
  font-size: 0.9375rem;
}

.price-features li::before { content: '✓ '; color: var(--success); font-weight: 700; }

/* Auth section */
.auth-section {
  padding: 4rem 2rem;
  background: var(--bg-secondary);
  display: flex;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.auth-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1.75rem;
}

.auth-tab {
  flex: 1;
  padding: 0.625rem;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Footer */
.landing-footer {
  background: var(--text);
  color: var(--bg);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.875rem;
  opacity: 0.85;
}

/* ══════════════════════════════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════════════════════════════ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.375rem 1.125rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  letter-spacing: -0.01em;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: 0.875rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.875rem;
  border-radius: 10px;
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: rgba(99,102,241,0.18);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 #6366f1;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  opacity: 0.85;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item.active .nav-icon { opacity: 1; }

/* Lucide icon sizing */
.nav-icon svg { width: 17px; height: 17px; stroke-width: 1.75; }
.stat-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }
.onboarding-card-icon svg { width: 28px; height: 28px; stroke-width: 1.5; }
.chat-welcome-icon svg { width: 40px; height: 40px; stroke-width: 1.25; }

.sidebar-footer {
  padding: 0.75rem 0.625rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
}

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

.user-details { flex: 1; min-width: 0; }
.user-email { font-size: 0.8rem; color: rgba(255,255,255,0.45); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-plan { font-size: 0.72rem; color: rgba(255,255,255,0.3); }

/* ─── Main ────────────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.125rem;
  transition: all var(--transition);
  cursor: pointer;
}

.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ─── Content area ────────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-header h2 { font-size: 1.375rem; }

/* ─── Dashboard ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient);
  opacity: 0.7;
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 0.875rem;
}

.stat-icon.income { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.05)); }
.stat-icon.expense { background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.05)); }
.stat-icon.balance { background: var(--gradient-soft); }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow);
}

.chart-card canvas { max-height: 220px; }

/* ─── Transactions ────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filters-bar .form-control {
  flex: 1;
  min-width: 140px;
  max-width: 200px;
}

.tx-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.tx-item:last-child { border-bottom: none; }
.tx-item:hover { background: var(--surface-hover); }

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.tx-icon.income { background: var(--success-bg); }
.tx-icon.expense { background: var(--primary-subtle); }

.tx-info { flex: 1; min-width: 0; }

.tx-category {
  font-weight: 600;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-amount {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}

.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

.tx-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: all var(--transition);
  cursor: pointer;
  opacity: 0;
}

.tx-item:hover .tx-delete { opacity: 1; }
.tx-delete:hover { color: var(--danger); background: var(--danger-bg); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h3 { margin-bottom: 0.5rem; color: var(--text); }

/* ─── Budget ──────────────────────────────────────────────────────────────────── */
.budget-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.budget-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
}

.budget-item.alert-active { border-color: var(--warning); }
.budget-item.danger-active { border-color: var(--danger); }

.budget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.budget-category {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
}

.budget-amounts {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.budget-amounts strong { color: var(--text); }

.budget-limit-input {
  width: 110px;
  padding: 0.375rem 0.625rem;
  font-size: 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: right;
}

.budget-limit-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ─── Goals ───────────────────────────────────────────────────────────────────── */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
}

.goal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.goal-name { font-size: 1.0625rem; font-weight: 700; }

.goal-target {
  text-align: right;
}

.goal-target-amount { font-size: 1.375rem; font-weight: 700; color: var(--primary); }
.goal-target-date { font-size: 0.8125rem; color: var(--text-secondary); }

.goal-progress-wrap { margin: 0.875rem 0; }

.goal-progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.goal-current { font-weight: 700; }
.goal-percent { color: var(--primary); font-weight: 700; }

.goal-suggestion {
  background: var(--primary-subtle);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--primary);
  margin-top: 0.875rem;
}

.goal-actions { display: flex; gap: 0.5rem; margin-top: 0.875rem; }

.goal-update-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ─── Reports ─────────────────────────────────────────────────────────────────── */
.report-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.compare-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.compare-card h4 { margin-bottom: 0.75rem; color: var(--text-secondary); font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }

.compare-diff {
  font-size: 1.5rem;
  font-weight: 700;
}

.compare-diff.better { color: var(--success); }
.compare-diff.worse { color: var(--danger); }

.top-categories {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.top-cat-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

.top-cat-item:last-child { border-bottom: none; }

.top-cat-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Paywall ─────────────────────────────────────────────────────────────────── */
.paywall-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.paywall-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.paywall-icon {
  width: 72px;
  height: 72px;
  background: var(--primary-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.25rem;
  margin: 0 auto 1.5rem;
}

.paywall-card h2 { margin-bottom: 0.75rem; }
.paywall-card p { color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.7; }

.paywall-price {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.paywall-price-note {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.paywall-features {
  list-style: none;
  text-align: left;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.paywall-features li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.9375rem;
}

.paywall-features li::before {
  content: '✓';
  color: var(--success);
  font-weight: 700;
  flex-shrink: 0;
}

.paywall-plan {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.875rem 0.75rem;
  cursor: pointer;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}
.paywall-plan:hover { border-color: var(--primary); }
.paywall-plan-active {
  border-color: var(--primary);
  background: rgba(99,102,241,0.07);
}
.paywall-plan-name { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.paywall-plan-price { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.paywall-plan-price span { font-size: 0.8rem; font-weight: 400; color: var(--text-secondary); }
.paywall-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ─── Sidebar overlay (mobile) ─────────────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ─── Mobile ──────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-backdrop { display: block; }

  .main-content { margin-left: 0; }

  .hamburger { display: flex; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: span 2; }

  .charts-grid { grid-template-columns: 1fr; }

  .report-stats { grid-template-columns: 1fr; }

  .compare-section { grid-template-columns: 1fr; }

  .form-row { grid-template-columns: 1fr; }

  .goals-grid { grid-template-columns: 1fr; }

  .content { padding: 1rem; }

  .filters-bar .form-control { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid .stat-card:last-child { grid-column: auto; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
}

/* ─── Loading ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
}

.loading-screen p { color: var(--text-secondary); }

/* ─── Subscription badge ──────────────────────────────────────────────────────── */
/* ─── Trial banner w headerze ─────────────────────────────────────────────── */
.trial-banner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.trial-days {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--warning);
  white-space: nowrap;
}

.btn-upgrade {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-weight: 600;
  border: none;
  white-space: nowrap;
}

.btn-upgrade:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

@media (max-width: 480px) {
  .trial-days { display: none; }
}

.trial-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Month picker row */
.month-picker-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.month-picker-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.month-picker-row .form-control { max-width: 180px; }

/* Section title divider */
.section-divider {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.5rem 0 0.75rem;
}

/* ─── Chat z AI ──────────────────────────────────────────────────────────────── */

.chat-limit-badge {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
}

.chat-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: calc(100vh - 200px);
  min-height: 480px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 100%;
  text-align: center;
  color: var(--text-secondary);
}

.chat-welcome-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.chat-welcome h3 {
  color: var(--text);
  margin: 0;
}

.chat-welcome p {
  font-size: 0.9375rem;
  max-width: 320px;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 0.25rem;
}

.chat-bubble.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-bubble.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.chat-bubble-text {
  padding: 0.625rem 0.875rem;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.user .chat-bubble-text {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant .chat-bubble-text {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.assistant.loading .chat-bubble-text {
  color: var(--text-muted);
  font-style: italic;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chat-suggestion-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.chat-suggestion-btn:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-light);
  color: var(--primary);
}

.chat-input-area {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.5;
  transition: border-color var(--transition);
  min-height: 52px;
}

.chat-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.chat-send-btn {
  white-space: nowrap;
  align-self: flex-end;
  height: 44px;
  padding: 0 1.25rem;
}

@media (max-width: 640px) {
  .chat-container {
    height: calc(100vh - 240px);
  }

  .chat-bubble {
    max-width: 92%;
  }

  .chat-suggestions {
    gap: 0.375rem;
  }

  .chat-suggestion-btn {
    font-size: 0.8125rem;
    padding: 0.3rem 0.625rem;
  }
}

/* ─── Section header actions ─────────────────────────────────────────────────── */

.section-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ─── Transaction edit button ────────────────────────────────────────────────── */

.tx-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
  flex-shrink: 0;
}

.tx-edit:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}

/* ─── Onboarding ─────────────────────────────────────────────────────────────── */

.onboarding-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 600px) {
  .onboarding-cards { grid-template-columns: 1fr; }
}

.onboarding-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition), background var(--transition), transform 0.15s;
}

.onboarding-card:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
  transform: translateY(-2px);
}

.onboarding-card-icon { font-size: 2rem; }

.onboarding-card-title {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9375rem;
}

.onboarding-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Category tags ──────────────────────────────────────────────────────────── */

.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.category-tag {
  display: inline-block;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ── Import CSV ─────────────────────────────────────────────────────────────── */

.import-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  background: var(--bg-secondary);
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.import-upload-area.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-secondary));
}
.import-upload-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.import-upload-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.375rem; }
.import-upload-desc { color: var(--text-secondary); font-size: 0.875rem; margin-bottom: 1.25rem; }

.import-processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 0;
  color: var(--text-secondary);
}

.import-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.import-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.import-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.import-tab-count {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  min-width: 1.5rem;
  text-align: center;
}
.import-tab.active .import-tab-count {
  background: color-mix(in srgb, var(--primary) 15%, var(--bg));
  color: var(--primary);
}

.import-item {
  display: grid;
  grid-template-columns: 6rem 1fr auto 10rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.import-item:last-child { border-bottom: none; }
.import-item-date { color: var(--text-secondary); font-size: 0.875rem; white-space: nowrap; }
.import-item-desc {
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-item-amount {
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.import-item-amount.expense { color: var(--danger); }
.import-item-amount.income { color: var(--success); }
.import-item-category select { font-size: 0.875rem; padding: 0.35rem 0.5rem; }
.import-item-confidence { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; grid-column: 1 / -1; padding-top: 0; padding-bottom: 0.25rem; margin-top: -0.5rem; }

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .import-item {
    grid-template-columns: 5rem 1fr auto;
    grid-template-rows: auto auto;
  }
  .import-item-category { grid-column: 1 / -1; }
}
