/* ================================
   CSS Variables
   ================================ */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dk: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 20px rgba(0,0,0,.05);
}

/* ================================
   Reset & Base
   ================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 16px 80px;
}

input, textarea, select, button { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
textarea { resize: vertical; }
.hidden { display: none !important; }

/* ================================
   Site header (above card)
   ================================ */
.site-top {
  text-align: center;
  margin-bottom: 24px;
  width: 100%;
  max-width: 740px;
}

.site-brand {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.03em;
}

.site-announce {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.site-announce:empty { display: none; }

/* ================================
   Main card
   ================================ */
.main-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  width: 100%;
  max-width: 740px;
  overflow: hidden;
}

/* ================================
   Card tab bar
   ================================ */
.card-tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.card-tab {
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 16px 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  letter-spacing: -.01em;
}

.card-tab:not(:last-child) {
  border-right: 1px solid var(--border);
}

.card-tab.active {
  background: var(--surface);
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.card-tab:hover:not(.active) {
  background: #f1f5f9;
  color: var(--text);
}

/* ================================
   Card panels
   ================================ */
.card-panel {
  padding: 28px;
}

/* ================================
   Stepper
   ================================ */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}

.stp {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.stp-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #94a3b8;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .2s, color .2s, box-shadow .2s;
}

.stp.active .stp-dot {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}

.stp.done .stp-dot {
  background: var(--success);
  color: #fff;
}

.stp-lbl {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
  transition: color .2s;
}

.stp.active .stp-lbl { color: var(--primary); }
.stp.done .stp-lbl   { color: var(--success); }

.stp-line {
  flex: 1;
  height: 2px;
  background: #e2e8f0;
  min-width: 10px;
  transition: background .3s;
}

/* ================================
   Step sections
   ================================ */
.step-section {
  padding-top: 4px;
}

/* ================================
   Card head
   ================================ */
.card-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.card-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-head h2 {
  margin: 0 0 3px;
  font-size: 17px;
  font-weight: 800;
}

.card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ================================
   Forms
   ================================ */
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field:last-child { margin-bottom: 0; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.flabel {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.opt {
  font-weight: 400;
  color: var(--muted);
}

.finput {
  width: 100%;
  border: 1.5px solid #cbd7e6;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 13px;
  outline: none;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

.finput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: -4px 0 14px;
}

.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.btn-row.center { justify-content: center; }

/* ================================
   Buttons
   ================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 14px;
  min-height: 42px;
  transition: background .15s, box-shadow .15s;
  white-space: nowrap;
}

.full-btn { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-ghost {
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
}
.btn-ghost:hover { background: #e9eef6; }

/* ================================
   Package preview
   ================================ */
.pkg-banner {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  color: #1e3a8a;
  font-size: 14px;
  line-height: 1.75;
}

.pkg-banner strong { display: block; font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.pkg-banner .muted-line { color: #3b82f6; font-size: 13px; margin-top: 4px; }

/* ================================
   Confirm box
   ================================ */
.confirm-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 16px;
  margin-bottom: 18px;
}

.c-row {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 14px;
  align-items: baseline;
}

.c-row:last-child { border-bottom: 0; }
.c-row span { color: var(--muted); min-width: 72px; flex-shrink: 0; font-size: 13px; }
.c-row b { word-break: break-all; }

/* ================================
   Step 4 success
   ================================ */
.success-hero {
  text-align: center;
  padding: 16px 0 24px;
}

.success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #dcfce7;
  color: var(--success);
  font-size: 28px;
  font-weight: 900;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}

.success-hero h2 { margin: 0 0 8px; font-size: 19px; }
.success-hero p  { margin: 0; color: var(--muted); font-size: 14px; }

.result-detail {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 16px;
  margin-bottom: 18px;
}

.result-detail strong {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0 10px;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.r-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px dashed #e2e8f0;
  font-size: 14px;
}

.r-row:last-child { border-bottom: 0; }
.r-row span { color: var(--muted); }

/* ================================
   Status badges
   ================================ */
.badge, .status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending    { color: #92400e; background: #fef3c7; }
.status.processing { color: #1e40af; background: #dbeafe; }
.status.completed  { color: #14532d; background: #dcfce7; }
.status.failed, .status.problem, .status.cancelled { color: #991b1b; background: #fee2e2; }
.status.unused, .status.returned { color: #713f12; background: #fefce8; }
.status.disabled, .status.expired, .status.missing, .status.unknown { color: #7f1d1d; background: #ffe4e6; }

/* ================================
   Query sub-tabs
   ================================ */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  border: none;
  background: none;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}

.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

/* ================================
   Summary cards
   ================================ */
.summary-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.s-card {
  flex: 1;
  min-width: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.s-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.s-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.s-card strong { font-size: 20px; font-weight: 900; }

.s-card.ok   { border-color: #bbf7d0; background: #f0fdf4; }
.s-card.ok strong   { color: var(--success); }
.s-card.warn { border-color: #fde68a; background: #fffbeb; }
.s-card.warn strong { color: var(--warning); }
.s-card.fail { border-color: #fecaca; background: #fff1f2; }
.s-card.fail strong { color: var(--danger); }

/* ================================
   Filter bar
   ================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.fbtn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 700;
  transition: all .15s;
}

.fbtn.active, .fbtn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.fbtn-export {
  margin-left: auto;
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.fbtn-export:hover { background: var(--primary); color: #fff; }

/* ================================
   Query results table
   ================================ */
.q-table-wrap {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}

.q-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
}

.q-table-wrap th, .q-table-wrap td {
  padding: 10px 13px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

.q-table-wrap th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.q-table-wrap tr:last-child td { border-bottom: 0; }
.q-table-wrap tr.row-ok td     { background: #fafffd; }
.q-table-wrap tr.row-pending td { background: #fffffb; }
.q-table-wrap tr.row-fail td   { background: #fffafa; }

.mono { font-family: Consolas, Menlo, "Courier New", monospace; font-size: 12px; }

.q-act {
  border: none;
  background: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
}

.q-act:hover { color: var(--primary-dk); text-decoration: underline; }
.q-acts { display: flex; gap: 8px; }

.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

/* ================================
   Order number result
   ================================ */
.order-result {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 16px;
  margin-top: 18px;
}

.or-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.or-head strong { font-size: 15px; }

/* ================================
   Tutorial
   ================================ */
.tut-list {
  display: grid;
  gap: 12px;
}

.tut-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  gap: 16px;
}

.tut-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 900;
  flex-shrink: 0;
  margin-top: 2px;
}

.tut-num-faq {
  background: linear-gradient(135deg, #0f172a, #334155);
  font-size: 17px;
}

.tut-body h3 { margin: 2px 0 8px; font-size: 15px; font-weight: 800; }
.tut-body p  { margin: 0 0 8px; color: #334155; font-size: 13px; line-height: 1.75; }
.tut-body p:last-child { margin-bottom: 0; }

.tut-faq { border-left: 3px solid #1d4ed8; }

code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px;
  color: #1e40af;
}

.code-block {
  background: #0f172a;
  color: #7dd3fc;
  font-family: Consolas, Menlo, "Courier New", monospace;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 7px;
  margin: 10px 0;
  word-break: break-all;
  user-select: all;
}

.tip-box {
  background: #eff6ff;
  border-left: 3px solid #3b82f6;
  border-radius: 0 6px 6px 0;
  padding: 9px 13px;
  font-size: 13px;
  color: #1e3a8a;
  margin: 10px 0 0;
  line-height: 1.65;
}

.tip-warn { background: #fffbeb; border-left-color: var(--warning); color: #78350f; }

.faq-item { margin-top: 12px; }
.faq-item:first-child { margin-top: 4px; }
.faq-q { font-weight: 700; color: var(--text); font-size: 13px; margin-bottom: 3px; }
.faq-a { color: var(--muted); font-size: 13px; line-height: 1.65; }

/* ================================
   Contact bar
   ================================ */
.contact-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 10px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
}

/* ================================
   Toast
   ================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  z-index: 999;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  pointer-events: none;
}

/* ================================
   Responsive — Mobile
   ================================ */
@media (max-width: 640px) {
  body { padding: 20px 10px 70px; }

  .site-brand { font-size: 18px; }

  .main-card { border-radius: 12px; }

  .card-tab { padding: 13px 6px; font-size: 13px; }

  .card-panel { padding: 20px 14px; }

  .stp-lbl { display: none; }
  .stp-line { min-width: 8px; }
  .stp-dot { width: 28px; height: 28px; font-size: 12px; }

  .field-row { grid-template-columns: 1fr; gap: 0; }

  .tut-card { padding: 14px 14px; gap: 12px; }
  .tut-num  { width: 32px; height: 32px; font-size: 13px; }
}
