:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --ok: #059669;
  --danger: #dc2626;
  --tron: #ef4444;
  --eth: #6366f1;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(37, 99, 235, 0.10), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(14, 165, 233, 0.08), transparent 50%),
    var(--bg);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 56px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  margin-bottom: 18px;
  position: sticky;
  top: 12px;
  z-index: 20;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
}

.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-tag { font-size: 12px; color: var(--muted); margin-top: 1px; }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.health {
  margin-left: auto;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}
.health.ok { color: var(--ok); border-color: #a7f3d0; background: #ecfdf5; }
.health.bad { color: var(--danger); border-color: #fecaca; background: #fef2f2; }

.panel { display: none; }
.panel.active { display: block; }

.hero-card,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 16px;
}

.hero-text h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.hero-text p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 720px;
}

.segment {
  display: inline-flex;
  padding: 4px;
  border-radius: 14px;
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  margin-bottom: 16px;
}

.segment-btn {
  border: 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-weight: 650;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  min-width: 120px;
}
.segment-btn.active {
  background: #fff;
  color: #1e3a8a;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.query-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.field.grow { flex: 1; min-width: 280px; }

input, select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  min-height: 44px;
}
input:focus, select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search {
  min-width: 220px;
}

.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}
.btn:hover { border-color: #94a3b8; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}
.btn.primary:hover { filter: brightness(1.03); }
.btn.xl { padding: 0 22px; }
.btn.danger {
  color: var(--danger);
  border-color: #fecaca;
  background: #fff;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.advanced-bar { margin-top: 14px; }
.advanced-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.progress {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
}
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #dbeafe;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width 0.35s ease;
}
.progress-text {
  margin-top: 8px;
  font-size: 13px;
  color: #1e40af;
  font-weight: 600;
}

.status {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 13px;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.error { color: var(--danger); }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.meta.soft { color: #94a3b8; }
.count { color: var(--muted); font-weight: 500; font-size: 14px; }

.addr-form {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  background: #fff;
}

.data-table tbody tr:hover td { background: #f8fbff; }
.data-table tfoot td {
  background: #f8fafc;
  font-weight: 700;
  border-bottom: 0;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}

.amount-cell {
  text-align: right;
}
.amount-main {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
}
.amount-sub {
  margin-top: 4px;
  font-size: 11px;
  color: #94a3b8;
  font-family: var(--mono);
}

.account-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.chain-logo {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}
.chain-logo.tron {
  background: #fee2e2;
  color: #b91c1c;
}
.chain-logo.ethereum {
  background: #e0e7ff;
  color: #4338ca;
}

.account-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.account-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.copy-btn {
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
}
.copy-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
  border-color: var(--line);
}
.copy-btn.copied {
  color: var(--ok);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: #475569;
}

.time {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.hidden { display: none !important; }

/* ========================================
   优化新增: Dark Mode / Toast / Stats / Animation
   ======================================== */

/* --- 暗色模式变量 --- */
body.dark {
  --bg: #0b1120;
  --surface: #1a2332;
  --surface-2: #1e293b;
  --ink: #e2e8f0;
  --muted: #8899b4;
  --line: #2a3a4e;
  --line-strong: #3b4f6a;
  --primary: #3b82f6;
  --primary-soft: #1e3a5f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --tron: #f87171;
  --eth: #818cf8;
}
body.dark .topbar { background: rgba(26, 35, 50, 0.92); border-color: var(--line); }
body.dark .tab.active { background: var(--surface); }
body.dark .data-table th { background: #1a2332; }
body.dark .data-table td { background: #1a2332; }
body.dark .data-table tbody tr:hover td { background: #1e293b; }
body.dark .data-table tfoot td { background: #121c2a; }
body.dark .segment { background: #1a2332; border-color: var(--line); }
body.dark .segment-btn.active { background: var(--surface-2); color: #93c5fd; }
body.dark .chip { background: #1a2332; }
body.dark .progress { background: #1a2332; border-color: var(--line); }
body.dark .progress-track { background: #1e293b; }
body.dark .progress-text { color: #93c5fd; }
body.dark input, body.dark select { background: #0f172a; border-color: var(--line-strong); color: var(--ink); }
body.dark .brand-mark { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
body.dark .health { background: var(--surface); }
body.dark .btn:not(.primary):not(.danger) { background: var(--surface); border-color: var(--line); color: var(--ink); }
body.dark .btn.danger { background: var(--surface); }
body.dark .copy-btn:hover { background: #1e293b; }
body.dark .stats-card { background: #1a2332; }
body.dark .stats-card.usdt { border-left-color: #26a17b; }
body.dark .stats-card.usdc { border-left-color: #2775ca; }
body.dark .stats-card.total { border-left-color: #3b82f6; }
body.dark .empty-state { background: #1a2332; }
body.dark .skeleton { background: linear-gradient(90deg, #1e293b 25%, #2a3a4e 50%, #1e293b 75%); background-size: 200% 100%; }
body.dark .toast { background: #1e293b; color: #e2e8f0; box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
body.dark .addr-input-valid { border-color: #059669; }
body.dark .addr-input-invalid { border-color: #dc2626; }

/* --- 暗色模式开关 --- */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  padding: 0;
  transition: all 0.25s ease;
  flex: 0 0 auto;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* --- 退出按钮 --- */
.btn-logout {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
  transition: all 0.2s ease;
}
.btn-logout:hover {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}
body.dark .btn-logout:hover {
  background: #2d1b1b;
  border-color: #4a2525;
}

/* --- Toast 通知系统 --- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 14px 20px;
  border-radius: 12px;
  background: #1e293b;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(16px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  border-left: 4px solid #64748b;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-left-color: #059669; }
.toast-error { border-left-color: #dc2626; }
.toast-info { border-left-color: #3b82f6; }
.toast-icon { font-size: 18px; flex: 0 0 auto; }

/* --- 统计摘要卡片 --- */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stats-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-left: 4px solid var(--line-strong);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.10);
}
.stats-card.usdt { border-left-color: #26a17b; }
.stats-card.usdc { border-left-color: #2775ca; }
.stats-card.total { border-left-color: var(--primary); }
.stats-card .stats-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.stats-card .stats-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stats-card .stats-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.stats-card .stats-sub .num-highlight { color: var(--positive); font-weight: 600; }
.stats-card .stats-skeleton {
  height: 32px;
  width: 60%;
  margin-bottom: 6px;
}

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 骨架屏 --- */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  height: 20px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- 空状态 --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state .empty-title { font-weight: 700; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.empty-state .empty-desc { font-size: 13px; color: var(--muted); max-width: 320px; line-height: 1.5; }

/* --- 行入场动画 --- */
@keyframes rowIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.data-table tbody tr {
  animation: rowIn 0.3s ease both;
}
.data-table tbody tr:nth-child(1) { animation-delay: 0.00s; }
.data-table tbody tr:nth-child(2) { animation-delay: 0.03s; }
.data-table tbody tr:nth-child(3) { animation-delay: 0.06s; }
.data-table tbody tr:nth-child(4) { animation-delay: 0.09s; }
.data-table tbody tr:nth-child(5) { animation-delay: 0.12s; }
.data-table tbody tr:nth-child(6) { animation-delay: 0.15s; }
.data-table tbody tr:nth-child(7) { animation-delay: 0.18s; }
.data-table tbody tr:nth-child(8) { animation-delay: 0.21s; }
.data-table tbody tr:nth-child(9) { animation-delay: 0.24s; }
.data-table tbody tr:nth-child(10) { animation-delay: 0.27s; }

/* --- 行斑马纹 --- */
.data-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}
body.dark .data-table tbody tr:nth-child(even) td {
  background: #151f2e;
}

/* --- 地址输入即时校验 --- */
.addr-input-valid { border-color: #059669 !important; }
.addr-input-invalid { border-color: #dc2626 !important; }

/* --- 复制 Tooltip --- */
.copy-btn {
  position: relative;
}
.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: #1e293b;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}
.copy-btn:hover .copy-tooltip { opacity: 1; transform: translateX(-50%) scale(1); }

/* --- 表格列宽优化 --- */
.data-table th.num, .data-table td.num {
  width: 140px;
  min-width: 120px;
}

/* --- 增强响应式 --- */
@media (max-width: 480px) {
  .stats-cards { grid-template-columns: 1fr; }
  .stats-card .stats-value { font-size: 22px; }
  .toast { max-width: calc(100vw - 48px); }
  .data-table tbody tr { animation: none; }
  #toast-container { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 860px) {
  .topbar {
    flex-wrap: wrap;
    position: static;
  }
  .health { margin-left: 0; width: 100%; text-align: center; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .query-row, .addr-form { flex-direction: column; align-items: stretch; }
  .field.grow { min-width: 0; }
  .btn.xl { width: 100%; }
}

/* ========================================
   登录叠加层
   ======================================== */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(37, 99, 235, 0.12), transparent 55%),
    radial-gradient(700px 360px at 90% 100%, rgba(14, 165, 233, 0.08), transparent 50%),
    #f3f6fb;
  padding: 20px;
}
body.dark .login-overlay {
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(700px 360px at 90% 100%, rgba(14, 165, 233, 0.05), transparent 50%),
    #0b1120;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.10);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  transition: background 0.3s ease;
}

.login-step { display: block; }
.login-step.hidden { display: none; }

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  color: #fff;
  background: linear-gradient(135deg, #1e3a5f, #2d5a87);
  margin-bottom: 14px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.login-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.login-field input {
  font-size: 16px;
  padding: 14px 16px;
  text-align: center;
  letter-spacing: 0.15em;
}
.login-field input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  margin-top: 4px;
}

.login-error {
  font-size: 13px;
  color: var(--danger);
  text-align: center;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
}
body.dark .login-error { background: #2d1b1b; border-color: #4a2525; }
.login-error.hidden { display: none; }

.login-2fa-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-container {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  margin-bottom: 12px;
}
.qr-container img {
  display: block;
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}
body.dark .qr-container { background: #fff; }

.qr-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 6px;
}

.qr-secret {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  word-break: break-all;
  user-select: all;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.qr-secret:hover { background: var(--surface); }

.login-footer {
  margin-top: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}
.login-version {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--line);
  font-weight: 600;
  font-size: 11px;
}
