/* Complete redesign with horizontal/vertical timeline */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-blue: #8b3ea8; /* QDS purple */
  --primary-dark: #6f2f86; /* darker purple */
  --secondary-blue: #f0e1f7; /* light purple tint */
  --success-green: #00b341;
  --warning-orange: #ff6b35;
  --error-red: #dc3545;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #374151;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(rgba(255,255,255,0.895), rgba(255,255,255,0.895)), url('doodle.jpg') center center/cover no-repeat fixed;
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
}

.bex-page-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 80px;
  position: relative;
}

/* Header */
.bex-header {
  text-align: center;
  padding: 60px 20px 40px;
}

.bex-logo {
  width: 220px;
  max-width: 45vw;
  height: auto;
  margin: 24px auto 0 auto;
  display: block;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
}

.bex-logo:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-xl);
}

.bex-title {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
}

.bex-subtitle {
  font-size: 1.25rem;
  color: var(--gray-500);
  font-weight: 400;
  margin-bottom: 0;
  margin-top: 0.5rem;
  letter-spacing: 0.01em;
  line-height: 1.4;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
}

.bex-header-card {
  display: inline-block;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 8px 32px 0 rgba(0,0,0,0.18), 0 1.5px 6px 0 rgba(0,0,0,0.10);
  border-radius: 20px;
  padding: 32px 40px 28px 40px;
  margin-top: 32px;
  margin-bottom: 0;
  text-align: center;
  transition: box-shadow 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.bex-header-card:hover {
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.18), 0 3px 12px 0 rgba(0,0,0,0.11);
  transform: translateY(-2px) scale(1.01);
}

/* Main container */
.bex-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 60px;
  width: 100%;
}

/* Search card */
.bex-input-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  margin: 0 auto 50px;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  transition: box-shadow 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.bex-input-card:hover {
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.18), 0 3px 12px 0 rgba(0,0,0,0.11);
  transform: translateY(-2px) scale(1.01);
}

.waybill-search-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bex-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.waybill-search-input {
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px 20px;
  font-size: 1.1rem;
  color: var(--gray-800);
  outline: none;
  transition: all 0.3s ease;
  font-weight: 500;
}

.waybill-search-input:focus {
  border-color: var(--primary-blue);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.waybill-search-input::placeholder {
  color: var(--gray-400);
}

.waybill-search-button {
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow-md);
}

.waybill-search-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Timeline container */
.bex-timeline-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  /* Allow the card height to naturally adjust so padding is consistent */
  min-height: auto;
  transition: box-shadow 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
}
.bex-timeline-card:hover {
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.18), 0 3px 12px 0 rgba(0,0,0,0.11);
  transform: translateY(-2px) scale(1.01);
}

/* Tracking area container - now directly in main without parent card */
#tracking_area {
  margin-top: 24px;
  margin-bottom: 24px;
}

/* Timeline cards container for multiple waybills */
.timeline-cards-container {
  display: none;
}

/* Individual timeline wrapper */
.timeline-wrapper {
  position: relative;
  background: var(--white);
  border-radius: 20px;
  padding: 40px;
  transition: all 0.3s ease;
  margin-bottom: 32px; /* Add space between cards */
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
}

.timeline-wrapper:last-child {
  margin-bottom: 0;
}

.timeline-wrapper:hover {
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.18), 0 3px 12px 0 rgba(0,0,0,0.11);
  transform: translateY(-2px) scale(1.01);
}

/* Waybill title card */
.waybill-title-card {
  position: absolute;
  top: 18px; /* further inside card */
  left: 20px;
  background: var(--primary-blue);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(139, 62, 168, 0.3);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

.waybill-label {
  opacity: 0.9;
  font-weight: 400;
}

.waybill-number {
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Adjust timeline padding when waybill title is present */
.timeline-wrapper .tracking-timeline {
  margin-top: 20px;
}

/* Desktop horizontal timeline */
.tracking-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  padding: 40px 0;
  z-index: 0; /* establish baseline stacking context below events/icons */
}

/* Base connector (gray) across the full span) */
.tracking-timeline::before,
.tracking-timeline::after {
  content: '';
  position: absolute;
  top: 96px; /* center line after additional padding added to tracking-event */
  height: 4px;
  border-radius: 2px;
  z-index: 0; /* keep connector behind events/icons */
}

  /* Base connector (always grey) */
  .tracking-timeline::before {
    left: var(--line-left, 0px);
    width: var(--base-progress-px, 0px);
    background: var(--gray-200);
    transition: width 0.8s ease-out;
  }

/* Progress connector (red) grows from the left on desktop) */
.tracking-timeline::after {
  left: var(--line-left, 0px);
  width: var(--progress-px, 0px);
  background: var(--primary-blue);
  transition: width 0.8s ease-out;
}

@media (max-width: 768px) {
  .tracking-timeline::before {
    height: var(--base-progress-px, 0px);
    transition: height 0.8s ease-out;
  }
  .tracking-timeline::after {
    height: var(--progress-px, 0px);
    transition: height 0.8s ease-out;
  }
}

/* Disable old gradient animation */
.tracking-timeline.animate::before {
  animation: none !important;
}

.tracking-event {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  width: 100%;
  flex: 1;
  max-width: 160px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
  padding: 16px 8px;
  border-radius: 16px;
  background: transparent;
  border: 2px solid transparent;
  z-index: 1; /* ensure events sit above connector */
}

.tracking-event:hover, .tracking-event:focus {
  transform: scale(1.05) translateY(-4px);
  z-index: 110; /* elevate hovered event above footer (z-index 100) */
  box-shadow: 
    0 12px 40px 0 rgba(139, 62, 168, 0.15), 
    0 4px 12px 0 rgba(0,0,0,0.08),
    0 0 0 1px rgba(139, 62, 168, 0.1);
  background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--white) 100%);
  border-color: rgba(139, 62, 168, 0.2);
}

.tracking-event:hover .status-icon,
.tracking-event:focus .status-icon {
  transform: scale(1.1);
  box-shadow: 
    0 8px 24px 0 rgba(139, 62, 168, 0.25),
    0 0 0 4px rgba(139, 62, 168, 0.1);
}

.tracking-event:hover .event-header,
.tracking-event:focus .event-header {
  color: var(--primary-blue);
  transform: translateY(-2px);
}

.tracking-event:hover .event-subheader,
.tracking-event:focus .event-subheader {
  color: var(--gray-700);
}

/* Add a subtle ripple effect on hover */
.tracking-event::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 62, 168, 0.1) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  transition: all 0.6s cubic-bezier(0.4,0,0.2,1);
  pointer-events: none;
  z-index: -1;
}

.tracking-event:hover::before,
.tracking-event:focus::before {
  width: 200px;
  height: 200px;
  opacity: 1;
}

/* Enhanced focus styles for accessibility */
.tracking-event:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .tracking-event,
  .tracking-event *,
  .status-icon,
  .status-icon::before,
  .status-icon::after {
    transition: none !important;
    animation: none !important;
  }
}
.timeline-tooltip {
  position: absolute;
  left: 50%;
  bottom: 110%;
  transform: translateX(-50%) scale(0.98);
  min-width: 180px;
  max-width: 260px;
  background: rgba(30,41,59,0.97);
  color: #fff;
  font-size: 0.97rem;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 6px 24px 0 rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s cubic-bezier(0.4,0,0.2,1), transform 0.18s cubic-bezier(0.4,0,0.2,1);
  white-space: pre-line;
  text-align: left;
  line-height: 1.5;
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  z-index: 120; /* ensure tooltip overlays footer and other elements */
}

/* When the current-step-card is present, push tooltip further up */
.tracking-event.has-current-card .timeline-tooltip {
  bottom: calc(110% + 42px); /* 42px approximates card height + gap */
}

.tracking-event.show-tooltip .timeline-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

/* Ensure event with visible tooltip is above footer and other fixed elements */
.tracking-event.show-tooltip {
  z-index: 110 !important; /* above footer's z-index (100) */
}

.tracking-timeline.animate .tracking-event {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

.tracking-timeline.animate .tracking-event:nth-child(1) { animation-delay: 0.1s; }
.tracking-timeline.animate .tracking-event:nth-child(2) { animation-delay: 0.2s; }
.tracking-timeline.animate .tracking-event:nth-child(3) { animation-delay: 0.3s; }
.tracking-timeline.animate .tracking-event:nth-child(4) { animation-delay: 0.4s; }
.tracking-timeline.animate .tracking-event:nth-child(5) { animation-delay: 0.5s; }
.tracking-timeline.animate .tracking-event:nth-child(6) { animation-delay: 0.6s; }

.status-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--white);
  border: 4px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
  z-index: 2; /* ensure icons sit above connector and events */
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Add a subtle glow effect behind the icon */
.status-icon::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 62, 168, 0.1) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
  z-index: -1;
}

.tracking-event:hover .status-icon::before,
.tracking-event:focus .status-icon::before {
  transform: translate(-50%, -50%) scale(1.2);
}

/* Status-specific icons with SVG backgrounds */
.status-icon[data-status="created"] {
  border-color: var(--primary-blue);
  background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--white) 100%);
}

.status-icon[data-status="created"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url('icons/created.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="created"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="created"]::after {
    width: 20px;
    height: 20px;
  }
}

.status-icon[data-status="collected"] {
  border-color: var(--primary-blue);
  background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--white) 100%);
}

.status-icon[data-status="collected"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url('icons/collected.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="collected"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="collected"]::after {
    width: 20px;
    height: 20px;
  }
}

.status-icon[data-status="transit"] {
  border-color: var(--primary-blue);
  background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--white) 100%);
}

.status-icon[data-status="transit"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url('icons/transit.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="transit"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="transit"]::after {
    width: 20px;
    height: 20px;
  }
}

.status-icon[data-status="out"] {
  border-color: var(--warning-orange);
  background: linear-gradient(135deg, #fff7ed 0%, var(--white) 100%);
}

.status-icon[data-status="out"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url('icons/delivery.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="out"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="out"]::after {
    width: 20px;
    height: 20px;
  }
}

.status-icon[data-status="delivered"] {
  border-color: var(--success-green);
  background: linear-gradient(135deg, #f0fdf4 0%, var(--white) 100%);
}

.status-icon[data-status="delivered"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url('icons/delivered.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="delivered"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="delivered"]::after {
    width: 20px;
    height: 20px;
  }
}

.status-icon[data-status="failed"] {
  border-color: var(--error-red);
  background: linear-gradient(135deg, #fef2f2 0%, var(--white) 100%);
}

.status-icon[data-status="failed"]::after {
  content: '';
  width: 32px;
  height: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.5' stroke='%23dc3545'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z' /%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: block;
}

@media (max-width: 768px) {
  .status-icon[data-status="failed"]::after {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 480px) {
  .status-icon[data-status="failed"]::after {
    width: 20px;
    height: 20px;
  }
}

.tracking-event.pending .status-icon {
  border-color: var(--gray-300);
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
  box-shadow: var(--shadow-sm);
}

.tracking-event.pending .event-header {
  color: var(--gray-500);
}

.tracking-event.pending .event-subheader {
  color: var(--gray-400);
}

.tracking-event.pending:hover,
.tracking-event.pending:focus {
  box-shadow: 
    0 12px 40px 0 rgba(100, 116, 139, 0.15), 
    0 4px 12px 0 rgba(0,0,0,0.08),
    0 0 0 1px rgba(100, 116, 139, 0.1);
  background: linear-gradient(135deg, var(--gray-100) 0%, var(--white) 100%);
  border-color: rgba(100, 116, 139, 0.2);
}

.tracking-event.pending:hover .status-icon,
.tracking-event.pending:focus .status-icon {
  box-shadow: 
    0 8px 24px 0 rgba(100, 116, 139, 0.2),
    0 0 0 4px rgba(100, 116, 139, 0.1);
}

.tracking-event.pending::before {
  background: radial-gradient(circle, rgba(100, 116, 139, 0.08) 0%, transparent 70%);
}

.tracking-event.pending:hover .event-header,
.tracking-event.pending:focus .event-header {
  color: var(--gray-600);
}

.tracking-event.completed .status-icon {
  border-color: var(--success-green);
  background: linear-gradient(135deg, #f0fdf4 0%, var(--white) 100%);
  box-shadow: 0 0 20px rgba(0, 179, 65, 0.2);
}

.tracking-event.completed:hover,
.tracking-event.completed:focus {
  box-shadow: 
    0 12px 40px 0 rgba(0, 179, 65, 0.2), 
    0 4px 12px 0 rgba(0,0,0,0.08),
    0 0 0 1px rgba(0, 179, 65, 0.15);
  background: linear-gradient(135deg, #f0fdf4 0%, var(--white) 100%);
  border-color: rgba(0, 179, 65, 0.3);
}

.tracking-event.completed:hover .status-icon,
.tracking-event.completed:focus .status-icon {
  box-shadow: 
    0 8px 24px 0 rgba(0, 179, 65, 0.3),
    0 0 0 4px rgba(0, 179, 65, 0.15);
}

.tracking-event.completed::before {
  background: radial-gradient(circle, rgba(0, 179, 65, 0.1) 0%, transparent 70%);
}

/* Update icon when stage is completed */
.tracking-event.completed .status-icon[data-status="created"]::after,
.tracking-event.completed .status-icon[data-status="collected"]::after,
.tracking-event.completed .status-icon[data-status="transit"]::after,
.tracking-event.completed .status-icon[data-status="out"]::after,
.tracking-event.completed .status-icon[data-status="delivered"]::after {
  opacity: 1;
  transform: scale(1.1);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Enhanced icon hover effects for all status icons */
.status-icon::after {
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.tracking-event:hover .status-icon::after,
.tracking-event:focus .status-icon::after {
  transform: scale(1.15);
  filter: brightness(1.1);
}

.tracking-event.warning .status-icon {
  border-color: var(--warning-orange);
  background: linear-gradient(135deg, #fff7ed 0%, var(--white) 100%);
  box-shadow: 0 0 20px rgba(255, 107, 53, 0.2);
}

.tracking-event.warning:hover,
.tracking-event.warning:focus {
  box-shadow: 
    0 12px 40px 0 rgba(255, 107, 53, 0.2), 
    0 4px 12px 0 rgba(0,0,0,0.08),
    0 0 0 1px rgba(255, 107, 53, 0.15);
  background: linear-gradient(135deg, #fff7ed 0%, var(--white) 100%);
  border-color: rgba(255, 107, 53, 0.3);
}

.tracking-event.warning:hover .status-icon,
.tracking-event.warning:focus .status-icon {
  box-shadow: 
    0 8px 24px 0 rgba(255, 107, 53, 0.3),
    0 0 0 4px rgba(255, 107, 53, 0.15);
}

.tracking-event.warning::before {
  background: radial-gradient(circle, rgba(255, 107, 53, 0.1) 0%, transparent 70%);
}

.event-details {
  text-align: center;
}

.event-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.event-subheader {
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.4;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.event-subheader .date {
  display: block;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 2px;
}

.event-subheader .time {
  display: block;
  font-weight: 400;
  color: var(--gray-500);
  font-size: 0.75rem;
}

/* Footer */
.bex-footer {
  background: var(--gray-100);
  border-top: 1px solid var(--gray-200);
  padding: 24px 20px;
  margin-top: auto;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
}

.bex-footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.9rem;
  color: var(--gray-600);
}

.bex-footer-link {
  color: var(--primary-blue);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.bex-footer-link:hover {
  color: var(--primary-dark);
}

/* Utility classes */
.d-none {
  display: none !important;
}

/* Animations */
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* New: keep horizontal centering during card animation to avoid snap */
@keyframes fadeInUpCentered {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes subtlePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.02);
    opacity: 0.9;
  }
}

/* Add subtle pulse to current step */
.tracking-event.has-current-card .status-icon {
  animation: subtlePulse 3s ease-in-out infinite;
}

@keyframes expandLine {
  to {
    width: 75%;
    transform: translateX(-50%);
  }
}

@keyframes expandLineAnimate {
  from {
    width: 0;
  }
  to {
    width: 75%;
  }
}

@keyframes expandLineVertical {
  to {
    height: calc(100% - 60px);
    transform: translateY(-50%);
  }
}

@keyframes expandLineVerticalAnimate {
  from {
    height: 0;
  }
  to {
    height: calc(100% - 60px);
  }
}

/* Mobile responsive - vertical timeline */
@media (max-width: 768px) {
  .bex-logo {
    width: 180px;
    max-width: 60vw;
  }

  .bex-title {
    font-size: 2.5rem;
  }

  .bex-subtitle {
    font-size: 1rem;
  }

  .bex-input-card {
    margin: 0 auto 30px;
    padding: 30px 24px;
  }

  .bex-timeline-card {
    box-shadow: 0 4px 16px 0 rgba(0,0,0,0.10), 0 1px 3px 0 rgba(0,0,0,0.06);
    border-width: 1px;
    border-radius: 16px;
    padding: 30px 20px;
  }

  /* Switch to vertical timeline on mobile */
  .tracking-timeline {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
    padding: 20px 0 20px 30px;
    z-index: 0; /* keep behind children */
  }

  /* Re-map connector to vertical orientation */
  .tracking-timeline::before,
  .tracking-timeline::after {
    top: var(--line-top, 0px);
    left: var(--line-left, 0px);
    width: 4px;
    height: 0;
    transform: none;
    z-index: 0; /* behind events/icons on mobile too */
  }
  .tracking-timeline::before {
    height: var(--base-progress-px, 0px);
    background: var(--gray-200);
    transition: height 0.8s ease-out;
  }
  .tracking-timeline::after {
    height: var(--progress-px, 0px);
    background: var(--primary-blue);
    transition: height 0.8s ease-out;
  }

  /* Disable old vertical animation */
  .tracking-timeline.animate::before {
    animation: none !important;
  }

  .tracking-event {
    flex-direction: row;
    text-align: left;
    align-items: center;
    max-width: none;
    gap: 20px;
    padding: 12px 16px;
    border-radius: 12px;
  }
  
  .tracking-event:hover,
  .tracking-event:focus {
    transform: scale(1.02) translateY(-2px);
    padding: 12px 16px;
  }

  .status-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 0;
    flex-shrink: 0;
  }


  .event-details {
    text-align: left;
    flex: 1;
  }

  .event-header {
    font-size: 1rem;
    margin-bottom: 2px;
  }

  .event-subheader {
    font-size: 0.85rem;
  }

  .bex-footer-content {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  /* Multiple timelines mobile styles */
  .timeline-wrapper {
    padding: 24px 16px;
    border-radius: 12px;
    margin-bottom: 24px;
  }

  .waybill-title-card {
    font-size: 0.85rem;
    padding: 6px 16px;
    top: 14px; /* further inside card */
    left: 15px;
  }

  .timeline-wrapper .tracking-timeline {
    margin-top: 15px;
  }
}

@media (max-width: 480px) {
  .bex-header {
    padding: 24px 20px 20px;
  }

  .bex-header-card {
    margin-top: 8px;
  }

  .bex-logo-card {
    margin: 8px auto 0 auto; /* reduced gap above header */
  }

  .bex-title {
    font-size: 2rem;
  }

  .bex-input-card {
    padding: 24px 20px;
  }

  .bex-timeline-card {
    border-radius: 12px;
    padding: 24px 16px;
  }

  .status-icon {
    width: 50px;
    height: 50px;
  }


  .tracking-event {
    gap: 16px;
  }

  .tracking-timeline {
    padding-left: 25px;
  }
  .tracking-timeline::before {
    left: 0;
  }
  .bex-page-content {
    padding-top: 24px !important;
  }
}

.bex-logo-card {
  position: fixed;
  top: 32px;
  left: 32px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(0,0,0,0.18), 0 1.5px 6px 0 rgba(0,0,0,0.10);
  border: 1.5px solid var(--gray-200);
  background: rgba(255,255,255,0.98);
  transition: box-shadow 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.bex-logo-card:hover {
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.22), 0 3px 12px 0 rgba(0,0,0,0.13);
  transform: translateY(-2px) scale(1.01);
}

.bex-logo-card .bex-logo {
  width: 220px;
  max-width: 45vw;
  height: auto;
  margin: 0;
  border-radius: 16px;
  box-shadow: none;
}

@media (max-width: 768px) {
  .bex-logo-card {
    position: static;
    transform: none;
    margin: 8px auto 0 auto; /* reduced gap above header */
  }
  .bex-header {
    padding: 24px 20px 20px;
  }

  .bex-header-card {
    margin-top: 8px;
  }
}

@media (min-width: 1001px) {
  .bex-header-card {
    margin-top: 0;
  }
  .bex-logo-card {
    position: fixed; /* ensure logo remains fixed on large desktop */
  }
  .bex-header-card.overlap-avoid {
    margin-top: 120px;
  }
}

.bex-current-step-card {
  background: var(--primary-blue);
  color: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 4px 14px 4px 8px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  min-width: 0;
  max-width: 140px;
  width: max-content;
  pointer-events: none;
  opacity: 0.97;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeInUpCentered 0.4s cubic-bezier(0.4,0,0.2,1);
  animation-fill-mode: both;
}
@media (max-width: 768px) {
  .bex-current-step-card {
    max-width: 98vw;
    padding: 16px 8vw 12px 8vw;
    font-size: 0.98rem;
  }
}

@media (min-width: 601px) {
  .bex-current-step-card {
    /* Add extra vertical spacing so the card sits nicely above the stage */
    top: -48px !important;
    margin-bottom: 18px;
  }
}

@media (max-width: 600px) {
    .bex-current-step-card {
     position: static !important;
     left: unset !important;
     top: unset !important;
     transform: none !important;
     width: 100%;
     max-width: 100%;
     margin-bottom: 8px;
     margin-top: -2px;
     border-radius: 6px;
     justify-content: center;
     text-align: center;
     display: flex;
     align-items: center;
     gap: 3px;
     z-index: 1;
     font-size: 0.78rem;
     padding: 2px 6px 2px 4px;
     min-height: unset;
     animation: fadeInUp 0.4s cubic-bezier(0.4,0,0.2,1) !important;
     animation-fill-mode: both !important;
   }
  .bex-current-step-card svg {
    width: 13px;
    height: 13px;
    margin-right: 2px;
  }
}

/* Support button hover effects */
.support-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  color: white;
}

.support-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

/* Waybill not found card specific styling */
.waybill-not-found-card {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}

.waybill-not-found-card .support-icon {
  transition: transform 0.3s ease;
}

.waybill-not-found-card:hover .support-icon {
  transform: scale(1.05);
}

/* Mobile responsive adjustments for support card */
@media (max-width: 768px) {
  .waybill-not-found-card {
    padding: 30px 20px;
  }
  
  .waybill-not-found-card .support-icon {
    width: 60px;
    height: 60px;
  }
  
  .waybill-not-found-card .support-icon svg {
    width: 24px;
    height: 24px;
  }
  
  .support-button {
    padding: 12px 20px !important;
    font-size: 0.9rem !important;
  }
}

/* Floating Help FAB */
.help-fab {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255,255,255,0.98);
  border: 1.5px solid var(--gray-200);
  box-shadow: 0 8px 32px 0 rgba(0,0,0,0.18), 0 1.5px 6px 0 rgba(0,0,0,0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 140; /* above footer and tooltips */
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.help-fab svg {
  width: 26px;
  height: 26px;
}

.help-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px 0 rgba(0,0,0,0.22), 0 3px 12px 0 rgba(0,0,0,0.13);
}

@media (max-width: 768px) {
  .help-fab {
    top: 18px;
    right: 18px;
    width: 50px;
    height: 50px;
  }
  .help-fab svg { width: 24px; height: 24px; }
}

@media (max-width: 480px) {
  .help-fab {
    top: 14px;
    right: 14px;
    width: 46px;
    height: 46px;
  }
  .help-fab svg { width: 22px; height: 22px; }
}

/* Help page accordion */
.help-accordion {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.accordion-item {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.accordion-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.accordion-summary:hover {
  background: linear-gradient(135deg, var(--secondary-blue) 0%, var(--white) 100%);
}

/* Hide default marker */
.accordion-summary::-webkit-details-marker {
  display: none;
}

.summary-text h3 {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 1.1rem;
  line-height: 1.2;
  color: var(--gray-800);
  margin: 0;
}

.summary-text p {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-size: 0.92rem;
  color: var(--gray-600);
  margin: 2px 0 0 0;
}

/* Chevron indicator */
.chevron {
  margin-left: auto;
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--gray-500);
  border-bottom: 2px solid var(--gray-500);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}

.accordion-item[open] .chevron {
  transform: rotate(135deg);
}

.accordion-panel {
  padding: 16px 20px 20px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.help-list {
  padding-left: 20px;
  margin: 0 0 10px 0;
}

.help-bullets {
  padding-left: 18px;
  margin: 0;
}

/* Stage icon inside summaries on help page */
.help-stage-summary .status-icon {
  width: 44px;
  height: 44px;
  border-width: 3px;
  margin: 0 4px 0 0;
  box-shadow: var(--shadow-md);
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .accordion-summary {
    padding: 16px 16px;
    gap: 14px;
  }
  .summary-text h3 {
    font-size: 1.05rem;
  }
  .summary-text p {
    font-size: 0.9rem;
  }
  .help-stage-summary .status-icon {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .accordion-summary {
    padding: 14px 14px;
    gap: 12px;
  }
  .summary-text h3 {
    font-size: 1rem;
  }
  .summary-text p {
    font-size: 0.88rem;
  }
  .help-stage-summary .status-icon {
    width: 38px;
    height: 38px;
  }
}

/* Help grid for large screens */
.help-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
.help-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.help-section-title {
  font-family: 'Inter', 'Segoe UI', Arial, sans-serif;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.01em;
  padding: 6px 2px 2px;
}

@media (min-width: 1440px) {
  .help-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

/* Elegant, one-time firework burst around completed stage icons */
.firework {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3; /* above icon, below hover shadows */
  /* Defaults; JS sets --r0 per icon so the effect starts outside the circle */
  --r0: 44px; /* base outside radius fallback */
  --ringGrow: 60px; /* how far the ring expands beyond start */
}

/* Subtle expanding ring starting just outside the icon */
.firework::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--r0) * 2);
  height: calc(var(--r0) * 2);
  border-radius: 50%;
  border: 2px solid rgba(139, 62, 168, 0.25);
  transform: translate(-50%, -50%);
  animation: fw-ring 480ms ease-out forwards;
}

/* Sparks radiating outwards (starting outside the icon edge) */
.firework .spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 62, 168, 1) 0%, rgba(139, 62, 168, 0.7) 60%, rgba(139, 62, 168, 0) 100%);
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  animation: fw-spark 520ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}

/* Use custom properties --i (index), --n (total), --d (distance), and --r0 (base radius) */
.firework .spark {
  --angle: calc((360deg / var(--n)) * var(--i));
}

@keyframes fw-ring {
  0% {
    width: calc(var(--r0) * 2);
    height: calc(var(--r0) * 2);
    opacity: 0.9;
    border-width: 2px;
  }
  70% { opacity: 0.5; }
  100% {
    width: calc(var(--r0) * 2 + var(--ringGrow));
    height: calc(var(--r0) * 2 + var(--ringGrow));
    opacity: 0;
    border-width: 1px;
  }
}

@keyframes fw-spark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translate(var(--r0)) scale(0.6);
  }
  12% { opacity: 1; }
  70% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translate(calc(var(--r0) + var(--d))) scale(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .firework, .firework * {
    animation: none !important;
  }
}

/* Disable the expanding ring: keep only particle sparks */
.firework::before { display: none !important; }