:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-input: #0d1117;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #238636;
  --accent-hover: #2ea043;
  --danger: #da3633;
  --secondary: #21262d;
  --secondary-hover: #30363d;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── LOGIN ─── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { text-align: center; font-size: 26px; }
.subtitle { text-align: center; color: var(--muted); margin-bottom: 8px; }

/* ─── TOPBAR ─── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 18px; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a, .link-btn {
  color: var(--muted); text-decoration: none; font-size: 14px;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.topbar nav a:hover, .link-btn:hover { color: var(--text); }
.topbar .user { color: var(--text); font-size: 14px; }
.topbar .logout { color: var(--danger); }

/* ─── BALANCE CHIPS ─── */
.balance-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--secondary); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px; font-size: 13px;
  cursor: pointer; user-select: none; transition: background .15s;
}
.balance-chip:hover { background: var(--secondary-hover); }
.balance-chip .bal-val { font-weight: 600; color: var(--accent-hover); font-family: "Cascadia Code", Consolas, monospace; }

/* ─── GRID ─── */
.grid {
  display: grid; gap: 18px; padding: 24px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  max-width: 1200px; margin: 0 auto;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.card.wide { grid-column: 1 / -1; }
.card h2 { font-size: 17px; }

/* ─── INPUTS ─── */
input, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px; font-size: 14px; font-family: inherit; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
select option { background: var(--bg-card); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input, .row > select { flex: 1; width: auto; }

/* ─── BUTTONS ─── */
button {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 9px 16px;
  font-size: 14px; font-weight: 500; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--secondary); }
button.secondary:hover { background: var(--secondary-hover); }

/* ─── RESULTS ─── */
.result {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; font-size: 14px;
}
.log {
  background: #010409; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; font-size: 12px;
  color: var(--muted); max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; font-family: "Cascadia Code", Consolas, monospace;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: "Cascadia Code", Consolas, monospace; }
hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ─── SCORE ─── */
.score-badge {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 22px; font-weight: 700; margin-bottom: 8px;
}
.score-num {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
.s-good { background: var(--accent); }
.s-mid  { background: #bb8009; }
.s-bad  { background: var(--danger); }
.issues { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.issues li { font-size: 13px; color: #f0a; padding-left: 14px; position: relative; }
.issues li::before { content: "•"; position: absolute; left: 0; color: var(--danger); }

.code-highlight {
  font-size: 24px; font-weight: 700; color: var(--accent-hover);
  letter-spacing: 3px; font-family: "Cascadia Code", Consolas, monospace;
}
.copy-field {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  background: var(--bg-card); padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border); margin-top: 6px;
}
.copy-field .mono { word-break: break-all; }
.copy-btn { padding: 4px 10px; font-size: 12px; }

/* ─── ALERTS ─── */
.alert { padding: 10px 12px; border-radius: var(--radius); font-size: 14px; }
.alert-error { background: rgba(218,54,51,.15); color: #ff7b72; border: 1px solid var(--danger); }
.alert-success { background: rgba(35,134,54,.15); color: #3fb950; border: 1px solid var(--accent); }

/* ─── MODAL ─── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.modal-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

/* ─── HISTORY ─── */
.history-wrap { max-width: 1000px; margin: 0 auto; padding: 24px; }
.history-wrap h2 { margin-bottom: 16px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history-table th, .history-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.history-table th { color: var(--muted); font-weight: 500; }
.nowrap { white-space: nowrap; }
.badge { padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.badge-ip { background: rgba(35,134,54,.2); color: #3fb950; }
.badge-email { background: rgba(88,166,255,.2); color: #58a6ff; }
.badge-sms { background: rgba(187,128,9,.2); color: #d29922; }
.badge-names { background: rgba(139,148,158,.2); color: #8b949e; }

/* ─── ADMIN: USERS ─── */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.admin-wrap h2 { margin-bottom: 4px; }
.admin-wrap h3 { font-size: 15px; margin-bottom: 10px; }
.user-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.user-form input[type="text"] { flex: 1; min-width: 160px; width: auto; }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.checkbox input { width: auto; }
.users-table td { vertical-align: middle; }
.users-table .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input[type="text"] { width: 130px; padding: 6px 8px; font-size: 13px; }
button.small { padding: 6px 10px; font-size: 12px; }
button.danger { background: var(--danger); }
button.danger:hover { background: #f85149; }
