/* ============================================================
   MEP OSM Solutions – AI Tracking Platform
   Design System v2.0  |  Brand: Navy / Steel Blue
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Brand Palette */
  --navy:      #0c1825;
  --primary:   #16447b;
  --mid:       #2951a0;
  --accent:    #4884cd;
  --heading:   #005583;
  --white:     #ffffff;
  --off-white: #f0f4f8;
  --surface:   #f7f9fc;

  /* Neutrals */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status Colors */
  --status-delivered:       #16a34a;
  --status-in-transit:      #1d4ed8;
  --status-booking:         #1d4ed8;
  --status-arrived-hub:     #1d4ed8;
  --status-departed-origin: #1d4ed8;
  --status-customs:         #7c3aed;
  --status-out-delivery:    #0891b2;
  --status-delayed:         #d97706;
  --status-exception:       #dc2626;
  --status-pending:         #6b7280;
  --status-unknown:         #6b7280;

  /* Typography */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Sizing */
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.18);

  /* Transitions */
  --t-fast: 120ms ease;
  --t-base: 200ms ease;
  --t-slow: 350ms ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================================
   LAYOUT
   ============================================================ */

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--t-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-text strong {
  color: var(--white);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .02em;
}

.sidebar-logo-text span {
  color: rgba(255,255,255,.5);
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--mid);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
}

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

.sidebar-user-name {
  color: var(--white);
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: var(--accent);
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-section-label {
  padding: 10px 20px 4px;
  color: rgba(255,255,255,.35);
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--white);
  text-decoration: none;
}

.nav-item.active {
  background: rgba(72,132,205,.15);
  color: var(--white);
  border-left-color: var(--accent);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--white);
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}

.topbar-subtitle {
  font-size: .78rem;
  color: var(--gray-500);
  font-weight: 400;
  margin-left: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--gray-600);
  font-size: 1.2rem;
}

.topbar-logo {
  display: none;
}

.topbar-logo img {
  height: 28px;
  width: auto;
}

/* Page body */
.page-body {
  padding: 24px;
  flex: 1;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}

.card-subtitle {
  font-size: .78rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.card-body {
  padding: 20px 22px;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: box-shadow var(--t-base);
}

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

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

.stat-icon.blue   { background: #dbeafe; color: var(--mid); }
.stat-icon.green  { background: #dcfce7; color: var(--status-delivered); }
.stat-icon.amber  { background: #fef3c7; color: var(--status-delayed); }
.stat-icon.red    { background: #fee2e2; color: var(--status-exception); }
.stat-icon.purple { background: #f3e8ff; color: var(--status-customs); }
.stat-icon.cyan   { background: #cffafe; color: var(--status-out-delivery); }
.stat-icon.navy   { background: #dce5f0; color: var(--navy); }

.stat-data { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: .78rem;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-delta {
  font-size: .75rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}

.stat-delta.up   { color: var(--status-delivered); }
.stat-delta.down { color: var(--status-exception); }
.stat-delta.flat { color: var(--gray-400); }

/* ============================================================
   STATUS BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-delivered        { background: #dcfce7; color: var(--status-delivered); }
.badge-in-transit       { background: #dbeafe; color: var(--status-in-transit); }
.badge-booking          { background: #dbeafe; color: var(--status-booking); }
.badge-arrived-hub      { background: #dbeafe; color: var(--status-arrived-hub); }
.badge-departed-origin  { background: #dbeafe; color: var(--status-departed-origin); }
.badge-customs          { background: #f3e8ff; color: var(--status-customs); }
.badge-out-delivery     { background: #cffafe; color: var(--status-out-delivery); }
.badge-delayed          { background: #fef3c7; color: var(--status-delayed); }
.badge-exception        { background: #fee2e2; color: var(--status-exception); }
.badge-pending          { background: var(--gray-100); color: var(--status-pending); }
.badge-unknown          { background: var(--gray-100); color: var(--status-unknown); }

.badge-role-admin  { background: #dbeafe; color: var(--primary); }
.badge-role-worker { background: var(--gray-100); color: var(--gray-600); }

.badge-sm { padding: 2px 8px; font-size: .66rem; }
.badge-lg { padding: 5px 14px; font-size: .8rem; }

/* Shipment type */
.badge-air { background: #cffafe; color: #0e7490; }
.badge-sea { background: #dbeafe; color: #1e40af; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  font-family: var(--font-sans);
}

.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--mid); border-color: var(--mid); text-decoration: none; color: var(--white); }

.btn-accent {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--mid); border-color: var(--mid); text-decoration: none; color: var(--white); }

.btn-navy {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.btn-navy:hover { background: var(--primary); border-color: var(--primary); text-decoration: none; color: var(--white); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); text-decoration: none; }

.btn-danger {
  background: var(--status-exception);
  color: var(--white);
  border-color: var(--status-exception);
}
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: var(--white); }

.btn-success {
  background: var(--status-delivered);
  color: var(--white);
  border-color: var(--status-delivered);
}
.btn-success:hover { background: #15803d; text-decoration: none; color: var(--white); }

.btn-sm  { padding: 6px 13px; font-size: .78rem; }
.btn-lg  { padding: 12px 26px; font-size: .95rem; }
.btn-xl  { padding: 15px 32px; font-size: 1rem; }
.btn-icon-only { padding: 8px; width: 36px; height: 36px; border-radius: var(--radius-sm); }

.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .required { color: var(--status-exception); margin-left: 2px; }

.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--gray-800);
  font-family: var(--font-sans);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.form-control::placeholder { color: var(--gray-400); }
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(72,132,205,.18);
}
.form-control.is-invalid { border-color: var(--status-exception); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
.form-control.is-valid { border-color: var(--status-delivered); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: .75rem; color: var(--gray-500); margin-top: 5px; }
.form-error { font-size: .75rem; color: var(--status-exception); margin-top: 5px; display: none; }
.form-error.show { display: block; }

.form-row {
  display: grid;
  gap: 16px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   TABLE
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .845rem;
}

.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover { color: var(--primary); }
.data-table thead th.sort-asc::after  { content: ' ↑'; }
.data-table thead th.sort-desc::after { content: ' ↓'; }

.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--t-fast);
}

.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: #f0f6ff; }

.data-table td {
  padding: 12px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table td.mono {
  font-family: var(--font-mono);
  font-size: .8rem;
}

.data-table td .text-muted {
  font-size: .75rem;
  color: var(--gray-400);
}

/* Table toolbar */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  outline: none;
  transition: border-color var(--t-fast);
  font-family: var(--font-sans);
}

.search-box input:focus { border-color: var(--accent); background: var(--white); }

.search-box .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: .85rem;
  pointer-events: none;
}

.filter-select {
  padding: 9px 32px 9px 12px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  outline: none;
  font-family: var(--font-sans);
}

.filter-select:focus { border-color: var(--accent); }

/* Empty state */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: .4;
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: .85rem;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* ============================================================
   TIMELINE
   ============================================================ */

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item {
  position: relative;
  padding-bottom: 24px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: -24px; top: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem;
  z-index: 1;
}

.timeline-item.current .timeline-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--white);
  box-shadow: 0 0 0 4px rgba(72,132,205,.2);
}

.timeline-item.delivered .timeline-dot {
  background: var(--status-delivered);
  border-color: var(--status-delivered);
  color: var(--white);
}

.timeline-item.exception .timeline-dot {
  background: var(--status-exception);
  border-color: var(--status-exception);
  color: var(--white);
}

.timeline-item.delayed .timeline-dot {
  background: var(--status-delayed);
  border-color: var(--status-delayed);
  color: var(--white);
}

.timeline-content {}

.timeline-date {
  font-size: .72rem;
  color: var(--gray-400);
  font-weight: 500;
  margin-bottom: 2px;
}

.timeline-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 2px;
}

.timeline-location {
  font-size: .78rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12,24,37,.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(.97);
  transition: transform var(--t-base);
}

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

.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

.modal-header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--t-fast);
  line-height: 1;
}

.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }

.modal-body { padding: 22px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}

.alert-icon { flex-shrink: 0; font-size: .9rem; margin-top: 1px; }

.alert-info    { background: #dbeafe; border-color: #93c5fd; color: var(--primary); }
.alert-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* Toast container */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.toast {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: .84rem;
  border-left: 4px solid var(--accent);
  animation: slideInToast .25s ease;
}

.toast.success { border-left-color: var(--status-delivered); }
.toast.error   { border-left-color: var(--status-exception); }
.toast.warning { border-left-color: var(--status-delayed); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-weight: 700; color: var(--gray-800); margin-bottom: 2px; }
.toast-msg   { color: var(--gray-500); font-size: .8rem; }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }

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

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 20px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 7px;
}

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

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

/* ============================================================
   SPINNER & LOADING
   ============================================================ */

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 50;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--primary) 50%, var(--mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 50%, rgba(72,132,205,.15) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(255,255,255,.05) 0%, transparent 40%);
  pointer-events: none;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  padding: 40px;
  position: relative;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 12px;
  box-shadow: 0 8px 24px rgba(22,68,123,.35);
}

.login-app-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 3px;
}

.login-app-sub {
  font-size: .78rem;
  color: var(--gray-500);
  letter-spacing: .03em;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: .84rem;
  color: var(--gray-500);
  margin-bottom: 24px;
}

/* ============================================================
   PAGE-SPECIFIC LAYOUT HELPERS
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-text { flex: 1; min-width: 0; }
.page-header-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.2;
}
.page-header-sub {
  font-size: .84rem;
  color: var(--gray-500);
  margin-top: 4px;
}

.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Info grid (shipment detail) */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0;
}

.info-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
  border-right: 1px solid var(--gray-100);
}

.info-item:nth-child(even) { border-right: none; }

.info-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  font-weight: 600;
  margin-bottom: 4px;
}

.info-value {
  font-size: .9rem;
  color: var(--gray-800);
  font-weight: 600;
}

.info-value.mono { font-family: var(--font-mono); font-size: .82rem; }

/* Section title */
.section-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */

.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-navy    { color: var(--navy); }
.text-muted   { color: var(--gray-400); }
.text-danger  { color: var(--status-exception); }
.text-success { color: var(--status-delivered); }

.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }

.mono { font-family: var(--font-mono); }

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 18px 0;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  justify-content: space-between;
  flex-wrap: wrap;
}

.pagination-info { font-size: .8rem; color: var(--gray-500); }

.pagination-btns { display: flex; gap: 4px; }

.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--gray-600);
  transition: all var(--t-fast);
}

.page-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.page-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content { margin-left: 0; }

  .hamburger { display: flex; }

  .topbar-logo { display: block; }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 199;
  }

  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .modal { border-radius: var(--radius); }
  .login-card { padding: 28px 22px; }
  .info-grid { grid-template-columns: 1fr; }
  .info-item { border-right: none; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: unset; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .sidebar, .topbar, .topbar-actions { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
