/**
 * Silex Shoes - Modern Factory OS Design System
 * Primary Color: #800000 (Deep Maroon)
 * Supporting Colors: #600000 (Dark Maroon), #9c1c1c, #fbebee, #f8fafc, #0F172A
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Brand Maroon Palette (Previous #800000 Deep Maroon) */
  --primary-maroon: #800000;
  --primary-maroon-dark: #600000;
  --primary-maroon-light: #9c1c1c;
  --primary-maroon-hover: #6a0000;
  --primary-maroon-subtle: #fbebee;
  --primary-maroon-border: #f2c7ce;
  --maroon-gradient: linear-gradient(135deg, #800000 0%, #580000 100%);
  --maroon-gradient-light: linear-gradient(135deg, #9c1c1c 0%, #800000 100%);
  --maroon-shadow: 0 4px 14px rgba(128, 0, 0, 0.25);
  --maroon-shadow-hover: 0 8px 20px rgba(128, 0, 0, 0.35);

  /* Surface & Text Tokens */
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --text-main: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --border-focus: #800000;

  /* Accent Tokens */
  --accent-amber: #D97706;
  --accent-amber-subtle: #FEF3C7;
  --accent-emerald: #059669;
  --accent-emerald-subtle: #D1FAE5;
  --accent-sky: #0284C7;
  --accent-sky-subtle: #E0F2FE;
  --accent-purple: #7C3AED;
  --accent-purple-subtle: #EDE9FE;
  --accent-rose: #E11D48;
  --accent-rose-subtle: #FFE4E6;

  /* Elevation & Shadows */
  --card-shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 4px 12px -2px rgba(15, 23, 42, 0.05);
  --card-hover-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.03);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* Global Reset & Base Typography */
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .brand-text, .kpi-value, .display-font {
  font-family: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  letter-spacing: -0.01em;
}

/* Primary Color Utilities */
.bg-maroon {
  background-color: var(--primary-maroon) !important;
  color: #ffffff !important;
}

.text-maroon {
  color: var(--primary-maroon) !important;
}

.border-maroon {
  border-color: var(--primary-maroon) !important;
}

.bg-maroon-subtle {
  background-color: var(--primary-maroon-subtle) !important;
  color: var(--primary-maroon) !important;
}

.border-maroon-subtle {
  border-color: var(--primary-maroon-border) !important;
}

/* Custom Buttons with Micro-interactions */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-maroon {
  background: var(--maroon-gradient);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--maroon-shadow);
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-md);
}

.btn-maroon:hover, 
.btn-maroon:focus, 
.btn-maroon:active {
  background: var(--maroon-gradient-light);
  color: #ffffff;
  transform: translateY(-1.5px);
  box-shadow: var(--maroon-shadow-hover);
}

.btn-outline-maroon {
  background-color: transparent;
  color: var(--primary-maroon);
  border: 1.5px solid var(--primary-maroon);
  border-radius: var(--radius-md);
  padding: 0.5rem 1.15rem;
}

.btn-outline-maroon:hover,
.btn-outline-maroon:focus,
.btn-outline-maroon:active {
  background-color: var(--primary-maroon);
  color: #ffffff;
  transform: translateY(-1.5px);
  box-shadow: var(--maroon-shadow);
}

/* ========================================================
   MODERN APP LAYOUT & SIDEBAR NAVIGATION SYSTEM
   ======================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--bg-body);
}

/* Sidebar Backdrop for Mobile/Tablet Drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1035;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* 1. APP SIDEBAR */
.app-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: linear-gradient(180deg, #600000 0%, #420000 55%, #2a0000 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

/* Sidebar Brand Header */
.sidebar-header {
  height: 64px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #FFFFFF;
}

.sidebar-brand:hover {
  color: #FFFFFF;
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.sidebar-brand .brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.sidebar-brand .brand-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  color: #FFFFFF;
}

.sidebar-brand .brand-subtext {
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-close-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

/* Sidebar Active Route Card */
.sidebar-route-card {
  margin: 0.85rem 0.85rem 0.25rem 0.85rem;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sidebar-route-card .route-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 0.15rem;
}

.sidebar-route-card .route-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #F8FAFC;
}

/* Sidebar Navigation Items */
.sidebar-menu-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0.65rem;
}

.sidebar-menu-wrapper::-webkit-scrollbar {
  width: 5px;
}
.sidebar-menu-wrapper::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-menu-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.sidebar-menu-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  padding: 0.65rem 0.75rem 0.35rem 0.75rem;
  user-select: none;
}

.sidebar-nav .nav-link {
  color: rgba(255, 255, 255, 0.84) !important;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.52rem 0.75rem !important;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all 0.18s ease;
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar-nav .nav-link .nav-icon {
  font-size: 1.1rem;
  margin-right: 0.75rem;
  width: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  transition: color 0.18s ease;
}

.sidebar-nav .nav-link .sub-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: rgba(255, 255, 255, 0.5);
}

.sidebar-nav .nav-link[aria-expanded="true"] .sub-arrow {
  transform: rotate(180deg);
}

.sidebar-nav .nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF !important;
  transform: translateX(2px);
}

.sidebar-nav .nav-link:hover .nav-icon {
  color: #FFFFFF;
}

.sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF !important;
  font-weight: 600;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2), 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-nav .nav-link.active .nav-icon {
  color: #FBBF24;
}

/* Submenu Links */
.sub-nav {
  padding-left: 1.75rem;
  margin-top: 2px;
  margin-bottom: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  margin-left: 1.15rem;
}

.sub-link {
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem !important;
  color: rgba(255, 255, 255, 0.72) !important;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  text-decoration: none;
}

.sub-link:hover {
  color: #FFFFFF !important;
  background: rgba(255, 255, 255, 0.08);
}

.sub-link.active {
  color: #FFFFFF !important;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.16);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.75rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sidebar-user-card .user-details {
  flex: 1;
  min-width: 0;
}

.sidebar-user-card .user-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #FFFFFF;
}

.sidebar-user-card .user-role-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-sidebar-logout {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-sidebar-logout:hover {
  background: #EF4444;
  color: #FFFFFF;
  transform: scale(1.05);
}

/* 2. APP MAIN & TOPBAR */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: var(--bg-body);
}

.app-topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1020;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.btn-topbar-toggle {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  color: #334155;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-topbar-toggle:hover {
  background: #E2E8F0;
  color: #0F172A;
  transform: translateY(-1px);
}

.topbar-page-info {
  line-height: 1.2;
}

.topbar-title {
  color: #0F172A;
  font-family: 'Outfit', sans-serif;
}

.topbar-subtitle {
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Topbar Element Overrides */
.app-topbar .btn-route-switcher {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  color: #92400E;
  font-size: 0.84rem;
}

.app-topbar .btn-route-switcher:hover,
.app-topbar .btn-route-switcher:focus {
  background: #FEF3C7;
  border-color: #F59E0B;
  color: #78350F;
}

.app-topbar .badge-offline-ready {
  background: #F1F5F9;
  color: #059669;
  border: 1px solid #D1FAE5;
}

.app-topbar .btn-icon-glass {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  color: #334155;
}

.app-topbar .btn-icon-glass:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.app-topbar .btn-profile-glass {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  color: #0F172A;
}

.app-topbar .btn-profile-glass:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: #0F172A;
}

/* 3. DESKTOP COLLAPSED STATE */
.app-layout.sidebar-collapsed .app-sidebar {
  width: 72px;
  min-width: 72px;
}

.app-layout.sidebar-collapsed .app-main {
  margin-left: 72px;
}

.app-layout.sidebar-collapsed .brand-info,
.app-layout.sidebar-collapsed .brand-subtext,
.app-layout.sidebar-collapsed .nav-label,
.app-layout.sidebar-collapsed .nav-section-title,
.app-layout.sidebar-collapsed .sub-arrow,
.app-layout.sidebar-collapsed .sidebar-route-card,
.app-layout.sidebar-collapsed .user-details,
.app-layout.sidebar-collapsed .sub-nav {
  display: none !important;
}

.app-layout.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-link {
  justify-content: center;
  padding: 0.65rem 0 !important;
}

.app-layout.sidebar-collapsed .sidebar-nav .nav-link .nav-icon {
  margin-right: 0 !important;
  font-size: 1.25rem;
}

.app-layout.sidebar-collapsed .sidebar-user-card {
  justify-content: center;
}

/* 4. MOBILE & TABLET RESPONSIVENESS (< 1200px) */
@media (max-width: 1199.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 270px;
  }
  
  .app-main {
    margin-left: 0 !important;
  }
  
  .app-layout.sidebar-open .app-sidebar {
    transform: translateX(0);
  }
  
  .app-layout.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }
}

/* 5. PRINT OVERRIDES */
@media print {
  .app-sidebar,
  .app-topbar,
  .app-footer,
  .no-print {
    display: none !important;
  }
  
  .app-main {
    margin-left: 0 !important;
    padding: 0 !important;
  }
}

/* Header Right Action Elements */
.btn-route-switcher {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #F8FAFC;
  font-size: 0.84rem;
  transition: all 0.2s ease;
}

.btn-route-switcher:hover, .btn-route-switcher:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(245, 158, 11, 0.8);
  color: #ffffff;
  transform: translateY(-1px);
}

.route-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10B981;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.btn-icon-glass {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.btn-icon-glass:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  transform: scale(1.05);
}

.btn-profile-glass {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.btn-profile-glass:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}

.user-avatar-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Offline Badge */
.badge-offline-ready {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

/* Dropdown Menus */
.dropdown-menu {
  border-radius: var(--radius-md);
  box-shadow: 0 14px 34px -4px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  padding: 0.5rem;
  animation: dropdownFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.dropdown-item {
  border-radius: var(--radius-sm);
  padding: 0.48rem 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background-color: var(--primary-maroon-subtle);
  color: var(--primary-maroon);
}

.dropdown-item.active,
.dropdown-item:active {
  background-color: var(--primary-maroon);
  color: #ffffff;
}

/* Modern Role Badges */
.badge-role-admin {
  background: linear-gradient(135deg, #800000 0%, #600000 100%);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(128, 0, 0, 0.25);
}

.badge-role-office {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.badge-role-rep {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

/* Elevated Modern Cards */
.card-custom {
  background: var(--bg-surface);
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.card-custom:hover {
  box-shadow: var(--card-hover-shadow);
}

.card-header-maroon {
  background-color: #ffffff;
  border-bottom: 1.5px solid var(--primary-maroon-subtle);
  padding: 1.1rem 1.4rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-maroon);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modern Metric / Stat KPI Cards */
.kpi-card {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(226, 232, 240, 0.85);
  background: #ffffff;
  padding: 1.35rem 1.4rem;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--maroon-gradient);
}

.kpi-card.kpi-blue::before { background: linear-gradient(90deg, #0284C7, #38BDF8); }
.kpi-card.kpi-green::before { background: linear-gradient(90deg, #059669, #34D399); }
.kpi-card.kpi-amber::before { background: linear-gradient(90deg, #D97706, #FBBF24); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, #7C3AED, #A78BFA); }

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
}

.kpi-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

/* Subtle Color Variations for Badges and Icons */
.bg-primary-subtle { background-color: var(--accent-sky-subtle) !important; color: var(--accent-sky) !important; }
.bg-success-subtle { background-color: var(--accent-emerald-subtle) !important; color: var(--accent-emerald) !important; }
.bg-warning-subtle { background-color: var(--accent-amber-subtle) !important; color: var(--accent-amber) !important; }
.bg-danger-subtle  { background-color: var(--accent-rose-subtle) !important; color: var(--accent-rose) !important; }
.bg-info-subtle    { background-color: var(--accent-purple-subtle) !important; color: var(--accent-purple) !important; }

/* Status Badges */
.badge-status {
  padding: 0.4em 0.8em;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: capitalize;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-status-approved { background-color: var(--accent-emerald-subtle); color: var(--accent-emerald); }
.badge-status-pending  { background-color: var(--accent-amber-subtle); color: var(--accent-amber); }
.badge-status-rejected { background-color: var(--accent-rose-subtle); color: var(--accent-rose); }

/* Fulfillment Pipeline Step Pills */
.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.step-orderplaced, .step-placed     { background-color: var(--accent-amber-subtle); color: #92400E; border: 1px solid #FDE68A; }
.step-inproduction, .step-production { background-color: var(--accent-sky-subtle); color: #0369A1; border: 1px solid #BAE6FD; }
.step-readytodispatch, .step-ready   { background-color: #EDE9FE; color: #6D28D9; border: 1px solid #DDD6FE; }
.step-dispatched { background-color: var(--accent-emerald-subtle); color: #15803D; border: 1px solid #A7F3D0; }
.step-delivered  { background-color: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }
.step-cancelled  { background-color: var(--accent-rose-subtle); color: #B91C1C; border: 1px solid #FECDD3; }

/* Tables & Modern DataTables */
.table-custom {
  margin-bottom: 0;
}

.table-custom thead th {
  background-color: #F8FAFC;
  color: var(--text-secondary);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  border-bottom: 1.5px solid var(--border-color);
  padding: 0.95rem 1.15rem;
  white-space: nowrap;
}

.table-custom tbody td {
  padding: 0.95rem 1.15rem;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  font-size: 0.9rem;
  color: var(--text-main);
}

.table-custom tbody tr {
  transition: background-color 0.15s ease;
}

.table-custom tbody tr:hover {
  background-color: #FDF8F9;
}

/* Modern DataTables Controls */
.dataTables_wrapper .dataTables_filter input {
  border-radius: 20px !important;
  border: 1px solid var(--border-color) !important;
  padding: 0.4rem 1rem !important;
  font-size: 0.86rem !important;
  outline: none !important;
  transition: all 0.2s ease !important;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary-maroon) !important;
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.15) !important;
}

.dataTables_wrapper .dataTables_length select {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  padding: 0.35rem 1.8rem 0.35rem 0.75rem !important;
  font-size: 0.86rem !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
  padding: 0.35rem 0.75rem !important;
  font-size: 0.84rem !important;
  transition: all 0.15s ease !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--maroon-gradient) !important;
  color: #ffffff !important;
  border: none !important;
}

/* Quick Action Tiles for Field Sales Reps */
.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.4rem 1.1rem;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 120px;
  box-shadow: var(--card-shadow);
}

.quick-action-tile:hover {
  border-color: var(--primary-maroon-border);
  background: var(--primary-maroon-subtle);
  color: var(--primary-maroon);
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
}

.quick-action-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-maroon);
  transition: transform 0.2s ease;
}

.quick-action-tile:hover .quick-action-icon {
  transform: scale(1.1);
}

.quick-action-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

/* Form Controls & Inputs */
.form-control, .form-select {
  border-radius: var(--radius-md);
  border: 1px solid #CBD5E1;
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-maroon);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.14);
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.input-group-text {
  border-radius: var(--radius-md);
  border-color: #CBD5E1;
  background-color: #F8FAFC;
  color: var(--text-secondary);
}

/* Modals */
.modal-content {
  border-radius: var(--radius-xl);
  border: none;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 1rem 1.5rem;
}

/* Enhanced Scrollable Modal Support */
.modal-dialog-scrollable .modal-content {
  max-height: calc(100vh - 3rem) !important;
  display: flex !important;
  flex-direction: column !important;
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
  flex-shrink: 0;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: #F8FAFC;
}
::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Alerts */
.alert {
  border-radius: var(--radius-md);
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Responsive Handheld Optimizations */
@media (max-width: 768px) {
  .table-custom thead th {
    padding: 0.7rem 0.6rem;
    font-size: 0.72rem;
  }
  .table-custom tbody td {
    padding: 0.75rem 0.6rem;
    font-size: 0.84rem;
  }
  .card-body {
    padding: 1.15rem !important;
  }
  .kpi-value {
    font-size: 1.45rem;
  }
  .kpi-card {
    padding: 1.15rem;
  }
}

/* =========================================================
   SYSTEM-WIDE MODERN DATATABLES & HORIZONTAL SCROLL ARCHITECTURE
   ========================================================= */

/* Modern Responsive Table Containers */
.table-responsive,
.dataTables_scrollBody {
  position: relative;
  border-radius: var(--radius-sm, 8px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 0, 0, 0.45) #f1f5f9;
  transition: box-shadow 0.25s ease;
  cursor: default;
}

/* Custom Sleek Scrollbar for all table containers across the system */
.table-responsive::-webkit-scrollbar,
.dataTables_scrollBody::-webkit-scrollbar,
.table-scroll-container::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.table-responsive::-webkit-scrollbar-track,
.dataTables_scrollBody::-webkit-scrollbar-track,
.table-scroll-container::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb,
.dataTables_scrollBody::-webkit-scrollbar-thumb,
.table-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(128, 0, 0, 0.35);
  border-radius: 10px;
  border: 2px solid #f1f5f9;
  transition: background 0.2s ease;
}

.table-responsive::-webkit-scrollbar-thumb:hover,
.dataTables_scrollBody::-webkit-scrollbar-thumb:hover,
.table-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary-maroon, #800000);
}

/* Modern Dynamic Horizontal Scroll Affordance Indicators (Edge Shadows) */
.table-responsive.has-scroll-left::before,
.table-scroll-wrapper.has-scroll-left::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 8px;
  left: 0;
  width: 24px;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.08), transparent);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.2s ease;
}

.table-responsive.has-scroll-right::after,
.table-scroll-wrapper.has-scroll-right::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 8px;
  right: 0;
  width: 24px;
  background: linear-gradient(to left, rgba(15, 23, 42, 0.08), transparent);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.2s ease;
}

/* Enhanced Table Typography & Row Layout - High Density & Compact (Full Data in One Screen) */
.table-custom {
  margin-bottom: 0;
  font-size: 0.8125rem !important; /* ~13px */
  border-collapse: separate;
  border-spacing: 0;
  width: 100% !important;
}

.table-custom thead th {
  background-color: #f8fafc !important;
  color: #475569 !important;
  font-weight: 700 !important;
  font-size: 0.72rem !important; /* ~11.5px */
  text-transform: uppercase !important;
  letter-spacing: 0.4px !important;
  padding: 8px 10px !important;
  border-top: none !important;
  border-bottom: 2px solid #e2e8f0 !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
}

.table-custom tbody td {
  padding: 7px 10px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  vertical-align: middle !important;
  color: var(--text-main, #0f172a);
  font-size: 0.8125rem !important;
  line-height: 1.35 !important;
}

.table-custom tbody tr:hover td {
  background-color: #fffafa !important;
}

/* Compact Badges inside all tables */
.table-custom td .badge,
.table-custom th .badge {
  font-size: 0.7rem !important;
  padding: 3px 6px !important;
  font-weight: 600 !important;
  letter-spacing: 0.2px;
  white-space: nowrap !important;
}

/* Compact Buttons inside all tables */
.table-custom td .btn-sm,
.table-custom th .btn-sm {
  padding: 2px 7px !important;
  font-size: 0.76rem !important;
  line-height: 1.4 !important;
  border-radius: 6px !important;
}

/* Compact Form Inputs & Selects inside all tables */
.table-custom td .form-select-sm,
.table-custom td .form-control-sm {
  font-size: 0.78rem !important;
  padding: 3px 6px !important;
  height: auto !important;
  min-height: 28px !important;
  border-radius: 6px !important;
}

/* Compact Secondary / Sub-labels in cells */
.table-custom td .small,
.table-custom td small,
.table-custom td .text-muted.small {
  font-size: 0.7rem !important;
  line-height: 1.25 !important;
}

/* General table class fallback for tables without .table-custom */
.table:not(.table-custom) th {
  padding: 8px 10px !important;
  font-size: 0.74rem !important;
}
.table:not(.table-custom) td {
  padding: 7px 10px !important;
  font-size: 0.8125rem !important;
}

/* Prevent awkward word-breaking and cell wraps */
.table-custom .text-nowrap,
.table-custom td.text-nowrap,
.table-custom th.text-nowrap {
  white-space: nowrap !important;
}

.table-custom .btn-group,
.table-custom td:last-child {
  white-space: nowrap !important;
}

/* Modern DataTables UI Controls (Filter, Length, Paginate) */
.dataTables_wrapper {
  padding-top: 4px;
}

.dataTables_wrapper .dataTables_filter {
  margin-bottom: 12px;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.86rem;
  outline: none;
  transition: all 0.2s ease;
  background-color: #ffffff;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary-maroon, #800000);
  box-shadow: 0 0 0 3px rgba(128, 0, 0, 0.12);
}

.dataTables_wrapper .dataTables_length select {
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.86rem;
  outline: none;
}

.dataTables_wrapper .dataTables_info {
  font-size: 0.82rem;
  color: #64748b;
  padding-top: 12px;
}

.dataTables_wrapper .dataTables_paginate {
  padding-top: 10px;
}

.dataTables_wrapper .dataTables_paginate .pagination {
  margin-bottom: 0;
  gap: 4px;
}

.dataTables_wrapper .dataTables_paginate .page-item .page-link {
  border-radius: 8px !important;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  transition: all 0.15s ease;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
  background-color: var(--primary-maroon, #800000) !important;
  border-color: var(--primary-maroon, #800000) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(128, 0, 0, 0.25);
}

.dataTables_wrapper .dataTables_paginate .page-item:not(.active):hover .page-link {
  background-color: #fbebee;
  color: var(--primary-maroon, #800000);
  border-color: #f2c7ce;
}

/* ==========================================================================
   Modern Searchable Select Dropdown Component (Deep Maroon Brand Theme)
   ========================================================================== */
.searchable-select-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.searchable-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.searchable-select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
  color: #1e293b;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  cursor: pointer;
  user-select: none;
  text-align: left;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  min-height: 38px;
}

.searchable-select-btn:hover:not(:disabled) {
  border-color: #94a3b8;
  background-color: #fafafa;
}

.searchable-select-btn:focus,
.searchable-select-btn.active {
  outline: none;
  border-color: var(--primary-maroon, #800000) !important;
  box-shadow: 0 0 0 0.2rem rgba(128, 0, 0, 0.18) !important;
  background-color: #ffffff;
}

.searchable-select-btn.s-select-btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  min-height: 31px;
  border-radius: 0.25rem;
}

.searchable-select-btn.disabled,
.searchable-select-btn:disabled {
  background-color: #f1f5f9 !important;
  border-color: #e2e8f0 !important;
  color: #94a3b8 !important;
  cursor: not-allowed;
  opacity: 0.75;
}

.searchable-select-btn.is-invalid {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.searchable-select-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  margin-right: 6px;
}

.searchable-select-label.is-placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.searchable-select-icons {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.searchable-select-chevron {
  font-size: 0.75rem;
  color: #64748b;
  transition: transform 0.2s ease;
}

.searchable-select-btn.active .searchable-select-chevron {
  transform: rotate(180deg);
  color: var(--primary-maroon, #800000);
}

/* Floating Dropdown Container (fixed positioning in body) */
.searchable-select-dropdown {
  position: fixed;
  z-index: 1080;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: sSelectFadeIn 0.15s ease-out;
}

.searchable-select-dropdown.show {
  display: flex;
}

@keyframes sSelectFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Search Header */
.searchable-select-search {
  position: relative;
  padding: 6px 8px;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
}

.searchable-select-search-icon {
  position: absolute;
  left: 16px;
  color: #94a3b8;
  font-size: 0.8rem;
  pointer-events: none;
}

.searchable-select-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 5px 26px 5px 28px;
  font-size: 0.85rem;
  outline: none;
  background-color: #ffffff;
  color: #1e293b;
  transition: border-color 0.15s ease;
}

@media (max-width: 768px) {
  .searchable-select-input {
    font-size: 16px !important; /* Prevents auto-zoom on mobile browsers */
    padding: 7px 30px 7px 32px;
  }
}

.searchable-select-input:focus {
  border-color: var(--primary-maroon, #800000);
  box-shadow: 0 0 0 2px rgba(128, 0, 0, 0.15);
}

.searchable-select-clear {
  position: absolute;
  right: 14px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
}

.searchable-select-clear:hover {
  color: #334155;
}

/* Options Scroll Area */
.searchable-select-options {
  overflow-y: auto;
  max-height: 240px;
  padding: 4px;
}

.searchable-select-options::-webkit-scrollbar {
  width: 6px;
}
.searchable-select-options::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.searchable-select-options::-webkit-scrollbar-thumb:hover {
  background: var(--primary-maroon, #800000);
}

/* Item */
.searchable-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 0.825rem;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.1s ease, color 0.1s ease;
  margin-bottom: 2px;
}

.searchable-select-item:hover,
.searchable-select-item.highlighted {
  background-color: var(--primary-maroon-subtle, #fbebee);
  color: var(--primary-maroon, #800000);
  font-weight: 600;
}

.searchable-select-item.active {
  background-color: var(--primary-maroon, #800000);
  color: #ffffff;
  font-weight: 600;
}

.searchable-select-item.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.searchable-select-item-text {
  flex: 1 1 auto;
  white-space: normal;
  line-height: 1.35;
}

.searchable-select-check {
  font-size: 1rem;
  margin-left: 8px;
  opacity: 0;
  flex: 0 0 auto;
}

.searchable-select-item.active .searchable-select-check {
  opacity: 1;
  color: #ffffff;
}

.searchable-select-empty {
  padding: 18px 12px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.825rem;
  font-style: italic;
}

/* Bootstrap Input Group Integration */
.input-group > .searchable-select-wrapper {
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}
.input-group > span.input-group-text + .searchable-select-wrapper .searchable-select-btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.input-group > .searchable-select-wrapper:not(:last-child) .searchable-select-btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.d-flex > .searchable-select-wrapper {
  flex: 0 1 auto;
}

/* ==========================================================================
   Mobile Tablet Progressive Web App (PWA) Styling & Touch Optimizations
   ========================================================================== */
.btn-pwa-install {
  border-color: var(--primary-maroon, #800000) !important;
  color: var(--primary-maroon, #800000) !important;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-pwa-install:hover,
.btn-pwa-install:focus {
  background-color: var(--primary-maroon, #800000) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(128, 0, 0, 0.25);
  transform: translateY(-1px);
}

.pwa-standalone-badge {
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
  background-color: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
  color: #065f46 !important;
}

/* Standalone PWA Tablet Optimizations */
@media (display-mode: standalone), (display-mode: fullscreen) {
  body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
  
  /* Allow text selection in inputs and tables */
  input, textarea, select, table, .table-container {
    user-select: text;
  }

  /* Safe area insets for tablets with notch/pill displays */
  .app-topbar {
    padding-top: env(safe-area-inset-top, 0.5rem);
  }

  .app-footer {
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
  }
}

/* Tablet touch target adjustments */
@media (max-width: 1024px) {
  .btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .form-control, .form-select {
    min-height: 40px;
  }
}



