/* ==========================================================================
   CSS CUSTOM PROPERTIES (TOKENS)
   ========================================================================== */
:root {
  /* Colors - Light Theme (Default) */
  --color-primary: #0F172A; /* Slate 900 */
  --color-secondary: #1E293B; /* Slate 800 */
  --color-accent: #2563EB; /* Blue 600 */
  --color-accent-hover: #1D4ED8; /* Blue 700 */
  --color-success: #10B981; /* Emerald 500 */
  --color-warning: #F59E0B; /* Amber 500 */
  --color-danger: #EF4444; /* Red 500 */
  
  --bg-body: #F8FAFC; /* Slate 50 */
  --bg-surface: #FFFFFF; /* White */
  --bg-surface-hover: #F1F5F9; /* Slate 100 */
  
  --text-main: #0F172A;
  --text-muted: #64748B; /* Slate 500 */
  --text-inverse: #FFFFFF;
  
  --border-light: #E2E8F0; /* Slate 200 */
  --border-focus: #2563EB;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  
  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-primary: #FFFFFF;
  --color-secondary: #F8FAFC;
  --color-accent: #3B82F6; /* Blue 500 */
  --color-accent-hover: #60A5FA; /* Blue 400 */
  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-danger: #F87171;
  
  --bg-body: #020617; /* Slate 950 */
  --bg-surface: #0F172A; /* Slate 900 */
  --bg-surface-hover: #1E293B; /* Slate 800 */
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8; /* Slate 400 */
  --text-inverse: #020617;
  
  --border-light: #334155; /* Slate 700 */
  --border-focus: #3B82F6;
  
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   RESET & TYPOGRAPHY
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-main);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.2;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

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

/* ==========================================================================
   LAYOUT & GRID
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .lg\:grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
}

@media (max-width: 768px) {
  .md\:grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  /* On very small screens, force basic grids to stack */
  .grid-cols-2, .grid-cols-3, .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-8 { margin-bottom: var(--space-8); }

/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* Cards */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: all var(--transition-fast);
  gap: var(--space-2);
}

.btn-primary {
  background-color: var(--color-accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background-color: var(--border-light);
}

.btn-danger {
  background-color: var(--color-danger);
  color: #FFFFFF;
}

/* Forms */
.form-group {
  position: relative;
  margin-bottom: var(--space-4);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) 2.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 16px; /* Prevents iOS Safari auto-zoom */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.form-label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
  font-size: 0.875rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--color-success); }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: var(--color-warning); }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--color-danger); }
.badge-info { background-color: rgba(37, 99, 235, 0.1); color: var(--color-accent); }
.badge-neutral { background-color: var(--bg-surface-hover); color: var(--text-muted); }

/* Tables */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}

th {
  background-color: var(--bg-surface-hover);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--bg-surface-hover);
}

/* Alert/Toasts */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
}
.alert.hidden { display: none; }
.alert-error { background-color: rgba(239, 68, 68, 0.1); color: var(--color-danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-success { background-color: rgba(16, 185, 129, 0.1); color: var(--color-success); border: 1px solid rgba(16, 185, 129, 0.2); }

/* ==========================================================================
   APP SHELL (DASHBOARD LAYOUT)
   ========================================================================== */
.app-shell {
  display: flex;
  flex-direction: row !important;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-body);
}

/* Sidebar */
.app-sidebar {
  width: 280px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 40;
}

.sidebar-header {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border-light);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-main);
  gap: var(--space-2);
}

.sidebar-header svg {
  color: var(--color-accent);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

.nav-item.active {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--color-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Main Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top Header */
.app-header {
  height: 72px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  z-index: 30;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
}

/* Page Content */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

/* Mobile Sidebar Toggle */
.mobile-toggle {
  display: none;
}

@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-float);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .mobile-toggle {
    display: flex;
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 35; /* Just below sidebar (40) */
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-normal);
  padding: var(--space-6);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.animate-fade {
  animation: fadeIn var(--transition-normal) forwards;
}

.animate-slide-up {
  animation: slideUp var(--transition-normal) forwards;
}

/* Skeleton Loading */
@keyframes skeletonPulse {
  0% { background-color: var(--bg-surface-hover); }
  50% { background-color: var(--border-light); }
  100% { background-color: var(--bg-surface-hover); }
}

.skeleton {
  animation: skeletonPulse 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   JIDDE PROCUREMENT AND LOGISTICS PLATFORM — NEW STYLES
   ========================================================================== */

/* ── Platform-wide Page Headers ──────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Stats Cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.stat-icon.blue   { background: rgba(37,99,235,0.1);  color: #2563EB; }
.stat-icon.green  { background: rgba(16,185,129,0.1); color: #10B981; }
.stat-icon.amber  { background: rgba(245,158,11,0.1); color: #F59E0B; }
.stat-icon.red    { background: rgba(239,68,68,0.1);  color: #EF4444; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8B5CF6; }
.stat-icon.teal   { background: rgba(20,184,166,0.1); color: #14B8A6; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Shipment Cards (User Dashboard) ─────────────────────────────────────── */
.shipment-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.shipment-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.shipment-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-2);
}

.shipment-tracker-id {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-accent);
}

.shipment-ref {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
}

.shipment-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.shipment-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shipment-field-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.shipment-field-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.shipment-card-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
}

/* ── Status Badges (Global Platform) ─────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.sb-pending     { background: rgba(245,158,11,0.12); color: #D97706; }
.sb-review      { background: rgba(139,92,246,0.12); color: #7C3AED; }
.sb-verified    { background: rgba(16,185,129,0.12); color: #059669; }
.sb-rejected    { background: rgba(239,68,68,0.12);  color: #DC2626; }
.sb-assigned    { background: rgba(37,99,235,0.12);  color: #2563EB; }
.sb-waybill     { background: rgba(6,182,212,0.12);  color: #0891B2; }
.sb-warehouse   { background: rgba(20,184,166,0.12); color: #0D9488; }
.sb-packed      { background: rgba(245,158,11,0.12); color: #D97706; }
.sb-export      { background: rgba(99,102,241,0.12); color: #6366F1; }
.sb-transit     { background: rgba(59,130,246,0.12); color: #2563EB; }
.sb-arrived     { background: rgba(14,165,233,0.12); color: #0284C7; }
.sb-delivery    { background: rgba(245,158,11,0.12); color: #D97706; }
.sb-delivered   { background: rgba(16,185,129,0.12); color: #059669; }
.sb-cargo-sea   { background: rgba(13,91,166,0.1);  color: #0D47A1; }
.sb-cargo-air   { background: rgba(6,182,212,0.1);  color: #0891B2; }

.verification-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vb-pending    { background: rgba(245,158,11,0.12); color: #D97706; }
.vb-under_review { background: rgba(139,92,246,0.12); color: #7C3AED; }
.vb-verified   { background: rgba(16,185,129,0.12); color: #059669; }
.vb-rejected   { background: rgba(239,68,68,0.12);  color: #DC2626; }
.vb-info_requested { background: rgba(20,184,166,0.12); color: #0D9488; }

/* ── Timeline ────────────────────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-light);
}

.timeline-event {
  position: relative;
  padding-bottom: var(--space-5);
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--bg-surface);
  z-index: 1;
}

.timeline-event.completed::before { background: var(--color-success); }
.timeline-event.current::before { background: var(--color-warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.2); }
.timeline-event.active::before { background: var(--color-accent); }

.timeline-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.timeline-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-location {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-remarks {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

/* ── Shipment Form ────────────────────────────────────────────────────────── */
.shipment-form {
  max-width: 800px;
  margin: 0 auto;
}

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.form-section-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-section-title svg { color: var(--color-accent); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

.form-input-plain {
  width: 100%;
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input-plain:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

textarea.form-input-plain {
  resize: vertical;
  min-height: 80px;
}

select.form-input-plain {
  cursor: pointer;
  appearance: auto;
}

.cargo-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.cargo-type-option {
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-fast);
  background: var(--bg-surface);
}

.cargo-type-option:hover {
  border-color: var(--color-accent);
}

.cargo-type-option.selected {
  border-color: var(--color-accent);
  background: rgba(37,99,235,0.05);
}

.cargo-type-option input { display: none; }

.cargo-type-icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
  display: block;
}

.cargo-type-label {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-main);
}

.cargo-type-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cargo-type-option.selected .cargo-type-label { color: var(--color-accent); }

/* ── Filter Bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  align-items: center;
}

.filter-bar select,
.filter-bar input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
}

.filter-bar .search-input {
  flex: 1;
  min-width: 200px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
}

/* ── Admin Shipment Table ─────────────────────────────────────────────────── */
.admin-shipment-table .col-ref     { min-width: 120px; }
.admin-shipment-table .col-track    { min-width: 130px; }
.admin-shipment-table .col-dest     { min-width: 130px; }
.admin-shipment-table .col-cargo    { min-width: 90px; }
.admin-shipment-table .col-status  { min-width: 130px; }
.admin-shipment-table .col-cbm      { min-width: 80px; text-align: right; }
.admin-shipment-table .col-kg       { min-width: 80px; text-align: right; }
.admin-shipment-table .col-warehouse { min-width: 110px; }
.admin-shipment-table .col-actions  { min-width: 100px; text-align: center; }

/* ── Admin Action Buttons ─────────────────────────────────────────────────── */
.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-sm-primary   { background: var(--color-accent);  color: #fff; }
.btn-sm-primary:hover { background: var(--color-accent-hover); }
.btn-sm-success   { background: var(--color-success); color: #fff; }
.btn-sm-warning   { background: var(--color-warning); color: #fff; }
.btn-sm-danger    { background: var(--color-danger);  color: #fff; }
.btn-sm-secondary { background: var(--bg-surface-hover); color: var(--text-main); border: 1px solid var(--border-light); }
.btn-sm-secondary:hover { background: var(--border-light); }

/* ── Warehouse Cards ──────────────────────────────────────────────────────── */
.warehouse-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.warehouse-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.warehouse-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.warehouse-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
}

.warehouse-code {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  background: var(--bg-surface-hover);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.warehouse-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(37,99,235,0.08);
  color: #2563EB;
}

.warehouse-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.warehouse-detail-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.warehouse-detail-value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.warehouse-actions {
  display: flex;
  gap: var(--space-2);
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-3);
}

/* ── Notifications Panel ──────────────────────────────────────────────────── */
.notification-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-surface-hover);
  margin-bottom: var(--space-2);
  align-items: flex-start;
  transition: background var(--transition-fast);
}

.notification-item:hover { background: var(--border-light); }
.notification-item.unread { background: rgba(37,99,235,0.06); border-left: 3px solid var(--color-accent); }

.notification-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.notification-content { flex: 1; }
.notification-title { font-size: 0.8rem; font-weight: 700; color: var(--text-main); }
.notification-message { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.notification-time { font-size: 0.7rem; color: var(--text-muted); }

/* ── Detail Panels ────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.detail-item {
  background: var(--bg-surface-hover);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.detail-item-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-item-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}

.tab-btn {
  padding: var(--space-3) var(--space-4);
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Waybill Preview ─────────────────────────────────────────────────────── */
.waybill-preview {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 800px;
  margin: 0 auto;
}

.waybill-preview-header {
  padding: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
}

.waybill-preview-header.air  { background: linear-gradient(135deg, #1565C0, #0D47A1); color: white; }
.waybill-preview-header.sea  { background: linear-gradient(135deg, #0D3B66, #0A2F52); color: white; }

.waybill-title {
  font-size: 1.5rem;
  font-weight: 800;
}

.waybill-subtitle {
  font-size: 0.875rem;
  opacity: 0.8;
}

.waybill-number {
  font-family: 'Courier New', monospace;
  font-size: 0.875rem;
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  text-align: right;
}

.waybill-section {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-light);
}

.waybill-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

/* ── Empty States ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-4);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.3;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: var(--space-2);
}

.empty-state-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-5);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  margin-top: var(--space-6);
}

.page-btn {
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.page-btn:hover { background: var(--bg-surface-hover); }
.page-btn.active { background: var(--color-accent); color: white; border-color: var(--color-accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Scrollable Table Container ────────────────────────────────────────────── */
.table-scroll {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

/* ── Utility Classes ──────────────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'Courier New', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .shipment-card-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; }
  .app-content { padding: var(--space-4); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .shipment-card-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}/* ==========================================================================
   COMPREHENSIVE MOBILE RESPONSIVE STYLES
   ========================================================================== */

/* ── Safe Area & Viewport Fixes ──────────────────────────────────────── */
html {
  /* Prevent iOS font size inflation */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Touch action for better mobile scrolling */
* {
  -webkit-tap-highlight-color: transparent;
}

/* ── Extra Small Devices (320px - 374px) ──────────────────────────── */
@media (max-width: 374px) {
  :root {
    --space-2: 0.375rem;
    --space-3: 0.5rem;
    --space-4: 0.75rem;
  }
  
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.25rem !important; }
  h3 { font-size: 1.1rem !important; }
  
  .btn { padding: 0.5rem 0.875rem; font-size: 0.875rem; }
  .form-input-plain { font-size: 14px; }
  .card { padding: var(--space-4); }
  .container { padding: 0 var(--space-3); }
}

/* ── Small Devices (375px - 767px) - iPhones & Android ───────────────── */
@media (min-width: 320px) and (max-width: 767px) {
  /* Typography */
  html { font-size: 15px; }
  
  body {
    overflow-x: hidden;
  }
  
  /* Container adjustments */
  .container {
    padding: 0 var(--space-4);
    max-width: 100%;
  }
  
  /* Card improvements */
  .card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }
  
  /* Button touch targets (minimum 44px for iOS) */
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-3) var(--space-4);
  }
  
  /* Form improvements */
  .form-input, .form-input-plain {
    font-size: 16px; /* Prevent iOS zoom */
    padding: var(--space-3);
    min-height: 48px;
  }
  
  select.form-input-plain {
    min-height: 48px;
  }
  
  /* Stats on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
  
  .stat-card {
    padding: var(--space-3);
    flex-direction: column;
    text-align: center;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
  }
  
  .stat-value {
    font-size: 1.25rem;
  }
  
  /* Shipment cards */
  .shipment-card {
    padding: var(--space-3);
  }
  
  .shipment-card-grid {
    grid-template-columns: 1fr;
  }
  
  .shipment-card-actions {
    flex-direction: column;
  }
  
  .shipment-card-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Filter bar */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-bar select,
  .filter-bar input,
  .filter-bar .search-input {
    width: 100%;
    min-height: 44px;
  }
  
  /* Tables */
  .table-wrapper {
    margin: 0 calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  table {
    font-size: 0.8rem;
  }
  
  th, td {
    padding: var(--space-2) var(--space-3);
  }
  
  /* Admin tables */
  .admin-shipment-table th,
  .admin-shipment-table td {
    padding: var(--space-2);
    font-size: 0.75rem;
  }
  
  /* Page header */
  .page-header {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .page-title {
    font-size: 1.25rem;
  }
  
  /* Modal on mobile */
  .modal-content {
    margin: var(--space-4);
    max-height: calc(100vh - var(--space-8));
    padding: var(--space-4);
  }
  
  /* Waybill preview */
  .waybill-preview {
    border-radius: 0;
    margin: 0 calc(var(--space-4) * -1);
  }
  
  .waybill-preview-header {
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-4);
  }
  
  .waybill-title {
    font-size: 1.25rem;
  }
  
  .waybill-section {
    padding: var(--space-3) var(--space-4);
  }
}

/* ── Tablet Devices (768px - 1023px) ──────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .shipment-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Large Tablets & Small Laptops (768px - 1199px) ────────────────── */
@media (max-width: 1199px) {
  .container {
    max-width: 100%;
  }
}

/* ── Landscape Mobile Adjustments ──────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    padding: var(--space-6) 0;
  }
  
  .hero-title {
    font-size: 2rem;
  }
  
  .stats-section {
    padding: var(--space-4) 0;
  }
  
  .stat-num {
    font-size: 2rem;
  }
}

/* ── iOS Safari Specific Fixes ────────────────────────────────────── */
@supports (-webkit-touch-callout: none) {
  /* iOS Safari specific styles */
  .app-content {
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar-nav {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Fix for iOS input zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ── Android Chrome Specific Fixes ─────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Touch device optimizations */
  .btn:hover {
    transform: none;
  }
  
  .card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
  }
  
  /* Active states for touch */
  .btn:active {
    transform: scale(0.98);
  }
  
  .nav-item:active {
    background-color: var(--bg-surface-hover);
  }
}

/* ── Sidebar Mobile Optimizations ──────────────────────────────────── */
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 50;
    box-shadow: var(--shadow-float);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  .app-sidebar.open ~ .sidebar-overlay {
    display: block;
    opacity: 1;
  }
  
  .mobile-toggle {
    display: flex !important;
    min-width: 44px;
    min-height: 44px;
  }
  
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
  
  .app-main {
    width: 100%;
  }
}

/* ── Dashboard & Portal Layout Responsive ─────────────────────────── */
@media (max-width: 1024px) {
  body.app-shell {
    flex-direction: column;
  }
  
  /* Portal layouts */
  .portal-inner {
    padding: var(--space-4);
  }
  
  .portal-page-header {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .portal-topbar {
    padding: 0 var(--space-4);
    height: 56px;
  }
  
  .track-search {
    display: none; /* Hide on mobile, show simplified version */
  }
  
  .summary-ribbon {
    grid-template-columns: repeat(2, 1fr);
    margin: 0 calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .summary-item {
    padding: var(--space-3) var(--space-4);
  }
  
  .summary-val {
    font-size: 1.5rem;
  }
  
  /* Portal layout grid */
  .portal-layout {
    grid-template-columns: 1fr;
  }
  
  /* Panel responsive */
  .panel {
    margin-left: calc(var(--space-4) * -1);
    margin-right: calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .panel-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
}

/* ── Login/Register Responsive ─────────────────────────────────────── */
@media (max-width: 767px) {
  .auth-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  
  .auth-panel {
    padding: var(--space-6) var(--space-4);
    min-height: 100vh;
    justify-content: flex-start;
    padding-top: var(--space-8);
  }
  
  .auth-form-container {
    max-width: 100%;
  }
  
  .auth-graphic {
    display: none;
  }
  
  .auth-card {
    padding: var(--space-4);
    width: 100%;
    box-shadow: none;
    border: none;
  }
}

/* ── Landing Page Mobile Responsive ────────────────────────────────── */
@media (max-width: 767px) {
  /* Navbar mobile */
  .navbar {
    padding: var(--space-3) var(--space-4);
    height: auto;
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .nav-links {
    display: none; /* Consider hamburger menu */
  }
  
  /* Hero mobile */
  .hero-section {
    padding: var(--space-8) 0 var(--space-12);
  }
  
  .hero-title {
    font-size: clamp(2rem, 8vw, 2.5rem);
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .hero-actions {
    flex-direction: column;
    width: 100%;
    gap: var(--space-3);
  }
  
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Track demo mobile */
  .track-demo {
    margin: var(--space-6) auto 0;
    padding: var(--space-4);
    max-width: 100%;
  }
  
  .track-demo-form {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  /* Stats mobile */
  .stats-section {
    padding: var(--space-6) 0;
  }
  
  .stats-grid {
    flex-direction: column;
  }
  
  .stat-box {
    padding: var(--space-4) 0;
  }
  
  .stat-num {
    font-size: 2rem;
  }
  
  /* Features mobile */
  .features-section {
    padding: var(--space-8) 0;
  }
  
  .feature-card {
    padding: var(--space-5);
  }
  
  .feature-icon {
    width: 48px;
    height: 48px;
  }
  
  /* Route section mobile */
  .route-section {
    padding: var(--space-8) var(--space-4);
  }
  
  .route-visual {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .route-line {
    width: 2px;
    height: 40px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.5), transparent);
  }
  
  /* Footer mobile */
  .footer {
    padding: var(--space-6) var(--space-4) var(--space-4);
    text-align: center;
  }
  
  .footer-links {
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ── Track Page Mobile Responsive ─────────────────────────────────── */
@media (max-width: 767px) {
  .track-hero {
    padding: var(--space-8) 0;
  }
  
  .track-search-box {
    margin: 0 var(--space-4);
    padding: var(--space-4);
  }
  
  #track-form {
    flex-direction: column;
  }
  
  #track-input {
    min-height: 48px;
    font-size: 16px;
  }
  
  #track-btn {
    width: 100%;
    min-height: 48px;
  }
  
  /* Timeline mobile - horizontal scroll */
  .v-timeline-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-4);
  }
  
  .v-timeline {
    min-width: 600px;
  }
  
  .v-step {
    width: 80px;
  }
  
  .v-step-dot {
    width: 40px;
    height: 40px;
  }
  
  /* Meta grid mobile */
  .meta-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  /* Map mobile */
  #shipment-map {
    height: 250px;
    margin-left: calc(var(--space-4) * -1);
    margin-right: calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  /* History timeline mobile */
  .history-timeline {
    margin-left: var(--space-2);
    padding-left: var(--space-4);
  }
  
  /* Codes panel mobile */
  .codes-panel {
    padding: var(--space-4);
  }
  
  .codes-flex {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .code-item {
    min-width: 100%;
  }
}

/* ── Form Responsive ──────────────────────────────────────────────── */
@media (max-width: 767px) {
  .form-section {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    margin-left: calc(var(--space-4) * -1);
    margin-right: calc(var(--space-4) * -1);
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  
  .form-section-title {
    font-size: 0.85rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  /* Cargo type selector mobile */
  .cargo-type-selector {
    grid-template-columns: 1fr;
  }
  
  /* Header actions mobile */
  .header-actions {
    gap: var(--space-2);
  }
  
  .header-actions .btn {
    padding: var(--space-2) var(--space-3);
    font-size: 0.8rem;
  }
}

/* ── Table Scroll Enhancement for Mobile ──────────────────────────── */
@media (max-width: 767px) {
  .table-scroll {
    max-height: 400px;
    border-radius: var(--radius-md);
    margin: 0;
  }
  
  /* Horizontal scroll for tables */
  .table-wrapper table,
  .table-scroll table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  
  .table-wrapper th,
  .table-wrapper td,
  .table-scroll th,
  .table-scroll td {
    white-space: nowrap;
  }
}

/* ── Animations for Mobile Performance ─────────────────────────────── */
@media (max-width: 767px) {
  .animate-slide-up,
  .animate-fade {
    animation: none;
    opacity: 1;
    transform: none;
  }
  
  /* Reduce motion for users who prefer it */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
}

/* ── Print Styles (Hide Mobile Elements) ──────────────────────────── */
@media print {
  .mobile-toggle,
  .sidebar-overlay,
  .sidebar-nav {
    display: none !important;
  }
  
  .app-sidebar {
    position: static;
    transform: none;
  }
}

/* ── High Contrast Mode Support ───────────────────────────────────── */
@media (prefers-contrast: high) {
  :root {
    --border-light: #000;
    --text-muted: #333;
  }
  
  .btn {
    border: 2px solid currentColor;
  }
  
  .card,
  .form-input-plain {
    border: 2px solid currentColor;
  }
}

/* ── Dark Mode High Contrast ───────────────────────────────────────── */
@media (prefers-contrast: high) and (prefers-color-scheme: dark) {
  :root {
    --border-light: #fff;
    --text-muted: #ccc;
  }
}

/* ── Container Max Width Adjustments ───────────────────────────────── */
@media (max-width: 640px) {
  .container {
    padding: 0 var(--space-3);
  }
  
  .shipment-form {
    padding: 0;
  }
}

/* ── Accessibility: Focus Visible ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ── Safe Area Insets for Modern Mobile Browsers ───────────────────── */
@supports (padding: max(0px)) {
  .app-header,
  .app-content,
  .portal-topbar {
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
  }
  
  .app-content {
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  }
  
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Notch / Dynamic Island Support ───────────────────────────────── */
@supports (padding: max(0px)) {
  .navbar {
    padding-top: max(var(--space-3), env(safe-area-inset-top));
  }
}

/* ==========================================================================
   ACCESSIBILITY ENHANCEMENTS (WCAG 2.1 AA+)
   ========================================================================== */

/* ── Skip to Content Link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent);
  color: white;
  padding: var(--space-2) var(--space-4);
  z-index: 1000;
  text-decoration: none;
  font-weight: 700;
  border-radius: 0 0 var(--radius-md) 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Screen Reader Only (SR-Only) ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ── ARIA Live Regions ─────────────────────────────────────────────────── */
[aria-live] {
  position: relative;
}

[aria-live="polite"] {
  clip-path: inset(50%);
}

[aria-live="assertive"] {
  clip-path: inset(50%);
}

/* ── Improved Focus Indicators ─────────────────────────────────────────── */
button:focus-visible,
.btn:focus-visible,
[role="button"]:focus-visible,
input[type="checkbox"]:focus-visible + label::before,
input[type="radio"]:focus-visible + label::before,
select:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.3);
}

a:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Form Accessibility ─────────────────────────────────────────────────── */
.form-input:focus-visible,
.form-input-plain:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 0;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.2);
}

.form-input.error,
.form-input-plain.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.15);
}

.form-label.error {
  color: var(--color-danger);
}

.required-indicator {
  color: var(--color-danger);
  margin-left: 2px;
  font-weight: 700;
}

.form-error {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* ── Disabled State Accessibility ──────────────────────────────────────── */
button:disabled,
.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

button:disabled:focus-visible,
.btn:disabled:focus-visible {
  outline: 2px dashed var(--color-accent);
  outline-offset: 2px;
}

/* ── Touch Target Size (Minimum 44x44px per WCAG) ─────────────────────── */
button,
.btn,
a[class*="btn"],
.icon-btn,
.nav-item,
.tab-btn,
.page-btn,
[role="button"],
[role="tab"],
[role="menuitem"],
.pagination .page-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Table Accessibility ─────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
}

caption {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  padding: var(--space-2);
  text-align: left;
}

th[aria-sort] {
  cursor: pointer;
}

th[aria-sort]::after {
  content: '';
  display: inline-block;
  margin-left: var(--space-2);
  width: 0;
  height: 0;
  border: 5px solid transparent;
  vertical-align: middle;
}

th[aria-sort="ascending"]::after {
  border-bottom: 5px solid var(--text-muted);
}

th[aria-sort="descending"]::after {
  border-top: 5px solid var(--text-muted);
}

/* ── Modal Accessibility ────────────────────────────────────────────────── */
.modal-overlay {
  role: dialog;
  aria-modal: true;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 var(--space-4);
}

.modal-content:focus {
  outline: none;
}

/* ── Loading States ──────────────────────────────────────────────────────── */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--border-light);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn.loading {
  color: transparent !important;
  position: relative;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Alert Accessibility ────────────────────────────────────────────────── */
.alert[role="alert"] {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.alert[role="alert"]:empty {
  display: none;
}

[role="status"],
[role="log"],
[role="marquee"] {
  clip-path: inset(50%);
}

/* ── Landmark Regions ───────────────────────────────────────────────────── */
[role="banner"] {
  min-height: 72px;
}

[role="navigation"] {
  min-height: 44px;
}

[role="main"] {
  flex: 1;
}

[role="contentinfo"] {
  margin-top: auto;
}

/* ── Reduced Motion Preference ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .loading::after,
  .btn.loading::after {
    animation: none;
  }
  
  .skeleton {
    animation: none;
    background: var(--bg-surface-hover);
  }
  
  .card:hover,
  .stat-card:hover,
  .shipment-card:hover,
  .warehouse-card:hover,
  .feature-card:hover {
    transform: none;
  }
}

/* ── Print Accessibility ────────────────────────────────────────────────── */
@media print {
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  a[href^="#"]::after,
  a[href^="javascript"]::after {
    content: "";
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  table {
    page-break-inside: avoid;
  }
  
  .skip-link,
  .mobile-toggle,
  .sidebar-overlay,
  button,
  .no-print {
    display: none !important;
  }
}

/* ── Checkbox & Radio Accessibility ──────────────────────────────────────── */
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-accent);
}

/* ── High Contrast Mode ────────────────────────────────────────────────── */
.high-contrast {
  --text-main: #000000;
  --text-muted: #333333;
  --border-light: #000000;
  --color-accent: #0000EE;
}

/* ── Dark Mode Accessibility Enhancements ───────────────────────────────── */
[data-theme="dark"] .form-input:focus-visible,
[data-theme="dark"] .form-input-plain:focus-visible {
  box-shadow: 0 0 0 5px rgba(96, 165, 250, 0.4);
}

[data-theme="dark"] button:focus-visible,
[data-theme="dark"] .btn:focus-visible {
  box-shadow: 0 0 0 5px rgba(96, 165, 250, 0.4);
}

/* ── Responsive Visibility Utility Classes ── */
@media (min-width: 1025px) {
  .mobile-only { display: none !important; }
}
@media (max-width: 1024px) {
  .desktop-only { display: none !important; }
}
