:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2f4059;
  --text: #e8eef7;
  --muted: #8fa3bf;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --naxx: #a78bfa;
  --aq40: #fbbf24;
  --success: #34d399;
  --error: #f87171;
  --discord: #5865f2;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.bg-pattern {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(91, 141, 239, 0.12), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(167, 139, 250, 0.1), transparent 35%),
    radial-gradient(circle at 50% 100%, rgba(251, 191, 36, 0.08), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.logo.small { font-size: 1.1rem; margin-bottom: 0.25rem; }

h1 {
  margin: 0.25rem 0 0;
  font-size: 1.75rem;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 600;
}

.subtitle, .hint {
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.login-card {
  max-width: 420px;
  margin: 10vh auto 0;
  text-align: center;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.user-panel {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name { color: var(--muted); font-size: 0.95rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card.naxx { border-color: rgba(167, 139, 250, 0.45); }
.stat-card.aq40 { border-color: rgba(251, 191, 36, 0.45); }

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.last-sync, .sync-status { color: var(--muted); font-size: 0.9rem; }

.search-card { margin-bottom: 1rem; }

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.search-form input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}

.live-result {
  margin-top: 0.75rem;
  color: var(--accent);
  font-size: 0.92rem;
}

.player-link {
  color: var(--text);
  text-decoration: none;
}

.player-link:hover { color: var(--accent); }

.wcl-link {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.wcl-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.date { font-variant-numeric: tabular-nums; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.9em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-discord {
  margin-top: 1.5rem;
  background: var(--discord);
  color: #fff;
  width: 100%;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, monospace; color: var(--muted); }
.total { font-weight: 700; color: var(--accent); }

.empty { color: var(--muted); margin: 0; }

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history-item .message {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-success .badge { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.status-error .badge { background: rgba(248, 113, 113, 0.15); color: var(--error); }
.status-running .badge { background: rgba(91, 141, 239, 0.15); color: var(--accent); }

@media (max-width: 640px) {
  .topbar { flex-direction: column; }
  .history-item { grid-template-columns: 1fr; }
}
