:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #66727f;
  --line: #dfe4e8;
  --accent: #087f5b;
  --accent-dark: #066a4c;
  --accent-soft: #e9f7f1;
  --blue: #2864dc;
  --blue-soft: #eaf0ff;
  --danger: #c53b3b;
  --danger-soft: #fff0f0;
  --warning: #a6640a;
  --warning-soft: #fff6e6;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
}

button, input, textarea { font: inherit; letter-spacing: 0; }

button { cursor: pointer; }

button:disabled { cursor: not-allowed; opacity: .58; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1120px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; }

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-radius: 7px;
  font-size: 15px;
}

.tabs { align-self: stretch; display: flex; gap: 24px; }

.tab {
  position: relative;
  border: 0;
  padding: 0 2px;
  color: var(--muted);
  background: transparent;
  font-weight: 600;
}

.tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  background: transparent;
}

.tab.active { color: var(--ink); }
.tab.active::after { background: var(--accent); }
.support-trigger { min-width: 76px; border: 0; padding: 0 2px; color: var(--accent-dark); background: transparent; font-weight: 700; }

.view { display: none; }
.view.active { display: block; }

.workspace { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 72px; }

.page-heading { margin-bottom: 30px; }
.page-heading h1 { margin: 5px 0 8px; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
.page-heading > p:last-child { margin: 0; color: var(--muted); line-height: 1.65; }

.eyebrow { margin: 0; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 1.4px; }

.redeem-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 24px; align-items: start; }

.tool-panel, .status-panel, .history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tool-panel { padding: 30px; }
.status-panel { padding: 26px; min-height: 380px; }

.panel-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.panel-heading.compact { margin-bottom: 22px; }
.panel-heading h2, .status-header h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: 0; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.step-number {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }

input, textarea {
  width: 100%;
  border: 1px solid #cbd2d8;
  border-radius: 6px;
  padding: 13px 14px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}

textarea { min-height: 150px; resize: vertical; font-family: Consolas, monospace; font-size: 13px; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 127, 91, .12); }

.button-row { display: flex; gap: 12px; margin-top: 16px; }
.button-row button { flex: 1; }

.primary, .secondary {
  min-height: 43px;
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 700;
}

.primary { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { border: 1px solid #cbd2d8; color: var(--ink); background: #fff; }
.secondary:hover:not(:disabled) { border-color: #9da8b2; background: #fafbfc; }
.full { width: 100%; margin-top: 20px; }

.inline-message { display: none; margin-top: 14px; padding: 11px 13px; border-radius: 6px; font-size: 13px; line-height: 1.5; }
.inline-message.show { display: block; }
.inline-message.success { color: #076747; background: var(--accent-soft); }
.inline-message.error { color: #9e2f2f; background: var(--danger-soft); }
.inline-message.info { color: #1f55ba; background: var(--blue-soft); }

.divider { height: 1px; margin: 28px 0; background: var(--line); }
.session-guide { margin: -4px 0 20px; padding: 13px 15px; border-left: 3px solid var(--blue); background: #f2f6ff; color: #465463; font-size: 13px; line-height: 1.65; }
.session-guide p { margin: 0; }
.session-guide p + p { margin-top: 3px; }
.session-guide a { color: #1f55ba; font-weight: 700; overflow-wrap: anywhere; }
.session-guide a:hover { color: #174397; }
.session-meta { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.session-meta span:first-child { color: var(--accent); font-weight: 700; }

.confirmed-account, .account-preview {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #bde3d4;
  border-radius: 6px;
  background: var(--accent-soft);
  font-size: 13px;
}

.confirmed-account span, .account-preview span { color: var(--muted); }
.confirmed-account strong, .account-preview strong { overflow-wrap: anywhere; text-align: right; }

.status-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.status-header h2 { margin-top: 5px; }
.status-badge { flex: 0 0 auto; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 800; }
.status-badge.neutral { color: #5f6872; background: #eef1f3; }
.status-badge.pending { color: var(--warning); background: var(--warning-soft); }
.status-badge.processing { color: var(--blue); background: var(--blue-soft); }
.status-badge.done { color: var(--accent); background: var(--accent-soft); }
.status-badge.failed { color: var(--danger); background: var(--danger-soft); }

.progress-track { height: 5px; margin: 24px 0 28px; overflow: hidden; border-radius: 3px; background: #e9edf0; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .4s ease; }

.status-empty { min-height: 235px; display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.status-empty p { max-width: 260px; margin: 14px 0 0; font-size: 13px; line-height: 1.7; }
.status-symbol { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-weight: 800; }

.status-content dl { margin: 0; }
.status-content dl div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #edf0f2; }
.status-content dt { color: var(--muted); font-size: 13px; }
.status-content dd { margin: 0; max-width: 65%; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; text-align: right; }
.status-note { margin: 18px 0 0; padding: 13px; border-radius: 6px; background: #f5f7f8; color: #4f5a65; font-size: 13px; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; }

.history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.history-heading .secondary { margin-bottom: 30px; }
.history-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: 15px 18px; border-bottom: 1px solid #e8ecef; text-align: left; font-size: 13px; }
th { color: var(--muted); background: #fafbfc; font-size: 12px; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
.record-status { display: inline-block; border-radius: 999px; padding: 5px 8px; font-size: 11px; font-weight: 800; }
.record-status.done { color: var(--accent); background: var(--accent-soft); }
.record-status.failed, .record-status.not_found { color: var(--danger); background: var(--danger-soft); }
.record-status.pending { color: var(--warning); background: var(--warning-soft); }
.record-status.processing { color: var(--blue); background: var(--blue-soft); }
.history-empty { padding: 52px 20px; color: var(--muted); text-align: center; }

dialog { width: min(440px, calc(100% - 32px)); border: 0; border-radius: 8px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(20, 30, 40, .24); }
dialog::backdrop { background: rgba(16, 25, 33, .55); }
dialog form { padding: 30px; }
dialog h2 { margin: 8px 0; font-size: 22px; letter-spacing: 0; }
dialog form > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-icon { width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 50%; color: #fff; background: var(--accent); font-weight: 800; }
.dialog-actions { margin-top: 24px; }
.support-dialog { width: min(420px, calc(100% - 32px)); }
.support-dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.support-dialog-heading h2 { margin-top: 6px; }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: white; font-size: 22px; line-height: 1; }
.support-wechat-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 20px 0 16px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; }
.support-wechat-row span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.support-wechat-row strong { overflow-wrap: anywhere; }
.support-public-qr { width: min(280px, 100%); aspect-ratio: 1; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: white; }
.support-public-qr img { width: 100%; height: 100%; display: block; object-fit: contain; }
.support-contact-empty { padding: 36px 12px; color: var(--muted); text-align: center; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100% - 48px)); padding: 12px 16px; border-radius: 6px; color: #fff; background: #25313c; box-shadow: 0 8px 28px rgba(20, 30, 40, .22); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 780px) {
  .topbar { height: auto; min-height: 64px; padding: 0 18px; }
  .brand { font-size: 14px; }
  .tabs { gap: 14px; }
  .tab { min-height: 64px; font-size: 13px; }
  .support-trigger { min-height: 64px; font-size: 13px; }
  .workspace { width: min(100% - 28px, 620px); padding: 34px 0 54px; }
  .page-heading h1 { font-size: 25px; }
  .redeem-grid { grid-template-columns: 1fr; }
  .tool-panel, .status-panel { padding: 22px; }
  .button-row:not(.dialog-actions) { flex-direction: column; }
  .session-meta { flex-direction: column; gap: 4px; }
  .history-heading { align-items: stretch; flex-direction: column; gap: 0; }
  .history-heading .secondary { align-self: flex-start; margin: -14px 0 22px; }
}

@media (max-width: 430px) {
  .brand span:last-child { display: none; }
  .tabs { margin-left: auto; }
  .tabs { gap: 11px; }
  .confirmed-account, .account-preview { flex-direction: column; gap: 5px; }
  .confirmed-account strong, .account-preview strong { text-align: left; }
  dialog form { padding: 24px; }
}
