:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c232c;
  --line: #262d36;
  --text: #e6edf3;
  --muted: #8b949e;
  --acc: #3fb950;
  --acc2: #58a6ff;
  --warn: #d29922;
  --bad: #f85149;
}

* { box-sizing: border-box; }

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

.hide { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }

/* ---------- màn đăng nhập ---------- */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
}

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

.gate-tabs { display: flex; gap: 8px; margin: 16px 0; }

.gate-tabs button {
  flex: 1;
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.gate-tabs button.on { color: var(--text); border-color: var(--acc2); }

/* ---------- thành phần chung ---------- */

input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  padding: 9px 11px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--acc2);
}

button { cursor: pointer; }
button:hover { filter: brightness(1.18); }
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-main { background: var(--acc); color: #06240f; border-color: transparent; font-weight: 600; }
.btn-blue { background: var(--acc2); color: #04213f; border-color: transparent; font-weight: 600; }
.btn-bad { background: transparent; color: var(--bad); border-color: #43262a; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.full { width: 100%; }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
label.field input, label.field select { width: 100%; }

.msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--acc); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

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

/* ---------- thanh trên ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.top h1 { margin: 0; font-size: 19px; }
.top .spacer { flex: 1; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
}

.pill.on { color: var(--acc); border-color: #1f462a; }
.pill.role { color: var(--acc2); border-color: #1b3a5c; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.tabs button { background: var(--panel); color: var(--muted); }
.tabs button.on { color: var(--text); border-color: var(--acc2); }
.tabs .badge {
  background: var(--bad);
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 6px;
  font-size: 11px;
}

/* ---------- thẻ số ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12px; }

/* ---------- bảng ---------- */

.tw { overflow-x: auto; }

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

th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:hover { background: #1a212a; }

code.tok { font-size: 12px; color: var(--muted); word-break: break-all; }

.tag { font-size: 11px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); }
.tag.g { color: var(--acc); border-color: #1f462a; }
.tag.b { color: var(--bad); border-color: #43262a; }
.tag.y { color: var(--warn); border-color: #453a1c; }
.tag.i { color: var(--acc2); border-color: #1b3a5c; }

.gain { color: var(--acc); font-size: 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

details.log { margin-top: 6px; }
details.log summary { cursor: pointer; color: var(--acc2); font-size: 12px; }
details.log div { max-height: 170px; overflow: auto; margin-top: 5px; }

.logbox {
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
}

.logbox p { margin: 0 0 3px; }

textarea { width: 100%; min-height: 92px; resize: vertical; font-family: ui-monospace, monospace; }

/* ---------- modal quét QR Discord ---------- */

.qr-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .68);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}

.qr-card {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.qr-card h2 { margin: 0 0 10px; font-size: 17px; }

.qr-steps {
  text-align: left; font-size: 12.5px; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; margin-bottom: 14px;
}

.qr-box img {
  width: 230px; height: 230px;
  background: #fff; border-radius: 10px;
  border: 1px solid var(--line);
}

.qr-count { margin-top: 8px; font-size: 12px; color: var(--muted); min-height: 18px; }

.qr-user {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 12px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}

.qr-user img { width: 40px; height: 40px; border-radius: 50%; }


/* ---------- P24: tiến trình nhặt xu ---------- */

.pbar { height: 6px; min-width: 64px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--acc); }

.livebar { background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px; margin: 0 0 16px;
  font: 12.5px/1.5 ui-monospace, monospace; color: var(--muted); }
.livebar.on { color: var(--acc); border-color: #1f462a; }

/* ---------- P24: note link đăng nhập QR ---------- */

.qr-link { margin-top: 12px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  text-align: left; }
.qr-linka { color: var(--acc2); font-size: 13px; text-decoration: underline; }
