:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --orange: #ea580c;
  --orange-soft: #fff7ed;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --gray: #6b7280;
  --gray-soft: #f3f4f6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* ---------- Header ---------- */
.header {
  text-align: center;
  margin-bottom: 24px;
}

.header .logo {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
}

.header .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---------- Form ---------- */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.required {
  color: var(--red);
}

.hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

.field input,
.field select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.row {
  display: flex;
  gap: 12px;
}

.row .field {
  flex: 1;
}

.btn-primary {
  width: 100%;
  height: 48px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-primary:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
}

.tip {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: center;
}

/* ---------- Loading ---------- */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Error ---------- */
.error {
  background: var(--red-soft);
  border-color: #fecaca;
  color: var(--red);
  font-size: 14px;
  text-align: center;
}

/* ---------- Result ---------- */
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.result-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.com-badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.number {
  font-size: 14px;
  color: var(--text-muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.5px;
}

.status-badge {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
}

.status-badge.s-green { background: var(--green-soft); color: var(--green); }
.status-badge.s-blue { background: var(--blue-soft); color: var(--blue); }
.status-badge.s-orange { background: var(--orange-soft); color: var(--orange); }
.status-badge.s-red { background: var(--red-soft); color: var(--red); }
.status-badge.s-gray { background: var(--gray-soft); color: var(--gray); }

.trace-summary {
  margin: 14px 0 4px;
  font-size: 14px;
  color: var(--text);
}

.trace-summary strong {
  color: var(--primary);
}

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  margin-top: 12px;
  position: relative;
}

.timeline li {
  position: relative;
  padding: 0 0 22px 28px;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.timeline li:first-child::before {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.timeline li::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline li:last-child::after {
  display: none;
}

.timeline .t-content {
  font-size: 14px;
  color: var(--text);
}

.timeline .t-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

/* ---------- History ---------- */
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-head h2 {
  font-size: 15px;
  font-weight: 700;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-ghost:hover {
  color: var(--red);
  background: var(--red-soft);
}

.history-list {
  list-style: none;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  border-radius: 8px;
}

.history-list li:last-child {
  border-bottom: none;
}

.history-list li:hover {
  background: var(--gray-soft);
}

.history-item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.history-item-main .h-com {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.history-item-main .h-number {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 16px 0;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 24px;
}

/* ---------- Utils ---------- */
.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .row {
    flex-direction: column;
    gap: 0;
  }
}
