/* ============================================
   shadcn-like Design System for FinanceApp
   Pure CSS — no React/Next.js dependency
   ============================================ */

/* ---------- CSS Variables (shadcn-inspired) ---------- */
:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --success: #22c55e;
  --success-foreground: #fafafa;
  --warning: #f59e0b;
  --warning-foreground: #fafafa;
  --info: #3b82f6;
  --info-foreground: #fafafa;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #18181b;
  --radius: 0.5rem;

  --sidebar-bg: #fafafa;
  --sidebar-width: 240px;
  --header-height: 56px;
}

/* ---------- Base ---------- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--muted);
  color: var(--foreground);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

body.auth-body {
  background-color: var(--muted);
  overflow-x: hidden;
}

.content-auth {
  padding: 0 !important;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

body.auth-body .app-layout,
body.auth-body .main-content {
  min-height: 100vh;
  overflow-x: hidden;
}

/* Inter font fallback using system fonts */
@supports (font-variation-settings: normal) {
  body { font-family: 'InterVariable', 'Inter', -apple-system, sans-serif; }
}

/* ---------- Layout ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ---------- Sidebar (shadcn-inspired) ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.sidebar-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.sidebar-link.active i {
  color: var(--primary-foreground);
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ---------- Main Content Area ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

/* Auth pages: no sidebar → no left margin, full centering */
body.auth-body .main-content {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
}

/* ---------- Top Header Bar ---------- */
.top-header {
  height: var(--header-height);
  background: var(--background);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.top-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--foreground);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius);
}

.mobile-menu-btn:hover {
  background: var(--accent);
}

.page-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
}

.page-title-icon {
  font-size: 1.125rem;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.page-title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.75rem;
}

/* ---------- Content Container ---------- */
.content-area {
  padding: 1.5rem;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: hidden;
}

/* ---------- shadcn Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  overflow: hidden;
  min-width: 0;
}

.card-hover:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

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

.card-header h5,
.card-header h6 {
  margin: 0;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--muted);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Stat Cards (Dashboard) ---------- */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-card .stat-trend {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Stat card variants */
.stat-income .stat-icon {
  background: #dcfce7;
  color: #15803d;
}

.stat-income .stat-value {
  color: #15803d;
}

.stat-expense .stat-icon {
  background: #fee2e2;
  color: #dc2626;
}

.stat-expense .stat-value {
  color: #dc2626;
}

.stat-balance .stat-icon {
  background: #dbeafe;
  color: #2563eb;
}

.stat-balance .stat-value {
  color: var(--foreground);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: #27272a;
  border-color: #27272a;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #e4e4e7;
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--foreground);
}

.btn-danger {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
  height: 32px;
}

.btn-lg {
  padding: 0.625rem 1.5rem;
  font-size: 1rem;
  height: 44px;
}

.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- Badges / Tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  border: 1px solid transparent;
}

.badge-income {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.badge-expense {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.badge-default {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.badge-outline {
  background: transparent;
  color: var(--muted-foreground);
  border-color: var(--border);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--muted-foreground);
}

.form-select {
  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='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* ---------- shadcn Table ---------- */
.table-container {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: var(--muted);
}

table th {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody tr:hover {
  background: var(--muted);
}

table .amount-positive {
  color: #15803d;
  font-weight: 600;
}

table .amount-negative {
  color: #dc2626;
  font-weight: 600;
}

.table-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted-foreground);
}

.table-empty i {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

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

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

/* ---------- Modal (shadcn style) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.modal-overlay.show {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 480px;
  margin: 1rem;
  transform: scale(0.95);
  transition: transform 0.15s ease;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 1.125rem;
}

.modal-close:hover {
  background: var(--accent);
  color: var(--foreground);
}

.modal-body {
  padding: 1.25rem;
}

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


/* ---------- Auth Pages ---------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--muted);
  padding: 1.5rem;
  box-sizing: border-box;
  overflow-x: hidden;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
}

.auth-card .card-body {
  padding: 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin-bottom: 1.5rem;
}

.auth-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}

.auth-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-title {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.auth-subtitle {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin: 0 0 1.5rem 0;
}

.auth-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.auth-footer a {
  color: var(--foreground);
  font-weight: 500;
  text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Demo Account Section */
.demo-account-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.875rem;
    background: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.demo-account-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.demo-account-label i {
    font-size: 0.875rem;
}

.demo-account-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-family: monospace;
    font-weight: 600;
    color: var(--primary);
    background: var(--background);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.demo-username,
.demo-password {
    color: var(--foreground);
}

.demo-password-divider {
    color: var(--muted-foreground);
}

.demo-fill-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
    align-self: flex-end;
}

.demo-fill-btn:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* ---------- Chart Container ---------- */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
  overflow: hidden;
  min-width: 0;
}

.chart-container canvas {
  max-width: 100% !important;
}

/* Full width chart for Monthly Income vs Expense */
.full-width-chart {
  grid-column: span 2;
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--muted-foreground);
  opacity: 0.4;
  margin-bottom: 1rem;
}

.empty-state h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
}

.empty-state p {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin: 0 0 1rem 0;
}

/* ---------- Action buttons row ---------- */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.action-bar h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.action-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---------- Spacing Utilities ---------- */
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }

/* ---------- Flex Utilities ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ---------- Text Utilities ---------- */
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--muted-foreground); }
.text-success { color: #15803d; }
.text-danger { color: #dc2626; }
.text-center { text-align: center; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Miscellaneous ---------- */
a {
  color: var(--foreground);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ---------- Techy Filter Pill + Popover ---------- */

/* Wrapper — holds button + popover */
.filter-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

/* Pill Button */
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0.5rem 0.875rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 9999px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    user-select: none;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--ring);
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    background: var(--accent);
}

.filter-pill:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.filter-pill i {
    font-size: 0.875rem;
}

.filter-pill .filter-chevron {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    transition: transform 0.2s ease;
}

.filter-pill.open .filter-chevron {
    transform: rotate(180deg);
}

/* Badge — active filter count */
.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 9999px;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
}

/* Popover Dropdown */
.filter-popover {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 380px;
    max-width: 480px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    z-index: 45;
    animation: popoverIn 0.15s ease-out;
}

@keyframes popoverIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.filter-popover-title {
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--foreground);
}

.filter-popover-title i {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.filter-popover-close {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 1.125rem;
    transition: all 0.15s ease;
}

.filter-popover-close:hover {
    background: var(--accent);
    color: var(--foreground);
}

.filter-popover-body {
    padding: 0.75rem 1rem;
}

/* Chip list inside popover */
.filter-popover-body .chip-list {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chip-placeholder {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    padding: 0.125rem 0;
    user-select: none;
    opacity: 0.6;
}

/* Chip Tag */
.chip-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    animation: chipIn 0.2s ease-out;
    cursor: default;
}

.chip-tag-label {
    cursor: pointer;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-tag-label:hover {
    opacity: 0.85;
}

.chip-tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary-foreground);
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.chip-tag-remove:hover {
    background: rgba(255, 255, 255, 0.45);
}

@keyframes chipIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* Add filter pill inside popover */
.filter-add-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    margin-top: 0.625rem;
    border: 1.5px dashed var(--border);
    border-radius: 9999px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.filter-add-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--accent);
}

/* Autocomplete inside popover body */
.filter-popover-body .chip-autocomplete {
    position: static;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    margin-top: 0.625rem;
    overflow: hidden;
    animation: dropdownIn 0.15s ease-out;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.autocomplete-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.autocomplete-search i {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.autocomplete-search input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.8125rem;
    color: var(--foreground);
    width: 100%;
}

.autocomplete-search input::placeholder {
    color: var(--muted-foreground);
}

.autocomplete-list {
    max-height: 240px;
    overflow-y: auto;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    transition: background 0.1s ease;
}

.autocomplete-item:hover {
    background: var(--accent);
}

.autocomplete-item i {
    font-size: 1rem;
    color: var(--muted-foreground);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.autocomplete-item-title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
}

.autocomplete-item-desc {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    margin-top: 1px;
}

.autocomplete-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* Value Panel inside popover */
.filter-popover-body .chip-value-panel {
    margin-top: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    animation: dropdownIn 0.15s ease-out;
}

.value-panel-inner {
    padding: 0;
}

.value-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
    background: var(--muted);
}

.value-panel-title {
    font-size: 0.8125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--foreground);
}

.value-panel-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: none;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 1rem;
}

.value-panel-close:hover {
    background: var(--border);
    color: var(--foreground);
}

.value-panel-body {
    padding: 0.875rem;
}

.value-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.value-row:last-child {
    margin-bottom: 0;
}

.value-row label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    min-width: 50px;
    flex-shrink: 0;
}

.value-row input,
.value-row select {
    flex: 1;
    padding: 0.4375rem 0.625rem;
    font-size: 0.8125rem;
    border: 1px solid var(--input);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    outline: none;
    transition: border-color 0.15s ease;
}

.value-row input:focus,
.value-row select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.08);
}

.value-row .search-input-wrapper {
    flex: 1;
    position: relative;
}

.value-row .search-input-wrapper .search-icon {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    pointer-events: none;
}

.value-row .search-input-wrapper .form-input {
    padding-left: 2rem;
    width: 100%;
    box-sizing: border-box;
    padding-top: 0.4375rem;
    padding-bottom: 0.4375rem;
    font-size: 0.8125rem;
}

.value-presets {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.preset-btn {
    padding: 0.25rem 0.625rem !important;
    font-size: 0.75rem !important;
}

.value-panel-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border-top: 1px solid var(--border);
    background: var(--muted);
}

/* Popover footer — Apply / Clear */
.filter-popover-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--muted);
}

/* ---------- Auth Pages Responsive ---------- */
@media (max-width: 480px) {
  .auth-page {
    padding: 1rem;
  }
  
  .auth-card .card-body {
    padding: 1.5rem;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

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

  .mobile-menu-btn {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .full-width-chart {
    grid-column: span 1;
  }

  .filter-popover {
    min-width: 320px;
  }
  
  /* Adjust top header for mobile */
  .top-header {
    padding: 0 1rem;
  }
  
  .page-title {
    font-size: 1rem;
  }
  
  .user-badge .hidden-mobile {
    display: none;
  }
  
  .chart-container {
    height: 240px;
  }
}

@media (max-width: 640px) {
  /* General mobile styles */
  body {
    font-size: 14px;
  }
  
  .content-area {
    padding: 1rem;
  }
  
  .auth-page {
    padding: 0.75rem;
  }
  
  /* Top header mobile adjustments */
  .top-header {
    height: 48px;
    padding: 0 0.75rem;
  }
  
  .page-title-group {
    flex: 1;
    min-width: 0;
  }

  .page-title {
    font-size: 0.9rem;
  }

  .page-title-icon {
    font-size: 1rem;
  }
  
  /* Stats grid mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  
  .stat-card .stat-value {
    font-size: 1.125rem;
  }
  
  .stat-card .stat-label {
    font-size: 0.6875rem;
  }
  
  .stat-card .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    margin-bottom: 0.375rem;
  }
  
  /* Charts grid mobile */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .full-width-chart {
    grid-column: span 1;
  }
  
  .chart-container {
    height: 200px;
  }
  
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .card-header h5 {
    font-size: 0.875rem;
  }
  
  /* Table mobile responsiveness */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table th, table td {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
  
  table th {
    white-space: nowrap;
  }
  
  /* Action bar mobile */
  .action-bar {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .action-bar h2 {
    font-size: 1.125rem;
  }
  
  .action-bar-actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }
  
  .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    flex: 1;
    min-width: 100px;
  }
  
  /* Pagination mobile */
  .pagination-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .pagination-info {
    text-align: center;
    margin-bottom: 0.75rem;
  }
  
  .pagination-controls {
    justify-content: center;
  }
  
  .pagination-btn {
    min-width: 2rem;
    height: 1.75rem;
    font-size: 0.75rem;
    padding: 0 0.375rem;
  }
  
  /* Modal mobile */
  .modal-content {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
  }
  
  .form-input, .form-select {
    padding: 0.375rem 0.5rem;
    font-size: 0.8125rem;
  }
  
  /* Filter mobile styles */
  .filter-wrapper {
    width: 100%;
    margin-bottom: 0.75rem;
  }
  
  .filter-popover {
    position: fixed;
    top: auto;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    min-width: auto;
    max-width: none;
    border-radius: calc(var(--radius) + 2px);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  }

  .filter-popover-body {
    overflow-y: auto;
    flex: 1;
  }

  .chip-tag-label {
    max-width: 120px;
  }

  .value-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
  }

  .value-row label {
    min-width: auto;
  }

  .filter-popover-footer {
    flex-direction: column-reverse;
  }

  .filter-popover-footer .btn {
    width: 100%;
  }
  
  /* Auth page mobile */
  .auth-card .card-body {
    padding: 1.25rem;
  }
  
  .auth-logo-icon {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }
  
  .auth-logo-text {
    font-size: 1.125rem;
  }
  
  .auth-title {
    font-size: 1rem;
  }
  
  .auth-subtitle {
    font-size: 0.75rem;
    margin-bottom: 1.25rem;
  }
  
  .demo-account-info {
    margin-bottom: 1.25rem;
    padding: 0.75rem;
  }
  
  .demo-account-details {
    font-size: 0.75rem;
    padding: 0.375rem 0.5rem;
  }
  
  .demo-fill-btn {
    font-size: 0.625rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Very small screens (phones ≤ 400px) */
@media (max-width: 400px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .content-area {
    padding: 0.75rem;
  }
  
  .top-header {
    padding: 0 0.5rem;
  }
  
  .page-title {
    font-size: 0.8rem;
  }
  
  .chart-container {
    height: 180px;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  .card-header {
    padding: 0.625rem 0.75rem;
  }
  
  .action-bar h2 {
    font-size: 1rem;
  }
  
  table th, table td {
    padding: 0.375rem;
    font-size: 0.6875rem;
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

/* ---------- Sidebar overlay (mobile) ---------- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 35;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.sidebar-overlay.show {
  visibility: visible;
  opacity: 1;
}

/* ---------- Chart header fix ---------- */
.card-header-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

/* ---------- Toast Notification ---------- */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  max-width: 420px;
}

@media (max-width: 640px) {
  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: 0.75rem;
    max-width: none;
  }
  
  .toast {
    max-width: none;
    min-width: auto;
  }
}

/* ---------- Alert Styles ---------- */
.alert {
  padding: 0.875rem 1.125rem;
  border-radius: calc(var(--radius) + 2px);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  animation: toastIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  max-width: 380px;
  min-width: 280px;
}

.toast.toast-success {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.toast.toast-error {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.toast i {
  font-size: 1.25rem;
  flex-shrink: 0;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) translateY(-10px) scale(0.9);
  }
}

/* ---------- Pagination ---------- */
.pagination-container {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  min-width: 200px;
}

.pagination-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.pagination-btn {
  min-width: 2.5rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  border-radius: calc(var(--radius) - 2px);
  transition: all 0.2s;
  text-decoration: none;
}

.pagination-btn:hover:not(.disabled) {
  background: var(--accent);
}

.pagination-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 500;
}

.pagination-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Transactions table (mobile) ---------- */
.transactions-card {
  overflow: visible;
}

.category-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.transactions-table .date-short,
.transactions-table .th-short {
  display: none;
}

.transactions-table .note-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.transactions-table .txn-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .transactions-table-wrap.table-container {
    overflow-x: visible;
  }

  .transactions-table {
    table-layout: fixed;
    width: 100%;
  }

  .transactions-table .col-type {
    display: none;
  }

  .transactions-table .th-long {
    display: none;
  }

  .transactions-table .th-short {
    display: inline;
  }

  .transactions-table .date-full {
    display: none;
  }

  .transactions-table .date-short {
    display: inline;
  }

  .transactions-table .category-name {
    display: none;
  }

  .transactions-table .category-cell {
    justify-content: center;
    gap: 0;
  }

  .transactions-table .category-icon {
    font-size: 1.125rem;
  }

  .transactions-table th,
  .transactions-table td {
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
    vertical-align: middle;
  }

  .transactions-table thead th {
    font-size: 0.625rem;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .transactions-table .col-date {
    width: 14%;
  }

  .transactions-table .col-category {
    width: 10%;
    text-align: center;
  }

  .transactions-table .col-note {
    width: 28%;
    overflow: hidden;
  }

  .transactions-table .col-amount {
    width: 22%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .transactions-table .col-actions {
    width: 4.75rem;
    min-width: 4.75rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
  }

  .transactions-table .txn-actions .btn {
    padding: 0.25rem;
    min-width: unset;
    flex: none;
  }

  .transactions-table .txn-actions .btn i {
    font-size: 0.875rem;
  }
}

/* Badge for "All transactions" */
.badge-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 0.25rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 0.5rem;
  display: inline-flex;
  align-items: center;
}
