:root {
  --bg: #f4f8f7;
  --surface: #ffffff;
  --surface-soft: #f7fbfa;
  --text: #17322d;
  --muted: #6a7e79;
  --line: #dce8e5;
  --primary: #16866f;
  --primary-dark: #106b59;
  --primary-soft: #e8f5f1;
  --blue: #3978a8;
  --warning: #9a6700;
  --danger: #b43a45;
  --shadow: 0 12px 32px rgba(33, 77, 68, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.is-hidden { display: none !important; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 24px auto 56px; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; min-width: 0; gap: 14px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 50px; width: 50px; height: 50px; border-radius: 8px; color: #fff; background: var(--primary); font-size: 18px; font-weight: 900; }
.brand h1 { margin: 0; font-size: 21px; line-height: 1.25; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; margin-top: 20px; }
.sidebar, .content-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.sidebar { padding: 22px; }
.section-label { margin-bottom: 12px; color: var(--primary); font-size: 13px; font-weight: 800; }
.support-qr { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: contain; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.steps { display: grid; gap: 10px; margin-top: 20px; }
.step { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 11px; min-height: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface-soft); }
.step.is-active { border-color: #8cc8ba; color: var(--text); background: var(--primary-soft); }
.step-number { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #b8cbc6; border-radius: 50%; font-weight: 800; }
.step.is-active .step-number { border-color: var(--primary); color: #fff; background: var(--primary); }
.step strong, .step small { display: block; }
.step strong { font-size: 14px; }
.step small { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.content-panel { min-height: 595px; padding: clamp(26px, 4vw, 48px); }
.flow-view { width: 100%; }
.panel-heading { margin-bottom: 28px; }
.step-tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 11px; border-radius: 6px; color: var(--primary-dark); background: var(--primary-soft); font-size: 12px; font-weight: 900; }
.panel-heading h2 { margin: 18px 0 8px; font-size: clamp(24px, 3vw, 32px); line-height: 1.2; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.field { display: grid; gap: 9px; margin-bottom: 16px; }
.field > span { font-size: 14px; font-weight: 800; }
input, textarea { width: 100%; border: 1px solid #cbdcd7; border-radius: 8px; outline: none; color: var(--text); background: #fff; transition: border-color .2s, box-shadow .2s; }
input { height: 52px; padding: 0 15px; }
textarea { min-height: 150px; padding: 14px 15px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 134, 111, .12); }
input::placeholder, textarea::placeholder { color: #9aaba7; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 19px; border: 1px solid transparent; border-radius: 8px; text-decoration: none; font-weight: 800; transition: background .2s, border-color .2s, transform .1s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-outline { border-color: #a7c9c1; color: var(--primary-dark); background: #fff; }
.button-outline:hover { border-color: var(--primary); background: var(--primary-soft); }
.button-muted { border-color: var(--line); color: #536965; background: #f3f7f6; }
.button-full { width: 100%; }
.button-row { display: grid; grid-template-columns: auto minmax(180px, 1fr); gap: 12px; margin-top: 18px; }
.session-link { display: flex; align-items: center; justify-content: center; min-height: 50px; margin-bottom: 18px; border: 1px dashed #78b5a7; border-radius: 8px; color: var(--primary-dark); background: var(--primary-soft); text-decoration: none; font-weight: 800; }

.helper-box { margin-top: 18px; padding: 16px 18px; border-left: 4px solid #79b9aa; border-radius: 0 8px 8px 0; background: var(--surface-soft); }
.helper-box strong { font-size: 14px; }
.helper-box p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.status-message { margin-top: 14px; padding: 12px 14px; border-radius: 8px; color: var(--muted); background: #f3f7f6; font-size: 13px; line-height: 1.55; }
.status-message.success { color: var(--primary-dark); background: var(--primary-soft); }
.status-message.error { color: var(--danger); background: #fff0f1; }
.status-message.pending { color: var(--blue); background: #edf5fa; }
.account-summary { display: grid; gap: 1px; overflow: hidden; margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.account-summary > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 12px; padding: 13px 15px; background: #fff; }
.account-summary span { color: var(--muted); font-size: 13px; }
.account-summary strong { overflow-wrap: anywhere; font-size: 14px; }

.notice-band { margin-top: 20px; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.notice-band h2 { margin: 0 0 14px; font-size: 17px; }
.notice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.notice-grid p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.notice-grid b { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 5px; border-radius: 50%; color: var(--primary-dark); background: var(--primary-soft); }
.tool-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.usage-tutorial { cursor: default; opacity: .82; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: rgba(20, 44, 39, .46); }
.modal-dialog { position: relative; z-index: 1; width: min(500px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 26px; border: 2px solid #8cc8ba; border-radius: 10px; background: #fff; box-shadow: 0 24px 70px rgba(20, 55, 48, .18); }
.draggable-dialog { cursor: default; }
.draggable-dialog.is-dragging { cursor: grabbing; user-select: none; }
.modal-drag-bar { display: flex; align-items: center; justify-content: space-between; height: 44px; margin: -26px -26px 18px; padding-left: 16px; border-bottom: 1px solid #dce8e5; color: var(--muted); cursor: grab; font-size: 12px; font-weight: 800; touch-action: none; }
.modal-drag-bar .icon-button { width: 32px; height: 32px; margin-left: 10px; border: 0; background: transparent; }
.draggable-dialog.is-dragging .modal-drag-bar { cursor: grabbing; }
.modal-wide { width: min(680px, 100%); }
.modal-dialog > h2 { margin: 14px 0 0; text-align: center; font-size: 22px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-heading h2 { margin: 0; font-size: 21px; }
.modal-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: #fff; font-size: 24px; line-height: 1; }
.result-mark { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto; border-radius: 50%; color: #fff; background: var(--primary); font-weight: 900; }
.result-mark.error { background: var(--danger); }
.modal-copy { margin: 16px 0 20px; color: var(--muted); text-align: center; font-size: 14px; line-height: 1.65; }
.detail-list { display: grid; gap: 1px; overflow: hidden; margin-top: 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--line); }
.detail-list > div { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 12px; padding: 12px 14px; background: #fff; }
.detail-list span { color: var(--muted); font-size: 13px; }
.detail-list strong { overflow-wrap: anywhere; font-size: 14px; }
.loader { width: 44px; height: 44px; margin: 0 auto; border: 4px solid #dcebe7; border-top-color: var(--primary); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; margin: 18px 0; overflow: hidden; border-radius: 4px; background: #e8efed; }
.progress span { display: block; width: 8%; height: 100%; background: var(--primary); transition: width .5s ease; }
.query-input { min-height: 130px; margin-bottom: 14px; }
.query-results { display: grid; gap: 9px; margin-top: 16px; }
.query-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 8px; }
.query-stat { display: grid; place-items: center; min-height: 70px; padding: 10px; border: 1px solid; border-radius: 8px; }
.query-stat span { font-size: 12px; font-weight: 800; }
.query-stat strong { margin-top: 2px; font-size: 22px; line-height: 1; }
.query-stat.valid { border-color: #9bd7fb; color: #087dad; background: #eff9ff; }
.query-stat.used { border-color: #f1cf75; color: #b66a00; background: #fff9e9; }
.query-stat.invalid { border-color: #f1c8cd; color: #c83e49; background: #fff4f5; }
.query-details-label { margin: 4px 2px 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.query-item { padding: 14px 16px; border: 1px solid #83cfff; border-radius: 12px; background: #fff; box-shadow: 0 4px 12px rgba(47, 103, 132, .08); }
.query-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 38px; padding-bottom: 11px; border-bottom: 1px solid #edf2f5; }
.query-item code { overflow-wrap: anywhere; color: var(--text); font-weight: 800; }
.badge { flex: 0 0 auto; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.badge.valid { color: var(--primary-dark); background: var(--primary-soft); }
.badge.used { color: var(--warning); background: #fff5db; }
.badge.invalid { color: var(--danger); background: #fff0f1; }
.query-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; color: var(--muted); font-size: 12px; }
.query-meta span { padding: 4px 8px; border-radius: 6px; background: #f4f8fa; }
.query-meta .query-time { flex-basis: 100%; padding: 0 2px; background: transparent; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 20px, 600px); margin: 10px auto 34px; }
  .site-header { align-items: stretch; padding: 15px; }
  .brand-mark { flex-basis: 44px; width: 44px; height: 44px; }
  .brand h1 { font-size: 17px; }
  .brand p { font-size: 11px; }
  .site-header > .button { min-height: 44px; padding: 0 13px; font-size: 13px; }
  .workspace { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
  .sidebar { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; padding: 14px; }
  .section-label { margin-bottom: 7px; font-size: 12px; }
  .support-qr { width: 112px; aspect-ratio: 1 / 1; }
  .steps { gap: 6px; margin: 0; }
  .step { grid-template-columns: 28px minmax(0, 1fr); min-height: 54px; padding: 8px; }
  .step-number { width: 26px; height: 26px; font-size: 12px; }
  .step strong { font-size: 13px; }
  .step small { display: none; }
  .content-panel { min-height: 480px; padding: 24px 16px; }
  .panel-heading { margin-bottom: 22px; }
  .panel-heading h2 { margin-top: 14px; font-size: 25px; }
  .button-row { grid-template-columns: 1fr; }
  .button-row .button-primary { order: -1; }
  .notice-band { margin-top: 12px; padding: 17px; }
  .notice-grid { grid-template-columns: 1fr; gap: 7px; }
  .tool-row { display: grid; grid-template-columns: 1fr 1fr; }
  .modal-dialog { padding: 22px 17px; }
  .modal-drag-bar { margin: -22px -17px 18px; }
  .query-summary { gap: 8px; }
  .query-stat { min-height: 64px; padding: 8px 4px; }
}

@media (max-width: 420px) {
  .site-header { flex-wrap: wrap; }
  .site-header > .button { width: 100%; }
  .sidebar { grid-template-columns: 88px minmax(0, 1fr); }
  .support-qr { width: 88px; }
  .step { min-height: 48px; }
  .content-panel { padding: 22px 14px; }
}
