:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --moving: #1d4ed8;
  --moving-bg: #dbeafe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------------- header ---------------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
  font-weight: 700;
  letter-spacing: .5px;
  flex-wrap: wrap;
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--primary);
  display: inline-block;
  align-self: center;
}

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

.count {
  font-size: 13px;
  color: var(--muted);
}

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: #cbd5e1; }

/* 云端模式：当前登录人 + 退出（本地模式不出现） */
.who {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  line-height: 1.3;
}

.logout:hover { color: var(--text); border-color: #cbd5e1; }

/* ---------------- search ---------------- */

.search {
  display: flex;
  gap: 10px;
  background: var(--card);
  border-radius: 14px;
  padding: 10px;
  box-shadow: var(--shadow);
}

.search input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f8fafc;
  color: var(--text);
}

#num { flex: 1; min-width: 0; letter-spacing: .5px; }
#num::placeholder { letter-spacing: 0; color: #9ca3af; }

#phone {
  width: 108px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
#phone:focus { color: var(--text); background: #fff; box-shadow: inset 0 0 0 1px #bfdbfe; }

.search input:focus { background: #fff; box-shadow: inset 0 0 0 1px #bfdbfe; }

.search button {
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 0 26px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s;
}
.search button:hover { background: var(--primary-dark); }
.search button:disabled { background: #93c5fd; cursor: default; }

.hint {
  min-height: 22px;
  font-size: 13px;
  color: var(--muted);
  padding: 8px 4px 0;
}
.hint.error { color: var(--bad); }

/* ---------------- result ---------------- */

.result { margin-top: 6px; }

.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px 24px 8px;
  animation: fade .18s ease-out;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.nu {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  word-break: break-all;
}

.meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.badge {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.moving { color: var(--moving); background: var(--moving-bg); }
.badge.unknown { color: var(--muted); background: #f3f4f6; }

/* 时间线 */

.timeline {
  list-style: none;
  margin: 0;
  padding: 18px 0 8px;
}

.timeline li {
  position: relative;
  padding: 0 0 20px 26px;
  border-left: 2px solid var(--line);
  margin-left: 5px;
}

.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 6px;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #cbd5e1;
}

.timeline li:first-child::before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.timeline .t {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.timeline .c {
  font-size: 14.5px;
  margin-top: 2px;
  word-break: break-all;
}

.timeline li:first-child .c {
  font-weight: 600;
  color: var(--text);
}

/* 空态 / 错误 */

.empty {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfcfe;
}

.err-box {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border-left: 4px solid var(--bad);
}

.err-box .m {
  font-weight: 600;
  color: var(--bad);
}

.err-box .h {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

.err-box .raw {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 8px;
  font-family: Consolas, monospace;
  word-break: break-all;
}

/* 认不出快递公司时的手动选择条 */
.err-box .pick-com {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.err-box .pick-label {
  font-size: 13px;
  color: var(--text);
}

.err-box .pick-com select {
  flex: 1;
  min-width: 150px;
  max-width: 220px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
}

.err-box .pick-com select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.err-box .pick-com button {
  height: 34px;
  padding: 0 18px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
}

.err-box .pick-com button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

/* ---------------- modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .22);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.modal-tip {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.6;
}

.modal-card label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 0 5px;
}

.opt {
  color: #9ca3af;
  font-weight: 400;
}

.modal-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  outline: none;
  color: var(--text);
}
.modal-card input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(59, 130, 246, .12); }

.cfg-msg {
  font-size: 12.5px;
  min-height: 18px;
  margin-top: 10px;
  color: var(--ok);
}
.cfg-msg.error { color: var(--bad); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions button {
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
.modal-actions button:hover { background: var(--primary-dark); }

.modal-actions button.ghost {
  background: #f3f4f6;
  color: var(--muted);
}
.modal-actions button.ghost:hover { background: #e5e7eb; color: var(--text); }
