/* ==================== 全局重置 ==================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0f1420;
  --bg-card: #181f2e;
  --bg-elevated: #222a3d;
  --border: #2c354a;
  --text: #e6e8ef;
  --text-dim: #8b93a7;
  --text-muted: #5c6578;
  --primary: #f0b90b; /* BSC 币安黄 */
  --primary-dark: #c99a08;
  --danger: #e84142;
  --danger-dark: #b83334;
  --success: #14b866;
  --warning: #ffa500;
  --info: #4f8cff;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* 防止页面被横向拉宽（在某些 DApp 浏览器里容易出现） */
body {
  overflow-x: hidden;
}

/* ==================== 顶部安全横幅 ==================== */
.safety-banner {
  background: linear-gradient(90deg, #5c1d1d 0%, #3a1818 100%);
  color: #ffcaca;
  padding: 10px 16px;
  border-bottom: 2px solid var(--danger);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.safety-banner strong {
  color: #ff8a8a;
}

/* ==================== 容器 ==================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.page-header {
  text-align: center;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  background: linear-gradient(90deg, var(--primary), #ffd900);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.page-header .subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

/* ==================== 步骤卡片 ==================== */
.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: opacity 0.3s;
}

@media (min-width: 721px) {
  .step-card {
    padding: 24px;
  }
}

.step-card.hidden {
  display: none;
}

.step-card h2 {
  margin: 0 0 20px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: #000;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
}

.step-card .desc {
  color: var(--text-dim);
  margin: 0 0 16px;
  font-size: 13px;
}

/* ==================== 表单 ==================== */
.form-row {
  margin-bottom: 16px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 16px;
}

@media (max-width: 720px) {
  .form-row.two-col,
  .form-row.three-col {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* iOS Safari 在 <16px 时会自动缩放页面，所以强制 16px */
  outline: none;
  transition: border-color 0.15s;
  min-height: 44px; /* 触控友好 */
}

@media (min-width: 721px) {
  input[type="text"],
  input[type="number"],
  input[type="password"],
  textarea,
  select {
    font-size: 14px;
    padding: 10px 12px;
  }
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
}

input[type="file"] {
  color: var(--text-dim);
}

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

.input-with-toggle textarea {
  -webkit-text-security: disc;
  padding-right: 48px;
}

.input-with-toggle.reveal textarea {
  -webkit-text-security: none;
}

.toggle-btn {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  border-radius: 6px;
}

.toggle-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.hint.error {
  color: var(--danger);
}

.hint.success {
  color: var(--success);
}

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  min-height: 44px; /* 触控友好 */
  -webkit-tap-highlight-color: transparent;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-dark);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  .actions {
    flex-direction: column;
  }
  .actions .btn {
    width: 100%;
  }
}


/* ==================== 代币快捷按钮 ==================== */
.quick-tokens {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

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

.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 36px;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* ==================== 派生地址表 ==================== */
.derived-table-wrap,
.plan-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.derived-table,
.plan-table,
.recipients-form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.derived-table thead,
.plan-table thead,
.recipients-form-table thead {
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 1;
}

.derived-table th,
.plan-table th,
.recipients-form-table th {
  text-align: left;
  padding: 10px 10px;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
}

.derived-table td,
.plan-table td,
.recipients-form-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

/* 手机端：派生地址列表改成卡片式列表，避免横向滚动 */
@media (max-width: 720px) {
  .derived-table thead {
    display: none;
  }
  .derived-table tbody tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .derived-table tbody td {
    padding: 2px 0;
    border: none;
    font-size: 13px;
  }
  .derived-table tbody td:nth-child(1) {
    grid-row: 1 / span 3;
    align-self: center;
  }
  .derived-table tbody td:nth-child(1) input {
    width: 22px;
    height: 22px;
  }
  .derived-table tbody td:nth-child(2) {
    font-weight: 600;
    color: var(--primary);
  }
  .derived-table tbody td:nth-child(2)::before {
    content: "序号 ";
    color: var(--text-muted);
    font-weight: normal;
  }
  .derived-table tbody td:nth-child(3) {
    word-break: break-all;
  }
  .derived-table tbody td:nth-child(4)::before {
    content: "BNB: ";
    color: var(--text-muted);
  }
  .derived-table tbody td:nth-child(5)::before {
    content: "代币: ";
    color: var(--text-muted);
  }
  .derived-table tfoot tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    padding: 12px;
  }
  .derived-table tfoot td:nth-child(1) {
    grid-column: 1 / -1;
    text-align: left !important;
  }

  /* 预览表也卡片化 */
  .plan-table thead {
    display: none;
  }
  .plan-table tbody tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .plan-table tbody td {
    padding: 2px 0;
    border: none;
    font-size: 13px;
  }
  .plan-table tbody td:nth-child(1) {
    grid-row: 1 / span 7;
    align-self: start;
    font-weight: 700;
    color: var(--primary);
  }
  .plan-table tbody td:nth-child(2)::before { content: "从: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(3)::before { content: "到: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(4)::before { content: "数量: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(5)::before { content: "单位: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(6)::before { content: "gas: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(7)::before { content: "状态: "; color: var(--text-muted); }
  .plan-table tbody td:nth-child(8)::before { content: "TX: "; color: var(--text-muted); }
}

.derived-table tfoot td {
  font-weight: 600;
  color: var(--primary);
  border-top: 2px solid var(--border);
  background: var(--bg-elevated);
}

.derived-table tbody tr:hover,
.plan-table tbody tr:hover {
  background: rgba(240, 185, 11, 0.05);
}

.recipients-form-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.recipients-form-table input {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 8px;
  min-height: 36px;
}

.recipients-form-table input:focus {
  border-color: var(--primary);
  background: var(--bg);
}

.recipients-form-table .row-remove {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 20px;
  padding: 4px 10px;
  min-width: 36px;
  min-height: 36px;
}

/* 手机端：收款地址表格改成卡片式 */
@media (max-width: 720px) {
  .recipients-form-table thead {
    display: none;
  }
  .recipients-form-table tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "num addr remove"
      "num cap  remove";
    gap: 6px 10px;
    padding: 10px;
    border-bottom: 1px solid var(--border);
  }
  .recipients-form-table tbody td {
    padding: 0;
    border: none;
  }
  .recipients-form-table tbody td:nth-child(1) {
    grid-area: num;
    align-self: center;
    font-weight: 600;
    color: var(--primary);
    min-width: 24px;
  }
  .recipients-form-table tbody td:nth-child(2) { grid-area: addr; }
  .recipients-form-table tbody td:nth-child(3) { grid-area: cap; }
  .recipients-form-table tbody td:nth-child(4) {
    grid-area: remove;
    align-self: center;
  }
  .recipients-form-table tbody input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    font-size: 14px;
  }
}

/* ==================== Tab ==================== */
.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

pre.sample {
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0;
  border: 1px solid var(--border);
}

code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary);
}

/* ==================== 预览汇总 ==================== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 720px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .summary-item {
    padding: 10px;
  }
  .summary-value {
    font-size: 16px;
  }
  .summary-label {
    font-size: 11px;
  }
}

.summary-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.summary-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* ==================== 交易状态徽章 ==================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-pending {
  background: rgba(255, 165, 0, 0.15);
  color: var(--warning);
}

.badge-sending {
  background: rgba(79, 140, 255, 0.15);
  color: var(--info);
}

.badge-success {
  background: rgba(20, 184, 102, 0.15);
  color: var(--success);
}

.badge-failed {
  background: rgba(232, 65, 66, 0.15);
  color: var(--danger);
}

.plan-table a {
  color: var(--info);
  text-decoration: none;
}

.plan-table a:hover {
  text-decoration: underline;
}

/* ==================== 警告条 ==================== */
.warnings {
  margin: 16px 0;
}

.warning-item {
  background: rgba(232, 65, 66, 0.08);
  border: 1px solid rgba(232, 65, 66, 0.25);
  color: #ffb3b3;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 8px;
}

.warning-item.info {
  background: rgba(79, 140, 255, 0.08);
  border-color: rgba(79, 140, 255, 0.25);
  color: #a8c7ff;
}

/* ==================== 遮罩弹窗 ==================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-mask.hidden {
  display: none;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: 92%;
  max-width: 500px;
  box-shadow: var(--shadow);
  max-height: 85vh;
  overflow-y: auto;
}

@media (max-width: 720px) {
  .modal-actions {
    flex-direction: column;
  }
  .modal-actions .btn {
    width: 100%;
  }
}

.modal h3 {
  margin: 0 0 12px;
}

.modal p {
  margin: 0 0 20px;
  color: var(--text-dim);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ==================== 页脚 ==================== */
.page-footer {
  margin-top: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.page-footer code {
  background: transparent;
  color: var(--text-dim);
}

/* ==================== 通用 ==================== */
.hidden {
  display: none !important;
}

.address-short {
  font-family: ui-monospace, monospace;
}
