:root {
  color-scheme: light;
  --ink: #121814;
  --muted: #67706a;
  --line: #dce2de;
  --line-strong: #c5cec8;
  --canvas: #f4f6f4;
  --surface: #ffffff;
  --accent: #08785b;
  --accent-dark: #056047;
  --accent-soft: #e5f3ee;
  --danger: #b83037;
  --danger-soft: #fae9ea;
  --warning: #a55d08;
  --warning-soft: #fbf0dc;
  --focus: #43a98b;
  --radius: 6px;
  --shadow: 0 10px 28px rgba(22, 35, 27, 0.07);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.topbar-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa19c;
}

.state-dot.is-online {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.state-dot.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.state-dot.is-pending {
  background: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-soft);
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 28px auto 48px;
}

.access-strip {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(420px, 1.3fr);
  align-items: end;
  gap: 48px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.access-copy,
.panel-heading > div:first-child {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.section-index {
  flex: 0 0 auto;
  margin-top: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.3;
}

h3 {
  margin-bottom: 0;
  font-size: 14px;
}

.key-field label,
.field-group label {
  display: block;
  margin-bottom: 8px;
  color: #3f4943;
  font-size: 13px;
  font-weight: 700;
}

.input-with-action {
  position: relative;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input {
  height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 294px;
  padding: 13px;
  resize: vertical;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #9aa19c;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(67, 169, 139, 0.16);
}

.input-with-action input {
  padding-right: 48px;
}

.icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover {
  background: var(--canvas);
  color: var(--ink);
}

.icon-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.view-tabs {
  display: flex;
  width: max-content;
  margin: 24px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #e9eeeb;
}

.tab-button {
  min-width: 110px;
  height: 38px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 32, 25, 0.09);
}

.workspace-view {
  display: none;
}

.workspace-view.is-active {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(350px, 0.82fr) minmax(480px, 1.18fr);
  gap: 18px;
}

.form-panel,
.result-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 24px;
}

.result-panel {
  min-height: 530px;
  padding: 24px;
}

.panel-heading {
  min-height: 42px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.counter {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--danger);
  font-weight: 800;
}

.field-group {
  margin-bottom: 20px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.text-action {
  margin: -6px -6px 2px 0;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.text-action:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.primary-button {
  width: 100%;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  transition: background 150ms ease, transform 150ms ease;
}

.primary-button:hover:not(:disabled) {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.form-message {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: #7a2227;
  font-size: 13px;
  line-height: 1.5;
}

.balance {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.balance span {
  color: var(--muted);
  font-size: 12px;
}

.balance strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.balance strong::after {
  content: " U";
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  min-height: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-symbol {
  width: 46px;
  height: 46px;
  margin-bottom: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: #7b857f;
  font-size: 15px;
  font-weight: 800;
}

.empty-state strong {
  margin-bottom: 6px;
  color: #47504a;
  font-size: 14px;
}

.empty-state p {
  margin-bottom: 0;
  font-size: 13px;
}

.result-section + .result-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.result-section-title {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-count {
  min-width: 25px;
  padding: 3px 7px;
  border-radius: 999px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.status-count-success {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-count-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.order-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(150px, 1fr) 90px 64px;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 0;
  border-bottom: 1px solid #edf0ee;
}

.order-row:last-child,
.rejected-item:last-child {
  border-bottom: 0;
}

.order-id {
  overflow-wrap: anywhere;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

.order-email {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-status {
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
}

.query-link {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.query-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rejected-item {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.2fr);
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #edf0ee;
}

.rejected-main strong,
.rejected-main span {
  display: block;
}

.rejected-main strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.rejected-main span {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.rejected-data {
  overflow: hidden;
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.query-grid {
  grid-template-columns: minmax(340px, 0.7fr) minmax(500px, 1.3fr);
}

.query-form,
.query-result {
  min-height: 370px;
}

.query-result .empty-state {
  min-height: 230px;
}

.order-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}

.detail-item {
  min-width: 0;
  padding: 15px 0;
  border-bottom: 1px solid #edf0ee;
}

.detail-item dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
}

.detail-item dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.detail-item.is-wide {
  grid-column: 1 / -1;
}

.site-footer {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto 26px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 11px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .access-strip {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .workspace-grid,
  .query-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    min-height: 420px;
  }

  .empty-state {
    min-height: 280px;
  }
}

@media (max-width: 620px) {
  .topbar-inner,
  .page-shell,
  .site-footer {
    width: min(100% - 24px, 1240px);
  }

  .topbar-inner {
    min-height: 68px;
  }

  .brand small,
  .service-state span:last-child {
    display: none;
  }

  .page-shell {
    margin-top: 16px;
  }

  .access-strip,
  .form-panel,
  .result-panel {
    padding: 18px;
  }

  .view-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .order-row {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .order-email {
    grid-column: 1 / 2;
    grid-row: 2;
  }

  .order-status {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  .query-link {
    grid-column: 2;
    grid-row: 2;
  }

  .rejected-item,
  .order-detail {
    grid-template-columns: 1fr;
  }

  .rejected-item {
    gap: 7px;
  }

  .detail-item.is-wide {
    grid-column: auto;
  }

  .site-footer {
    flex-direction: column;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
