:root {
  --green: #25d366;
  --green-dark: #128c42;
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

#app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.auth-wrap {
  max-width: 420px;
  margin: 10vh auto 0;
}

.auth-card,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 26px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 6px 0 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

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

.field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--text);
}

.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  background: transparent;
  color: var(--text);
}

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

.btn.primary:hover {
  background: #1ebe5d;
}

.btn.ghost {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
}

.btn.ghost:hover {
  background: #f9fafb;
}

.btn.danger {
  color: var(--danger);
  border-color: #fecaca;
}

.btn.small {
  padding: 5px 9px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.error-text {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
  margin-top: 8px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.topbar .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  padding: 18px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
}

.card-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.inline-form .field {
  margin-bottom: 0;
  min-width: 200px;
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  background: #fafbfc;
}

tr:last-child td {
  border-bottom: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #e8f8ee;
  color: var(--green-dark);
}

.tag.off {
  background: #fef2f2;
  color: var(--danger);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
}

.empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.dup-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}

.dup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.dup-hash {
  color: var(--muted);
  font-size: 11.5px;
}

.dup-source {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  padding: 3px 0;
}

.dup-source .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}

.dup-source .time {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.toast.err {
  background: #b91c1c;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.token-value {
  display: block;
  padding: 10px;
  margin: 10px 0 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f9fafb;
  word-break: break-all;
  font-size: 12px;
}

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

.stat-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stat-controls .field {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  #app {
    padding: 16px 12px 40px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}
