:root {
  --brand: #e2231a;
  --brand-dark: #b81a13;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e7e7ea;
  --ok: #0a7d2c;
  --warn: #b8860b;
  --err: #b00020;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
main, header, footer, .mock-banner { max-width: 920px; margin: 0 auto; padding: 0 24px; }

header { display: flex; align-items: center; gap: 16px; padding-top: 28px; padding-bottom: 12px; }
.logo { height: 44px; width: auto; }
.title-block h1 { font-size: 20px; margin: 0; font-weight: 600; }
.subtitle { color: var(--muted); font-size: 13px; }

.mock-banner:not(:empty) {
  margin-top: 12px;
  background: #fff7e0;
  color: #6b5300;
  border: 1px solid #f1d873;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

main { padding-top: 16px; padding-bottom: 48px; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0 16px; }
.hint code { background: #f0f0f2; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }

.editor { position: relative; }
textarea {
  width: 100%;
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(226,35,26,.12); }
.counter {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.counter .warn { color: var(--warn); }
.counter .warn-bad { color: var(--err); width: 100%; margin-top: 2px; }

.shipment.skip-card {
  border-color: #f1d873;
  background: #fff7e0;
  padding: 10px 14px;
  color: #6b5300;
  font-size: 13px;
}

.actions { margin-top: 14px; display: flex; gap: 10px; }
button {
  position: relative;
  padding: 10px 20px;
  background: var(--brand);
  color: white;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
button:hover:not(:disabled) { background: var(--brand-dark); }
button:disabled { background: #c8c8cc; cursor: not-allowed; }
button.loading { background: var(--brand); cursor: wait; }
button.loading .btn-label { visibility: hidden; }
.btn-spinner { display: none; }
button.loading .btn-spinner {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover:not(:disabled) { background: #f0f0f2; }

progress {
  width: 100%;
  margin-top: 16px;
  height: 6px;
  appearance: none;
  border: none;
  border-radius: 3px;
  overflow: hidden;
  background: #ececef;
}
progress::-webkit-progress-bar { background: #ececef; border-radius: 3px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 3px; transition: width .2s; }
progress::-moz-progress-bar { background: var(--brand); }
.prog-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

#results { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

.shipment {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  transition: box-shadow .15s;
}
.shipment[open] { box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.shipment summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}
.shipment summary::-webkit-details-marker { display: none; }
.shipment summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
  transition: transform .2s;
  grid-column: 3;
  margin-left: 8px;
}
.shipment[open] summary::after { transform: rotate(180deg); }

.bc { font-family: ui-monospace, monospace; font-weight: 600; font-size: 14px; }
.headline { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.status-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status { font-size: 14px; font-weight: 500; }
.status.delivered { color: var(--ok); }
.status.transit { color: #1158c4; }
.status.customs { color: var(--warn); }
.status.notfound { color: var(--muted); }
.status.error { color: var(--err); }
.meta-line { color: var(--muted); font-size: 12px; }

.timeline {
  list-style: none;
  padding: 0 18px 18px 36px;
  margin: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 8px;
  bottom: 18px;
  width: 2px;
  background: var(--border);
}
.timeline li { position: relative; padding: 10px 0 10px 14px; }
.dot {
  position: absolute;
  left: -16px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c4c4c8;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline li:first-child .dot { background: var(--brand); }
.timeline .t { font-size: 12.5px; color: var(--muted); }
.timeline .d { font-size: 14px; margin-top: 2px; }
.timeline .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.country { font-family: ui-monospace, monospace; }

.empty-events {
  padding: 14px 18px 18px;
  color: var(--muted);
  font-size: 13.5px;
}

.shipment.error-card {
  border-color: #f3c2c8;
  background: #fff5f6;
  padding: 14px 18px;
  color: var(--err);
  font-size: 13.5px;
}

footer {
  color: var(--muted);
  font-size: 12px;
  padding: 24px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .shipment summary { grid-template-columns: 1fr auto; }
  .shipment summary::after { grid-column: 2; }
}
