:root {
  --bg: #0b0f1a;
  --bg-alt: #0f1729;
  --panel: #111a2f;
  --panel-strong: #141f38;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f5f7ff;
  --muted: #a9b3d4;
  --accent: #6ea8ff;
  --accent-2: #a78bfa;
  --accent-3: #f06a6a;
  --shadow: rgba(7, 9, 16, 0.65);
  --watermark: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #1a2547, var(--bg));
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.25;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  padding: 36px 40px 60px;
  max-width: 1320px;
  margin: 0 auto;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.hero-text {
  max-width: 560px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  color: var(--accent-2);
  margin-bottom: 12px;
}

h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 42px;
  margin: 0 0 12px;
}

h2, h3 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.watermark {
  position: fixed;
  inset: auto 26px 26px auto;
  width: 160px;
  height: 160px;
  background: var(--watermark) center/contain no-repeat;
  opacity: 0.08;
  pointer-events: none;
  filter: drop-shadow(0 0 18px rgba(0,0,0,0.45));
  z-index: 0;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 20px 40px var(--shadow);
  margin-bottom: 18px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

input, select {
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}

input[type="search"] {
  width: 100%;
}

.btn {
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #0d1221;
  box-shadow: 0 12px 20px rgba(110, 168, 255, 0.35);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--panel-border);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 24px;
}

.tab {
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--panel-strong);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.tab-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--panel-strong);
}

.toggle input {
  accent-color: var(--accent);
}

.btn.small {
  padding: 8px 12px;
  font-size: 13px;
}

.tab-panel {
  display: none;
  gap: 18px;
  flex-direction: column;
}

.tab-panel.active {
  display: flex;
  animation: fadeInUp 0.4s ease;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 32px var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 28px;
  margin: 8px 0 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 40px var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 12px;
}

.panel-meta {
  font-size: 12px;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.roster {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.roster-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

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

.clickable {
  cursor: pointer;
}

.signals {
  display: grid;
  gap: 12px;
}

.signal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-strong);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--panel-border);
}

.table {
  display: grid;
  gap: 6px;
}

.table-row {
  display: grid;
  grid-template-columns: 0.5fr 1.5fr 1fr 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  font-size: 14px;
}

.table-row.header {
  background: transparent;
  border: none;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
}

.table-row.clickable {
  cursor: pointer;
}

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

.pager {
  display: flex;
  gap: 8px;
}

.user-detail-panel {
  display: grid;
  gap: 14px;
}

.user-detail-card {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel-strong);
}

.user-detail-text {
  display: grid;
  gap: 4px;
}

.user-detail-name {
  font-size: 18px;
  font-weight: 700;
}

.user-detail-meta {
  color: var(--muted);
}

.user-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  font-size: 12px;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--muted);
  width: fit-content;
}

.status-pill .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.status-pill.online {
  color: #7de3b3;
  border-color: rgba(125, 227, 179, 0.45);
  background: rgba(125, 227, 179, 0.12);
}

.status-pill.offline {
  color: #f1b17a;
  border-color: rgba(241, 177, 122, 0.45);
  background: rgba(241, 177, 122, 0.12);
}

.status-pill.idle {
  color: var(--muted);
  border-color: var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
}

.status-pill.idle .status-dot {
  box-shadow: none;
}

.user-detail-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
  align-items: start;
}

.user-meta {
  display: grid;
  gap: 10px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
}

.user-meta div {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.meta-label {
  color: var(--muted);
}

.user-charts {
  display: grid;
  gap: 12px;
}

.subpanel {
  margin-top: 18px;
}

.heatmap {
  display: grid;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  position: relative;
}

.heat-head {
  display: grid;
  grid-template-columns: 1fr repeat(24, minmax(20px, 1fr));
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.heat-day {
  display: grid;
  grid-template-columns: 1fr repeat(24, minmax(20px, 1fr));
  gap: 4px;
  align-items: center;
}

.heat-day-label {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  padding-right: 6px;
}

.heat-cell {
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.heat-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 14, 24, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  display: none;
  z-index: 5;
}

.alerts {
  display: grid;
  gap: 12px;
}

.alert {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-strong);
}

.alert strong {
  display: block;
  margin-bottom: 6px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.help-card {
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 10px 20px var(--shadow);
}

.help-card h3 {
  margin: 0 0 6px;
}

.help-card p {
  margin: 0;
  color: var(--muted);
}

.peak-list {
  display: grid;
  gap: 8px;
}

.peak-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  font-size: 14px;
}

.peak-item .meta {
  color: var(--muted);
  font-size: 12px;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: grid;
  gap: 10px;
  z-index: 20;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(12, 16, 28, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 240px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  animation: fadeInUp 0.35s ease, fadeOut 0.3s ease 4.7s forwards;
}

.toast img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}

.toast-title {
  font-weight: 700;
}

.toast-sub {
  color: var(--muted);
  font-size: 12px;
}

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  position: relative;
  z-index: 1;
}

.heart {
  display: inline-block;
  color: #fff;
  animation: pulse 1.8s ease-in-out infinite;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 20, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal.open {
  display: flex;
}

.modal-inner {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  min-width: 320px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}

.profile-card {
  display: flex;
  gap: 14px;
  align-items: center;
}

.profile-avatar {
  width: 78px;
  height: 78px;
  border-radius: 16px;
  background: var(--panel-strong);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
}

#userDetailAvatar.profile-avatar {
  width: 96px;
  height: 96px;
}

.profile-info {
  display: grid;
  gap: 4px;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
}

.profile-meta, .profile-stats {
  color: var(--muted);
  font-size: 13px;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-6px); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
  }

  .controls {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .table-row {
    grid-template-columns: 0.5fr 1.4fr 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .app {
    padding: 24px;
  }

  h1 {
    font-size: 32px;
  }

  .table-row {
    grid-template-columns: 1fr 1fr;
  }
}
