/* ==========================================================================
   BODEGA INVENTORY & POS SYSTEM - ENTERPRISE RESPONSIVE STYLESHEET
   Optimized for Desktop, Tablets (iPad, 600-1024px), and Mobile Phones (320-640px)
   ========================================================================== */

:root {
  /* Brand Primary */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-border: #c7d2fe;

  /* Neutrals */
  --secondary: #64748b;
  --secondary-hover: #475569;
  --secondary-light: #f8fafc;

  /* Accents */
  --emerald: #059669;
  --emerald-hover: #047857;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;

  --indigo: #6366f1;
  --indigo-hover: #4f46e5;
  --indigo-light: #f5f3ff;
  --indigo-border: #ddd6fe;

  --amber: #d97706;
  --amber-hover: #b45309;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;

  --rose: #e11d48;
  --rose-hover: #be123c;
  --rose-light: #fff1f2;
  --rose-border: #fecdd3;

  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-light: #eff6ff;
  --blue-border: #bfdbfe;

  /* Surfaces & Backgrounds */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-dark: #0f172a;
  --bg-dark-surface: #1e293b;

  /* Borders & Dividers */
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-dark: #cbd5e1;
  --border-focus: #818cf8;

  /* Typography */
  --text-main: #0f172a;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  /* Radii & Geometry */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
}

/* Base Reset & Setup (Strict No-Horizontal-Overflow) */
html {
  box-sizing: border-box;
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 13.5px;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-mono {
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==========================================================================
   NAVIGATION BAR & APP HEADER
   ========================================================================== */
.navbar {
  background: linear-gradient(180deg, #0f172a 0%, #172033 100%);
  border-bottom: 1px solid #1e293b;
  color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(8px);
}

.nav-container {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-sizing: border-box !important;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #ffffff;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nav-brand:hover .brand-logo {
  transform: scale(1.05);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-sub {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.badge-tech {
  font-size: 0.62rem;
  font-weight: 800;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(165, 180, 252, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Nav Desktop Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 4px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.15s ease-in-out;
  white-space: nowrap;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%) !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4) !important;
}

.nav-icon {
  font-size: 0.95rem;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Hamburger / Drawer Toggle for Tablet & Mobile */
.nav-toggle-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Mobile Quick Navigation Carousel */
.mobile-nav {
  display: none;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  gap: 0.4rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.mobile-nav::-webkit-scrollbar {
  display: none;
}

.mobile-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 34px;
}

.mobile-item.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

/* Mobile Drawer Overlay */
.mobile-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

.mobile-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 290px;
  max-width: 85%;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
  animation: slideDrawer 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

@keyframes slideDrawer {
  0% { transform: translateX(100%); }
  100% { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
  padding-bottom: 0.75rem;
}

.drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.drawer-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.drawer-item.active {
  background: var(--primary);
  color: #ffffff;
}

/* ==========================================================================
   MAIN CONTENT & HERO BANNER
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #172554 100%);
  border: 1px solid #1e293b;
  border-radius: var(--radius-xl);
  padding: 1.75rem 2rem;
  color: #ffffff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.025em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  line-height: 1.2;
}

.hero-sub {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-top: 0.35rem;
  max-width: 640px;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   BUTTONS & TAP TARGETS (TOUCH-FRIENDLY)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.16s ease-in-out;
  white-space: nowrap;
  user-select: none;
  line-height: 1.25;
  min-height: 38px;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.77rem;
  border-radius: var(--radius-sm);
  min-height: 32px;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  min-height: 46px;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  border-color: #4338ca;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-secondary {
  background: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.btn-emerald {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff;
  border-color: #047857;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
}
.btn-emerald:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.btn-indigo {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border-color: #4f46e5;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}
.btn-indigo:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.btn-amber {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: #ffffff;
  border-color: #b45309;
}
.btn-amber:hover {
  background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
}

.btn-rose {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  border-color: #be123c;
}
.btn-rose:hover {
  background: linear-gradient(135deg, #be123c 0%, #9f1239 100%);
}

.btn-dark {
  background: #0f172a;
  color: #ffffff;
  border-color: #1e293b;
}
.btn-dark:hover {
  background: #1e293b;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  font-weight: 600;
  min-height: auto;
}

.w-full { width: 100% !important; }

/* ==========================================================================
   RESPONSIVE GRID SYSTEM (PHONE & TABLET SPECIFIC ARCHITECTURE)
   ========================================================================== */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.grid-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

/* Tablet & Mid-Width Viewports (600px - 1040px) */
@media (max-width: 1040px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
  .grid-split {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
}

/* Phone Viewports (<640px) */
@media (max-width: 640px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important; /* Keep 2x2 grid on mobile for compactness */
    gap: 0.65rem !important;
  }
  .grid-3, .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }
}

@media (max-width: 420px) {
  .grid-4 {
    grid-template-columns: 1fr !important; /* Stack only on very narrow screens */
    gap: 0.65rem !important;
  }
}

/* ==========================================================================
   CARDS & ELEVATED KPI METRICS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-card:nth-child(1)::before { background: linear-gradient(90deg, #6366f1, #818cf8); }
.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, #059669, #34d399); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, #d97706, #fbbf24); }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.kpi-val, .kpi-value {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text-main);
  margin-bottom: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card-sm {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

/* ==========================================================================
   SEGMENTED CONTROL TABS (IMPORT & EXPORT HUB)
   ========================================================================== */
.tab-header {
  display: flex;
  gap: 0.4rem;
  background: #f1f5f9;
  padding: 5px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tab-header::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 700;
  color: #64748b;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  white-space: nowrap;
  user-select: none;
  min-height: 40px;
}

.tab-btn:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.tab-content {
  animation: tabFadeIn 0.2s ease-in-out;
}

@keyframes tabFadeIn {
  0% { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Drag & Drop Zone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 2.5rem 1.25rem;
  text-align: center;
  background: #fafafa;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.dropzone:hover {
  border-color: var(--primary);
  background: #f5f3ff;
  transform: scale(1.005);
}

/* ==========================================================================
   DATA TABLES & RESPONSIVE TOUCH SCROLL
   ========================================================================== */
.table-container, .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82rem;
}

.table th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color 0.12s ease;
}

.table tbody tr:hover {
  background-color: #f8fafc;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-sm th, .table-sm td {
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
}

/* Status Badges with Pulse Dots */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-in-stock {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-low-stock {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-out-stock {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.badge-outbound {
  background: #f5f3ff;
  color: #7c3aed;
  border: 1px solid #ddd6fe;
}

.badge-inbound {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-code {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #1e293b;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
  transition: all 0.15s ease;
  user-select: all;
}

.badge-code:hover {
  background: #ede9fe;
  color: #4338ca;
  border-color: #c7d2fe;
}

/* ==========================================================================
   FORMS, INPUTS & TOUCH ERGONOMICS
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #475569;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  transition: all 0.15s ease;
  outline: none;
  min-height: 40px;
}

.form-input:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: all 0.15s ease;
}

.form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Prevent auto-zoom on mobile inputs */
@media (max-width: 768px) {
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }
}

/* ==========================================================================
   MODALS & BACKDROPS (DESKTOP CENTERED + TABLET ADAPTIVE + MOBILE BOTTOM SHEET)
   ========================================================================== */
.modal,
.modal-backdrop {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
  z-index: 1050 !important;
  background: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
  padding: 1.5rem 1rem !important;
  overscroll-behavior-y: contain !important;
}

/* Modal is shown when active or styled display: flex/block */
.modal.active,
.modal.show,
.modal-backdrop.active,
.modal-backdrop.show,
.modal[style*="display: flex"],
.modal[style*="display:flex"],
.modal[style*="display: block"],
.modal[style*="display:block"],
.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"],
.modal-backdrop[style*="display: block"],
.modal-backdrop[style*="display:block"] {
  display: flex !important;
  justify-content: center !important;
  align-items: flex-start !important;
}

/* Explicitly hidden */
.modal[style*="display: none"],
.modal[style*="display:none"],
.modal-backdrop[style*="display: none"],
.modal-backdrop[style*="display:none"] {
  display: none !important;
}

.modal-card {
  background: #ffffff !important;
  border-radius: var(--radius-xl, 14px) !important;
  width: 100% !important;
  max-width: 640px;
  max-height: calc(100vh - 3rem) !important;
  max-height: calc(100dvh - 3rem) !important;
  display: flex !important;
  flex-direction: column !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
  border: 1px solid var(--border) !important;
  overflow: hidden !important;
  margin: auto !important;
  position: relative !important;
  animation: modalScaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  box-sizing: border-box !important;
}

@keyframes modalScaleUp {
  0% { transform: scale(0.96); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-lg,
#warehouseReceiveModal .modal-card {
  max-width: 860px !important;
}

#proPrintModal .modal-card {
  max-width: 1060px !important;
}

.modal-header {
  padding: 1.15rem 1.5rem !important;
  border-bottom: 1px solid var(--border) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  background: #f8fafc !important;
  flex-shrink: 0 !important;
}

.modal-title {
  font-size: 1.15rem !important;
  font-weight: 800 !important;
  color: var(--text-dark) !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
}

.modal-subtitle {
  font-size: 0.82rem !important;
  color: var(--text-muted) !important;
  margin-top: 0.2rem !important;
}

.modal-title-group {
  display: flex !important;
  flex-direction: column !important;
}

.modal-icon {
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.3rem !important;
  background: #eef2ff !important;
  color: #4f46e5 !important;
  flex-shrink: 0 !important;
}

.modal-close {
  background: none !important;
  border: none !important;
  font-size: 1.35rem !important;
  color: var(--text-muted) !important;
  cursor: pointer !important;
  padding: 0.45rem !important;
  min-width: 38px !important;
  min-height: 38px !important;
  line-height: 1 !important;
  border-radius: var(--radius-sm) !important;
  transition: all 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  touch-action: manipulation !important;
}

.modal-close:hover {
  color: #0f172a !important;
  background: rgba(0, 0, 0, 0.05) !important;
}

.modal-body {
  padding: 1.35rem 1.5rem !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  scrollbar-width: thin !important;
}

.modal-footer {
  padding: 1rem 1.5rem !important;
  border-top: 1px solid var(--border) !important;
  background: #f8fafc !important;
  display: flex !important;
  justify-content: flex-end !important;
  align-items: center !important;
  gap: 0.75rem !important;
  flex-shrink: 0 !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 10 !important;
}

/* Tablet Centering & Fluid Widths (641px - 1024px) */
@media (max-width: 1024px) {
  .modal,
  .modal-backdrop {
    padding: 1.25rem 1rem !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-card {
    max-width: min(96%, 780px) !important;
    max-height: calc(100dvh - 2.5rem) !important;
    margin: auto !important;
  }
  #warehouseReceiveModal .modal-card,
  #proPrintModal .modal-card {
    max-width: 98% !important;
  }
  .modal-footer {
    padding: 0.85rem 1.25rem !important;
    position: sticky !important;
    bottom: 0 !important;
    background: #f8fafc !important;
  }
  .modal-footer .btn {
    min-height: 44px !important;
  }
}

/* Mobile Bottom-Sheet Drawer (< 640px) */
@media (max-width: 640px) {
  .modal,
  .modal-backdrop {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-card {
    border-radius: 20px 20px 0 0 !important;
    max-height: 90dvh !important;
    max-height: calc(100dvh - 1.5rem) !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: auto 0 0 0 !important;
    display: flex !important;
    flex-direction: column !important;
    animation: slideUpModal 0.26s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  @keyframes slideUpModal {
    0% { transform: translateY(100%); }
    100% { transform: translateY(0); }
  }
  .modal-header {
    padding: 0.9rem 1.15rem !important;
    flex-shrink: 0 !important;
  }
  .modal-title {
    font-size: 1.05rem !important;
  }
  .modal-subtitle {
    font-size: 0.78rem !important;
  }
  .modal-body {
    padding: 1rem !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-footer {
    padding: 0.85rem 1rem max(1.15rem, env(safe-area-inset-bottom, 20px)) !important;
    flex-direction: column-reverse !important;
    gap: 0.5rem !important;
    position: sticky !important;
    bottom: 0 !important;
    background: #f8fafc !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08) !important;
    z-index: 20 !important;
  }
  .modal-footer .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.92rem !important;
    min-height: 48px !important;
    white-space: normal !important;
    text-align: center !important;
  }

  /* Specific dialogs without standard modal-body like confirm modals */
  #proProceedConfirmModal .modal-card,
  #proCreatedPromptModal .modal-card {
    max-height: 90dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1.25rem 1rem !important;
  }
  #proProceedConfirmModal .modal-card > div:last-child,
  #proCreatedPromptModal .modal-card > div:last-child {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  #proProceedConfirmModal .modal-card > div:last-child .btn,
  #proCreatedPromptModal .modal-card > div:last-child .btn {
    width: 100% !important;
    min-height: 46px !important;
    font-size: 0.92rem !important;
  }

  #warehouseReceiveModal .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  #warehouseReceiveModal .grid-3 > div {
    grid-column: span 1 !important;
  }
  #adminApprovalModal .grid-2,
  #warehouseReceiveModal .grid-2 {
    grid-template-columns: 1fr !important;
  }
  #whSigCanvas,
  #adminSigCanvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 130px !important;
    touch-action: none;
  }
  #warehouseReceiveModal .table-responsive {
    max-height: 240px !important;
  }
}

/* ==========================================================================
   TOAST NOTIFICATION SYSTEM
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: calc(100vw - 2.5rem);
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: toastSlide 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlide {
  0% { transform: translateX(100%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

.toast-success { background: #065f46; border-color: #34d399; }
.toast-error { background: #9f1239; border-color: #f43f5e; }
.toast-info { background: #1e1b4b; border-color: #818cf8; }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.db-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #ecfdf5;
  color: #047857;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.72rem;
  border: 1px solid #a7f3d0;
}

.db-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE REFINEMENTS
   ========================================================================== */
@media (max-width: 980px) {
  .nav-links { display: none; }
  .mobile-nav { display: flex; }
  .nav-toggle-btn { display: inline-flex; }
  .nav-actions { display: none; }
  .main-content {
    padding: 1.15rem 1rem 2rem;
    gap: 1.15rem;
  }
}

@media (max-width: 640px) {
  .nav-container {
    height: 58px;
    padding: 0 0.85rem;
  }
  .brand-logo {
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }
  .brand-title {
    font-size: 0.92rem;
  }
  .brand-sub {
    display: none; /* Hide on small mobile to save space */
  }
  .main-content {
    padding: 0.85rem 0.75rem 2rem;
    gap: 1rem;
  }
  .hero-banner {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-lg);
  }
  .hero-title {
    font-size: 1.2rem;
  }
  .hero-actions .btn {
    flex: 1;
    min-width: 140px;
  }
  .card {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }
  .kpi-card {
    padding: 1rem 0.85rem;
    border-radius: var(--radius-lg);
  }
  .kpi-val, .kpi-value {
    font-size: 1.35rem;
  }
  .table th, .table td {
    padding: 0.65rem 0.75rem;
  }
}

/* Print Styles */
@media print {
  .navbar, .mobile-nav, .mobile-drawer, .footer, .hero-actions, .nav-actions, .btn { display: none !important; }
  body { background: #ffffff; color: #000000; }
  .card, .modal-card { border: none !important; box-shadow: none !important; }
}

/* ==========================================================================
   PRO (PURCHASED REQUEST ORDER) DOCUMENT & WORKFLOW STYLES
   Exact Replica of BODEGA2022 NI TATAY, OPC Official Paper Form
   ========================================================================== */

.badge-pending-admin {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.badge-approved-admin {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.badge-received-final {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.badge-rejected {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

/* Paper Document Replica Sheet */
.pro-sheet {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  padding: 2.25rem 2.5rem;
  max-width: 980px;
  margin: 0 auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  position: relative;
}

.pro-sheet-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pro-company-title {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #0f172a;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.pro-doc-title {
  font-size: 1.1rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
  letter-spacing: 0.05em;
  color: #1e293b;
  text-transform: uppercase;
}

.pro-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.pro-meta-full {
  grid-column: span 2;
}

.pro-field-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.pro-field-label {
  font-weight: 700;
  white-space: nowrap;
  color: #334155;
  font-size: 0.85rem;
}

.pro-field-input {
  flex: 1;
  border: none;
  border-bottom: 1px solid #94a3b8;
  background: transparent;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s ease;
}

.pro-field-input:focus {
  border-bottom-color: #2563eb;
  background: rgba(37, 99, 235, 0.02);
}

/* Formal 8-Column PRO Table */
.pro-table-wrapper {
  border: 1px solid #475569;
  border-radius: 4px;
  overflow: hidden;
  margin: 1.25rem 0 1rem;
}

.pro-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.pro-table th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  padding: 7px 8px;
  border: 1px solid #64748b;
  text-align: center;
  white-space: nowrap;
}

.pro-table td {
  padding: 6px 8px;
  border: 1px solid #94a3b8;
  vertical-align: middle;
  background: #ffffff;
}

.pro-table tbody tr:hover td {
  background: #f8fafc;
}

.pro-table tfoot td {
  background: #f8fafc;
  font-weight: 800;
  border-top: 2px solid #475569;
}

.pro-cell-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f172a;
  border-radius: 3px;
}

.pro-cell-input:focus {
  border-color: #3b82f6;
  background: #ffffff;
  outline: none;
}

.pro-notes-section {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0.75rem 0 1.25rem;
  font-size: 0.85rem;
}

.pro-auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
}

.pro-auth-col {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  font-size: 0.85rem;
}

.pro-delivery-mode {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 4px 0;
}

.pro-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
}

/* 5-Row MOP Installment Schedule Table */
.pro-mop-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.pro-mop-table td {
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
}

/* Delivery Receiver In Charge Section */
.pro-receiver-section {
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  background: #fbfcfe;
}

.pro-receiver-title {
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #cbd5e1;
  color: #0f172a;
}

.pro-receiver-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 1rem;
}

.pro-footer-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 0.75rem;
  font-size: 0.75rem;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
}

/* Status Filter Bar */
.pro-filter-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.pro-filter-btn {
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.pro-filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pro-filter-btn .count-badge {
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.72rem;
}

.pro-filter-btn.active .count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

@media (max-width: 768px) {
  .pro-sheet {
    padding: 1.25rem 1rem;
  }
  .pro-auth-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .pro-receiver-grid {
    grid-template-columns: 1fr;
  }
  .pro-meta-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .pro-meta-full {
    grid-column: span 1;
  }
}

/* Printable Document Optimization */
@media print {
  @page {
    size: letter portrait;
    margin: 12mm 10mm;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  .navbar, .mobile-nav, .mobile-drawer, .footer, .btn, .no-print, .modal-header, .modal-footer, .card-header-actions {
    display: none !important;
  }
  .modal-backdrop {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  .modal-card {
    max-width: 100% !important;
    width: 100% !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
  }
  .pro-sheet {
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    padding: 15px !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  .pro-table th {
    background: #f1f1f1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid #000000 !important;
  }
  .pro-table td {
    border: 1px solid #000000 !important;
  }
  .pro-receiver-section {
    border: 1px solid #000000 !important;
  }
}


/* Responsive Table vs Mobile Card System */
.desktop-table-wrapper {
  display: block;
}
.mobile-cards-wrapper {
  display: none;
}

@media (max-width: 768px) {
  .desktop-table-wrapper {
    display: none !important;
  }
  .mobile-cards-wrapper {
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
  }
  .top-action-bar-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .top-action-bar-grid .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.65rem 0.4rem !important;
    font-size: 0.75rem !important;
    text-align: center !important;
  }
  .card.flex-between {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.85rem !important;
  }
}

.mobile-record-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* ==========================================================================
   USER-FRIENDLY MODERN UI/UX ENHANCEMENTS
   ========================================================================== */

/* Modern Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #4f46e5;
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* User-Friendly Segmented View Switcher */
.segmented-control {
  display: inline-flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  border: 1px solid #e2e8f0;
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.segmented-btn:hover {
  color: #1e293b;
  background: rgba(255, 255, 255, 0.6);
}

.segmented-btn.active {
  background: #ffffff;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Step Wizard Pill Indicator */
.step-tracker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.step-node {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
}

.step-node.active {
  color: #4338ca;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

.step-node.active .step-num {
  background: #4f46e5;
  color: #ffffff;
}

.step-sep {
  color: #cbd5e1;
  font-size: 0.75rem;
}

/* Permission Card Polish */
.permission-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem;
  background: #ffffff;
  cursor: pointer;
}

.permission-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.05);
}

.permission-card.allowed {
  background: #ffffff;
  border-color: #c7d2fe;
}

.permission-card.restricted {
  background: #f8fafc;
  opacity: 0.75;
}

.permission-card.restricted:hover {
  opacity: 1;
}

/* Enhanced Focus & Hover Rings */
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

/* Polish for Dropzone Box */
.dropzone-box:hover {
  border-color: #4f46e5 !important;
  background: #f5f3ff !important;
}


/* ==========================================================================
   MOBILE & TABLET RESPONSIVE CARDS & COMPONENT ARCHITECTURE
   ========================================================================== */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  width: 100%;
}

.navbar {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

.nav-container {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.main-content {
  width: 100%;
  max-width: 1400px;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Multi-Column Stat Grids Inside Cards (Prevent 1-column mobile collapse) */
.card-stat-grid,
.mobile-record-card .grid-3 {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 6px !important;
}

.mobile-record-card .grid-2 {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 6px !important;
}

/* Elevated Mobile Record Card */
.mobile-record-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 0.95rem;
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.06), 0 1px 3px 0 rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.mobile-record-card:active {
  transform: scale(0.995);
}

/* Card Header: Control number & Status */
.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.pro-ctrl-chip {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-weight: 800;
  font-size: 0.85rem;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

.pro-date-chip {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge.status-pending,
.badge-pending-admin {
  background: #fffbeb !important;
  color: #b45309 !important;
  border: 1px solid #fde68a !important;
}

.status-badge.status-approved,
.badge-approved-admin {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
}

.status-badge.status-received,
.badge-received-final {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0 !important;
}

.status-badge.status-rejected,
.badge-rejected {
  background: #fee2e2 !important;
  color: #b91c1c !important;
  border: 1px solid #fca5a5 !important;
}

/* Vendor & Terms */
.card-vendor-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-vendor-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
}

.card-terms-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.card-term-pill {
  font-size: 0.72rem;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* 3-Column Financial Stat Grid */
.card-stat-grid {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 6px !important;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  margin: 0.25rem 0;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.stat-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.stat-col.stat-profit {
  border-left: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  padding: 0 4px;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stat-val {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Staff & Approvals Row */
.card-staff-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: #64748b;
  padding-top: 0.25rem;
  border-top: 1px dashed #f1f5f9;
}

.staff-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* Card Action Buttons */
.card-workflow-row {
  display: flex;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.25rem;
}

.card-workflow-notice {
  margin-top: 0.25rem;
  width: 100%;
}

.card-actions-grid {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 0.2rem;
}

.card-action-btn {
  flex: 1;
  min-height: 40px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 700 !important;
  font-size: 0.8rem !important;
  border-radius: 8px !important;
  padding: 6px 12px !important;
}

/* Toolbar & Action Bar Layouts on Small Screens */
@media (max-width: 768px) {
  .top-action-bar-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .top-action-bar-grid .btn {
    width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
    min-height: 48px !important;
    padding: 0.65rem 0.4rem !important;
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    line-height: 1.25 !important;
    text-align: center !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    border-radius: 10px !important;
  }
  .pro-filter-strip {
    display: flex !important;
    gap: 0.45rem !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 0.4rem !important;
    scrollbar-width: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .pro-filter-strip::-webkit-scrollbar {
    display: none !important;
  }
  .pro-filter-btn {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    font-size: 0.78rem !important;
    padding: 6px 14px !important;
    border-radius: 9999px !important;
  }
}

@media (max-width: 640px) {
  .pro-search-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .pro-search-input-wrap {
    width: 100% !important;
    min-width: 0 !important;
  }
  .pro-search-btns {
    width: 100% !important;
    display: flex !important;
    gap: 0.5rem !important;
  }
  .pro-search-btns .btn {
    flex: 1 !important;
    min-height: 42px !important;
    justify-content: center !important;
    font-weight: 700 !important;
  }
  .pro-table-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .pro-sheet {
    padding: 1.15rem 0.85rem !important;
    border-radius: var(--radius-md) !important;
  }
  .pro-company-title {
    font-size: 1.1rem !important;
  }
  .pro-doc-title {
    font-size: 0.95rem !important;
  }
}


/* ==========================================================================
   OUTBOUND & MOBILE RESPONSIVE CSS FIXES
   Prevents table blow-out, navbar truncation, and horizontal overflow on mobile
   ========================================================================== */

/* 1. Global Viewport & Flex Utilities */
html {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: pan-y;
}

.main-content {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

.card {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.flex-between {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.flex-wrap {
  flex-wrap: wrap !important;
}

/* Ensure navbar always fills full width and never truncates */
.navbar, .mobile-nav {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.nav-container {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* 2. Responsive Segmented Control */
.segmented-control {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
  border: 1px solid #e2e8f0;
  box-sizing: border-box;
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #64748b;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.segmented-btn:hover {
  color: #1e293b;
  background: rgba(255, 255, 255, 0.6);
}

.segmented-btn.active {
  background: #4f46e5 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35) !important;
}

/* 3. Table Responsive Container */
.table-responsive {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  display: block !important;
  box-sizing: border-box !important;
}

.outbound-desktop-table {
  display: block;
}
.outbound-mobile-cards {
  display: none;
}

/* 4. Phone Screen Rules (<640px) */
@media (max-width: 640px) {
  .main-content {
    padding: 0.75rem 0.65rem 2.5rem !important;
    gap: 1rem !important;
  }

  .outbound-top-card,
  .card.flex-between {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.85rem !important;
    padding: 1.15rem 1rem !important;
  }

  /* Segmented Control: Stack to full width buttons on phone */
  .segmented-control {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    gap: 6px !important;
    padding: 6px !important;
    background: #f1f5f9 !important;
    border-radius: 12px !important;
  }

  .segmented-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
    min-height: 42px !important;
    border-radius: 8px !important;
  }

  /* Step tracker on upload section */
  .step-tracker {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.35rem !important;
    padding: 0.65rem 0.85rem !important;
  }
  .step-sep {
    display: none !important;
  }
  .step-node {
    font-size: 0.75rem !important;
  }

  /* Form Grids: Single Column on Mobile */
  #outboundCreateSection .grid-4,
  #outboundCreateSection .grid-2,
  #outboundUploadSection .grid-4,
  #outboundUploadSection .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  /* Outbound Items Table */
  #outboundItemsTable,
  #reconTable {
    min-width: 580px !important;
  }

  /* Action Buttons Stacked */
  #outboundCreateSection .flex-end,
  #fileReconSection .flex-between {
    display: flex !important;
    flex-direction: column-reverse !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  #outboundCreateSection .flex-end button,
  #fileReconSection .flex-between button {
    width: 100% !important;
    min-height: 44px !important;
    justify-content: center !important;
  }

  /* Switch Table to Cards */
  .outbound-desktop-table {
    display: none !important;
  }
  .outbound-mobile-cards {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .segmented-control {
    display: flex !important;
    width: 100% !important;
  }
  .segmented-btn {
    flex: 1 !important;
    justify-content: center !important;
  }
}


/* ==========================================================================
   ADVANCED MOBILE & TABLET CSS FIXES (TOUCH, FONTS, SCROLLING & ACCESSIBILITY)
   ========================================================================== */

/* 1. Universal iOS Zoom Prevention (16px Input Floor on <= 768px) */
@media (max-width: 768px) {
  input, select, textarea,
  .form-input, .form-select, .form-textarea,
  .pro-cell-input,
  input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
    font-size: 16px !important;
  }
}

/* 2. Mobile & Tablet Touch Target Standards & Safe Scrolling Clearance */
@media (max-width: 1024px) {
  .btn, button, .modal-close, .mobile-item, .drawer-item, .pro-filter-btn {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    cursor: pointer !important;
  }

  .btn {
    min-height: 44px !important;
    font-size: 0.88rem !important;
  }

  .btn-sm {
    min-height: 40px !important;
    padding: 0.5rem 0.85rem !important;
    font-size: 0.84rem !important;
  }

  .btn, .card-action-btn, .top-action-bar-grid .btn {
    white-space: normal !important;
    word-break: break-word !important;
    text-align: center !important;
  }

  /* Ensure page content never gets cut off at bottom */
  .main-content {
    padding-bottom: 6.5rem !important;
  }

  /* Tablet table scroll container */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100% !important;
  }
}

/* 3. Enhanced Font Readability & Contrast for Phone Screens */
@media (max-width: 768px) {
  .stat-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
  }
  .stat-val {
    font-size: 0.94rem !important;
    font-weight: 800 !important;
  }
  .card-vendor-title {
    font-size: 1.05rem !important;
    font-weight: 800 !important;
  }
  .card-term-pill {
    font-size: 0.78rem !important;
    padding: 3px 8px !important;
  }
  .staff-tag {
    font-size: 0.82rem !important;
  }
  .pro-date-chip {
    font-size: 0.78rem !important;
  }
  .pro-ctrl-chip {
    font-size: 0.88rem !important;
  }
  .status-badge {
    font-size: 0.78rem !important;
    padding: 5px 11px !important;
  }
  .pro-reject-reason-box {
    font-size: 0.82rem !important;
    line-height: 1.4 !important;
  }
  .badge {
    font-size: 0.78rem !important;
    padding: 4px 9px !important;
  }
  .kpi-title {
    font-size: 0.75rem !important;
  }
  .kpi-value {
    font-size: 1.25rem !important;
  }
}

/* 4. Phone Screen Buttons Grid & Card Actions */
@media (max-width: 640px) {
  .card-actions-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }
  .card-action-btn {
    width: 100% !important;
    min-height: 44px !important;
    font-size: 0.84rem !important;
    padding: 6px 8px !important;
  }
  .card-workflow-row {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }
  .card-workflow-row .btn {
    width: 100% !important;
    min-height: 46px !important;
  }
}

/* Form Action Buttons: Stack Full-Width on Mobile */
@media (max-width: 640px) {
  #proForm .flex-end,
  #manualDeliveryForm .flex-end,
  #outboundForm .flex-end,
  .pro-prompt-btn-grid {
    display: flex !important;
    flex-direction: column-reverse !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  #proForm .flex-end .btn,
  #manualDeliveryForm .flex-end .btn,
  #outboundForm .flex-end .btn,
  .pro-prompt-btn-grid .btn {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
    font-size: 0.92rem !important;
    font-weight: 700 !important;
  }
}
