:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #647180;
  --line: #dce2e8;
  --line-strong: #c7d0d9;
  --accent: #1261a0;
  --accent-hover: #0d4f85;
  --accent-soft: #eaf3fa;
  --success: #177245;
  --success-soft: #eaf6ef;
  --warning: #8a5700;
  --warning-soft: #fff6df;
  --danger: #a12c2c;
  --danger-soft: #fff0f0;
  --shadow: 0 1px 2px rgba(19, 32, 45, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(960px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 700;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.main-content {
  padding-block: 30px 56px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line-strong);
}

.tab-button {
  min-height: 44px;
  padding: 9px 18px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-weight: 600;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-button:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(18, 97, 160, 0.2);
  outline-offset: 2px;
}

.tab-panel {
  padding: 26px 28px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.35;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.critical-notice {
  margin: -4px 0 22px;
  padding: 13px 15px;
  color: #8f1717;
  background: #fff0f0;
  border: 1px solid #e7a9a9;
  border-left: 5px solid #c92323;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.critical-notice strong {
  color: #b51212;
  font-size: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 124px;
  gap: 16px;
  align-items: end;
}

.history-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: #344252;
  font-weight: 600;
}

.field small {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
}

.field input::placeholder {
  color: #929da8;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 97, 160, 0.1);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}

.primary-button {
  padding: 9px 18px;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

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

.secondary-button {
  padding: 7px 14px;
  color: #344252;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover:not(:disabled) {
  color: var(--accent);
  background: #f8fafc;
  border-color: #9fb5c8;
}

.button-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.is-loading .button-spinner {
  display: block;
}

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

@media (prefers-reduced-motion: reduce) {
  .button-spinner {
    animation: none;
  }
}

.notice {
  margin-top: 20px;
  padding: 11px 13px;
  color: #2e506b;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.notice[data-tone="success"] {
  color: var(--success);
  background: var(--success-soft);
  border-left-color: var(--success);
}

.notice[data-tone="warning"] {
  color: var(--warning);
  background: var(--warning-soft);
  border-left-color: #c27a00;
}

.notice[data-tone="error"] {
  color: var(--danger);
  background: var(--danger-soft);
  border-left-color: var(--danger);
}

.order-result,
.history-result {
  margin-top: 26px;
  padding-top: 25px;
  border-top: 1px solid var(--line);
}

.result-header,
.delivery-heading,
.balance-row,
.history-order-head,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.result-header h2 {
  margin: 0;
  font-size: 19px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #c7ddeb;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge[data-tone="success"] {
  color: var(--success);
  background: var(--success-soft);
  border-color: #bddfc9;
}

.status-badge[data-tone="warning"] {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: #ead6a9;
}

.status-badge[data-tone="error"] {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efc7c7;
}

.result-message {
  margin: 13px 0 0;
  color: var(--muted);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 22px 0 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.detail-item {
  min-width: 0;
  margin: 0;
  padding: 13px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-item dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-item dd {
  margin: 3px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.delivery {
  margin-top: 24px;
}

.delivery-heading h3 {
  margin: 0;
  font-size: 16px;
}

.copy-all-button {
  min-height: 36px;
}

.delivery-list {
  margin-top: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.delivery-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 47px;
  padding: 8px 9px 8px 13px;
  background: #fbfcfd;
}

.delivery-item + .delivery-item {
  border-top: 1px solid var(--line);
}

.delivery-value {
  min-width: 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-button {
  min-width: 56px;
  min-height: 32px;
  padding: 4px 10px;
  color: var(--accent);
  background: transparent;
  border: 1px solid #b9cddd;
  border-radius: 5px;
  font-size: 12px;
}

.copy-button:hover {
  background: var(--accent-soft);
}

.balance-row {
  padding: 15px 17px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.balance-row div {
  display: grid;
  gap: 1px;
}

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

.balance-row strong {
  color: var(--success);
  font-size: 22px;
  line-height: 1.4;
}

.history-list {
  margin-top: 22px;
  border-top: 1px solid var(--line-strong);
}

.history-order {
  padding: 20px 2px;
  border-bottom: 1px solid var(--line);
}

.history-order-title {
  margin: 0;
  font-size: 16px;
}

.history-order-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.history-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.history-meta div {
  min-width: 0;
}

.history-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.history-meta strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.history-delivery {
  margin-top: 14px;
}

.history-delivery > p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
}

.empty-history {
  margin: 0;
  padding: 38px 16px;
  color: var(--muted);
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.pagination {
  justify-content: center;
  margin-top: 22px;
}

.pagination span {
  min-width: 92px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.pagination .secondary-button {
  min-height: 38px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 9px 15px;
  color: #fff;
  background: #25313d;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.2);
  transform: translateX(-50%);
  font-size: 13px;
}

@media (max-width: 760px) {
  .form-grid,
  .history-form {
    grid-template-columns: 1fr;
  }

  .field small {
    min-height: 0;
  }

  .primary-button {
    width: 100%;
  }

  .details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 24px, 960px);
  }

  .header-inner {
    min-height: 72px;
  }

  .subtitle {
    display: none;
  }

  .main-content {
    padding-block: 18px 32px;
  }

  .tabs {
    margin-bottom: 14px;
  }

  .tab-button {
    flex: 1 1 50%;
    padding-inline: 8px;
  }

  .tab-panel {
    padding: 20px 16px 24px;
  }

  .section-heading {
    margin-bottom: 19px;
  }

  .section-heading h1 {
    font-size: 20px;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .result-header,
  .history-order-head {
    align-items: flex-start;
  }

  .balance-row {
    align-items: flex-end;
  }

  .delivery-item {
    align-items: start;
  }

  .history-meta {
    gap: 12px 8px;
  }

  .toast {
    bottom: 14px;
  }
}
