:root {
  --bg: #080b10;
  --bg-soft: #0d1117;
  --panel: #11161f;
  --panel-2: #161c27;
  --border: #1f2733;
  --border-soft: #19202b;
  --text: #e8edf5;
  --muted: #7d8a9c;
  --dim: #55606f;
  --brand: #f0b90b;
  --brand-dim: #8a6a06;
  --green: #16c784;
  --red: #ea3943;
  --blue: #3b82f6;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(240, 185, 11, 0.09), transparent 60%),
    radial-gradient(700px 420px at 95% 0%, rgba(59, 130, 246, 0.06), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- 登录 ---------- */
.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 34px 30px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.logo-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), #c99500);
  color: #14100a;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 15px;
}

.auth-card h1 { font-size: 20px; font-weight: 650; margin-bottom: 6px; }
.auth-card p.sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; line-height: 1.6; }

.auth-card .hintbox {
  background: rgba(240, 185, 11, 0.07);
  border: 1px solid rgba(240, 185, 11, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: #d7b34a;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ---------- 布局 ---------- */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 218px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border-soft);
  background: rgba(10, 13, 18, 0.75);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  font-weight: 700;
  font-size: 14.5px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.side-logo small {
  display: block;
  font-weight: 500;
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: 0.14s;
  user-select: none;
}

.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: rgba(240, 185, 11, 0.1);
  border-color: rgba(240, 185, 11, 0.22);
  color: var(--brand);
  font-weight: 600;
}

.nav-item .ic { width: 17px; text-align: center; opacity: 0.9; font-size: 14px; }

.side-foot { border-top: 1px solid var(--border-soft); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.side-foot .chain-tag {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--muted);
  font-family: var(--mono);
  padding: 0 4px;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); box-shadow: 0 0 8px var(--red); }

.main { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}

.topbar h2 { font-size: 20px; font-weight: 650; letter-spacing: 0.2px; }
.topbar .desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.topstats { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
  font-size: 11.5px; color: var(--muted); font-family: var(--mono);
}
.chip b { color: var(--text); font-weight: 600; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 14px; }
.grid.k2 { grid-template-columns: repeat(2, 1fr); }
.grid.k3 { grid-template-columns: repeat(3, 1fr); }
.grid.k4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.card.tight { padding: 14px 16px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 11.5px; color: var(--dim); margin-top: 2px; }

.stat-label { font-size: 11.5px; color: var(--muted); letter-spacing: 0.3px; }
.stat-value { font-size: 24px; font-weight: 680; font-family: var(--mono); margin-top: 6px; letter-spacing: -0.5px; }
.stat-value small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat-foot { font-size: 11.5px; color: var(--dim); margin-top: 6px; font-family: var(--mono); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field label {
  display: block; font-size: 12px; color: var(--muted);
  margin-bottom: 6px; font-weight: 500;
}
.field .tip { font-size: 11px; color: var(--dim); margin-top: 5px; line-height: 1.5; }

input, select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-dim);
  background: #0b1017;
  box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.08);
}
input::placeholder, textarea::placeholder { color: #3d4653; }
textarea { resize: vertical; min-height: 76px; font-family: var(--mono); font-size: 12px; line-height: 1.6; }
select { cursor: pointer; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); cursor: pointer; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #1c2431; border-color: #2a3444; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--brand); border-color: var(--brand); color: #14100a; font-weight: 680;
}
.btn.primary:hover:not(:disabled) { background: #ffc61a; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(234, 57, 67, 0.3); background: rgba(234, 57, 67, 0.07); }
.btn.danger:hover:not(:disabled) { background: rgba(234, 57, 67, 0.14); }
.btn.sm { padding: 5px 9px; font-size: 11.5px; border-radius: 7px; }
.btn.block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 999px; background: #232c39;
  position: relative; transition: 0.18s; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px; border-radius: 50%; background: #7d8a9c; transition: 0.18s;
}
.switch input:checked + .track { background: rgba(22, 199, 132, 0.28); }
.switch input:checked + .track::after { left: 20px; background: var(--green); }
.switch .lbl { font-size: 12.5px; color: var(--muted); }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--border-soft); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; padding: 9px 12px; color: var(--muted); font-weight: 550;
  background: var(--bg-soft); border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px; white-space: nowrap; position: sticky; top: 0;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.017); }
td.mono, .mono { font-family: var(--mono); }
.addr { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.3px;
}
.tag.buy { background: rgba(22, 199, 132, 0.13); color: var(--green); }
.tag.sell { background: rgba(234, 57, 67, 0.13); color: var(--red); }
.tag.pending { background: rgba(240, 185, 11, 0.13); color: var(--brand); }
.tag.failed { background: rgba(234, 57, 67, 0.13); color: var(--red); }
.tag.ok { background: rgba(22, 199, 132, 0.13); color: var(--green); }
.tag.gray { background: rgba(125, 138, 156, 0.13); color: var(--muted); }

.empty {
  padding: 34px 20px; text-align: center; color: var(--dim); font-size: 12.5px;
}

.log-line {
  display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 12px; line-height: 1.5;
}
.log-line:last-child { border-bottom: none; }
.log-line .t { color: var(--dim); font-family: var(--mono); font-size: 10.5px; flex: none; padding-top: 2px; }
.log-line.info .msg { color: var(--muted); }
.log-line.success .msg { color: var(--green); }
.log-line.warn .msg { color: var(--brand); }
.log-line.error .msg { color: var(--red); }

/* ---------- Toast / 弹窗 ---------- */
#toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 9px; max-width: min(380px, calc(100vw - 32px));
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.2s ease;
  line-height: 1.5;
  word-break: break-word;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(3, 5, 8, 0.78);
  backdrop-filter: blur(3px); z-index: 500;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 88vh; overflow: auto; padding: 22px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}
.modal h3 { font-size: 16px; margin-bottom: 4px; }
.modal .mdesc { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.code-box {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; font-family: var(--mono); font-size: 12px;
  color: var(--brand); word-break: break-all; line-height: 1.7;
  max-height: 220px; overflow: auto;
}

.spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2); border-top-color: #14100a;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; font-size: 12.5px;
  margin-bottom: 14px; line-height: 1.55;
}
.banner.warn { background: rgba(240, 185, 11, 0.08); border: 1px solid rgba(240, 185, 11, 0.22); color: #ddb84a; }
.banner.err { background: rgba(234, 57, 67, 0.08); border: 1px solid rgba(234, 57, 67, 0.22); color: #f0797f; }
.banner.info { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2); color: #93b8f5; }

.hr { height: 1px; background: var(--border-soft); margin: 16px 0; }

.flex { display: flex; align-items: center; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 11.5px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.green { color: var(--green); }
.red { color: var(--red); }
.brand { color: var(--brand); }

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pill {
  padding: 5px 11px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--border);
  cursor: pointer; color: var(--muted); transition: 0.14s;
}
.pill:hover { color: var(--text); border-color: #2a3444; }
.pill.on { background: rgba(240, 185, 11, 0.12); border-color: rgba(240, 185, 11, 0.3); color: var(--brand); }

.stat-mini { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-mini > div { min-width: 88px; }

@media (max-width: 1100px) {
  .grid.k4 { grid-template-columns: repeat(2, 1fr); }
  .grid.k3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  #toasts { bottom: 82px; right: 16px; left: 16px; max-width: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
    flex-direction: row; padding: 8px 10px; border-right: none;
    border-top: 1px solid var(--border); z-index: 100;
    background: rgba(8, 11, 16, 0.96);
  }
  .side-logo, .side-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 10px; white-space: nowrap; }
  .nav-item .ic { font-size: 15px; }
  .main { padding: 16px 14px 96px; }
  .grid.k2, .grid.k3, .grid.k4, .row2, .row3 { grid-template-columns: 1fr; }
  .topbar h2 { font-size: 17px; }
}
