/* ---------------------------------------------------------------------------
   Shipment Transit Time & Tracking — freight / logistics theme
   Maritime navy + cyan/teal accents, amber headline metric. Responsive.
--------------------------------------------------------------------------- */

:root {
  --navy-900: #081a30;
  --navy-800: #0c2440;
  --navy-700: #123257;
  --cyan: #22d3ee;
  --cyan-600: #0891b2;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --amber-soft: #fde68a;
  --ink: #0f1f33;
  --muted: #64748b;
  --line: #e6ebf2;
  --paper: #ffffff;
  --dhl-red: #d40511;
  --radius: 16px;
  --shadow: 0 22px 60px rgba(3, 12, 28, 0.45);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 40px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  /* Freight photo background, lightly dimmed so the card stays readable */
  background:
    linear-gradient(160deg, rgba(8, 26, 48, 0.45) 0%, rgba(7, 23, 43, 0.55) 100%),
    url("/background.jpg?v=2") center center / cover no-repeat fixed;
  background-color: #07172b; /* fallback while the image loads */
}

.app {
  width: 100%;
  max-width: 640px;
  background: var(--paper);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ---- Hero header --------------------------------------------------- */
.hero {
  position: relative;
  padding: 26px 28px 0;
  color: #eaf6ff;
  background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 100%);
  overflow: hidden;
}

/* Faint dotted "shipping route" motif across the header */
.hero-routes {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.16) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(105deg, transparent 0%, #000 35%, transparent 75%);
          mask-image: linear-gradient(105deg, transparent 0%, #000 35%, transparent 75%);
  opacity: 0.7;
  pointer-events: none;
}

.hero-inner { position: relative; }

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  color: var(--navy-900);
  background: linear-gradient(135deg, var(--cyan) 0%, var(--teal) 100%);
  box-shadow: 0 6px 18px rgba(34, 211, 238, 0.35);
}
.brand-mark svg { width: 26px; height: 26px; }

.brand-text h1 {
  margin: 0;
  font-size: 1.32rem;
  line-height: 1.2;
  letter-spacing: 0.2px;
}
.tagline {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: #9fc4e6;
}

/* ---- Segmented control (two functions) ---------------------------- */
.segmented {
  position: relative;
  display: flex;
  gap: 4px;
  margin-top: 22px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px 12px 0 0;
}

.seg {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #bcd6ef;
  background: transparent;
  border: none;
  border-radius: 9px 9px 0 0;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg svg { width: 17px; height: 17px; }
.seg:hover { color: #fff; }
.seg.active {
  color: var(--ink);
  background: var(--paper);
}

/* ---- Content ------------------------------------------------------- */
.content { padding: 26px 28px 28px; }

.panel { display: none; }
.panel.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- Route strip --------------------------------------------------- */
.route-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  margin-bottom: 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f1f7fd 0%, #eef6f4 100%);
  border: 1px solid #e2edf6;
}

.endpoint { flex: 1 1 0; min-width: 0; text-align: center; }
.ep-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.ep-value {
  display: block;
  margin-top: 3px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--navy-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-line {
  flex: 1.4 1 0;
  display: flex;
  align-items: center;
  gap: 0;
}
.route-track {
  flex: 1;
  height: 0;
  border-top: 2px dashed #b9cfe2;
}
.route-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--cyan-600);
  flex: 0 0 auto;
}
.route-vehicle {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  margin: 0 -2px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--cyan-600) 0%, var(--teal) 100%);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
}
.route-vehicle svg { width: 19px; height: 19px; }

/* ---- Controls / fields -------------------------------------------- */
.controls { display: grid; gap: 16px; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

select,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select { cursor: pointer; }
select:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--cyan-600);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.16);
}

button.primary {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #042430;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--teal) 100%);
  border: none;
  border-radius: 11px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.3);
  transition: transform 0.05s ease, filter 0.15s ease;
}
button.primary:hover { filter: brightness(1.04); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Go + Clear sit on one row; Go flexes, Clear is compact */
.btn-row { display: flex; gap: 10px; }
.btn-row .primary { flex: 1; }

button.ghost {
  flex: 0 0 auto;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-700);
  background: #eef3f8;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button.ghost:hover { background: #e3eaf2; }
button.ghost:active { transform: translateY(1px); }

/* Full-width "Show Full List" button */
button.ghost.wide { width: 100%; margin-top: 14px; padding: 12px 16px; }

/* ---- Full list view (All Lanes) ----------------------------------- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.list-head .block-title { margin: 0; }
.list-head button.ghost { padding: 9px 16px; }

.list-wrap {
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.lane-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.lane-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 11px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  background: var(--navy-700);
}
.lane-table tbody td {
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  vertical-align: top;
}
.lane-table tbody tr:nth-child(even) { background: #f6f9fc; }
.lane-table tbody tr:hover { background: #eef5fb; }
.lane-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 22px 14px;
}

/* ---- Transit result: metric stat card ----------------------------- */
.result-slot { margin-top: 22px; }

.stat-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 100%);
  box-shadow: 0 14px 34px rgba(8, 36, 64, 0.35);
}
.stat-icon {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 54px; height: 54px;
  border-radius: 14px;
  color: var(--navy-900);
  background: linear-gradient(135deg, var(--amber) 0%, #fbbf24 100%);
}
.stat-icon svg { width: 30px; height: 30px; }
.stat-body { min-width: 0; }
.stat-number {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--amber-soft);
}
.stat-number.text { font-size: 1.35rem; line-height: 1.3; }
.stat-unit {
  font-size: 1rem;
  font-weight: 600;
  margin-left: 8px;
  color: #cfe3f5;
}
.stat-label {
  margin-top: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #9fc4e6;
}
.stat-sub {
  margin-top: 4px;
  font-size: 0.9rem;
  color: #d6e6f5;
}

/* Muted "not available" card */
.stat-empty {
  padding: 18px 20px;
  border-radius: 14px;
  text-align: center;
  font-weight: 600;
  color: #8a3b3b;
  background: #fdf2f2;
  border: 1px solid #f6d7d7;
}
.stat-hint { /* validation prompt */
  padding: 14px 16px;
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
  color: #7c5a12;
  background: #fff8e6;
  border: 1px solid #f6e3b0;
}

/* ---- Tracking: forwarders ----------------------------------------- */
.card-inner {
  padding: 4px 2px 2px;
}
.block-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.forwarder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.forwarder-name {
  flex: 1 1 160px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--dhl-red); /* default; overridden per-forwarder inline */
}
.forwarder-name::before {
  content: "";
  width: 10px; height: 10px; border-radius: 2px;
  background: currentColor; /* matches the forwarder's brand colour */
}
.forwarder-row input[type="text"] { flex: 2 1 150px; width: auto; }
.forwarder-row button.go-sm {
  flex: 0 0 auto;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--dhl-red);
  border: none;
  border-radius: 11px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}
.forwarder-row button.go-sm:hover { filter: brightness(1.07); }
.forwarder-row button.go-sm:active { transform: translateY(1px); }
.forwarder-row button.go-sm:disabled { opacity: 0.6; cursor: not-allowed; }

.demo-line {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.link-btn {
  background: none; border: none; padding: 0;
  font: inherit; font-weight: 700;
  color: var(--cyan-600);
  cursor: pointer;
  text-decoration: underline;
}

/* ---- Tracking: messages + detail ---------------------------------- */
.msg {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
}
.msg.loading { background: #eaf6fb; color: #0b4f63; }

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #0b3a52;
  background: #e9f6fb;
  border: 1px solid #cde9f3;
}
.notice strong { color: #093247; }

.track-card {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(10, 31, 58, 0.06);
}
.track-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.track-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  background: var(--dhl-red);
  padding: 4px 9px;
  border-radius: 999px;
}
.track-badge.sample { background: var(--amber); color: #3a2a00; }
.track-status {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy-700);
}
.track-meta {
  margin-top: 10px;
  color: #54657a;
  font-size: 0.86rem;
  line-height: 1.7;
}

.timeline { margin: 18px 0 0; padding: 0; list-style: none; }
.timeline li {
  position: relative;
  padding: 0 0 18px 26px;
  border-left: 2px solid #dbe6f1;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 2px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -8px; top: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--cyan-600);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #cfe3f5;
}
.timeline li:first-child::before { background: var(--teal); }
.timeline .when { font-size: 0.72rem; color: #94a3b8; }
.timeline .what { font-weight: 700; color: var(--ink); }
.timeline .where { font-size: 0.82rem; color: #64748b; }

/* ---- Fallback + footer -------------------------------------------- */
.fallback {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.fallback .hint { margin: 0 0 10px; font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
code {
  background: #eef3f8;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.foot {
  padding: 16px 28px;
  font-size: 0.75rem;
  color: #7e8aa0;
  background: #f7f9fc;
  border-top: 1px solid var(--line);
  text-align: center;
}
.foot code { background: #eaeff6; }

.hidden { display: none; }

/* ---- Responsive ---------------------------------------------------- */
@media (max-width: 540px) {
  .hero { padding: 22px 18px 0; }
  .content { padding: 22px 18px 22px; }
  .brand-text h1 { font-size: 1.12rem; }
  .seg { font-size: 0.82rem; padding: 10px 6px; }

  /* Stack the route strip vertically */
  .route-strip { flex-direction: column; gap: 6px; }
  .route-line { width: 100%; flex: none; transform: rotate(90deg); height: 40px; }

  .stat-number { font-size: 2.1rem; }
  .foot { padding: 14px 18px; }
}
