:root {
  --bg: #f6f7f9;
  --card: #fff;
  --line: #e6e8eb;
  --text: #1f2329;
  --muted: #8a919b;
  --green: #1f9d55;
  --red: #e5484d;
  --blue: #2f6fed;
  --yellow: #d9a400;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 650; font-size: 15px; white-space: nowrap; }
.logo { margin-right: 4px; }

.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f2f4;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.chip b { color: var(--text); margin-left: 2px; }
.chip.alive { background: #e8f6ee; color: var(--green); }
.chip.alive b { color: var(--green); }
.chip.dead { background: #fdecec; color: var(--red); }
.chip.dead b { color: var(--red); }

.actions { margin-left: auto; display: flex; gap: 8px; }

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}
button:hover { border-color: #c9ccd1; background: #fafbfc; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover { background: #2459c9; }
button.ghost { background: transparent; }
button.small { padding: 4px 9px; font-size: 12px; }
button.danger { color: var(--red); }
button.danger:hover { border-color: var(--red); background: #fff6f6; }

main { padding: 20px; max-width: 1180px; margin: 0 auto; }

.banner {
  background: #fff6e6;
  border: 1px solid #ffd89b;
  color: #8a5a00;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.grid th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
}
.grid td { padding: 11px 14px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: #fafbfc; }
.grid .ops { text-align: right; white-space: nowrap; }
.grid .ops button { margin-left: 6px; }

.name { font-weight: 550; }
.sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.muted { color: var(--muted); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  background: #c9ccd1;
  vertical-align: 1px;
}
.dot.alive { background: var(--green); }
.dot.dead { background: var(--red); }
.dot.login { background: var(--blue); animation: pulse 1.2s infinite; }
.dot.checking { background: var(--yellow); animation: pulse 1.2s infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty code, .muted code { background: #f1f2f4; padding: 1px 5px; border-radius: 4px; }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 26, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.hidden { display: none !important; }

.modal {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.modal input, .modal textarea {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
.modal input:focus, .modal textarea:focus { outline: none; border-color: var(--blue); }
.modal textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.qr-modal { width: 340px; text-align: center; }.qr-box {
  margin: 12px auto;
  width: 240px;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.qr-box img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }
.status-line { color: var(--muted); font-size: 13px; min-height: 20px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  background: #1f2329;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 200;
  max-width: 90vw;
}
.toast.error { background: var(--red); }

.modal.wide { width: 780px; max-height: 90vh; overflow: auto; }
.modal.wide h4 { margin: 16px 0 8px; font-size: 13px; color: var(--text); }
.modal.wide h4:first-of-type { margin-top: 10px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.stat-item {
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.stat-item span {
  display: block;
  font-size: 11px;
  color: var(--muted);
}
.stat-item b { font-size: 16px; }

.pub-grid { display: grid; grid-template-columns: 1fr 220px; gap: 16px; }
@media (max-width: 720px) { .pub-grid { grid-template-columns: 1fr; } }
.pub-accounts {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
}
.pub-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.pub-item:hover { background: #fafbfc; }
.pub-item input { width: auto; margin: 0; }
.pub-limit { margin-left: auto; }
.pub-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.pub-table th, .pub-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.pub-table th { color: var(--muted); font-weight: 500; }

.pub-progress {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  max-height: 180px;
  overflow: auto;
}
.pub-progress b { display: block; margin-bottom: 6px; }
.pub-row { padding: 3px 0; }
.pub-row.failed { color: var(--red); }
.pub-row.ok { color: var(--green); }

.login-card {
  position: fixed;
  inset: 0;
  margin: auto;
  width: 320px;
  height: fit-content;
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
}
.login-card h2 {
  margin: 0 0 18px;
  font-size: 17px;
  text-align: center;
}
.login-card label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.login-card input {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--blue); }
.login-err { color: var(--red); font-size: 12px; margin: 0 0 10px; }
.wide-btn { width: 100%; padding: 10px; }
.me { font-size: 13px; align-self: center; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .actions { margin-left: 0; width: 100%; }
  .grid .sub, .grid th:nth-child(2), .grid td:nth-child(2) { display: none; }
}
