/* ==========================================================================
   ShipTracking — design system
   Vernacular: the waybill / manifest / customs stamp. Tracking codes and
   timestamps are set in mono (as they'd appear on a real printed waybill),
   headings use a condensed industrial display face, and the one moment of
   flourish is the "delivered" ink-stamp badge — everything else stays quiet.
   ========================================================================== */

:root {
  color-scheme: light;

  --font-display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --ink: #171b1f;
  --muted: #5b6660;
  --paper: #eef2ef;
  --surface: #ffffff;
  --line: #dbe3de;
  --line-strong: #c4cec8;

  --signal: #2451c4;
  --signal-ink: #17348c;
  --signal-wash: #e4ebfa;

  --transit: #c2740a;
  --transit-wash: #faf0dd;

  --stamp: #a93226;
  --stamp-wash: #f8e6e3;

  --success: #2f6f4e;
  --success-wash: #dff2e7;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(23, 27, 31, 0.04);
  --shadow-hover: 0 8px 20px rgba(23, 27, 31, 0.09);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

a { color: var(--signal); }

::selection { background: var(--signal-wash); color: var(--signal-ink); }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  flex-shrink: 0;
  background-color: var(--ink);
  background-image: repeating-linear-gradient(
    90deg,
    var(--paper) 0,
    var(--paper) 2px,
    transparent 2px,
    transparent 5px
  );
}

.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.topbar nav { display: flex; align-items: center; gap: 22px; }
.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.92rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.is-active { color: var(--ink); border-bottom-color: var(--signal); }
.username { color: var(--muted); font-size: 0.85rem; font-family: var(--font-mono); }

/* ---------- Layout ---------- */

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.card.narrow { max-width: 420px; }

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
  margin: 0 0 16px;
}
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 14px;
}

.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.muted { color: var(--muted); }

/* ---------- Forms ---------- */

form label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: var(--muted);
}

input, select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-wash);
}

button {
  cursor: pointer;
  border: 1px solid var(--signal);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  background: var(--signal);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover { background: var(--signal-ink); border-color: var(--signal-ink); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--paper); border-color: var(--ink); color: var(--ink); }

.btn-danger-ghost {
  background: transparent;
  color: var(--stamp);
  border: 1px solid var(--stamp);
}
.btn-danger-ghost:hover { background: var(--stamp); color: #fff; }

.btn-small { padding: 6px 12px; font-size: 0.8rem; }

.btn-link {
  display: inline-block;
  text-decoration: none;
  background: #229ed9;
  border-color: #229ed9;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.link-button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-button:hover { background: none; color: var(--signal); }

.inline-form { display: inline-block; margin: 0; }

.add-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.add-form select { width: auto; }
.add-form input[type="text"] { width: auto; flex: 1; min-width: 170px; }
.add-form button { flex-shrink: 0; }

/* ---------- Flash & errors ---------- */

.flash {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.flash-error { background: var(--stamp-wash); color: var(--stamp); }
.flash-success { background: var(--success-wash); color: var(--success); }

.error-note, .waybill-error { color: var(--stamp); font-size: 0.8rem; }

code {
  font-family: var(--font-mono);
  background: var(--paper);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- Status badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.badge-pending  { background: #eceef1; color: #4b5563; }
.badge-transit  { background: var(--signal-wash); color: var(--signal-ink); }
.badge-out      { background: var(--transit-wash); color: var(--transit); }
.badge-delivered{ background: var(--success-wash); color: var(--success); }
.badge-issue    { background: var(--stamp-wash); color: var(--stamp); }

.tag-stopped {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
}

/* The one signature flourish: an ink stamp for delivered parcels */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--stamp);
  border: 2px solid var(--stamp);
  border-radius: 4px;
  padding: 3px 10px;
  transform: rotate(-4deg);
  position: relative;
}
.stamp::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid var(--stamp);
  border-radius: 2px;
  opacity: 0.55;
}

/* ---------- Ticket card (add shipment) ---------- */

.ticket-card { padding: 22px 24px 24px; }

.ticket-perf {
  position: relative;
  height: 0;
  border-top: 2px dashed var(--line);
  margin: 16px -24px 18px;
}
.ticket-perf::before, .ticket-perf::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--paper);
}
.ticket-perf::before { left: -8px; }
.ticket-perf::after { right: -8px; }

/* ---------- Waybill list ---------- */

.waybill-list { display: flex; flex-direction: column; gap: 12px; }

.waybill-card {
  display: grid;
  grid-template-columns: 1.1fr 1.5fr auto;
  gap: 8px 22px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.waybill-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

.waybill-card.accent-pending   { border-left-color: var(--line-strong); }
.waybill-card.accent-transit   { border-left-color: var(--signal); }
.waybill-card.accent-out       { border-left-color: var(--transit); }
.waybill-card.accent-delivered { border-left-color: var(--success); }
.waybill-card.accent-issue     { border-left-color: var(--stamp); }

.waybill-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}
.waybill-code a { color: var(--ink); text-decoration: none; }
.waybill-code a:hover { color: var(--signal); }
.waybill-label { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }

.waybill-detail {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 6px;
  line-height: 1.4;
}
.waybill-error { margin-top: 4px; }

.waybill-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}
.waybill-time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.waybill-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.empty-state {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
}

/* ---------- Journey timeline (shipment detail) ---------- */

.status-detail { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }

.journey {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.journey::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  border-left: 2px dashed var(--line);
}
.journey li { position: relative; padding: 0 0 22px 28px; }
.journey li:last-child { padding-bottom: 0; }
.journey-dot {
  position: absolute;
  left: 0;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-strong);
}
.journey li.is-latest .journey-dot {
  background: var(--signal);
  border-color: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-wash);
}
.journey-time { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); }
.journey-status { font-weight: 600; margin-top: 2px; }
.journey-location { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

/* ---------- Accessibility ---------- */

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .container { padding: 16px 14px 40px; }
  .card { padding: 18px; }
  .card.narrow { max-width: none; }

  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .topbar nav { flex-wrap: wrap; gap: 8px 16px; }

  .add-form { flex-direction: column; align-items: stretch; }
  .add-form select,
  .add-form input[type="text"],
  .add-form button { width: 100%; }

  .ticket-perf { margin-inline: -18px; }

  .waybill-card { grid-template-columns: 1fr; }
  .waybill-meta { flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
  .waybill-actions { justify-content: flex-start; }
}
