/* ==========================================
   ANTI-JUMP: Prevent page movement during renders
   ========================================== */

/* Prevent horizontal overflow on all devices */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  /* Prevent pull-to-refresh on mobile causing layout shifts */
  overscroll-behavior-y: contain;
  /* Disable smooth scrolling during JS scroll restoration */
  scroll-behavior: auto !important;
}

/* Lock scroll position during render */
html.is-rendering {
  /* Prevent any scroll during render */
  overflow-anchor: none;
}

/* Anti-Blink & Anti-Jump: Stable app container */
#app {
  /* Prevent layout shift during render */
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100%;
  /* Lock the container to prevent movement */
  position: relative;
  /* Isolate layout calculations */
  contain: layout style;
  /* Prevent content from pushing layout */
  overflow-anchor: none;
}

/* During render, lock the app height to prevent jumps */
#app.is-rendering {
  /* Lock current height during update */
  min-height: var(--app-height, 100vh);
  /* Prevent any animations during render */
  pointer-events: none;
}

/* DISABLE the fadeIn animation - it causes blinking */
#app > * {
  /* No animation - prevents flicker */
  animation: none !important;
}

/* Prevent white flash during navigation */
main, .main-content {
  background: inherit;
  min-height: 100vh;
  /* Prevent layout shift */
  contain: layout style;
  /* Stable positioning */
  position: relative;
}

/* Content area should maintain stable dimensions */
.p-4.md\:p-8 {
  /* Prevent content area from causing jumps */
  contain: layout style;
  /* Minimum height to prevent collapse */
  min-height: calc(100vh - 80px);
}

/* Stabilize sidebar during navigation */
nav, aside, .sidebar {
  /* Don't animate sidebar - keeps it stable */
  animation: none !important;
  /* Prevent reflow */
  contain: layout style paint;
  /* Fixed positioning already prevents jumps, reinforce it */
  will-change: transform;
}

/* Prevent all layout shifts during sync */
.glass-panel, .rounded-2xl, .rounded-xl {
  /* Contain layout to prevent shifts */
  contain: layout style;
  /* Prevent size changes from affecting parent */
  box-sizing: border-box;
}

/* Grids should maintain stable layouts */
.grid {
  /* Prevent grid from causing reflows */
  contain: layout;
}

/* Buttons and interactive elements shouldn't cause reflow */
button, a, select, input {
  /* Prevent dimension changes on state changes */
  box-sizing: border-box;
}

/* Prevent images and icons from causing layout shifts */
img, svg, [data-lucide] {
  /* Reserve space for icons */
  display: inline-block;
  vertical-align: middle;
}

/* Lucide icons placeholder to prevent shift when they load */
[data-lucide]:empty {
  /* Reserve icon space before JS renders them */
  min-width: 1em;
  min-height: 1em;
  display: inline-block;
}

/* Prevent scroll anchoring issues */
.space-y-4 > *, .space-y-6 > *, .space-y-3 > * {
  overflow-anchor: none;
}

/* Mobile: Extra anti-jump measures */
@media (max-width: 768px) {
  html, body {
    /* Prevent overscroll effects */
    overscroll-behavior: none;
    /* Disable smooth scrolling on mobile */
    scroll-behavior: auto !important;
  }

  #app {
    /* Use dynamic viewport height */
    min-height: 100dvh;
  }

  /* Prevent mobile keyboard from causing jumps */
  .fixed.inset-0 {
    /* Modal overlays should not affect scroll */
    overscroll-behavior: contain;
  }
}

/* Hide sync indicator animation to reduce repaints */
#sync-status-indicator {
  /* GPU accelerate to prevent main thread jank */
  transform: translateZ(0);
  will-change: opacity;
  /* Fixed position prevents layout interference */
  position: fixed;
}

/* Global Variables */
:root {
  /* Albayan Brand Palette (teal / blue / pink) */
  --brand-teal: #34e2c0;
  --brand-teal-rgb: 52, 226, 192;
  --brand-blue: #0b4bff;
  --brand-blue-rgb: 11, 75, 255;
  --brand-blue-700: #063bd0;
  --brand-blue-700-rgb: 6, 59, 208;
  --brand-pink: #ff5aa6;
  --brand-pink-rgb: 255, 90, 166;

  --glass-border: 1px solid rgba(var(--brand-blue-rgb), 0.14);
  --glass-bg: rgba(255, 255, 255, 0.86);
  --glass-shadow: 0 8px 32px 0 rgba(2, 6, 23, 0.08);
  --neon-glow: 0 0 10px rgba(var(--brand-blue-rgb), 0.28), 0 0 18px rgba(var(--brand-teal-rgb), 0.18);
}

.dark {
  --glass-border: 1px solid rgba(var(--brand-teal-rgb), 0.12);
  --glass-bg: rgba(15, 23, 42, 0.78);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.55);
  --neon-glow: 0 0 10px rgba(var(--brand-teal-rgb), 0.16), 0 0 18px rgba(var(--brand-blue-rgb), 0.14);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 20%, rgba(var(--brand-teal-rgb), 0.08), transparent 52%),
              radial-gradient(circle at 80% 80%, rgba(var(--brand-pink-rgb), 0.06), transparent 55%),
              radial-gradient(circle at 80% 15%, rgba(var(--brand-blue-rgb), 0.06), transparent 48%);
  pointer-events: none;
  z-index: 0;
}

/* Cinematic Noise Texture */
.bg-noise {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Advanced Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 100vh;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(var(--brand-blue-rgb), 0.65), rgba(var(--brand-teal-rgb), 0.65));
  border-radius: 100vh;
  backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(var(--brand-blue-rgb), 0.85), rgba(var(--brand-teal-rgb), 0.85));
  border-color: rgba(255, 255, 255, 0.8);
}

/* Glass Panel Effects */
.glass-panel {
  background: var(--glass-bg);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
}

@supports (backdrop-filter: blur(20px)) {
  .glass-panel {
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
  }
}

/* PERFORMANCE: Reduce blur on mobile/low-end devices (big battery & FPS win) */
@media (max-width: 768px), (prefers-reduced-motion: reduce) {
  .glass-panel {
    backdrop-filter: blur(8px) saturate(120%) !important;
    -webkit-backdrop-filter: blur(8px) saturate(120%) !important;
  }
}

@supports not (backdrop-filter: blur(20px)) {
  .glass-panel {
    background: rgba(255, 255, 255, 0.95);
  }
  .dark .glass-panel {
    background: rgba(15, 23, 42, 0.95);
  }
}

.glass-panel:hover {
  box-shadow: 0 15px 40px -10px rgba(var(--brand-blue-rgb), 0.20);
  border-color: rgba(var(--brand-blue-rgb), 0.32);
  transform: translateY(-2px);
}

/* ==========================================
   Scroll performance mode (prevents jank + "disappearing" while scrolling)
   We temporarily reduce heavy effects (blur/shadows/hover transforms).
   Enabled by JS toggling `body.is-scrolling`.
   ========================================== */
body.is-scrolling #aurora-bg {
  opacity: 0 !important;
  filter: none !important;
}

body.is-scrolling .bg-noise {
  opacity: 0 !important;
}

body.is-scrolling::before {
  opacity: 0.35 !important;
}

body.is-scrolling #aurora-bg * {
  animation-play-state: paused !important;
}

/* Disable Tailwind backdrop blur utilities while scrolling (big performance win) */
body.is-scrolling [class*="backdrop-blur"] {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.is-scrolling .glass-panel,
body.is-scrolling .glass-panel-sm {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  transition: none !important;
}

body.is-scrolling .glass-panel:hover,
body.is-scrolling .glass-panel-sm:hover,
body.is-scrolling .btn-shine:hover,
body.is-scrolling .card-hover-lift:hover {
  transform: none !important;
}

body.is-scrolling .btn-shine:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10) !important;
}

/* ==========================================
   PERFORMANCE: Content Visibility & Containment
   Dramatically speeds up rendering of long lists
   ========================================== */

/* Containment for main content area - isolates repaints */
#app {
  contain: layout style;
}

/* Virtual scrolling hint for list items - browser can skip rendering off-screen items */
.glass-panel {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px; /* Estimated height for off-screen panels */
}

/* Cards in grid layouts */
.grid > .glass-panel,
.space-y-4 > .glass-panel,
.space-y-3 > .glass-panel {
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}

/* Sidebar isolation - don't repaint when main content changes */
aside, nav {
  contain: layout style paint;
}

/* Modal backdrop - isolate from main page repaints */
.fixed.inset-0 {
  contain: strict;
}

/* Performance: will-change hints for animated elements */
.animate-fade-in,
.animate-fade-in-up,
.animate-slide-up,
.notification-enter {
  will-change: opacity, transform;
}

/* Remove will-change after animation completes (via JS or animation-fill-mode) */
.animate-fade-in.animation-done,
.animate-fade-in-up.animation-done {
  will-change: auto;
}

/* Reduce paint complexity on tables */
table {
  contain: layout style;
}

/* Input Fields */
.glass-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(var(--brand-blue-rgb), 0.18);
  transition: all 0.3s ease;
}

/* Hide number input spinner arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

@supports (backdrop-filter: blur(10px)) {
  .glass-input {
    backdrop-filter: blur(8px);
  }
}

.glass-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(var(--brand-blue-rgb), 0.55);
  box-shadow: 0 0 0 4px rgba(var(--brand-blue-rgb), 0.14), 0 4px 12px rgba(var(--brand-teal-rgb), 0.18);
  outline: none;
  transform: translateY(-1px);
}

.glass-input:hover:not(:focus) {
  border-color: rgba(var(--brand-blue-rgb), 0.35);
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================
   Albayan Brand Utilities (used across UI)
   ========================================== */
.alb-mark {
  background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-blue) 72%);
  box-shadow: 0 18px 40px -26px rgba(var(--brand-blue-rgb), 0.55);
}

.alb-mark-dot {
  position: relative;
}

.alb-mark-dot::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--brand-pink), #ff7ab7);
  bottom: -6px;
  right: -6px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 20px -14px rgba(var(--brand-pink-rgb), 0.55);
}

.dark .alb-mark-dot::after {
  border-color: rgba(15, 23, 42, 0.9);
}

.alb-btn-primary {
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-teal) 100%);
  box-shadow: 0 12px 24px -18px rgba(var(--brand-blue-rgb), 0.55);
}

.alb-btn-primary:hover {
  filter: saturate(1.05) brightness(0.98);
  box-shadow: 0 16px 30px -20px rgba(var(--brand-teal-rgb), 0.45);
}

.alb-btn-primary:active {
  filter: saturate(1.02) brightness(0.96);
}

.alb-nav-active {
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-teal) 100%);
  color: white;
  box-shadow: 0 12px 24px -18px rgba(var(--brand-blue-rgb), 0.55);
}

.alb-link {
  color: var(--brand-blue);
}

.alb-link:hover {
  color: var(--brand-blue-700);
}

.alb-hover-brand:hover {
  color: var(--brand-blue) !important;
}

.alb-hero {
  background: linear-gradient(
    135deg,
    rgba(var(--brand-blue-rgb), 0.08),
    rgba(var(--brand-teal-rgb), 0.08),
    rgba(var(--brand-pink-rgb), 0.06)
  );
  border: 1px solid rgba(var(--brand-blue-rgb), 0.18);
}

.dark .alb-hero {
  background: linear-gradient(
    135deg,
    rgba(var(--brand-blue-rgb), 0.16),
    rgba(var(--brand-teal-rgb), 0.10),
    rgba(var(--brand-pink-rgb), 0.06)
  );
  border-color: rgba(var(--brand-teal-rgb), 0.16);
}

.alb-gradient-text {
  background-image: linear-gradient(90deg, var(--brand-blue), var(--brand-teal), var(--brand-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Tailwind "primary" remap → Albayan brand (keeps templates consistent without rewriting every class) */
.text-indigo-600 { color: var(--brand-blue) !important; }
.text-indigo-700 { color: var(--brand-blue-700) !important; }
.text-indigo-400 { color: rgba(var(--brand-blue-rgb), 0.65) !important; }
.bg-indigo-600 { background-color: var(--brand-blue) !important; }
.bg-indigo-700 { background-color: var(--brand-blue-700) !important; }
.border-indigo-200 { border-color: rgba(var(--brand-blue-rgb), 0.22) !important; }
.border-indigo-400 { border-color: rgba(var(--brand-blue-rgb), 0.45) !important; }
.hover\:text-indigo-700:hover { color: var(--brand-blue-700) !important; }
.hover\:text-indigo-600:hover { color: var(--brand-blue) !important; }
.hover\:bg-indigo-700:hover { background-color: var(--brand-blue-700) !important; }
.hover\:border-indigo-400:hover { border-color: rgba(var(--brand-blue-rgb), 0.45) !important; }

/* Tailwind gradients commonly used for the primary brand flow */
.from-indigo-500,
.from-indigo-600 {
  --tw-gradient-from: var(--brand-blue) !important;
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgba(var(--brand-blue-rgb), 0)) !important;
}

.to-purple-500,
.to-purple-600 {
  --tw-gradient-to: var(--brand-teal) !important;
}

/* Aurora background blobs (keep the effect, but constrain to brand colors + softer alpha) */
.alb-aurora-1 {
  background: linear-gradient(
    90deg,
    rgba(var(--brand-blue-rgb), 0.45),
    rgba(var(--brand-pink-rgb), 0.38),
    rgba(var(--brand-teal-rgb), 0.42)
  );
}

.alb-aurora-2 {
  background: linear-gradient(
    90deg,
    rgba(var(--brand-teal-rgb), 0.42),
    rgba(var(--brand-blue-rgb), 0.38),
    rgba(var(--brand-pink-rgb), 0.40)
  );
}

.alb-aurora-3 {
  background: linear-gradient(
    90deg,
    rgba(var(--brand-pink-rgb), 0.38),
    rgba(var(--brand-blue-rgb), 0.34)
  );
}

/* Button Shine Effect */
.btn-shine {
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.btn-shine::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: 0.5s;
}

.btn-shine:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn-shine:hover::after {
  left: 100%;
}

.btn-shine:active {
  transform: translateY(0);
}

/* Utility Classes */
.custom-scrollbar {
  overflow-y: auto;
}

.animate-shake {
  animation: shake 0.3s ease-in-out;
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
}

[dir="rtl"] .space-x-reverse > * + * {
  margin-right: 0.75rem;
  margin-left: 0;
}

/* Notification Animations */
@keyframes slideIn {
  from {
    transform: translateX(400px) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateX(-10px) scale(1.02);
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  to {
    transform: translateX(400px) scale(0.8);
    opacity: 0;
  }
}

.notification-enter {
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.notification-exit {
  animation: slideOut 0.3s ease-in;
}

/* Table Styles */
table {
  border-collapse: collapse;
  width: 100%;
}

table th {
  text-align: left;
  font-weight: 600;
  padding: 12px;
  border-bottom: 2px solid rgba(var(--brand-blue-rgb), 0.28);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, rgba(var(--brand-blue-rgb), 0.06), transparent);
}

table td {
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

table tbody tr {
  transition: all 0.2s ease;
}

table tbody tr:hover {
  background: linear-gradient(90deg, rgba(var(--brand-teal-rgb), 0.07), rgba(var(--brand-blue-rgb), 0.05));
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(var(--brand-blue-rgb), 0.08);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.status-pending {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
  color: rgb(217, 119, 6);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.status-completed {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.15));
  color: rgb(5, 150, 105);
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.status-canceled {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(220, 38, 38, 0.15));
  color: rgb(185, 28, 28);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.status-lost {
  background: linear-gradient(135deg, rgba(107, 114, 128, 0.2), rgba(75, 85, 99, 0.15));
  color: rgb(55, 65, 81);
  border: 1px solid rgba(107, 114, 128, 0.4);
}

/* Delivery Status Badges */
.delivery-needs {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
  color: rgb(217, 119, 6);
  border: 1px solid rgba(251, 191, 36, 0.4);
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.2);
}

.delivery-progress {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.15));
  color: rgb(29, 78, 216);
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.delivery-delivered {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.15));
  color: rgb(5, 150, 105);
  border: 1px solid rgba(34, 197, 94, 0.4);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.delivery-office {
  background: linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.16), rgba(var(--brand-teal-rgb), 0.10));
  color: var(--brand-blue-700);
  border: 1px solid rgba(var(--brand-blue-rgb), 0.32);
  box-shadow: 0 2px 8px rgba(var(--brand-blue-rgb), 0.12);
}

/* Payment Method Badges */
.payment-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.16), rgba(var(--brand-teal-rgb), 0.10));
  color: var(--brand-blue-700);
  border: 1px solid rgba(var(--brand-blue-rgb), 0.24);
  box-shadow: 0 2px 6px rgba(var(--brand-blue-rgb), 0.12);
}

/* Loading Spinner */
.spinner {
  border: 3px solid rgba(var(--brand-blue-rgb), 0.14);
  border-radius: 50%;
  border-top: 3px solid var(--brand-blue);
  border-right: 3px solid var(--brand-teal);
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  box-shadow: 0 2px 10px rgba(var(--brand-blue-rgb), 0.16);
}

@keyframes spin {
  0% { 
    transform: rotate(0deg);
    border-top-color: var(--brand-blue);
    border-right-color: var(--brand-teal);
  }
  50% {
    border-top-color: var(--brand-teal);
    border-right-color: var(--brand-pink);
  }
  100% { 
    transform: rotate(360deg);
    border-top-color: var(--brand-blue);
    border-right-color: var(--brand-teal);
  }
}

/* Fade In Animation */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal Overlay */
.modal-overlay {
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Split Payment Item */
.split-payment-item {
  background: linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.08), rgba(var(--brand-teal-rgb), 0.05));
  border: 1px solid rgba(var(--brand-blue-rgb), 0.18);
  border-radius: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(var(--brand-blue-rgb), 0.05);
}

.split-payment-item:hover {
  background: linear-gradient(135deg, rgba(var(--brand-blue-rgb), 0.12), rgba(var(--brand-teal-rgb), 0.08));
  border-color: rgba(var(--brand-blue-rgb), 0.26);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--brand-blue-rgb), 0.12);
}

/* Top-up Badge */
.topup-badge {
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-teal) 60%, var(--brand-pink) 120%);
  color: white;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 12px rgba(var(--brand-blue-rgb), 0.25);
  animation: pulse 3s ease-in-out infinite;
}

/* Reconciliation Status */
.recon-match {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
  border-left: 4px solid rgb(34, 197, 94);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.1);
}

.recon-overspent {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border-left: 4px solid rgb(239, 68, 68);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.1);
}

.recon-underspent {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05));
  border-left: 4px solid rgb(251, 191, 36);
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.1);
}

/* Audit Log Item */
.audit-log-item {
  border-left: 4px solid;
  padding-left: 1rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
  border-radius: 0.5rem;
}

.audit-log-item:hover {
  transform: translateX(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.audit-login {
  border-color: rgb(34, 197, 94);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.1), transparent);
}

.audit-logout {
  border-color: rgb(107, 114, 128);
  background: linear-gradient(90deg, rgba(107, 114, 128, 0.1), transparent);
}

.audit-create {
  border-color: rgb(59, 130, 246);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.1), transparent);
}

.audit-update {
  border-color: rgb(251, 191, 36);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), transparent);
}

.audit-delete {
  border-color: rgb(239, 68, 68);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.1), transparent);
}

.audit-collect {
  border-color: rgb(34, 197, 94);
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.1), transparent);
}

/* Stats Card */
.stat-card {
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0)
  );
  transform: rotate(30deg);
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 20px 50px -10px rgba(var(--brand-blue-rgb), 0.22);
}

/* Command Palette Styles */
.command-palette {
  max-height: 400px;
  overflow-y: auto;
}

.command-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 0.5rem;
  margin: 0.25rem 0;
}

.command-item:hover,
.command-item.selected {
  background: linear-gradient(90deg, rgba(var(--brand-blue-rgb), 0.12), rgba(var(--brand-teal-rgb), 0.08));
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(var(--brand-blue-rgb), 0.08);
}

/* Responsive Sidebar */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  
  #sidebar.mobile-open {
    transform: translateX(0);
  }
}

/* Print Styles */
@media print {
  @page {
    size: landscape;
    margin: 2mm;
  }
  
  body {
    background: white !important;
    color: black !important;
    zoom: 0.8;
  }
  
  #sidebar,
  header,
  nav,
  button,
  .no-print,
  #sync-status-container,
  #notification-container {
    display: none !important;
  }
  
  .glass-panel {
    background: none !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }
  
  .bg-noise,
  #aurora-bg {
    display: none;
  }
  
  table {
    page-break-inside: auto;
  }
  
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
}

/* Cloud Sync Indicator */
.sync-pulse {
  animation: syncPulse 2s ease-in-out infinite;
}

@keyframes syncPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(var(--brand-blue-rgb), 0.55);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.15);
    box-shadow: 0 0 0 8px rgba(var(--brand-blue-rgb), 0);
  }
}

/* Error Boundary */
.error-boundary {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.08));
  border: 2px solid rgb(239, 68, 68);
  border-radius: 1rem;
  padding: 2rem;
  margin: 2rem;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.2);
}

/* Toast notifications positioning */
#notification-container {
  pointer-events: none;
}

#notification-container > * {
  pointer-events: auto;
}

/* Animation delays */
.animation-delay-2000 {
  animation-delay: 2s;
}

.animation-delay-4000 {
  animation-delay: 4s;
}

/* Smooth transitions */
* {
  transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

button,
a,
input,
select,
textarea {
  transition: all 0.2s ease;
}

/* Focus visible for accessibility */
*:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

/* Disabled state */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Selection color */
::selection {
  background: var(--brand-blue);
  color: white;
}

::-moz-selection {
  background: var(--brand-blue);
  color: white;
}

/* Customer Search Dropdown */
.customer-option {
  transition: all 0.15s ease;
}

.customer-option:hover {
  transform: translateX(6px);
  background: linear-gradient(90deg, rgba(var(--brand-blue-rgb), 0.10), rgba(var(--brand-teal-rgb), 0.06)) !important;
  box-shadow: 0 2px 8px rgba(var(--brand-blue-rgb), 0.08);
}

/* Customer Confirmation Panel */
#ad-customer-confirmation,
#receipt-customer-confirmation {
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Dropdown scroll */
[id$="-dropdown"] {
  scrollbar-width: thin;
}

[id$="-dropdown"]::-webkit-scrollbar {
  width: 4px;
}

[id$="-dropdown"]::-webkit-scrollbar-thumb {
  background: rgba(var(--brand-blue-rgb), 0.35);
  border-radius: 100px;
}

/* Advanced Delivery Operations Animations */
.animate-fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

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

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-pulse-slow {
  animation: pulseSlow 2s ease-in-out infinite;
}

@keyframes pulseSlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(var(--brand-blue-rgb), 0.35);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px 5px rgba(var(--brand-blue-rgb), 0.16);
  }
}

/* Glass Panel Small Variant */
.glass-panel-sm {
  background: var(--glass-bg);
  border: var(--glass-border);
  box-shadow: 0 4px 16px 0 rgba(31, 38, 135, 0.05);
  transition: all 0.3s ease;
}

@supports (backdrop-filter: blur(12px)) {
  .glass-panel-sm {
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
  }
}

.glass-panel-sm:hover {
  box-shadow: 0 8px 24px -5px rgba(var(--brand-blue-rgb), 0.12);
  border-color: rgba(var(--brand-blue-rgb), 0.26);
}

/* Delivery Status Badge Enhanced */
.delivery-needsdelivery {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(245, 158, 11, 0.2));
  color: rgb(180, 83, 9);
  border: 1px solid rgba(251, 191, 36, 0.5);
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.25);
}

.delivery-inprogress {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(37, 99, 235, 0.2));
  color: rgb(29, 78, 216);
  border: 1px solid rgba(59, 130, 246, 0.5);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.25);
}

.delivery-canceled {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(220, 38, 38, 0.2));
  color: rgb(185, 28, 28);
  border: 1px solid rgba(239, 68, 68, 0.5);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}

/* Usage Status Badges */
.status-unused {
  background: linear-gradient(135deg, rgba(107, 114, 128, 0.2), rgba(75, 85, 99, 0.15));
  color: rgb(55, 65, 81);
  border: 1px solid rgba(107, 114, 128, 0.4);
}

.status-partially-used {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.15));
  color: rgb(29, 78, 216);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.status-fully-used {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.15));
  color: rgb(5, 150, 105);
  border: 1px solid rgba(34, 197, 94, 0.4);
}

/* Gradient Text */
.bg-clip-text {
  -webkit-background-clip: text;
  background-clip: text;
}

/* Shake Animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Pipeline Stage Hover Effect */
.pipeline-stage:hover {
  transform: scale(1.1);
}

.pipeline-stage:hover .pipeline-icon {
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Table Row Animation */
.delivery-table-row {
  animation: slideInRow 0.3s ease-out;
}

@keyframes slideInRow {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Card Hover Lift Effect */
.card-hover-lift {
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px -10px rgba(var(--brand-blue-rgb), 0.18);
}

/* Urgent Badge Pulse */
.urgent-pulse {
  animation: urgentPulse 1.5s ease-in-out infinite;
}

@keyframes urgentPulse {
  0%, 100% {
    background-color: rgb(239, 68, 68);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    background-color: rgb(248, 113, 113);
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
}

/* Driver Card Highlight */
.driver-top-performer {
  position: relative;
}

.driver-top-performer::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #f59e0b, #eab308, #f59e0b);
  border-radius: inherit;
  z-index: -1;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ==========================================
   MOBILE-RESPONSIVE TABLES & LAYOUTS
   ========================================== */

/* On mobile, make table rows display as cards */
@media (max-width: 768px) {
  /* Table becomes a card stack on mobile */
  .glass-panel table {
    display: block;
    overflow-x: visible;
  }

  .glass-panel table thead {
    display: none; /* Hide header on mobile */
  }

  .glass-panel table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .glass-panel table tbody tr {
    display: flex;
    flex-wrap: wrap;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(var(--brand-blue-rgb), 0.1);
    border-radius: 1rem;
    gap: 0.5rem;
    align-items: center;
  }

  .dark .glass-panel table tbody tr {
    background: rgba(15, 23, 42, 0.5);
    border-color: rgba(var(--brand-teal-rgb), 0.1);
  }

  .glass-panel table tbody tr td {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0.5rem;
    border: none;
    min-width: 0;
    flex-shrink: 0;
  }

  /* Make certain columns take full width on mobile */
  .glass-panel table tbody tr td:first-child {
    flex-basis: 100%;
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(var(--brand-blue-rgb), 0.1);
    padding-bottom: 0.75rem;
  }

  /* Actions column stays at the end */
  .glass-panel table tbody tr td:last-child {
    flex-basis: 100%;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(var(--brand-blue-rgb), 0.1);
    justify-content: center;
  }

  .glass-panel table tbody tr td:last-child > div {
    justify-content: center;
    gap: 0.75rem;
  }

  /* Style action buttons for mobile */
  .glass-panel table tbody tr td:last-child button {
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: rgba(var(--brand-blue-rgb), 0.1);
  }

  /* Add data labels before content on mobile (via pseudo-elements) */
  .glass-panel table tbody tr td::before {
    content: attr(data-label);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-blue);
    opacity: 0.7;
    margin-bottom: 0.25rem;
  }
}

/* Mobile-responsive header sections */
@media (max-width: 640px) {
  /* Stack header title and buttons vertically */
  .flex.justify-between.items-center {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }

  /* Full-width buttons on mobile */
  .flex.justify-between.items-center .btn-shine,
  .flex.justify-between.items-center button {
    width: 100%;
    justify-content: center;
  }

  /* Stack filter dropdowns */
  .flex.flex-wrap.gap-2 {
    flex-direction: column;
    width: 100%;
  }

  .flex.flex-wrap.gap-2 > select,
  .flex.flex-wrap.gap-2 > button {
    width: 100%;
  }

  /* Reduce heading sizes on mobile */
  h1.text-3xl {
    font-size: 1.5rem;
  }

  h2.text-2xl {
    font-size: 1.25rem;
  }

  /* Smaller stat cards on mobile */
  .stat-card {
    padding: 0.75rem 1rem;
  }

  .stat-card .text-3xl,
  .stat-card .text-2xl {
    font-size: 1.25rem;
  }
}

/* Ensure cards don't overflow on mobile */
@media (max-width: 768px) {
  .glass-panel,
  .glass-panel-sm {
    max-width: 100%;
    overflow: hidden;
  }

  /* Prevent horizontal scroll from content */
  .glass-panel > *,
  .glass-panel-sm > * {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

  /* Grid should be single column on mobile */
  .grid.grid-cols-2,
  .grid.grid-cols-3,
  .grid.grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Exception: small stat grids can be 2 columns */
  .grid.grid-cols-2.gap-3,
  .grid.grid-cols-2.gap-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Modal responsiveness */
@media (max-width: 768px) {
  /* Full-screen modals on mobile */
  .fixed.inset-0 > .glass-panel,
  .fixed.inset-0 > div > .glass-panel {
    max-height: 95vh;
    max-width: 95vw;
    margin: 0.5rem;
    border-radius: 1rem;
  }

  /* Modal content scrollable */
  .fixed.inset-0 .overflow-y-auto {
    max-height: calc(95vh - 120px);
  }

  /* Modal form inputs full width */
  .fixed.inset-0 input,
  .fixed.inset-0 select,
  .fixed.inset-0 textarea {
    width: 100%;
    font-size: 16px; /* Prevent iOS zoom */
  }
}

/* Delivery Dashboard Mobile Optimization */
@media (max-width: 768px) {
  /* Stat cards in a 2x2 grid on mobile */
  .delivery-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .delivery-stats-grid > * {
    padding: 0.75rem;
  }

  /* Delivery card actions */
  .delivery-card-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .delivery-card-actions button {
    width: 100%;
  }
}

/* Analytics View Mobile */
@media (max-width: 768px) {
  /* Analytics stat cards */
  .analytics-stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-stat-cards .glass-panel {
    padding: 0.75rem;
  }

  .analytics-stat-cards .text-2xl {
    font-size: 1.125rem;
  }
}

/* ==========================================
   MOBILE & TOUCH DEVICE FIXES
   ========================================== */

/* Disable hover effects on touch devices to prevent "sticky hover" */
@media (hover: none) {
  .card-hover-lift:hover,
  .pipeline-stage:hover,
  .glass-panel:hover {
    transform: none !important;
    box-shadow: inherit;
  }
  
  /* Use active state instead of hover for touch feedback */
  .card-hover-lift:active,
  .pipeline-stage:active,
  .glass-panel:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

/* Platform-specific body classes */
body.is-touch,
body.no-hover {
  /* Disable all hover animations on touch devices */
  --hover-scale: 1;
  --hover-lift: 0;
}

body.is-touch *:hover {
  /* Prevent hover states from getting "stuck" on touch */
  transition-delay: 0s !important;
}

/* Ensure minimum touch target sizes (44x44 as per Apple HIG) */
body.is-mobile button,
body.is-mobile a,
body.is-mobile [role="button"],
body.is-mobile input[type="checkbox"],
body.is-mobile input[type="radio"],
body.is-mobile select {
  min-height: 44px;
  min-width: 44px;
}

body.is-mobile input[type="text"],
body.is-mobile input[type="email"],
body.is-mobile input[type="password"],
body.is-mobile input[type="number"],
body.is-mobile input[type="tel"],
body.is-mobile textarea,
body.is-mobile select {
  /* Prevent iOS zoom on input focus (requires 16px+ font) */
  font-size: 16px !important;
}

/* Fix for Capacitor iOS safe areas */
body.platform-ios {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Fix for iOS momentum scrolling */
body.platform-ios .overflow-y-auto,
body.platform-ios .overflow-auto {
  -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on interactive elements (mobile) */
body.is-mobile button,
body.is-mobile a,
body.is-mobile [role="button"] {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Smooth transitions for mobile */
body.is-mobile * {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

/* Fix for Android keyboard pushing content */
body.platform-android {
  height: 100%;
  overflow: hidden;
}

body.platform-android #app {
  height: 100%;
  overflow-y: auto;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile sidebar fixes */
@media (max-width: 768px) {
  body.is-mobile .sidebar,
  body.is-mobile nav {
    /* Ensure sidebar is touchable and doesn't overlap content */
    z-index: 1000;
  }
  
  /* Increase tap targets on mobile */
  body.is-mobile .nav-item,
  body.is-mobile .menu-item {
    padding: 12px 16px;
    min-height: 48px;
    display: flex;
    align-items: center;
  }
}

/* Fix viewport issues on mobile */
html {
  /* Prevent horizontal scroll */
  overflow-x: hidden;
  /* Fix for 100vh on mobile browsers */
  height: -webkit-fill-available;
}

body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

