/* ── Sidebar layout ───────────────────────────────────────────────────────── */
:root {
  --bs-font-sans-serif: 'Inter', system-ui, -apple-system, sans-serif;
  --bs-body-font-family: var(--bs-font-sans-serif);
  --sidebar-width: 260px;
  --bs-border-radius: 1rem;
  --bs-border-radius-lg: 1.5rem;
  --bs-body-bg: #f8fafc;
  --bs-body-color: #334155;
  --glass-bg-light: rgba(255, 255, 255, 0.7);
  --glass-border-light: rgba(255, 255, 255, 0.5);
  --glass-shadow-light: 0 8px 32px rgba(30, 41, 59, 0.08);

  /* Brand Colors */
  --bs-primary: #8b5cf6; /* Vibrant Violet */
  --bs-primary-rgb: 139, 92, 246;
  --bs-secondary: #0ea5e9; /* Cyan */
}

[data-bs-theme="dark"] {
  --bs-body-bg: #0f172a;  /* deep indigo slate */
  --bs-body-color: #f1f5f9;
  --bs-card-bg: rgba(30, 41, 59, 0.4) !important;
  --bs-dark-bg-subtle: rgba(15, 23, 42, 0.7) !important;
  --bs-border-color: rgba(255, 255, 255, 0.08) !important;
  --glass-bg-dark: rgba(30, 41, 59, 0.4);
  --glass-border-dark: rgba(255, 255, 255, 0.08);
  --glass-shadow-dark: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  background: var(--glass-bg-light);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  border: 1px solid var(--glass-border-light) !important;
  width: var(--sidebar-width);
  min-height: calc(100vh - 2rem);
  height: calc(100vh - 2rem);
  margin: 1rem;
  border-radius: 1.5rem;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(0);
}

[data-bs-theme="dark"] .sidebar {
  background: linear-gradient(180deg, rgba(30,41,59,0.85) 0%, rgba(15,23,42,0.95) 100%) !important;
  border: 1px solid rgba(255,255,255,0.05) !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

#page-content-wrapper {
  flex: 1;
  min-width: 0;
  margin-left: calc(var(--sidebar-width) + 2rem);
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
  background: var(--bs-body-bg);
}

/* ── Desktop: sidebar collapsed ──────────────────────────────────────────── */
@media (min-width: 992px) {
  body.sidebar-collapsed .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width) - 2rem));
  }

  body.sidebar-collapsed #page-content-wrapper {
    margin-left: 0;
  }
}

/* ── Mobile (≤ 991px): sidebar hidden by default, overlays on open ───────── */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width) - 2rem));
  }

  #page-content-wrapper {
    margin-left: 0;
  }

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

  /* Backdrop overlay when sidebar is open on mobile */
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1035;
  }
}

/* ── Sidebar nav links ───────────────────────────────────────────────────── */
.sidebar-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
  background: rgba(0, 0, 0, 0.02);
}
[data-bs-theme="dark"] .sidebar-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  background: rgba(255, 255, 255, 0.02);
}

.sidebar .nav-link {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  color: #64748b !important;
  display: flex;
  align-items: center;
}
[data-bs-theme="dark"] .sidebar .nav-link {
  color: rgba(255, 255, 255, 0.65) !important;
}

.sidebar .nav-link i {
  transition: all 0.3s ease;
  color: #94a3b8;
  font-size: 1.15rem;
  margin-right: 0.75rem !important;
}
[data-bs-theme="dark"] .sidebar .nav-link i {
  color: rgba(255, 255, 255, 0.45);
}

.sidebar .nav-link:hover {
  background: rgba(139, 92, 246, 0.08);
  color: #0f172a !important;
  transform: translateX(4px);
}
[data-bs-theme="dark"] .sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff !important;
}

.sidebar .nav-link:hover i {
  color: var(--bs-primary);
}
[data-bs-theme="dark"] .sidebar .nav-link:hover i {
  color: #fff;
}

.sidebar .nav-link.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.15) 0%, rgba(139, 92, 246, 0.0) 100%);
  color: var(--bs-primary) !important;
  border-left: 3px solid var(--bs-primary);
  font-weight: 600;
}
[data-bs-theme="dark"] .sidebar .nav-link.active {
  color: #fff !important;
}

.sidebar .nav-link.active i {
  color: var(--bs-primary);
}
[data-bs-theme="dark"] .sidebar .nav-link.active i {
  text-shadow: 0 0 16px rgba(139, 92, 246, 0.8);
}

/* Submenu / Collapse links */
.sidebar .collapse .nav-link {
  padding-left: 3rem;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.sidebar .collapse .nav-link.active {
  border-left: none;
  background: rgba(0, 0, 0, 0.04);
}
[data-bs-theme="dark"] .sidebar .collapse .nav-link.active {
  background: rgba(255, 255, 255, 0.08);
}

/* ── Navbar Glassmorphism ────────────────────────────────────────────────── */
.navbar {
  flex-wrap: nowrap;
  background: var(--glass-bg-light) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border-light) !important;
  position: relative;
  z-index: 1030;
}

[data-bs-theme="dark"] .navbar {
  background: rgba(15, 23, 42, 0.6) !important;
  border-bottom: 1px solid var(--glass-border-dark) !important;
}

/* ── Cards (Glassmorphic) ────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg-light);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border-light);
  box-shadow: var(--glass-shadow-light);
  border-radius: var(--bs-border-radius-lg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

[data-bs-theme="dark"] .card {
  background: var(--glass-bg-dark) !important;
  border-color: var(--glass-border-dark);
  box-shadow: var(--glass-shadow-dark);
}

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

[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}

/* ── Glass Alerts ────────────────────────────────────────────────────────── */
.glass-alert {
  background: var(--glass-bg-light) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border-light) !important;
  color: var(--bs-body-color) !important;
  font-weight: 500;
}

[data-bs-theme="dark"] .glass-alert {
  background: var(--glass-bg-dark) !important;
  border-color: var(--glass-border-dark) !important;
  color: #fff !important;
}

.glass-alert.alert-info { border-left: 4px solid var(--bs-info) !important; }
.glass-alert.alert-success { border-left: 4px solid var(--bs-success) !important; }
.glass-alert.alert-warning { border-left: 4px solid var(--bs-warning) !important; }
.glass-alert.alert-danger { border-left: 4px solid var(--bs-danger) !important; }

/* ── Modern Electric Buttons ─────────────────────────────────────────────── */
.btn {
  border-radius: var(--bs-border-radius);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  letter-spacing: 0.3px;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  border: none;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
  color: white;
}

[data-bs-theme="dark"] .btn-primary {
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
  color: white;
  transform: translateY(-3px);
}

.btn-outline-primary {
  border: 2px solid #8b5cf6;
  color: #8b5cf6;
  background: transparent;
}
.btn-outline-primary:hover {
  background: #8b5cf6;
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  border: none;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
  color: white;
}
.btn-secondary:hover {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
  transform: translateY(-3px);
  color: white;
}

/* ── VAT rate badges ─────────────────────────────────────────────────────── */
.badge.bg-success { background-color: #10b981 !important; }
.badge.bg-warning { background-color: #f59e0b !important; }
.badge.bg-danger  { background-color: #ef4444 !important; }

/* ── Modern Tables ───────────────────────────────────────────────────────── */
.table {
  --bs-table-bg: transparent !important;
  color: var(--bs-body-color);
  vertical-align: middle;
}

.table > :not(caption) > * > * {
  border-bottom-width: 0px !important;
  background-color: transparent !important;
}

.table th {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: rgba(15, 23, 42, 0.6) !important;
  border-bottom: 1px solid rgba(0,0,0,0.06) !important;
  padding: 1rem 1.25rem !important;
}

[data-bs-theme="dark"] .table th {
  color: rgba(255, 255, 255, 0.5) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
}

.table td {
  padding: 1rem 1.25rem !important;
  vertical-align: middle;
  border-bottom: 1px solid rgba(0,0,0,0.03) !important;
}

[data-bs-theme="dark"] .table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
}

.table-hover tbody tr {
  transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover td {
  background-color: rgba(0, 0, 0, 0.02) !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover td {
  background-color: rgba(255, 255, 255, 0.03) !important;
  color: #fff;
}

/* ── Loading spinner overlay ─────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ── Dark mode overrides for hardcoded light classes ────────────────────── */
[data-bs-theme="dark"] .bg-white {
  background-color: transparent !important;
  color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .bg-dark {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.95) 100%) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--glass-border-dark) !important;
}

[data-bs-theme="dark"] .navbar-light {
  background-color: var(--bs-dark-bg-subtle) !important;
  border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .spinner-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: transparent !important;
  --bs-table-color: var(--bs-body-color);
}

/* ── Nav dropdown triggers ───────────────────────────────────────────────── */
.nav-dd-trigger {
  background: transparent !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  color: var(--bs-body-color) !important;
  font-size: 0.875rem;
  padding: 5px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
  box-shadow: none !important;
}
.nav-dd-trigger:hover,
.nav-dd-trigger:focus,
.nav-dd-trigger.show {
  background: rgba(0, 0, 0, 0.05) !important;
  border-color: rgba(0, 0, 0, 0.15) !important;
  color: var(--bs-body-color) !important;
  box-shadow: none !important;
}
[data-bs-theme="dark"] .nav-dd-trigger {
  border-color: rgba(255, 255, 255, 0.1) !important;
}
[data-bs-theme="dark"] .nav-dd-trigger:hover,
[data-bs-theme="dark"] .nav-dd-trigger:focus,
[data-bs-theme="dark"] .nav-dd-trigger.show {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  color: #fff !important;
}

/* Small avatar in trigger button */
.nav-dd-avatar-sm {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: 0.58rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  line-height: 1;
}

/* ── Nav dropdown menus ──────────────────────────────────────────────────── */
.nav-dropdown {
  min-width: 230px;
  padding: 6px !important;
  border-radius: 14px !important;
  background: rgba(255, 255, 255, 0.97) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}
[data-bs-theme="dark"] .nav-dropdown {
  background: rgba(16, 23, 40, 0.97) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.nav-dropdown .dropdown-item {
  border-radius: 8px;
  padding: 8px 10px !important;
  font-size: 0.875rem;
  color: #334155;
  transition: background 0.15s ease, color 0.15s ease;
}
[data-bs-theme="dark"] .nav-dropdown .dropdown-item {
  color: rgba(255, 255, 255, 0.82);
}
.nav-dropdown .dropdown-item:hover,
.nav-dropdown .dropdown-item:focus {
  background: rgba(139, 92, 246, 0.07);
  color: #0f172a;
}
[data-bs-theme="dark"] .nav-dropdown .dropdown-item:hover,
[data-bs-theme="dark"] .nav-dropdown .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

/* Active org item */
.nav-dropdown .dropdown-item.org-active {
  background: rgba(139, 92, 246, 0.1) !important;
  color: var(--bs-primary) !important;
  font-weight: 600;
}
[data-bs-theme="dark"] .nav-dropdown .dropdown-item.org-active {
  background: rgba(139, 92, 246, 0.2) !important;
  color: #c4b5fd !important;
}

/* Org letter chip */
.nav-dd-org-chip {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(139, 92, 246, 0.12);
  color: var(--bs-primary);
  font-weight: 700;
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
[data-bs-theme="dark"] .nav-dd-org-chip {
  background: rgba(139, 92, 246, 0.28);
  color: #c4b5fd;
}
.nav-dropdown .dropdown-item.org-active .nav-dd-org-chip {
  background: rgba(139, 92, 246, 0.22);
}

/* Logout / danger */
.nav-dropdown .dropdown-item.text-danger:hover,
.nav-dropdown .dropdown-item.text-danger:focus {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #ef4444 !important;
}
[data-bs-theme="dark"] .nav-dropdown .dropdown-item.text-danger:hover,
[data-bs-theme="dark"] .nav-dropdown .dropdown-item.text-danger:focus {
  background: rgba(239, 68, 68, 0.14) !important;
}

/* Divider */
.nav-dropdown .dropdown-divider {
  border-color: rgba(0, 0, 0, 0.06);
  margin: 4px 0 !important;
}
[data-bs-theme="dark"] .nav-dropdown .dropdown-divider {
  border-color: rgba(255, 255, 255, 0.07);
}

/* User info header */
.nav-dd-user-header {
  padding: 10px 12px 8px;
  pointer-events: none;
  cursor: default;
}
.nav-dd-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

/* ── Flatpickr calendar theme ────────────────────────────────────────────── */

/* Shared shape */
.flatpickr-calendar {
  border-radius: 14px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  font-family: var(--bs-font-sans-serif) !important;
  /* Vertical padding only — horizontal padding would cause overflow:hidden to
     clip the right column of day cells (dayContainer = full calendar width). */
  padding: 6px 0 12px !important;
  width: 308px !important;
}
.flatpickr-calendar.arrowTop::before,
.flatpickr-calendar.arrowTop::after { display: none; }
.flatpickr-calendar.arrowBottom::before,
.flatpickr-calendar.arrowBottom::after { display: none; }

/* Month navigation */
.flatpickr-months {
  padding: 4px 10px 6px;
  align-items: center;
}
.flatpickr-prev-month,
.flatpickr-next-month {
  padding: 6px 10px !important;
  border-radius: 8px !important;
  top: 4px !important;
}
.flatpickr-prev-month:hover,
.flatpickr-next-month:hover { background: rgba(139, 92, 246, 0.1) !important; }
.flatpickr-prev-month svg,
.flatpickr-next-month svg { width: 14px; height: 14px; }

.flatpickr-current-month {
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  padding-top: 2px !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
  font-weight: 600;
  font-size: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.numInputWrapper { display: inline-block; }
.numInputWrapper span { display: none !important; } /* hide year up/down arrows */
.numInput.cur-year {
  font-weight: 600;
  font-size: 0.95rem;
  pointer-events: none;
}

/* Day headers (Mo Tu We…) */
.flatpickr-weekdays { padding: 0 2px; }
.flatpickr-weekday {
  font-size: 0.72rem !important;
  font-weight: 500 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Day cells */
.flatpickr-day {
  border-radius: 8px !important;
  font-size: 0.875rem;
  max-width: 38px;
  height: 38px;
  line-height: 38px;
  margin: 1px;
  border: none !important;
}
.flatpickr-day:hover,
.flatpickr-day:focus {
  border: none !important;
}

/* Selected day */
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #7c3aed !important;
  border-color: #7c3aed !important;
  color: #fff !important;
  border-radius: 8px !important;
}

/* Today */
.flatpickr-day.today {
  border: 1.5px solid rgba(139, 92, 246, 0.5) !important;
  color: inherit;
}
.flatpickr-day.today:hover { background: rgba(139, 92, 246, 0.1); }
.flatpickr-day.today.selected { border-color: #7c3aed !important; }

/* ── Dark mode overrides ── */
[data-bs-theme="dark"] .flatpickr-calendar {
  background: #111827 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .flatpickr-months { background: transparent; }
[data-bs-theme="dark"] .flatpickr-month { background: transparent; color: #f1f5f9; }

[data-bs-theme="dark"] .flatpickr-current-month,
[data-bs-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months,
[data-bs-theme="dark"] .numInput.cur-year {
  color: #f1f5f9 !important;
  background: transparent !important;
}
[data-bs-theme="dark"] .flatpickr-current-month .flatpickr-monthDropdown-months option {
  background: #111827;
}

[data-bs-theme="dark"] .flatpickr-prev-month,
[data-bs-theme="dark"] .flatpickr-next-month {
  color: rgba(255, 255, 255, 0.45) !important;
  fill: rgba(255, 255, 255, 0.45) !important;
}
[data-bs-theme="dark"] .flatpickr-prev-month:hover,
[data-bs-theme="dark"] .flatpickr-next-month:hover {
  background: rgba(255, 255, 255, 0.07) !important;
  color: #fff !important;
  fill: #fff !important;
}
[data-bs-theme="dark"] .flatpickr-prev-month svg,
[data-bs-theme="dark"] .flatpickr-next-month svg { fill: inherit; }

[data-bs-theme="dark"] .flatpickr-weekdays { background: transparent; }
[data-bs-theme="dark"] span.flatpickr-weekday {
  background: transparent;
  color: rgba(255, 255, 255, 0.32) !important;
}

[data-bs-theme="dark"] .flatpickr-innerContainer,
[data-bs-theme="dark"] .flatpickr-rContainer,
[data-bs-theme="dark"] .dayContainer {
  background: transparent;
}

[data-bs-theme="dark"] .flatpickr-day {
  color: rgba(255, 255, 255, 0.82);
}
[data-bs-theme="dark"] .flatpickr-day:hover,
[data-bs-theme="dark"] .flatpickr-day:focus {
  background: rgba(139, 92, 246, 0.18) !important;
  color: #fff;
}
[data-bs-theme="dark"] .flatpickr-day.prevMonthDay,
[data-bs-theme="dark"] .flatpickr-day.nextMonthDay {
  color: rgba(255, 255, 255, 0.2) !important;
}
[data-bs-theme="dark"] .flatpickr-day.disabled,
[data-bs-theme="dark"] .flatpickr-day.disabled:hover {
  color: rgba(255, 255, 255, 0.15) !important;
  background: transparent !important;
}
[data-bs-theme="dark"] .flatpickr-day.today {
  border-color: rgba(139, 92, 246, 0.5) !important;
  color: #a78bfa;
}
[data-bs-theme="dark"] .flatpickr-day.today.selected { color: #fff !important; }

/* ── Form Controls (Global Modern Styles) ─────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background-color: rgba(0, 0, 0, 0.02);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  color: var(--bs-body-color);
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12) !important;
  background-color: transparent;
}

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

[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus {
  background-color: rgba(255, 255, 255, 0.09) !important;
}

/* Checkboxes */
.form-check-input {
  border-radius: 4px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background-color: rgba(0, 0, 0, 0.02);
  cursor: pointer;
  width: 1.1em;
  height: 1.1em;
  margin-top: 0.25em;
  transition: all 0.2s ease;
}

[data-bs-theme="dark"] .form-check-input {
  background-color: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
}

.form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  border-color: var(--bs-primary);
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  padding: 14px 16px !important;
}

.filter-bar .form-select,
.filter-bar .form-control {
  font-size: 0.8125rem;
}

/* Date range arrow separator */
.filter-date-sep {
  color: #94a3b8;
  font-size: 0.75rem;
  flex-shrink: 0;
  padding-top: 2px;
}
[data-bs-theme="dark"] .filter-date-sep {
  color: rgba(255, 255, 255, 0.3);
}

/* Fix native calendar picker icon in dark mode */
[data-bs-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.65);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
[data-bs-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ── Pill selects (filter bar) ───────────────────────────────────────────── */
.filter-pill-select {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 30px;
  padding: 0 28px 0 11px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 30px;
  color: #475569;
  background-color: transparent;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 11px 11px;
}
.filter-pill-select:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.filter-pill-select.is-active {
  background-color: rgba(139, 92, 246, 0.07);
  border-color: rgba(139, 92, 246, 0.38);
  color: #6d28d9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%237c3aed' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .filter-pill-select {
  color: rgba(255, 255, 255, 0.72);
  border-color: rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.05);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .filter-pill-select option {
  background: #1e293b;
  color: #f1f5f9;
}
[data-bs-theme="dark"] .filter-pill-select:focus {
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}
[data-bs-theme="dark"] .filter-pill-select.is-active {
  background-color: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.45);
  color: #a78bfa;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
}

/* ── Type filter chip buttons ────────────────────────────────────────────── */
.filter-type-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.filter-chip {
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.filter-chip:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.18);
  color: #475569;
}
.filter-chip.active {
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.4);
  color: #6d28d9;
}
[data-bs-theme="dark"] .filter-chip {
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
}
[data-bs-theme="dark"] .filter-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
}
[data-bs-theme="dark"] .filter-chip.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: rgba(139, 92, 246, 0.5);
  color: #a78bfa;
}

/* ── Modal form controls ─────────────────────────────────────────────────── */
[data-bs-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.65);
  cursor: pointer;
  opacity: 0.75;
}
[data-bs-theme="dark"] .modal-body input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* ── Project access container ────────────────────────────────────────────── */
.project-access-container {
  background-color: #f8fafc;
}

[data-bs-theme="dark"] .project-access-container {
  background-color: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* ── Admin Dashboard Modern Filters ─────────────────────────────────────── */
.filter-chips .btn {
  border: none;
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 0.725rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: transparent;
  color: #64748b;
  margin-right: 2px;
  border: 1px solid transparent;
}

.filter-chips .btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #94a3b8;
}

.filter-chips .btn.active {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.filter-chips .btn.active[data-filter="all"] { background: rgba(148, 163, 184, 0.15) !important; color: #cbd5e1 !important; border-color: rgba(148, 163, 184, 0.3) !important; }
.filter-chips .btn.active[data-filter="active"] { background: rgba(16, 185, 129, 0.15) !important; color: #34d399 !important; border-color: rgba(16, 185, 129, 0.3) !important; }
.filter-chips .btn.active[data-filter="trialing"] { background: rgba(6, 182, 212, 0.15) !important; color: #22d3ee !important; border-color: rgba(6, 182, 212, 0.3) !important; }
.filter-chips .btn.active[data-filter="past_due"] { background: rgba(239, 68, 68, 0.15) !important; color: #f87171 !important; border-color: rgba(239, 68, 68, 0.3) !important; }
.filter-chips .btn.active[data-filter="canceled"] { background: rgba(100, 116, 139, 0.15) !important; color: #94a3b8 !important; border-color: rgba(100, 116, 139, 0.3) !important; }
.filter-chips .btn.active[data-filter="lifetime"] { background: rgba(139, 92, 246, 0.15) !important; color: #a78bfa !important; border-color: rgba(139, 92, 246, 0.3) !important; }
.filter-chips .btn.active[data-filter="monthly"] { background: rgba(59, 130, 246, 0.15) !important; color: #60a5fa !important; border-color: rgba(59, 130, 246, 0.3) !important; }
.filter-chips .btn.active[data-filter="yearly"] { background: rgba(245, 158, 11, 0.15) !important; color: #fbbf24 !important; border-color: rgba(245, 158, 11, 0.3) !important; }

/* Plan Badges */
.badge-plan-monthly {
  background: rgba(59, 130, 246, 0.1) !important;
  color: #60a5fa !important;
  border: 1px solid rgba(59, 130, 246, 0.25) !important;
}
.badge-plan-yearly {
  background: rgba(245, 158, 11, 0.1) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.25) !important;
}

/* ── Responsive Table Truncation ────────────────────────────────────────── */
.org-name-cell {
  max-width: 140px;
}

@media (min-width: 768px) {
  .org-name-cell {
    max-width: 250px;
  }
}

@media (min-width: 1200px) {
  .org-name-cell {
    max-width: 400px;
  }
}

/* ── Admin Dashboard Tabs ───────────────────────────────────────────────── */
#adminTabs .nav-link {
  color: #94a3b8;
  position: relative;
  transition: color 0.2s ease;
}

#adminTabs .nav-link:hover {
  color: #cbd5e1;
}

#adminTabs .nav-link.active {
  color: #8b5cf6 !important;
  background: transparent !important;
}

#adminTabs .nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: #8b5cf6;
  border-radius: 2px;
}

/* ── Support Issue Modal Fixes ──────────────────────────────────────────── */
#issueModal .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

[data-bs-theme="dark"] #issueModal .form-select {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] #issueModal option {
  background-color: #1e293b !important;
  color: #fff !important;
}

/* ── Quill Editor Dark Mode Fixes ───────────────────────────────────────── */
[data-bs-theme="dark"] .ql-toolbar.ql-snow {
  border-color: rgba(255, 255, 255, 0.1) !important;
  background-color: rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .ql-container.ql-snow {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .ql-snow .ql-stroke {
  stroke: #cbd5e1 !important;
}

[data-bs-theme="dark"] .ql-snow .ql-fill {
  fill: #cbd5e1 !important;
}

[data-bs-theme="dark"] .ql-snow .ql-picker {
  color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .ql-editor.ql-blank::before {
  color: rgba(255, 255, 255, 0.5) !important;
}

[data-bs-theme="dark"] .ql-editor {
  color: #f8fafc !important;
}
