:root {
  --bg: #0a0e17;
  --bg-alt: #0d1220;
  --surface: #121829;
  --surface-2: #171f35;
  --border: #232c46;
  --text: #eef1f8;
  --text-dim: #a3aec7;
  --text-faint: #6b7591;

  --blue: #2b63e0;
  --blue-light: #4d84ff;
  --green: #25d366;
  --red: #ef4444;

  --radius: 14px;
  --radius-sm: 9px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-glow {
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 500px;
  background: radial-gradient(circle, rgba(43,99,224,.35), transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 34px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.6);
}
.login-logo { height: 34px; width: auto; margin: 0 auto 22px; }
.login-card h1 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.login-card p { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 26px; }
.login-card input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 14px;
}
.login-card input:focus { outline: none; border-color: var(--blue-light); }
.login-card button {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .15s ease;
}
.login-card button:hover { transform: translateY(-1px); }
.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 14px;
  min-height: 18px;
}

/* Dashboard layout */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,14,23,.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { height: 28px; width: auto; }
.topbar-title { font-size: 0.95rem; font-weight: 600; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.range-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

main { max-width: 1180px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 22px; }

/* Realtime hero */
.realtime-card {
  background: linear-gradient(135deg, rgba(43,99,224,.14), rgba(37,211,102,.06));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.realtime-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(37,211,102,.6);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(37,211,102,.6); }
  70% { box-shadow: 0 0 0 10px rgba(37,211,102,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,211,102,0); }
}
.realtime-number { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.realtime-label { color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.realtime-main { display: flex; align-items: center; gap: 16px; }
.realtime-lists { display: flex; gap: 36px; flex-wrap: wrap; margin-left: auto; }
.realtime-lists h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: 8px; }
.realtime-lists ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.realtime-lists li { font-size: 0.85rem; color: var(--text-dim); display: flex; justify-content: space-between; gap: 16px; min-width: 180px; }
.realtime-lists li strong { color: var(--text); font-weight: 600; }
.realtime-empty { color: var(--text-faint); font-size: 0.85rem; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-label { color: var(--text-faint); font-size: 0.8rem; margin-top: 4px; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 18px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

.chart-wrap svg { width: 100%; height: 220px; display: block; }

table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-dim);
}
table td:last-child, table th:last-child { text-align: right; color: var(--text); font-weight: 600; }
table tr:last-child td { border-bottom: none; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { font-size: 0.85rem; color: var(--text-dim); width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-light)); border-radius: 999px; }
.bar-value { font-size: 0.82rem; color: var(--text); font-weight: 600; width: 46px; text-align: right; flex-shrink: 0; }

.empty-state { color: var(--text-faint); font-size: 0.88rem; text-align: center; padding: 30px 0; }
.loading-state { color: var(--text-faint); font-size: 0.85rem; }

@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .realtime-lists { margin-left: 0; gap: 24px; }
  main { padding: 20px 16px; }
}
