/**
 * static/css/styles.css - Logistics Tracking Platform Modern Stylesheet
 * Milestone 4: Comprehensive Design System & Layout
 */

/* ==========================================================================
   1. Design System & CSS Variables
   ========================================================================== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-dark: #1e40af;
  
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Status Color Palette */
  --status-pending-bg: #f1f5f9;
  --status-pending-text: #475569;
  --status-pending-border: #cbd5e1;
  --status-pending-dot: #64748b;

  --status-transit-bg: #dbeafe;
  --status-transit-text: #1d4ed8;
  --status-transit-border: #93c5fd;
  --status-transit-dot: #3b82f6;

  --status-delivery-bg: #fef3c7;
  --status-delivery-text: #b45309;
  --status-delivery-border: #fcd34d;
  --status-delivery-dot: #f59e0b;

  --status-delivered-bg: #dcfce7;
  --status-delivered-text: #15803d;
  --status-delivered-border: #86efac;
  --status-delivered-dot: #22c55e;

  --status-incident-bg: #fee2e2;
  --status-incident-text: #b91c1c;
  --status-incident-border: #fca5a5;
  --status-incident-dot: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body.app-body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--primary-hover);
}

.text-muted { color: var(--text-muted); }
.text-danger { color: #dc2626; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-monospace { font-family: var(--font-mono); }

/* ==========================================================================
   3. Header & Navigation Bar
   ========================================================================== */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-xs);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
}

.brand-icon-box {
  background: var(--primary);
  color: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-item:hover, .nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item.nav-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.nav-item.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ==========================================================================
   4. Status Pills & Badges
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid transparent;
  line-height: 1;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-pill.large {
  padding: 0.5rem 1.15rem;
  font-size: 1rem;
}
.status-pill.large::before {
  width: 10px;
  height: 10px;
}

.status-pendiente {
  background: var(--status-pending-bg);
  color: var(--status-pending-text);
  border-color: var(--status-pending-border);
}
.status-pendiente::before { background: var(--status-pending-dot); }

.status-en-transito {
  background: var(--status-transit-bg);
  color: var(--status-transit-text);
  border-color: var(--status-transit-border);
}
.status-en-transito::before { background: var(--status-transit-dot); }

.status-en-reparto {
  background: var(--status-delivery-bg);
  color: var(--status-delivery-text);
  border-color: var(--status-delivery-border);
}
.status-en-reparto::before { background: var(--status-delivery-dot); }

.status-entregado {
  background: var(--status-delivered-bg);
  color: var(--status-delivered-text);
  border-color: var(--status-delivered-border);
}
.status-entregado::before { background: var(--status-delivered-dot); }

.status-incidencia {
  background: var(--status-incident-bg);
  color: var(--status-incident-text);
  border-color: var(--status-incident-border);
}
.status-incidencia::before { background: var(--status-incident-dot); }

/* ==========================================================================
   5. Public Tracking Page Layout & Search Section
   ========================================================================== */
.app-content {
  flex: 1;
}

.track-page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.search-section {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
}

.search-box-wrapper {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.search-heading {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.search-subheading {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 1.75rem;
}

.search-form {
  width: 100%;
}

.input-with-button {
  display: flex;
  position: relative;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: var(--shadow-lg);
}

.search-input-icon {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.tracking-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.85rem 1rem 0.85rem 3rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tracking-input::placeholder {
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-light);
}

.btn-primary, .btn.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.btn-primary:hover, .btn.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary, .btn.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.btn-secondary:hover, .btn.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline, .btn.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.btn-outline:hover, .btn.btn-outline:hover {
  background: var(--primary-light);
}

.btn-danger, .btn.btn-danger {
  background: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.btn-danger:hover, .btn.btn-danger:hover {
  background: #dc2626;
}

.btn-disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   6. Clean 404 Not Found Card
   ========================================================================== */
.not-found-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  max-width: 680px;
  margin: 1rem auto 3rem auto;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.not-found-icon-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.5rem auto;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-404-badge {
  font-size: 1.5rem;
  font-weight: 800;
}

.not-found-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.not-found-msg {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.code-highlight {
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.not-found-tips {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  text-align: left;
  margin-bottom: 2rem;
}

.not-found-tips h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.not-found-tips ul {
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.not-found-tips li {
  margin-bottom: 0.35rem;
}

.not-found-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* ==========================================================================
   7. Shipment Hero Summary Card
   ========================================================================== */
.shipment-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.guide-badge-box {
  display: flex;
  flex-direction: column;
}

.guide-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.guide-number {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.route-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 2rem;
  margin-bottom: 1.75rem;
}

.route-point {
  display: flex;
  flex-direction: column;
}
.route-point.destination {
  text-align: right;
}

.route-type {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.route-city {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.route-divider {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 2rem;
}

.route-line {
  position: absolute;
  width: 100%;
  height: 2px;
  background: var(--border-color);
  border-top: 2px dashed #94a3b8;
}

.route-vehicle-icon {
  position: relative;
  z-index: 2;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--primary);
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
}

.meta-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ==========================================================================
   8. Split Layout: Interactive Map & Timeline
   ========================================================================== */
.tracking-split-layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 2rem;
}

.map-section-card,
.timeline-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.checkpoint-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-animation 1.5s infinite;
}

@keyframes pulse-animation {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.interactive-map-container {
  height: 460px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  z-index: 10;
}

.map-notice-banner {
  margin-top: 1rem;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* ==========================================================================
   9. Timeline (Bitácora) Components
   ========================================================================== */
.timeline-order-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.timeline-container {
  position: relative;
  padding: 0.5rem 0 0.5rem 1.5rem;
}

.timeline-track {
  list-style: none;
  position: relative;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 24px;
  left: -19px;
  width: 2px;
  background: var(--border-color);
}

.timeline-node {
  position: relative;
  margin-bottom: 1.75rem;
}
.timeline-node:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -26px;
  top: 4px;
}

.marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.timeline-node.is-latest .marker-dot {
  background: var(--primary);
  border-color: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.timeline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-node.is-latest .timeline-card {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-light);
}

.timeline-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.checkpoint-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.checkpoint-location {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.checkpoint-coords {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
}

.btn-focus-marker {
  background: transparent;
  border: none;
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
}
.btn-focus-marker:hover {
  background: var(--primary-light);
  text-decoration: underline;
}

.checkpoint-notes {
  background: var(--bg-subtle);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.5rem;
}

.timeline-empty-card {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-icon-box {
  margin-bottom: 1rem;
  color: var(--text-light);
}

/* Modal history timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  padding-left: 1.5rem;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 6px;
  width: 2px;
  background: var(--border-color);
}
.timeline-item {
  position: relative;
}
.timeline-dot {
  position: absolute;
  left: -1.75rem;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px var(--border-color);
}
.timeline-item.is-latest .timeline-dot {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}
.timeline-content {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}
.timeline-meta {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}
.timeline-notes {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-secondary);
}

/* ==========================================================================
   10. Leaflet Custom Popup Styling
   ========================================================================== */
.custom-map-popup {
  padding: 0.25rem;
  font-family: var(--font-sans);
}

.popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.popup-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.popup-info-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.popup-notes {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  background: #f1f5f9;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  color: #334155;
}

/* ==========================================================================
   11. Landing Features Grid
   ========================================================================== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.feature-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   12. Auth / Login Page Layout
   ========================================================================== */
.auth-wrapper {
  max-width: 440px;
  margin: 3rem auto;
  padding: 0 1rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.auth-card {
  padding: 2.25rem 2rem;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-icon-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem auto;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-header h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.auth-header p {
  font-size: 0.88rem;
  line-height: 1.4;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle-btn {
  position: absolute;
  right: 0.65rem;
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}

.alert-danger {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

.test-credentials-box {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.test-cred-header {
  margin-bottom: 0.5rem;
  text-align: center;
}

.test-cred-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.88rem;
}

/* ==========================================================================
   13. Operator Dashboard Layout
   ========================================================================== */
.dashboard-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.25rem 1.75rem;
}

.dashboard-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.badge-role {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary-dark);
}

.badge-role-admin {
  background: #fef3c7;
  color: #b45309;
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toolbar */
.toolbar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-input-search {
  min-width: 260px;
}

.badge-counter {
  font-size: 0.85rem;
}

/* Table */
.table-container {
  padding: 0;
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  background: var(--bg-subtle);
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tr:hover {
  background-color: var(--bg-subtle);
}

.code-col {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tracking-code-link {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
}

.btn-copy {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  font-size: 0.85rem;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.btn-copy:hover {
  opacity: 1;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

.cargo-meta {
  display: flex;
  flex-direction: column;
}

.cargo-desc {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.carrier-name {
  font-size: 0.78rem;
}

.action-buttons {
  display: inline-flex;
  gap: 0.4rem;
}

.btn-action-checkpoint {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--status-transit-border);
  font-weight: 600;
  cursor: pointer;
}
.btn-action-checkpoint:hover {
  background: var(--primary);
  color: #ffffff;
}

.loading-state, .empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem auto;
}

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

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   14. Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
}

.modal-lg { max-width: 760px; }
.modal-md { max-width: 600px; }

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-page);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.shipment-summary-box {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.chip-btn {
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

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

.chip-gps {
  background: #f0fdf4;
  border-color: #86efac;
  color: #15803d;
  font-weight: 600;
}

/* ==========================================================================
   15. Toast Feedback Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  min-width: 280px;
  animation: slide-in 0.25s ease forwards;
}

.toast-success { border-left: 4px solid #22c55e; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid var(--primary); }

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-left: auto;
  padding: 0 0.2rem;
}

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
}

/* ==========================================================================
   16. Footer
   ========================================================================== */
.app-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  padding: 2rem 1.5rem;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-info strong {
  font-size: 0.95rem;
  color: var(--text-primary);
}
.footer-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}
.footer-links a {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.footer-links a:hover {
  color: var(--primary);
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

/* ==========================================================================
   17. Responsive Breakpoints
   ========================================================================== */
@media (max-width: 992px) {
  .tracking-split-layout {
    grid-template-columns: 1fr;
  }

  .interactive-map-container {
    height: 380px;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    gap: 0.75rem;
  }

  .search-section {
    padding: 1.75rem 1.25rem;
  }

  .search-heading {
    font-size: 1.45rem;
  }

  .input-with-button {
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-input-icon {
    display: none;
  }

  .tracking-input {
    padding: 0.75rem;
  }

  .btn-primary.search-submit-btn {
    width: 100%;
    justify-content: center;
  }

  .route-banner {
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 1rem;
  }
  .route-point.destination {
    text-align: left;
  }
  .route-divider {
    width: 100%;
    margin: 0.5rem 0;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .toolbar-section {
    flex-direction: column;
    align-items: stretch;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}
