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

:root {
  --red:       #d3282f;
  --red-dark:  #a81f25;
  --red-light: #fdecea;
  --navy:      #1a1f36;
  --navy2:     #252b45;
  --navy3:     #2f3654;
  --white:     #ffffff;
  --gray-50:   #f8f9fc;
  --gray-100:  #f1f3f9;
  --gray-200:  #e4e7ef;
  --gray-400:  #9aa0b4;
  --gray-600:  #5a6178;
  --gray-800:  #2d3250;
  --green:     #16a34a;
  --green-bg:  #dcfce7;
  --orange:    #ea580c;
  --orange-bg: #ffedd5;
  --blue:      #2563eb;
  --blue-bg:   #dbeafe;
  --yellow:    #d97706;
  --yellow-bg: #fef3c7;
  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
  font-size: 14px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--navy3);
}
.brand-icon { font-size: 26px; }
.brand-name {
  display: block;
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  line-height: 1.2;
}
.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--gray-400);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--gray-400);
  transition: background .15s, color .15s;
  cursor: pointer;
  font-size: 13.5px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--navy3); color: var(--white); }
.nav-item.active { background: var(--red); color: var(--white); font-weight: 600; }

.sidebar-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--navy3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.env-badge {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 0;
  border-radius: 6px;
  margin-bottom: 4px;
}
.env-sandbox { background: var(--yellow-bg); color: var(--yellow); }
.env-prod    { background: var(--green-bg);  color: var(--green);  }

.logout-btn { color: #ef4444; }
.logout-btn:hover { background: #3d1515; color: #ff6b6b; }

/* ── Main Wrapper ────────────────────────────────────── */
.main-wrapper {
  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;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-600);
}
.topbar-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--gray-800);
}
.topbar-right { margin-left: auto; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--gray-600);
}
.topbar-user svg { width: 16px; height: 16px; }

/* ── Main Content ────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px 28px;
  max-width: 1400px;
  width: 100%;
}

/* ── Alert ───────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 20px;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; }
.alert-success { background: var(--green-bg);  color: #15803d; }
.alert-error   { background: var(--red-light); color: var(--red-dark); }
.alert-info    { background: var(--blue-bg);   color: #1d4ed8; }
.alert-warning { background: var(--yellow-bg); color: var(--yellow); }

/* ── Stats Grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon-red    { background: var(--red-light);   color: var(--red); }
.stat-icon-green  { background: var(--green-bg);    color: var(--green); }
.stat-icon-blue   { background: var(--blue-bg);     color: var(--blue); }
.stat-icon-orange { background: var(--orange-bg);   color: var(--orange); }
.stat-icon-yellow { background: var(--yellow-bg);   color: var(--yellow); }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Card ────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.card-title {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--gray-800);
}
.card-body { padding: 20px; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-400);
  padding: 11px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  font-size: 13.5px;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badge / Pill ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-booked     { background: var(--blue-bg);    color: var(--blue); }
.badge-delivered  { background: var(--green-bg);   color: var(--green); }
.badge-cancelled  { background: var(--red-light);  color: var(--red-dark); }
.badge-in_transit { background: var(--orange-bg);  color: var(--orange); }
.badge-failed     { background: #fce7f3;           color: #9d174d; }
.badge-processing { background: var(--blue-bg);    color: var(--blue); }
.badge-pending    { background: var(--yellow-bg);  color: var(--yellow); }
.badge-completed  { background: var(--green-bg);   color: var(--green); }
.badge-cod        { background: var(--orange-bg);  color: var(--orange); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { filter: brightness(0.93); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--red);   color: var(--white); }
.btn-success { background: var(--green); color: var(--white); }
.btn-outline {
  background: var(--white);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}
.btn-outline:hover { background: var(--gray-100); filter: none; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ── Form ────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-600);
}
.form-control {
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  outline: none;
  background: var(--white);
  color: var(--gray-800);
  transition: border-color .15s;
  width: 100%;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(211,40,47,.12); }
select.form-control { appearance: auto; }

.form-section {
  margin-bottom: 28px;
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

/* ── Page Header ─────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}
.page-header-left p {
  color: var(--gray-400);
  font-size: 13px;
  margin-top: 3px;
}
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Search / Filter Bar ─────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.filter-bar .form-control { min-width: 160px; padding: 7px 11px; }
.search-input { flex: 1; min-width: 220px; }

/* ── Order Info Box ──────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.info-row { display: flex; flex-direction: column; gap: 3px; }
.info-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-400); }
.info-value { font-size: 14px; font-weight: 500; color: var(--gray-800); }

/* ── Tracking Timeline ───────────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 0; bottom: 0;
  width: 2px;
  background: var(--gray-200);
}
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-dot {
  position: absolute;
  left: -20px; top: 3px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gray-200);
  border: 2px solid var(--white);
}
.timeline-item.active .timeline-dot { background: var(--red); }
.timeline-date { font-size: 11px; color: var(--gray-400); margin-bottom: 2px; }
.timeline-event { font-size: 13px; font-weight: 500; }
.timeline-loc { font-size: 12px; color: var(--gray-400); }

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  cursor: pointer; color: var(--gray-400);
  font-size: 22px;
  line-height: 1;
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin-top: 18px; align-items: center;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  border-radius: 7px;
  font-size: 13px;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  background: var(--white);
  padding: 0 8px;
}
.pagination a:hover { background: var(--gray-100); }
.pagination .current { background: var(--red); color: var(--white); border-color: var(--red); font-weight: 700; }

/* ── Misc Utilities ──────────────────────────────────── */
.text-muted { color: var(--gray-400); }
.text-bold  { font-weight: 700; }
.text-red   { color: var(--red); }
.text-green { color: var(--green); }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--white);
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  padding: 40px;
  width: min(420px, 95vw);
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .flag { font-size: 40px; }
.login-logo h1 { font-size: 20px; font-weight: 700; margin-top: 10px; color: var(--navy); }
.login-logo p  { color: var(--gray-400); font-size: 13px; margin-top: 4px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Plan widget (sidebar) ───────────────────────────── */
.plan-widget {
  display: block;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 11px 13px;
  margin: 0 10px 10px;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.plan-widget:hover { background: rgba(255,255,255,.12); }
.plan-widget-pro { border-color: rgba(167,139,250,.4); background: rgba(124,58,237,.18); }
.plan-widget-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.plan-chip { font-size: 10px; font-weight: 800; letter-spacing: .6px; padding: 2px 8px; border-radius: 999px; }
.chip-free { background: rgba(255,255,255,.15); color: #cbd5e1; }
.chip-pro  { background: linear-gradient(135deg,#7c3aed,#a855f7); color: #fff; }
.plan-upgrade-hint { font-size: 10px; color: #a5b4fc; font-weight: 600; }

/* ── Upgrade modal (triggered by gate responses) ─────── */
#upgrade-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.5); align-items: center; justify-content: center;
}
#upgrade-modal.open { display: flex; }
.upgrade-modal-box {
  background: #fff; border-radius: 18px; padding: 32px 28px;
  max-width: 400px; width: 90%; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: popIn .2s ease;
}
@keyframes popIn { from{transform:scale(.92);opacity:0} to{transform:scale(1);opacity:1} }
.upgrade-modal-icon { font-size: 40px; margin-bottom: 14px; }
.upgrade-modal-box h3 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.upgrade-modal-box p  { font-size: 13.5px; color: #6b7280; margin: 0 0 22px; }
.upgrade-modal-btns   { display: flex; gap: 10px; justify-content: center; }
.upgrade-modal-btns a   { background: linear-gradient(135deg,#7c3aed,#a855f7); color: #fff; border: none; padding: 10px 24px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.upgrade-modal-btns button { background: #f1f5f9; color: #475569; border: none; padding: 10px 18px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; }
