:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: rgba(18, 25, 41, 0.82);
  --panel-strong: #111a2b;
  --line: rgba(148, 163, 184, 0.16);
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #7c9cff;
  --accent-2: #47d7ac;
  --danger: #fb7185;
  --warning: #fbbf24;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(124, 156, 255, 0.18), transparent 38rem),
    radial-gradient(circle at 95% 20%, rgba(71, 215, 172, 0.1), transparent 30rem),
    var(--bg);
}

button, input { font: inherit; }

button {
  border: 0;
  border-radius: 9px;
  padding: 0.72rem 1rem;
  color: #07101e;
  background: var(--accent-2);
  font-weight: 750;
  cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:focus-visible, input:focus-visible, .skip-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.button-secondary { color: var(--text); background: #25324a; }

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.5rem;
  left: 0.5rem;
  transform: translateY(-150%);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
}
.skip-link:focus { transform: none; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.86);
  backdrop-filter: blur(18px);
}

.brand, .status-cluster, .section-heading, .progress-row, .token-actions { display: flex; align-items: center; }
.brand { gap: 0.7rem; }
.brand-mark {
  display: grid;
  width: 2.4rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 12px;
  color: #08101e;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
}
.brand div { display: grid; gap: 0.05rem; }
.brand span { color: var(--muted); font-size: 0.78rem; }
.status-cluster { flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

.status, .count {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.25rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.75rem;
  font-weight: 700;
}
.status-connected { color: var(--accent-2); border-color: rgba(71, 215, 172, 0.32); }
.status-error, .count-danger { color: var(--danger); border-color: rgba(251, 113, 133, 0.28); }
.status-waiting { color: var(--warning); }

.dashboard { width: min(1480px, 100%); margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 3.5rem) 3rem; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.2vw, 1.4rem);
  background: linear-gradient(150deg, rgba(24, 34, 55, 0.78), var(--panel));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.16);
}
.hero { margin-bottom: 1rem; }
.section-heading { justify-content: space-between; align-items: flex-start; gap: 1rem; }
.section-heading h1, .section-heading h2 { margin: 0; }
h1 { max-width: 52rem; font-size: clamp(1.35rem, 3.4vw, 2.4rem); line-height: 1.15; }
h2 { font-size: 0.96rem; letter-spacing: 0.01em; }
.eyebrow { margin: 0 0 0.38rem; color: var(--accent-2); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.timestamp, .hint, small, .empty { color: var(--muted); }
.timestamp { font-size: 0.75rem; white-space: nowrap; }

.progress-row { gap: 0.8rem; margin-top: 1.25rem; }
progress { width: 100%; height: 0.72rem; border: 0; border-radius: 99px; overflow: hidden; background: #202b42; }
progress::-webkit-progress-bar { background: #202b42; }
progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.progress-row strong { min-width: 3.2rem; text-align: right; }

.auth-panel { display: grid; grid-template-columns: minmax(14rem, 0.65fr) 1fr; gap: 1.5rem; margin-bottom: 1rem; }
.auth-panel h2, .auth-panel p { margin-block: 0 0.25rem; }
.hint, small { font-size: 0.78rem; }
.token-form { display: grid; gap: 0.38rem; }
.token-form > label { font-size: 0.78rem; font-weight: 700; }
.token-actions { gap: 0.5rem; }
.token-actions input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.72rem 0.8rem;
  color: var(--text);
  background: rgba(3, 7, 18, 0.58);
}

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 0.9fr); gap: 1rem; }
.side-stack { display: grid; align-content: start; gap: 1rem; }
.danger-panel { border-color: rgba(251, 113, 133, 0.17); }

.item-list, .event-list { display: grid; gap: 0.55rem; margin: 0.9rem 0 0; padding: 0; list-style: none; }
.item-list li, .event-list li { border-top: 1px solid var(--line); padding-top: 0.62rem; }
.item-list li:first-child, .event-list li:first-child { border-top: 0; padding-top: 0; }
.item-title { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.84rem; font-weight: 700; }
.item-meta, .event-meta { margin-top: 0.18rem; color: var(--muted); font-size: 0.72rem; }
.event-message { margin-top: 0.3rem; color: #d9e1f4; font-size: 0.82rem; line-height: 1.45; overflow-wrap: anywhere; }
.event-error .event-message { color: #fecdd3; }
.live-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 0.28rem rgba(71, 215, 172, 0.12); }

.table-wrap { margin-top: 0.8rem; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
th, td { padding: 0.58rem 0.35rem; border-top: 1px solid var(--line); text-align: left; }
th { border-top: 0; color: var(--muted); font-size: 0.67rem; text-transform: uppercase; }
code { color: #c7d2fe; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sha-match { color: var(--accent-2); }
.sha-mismatch { color: var(--danger); }

noscript { display: block; padding: 1rem; color: var(--danger); text-align: center; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid > :last-child { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .auth-panel { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { position: static; align-items: flex-start; }
  .brand span { display: none; }
  .status-cluster { display: grid; justify-items: end; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-grid > :last-child { grid-column: auto; }
  .token-actions { align-items: stretch; flex-wrap: wrap; }
  .token-actions input { flex-basis: 100%; }
  .section-heading { align-items: flex-start; }
  .hero .section-heading { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
