:root {
  --bg: #f1f5f9;
  --panel: rgba(255, 255, 255, 0.6);
  --panel-2: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #6366f1;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  background-image: radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.05) 0px, transparent 50%), radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.brand { font-weight: 700; font-size: 16px; font-family: 'Outfit', sans-serif; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.link { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
.link:hover { text-decoration: underline; }

.pill { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: bold; text-transform: uppercase; }
.pill-muted { background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.pill-on { background: rgba(34,197,94,.15); color: var(--green); }
.pill-off { background: rgba(239,68,68,.15); color: var(--red); }

.controls {
  display: flex; align-items: center; gap: 12px; padding: 14px 20px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
#playerIdInput {
  flex: 1; min-width: 280px; max-width: 460px;
  background: #ffffff; border: 2px solid rgba(0, 0, 0, 0.06); color: var(--text);
  padding: 8px 12px; border-radius: 10px; font-family: var(--mono); font-size: 12px;
  outline: none; transition: all 0.2s;
}
#playerIdInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}
.btn {
  background: #ffffff; color: var(--text); border: 2px solid rgba(0, 0, 0, 0.06);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all 0.2s;
}
.btn:hover { border-color: var(--accent); background: rgba(99, 102, 241, 0.02); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); font-weight: 700; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.15); }
.btn-primary:hover { background: #4f46e5; border-color: #4f46e5; }
.auto { color: var(--muted); display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; }
.status-msg { color: var(--muted); font-size: 12px; font-weight: 500; }
.muted { color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 2px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--border); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.tab {
  background: none; border: none; color: var(--muted); padding: 12px 20px;
  cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent;
  font-weight: 600; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tabview { display: none; padding: 20px; }
.tabview.active { display: block; }

.activity-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .activity-layout { grid-template-columns: 1fr; } }

.filterbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.filterbar input, .filterbar select {
  background: var(--panel-2); border: 2px solid rgba(0, 0, 0, 0.06); color: var(--text);
  padding: 6px 10px; border-radius: 8px; font-size: 12px; outline: none; transition: border-color 0.2s;
}
.filterbar input:focus, .filterbar select:focus { border-color: var(--accent); }
.filterbar input { flex: 1; }

.grid { width: 100%; border-collapse: collapse; }
.grid th {
  text-align: left; color: var(--muted); font-weight: 700; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 2px solid var(--border);
}
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.grid tbody tr { transition: background 0.15s; }
.grid tbody tr:hover { background: rgba(99, 102, 241, 0.03); }
.grid tbody tr.selected { background: rgba(99, 102, 241, 0.08); }

.method { font-family: var(--mono); font-weight: 600; font-size: 11px; }
.path-cell { font-family: var(--mono); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-family: var(--mono); font-weight: 600; }
.code-2 { color: var(--green); }
.code-4 { color: var(--amber); }
.code-5 { color: var(--red); }

.detail {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; min-height: 200px; position: sticky; top: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
.detail h3 { margin: 0 0 4px; font-size: 14px; }
.detail .kv { color: var(--muted); font-size: 12px; margin-bottom: 12px; font-family: var(--mono); }
.detail .section-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 4px; font-weight: 600; }
pre.body {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; overflow: auto; max-height: 320px; font-family: var(--mono);
  font-size: 12px; white-space: pre-wrap; word-break: break-word; margin: 0;
}

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

.db-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.db-section { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.db-section > summary {
  cursor: pointer; padding: 10px 12px; font-family: var(--mono); font-size: 12px;
  display: flex; align-items: center; gap: 10px; user-select: none;
}
.db-section > summary::-webkit-details-marker { display: none; }
.db-section .count { color: var(--muted); }
.db-section .db-link { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 11px; }
.db-table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
.db-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.db-table th { background: var(--panel-2); color: var(--muted); text-align: left; padding: 5px 8px; white-space: nowrap; font-weight: 500; }
.db-table td { padding: 5px 8px; border-top: 1px solid var(--border); font-family: var(--mono); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.db-empty { padding: 10px 12px; color: var(--muted); border-top: 1px solid var(--border); }
.db-section.err > summary { color: var(--red); }

/* Profile and Leaderboard Tab view */
.profile-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1000px) {
  .profile-layout {
    grid-template-columns: 1fr;
  }
}
.glass-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}
.glass-card h2 {
  margin: 0 0 16px;
  font-family: inherit;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.profile-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 6px;
  font-size: 12px;
}
.profile-item .label {
  color: var(--muted);
  font-weight: 500;
}
.profile-item .value {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}
.cohort-status-pill {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.cohort-status-pill.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border-color: rgba(34, 197, 94, 0.3);
}
.leaderboard-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
}
.leaderboard-grid tbody tr.caller {
  background: rgba(99, 102, 241, 0.08);
  border-left: 3px solid var(--accent);
}
.badge-bot {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
}
.badge-bot:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--amber);
  transform: scale(1.05);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.2);
}

.lb-switcher {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.lb-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 2px solid rgba(0, 0, 0, 0.06);
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}
.lb-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}
.lb-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 700;
}

.clickable-member {
  cursor: pointer;
}
.clickable-member:hover {
  background: rgba(99, 102, 241, 0.04) !important;
}

/* Profile Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 24px;
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
  animation: modalPop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.modal-header h3 {
  margin: 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 18px;
}
.bot-info-badge {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: 8px;
  padding: 12px;
  margin-top: 14px;
}
.bot-info-badge h4 {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

