/* ============================================================
 * 有信物流 · 查件系统
 * 清爽版：浅色底、蓝色强调、卡片式记录、默认收起轨迹
 * ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #e6eaf1;
  --line-strong: #d6dde8;
  --text: #1f2a37;
  --text-2: #475467;
  --muted: #7b8798;
  --brand: #0bade5;
  --brand-dark: #0895c6;
  --brand-soft: #e8f7fd;
  --ok: #1d9e57;
  --danger: #d94646;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d131a;
  --surface: #141c25;
  --surface-2: #18212c;
  --line: #243040;
  --line-strong: #33445a;
  --text: #e7eef7;
  --text-2: #b6c3d3;
  --muted: #8b9aab;
  --brand: #3cc0e8;
  --brand-dark: #5fd0f2;
  --brand-soft: #102c38;
  --ok: #3fc47e;
  --danger: #f07373;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.92em;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------------- 顶栏 ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.appbar__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.appbar__title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.appbar__title h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.appbar__title span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.appbar__actions { display: flex; align-items: center; gap: 10px; }

.health {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.health::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.health.is-ok { color: var(--ok); }
.health.is-off { color: var(--danger); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

/* ---------------- 主体 ---------------- */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 22px 24px 36px;
}

.search-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

#noInput {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#noInput::placeholder { color: var(--muted); font-family: var(--font); }
#noInput:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.search-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}
.search-btns { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.btn {
  height: 34px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--primary[disabled] { opacity: 0.7; cursor: progress; }
.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-2);
}
.btn--ghost:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------- 提示条 / 历史 ---------------- */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(217, 70, 70, 0.3);
  border-radius: 8px;
  background: rgba(217, 70, 70, 0.06);
  font-size: 12.5px;
  color: var(--text-2);
}
.banner strong { color: var(--danger); font-weight: 600; }
.banner code { background: var(--surface); }

.history-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 14px;
  font-size: 12.5px;
}
.history-line__label { color: var(--muted); }
.history-line__items { display: flex; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.history-item {
  border: 0;
  background: none;
  padding: 0;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  border-bottom: 1px solid transparent;
}
.history-item:hover { color: var(--brand); border-bottom-color: currentColor; }
.history-line__clear {
  margin-left: auto;
  border: 0;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
}
.history-line__clear:hover { color: var(--danger); }

/* ---------------- 结果 ---------------- */
.results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 0;
  color: var(--muted);
  font-size: 13px;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.record {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
  animation: fade-in 0.25s ease both;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.record:hover { border-color: var(--line-strong); }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.record__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.record__id {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 10px;
  min-width: 0;
}
.record__no {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  word-break: break-all;
}
button.record__no:hover { color: var(--brand); }
.record__no svg {
  width: 12px; height: 12px;
  color: var(--muted);
  opacity: 0.65;
  flex: 0 0 auto;
}
button.record__no:hover svg { color: var(--brand); opacity: 1; }

.record__source { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.record__source::before { content: "·"; margin-right: 6px; }

.record__side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.status {
  display: inline-block;
  max-width: 180px;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status--pending { color: #b3730a; background: #fdf4e3; border-color: #f3e2bd; }
.status--transit { color: #0b8fc9; background: #e8f7fd; border-color: #c9ecfa; }
.status--signed { color: #1d9e57; background: #e9f9ef; border-color: #c6ecd6; }
.status--exception { color: #d94646; background: #fdecec; border-color: #f6cccc; }
.status--unknown { color: #5b7186; background: #f0f4f8; border-color: #dfe6ee; }

[data-theme="dark"] .status--pending { color: #e0b063; background: rgba(224, 176, 99, 0.12); border-color: rgba(224, 176, 99, 0.28); }
[data-theme="dark"] .status--transit { color: #6cc9ef; background: rgba(60, 192, 232, 0.12); border-color: rgba(60, 192, 232, 0.28); }
[data-theme="dark"] .status--signed { color: #5fd08f; background: rgba(63, 196, 126, 0.12); border-color: rgba(63, 196, 126, 0.28); }
[data-theme="dark"] .status--exception { color: #f28b8b; background: rgba(240, 115, 115, 0.12); border-color: rgba(240, 115, 115, 0.28); }
[data-theme="dark"] .status--unknown { color: #a9b7c8; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.26); }

.record__toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 12.5px;
  white-space: nowrap;
}
.record__toggle:hover { color: var(--brand-dark); }
.record__toggle svg { width: 12px; height: 12px; transition: transform 0.2s ease; }
.record.is-open .record__toggle svg { transform: rotate(180deg); }

.record__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  margin: 12px 0 0;
}
.record__fields div { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.record__fields dt { color: var(--muted); font-size: 12.5px; }
.record__fields dd { margin: 0; color: var(--text); }

.record__last {
  display: flex;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
  word-break: break-word;
}
.record__last span { flex: 0 0 auto; color: var(--muted); }

.record__body {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.variant-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.variant-bar select {
  max-width: min(320px, 70vw);
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-family: var(--mono);
}

/* ---------------- 轨迹 ---------------- */
.events {
  --rail-x: 102px;
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}
.events::before {
  content: "";
  position: absolute;
  left: calc(var(--rail-x) - 0.5px);
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}
.event {
  display: grid;
  grid-template-columns: 84px 12px minmax(0, 1fr);
  column-gap: 12px;
  padding-bottom: 16px;
}
.event:last-child { padding-bottom: 0; }
.event__when {
  padding-top: 1px;
  text-align: right;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.event__when b { display: block; font-weight: 400; }
.event__dot { position: relative; }
.event__dot::before {
  content: "";
  position: relative;
  z-index: 1;
  display: block;
  width: 7px; height: 7px;
  margin: 6px auto 0;
  border-radius: 50%;
  background: var(--line-strong);
}
.event:first-child .event__dot::before {
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.event__main { min-width: 0; }
.event__title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.55;
  word-break: break-word;
}
.event__desc {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-word;
}
.no-events { margin: 0; padding: 4px 0; font-size: 12.5px; color: var(--muted); }

.record--empty .record__last { color: var(--text-2); }
.record--error { border-color: rgba(217, 70, 70, 0.35); }
.record--error .record__no { color: var(--danger); }
.record--error .record__last { color: var(--text-2); }
.record__hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

/* ---------------- 页脚 / 提示 ---------------- */
.footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 50;
  max-width: 90vw;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 640px) {
  .appbar__inner { padding: 0 16px; height: 52px; }
  .appbar__title h1 { font-size: 15.5px; }
  .page { padding: 16px 16px 28px; }
  .search-card { padding: 12px; }
  .search-foot { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-btns { justify-content: flex-end; }
  .record { padding: 12px 14px; }
  .record__side { gap: 8px; }
  .status { max-width: 128px; }
  .record__fields { gap: 3px 18px; }
  .events { --rail-x: 78px; }
  .event { grid-template-columns: 64px 12px minmax(0, 1fr); column-gap: 8px; }
  .footer { padding: 0 16px 26px; }
}

@media (max-width: 520px) {
  .record__head { flex-wrap: wrap; }
  .record__side { width: 100%; justify-content: space-between; }
}

@media (max-width: 400px) {
  .appbar__title span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ---------------- 联系我们 ---------------- */
.contact {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 24px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.contact__qr {
  flex: 0 0 auto;
  width: 124px;
  height: 124px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.contact__qr img { display: block; width: 100%; height: 100%; object-fit: contain; }
.contact__body { min-width: 0; }
.contact h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.contact__desc { margin: 0 0 8px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.contact__phone { display: inline-block; font-size: 18px; font-weight: 600; letter-spacing: 0.02em; color: var(--brand); }
.contact__phone:hover { text-decoration: underline; }
.contact__note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }

@media (max-width: 520px) {
  .contact { flex-direction: column; align-items: flex-start; gap: 14px; }
  .contact__qr { width: 110px; height: 110px; }
}
