/**
 * Sub2API Admin Nebula Glass Theme
 * Deep Violet-Blue Cosmic Glass Aesthetic (matching token.lddykj.cn)
 */

/* ==========================================================================
   1. Design Tokens & Theme Variables
   ========================================================================== */
:root,
html[data-sub2api-theme="nebula"],
html.dark[data-sub2api-theme="nebula"] {
  --nebula-bg-base: #060713;
  --nebula-bg-tint: rgba(8, 7, 20, 0.72);
  --nebula-glass-card: rgba(13, 14, 28, 0.72);
  --nebula-glass-card-hover: rgba(18, 19, 38, 0.78);
  --nebula-glass-header: rgba(10, 10, 24, 0.82);
  --nebula-glass-sidebar: rgba(11, 10, 24, 0.86);
  --nebula-glass-modal: rgba(14, 13, 30, 0.94);
  --nebula-glass-dropdown: rgba(14, 13, 30, 0.96);
  --nebula-glass-input: rgba(10, 11, 24, 0.78);

  --nebula-border-glass: rgba(139, 92, 246, 0.22);
  --nebula-border-glass-light: rgba(139, 92, 246, 0.14);
  --nebula-border-glass-glow: rgba(56, 189, 248, 0.35);
  --nebula-border-focus: #8b5cf6;

  --nebula-btn-primary: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --nebula-btn-primary-hover: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
  --nebula-btn-secondary: rgba(255, 255, 255, 0.07);
  --nebula-btn-secondary-border: rgba(255, 255, 255, 0.15);
  --nebula-btn-secondary-hover: rgba(255, 255, 255, 0.13);

  --nebula-text-primary: #f8fafc;
  --nebula-text-secondary: #cbd5e1;
  --nebula-text-muted: #94a3b8;
  --nebula-text-dim: #64748b;

  --nebula-accent-cyan: #38bdf8;
  --nebula-accent-purple: #a78bfa;
  --nebula-accent-emerald: #34d399;
  --nebula-accent-amber: #fbbf24;
  --nebula-accent-rose: #f43f5e;

  --nebula-radius-card: 16px;
  --nebula-radius-inner: 12px;
  --nebula-radius-btn: 12px;
  --nebula-blur: 20px;
  --nebula-shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.45), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  --nebula-shadow-modal: 0 24px 64px 0 rgba(0, 0, 0, 0.75), inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  --nebula-shadow-glow: 0 0 24px rgba(124, 58, 237, 0.35);
}

/* ==========================================================================
   2. Root & Background Overrides (Fixed Cosmic Nebula)
   ========================================================================== */
html[data-sub2api-theme="nebula"],
html[data-sub2api-theme="nebula"] body {
  color: var(--nebula-text-primary) !important;
  color-scheme: dark !important;
  min-height: 100vh;
}

html[data-sub2api-theme="nebula"] {
  background-color: var(--nebula-bg-base) !important;
}

html[data-sub2api-theme="nebula"] body {
  background-color: transparent !important;
}

html[data-sub2api-theme="nebula"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    radial-gradient(ellipse at 50% 15%, rgba(15, 14, 38, 0.45) 0%, rgba(6, 7, 18, 0.88) 100%),
    url('/theme/assets/fluid-bg.webp');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  pointer-events: none;
}

html[data-sub2api-theme="nebula"] #app {
  position: relative;
  z-index: 1;
}

@media (max-width: 768px) {
  html[data-sub2api-theme="nebula"] body::before {
    background-image:
      radial-gradient(ellipse at 50% 15%, rgba(15, 14, 38, 0.45) 0%, rgba(6, 7, 18, 0.88) 100%),
      url('/theme/assets/fluid-bg-mobile.webp');
  }
}

/* Prevent white/slate full-page container cutouts */
html[data-sub2api-theme="nebula"] #app,
html[data-sub2api-theme="nebula"] .min-h-screen,
html[data-sub2api-theme="nebula"] main {
  background-color: transparent !important;
  background-image: none !important;
}

/* Cosmic ambient mesh glow */
html[data-sub2api-theme="nebula"] .bg-mesh-gradient {
  background-image:
    radial-gradient(at 25% 15%, rgba(124, 58, 237, 0.18) 0px, transparent 50%),
    radial-gradient(at 80% 10%, rgba(56, 189, 248, 0.14) 0px, transparent 50%),
    radial-gradient(at 50% 85%, rgba(139, 92, 246, 0.12) 0px, transparent 55%) !important;
  opacity: 0.85 !important;
}

/* ==========================================================================
   3. Sidebar & Navigation
   ========================================================================== */
html[data-sub2api-theme="nebula"] .sidebar {
  background-color: var(--nebula-glass-sidebar) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border-right: 1px solid var(--nebula-border-glass) !important;
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.45) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-header {
  background-color: transparent !important;
  border-bottom: 1px solid var(--nebula-border-glass-light) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-logo {
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.4) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-brand-title {
  color: var(--nebula-text-primary) !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}

html[data-sub2api-theme="nebula"] .sidebar-section {
  color: var(--nebula-text-dim) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-link {
  color: var(--nebula-text-secondary) !important;
  border: 1px solid transparent !important;
  border-radius: var(--nebula-radius-inner) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-link:hover {
  color: #ffffff !important;
  background-color: rgba(139, 92, 246, 0.14) !important;
  border-color: rgba(139, 92, 246, 0.25) !important;
  transform: translateX(2px);
}

html[data-sub2api-theme="nebula"] .sidebar-link-active,
html[data-sub2api-theme="nebula"] .sidebar-link.router-link-active,
html[data-sub2api-theme="nebula"] .sidebar-link.router-link-exact-active {
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.32) 0%, rgba(56, 189, 248, 0.18) 100%) !important;
  border: 1px solid rgba(167, 139, 250, 0.42) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}

html[data-sub2api-theme="nebula"] .sidebar-link-active svg,
html[data-sub2api-theme="nebula"] .sidebar-link.router-link-active svg,
html[data-sub2api-theme="nebula"] .sidebar-link-active .sidebar-svg-icon {
  color: var(--nebula-accent-cyan) !important;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.55));
}

html[data-sub2api-theme="nebula"] .sidebar [class*="border-t"] {
  border-color: var(--nebula-border-glass-light) !important;
}

/* ==========================================================================
   4. Header / Navbar
   ========================================================================== */
html[data-sub2api-theme="nebula"] header.glass,
html[data-sub2api-theme="nebula"] .glass {
  background-color: var(--nebula-glass-header) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border-bottom: 1px solid var(--nebula-border-glass) !important;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3) !important;
}

/* Header balance pill & info chips */
html[data-sub2api-theme="nebula"] header [class*="bg-primary-50"],
html[data-sub2api-theme="nebula"] header [class*="dark:bg-primary-900/20"] {
  background: rgba(124, 58, 237, 0.18) !important;
  border: 1px solid rgba(167, 139, 250, 0.35) !important;
  color: var(--nebula-text-primary) !important;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.2) !important;
}

/* ==========================================================================
   5. Cards & Glass Panels
   ========================================================================== */
html[data-sub2api-theme="nebula"] .card,
html[data-sub2api-theme="nebula"] .card-glass,
html[data-sub2api-theme="nebula"] .stat-card,
html[data-sub2api-theme="nebula"] .table-scroll-container {
  background-color: var(--nebula-glass-card) !important;
  backdrop-filter: blur(var(--nebula-blur)) saturate(180%) !important;
  -webkit-backdrop-filter: blur(var(--nebula-blur)) saturate(180%) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-card) !important;
  box-shadow: var(--nebula-shadow-card) !important;
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .card-header {
  background-color: rgba(255, 255, 255, 0.02) !important;
  border-bottom: 1px solid var(--nebula-border-glass-light) !important;
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .card-body {
  color: var(--nebula-text-secondary) !important;
}

/* ==========================================================================
   6. Buttons
   ========================================================================== */
html[data-sub2api-theme="nebula"] .btn {
  border-radius: var(--nebula-radius-btn) !important;
  font-weight: 500 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Primary Button: Vibrant Blue-Violet Gradient */
html[data-sub2api-theme="nebula"] .btn-primary,
html[data-sub2api-theme="nebula"] button.btn-primary,
html[data-sub2api-theme="nebula"] a.btn-primary,
html[data-sub2api-theme="nebula"] [class*="bg-primary-500"]:not(.peer-checked):not(.badge),
html[data-sub2api-theme="nebula"] [class*="bg-primary-600"]:not(.peer-checked):not(.badge) {
  background-image: var(--nebula-btn-primary) !important;
  background-color: transparent !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

html[data-sub2api-theme="nebula"] .btn-primary:hover:not(:disabled),
html[data-sub2api-theme="nebula"] button.btn-primary:hover:not(:disabled),
html[data-sub2api-theme="nebula"] a.btn-primary:hover:not(:disabled) {
  background-image: var(--nebula-btn-primary-hover) !important;
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35) !important;
  transform: translateY(-1px);
}

/* Secondary Button: Glass Capsule */
html[data-sub2api-theme="nebula"] .btn-secondary,
html[data-sub2api-theme="nebula"] button.btn-secondary {
  background-color: var(--nebula-btn-secondary) !important;
  background-image: none !important;
  color: var(--nebula-text-primary) !important;
  border: 1px solid var(--nebula-btn-secondary-border) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25) !important;
}

html[data-sub2api-theme="nebula"] .btn-secondary:hover:not(:disabled),
html[data-sub2api-theme="nebula"] button.btn-secondary:hover:not(:disabled) {
  background-color: var(--nebula-btn-secondary-hover) !important;
  border-color: rgba(167, 139, 250, 0.38) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

/* Ghost Button */
html[data-sub2api-theme="nebula"] .btn-ghost,
html[data-sub2api-theme="nebula"] button.btn-ghost {
  background-color: transparent !important;
  color: var(--nebula-text-secondary) !important;
  border: 1px solid transparent !important;
}

html[data-sub2api-theme="nebula"] .btn-ghost:hover:not(:disabled),
html[data-sub2api-theme="nebula"] button.btn-ghost:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
}

/* Danger Button */
html[data-sub2api-theme="nebula"] .btn-danger,
html[data-sub2api-theme="nebula"] button.btn-danger {
  background-image: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(248, 113, 113, 0.3) !important;
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.35) !important;
}

/* ==========================================================================
   7. Form Inputs & Controls
   ========================================================================== */
html[data-sub2api-theme="nebula"] .input,
html[data-sub2api-theme="nebula"] .\!input,
html[data-sub2api-theme="nebula"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]),
html[data-sub2api-theme="nebula"] select,
html[data-sub2api-theme="nebula"] textarea,
html[data-sub2api-theme="nebula"] .select-trigger {
  background-color: var(--nebula-glass-input) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  color: var(--nebula-text-primary) !important;
  border-radius: 10px !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

html[data-sub2api-theme="nebula"] .input::placeholder,
html[data-sub2api-theme="nebula"] input::placeholder,
html[data-sub2api-theme="nebula"] textarea::placeholder {
  color: var(--nebula-text-dim) !important;
}

html[data-sub2api-theme="nebula"] .input:focus,
html[data-sub2api-theme="nebula"] input:focus,
html[data-sub2api-theme="nebula"] select:focus,
html[data-sub2api-theme="nebula"] textarea:focus,
html[data-sub2api-theme="nebula"] .select-trigger:focus,
html[data-sub2api-theme="nebula"] .select-trigger:focus-within {
  border-color: var(--nebula-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.28), 0 0 16px rgba(139, 92, 246, 0.25) !important;
  outline: none !important;
}

/* Custom Select Dropdowns */
html[data-sub2api-theme="nebula"] select option {
  background-color: #0d0c1e !important;
  color: #f8fafc !important;
}

html[data-sub2api-theme="nebula"] .select-options,
html[data-sub2api-theme="nebula"] [class*="select-options"] {
  background-color: var(--nebula-glass-dropdown) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-inner) !important;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.65) !important;
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .select-option:hover,
html[data-sub2api-theme="nebula"] [class*="select-option"]:hover {
  background-color: rgba(139, 92, 246, 0.16) !important;
  color: #ffffff !important;
}

/* Search Input wrapper */
html[data-sub2api-theme="nebula"] .input-wrapper svg,
html[data-sub2api-theme="nebula"] .relative svg.text-gray-400 {
  color: var(--nebula-text-muted) !important;
}

/* ==========================================================================
   8. Tables & Data Display
   ========================================================================== */
html[data-sub2api-theme="nebula"] .table-container,
html[data-sub2api-theme="nebula"] .table-wrapper {
  background-color: var(--nebula-glass-card) !important;
  backdrop-filter: blur(var(--nebula-blur)) !important;
  -webkit-backdrop-filter: blur(var(--nebula-blur)) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-card) !important;
}

/* Keep the table scroll chain alive: .table-wrapper is the scroll container
   used by TablePageLayout/DataTable. `overflow: hidden` here locks wheel and
   touch scrolling, leaving long tables (affiliate records, etc.) unreachable. */
html[data-sub2api-theme="nebula"] .table-container {
  overflow-x: auto !important;
}

html[data-sub2api-theme="nebula"] .table-wrapper {
  overflow-x: auto !important;
  overflow-y: auto !important;
}

html[data-sub2api-theme="nebula"] table,
html[data-sub2api-theme="nebula"] .table {
  background-color: transparent !important;
  color: var(--nebula-text-secondary) !important;
}

html[data-sub2api-theme="nebula"] thead,
html[data-sub2api-theme="nebula"] thead tr,
html[data-sub2api-theme="nebula"] .table-header,
html[data-sub2api-theme="nebula"] th {
  background-color: rgba(18, 17, 38, 0.88) !important;
  color: var(--nebula-text-muted) !important;
  border-bottom: 1px solid var(--nebula-border-glass) !important;
  font-weight: 600 !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em !important;
  text-transform: uppercase !important;
}

html[data-sub2api-theme="nebula"] tbody tr,
html[data-sub2api-theme="nebula"] .table-body tr {
  background-color: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  transition: background-color 0.15s ease !important;
}

html[data-sub2api-theme="nebula"] tbody tr:hover,
html[data-sub2api-theme="nebula"] .table-body tr:hover {
  background-color: rgba(139, 92, 246, 0.08) !important;
}

html[data-sub2api-theme="nebula"] td {
  color: var(--nebula-text-primary) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* ==========================================================================
   9. Tabs & Segmented Navigation
   ========================================================================== */
html[data-sub2api-theme="nebula"] .tabs {
  background-color: rgba(10, 11, 24, 0.78) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-inner) !important;
  padding: 4px !important;
}

html[data-sub2api-theme="nebula"] .tab {
  color: var(--nebula-text-muted) !important;
  border-radius: 8px !important;
  font-weight: 500 !important;
  transition: all 0.2s ease !important;
}

html[data-sub2api-theme="nebula"] .tab:hover {
  color: var(--nebula-text-primary) !important;
  background-color: rgba(255, 255, 255, 0.04) !important;
}

html[data-sub2api-theme="nebula"] .tab-active,
html[data-sub2api-theme="nebula"] .tab[aria-selected="true"] {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.45) 0%, rgba(56, 189, 248, 0.22) 100%) !important;
  border: 1px solid rgba(167, 139, 250, 0.38) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) !important;
}

/* ==========================================================================
   10. Pagination & Switches
   ========================================================================== */
html[data-sub2api-theme="nebula"] .pagination,
html[data-sub2api-theme="nebula"] [class*="pagination"] {
  background-color: transparent !important;
  border-color: var(--nebula-border-glass-light) !important;
}

html[data-sub2api-theme="nebula"] nav[aria-label="Pagination"] button,
html[data-sub2api-theme="nebula"] nav[aria-label="Pagination"] a,
html[data-sub2api-theme="nebula"] .page-size-select select {
  background-color: rgba(13, 14, 28, 0.75) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  color: var(--nebula-text-secondary) !important;
  border-radius: 8px !important;
}

html[data-sub2api-theme="nebula"] nav[aria-label="Pagination"] button:hover:not(:disabled),
html[data-sub2api-theme="nebula"] nav[aria-label="Pagination"] a:hover {
  background-color: rgba(139, 92, 246, 0.18) !important;
  border-color: rgba(167, 139, 250, 0.4) !important;
  color: #ffffff !important;
}

/* Switch / Toggle */
html[data-sub2api-theme="nebula"] .switch {
  background-color: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  transition: all 0.2s ease !important;
}

html[data-sub2api-theme="nebula"] .switch.peer-checked,
html[data-sub2api-theme="nebula"] .switch-checked,
html[data-sub2api-theme="nebula"] input:checked + .switch,
html[data-sub2api-theme="nebula"] input:checked ~ .switch,
html[data-sub2api-theme="nebula"] .peer:checked ~ .peer-checked\:bg-primary-500,
html[data-sub2api-theme="nebula"] .peer:checked ~ .peer-checked\:bg-primary-600 {
  background: var(--nebula-btn-primary) !important;
  border-color: rgba(167, 139, 250, 0.5) !important;
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5) !important;
}

/* ==========================================================================
   11. Modals, Dropdowns & Toasts
   ========================================================================== */
html[data-sub2api-theme="nebula"] .modal-overlay,
html[data-sub2api-theme="nebula"] div[class*="fixed inset-0"][class*="backdrop-blur"] {
  background: rgba(4, 3, 12, 0.78) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
}

html[data-sub2api-theme="nebula"] .modal-content,
html[data-sub2api-theme="nebula"] div[class*="rounded-3xl"][class*="shadow-2xl"] {
  background-color: var(--nebula-glass-modal) !important;
  backdrop-filter: blur(28px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(28px) saturate(180%) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: 20px !important;
  box-shadow: var(--nebula-shadow-modal) !important;
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .modal-header {
  border-bottom: 1px solid var(--nebula-border-glass-light) !important;
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .modal-footer {
  border-top: 1px solid var(--nebula-border-glass-light) !important;
  background-color: rgba(0, 0, 0, 0.22) !important;
}

html[data-sub2api-theme="nebula"] .dropdown,
html[data-sub2api-theme="nebula"] .\!dropdown,
html[data-sub2api-theme="nebula"] [class*="dropdown"]:not(.dropdown-item):not(.select-dropdown-portal):not(.usage-filter-dropdown):not(.date-picker-dropdown) {
  background-color: var(--nebula-glass-dropdown) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: 14px !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65) !important;
}

/* The select panel is teleported into its own fixed wrapper. Styling that
   wrapper as a second glass layer nests backdrop-filters, which can fail to
   paint on some GPUs. Keep the wrapper invisible and let .select-options own
   the glass look. */
html[data-sub2api-theme="nebula"] .select-dropdown-portal {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-sub2api-theme="nebula"] .date-picker-dropdown {
  background-color: var(--nebula-glass-dropdown) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: 14px !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65) !important;
}

html[data-sub2api-theme="nebula"] .dropdown-item {
  color: var(--nebula-text-secondary) !important;
  transition: all 0.15s ease !important;
}

html[data-sub2api-theme="nebula"] .dropdown-item:hover {
  background-color: rgba(139, 92, 246, 0.15) !important;
  color: #ffffff !important;
}

html[data-sub2api-theme="nebula"] .toast {
  background-color: rgba(15, 14, 32, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border: 1px solid rgba(139, 92, 246, 0.3) !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5) !important;
  color: var(--nebula-text-primary) !important;
}

/* Empty State */
html[data-sub2api-theme="nebula"] .empty-state {
  color: var(--nebula-text-muted) !important;
}

html[data-sub2api-theme="nebula"] .empty-state-icon {
  color: rgba(139, 92, 246, 0.45) !important;
}

html[data-sub2api-theme="nebula"] .empty-state-title {
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .empty-state-description {
  color: var(--nebula-text-muted) !important;
}

/* ==========================================================================
   12. Badges & Status Pills
   ========================================================================== */
html[data-sub2api-theme="nebula"] .badge {
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

html[data-sub2api-theme="nebula"] .badge-primary {
  background-color: rgba(56, 189, 248, 0.15) !important;
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
  color: var(--nebula-accent-cyan) !important;
}

html[data-sub2api-theme="nebula"] .badge-success {
  background-color: rgba(52, 211, 153, 0.15) !important;
  border: 1px solid rgba(52, 211, 153, 0.35) !important;
  color: var(--nebula-accent-emerald) !important;
}

html[data-sub2api-theme="nebula"] .badge-warning {
  background-color: rgba(251, 191, 36, 0.15) !important;
  border: 1px solid rgba(251, 191, 36, 0.35) !important;
  color: var(--nebula-accent-amber) !important;
}

html[data-sub2api-theme="nebula"] .badge-danger {
  background-color: rgba(248, 113, 113, 0.15) !important;
  border: 1px solid rgba(248, 113, 113, 0.35) !important;
  color: #f87171 !important;
}

html[data-sub2api-theme="nebula"] .badge-purple {
  background-color: rgba(168, 85, 247, 0.15) !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  color: #c084fc !important;
}

html[data-sub2api-theme="nebula"] .badge-gray {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: var(--nebula-text-secondary) !important;
}

/* ==========================================================================
   13. Comprehensive Tailwind Light Class Overrides
   (Eliminating light/white block residuals with surgical precision)
   ========================================================================== */

/* Overriding light surface backgrounds */
html[data-sub2api-theme="nebula"] .bg-white,
html[data-sub2api-theme="nebula"] [class*="bg-white/"] {
  background-color: var(--nebula-glass-card) !important;
}

html[data-sub2api-theme="nebula"] .bg-gray-50,
html[data-sub2api-theme="nebula"] [class*="bg-gray-50/"] {
  background-color: rgba(10, 10, 22, 0.65) !important;
}

html[data-sub2api-theme="nebula"] .bg-gray-100,
html[data-sub2api-theme="nebula"] [class*="bg-gray-100/"] {
  background-color: rgba(18, 17, 36, 0.65) !important;
}

html[data-sub2api-theme="nebula"] .bg-gray-200,
html[data-sub2api-theme="nebula"] [class*="bg-gray-200/"] {
  background-color: rgba(30, 29, 54, 0.65) !important;
}

/* Subtle tinted alert/badge boxes */
html[data-sub2api-theme="nebula"] .bg-blue-50,
html[data-sub2api-theme="nebula"] .bg-indigo-50,
html[data-sub2api-theme="nebula"] .bg-purple-50,
html[data-sub2api-theme="nebula"] .bg-violet-50 {
  background-color: rgba(124, 58, 237, 0.14) !important;
}

html[data-sub2api-theme="nebula"] .bg-emerald-50,
html[data-sub2api-theme="nebula"] .bg-green-50,
html[data-sub2api-theme="nebula"] .bg-teal-50 {
  background-color: rgba(16, 185, 129, 0.14) !important;
}

html[data-sub2api-theme="nebula"] .bg-amber-50,
html[data-sub2api-theme="nebula"] .bg-yellow-50 {
  background-color: rgba(245, 158, 11, 0.14) !important;
}

html[data-sub2api-theme="nebula"] .bg-red-50,
html[data-sub2api-theme="nebula"] .bg-rose-50 {
  background-color: rgba(239, 68, 68, 0.14) !important;
}

/* Overriding Sub2API's existing dark background utilities for glass consistency */
html[data-sub2api-theme="nebula"] [class*="dark:bg-dark-600"] {
  background-color: rgba(30, 29, 54, 0.75) !important;
}

html[data-sub2api-theme="nebula"] [class*="dark:bg-dark-700"] {
  background-color: rgba(18, 17, 36, 0.78) !important;
}

html[data-sub2api-theme="nebula"] [class*="dark:bg-dark-800"] {
  background-color: rgba(14, 13, 30, 0.82) !important;
}

html[data-sub2api-theme="nebula"] [class*="dark:bg-dark-900"] {
  background-color: rgba(10, 10, 24, 0.88) !important;
}

html[data-sub2api-theme="nebula"] [class*="dark:bg-dark-950"] {
  background-color: rgba(6, 7, 18, 0.92) !important;
}

/* Light border overrides */
html[data-sub2api-theme="nebula"] .border-gray-50,
html[data-sub2api-theme="nebula"] .border-gray-100 {
  border-color: var(--nebula-border-glass-light) !important;
}

html[data-sub2api-theme="nebula"] .border-gray-200 {
  border-color: var(--nebula-border-glass) !important;
}

html[data-sub2api-theme="nebula"] .border-gray-300 {
  border-color: rgba(139, 92, 246, 0.28) !important;
}

html[data-sub2api-theme="nebula"] [class*="dark:border-dark-600"],
html[data-sub2api-theme="nebula"] [class*="dark:border-dark-700"],
html[data-sub2api-theme="nebula"] [class*="dark:border-dark-800"] {
  border-color: var(--nebula-border-glass) !important;
}

html[data-sub2api-theme="nebula"] [class*="divide-gray"] > *,
html[data-sub2api-theme="nebula"] [class*="dark:divide-dark"] > * {
  border-color: var(--nebula-border-glass-light) !important;
}

/* Text Hierarchy Overrides */
html[data-sub2api-theme="nebula"] .text-gray-950,
html[data-sub2api-theme="nebula"] .text-gray-900,
html[data-sub2api-theme="nebula"] .text-gray-800,
html[data-sub2api-theme="nebula"] [class*="dark:text-white"],
html[data-sub2api-theme="nebula"] [class*="dark:text-gray-100"] {
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .text-gray-700,
html[data-sub2api-theme="nebula"] .text-gray-600,
html[data-sub2api-theme="nebula"] [class*="dark:text-gray-200"],
html[data-sub2api-theme="nebula"] [class*="dark:text-gray-300"],
html[data-sub2api-theme="nebula"] [class*="dark:text-dark-200"],
html[data-sub2api-theme="nebula"] [class*="dark:text-dark-300"] {
  color: var(--nebula-text-secondary) !important;
}

html[data-sub2api-theme="nebula"] .text-gray-500,
html[data-sub2api-theme="nebula"] .text-gray-400,
html[data-sub2api-theme="nebula"] [class*="dark:text-gray-400"],
html[data-sub2api-theme="nebula"] [class*="dark:text-dark-400"],
html[data-sub2api-theme="nebula"] [class*="dark:text-dark-500"] {
  color: var(--nebula-text-muted) !important;
}

/* Gradient headlines */
html[data-sub2api-theme="nebula"] .text-gradient,
html[data-sub2api-theme="nebula"] .bg-clip-text {
  background-image: linear-gradient(135deg, #a78bfa 0%, #38bdf8 50%, #ffffff 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
}

/* Hover background states */
html[data-sub2api-theme="nebula"] [class*="hover:bg-gray-50"]:hover,
html[data-sub2api-theme="nebula"] [class*="hover:bg-gray-100"]:hover,
html[data-sub2api-theme="nebula"] [class*="dark:hover:bg-dark-600"]:hover,
html[data-sub2api-theme="nebula"] [class*="dark:hover:bg-dark-700"]:hover,
html[data-sub2api-theme="nebula"] [class*="dark:hover:bg-dark-800"]:hover {
  background-color: rgba(139, 92, 246, 0.14) !important;
}

/* ==========================================================================
   14. Specialized Pages & Component Tuning
   ========================================================================== */

/* Auth Layout (Login, Register, Forgot Password) */
html[data-sub2api-theme="nebula"] .auth-logo {
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.45) !important;
}

/* Code & Pre Blocks */
html[data-sub2api-theme="nebula"] pre,
html[data-sub2api-theme="nebula"] code,
html[data-sub2api-theme="nebula"] .font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
}

html[data-sub2api-theme="nebula"] pre {
  background-color: rgba(9, 9, 22, 0.85) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-inner) !important;
  color: #e2e8f0 !important;
}

html[data-sub2api-theme="nebula"] code:not(pre code) {
  background-color: rgba(124, 58, 237, 0.16) !important;
  color: var(--nebula-accent-cyan) !important;
  border: 1px solid rgba(139, 92, 246, 0.25) !important;
  padding: 0.15em 0.35em !important;
  border-radius: 4px !important;
}

/* Markdown prose */
html[data-sub2api-theme="nebula"] .markdown-body {
  color: var(--nebula-text-secondary) !important;
}

html[data-sub2api-theme="nebula"] .markdown-body h1,
html[data-sub2api-theme="nebula"] .markdown-body h2,
html[data-sub2api-theme="nebula"] .markdown-body h3,
html[data-sub2api-theme="nebula"] .markdown-body h4 {
  color: var(--nebula-text-primary) !important;
}

/* Driver.js tour popovers */
html[data-sub2api-theme="nebula"] .driver-popover {
  background-color: var(--nebula-glass-modal) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border: 1px solid var(--nebula-border-glass) !important;
  border-radius: var(--nebula-radius-card) !important;
  color: var(--nebula-text-primary) !important;
  box-shadow: var(--nebula-shadow-modal) !important;
}

html[data-sub2api-theme="nebula"] .driver-popover-title {
  color: var(--nebula-text-primary) !important;
}

html[data-sub2api-theme="nebula"] .driver-popover-description {
  color: var(--nebula-text-secondary) !important;
}

html[data-sub2api-theme="nebula"] .driver-popover-footer button {
  background-color: rgba(255, 255, 255, 0.08) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: var(--nebula-text-primary) !important;
  border-radius: 6px !important;
}

/* Scrollbar Customization */
html[data-sub2api-theme="nebula"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

html[data-sub2api-theme="nebula"] ::-webkit-scrollbar-track {
  background: rgba(6, 7, 18, 0.5);
}

html[data-sub2api-theme="nebula"] ::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.28);
  border-radius: 9999px;
}

html[data-sub2api-theme="nebula"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* Keep the full-page shell transparent so the cosmic backdrop remains visible
   after the broader Tailwind utility overrides above. */
html[data-sub2api-theme="nebula"] .min-h-screen,
html[data-sub2api-theme="nebula"] main {
  background-color: transparent !important;
  background-image: none !important;
}

/* ==========================================================================
   15. Popover & Select Layering
   ========================================================================== */

/* Glass cards use backdrop-filter, which creates a stacking context. A fixed
   dropdown rendered inside a card is then painted below any later sibling
   card (e.g. the time-range menu buried under the model distribution card).
   Lift the host card while its select is open. */
html[data-sub2api-theme="nebula"] .card:has(.date-picker-dropdown),
html[data-sub2api-theme="nebula"] .card:has(.select-trigger-open),
html[data-sub2api-theme="nebula"] .card:has(.select-options),
html[data-sub2api-theme="nebula"] .card-glass:has(.date-picker-dropdown),
html[data-sub2api-theme="nebula"] .card-glass:has(.select-trigger-open),
html[data-sub2api-theme="nebula"] .stat-card:has(.date-picker-dropdown),
html[data-sub2api-theme="nebula"] .stat-card:has(.select-trigger-open),
html[data-sub2api-theme="nebula"] .nebula-popover-host {
  position: relative !important;
  z-index: 20 !important;
}

/* ==========================================================================
   16. Accessibility & Motion Preference
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html[data-sub2api-theme="nebula"] *,
  html[data-sub2api-theme="nebula"] *::before,
  html[data-sub2api-theme="nebula"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
