:root {
  color-scheme: light;
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --ink: #202124;
  --muted: #6b7280;
  --line: #dfe3e8;
  --line-strong: #c8cdd3;
  --yellow: #ffd100;
  --yellow-hover: #f3c700;
  --green: #157347;
  --green-soft: #e9f6ef;
  --red: #c9362b;
  --red-soft: #fff0ee;
  --blue: #2366b1;
  --amber: #8b5e00;
  --amber-soft: #fff8db;
  --shadow: 0 8px 24px rgba(32, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(35, 102, 177, 0.24);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark,
.login-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid #e6bb00;
  border-radius: 6px;
  background: var(--yellow);
}

.brand-mark img,
.login-mark img {
  width: 22px;
  height: 22px;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

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

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.environment-badge {
  min-width: 68px;
  padding: 5px 9px;
  border: 1px solid #ebcf67;
  border-radius: 4px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.environment-badge.live {
  border-color: #9dcdb1;
  color: var(--green);
  background: var(--green-soft);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--surface-muted);
}

.icon-button img {
  width: 18px;
  height: 18px;
}

.icon-button.is-loading img {
  animation: spin 0.8s linear infinite;
}

.workspace {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.mode-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  margin-bottom: 16px;
  padding: 8px 13px;
  border: 1px solid #ead27a;
  border-radius: 5px;
  color: #6f5000;
  background: var(--amber-soft);
  font-weight: 600;
}

.mode-notice img {
  width: 18px;
  height: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 92px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 16px 22px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  overflow: hidden;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-time {
  font-size: 18px;
}

.status-online {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 18px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #20a162;
  box-shadow: 0 0 0 4px #e5f5ec;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.ready-panel {
  padding: 24px;
}

.section-heading,
.orders-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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

.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.section-icon {
  width: 27px;
  height: 27px;
}

label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  height: 42px;
  margin: 0 0 18px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover {
  border-color: #9da4ad;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 102, 177, 0.12);
  outline: 0;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 9px;
  margin-top: 4px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

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

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button img {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.button-primary {
  border-color: #e0b700;
  background: var(--yellow);
}

.button-primary:hover:not(:disabled) {
  background: var(--yellow-hover);
}

.button-secondary,
.button-quiet {
  border-color: var(--line-strong);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  background: var(--surface-muted);
}

.button-quiet {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 12px;
}

.operation-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 54px;
  margin-top: 18px;
  padding: 11px 12px;
  border: 1px solid #abd4bd;
  border-radius: 5px;
  background: var(--green-soft);
}

.operation-result.error {
  border-color: #e9b2ad;
  background: var(--red-soft);
}

.operation-result > img {
  width: 19px;
  height: 19px;
  margin-top: 1px;
}

.operation-result strong,
.operation-result span {
  display: block;
}

.operation-result strong {
  font-size: 13px;
}

.operation-result span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.orders-panel {
  min-width: 0;
  overflow: hidden;
}

.orders-toolbar {
  align-items: center;
  min-height: 78px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  min-height: 280px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 52px;
  padding: 9px 12px;
  border-bottom: 1px solid #eceff2;
  text-align: left;
  vertical-align: middle;
}

th {
  height: 42px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
}

td {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th:nth-child(1) { width: 24%; }
th:nth-child(2) { width: 12%; }
th:nth-child(3) { width: 18%; }
th:nth-child(4) { width: 18%; }
th:nth-child(5) { width: 9%; }
th:nth-child(6) { width: 19%; }

.order-id {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-width: 52px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: #4b5563;
  background: var(--surface-muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.status-badge.succeeded {
  border-color: #a8d3b9;
  color: var(--green);
  background: var(--green-soft);
}

.status-badge.pending,
.status-badge.processing {
  border-color: #e6cd70;
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.failed {
  border-color: #e2aaa5;
  color: var(--red);
  background: var(--red-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 280px;
  color: var(--muted);
}

.empty-state img {
  width: 27px;
  height: 27px;
  margin-bottom: 8px;
  opacity: 0.62;
}

.table-wrap:not(.is-empty) .empty-state {
  display: none;
}

.table-wrap.is-empty table {
  display: none;
}

.mobile-orders {
  display: none;
}

.login-view {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
  padding: 28px 18px 64px;
  background: var(--bg);
}

.login-dialog {
  width: min(380px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
}

.login-dialog h1 {
  margin-bottom: 23px;
  font-size: 21px;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 44px;
}

.password-field button {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.password-field button:hover {
  background: var(--surface-muted);
}

.password-field img {
  width: 18px;
  height: 18px;
}

.login-error {
  margin: -8px 0 14px;
  color: var(--red);
  font-size: 12px;
}

.login-button {
  width: 100%;
  margin-top: 2px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid #a8d3b9;
  border-radius: 5px;
  color: #125f3b;
  background: var(--green-soft);
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.error {
  border-color: #e2aaa5;
  color: var(--red);
  background: var(--red-soft);
}

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

@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

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

  .ready-panel {
    max-width: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 58px;
    padding: 0 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

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

  .brand small {
    display: none;
  }

  .environment-badge {
    min-width: 0;
    padding: 4px 6px;
    font-size: 10px;
  }

  .icon-button {
    width: 32px;
    height: 32px;
  }

  .workspace {
    width: calc(100% - 24px);
    padding-top: 12px;
  }

  .mode-notice {
    align-items: flex-start;
    font-size: 12px;
  }

  .metrics {
    min-height: 0;
    margin-bottom: 12px;
  }

  .metric {
    min-height: 75px;
    padding: 12px 14px;
  }

  .metric-value {
    font-size: 18px;
  }

  .metric-time,
  .status-online {
    font-size: 15px;
  }

  .content-grid {
    gap: 12px;
  }

  .ready-panel {
    padding: 18px;
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .orders-toolbar {
    min-height: 72px;
    padding: 14px 16px;
  }

  .button-quiet {
    width: auto;
  }

  .table-wrap {
    display: none;
  }

  .mobile-orders {
    display: grid;
    gap: 0;
  }

  .mobile-order {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
  }

  .mobile-order:last-child {
    border-bottom: 0;
  }

  .mobile-order-head,
  .mobile-order-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-order-meta {
    margin-top: 9px;
    color: var(--muted);
    font-size: 11px;
  }

  .mobile-empty {
    display: grid;
    min-height: 160px;
    place-items: center;
    color: var(--muted);
  }

  .login-view {
    min-height: calc(100vh - 58px);
    padding-top: 18px;
    place-items: start center;
  }

  .login-dialog {
    padding: 24px 20px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

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