/* trackmything — corporate-tracker aesthetic, deliberately bland.
   References: USPS Tracking, UPS MyChoice, FedEx Tracking, AfterShip. */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --border:   #e3e6eb;
  --border2:  #cdd2dc;
  --text:     #1a1f2c;
  --muted:    #5b6577;
  --muted2:   #8a93a4;

  --accent:   #1d3a8a;          /* deep navy — the brand color */
  --accent2:  #0b1e57;
  --ok:       #1a7f3b;
  --warn:     #b25e00;
  --danger:   #b3261e;

  --shadow:   0 1px 2px rgba(20, 30, 60, 0.06), 0 2px 8px rgba(20, 30, 60, 0.04);
  --radius:   4px;
  --maxw:     1120px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.mono, code, .num { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }

/* ── Top brand bar ────────────────────────────────────────────────── */
.topbar {
  background: var(--accent);
  color: #fff;
  border-bottom: 3px solid #122560;
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand {
  font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 8px;
}
.brand .mark {
  display: inline-block; width: 22px; height: 22px;
  background: #fff; color: var(--accent);
  border-radius: 3px;
  font-size: 13px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.topbar-search {
  display: flex; gap: 0;
  border: 1px solid #fff3; border-radius: 3px;
  overflow: hidden;
  background: #ffffff15;
}
.topbar-search input {
  background: transparent; border: 0; color: #fff;
  padding: 6px 10px; font-size: 13px; width: 240px;
  font-family: ui-monospace, monospace;
}
.topbar-search input::placeholder { color: #ffffff90; }
.topbar-search button {
  background: #ffffff20; border: 0; border-left: 1px solid #fff3;
  color: #fff; padding: 0 12px; cursor: pointer; font-size: 12px;
}

/* ── Page container ────────────────────────────────────────────── */
.page { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 80px; }

.section-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  margin: 22px 0 8px;
}

/* ── Tracking number header ───────────────────────────────────── */
.tracker-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex; align-items: center; gap: 24px;
  flex-wrap: wrap;
}
.tracker-head .label-row {
  display: flex; flex-direction: column; gap: 2px;
}
.tracker-head .label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}
.tracker-head .number {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 22px; font-weight: 600; letter-spacing: 0.02em;
}
.tracker-head .copy-btn {
  background: transparent; border: 1px solid var(--border2); cursor: pointer;
  font-size: 11px; padding: 4px 10px; border-radius: 3px;
  color: var(--muted);
}
.tracker-head .copy-btn:hover { background: var(--bg); color: var(--text); }
.tracker-head .copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* ── Status row (status pill + service tier + ETA cards) ──────── */
.row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 16px; }
.col-7 { grid-column: span 7; } .col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; }
@media (max-width: 800px) { .col-7,.col-5,.col-6,.col-4 { grid-column: span 12; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h2 {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px;
}
.status-big { font-size: 24px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  background: #e7eefb; color: var(--accent);
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase;
}
.status-pill.ok { background: #e2f1e7; color: var(--ok); }
.status-pill.warn { background: #fbeedc; color: var(--warn); }
.detail { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 8px; }
.detail strong { color: var(--text); font-weight: 600; }

/* ── 4-stage progress bar ─────────────────────────────────────── */
.progress {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-top: 16px;
}
.progress-track {
  position: relative;
  display: grid; grid-template-columns: repeat(4, 1fr);
  align-items: center;
}
.progress-track::before {
  content: "";
  position: absolute; left: 4%; right: 4%; top: 13px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.progress-track::after {
  content: ""; position: absolute; left: 4%; top: 13px; height: 4px;
  background: var(--accent);
  border-radius: 2px;
  width: calc(var(--progress, 25%) - 4%);
  transition: width 0.4s ease;
}
.stage { position: relative; text-align: center; z-index: 1; }
.stage .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--border);
  margin: 0 auto 8px;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.stage.done .dot { background: var(--accent); border-color: var(--accent); }
.stage.current .dot {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px #1d3a8a25;
}
.stage .label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.stage.done .label, .stage.current .label { color: var(--text); }

/* ── Map + timeline ──────────────────────────────────────────── */
.map-card { padding: 0; overflow: hidden; }
#map { height: 480px; width: 100%; background: #eee; }
.leaflet-control-attribution { font-size: 9px !important; opacity: 0.7; }

.timeline {
  padding: 18px 20px;
  max-height: 480px;
  overflow-y: auto;
}
.timeline h2 { font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 14px; }
.event {
  display: grid; grid-template-columns: 16px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.event:last-child { border-bottom: 0; }
.event .pip {
  position: relative;
  margin-top: 6px;
}
.event .pip::before {
  content: ""; display: block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-left: 4px;
}
.event:first-child .pip::before { box-shadow: 0 0 0 3px #1d3a8a25; }
.event .when {
  font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace;
  letter-spacing: 0.02em;
}
.event .where { font-size: 14px; font-weight: 600; margin-top: 1px; }
.event .what  { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── From / To cards ─────────────────────────────────────────── */
.fromto-card { display: flex; gap: 10px; align-items: baseline; }
.fromto-card .label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); min-width: 50px;
}
.fromto-card .val { color: var(--text); font-size: 14px; }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  margin-top: 60px; padding: 28px 20px;
  border-top: 1px solid var(--border);
  color: var(--muted2); font-size: 12px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 14px;
  max-width: var(--maxw); margin-left: auto; margin-right: auto;
}
.footer a.easter {
  color: var(--muted2); font-size: 10px; letter-spacing: 0.05em;
}
.footer a.easter:hover { color: var(--text); }

/* ── Landing page (tracking-number entry) ────────────────────── */
.landing {
  max-width: 560px; margin: 0 auto; padding: 12vh 24px 4vh;
}
.landing-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 40px 32px;
}
.landing-h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
  text-align: center; margin-bottom: 6px;
}
.landing-sub {
  color: var(--muted); font-size: 14px; text-align: center;
  margin-bottom: 28px;
}
.landing-form {
  display: flex; flex-direction: column; gap: 10px;
}
.landing-form input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border2); border-radius: 4px;
  font-size: 16px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.02em; color: var(--text); background: #fff;
  text-transform: uppercase;
}
.landing-form input::placeholder { text-transform: none; color: var(--muted2); }
.landing-form input:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px #1d3a8a18;
}
.landing-form .primary {
  margin-top: 4px; padding: 12px;
  font-size: 15px; font-weight: 600;
}
.landing-err {
  background: #fff7f6; border: 1px solid #e8b5b1;
  color: #9b2b25; padding: 10px 12px; border-radius: 4px;
  font-size: 13px; margin-top: 14px;
}
.landing-help {
  color: var(--muted2); font-size: 12px; text-align: center;
  margin-top: 22px; line-height: 1.6;
}

/* ── Admin pages ─────────────────────────────────────────────── */
.center {
  max-width: 380px; margin: 14vh auto;
  background: var(--surface); border: 1px solid var(--border);
  padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.center h1 { font-size: 20px; margin-bottom: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin-top: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 4px;
  border: 1px solid var(--border2); border-radius: 3px;
  font-size: 14px; color: var(--text); background: #fff;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px #1d3a8a18;
}
button.primary {
  background: var(--accent); color: #fff; border: 0; padding: 10px 18px;
  border-radius: 3px; cursor: pointer; font-weight: 600; font-size: 14px;
  margin-top: 16px;
}
button.primary:hover { background: var(--accent2); }
button.ghost {
  background: transparent; border: 1px solid var(--border2);
  padding: 6px 10px; border-radius: 3px; cursor: pointer;
  font-size: 12px; color: var(--muted);
}
button.ghost:hover { background: var(--bg); color: var(--text); }
button.danger {
  background: transparent; border: 1px solid var(--border);
  color: var(--danger); padding: 4px 8px; font-size: 11px;
  cursor: pointer; border-radius: 3px;
}
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ── Admin-only pin-drop layout ─────────────────────────────── */
.admin-wrap {
  max-width: var(--maxw); margin: 0 auto;
  padding: 20px;
  display: grid; grid-template-columns: 1fr 380px; gap: 16px;
}
@media (max-width: 900px) { .admin-wrap { grid-template-columns: 1fr; } }
#admin-map { height: 500px; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-side .hint {
  background: #fff8e0; border: 1px solid #f0e4ad; color: #5d4d12;
  font-size: 12px; padding: 10px 12px; border-radius: 3px; margin-bottom: 12px;
}
.admin-history { margin-top: 16px; max-height: 340px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); }
.admin-history .row-h {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 9px 12px; font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.admin-history .row-h:last-child { border-bottom: 0; }
.admin-history .when { color: var(--muted); font-family: ui-monospace, monospace; font-size: 10px; }
