/* Global Font Import - Unified Source */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:wght@300;400;500&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

body {
  /* Main body font - DM Sans */
  font-family:
    "DM Sans",
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
  background-color: #faf9f6; /* Warm Parchment Background */
}

/* Global Card Refinements */
.card {
  box-shadow: none !important;
  border: 0.1px solid var(--bs-border-color-translucent) !important;
}

.glass-card {
  background: rgba(255, 255, 255, 0.7) !important;
  backdrop-filter: blur(10px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(10px) saturate(180%) !important;
  border: 1px solid rgba(209, 213, 219, 0.3) !important;
}

[data-bs-theme="dark"] .glass-card {
  background: rgba(30, 30, 30, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.card > .card-header:first-child {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fab-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(29, 158, 117, 0.4);
  }
  70% {
    transform: scale(1.04);
    box-shadow: 0 0 0 12px rgba(29, 158, 117, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(29, 158, 117, 0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

/* Utility Classes */
.hover-lift {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Icon refinement */
.bi {
  vertical-align: -0.125em;
}

/* Icon Shapes for dashboard/analytics */
.icon-shape {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.icon-shape-sm {
  width: 48px;
  height: 48px;
}

.icon-shape-md {
  width: 64px;
  height: 64px;
}

.icon-shape-lg {
  width: 80px;
  height: 80px;
}

/* --- Global Dashboard Theme Overrides --- */

:root {
  --color-primary: #1a1a18; /* Warm Ink Black */
  --color-secondary: #1D9E75; /* Forest Green */
  --color-success: #1D9E75; /* Forest Green */
  --color-danger: #E05C45; /* Warm Danger Red */
  --color-warning: #D4831A; /* Warm Amber */
  --bg-color: #faf9f6; /* Warm Parchment */
  --surface-color: #ffffff;
  --text-main: #1a1a18; /* Warm Ink Black */
  --color-accent: #1D9E75;
  --color-accent2: #D4831A;
  --border-color: rgba(26,26,24,0.1);
  --paper: #faf9f6;
  --paper2: #f2f0eb;
  --paper3: #e8e5de;
  --ink: #1a1a18;
  --ink2: #4a4a46;
  --ink3: #8a8a84;

  /* Override Bootstrap info color (default cyan is too bright) */
  --bs-info: #3d7a8a;
  --bs-info-rgb: 61, 122, 138;

  /* Override Bootstrap primary (default blue → Forest Green) */
  --bs-primary: #1D9E75;
  --bs-primary-rgb: 29, 158, 117;
  --bs-primary-bg-subtle: rgba(29, 158, 117, 0.1);
  --bs-primary-border-subtle: rgba(29, 158, 117, 0.2);
  --bs-primary-text-emphasis: #085041;

  /* Override Bootstrap danger (default red → Warm Red) */
  --bs-danger: #E05C45;
  --bs-danger-rgb: 192, 57, 43;

  /* Override Bootstrap success */
  --bs-success: #1D9E75;
  --bs-success-rgb: 29, 158, 117;

  /* Override Bootstrap warning */
  --bs-warning: #D4831A;
  --bs-warning-rgb: 224, 123, 57;
}

/* Override Bootstrap form check/switch colors */
.form-check-input:checked {
  background-color: #1D9E75;
  border-color: #1D9E75;
}

.text-teal {
  color: #1D9E75 !important;
}

.text-coral {
  color: #E05C45 !important;
}

.text-amber {
  color: #D4831A !important;
}

/* Payment Method Badges */
.payment-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: capitalize;
}

.pay-cash { background-color: rgba(29, 158, 117, 0.1); color: #1D9E75; }
.pay-credit-card { background-color: rgba(55, 138, 221, 0.1); color: #378ADD; }
.pay-debit-card { background-color: rgba(133, 183, 235, 0.15); color: #378ADD; }
.pay-upi { background-color: rgba(212, 131, 26, 0.1); color: #D4831A; }
.pay-netbanking { background-color: rgba(93, 202, 165, 0.15); color: #1D9E75; }

[data-bs-theme="dark"] .pay-cash { background-color: rgba(29, 158, 117, 0.2); color: #9FE1CB; }
[data-bs-theme="dark"] .pay-credit-card { background-color: rgba(55, 138, 221, 0.2); color: #85B7EB; }
[data-bs-theme="dark"] .pay-debit-card { background-color: rgba(133, 183, 235, 0.25); color: #85B7EB; }
[data-bs-theme="dark"] .pay-upi { background-color: rgba(212, 131, 26, 0.2); color: #F4B44E; }
[data-bs-theme="dark"] .pay-netbanking { background-color: rgba(93, 202, 165, 0.25); color: #9FE1CB; }

/* Dashboard Soft Badges */
.badge-soft {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 50rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  transition: all 0.2s ease;
}

.badge-soft-primary {
  background-color: rgba(29, 158, 117, 0.08);
  color: #1D9E75;
}

[data-bs-theme="dark"] .badge-soft-primary {
  background-color: rgba(29, 158, 117, 0.15);
  color: #9FE1CB;
}

.badge-soft-secondary {
  background-color: rgba(158, 157, 154, 0.1);
  color: #9E9D9A;
}

[data-bs-theme="dark"] .badge-soft-secondary {
  background-color: rgba(255, 255, 255, 0.08);
  color: #adb5bd;
}

.form-check-input:focus {
  border-color: #1D9E75;
  box-shadow: 0 0 0 0.25rem rgba(29, 158, 117, 0.25);
}

/* Override Bootstrap button component colors globally */
.btn-primary {
  --bs-btn-bg: #1D9E75;
  --bs-btn-border-color: #1D9E75;
  --bs-btn-hover-bg: #0F6E56;
  --bs-btn-hover-border-color: #0F6E56;
  --bs-btn-active-bg: #085041;
  --bs-btn-active-border-color: #085041;
  --bs-btn-disabled-bg: #1D9E75;
  --bs-btn-disabled-border-color: #1D9E75;
}
.btn-outline-primary {
  --bs-btn-color: #1D9E75;
  --bs-btn-border-color: #1D9E75;
  --bs-btn-hover-bg: #1D9E75;
  --bs-btn-hover-border-color: #1D9E75;
  --bs-btn-active-bg: #1D9E75;
  --bs-btn-active-border-color: #1D9E75;
  --bs-btn-disabled-color: #1D9E75;
  --bs-btn-disabled-border-color: #1D9E75;
}
.btn-outline-danger {
  --bs-btn-color: #E05C45;
  --bs-btn-border-color: #E05C45;
  --bs-btn-hover-bg: #E05C45;
  --bs-btn-hover-border-color: #E05C45;
  --bs-btn-active-bg: #A63C28;
  --bs-btn-active-border-color: #A63C28;
  --bs-btn-disabled-color: #E05C45;
  --bs-btn-disabled-border-color: #E05C45;
}
.btn-outline-success {
  --bs-btn-color: #1D9E75;
  --bs-btn-border-color: #1D9E75;
  --bs-btn-hover-bg: #1D9E75;
  --bs-btn-hover-border-color: #1D9E75;
  --bs-btn-active-bg: #0F6E56;
  --bs-btn-active-border-color: #0F6E56;
}

[data-bs-theme="dark"] {
  --color-primary: #3d8b6a; /* Lighter Forest Green for Dark Mode */
  --color-background: #111315; /* Landing Page BG */
  --color-surface: #1a1d21; /* Landing Page Surface */
  --color-text: #faf9f6;
  --bg-color: #111315;
  --surface-color: #1a1d21;
  
  /* Semantic Colors for Dark Mode Contrast */
  --color-success: #5DCAA5;
  --color-danger: #F49C8C;
  --color-warning: #F4B44E;
  --bs-success-rgb: 93, 202, 165;
  --bs-danger-rgb: 244, 156, 140;
  --bs-warning-rgb: 244, 180, 78;
}

body {
  font-family:
    "DM Sans",
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

[data-bs-theme="dark"] body {
  background-color: var(--color-background) !important;
  color: var(--color-text) !important;
}

/* Navbar Unification */
/* Navbar & Footer Unification */
[data-bs-theme="dark"] .navbar,
[data-bs-theme="dark"] footer {
  background-color: rgba(17, 19, 21, 0.9) !important;
  backdrop-filter: blur(10px);
  border-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .navbar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  background-color: rgba(17, 19, 21, 0.8) !important;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
}

[data-bs-theme="dark"] footer {
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .card {
  background-color: var(--color-surface);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* PWA Install Banner Dark Mode */
[data-bs-theme="dark"] #installAppContainer {
  background-color: var(--color-surface) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Navbar */
.bg-custom-dark {
  background-color: var(--color-primary) !important;
}

/* Primary Button */
.btn-primary {
  background-color: #1D9E75;
  border: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  color: #fff;
}
.btn-primary:hover,
.btn-primary:active,
.btn-primary:focus {
  background-color: #0F6E56;
  box-shadow: 0 4px 12px rgba(29, 158, 117, 0.25);
}

/* Success Button (Forest Green) */
.btn-success {
  background-color: #1D9E75;
  border: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  color: #fff;
}
.btn-success:hover,
.btn-success:active,
.btn-success:focus {
  background-color: #0F6E56;
  box-shadow: 0 4px 12px rgba(29, 158, 117, 0.25);
}

/* Danger Button (Warm Red) */
.btn-danger {
  background-color: var(--color-danger);
  border: 1px solid var(--color-danger);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
}
.btn-danger:hover,
.btn-danger:active,
.btn-danger:focus {
  background-color: #A63C28;
  border-color: #962c1b;
  color: #fff;
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--color-success);
}

/* Outline Buttons (for secondary actions) */
.btn-outline-primary {
  color: var(--color-success);
  border-color: var(--color-success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
}
.btn-outline-primary:hover,
.btn-outline-primary:active {
  background-color: #1D9E75 !important;
  border: 1px solid #1D9E75 !important;
  color: #fff !important;
}

.btn-outline-secondary {
  color: var(--color-primary);
  border-color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
}
.btn-outline-secondary:hover,
.btn-outline-secondary:active {
  background-color: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: #fff !important;
}

/* Specific Link Overrides */
.btn-link {
  color: var(--color-success); /* Forest Green for actions */
  text-decoration: none;
}
.btn-link:hover {
  color: #04342C;
}

/* Navbar Links */
.nav-link {
  color: var(--color-primary);
  height: 38px !important; /* Force standard height */
  font-weight: 400; /* Regular weight */
  font-size: 1rem; /* Consistent size */
}
.nav-link:hover,
.nav-link.active {
  color: var(--color-success) !important;
  font-weight: 500; /* Slightly heavier for active state */
}

/* Pagination */
.page-link {
  color: var(--color-primary);
}
.page-link:hover {
  color: var(--color-success);
  background-color: #faf9f6;
  border-color: #e8e5de;
}
.page-item.active .page-link {
  background-color: var(--color-success); /* Forest Green selected page */
  border-color: var(--color-success);
  color: #fff;
}

/* Sidebar / List Group Active State */
.list-group-item.active {
  background-color: var(--color-success); /* Forest Green */
  border-color: var(--color-success);
}

/* Text Colors */
.text-primary {
  color: var(--color-success) !important; /* Forest Green to match Primary Buttons */
}
.text-secondary {
  color: var(--color-primary) !important; /* Warm Ink Black for secondary text */
}
.text-success {
  color: var(--color-success) !important;
}
.text-danger {
  color: var(--color-danger) !important;
}
.text-warning {
  color: var(--color-warning) !important;
}
 
/* Override Bootstrap Dropdown Active State */
.dropdown-item.active, 
.dropdown-item:active {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
}

.dropdown-item:focus{
    background-color: var(--bs-primary-bg-subtle);
    color: #fff !important;
}

.dropdown-item:hover {
    background-color: var(--bs-primary-bg-subtle);
    color: var(--bs-primary-text-emphasis);
}

/* Accent Text Utility */
.text-gradient-primary {
  color: #1D9E75 !important;
  -webkit-text-fill-color: #1D9E75 !important;
  display: inline-block;
}

/* Dark Mode Overrides */
[data-bs-theme="dark"] .nav-link {
  color: #ffffff; /* White for dark mode */
}
[data-bs-theme="dark"] .nav-link:hover,
[data-bs-theme="dark"] .nav-link.active {
  color: var(--color-success) !important; /* Forest Green for hover/active */
}

/* Small Buttons height override */
.btn-sm {
  height: 31px !important;
  padding-top: 0;
  padding-bottom: 0;
}

/* Donation Button Styling */
.donation-btn {
  background-color: rgba(224, 123, 57, 0.1);
  border: 1px solid rgba(224, 123, 57, 0.3);
  color: var(--color-warning) !important;
  font-weight: 600 !important;
  transition: all 0.3s ease;
}

.donation-btn:hover {
  background-color: rgba(224, 123, 57, 0.18);
  border-color: var(--color-warning);
  transform: scale(1.05);
}

[data-bs-theme="dark"] .donation-btn {
  background-color: rgba(224, 123, 57, 0.18);
}

/* Fix for gray background behind inputs in Expense Form (Dark Mode) */
[data-bs-theme="dark"] #formset-table,
[data-bs-theme="dark"] #formset-table th,
[data-bs-theme="dark"] #formset-table td {
  background-color: transparent !important;
  --bs-table-bg: transparent !important;
  color: var(--color-text); /* Ensure text remains visible */
}

/* Ensure table borders don't look weird if they exist (though it is table-borderless) */
[data-bs-theme="dark"] #formset-table th {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1); /* Subtle separator for header */
}

/* --- Mobile Responsive Formset Table --- */
@media (max-width: 768px) {
  #formset-table thead {
    display: none;
  }

  #formset-table tbody,
  #formset-table tr,
  #formset-table td {
    display: block;
    width: 100%;
  }

  #formset-table tr {
    margin-bottom: 1.5rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    background-color: rgba(var(--bs-body-bg-rgb), 0.5); /* Slight separation */
    position: relative;
  }

  #formset-table td {
    padding: 0.5rem 0;
    border: none;
  }

  /* Add labels visually for context if needed, but placeholders help. 
       Let's ensure the delete button is well positioned. */
  #formset-table td:last-child {
    text-align: right;
    margin-top: 0.5rem;
    border-top: 1px dashed var(--bs-border-color);
    padding-top: 0.75rem;
  }

  /* Make the remove button look more like a distinct action on mobile */
  .remove-row,
  .delete-row {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
  }
}
/* --- Driver.js Tutorial Theme Customization --- */

/* Default (Light Mode) */
.driver-popover {
  background-color: var(--surface-color) !important;
  color: var(--text-main) !important;
  border-radius: 12px !important;
  padding: 15px !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.driver-popover-title {
  font-family: "DM Sans", sans-serif !important;
  font-weight: 600 !important;
  font-size: 1.1rem !important;
  margin-bottom: 8px !important;
  color: var(--color-primary) !important;
}

.driver-popover-description {
  font-family: "Inter", sans-serif !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  color: #495057 !important;
  margin-bottom: 0 !important;
}

/* Tutorial Buttons */
.driver-popover-footer button {
  border-radius: 6px !important;
  text-shadow: none !important;
  font-size: 0.85rem !important;
  padding: 6px 14px !important;
  font-weight: 500 !important;
}

.driver-popover-next-btn {
  background-color: var(--color-success) !important; /* Forest Green */
  color: white !important;
  border: none !important;
}

.driver-popover-prev-btn {
  background-color: transparent !important;
  color: var(--text-main) !important;
  border: 1px solid #dee2e6 !important;
}

.driver-popover-close-btn {
  color: var(--text-main) !important;
}

/* Dark Mode Overrides */
[data-bs-theme="dark"] .driver-popover {
  background-color: #1e2126 !important; /* Slightly lighter than surface for popover */
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .driver-popover-title {
  color: white !important;
}

[data-bs-theme="dark"] .driver-popover-description {
  color: #adb5bd !important;
}

[data-bs-theme="dark"] .driver-popover-prev-btn {
  color: #e9ecef !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .driver-popover-close-btn {
  color: #adb5bd !important;
}

[data-bs-theme="dark"] .driver-popover-close-btn:hover {
  color: white !important;
}

/* Speed up Driver.js animations */
.driver-active-element,
.driver-popover {
  transition-duration: 0.1s !important;
}

/* Theme-aware Image Utility Classes */
[data-bs-theme="dark"] .img-light {
  display: none !important;
}

[data-bs-theme="light"] .img-dark {
  display: none !important;
}

/* Fix Dropdown Z-Index Issue */
.navbar .dropdown-menu {
  z-index: 10000 !important; /* Ensure it sits above everything */
}

/* Ensure Navbar sits above filters (which have z-index: 1040) but below modals (1055) */
/* Essential because backdrop-filter in dark mode creates a new stacking context */
/* Sticky Navbar Glassmorphism and Z-index */
.navbar.sticky-top {
  background-color: rgba(var(--bs-tertiary-bg-rgb), 0.8) !important;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  z-index: 1050;
  transition: all 0.3s ease;
}

[data-bs-theme="dark"] .navbar.sticky-top {
  background-color: rgba(var(--color-surface-rgb, 26, 29, 33), 0.8) !important;
}

/* Social Share Buttons */
.btn-social {
  color: white !important;
  border: none;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.btn-social:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  opacity: 0.9;
}

.btn-twitter {
  background-color: #000000;
} /* X / Twitter */
.btn-linkedin {
  background-color: #0077b5;
}
.btn-facebook {
  background-color: #1877f2;
}
.btn-whatsapp {
  background-color: #25d366;
}
.btn-reddit {
  background-color: #ff4500;
}

/* Blog Content Typography */
.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4,
.blog-content h5,
.blog-content h6 {
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

/* Fix for first element */
.blog-content > *:first-child {
  margin-top: 0;
}

/* Dashboard Category List Redesign */
.category-list-item {
  transition: background-color 0.2s;
  border-radius: 8px;
}
.category-list-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.category-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* Progress Bars */
.progress-bar {
  --bs-progress-bar-bg: #1D9E75;
}
.progress-thin {
  height: 6px;
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.1);
}
[data-bs-theme="light"] .progress-thin {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Category Colors (cycling) - Flat solid colors */
.cat-color-0 {
  background-color: #1D9E75;
} /* Forest Green */
.cat-color-1 {
  background-color: #D4831A;
} /* Warm Amber */
.cat-color-2 {
  background-color: #E05C45;
} /* Warm Red */
.cat-color-3 {
  background-color: #8b6f47;
} /* Warm Brown */
.cat-color-4 {
  background-color: #6b8f71;
} /* Sage Green */

/* Progress Bar Animation */
@keyframes progress-fill {
  from {
    width: 0;
  }
  to {
    width: var(--progress-width, 100%);
  }
}

.progress-animate .progress-bar {
  animation: progress-fill 1s ease-out forwards;
}

.progress {
  overflow: hidden;
}

/* Semantic Progress Bar Colors - Premium Palette */
.progress-gradient-success {
  background-color: #1D9E75;
}
.progress-gradient-warning {
  background-color: #D4831A;
}
.progress-gradient-danger {
  background-color: #E05C45;
}
.progress-gradient-teal {
  background-color: #1D9E75;
}

/* Fix for Multiselect Dropdown Visibility */
.multiselect-container.dropdown-menu {
  z-index: 2000 !important;
}

/* Fix: Remove chevron/caret from dropdown option items */
.multiselect-container .multiselect-option::after,
.multiselect-container .multiselect-all::after,
.multiselect-container .dropdown-item::after {
  display: none !important;
  content: none !important;
}

/* Fix: Ensure radio inputs in single-select dropdown look correct */
.multiselect-container .form-check-input[type="radio"] {
  appearance: auto !important;
  -webkit-appearance: auto !important;
  background-image: none !important;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  cursor: pointer;
}

/* Fix for Mobile Dropdown Clipping */
@media (max-width: 768px) {
  /* Removed overflow: visible override for general .table-responsive to allow scrolling */

  #formset-table tr {
    position: static !important; /* Allow absolute dropdowns to escape the row/card */
    overflow: visible !important;
  }
}

/* Ensure multiselect dropdown is always above other elements */
.multiselect-native-select .btn-group {
  position: relative;
}

.multiselect-native-select .btn-group:hover,
.multiselect-native-select .btn-group:focus-within,
.multiselect-native-select .btn-group.show {
  z-index: 1055 !important; /* Elevate only the active dropdown to escape sibling stacking overlap */
}

/* Fix for overlapping rows in formsets on mobile */
.form-row {
  z-index: 1;
}

.form-row:focus-within {
  z-index: 1050; /* Bring current row to front when focused */
}




/* --- Mobile App Specific Styles --- */
/* These classes are toggled via JavaScript when running inside Capacitor */
.is-mobile-app .non-mobile-app {
  display: none !important;
}

.mobile-app-only {
  display: none;
}

.is-mobile-app .mobile-app-only {
  display: block;
}

/* Safe area padding for the navbar with a 44px fallback for iOS notches */
.is-mobile-app .navbar {
  padding-top: calc(env(safe-area-inset-top, 44px) + 0.5rem) !important;
}

.is-mobile-app .navbar-brand {
    padding-top: 0.5rem;
}

/* Ensure the body and main content respect safe areas */
.is-mobile-app body {
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px) + 1rem) !important;
}

.is-mobile-app main {
  padding-top: calc(env(safe-area-inset-top, 44px) + 0.5rem) !important; /* The navbar already has safe-area-inset-top */
}

/* Specific fix for authenticated users where the top navbar is hidden on mobile */
.is-mobile-app.is-authenticated main {
    padding-top: calc(env(safe-area-inset-top, 20px) + 0.75rem) !important;
}

/* Adjust sticky top position if needed */
.is-mobile-app .navbar.sticky-top {
  top: 0;
}

/* --- Visual Payment Method Selector --- */
.payment-method-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.payment-method-item {
  flex: 0 0 calc(20% - 12px);
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.payment-method-item:hover {
  background: rgba(0,0,0,0.02);
  transform: translateY(-2px);
}

.payment-method-item .icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.payment-method-item .label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
  text-align: center;
}

/* Selected State */
.payment-method-item.active {
  background: transparent;
}

.payment-method-item.active .icon-wrapper {
  background-color: #1D9E75;
  color: white;
  transform: scale(1.1);
}

.payment-method-item.active .label {
  color: var(--color-primary);
  font-weight: 600;
}

[data-bs-theme="dark"] .payment-method-item {
  border-color: rgba(255,255,255,0.1);
  background: transparent;
}

[data-bs-theme="dark"] .payment-method-item .icon-wrapper {
  background: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .payment-method-item:hover {
  background: rgba(255,255,255,0.04);
}

[data-bs-theme="dark"] .payment-method-item.active {
  background: transparent;
}

/* Responsive adjustment for small screens */
@media (max-width: 576px) {
  .payment-method-item {
    flex: 1 1 calc(33.333% - 12px);
  }
}

/* --- Compact Version for Formsets --- */
.payment-method-selector.compact {
  gap: 4px;
  justify-content: flex-start;
}

/* One-line layout inside modals */
.modal .payment-method-selector {
  flex-wrap: nowrap;
  gap: 6px;
}

.modal .payment-method-item {
  min-width: 0;
  flex: 1 1 0;
  padding: 10px 4px;
}

.modal .payment-method-item .icon-wrapper {
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
}

.modal .payment-method-item .label {
  font-size: 0.7rem;
}

.payment-method-selector.compact .payment-method-item {
  flex: 0 0 auto;
  min-width: 40px;
  padding: 6px;
  border-radius: 8px;
}

.payment-method-selector.compact .icon-wrapper {
  width: 28px;
  height: 28px;
  font-size: 1rem;
  margin-bottom: 2px;
}

.payment-method-selector.compact .label {
  display: none; /* Hide label in compact mode to save space */
}

/* Tooltip for compact mode */
.payment-method-selector.compact .payment-method-item:hover::after {
  content: attr(data-value);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  white-space: nowrap;
  z-index: 10;
}

/* --- Card-based Bulk Add Layout --- */
#formset-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-card {
  background: var(--surface-color);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  transition: all 0.3s ease;
  position: relative;
}

.form-card:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  border-color: rgba(29, 158, 117, 0.2);
}

.form-card .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.form-card .form-control, 
.form-card .form-select {
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  border: 1.5px solid rgba(0,0,0,0.05);
  background-color: #fcfdfe;
}

.form-card .form-control:focus,
.form-card .form-select:focus {
  border-color: #1D9E75;
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(29, 158, 117, 0.1);
}

.remove-item-container {
  border-top: 1px dashed rgba(0,0,0,0.1);
  margin-top: 1rem;
  padding-top: 1rem;
  text-align: center;
}

.remove-item-btn {
  color: #ff4d6d;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.remove-item-btn:hover {
  color: #ff0033;
  transform: scale(1.05);
}

[data-bs-theme="dark"] .form-card {
  border-color: rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
}

[data-bs-theme="dark"] .form-card .form-control,
[data-bs-theme="dark"] .form-card .form-select {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

/* --- Mobile Optimizations for Bulk Add --- */
@media (max-width: 576px) {
  #formset-container {
    gap: 1rem;
  }

  .form-card {
    padding: 1rem;
    border-radius: 16px;
  }

  .form-card .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
  }

  .form-card .form-control, 
  .form-card .form-select {
    padding: 0.5rem 0.75rem;
    font-size: 16px; /* Prevents iOS/Mobile zoom on focus */
    border-radius: 10px;
  }

  .remove-item-btn {
    font-size: 0.8rem;
  }
}

/* --- Compact Payment Selector for Cards (Desktop & Mobile Sync) --- */
.form-card .payment-method-selector,
.payment-method-selector.horizontal {
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: hidden;
  padding-bottom: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.form-card .payment-method-selector::-webkit-scrollbar,
.payment-method-selector.horizontal::-webkit-scrollbar {
  display: none;
}

.form-card .payment-method-item,
.payment-method-selector.horizontal .payment-method-item {
  flex: 1;
  min-width: 0;
  padding: 10px 2px;
  border-radius: 12px;
  box-shadow: none;
  border: none;
}

.form-card .payment-method-item .icon-wrapper,
.payment-method-selector.horizontal .payment-method-item .icon-wrapper {
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  border-radius: 10px;
  margin-bottom: 8px;
}

.form-card .payment-method-item .label,
.payment-method-selector.horizontal .payment-method-item .label {
  font-size: 0.7rem;
  white-space: normal;
  word-break: break-word;
  line-height: 1.1;
  text-align: center;
}

@media (max-width: 576px) {
  .form-card .payment-method-selector {
    overflow-x: hidden;
  }

  .form-card .payment-method-item {
    min-width: 0;
    flex: 1;
    padding: 6px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: transparent !important;
    box-shadow: none !important;
  }
  
  .form-card .payment-method-item:hover {
    background: transparent !important;
    transform: none;
  }
  
  .form-card .payment-method-item.active {
    background: transparent !important;
  }
  
  .form-card .payment-method-item .icon-wrapper {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    border-radius: 12px;
    margin-bottom: 6px;
  }
  
  .form-card .payment-method-item .label {
    font-size: 0.7rem;
    margin-top: 0;
    font-weight: 700;
    white-space: normal;
    line-height: 1.1;
    word-break: break-word;
  }
}

/* --- Sticky Action Bar --- */
.sticky-action-bar {
  position: sticky;
  bottom: 1.5rem;
  margin: 2rem 0 1rem;
  z-index: 1020;
  display: flex;
  justify-content: center;
}

.sticky-action-bar .action-bar-content {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .sticky-action-bar .action-bar-content {
  background: rgba(18, 18, 18, 0.85);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

@media (max-width: 576px) {
  .sticky-action-bar {
    bottom: 0;
    margin: 2rem calc(var(--bs-gutter-x) * -0.5) 0;
    justify-content: stretch;
  }
  
  .sticky-action-bar .action-bar-content {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 1rem;
    justify-content: center;
  }
  
  .sticky-action-bar .btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }
}

/* --- Global Mobile Input Zoom Prevention --- */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: 16px !important; /* Force 16px to prevent auto-zoom on mobile focus */
  }
  
  body {
    padding-bottom: 75px; /* Space for bottom nav */
  }
}

/* --- Mobile Bottom Navigation --- */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(70px + env(safe-area-inset-bottom, 0px));
  background: rgba(var(--bs-body-bg-rgb), 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--bs-border-color-translucent);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1100 !important; /* Always on top */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -8px 25px rgba(0,0,0,0.1);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--bs-secondary);
  text-decoration: none;
  flex: 1;
  height: 100%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  border: none;
  background: transparent;
  padding: 0;
}

.mobile-nav-item i {
  font-size: 1.35rem;
  height: 24px; /* Fixed height for consistent alignment */
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  transition: transform 0.2s ease;
}

.mobile-nav-item span {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.mobile-nav-item.active {
  color: var(--color-success); /* Forest Green to match desktop */
}

.mobile-nav-item.active i {
  transform: translateY(-2px);
  color: inherit;
}

/* --- Floating Action Button (FAB) --- */
.mobile-fab {
  position: relative;
  top: -20px;
  width: 65px;
  height: 65px;
  z-index: 1060;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-icon {
  width: 58px;
  height: 58px;
  background-color: #1D9E75;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--bs-body-bg);
  color: white;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: fab-pulse 2.5s infinite;
}

.fab-icon i {
  font-size: 1.8rem;
}

.mobile-fab:active .fab-icon {
  transform: scale(0.9) translateY(4px);
  box-shadow: 0 4px 8px rgba(29, 158, 117, 0.2);
}

[data-bs-theme="dark"] .mobile-bottom-nav {
  background: rgba(33, 37, 41, 0.9);
  border-top-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .fab-icon {
  border-color: #212529;
}

/* --- Mobile Bottom Sheet (Offcanvas) --- */
.mobile-bottom-sheet {
  height: auto !important;
  max-height: calc(85vh - (70px + env(safe-area-inset-bottom, 0px)));
  margin-bottom: calc(70px + env(safe-area-inset-bottom, 0px)); /* Dynamic offset for bottom nav */
  padding-left: env(safe-area-inset-left, 0px) !important;
  padding-right: env(safe-area-inset-right, 0px) !important;
  border-top-left-radius: 32px !important;
  border-top-right-radius: 32px !important;
  background: rgba(var(--bs-body-bg-rgb), 0.98) !important;
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid rgba(var(--bs-border-color-rgb), 0.1) !important;
  box-shadow: 0 -20px 50px rgba(0,0,0,0.1);
  z-index: 1080 !important;
}

.profile-avatar {
  background-color: rgba(29, 158, 117, 0.08);
  transition: all 0.3s ease;
}

[data-bs-theme="dark"] .profile-avatar {
  background-color: rgba(29, 158, 117, 0.15);
  border-color: rgba(255, 255, 255, 0.1) !important;
}

.mobile-bottom-sheet .offcanvas-header {
  padding: 1.5rem 1.75rem 1rem;
}

.mobile-bottom-sheet .list-group-item {
  background: transparent;
  padding: 0.6rem 1.75rem;
  border: none !important; /* Remove loud horizontal lines */
  transition: all 0.2s ease;
  font-weight: 500;
  font-size: 1rem;
  display: flex !important;
  align-items: center;
  gap: 1rem;
}

.mobile-bottom-sheet .list-group-item:active {
  background-color: rgba(var(--bs-primary-rgb), 0.05);
  transform: scale(0.98);
}

.mobile-bottom-sheet .list-group-item i {
  font-size: 1.4rem;
  width: 28px;
  text-align: center;
}

[data-bs-theme="dark"] .mobile-bottom-sheet {
  background: rgba(30, 34, 38, 0.98) !important;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.5);
}

.no-caret::after {
    display: none !important;
}

/* --- Premium Net Worth Card --- */
.nw-accent-line {
  height: 4px;
  width: 100%;
  background: var(--bs-primary);
  border-radius: 10px;
  margin: 1.5rem 0;
  opacity: 0.8;
}

.account-item-premium {
  display: flex;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: all 0.2s ease;
  position: relative;
}

.account-item-premium:last-child {
  border-bottom: none;
}

.account-item-premium:hover {
  background: rgba(0,0,0,0.02);
  transform: translateX(4px);
}

.account-status-bar {
  width: 3px;
  height: 32px;
  border-radius: 4px;
  margin-right: 1.25rem;
  flex-shrink: 0;
}

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

.account-name-bold {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--bs-body-color);
  margin-bottom: 2px;
  display: block;
}

.account-type-subtext {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #6c757d;
  letter-spacing: 0.05em;
}

.account-amount-bold {
  font-weight: 700;
  font-size: 1rem;
  margin-left: 1rem;
  flex-shrink: 0;
}

.text-negative {
  color: #ae2012 !important;
}

/* Dark mode adjustments */
[data-bs-theme="dark"] .account-item-premium {
  border-bottom-color: rgba(255,255,255,0.05);
}

[data-bs-theme="dark"] .account-item-premium:hover {
  background: rgba(255,255,255,0.03);
}

[data-bs-theme="dark"] .account-type-subtext {
  color: #adb5bd;
}
