:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --text: #1a1d26;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #f0b90b;
  --brand-dark: #0d1117;
  --panel: #ffffff;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --soft: #f9fafb;
  --gradient-start: #f0b90b;
  --gradient-end: #fbbf24;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 10px;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #f7f8fb 0%, #eef1f6 100%);
  color: var(--text);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

/* ========== 顶部导航栏 ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(240, 185, 11, 0.3);
  transition: transform 0.2s ease;
  display: block;
}

.brand-logo:hover {
  transform: scale(1.05);
}

.brand-logo rect {
  transition: filter 0.2s ease;
}

.brand-logo:hover rect {
  filter: brightness(1.05);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

h1 {
  margin: 0;
  font-size: 28px;
  background: linear-gradient(135deg, var(--text) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.subtitle {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin-top: 4px;
}

/* ========== 钱包区域 ========== */
.wallet-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.status-pill[data-tone="ready"] {
  background: linear-gradient(135deg, #e8f7f1 0%, #d4f0e3 100%);
  border-color: #b9e6d3;
  color: var(--ok);
}

.status-pill[data-tone="pending"] {
  background: linear-gradient(135deg, #fff7db 0%, #fff0c2 100%);
  border-color: #f4dc8b;
  color: var(--warn);
}

.status-pill[data-tone="warning"] {
  background: linear-gradient(135deg, #fff7db 0%, #fff0c2 100%);
  border-color: #f4dc8b;
  color: var(--warn);
}

.status-pill[data-tone="error"] {
  background: linear-gradient(135deg, #fff1f1 0%, #ffe0e0 100%);
  border-color: #f7c6c6;
  color: var(--danger);
}

/* ========== 市场区域 ========== */
.market {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

/* ========== 面板样式 ========== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-head h2 {
  font-size: 20px;
  font-weight: 700;
}

.panel-head .fee-badge {
  background: linear-gradient(135deg, #0f9f6e 0%, #0c8a5f 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(15, 159, 110, 0.25);
  white-space: nowrap;
}

.book-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ========== 输入框样式 ========== */
label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label small {
  min-height: 16px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.16);
}

input[readonly] {
  background: var(--soft);
  color: var(--muted);
  cursor: not-allowed;
}

/* ========== 表单布局 ========== */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ========== 费用明细 ========== */
.gas-note {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: 10px;
  color: #166534;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 16px;
  padding: 14px;
  line-height: 1.6;
}

.gas-note strong {
  display: block;
  margin-bottom: 6px;
}

.quote-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 4px 0 16px;
}

.quote-box.three {
  grid-template-columns: repeat(3, 1fr);
}

.quote-box div {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--soft);
  transition: all 0.2s ease;
}

.quote-box div:hover {
  border-color: var(--brand);
  background: #fefcf5;
}

.quote-box div.highlight {
  border-color: var(--brand);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.quote-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.quote-box strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

/* ========== 按钮样式 ========== */
button {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

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

.primary {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: #111;
  box-shadow: var(--shadow-sm);
}

.primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
}

.ghost {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--line);
}

.wide {
  width: 100%;
}

/* ========== 步骤指示 ========== */
.step-list {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all 0.2s ease;
}

.step b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #dfe4ec;
  color: var(--text);
  font-size: 13px;
  transition: all 0.2s ease;
}

.step.active {
  background: linear-gradient(135deg, #fff7db 0%, #fff0c2 100%);
  border-color: #f4dc8b;
  color: var(--warn);
}

.step.active b {
  background: var(--warn);
  color: #fff;
}

.step.done {
  background: linear-gradient(135deg, #e8f7f1 0%, #d4f0e3 100%);
  border-color: #b9e6d3;
  color: var(--ok);
}

.step.done b {
  background: var(--ok);
  color: #fff;
}

.step.error {
  background: linear-gradient(135deg, #fff1f1 0%, #ffe0e0 100%);
  border-color: #f7c6c6;
  color: var(--danger);
}

.step.error b {
  background: var(--danger);
  color: #fff;
}

/* ========== 加载动画 ========== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}

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

button.refreshing .spinner {
  opacity: 1;
  transform: scale(1);
}

button.refreshing .label {
  opacity: 0.7;
}

/* ========== Tab 切换（固定左右两列，不受 H5 响应式影响） ========== */
.order-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: var(--soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0;
  border-radius: 0;
  transform: none;
}

.tab-btn:hover:not(.active) {
  color: var(--text);
  background: #fff;
  border-color: var(--brand);
}

.tab-btn.active {
  color: var(--brand);
  background: linear-gradient(135deg, #fff7db 0%, #fff0c2 100%);
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(240, 185, 11, 0.2);
}

.tab-btn .tab-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  text-align: left;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  background: var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}

.tab-btn.active .tab-count {
  background: var(--brand);
  color: #111;
}

/* ========== 全部显示 / 收起订单按钮 ========== */
.show-more-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.show-more-btn {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.show-more-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ========== 订单卡片 ========== */
.orders {
  display: grid;
  gap: 12px;
}

.empty {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
  background: var(--soft);
  font-size: 15px;
  line-height: 1.6;
}

.order {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel);
  transition: all 0.2s ease;
}

.order:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}

.order.is-filled {
  background: linear-gradient(135deg, #f8fbfa 0%, #eef5f1 100%);
  border-color: #b9e6d3;
  opacity: 0.85;
}

.order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.order-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.order-badge {
  background: var(--brand);
  color: #111;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.order-details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--soft);
  border-radius: var(--radius-sm);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.detail-value {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.order-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover:not(:disabled) {
  background: #e5e7eb;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* ========== 交易流程 ========== */
.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.flow-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.flow-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.flow-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.flow strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.flow span {
  display: block;
  margin-top: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== 页脚 ========== */
.footer {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.footer-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

.footer-section p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 12px;
}

.contract-info {
  margin-bottom: 8px;
}

.contract-info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.contract-info strong {
  color: var(--text);
  font-size: 14px;
}

.safety-tips {
  list-style: none;
  padding: 0;
  margin: 0;
}

.safety-tips li {
  color: var(--ok);
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 600;
}

.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ========== Toast 通知 ========== */
.toast-host {
  bottom: 18px;
  display: grid;
  gap: 10px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  width: min(360px, calc(100% - 36px));
  z-index: 20;
}

.toast {
  background: #1a1d26;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  padding: 14px 16px;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: linear-gradient(135deg, var(--ok) 0%, #059669 100%);
}

.toast.warning {
  background: linear-gradient(135deg, var(--warn) 0%, #d97706 100%);
}

.toast.error {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

/* ========== 响应式设计 ========== */
@media (max-width: 860px) {
  .topbar,
  .market,
  .flow,
  .footer-content {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .wallet-area {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .split,
  .triple,
  .quote-box,
  .quote-box.three,
  .order-details {
    grid-template-columns: 1fr;
  }

  .brand {
    flex-direction: column;
    text-align: center;
  }

  h1 {
    font-size: 24px;
  }
}

/* ========== 工具类 ========== */
.hidden {
  display: none;
}

/* ========== 工具提示 ========== */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.tooltip:hover::after {
  opacity: 1;
}
