:root {
  --bg: #070d19;
  --card: #0d1527;
  --card-border: #253555;
  --text: #e7efff;
  --muted: #9bb0d6;
  --good: #84dec2;
  --warn: #ffd18a;
  --bad: #ffb0ab;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: radial-gradient(circle at 20% 0%, #13203d 0%, #070d19 52%, #050a12 100%);
  color: var(--text);
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.3px;
}

.header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.telemetry-bar {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.telemetry-item {
  border: 1px solid #2a3f67;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

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

.telemetry-item strong {
  font-size: 12px;
  color: #eff4ff;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  text-transform: uppercase;
  font-size: 10px !important;
  border: 1px solid #3c5e91;
}

.state-pill.connecting {
  color: #8ec6ff;
  background: #11253f;
}

.state-pill.live {
  color: #8cf5c5;
  background: #113525;
  border-color: #2d7858;
}

.state-pill.stale {
  color: #ffdd98;
  background: #3b2d13;
  border-color: #8f6a2f;
}

.state-pill.error {
  color: #ffb5b2;
  background: #3a1717;
  border-color: #954646;
}

.layout {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
}

.card {
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, #101a31 0%, #0c1425 100%);
  border-radius: 14px;
  padding: 12px;
}

.card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.chart-card {
  min-height: 560px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-head p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.status-group {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #38548d;
  background: #162441;
  color: #d9e6ff;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.7px;
}

.badge.live {
  border-color: #2d7858;
  background: #15372b;
  color: var(--good);
}

.badge.switching {
  border-color: #8d6f33;
  background: #3a2f17;
  color: var(--warn);
}

.badge.error {
  border-color: #8f3f3f;
  background: #341717;
  color: var(--bad);
}

.chart-shell {
  position: relative;
  height: 500px;
  border: 1px solid #29467a;
  border-radius: 12px;
  overflow: hidden;
}

.chart-root {
  position: absolute;
  inset: 0;
}

.window-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.window-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed rgba(235, 244, 255, 0.72);
}

.window-divider.current {
  border-left: 1px solid rgba(255, 225, 150, 0.88);
}

.window-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(120, 150, 206, 0.08);
}

.window-band.alt {
  background: rgba(88, 118, 172, 0.18);
}

.window-band.active {
  background: rgba(160, 185, 235, 0.2);
  border-left: 1px solid rgba(180, 205, 245, 0.42);
  border-right: 1px solid rgba(180, 205, 245, 0.42);
}

.window-label-tick {
  position: absolute;
  top: 4px;
  transform: translateX(3px);
  font-size: 10px;
  color: rgba(225, 236, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.side-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sub-title {
  margin: 8px 0 2px;
  font-size: 12px;
  color: #b7cbf5;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #24385f;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
}

.metric-row span {
  color: var(--muted);
}

.metric-row strong {
  color: #ecf3ff;
  text-align: right;
}

.log-card {
  margin-top: 14px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.log-head span {
  color: var(--muted);
  font-size: 11px;
}

.event-log {
  height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

.event-item {
  display: grid;
  grid-template-columns: 96px 80px 1fr;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #22395f;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-size: 11px;
}

.event-item .ts {
  color: #a9bde5;
}

.event-item .type {
  color: #dfe8ff;
}

.event-item .meta {
  color: #b8cdf4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.latency-green {
  color: #8df0c6 !important;
}

.latency-yellow {
  color: #ffd790 !important;
}

.latency-red {
  color: #ffb0ae !important;
}

@media (max-width: 1024px) {
  .telemetry-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .chart-shell {
    height: 420px;
  }
}
