:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e4e7ec;
  --line-soft: #eef0f3;
  --text: #1a1d23;
  --muted: #667085;
  --faint: #98a2b3;
  --accent: #f0b90b;
  --accent-ink: #1a1400;
  --accent-soft: #fff7d6;
  --ok: #12805c;
  --ok-bg: #e3f6ee;
  --warn: #a15c07;
  --warn-bg: #fff2d9;
  --err: #b42318;
  --err-bg: #fde8e6;
  --info: #175cd3;
  --info-bg: #e6efff;
  --idle: #475467;
  --idle-bg: #eef0f3;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  height: 56px; padding: 0 28px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 14px; height: 14px; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tab {
  position: relative; display: flex; align-items: center; padding: 0 14px;
  border: 0; background: none; color: var(--muted); cursor: pointer; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.spacer { flex: 1; }
.main { max-width: 1320px; margin: 0 auto; padding: 24px 28px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 20px; font-weight: 650; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: #f9fafb; border-color: #d0d5dd; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #e3ae08; border-color: #e3ae08; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-bg); border-color: #f4b8b2; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--idle-bg); }
.input, .select, .textarea {
  height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); outline: none; min-width: 0;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; width: 100%; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 185, 11, .18); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--faint); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
input[type=checkbox] { width: 15px; height: 15px; accent-color: #d9a406; cursor: pointer; }

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

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.err { color: var(--err); background: var(--err-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.idle { color: var(--idle); background: var(--idle-bg); }

/* ---------- stats ---------- */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
  display: flex; flex-direction: column; min-width: 112px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); cursor: pointer; text-align: left;
}
.stat:hover { border-color: #d0d5dd; }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 185, 11, .16); }
.stat .n { font-size: 22px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none;
  padding: 9px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.remark { font-weight: 600; cursor: text; border-radius: 5px; padding: 1px 4px; margin: -1px -4px; }
.remark:hover { background: var(--idle-bg); }
.remark-input { height: 28px; width: 160px; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.addr { cursor: pointer; }
.addr:hover { color: var(--info); }
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  background: var(--accent-soft); border-bottom: 1px solid #f3dd8a;
}

/* ---------- batch ---------- */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.batch-list { display: flex; flex-direction: column; }
.batch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px;
  border: 0; border-top: 1px solid var(--line-soft); background: none; text-align: left; cursor: pointer;
}
.batch-item:first-child { border-top: 0; }
.batch-item:hover { background: #fafbfc; }
.batch-item.active { background: var(--accent-soft); }
.progress { height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 6px; width: 120px; }
.progress > i { display: block; height: 100%; background: var(--ok); }
.preview { padding: 10px 12px; background: #fafbfc; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; }
.preview b { color: var(--text); }

.qr-grid { display: grid; gap: 12px; padding: 16px; }
.qr-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.qr-cell:not(.done) { cursor: zoom-in; }
.qr-cell canvas { width: 100%; height: auto; aspect-ratio: 1; image-rendering: pixelated; display: block; }
.qr-cell .name { font-weight: 650; font-size: 14px; }
.qr-cell .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.qr-cell .pair { font-family: var(--mono); letter-spacing: .5px; color: var(--text); }
.qr-cell.done { background: #f6fdf9; border-color: #b7e3cd; }
.qr-cell.dead canvas { opacity: .12; }
.qr-overlay {
  position: absolute; left: 8px; right: 8px; top: 10px; aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; font-weight: 600; border-radius: 6px;
}
.qr-overlay.done { color: var(--ok); }
.qr-overlay.scan { background: rgba(255, 255, 255, .86); color: var(--info); }
.qr-overlay.dead { color: var(--muted); }
.qr-overlay .big { font-size: 34px; line-height: 1; }
.cd { font-variant-numeric: tabular-nums; }
.cd.low { color: var(--err); font-weight: 600; }

/* ---------- misc ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); background: var(--card); border-radius: 14px; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
.modal-h { padding: 18px 20px 6px; font-size: 16px; font-weight: 650; }
.modal-b { padding: 6px 20px 16px; }
.modal-f { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.secret-box { padding: 10px 12px; background: #0f1419; color: #e7ecf3; border-radius: 8px; font-family: var(--mono); font-size: 12.5px; word-break: break-all; margin: 6px 0; }
.callout { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 13px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 9px; background: #101828; color: #fff; box-shadow: 0 8px 24px rgba(16, 24, 40, .25); max-width: 380px; animation: up .18s ease-out; }
.toast.err { background: #912018; }
@keyframes up { from { transform: translateY(6px); opacity: 0; } }

.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(400px, 100%); padding: 28px; }
.auth-card h1 { font-size: 20px; margin: 14px 0 4px; }

pre.code {
  margin: 8px 0; padding: 14px 16px; background: #0f1419; color: #dbe3ee; border-radius: 10px; overflow-x: auto;
  font: 12.5px/1.6 var(--mono);
}
.doc h3 { margin: 22px 0 6px; font-size: 15px; }
.doc p, .doc li { color: #344054; }
.doc code:not(pre code) { font-family: var(--mono); font-size: 12.5px; background: var(--idle-bg); padding: 1px 5px; border-radius: 4px; }
.doc table td, .doc table th { padding: 7px 12px; }
.tag { display: inline-block; padding: 1px 8px; margin: 1px 3px 1px 0; border-radius: 6px; background: var(--idle-bg); font-size: 12px; color: var(--idle); }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; gap: 14px; overflow-x: auto; }
  .main { padding: 16px 14px 60px; }
}

/* single-code lightbox */
.lb { position: fixed; inset: 0; z-index: 80; background: #fff; display: grid; place-items: center; }
.lb-body { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.lb-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.lb-name { font-size: 26px; font-weight: 700; }
.lb-qrbox { position: relative; border: 1px solid var(--border, #e4e7ec); border-radius: 12px; padding: 6px; background: #fff; }
.lb-qrbox canvas { display: block; image-rendering: pixelated; }
.lb-qrbox .qr-overlay { border-radius: 12px; text-align: center; font-size: 18px; }
.lb-pair { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: 3px; }
.lb-pair span { font-family: inherit; font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-right: 6px; }
.lb-cd { font-size: 15px; color: var(--muted); }
.lb-close { position: absolute; top: 14px; right: 18px; width: 44px; height: 44px; border: 0; background: #f2f4f7; border-radius: 22px; font-size: 28px; line-height: 1; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 56px; height: 96px; border: 0; background: #f2f4f7; border-radius: 12px; font-size: 44px; cursor: pointer; color: #344054; }
.lb-nav.prev { left: 18px; }
.lb-nav.next { right: 18px; }
.lb-nav:hover, .lb-close:hover { background: #e4e7ec; }
@media (max-width: 640px) { .lb-nav { width: 44px; height: 76px; } .lb-pair { font-size: 32px; } }
