:root {
  --bg: #0b1020;
  --bg-elev: #0f172a;
  --bg-elev-2: #131b30;
  --border: #1e293b;
  --border-strong: #2a3550;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-mute: #64748b;
  --cyan: #6ee7f7;
  --cyan-soft: rgba(110, 231, 247, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.16);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.16);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.18);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 8px 24px rgba(0, 0, 0, 0.35);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(110, 231, 247, 0.08), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(167, 139, 250, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: var(--cyan);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background:
    conic-gradient(from 220deg, var(--cyan), var(--purple), var(--cyan));
  box-shadow: 0 0 0 1px var(--border-strong),
    0 8px 20px rgba(110, 231, 247, 0.25);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: var(--bg);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-name {
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand-sub {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 3px;
}

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

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(52, 211, 153, 0.05);
  }
}

.segment {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-elev);
}
.segment button {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--mono);
}
.segment button[aria-selected="true"] {
  background: var(--cyan-soft);
  color: var(--cyan);
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 6px 10px;
  border-radius: 10px;
}
.select-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.select select {
  background: transparent;
  color: var(--text);
  border: 0;
  font: inherit;
  font-size: 13px;
  padding: 2px 4px;
  outline: none;
  cursor: pointer;
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.section-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}
.section-link {
  font-size: 12px;
  color: var(--text-dim);
}
.section-link:hover {
  color: var(--cyan);
}

/* ---------- KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(110, 231, 247, 0.4),
    transparent
  );
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.kpi-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.kpi-value {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 38px;
  line-height: 1;
  color: var(--text);
}
.kpi-unit {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 8px;
}

.kpi-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kpi-spark {
  position: relative;
  width: 100%;
  height: 56px;
  margin-top: 2px;
}
.kpi-spark canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.kpi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.delta {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}
.delta.up {
  color: var(--green);
  background: var(--green-soft);
}
.delta.down.good {
  color: var(--green);
  background: var(--green-soft);
}
.delta.down.bad,
.delta.up.bad {
  color: var(--red);
  background: var(--red-soft);
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.badge-elite {
  background: var(--cyan-soft);
  color: var(--cyan);
}
.badge-high {
  background: var(--purple-soft);
  color: var(--purple);
}
.badge-medium {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge-low {
  background: var(--red-soft);
  color: var(--red);
}

.spark {
  width: 110px;
  max-width: 60%;
  height: 36px;
}
.kpi-spark .spark {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
}

/* ---------- Charts / Cards ---------- */
.section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow);
}

.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-tall {
  height: 260px;
}
.chart-mid {
  height: 200px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--text-dim);
  font-size: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-cyan { background: var(--cyan); }
.dot-red { background: var(--red); }
.dot-purple { background: var(--purple); }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.card-link {
  font-size: 12px;
  color: var(--text-dim);
}
.card-link:hover {
  color: var(--cyan);
}

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.legend-list li {
  display: flex;
  justify-content: space-between;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.legend-list b {
  font-family: var(--mono);
  color: var(--text);
}

/* ---------- DevEx score bars ---------- */
.score-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.score-label {
  color: var(--text);
  font-weight: 600;
}
.score-val {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--cyan);
}
.score-val.warn {
  color: var(--amber);
}
.bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  margin: 6px 0 4px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: inherit;
}
.score-val small {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 2px;
}
.score-meta {
  color: var(--text-mute);
  font-size: 11px;
  font-family: var(--mono);
}

/* ---------- Latency stacked percentiles ---------- */
.kpi-full {
  grid-column: 1 / -1;
}
.kpi-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}
.latency-stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.latency-stack > li {
  display: grid;
  grid-template-columns: 48px 1fr 96px;
  align-items: center;
  gap: 14px;
}
.latency-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.latency-tag.warn {
  color: var(--amber);
}
.bar-thin {
  margin: 0;
  height: 8px;
}
.bar-thin.warn > span {
  background: linear-gradient(90deg, var(--amber), var(--red));
}
.latency-val {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-align: right;
}
.latency-val.warn {
  color: var(--amber);
}
.latency-val small {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 2px;
}

.error-budget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.error-budget-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.error-budget-chart-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.error-budget-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}
.error-budget-chart-sub {
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--mono);
}
.error-budget-chart-body {
  position: relative;
  width: 100%;
  height: 180px;
  margin-top: 4px;
}
.error-budget-chart-body.burn-rate-gauge {
  height: 220px;
}

.feature-chart {
  position: relative;
  width: 100%;
  height: 280px;
}
.feature-chart canvas {
  width: 100% !important;
  height: 100% !important;
}
.feature-legend {
  list-style: none;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px dashed var(--border);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
}
.feature-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.feature-legend .feature-name {
  flex: 1;
  color: var(--text);
  font-weight: 600;
}
.feature-legend .feature-val {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
}
.feature-legend .feature-name small {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10px;
  color: var(--text-mute);
  margin-left: 6px;
}
.feature-legend .feature-delta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-soft);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 56px;
  text-align: center;
}
.feature-legend .feature-delta.bad {
  color: var(--red);
  background: var(--red-soft);
}
@media (max-width: 640px) {
  .feature-legend {
    grid-template-columns: 1fr;
  }
}
.error-budget-chart-body canvas {
  width: 100% !important;
  height: 100% !important;
}
@media (max-width: 900px) {
  .error-budget-grid {
    grid-template-columns: 1fr;
  }
}

.latency-trend {
  position: relative;
  width: 100%;
  height: 180px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.latency-trend canvas {
  width: 100% !important;
  height: 100% !important;
}
.latency-legend {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
}
.latency-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 12px 16px;
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}
table.data tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table.data tbody tr:last-child td {
  border-bottom: 0;
}
table.data tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}
.num {
  font-family: var(--mono);
  font-weight: 600;
}
.num.good { color: var(--green); }
.num.warn { color: var(--amber); }
.num.bad { color: var(--red); }

.team-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}
.pill-good {
  background: var(--green-soft);
  color: var(--green);
}
.pill-warn {
  background: var(--amber-soft);
  color: var(--amber);
}
.pill-bad {
  background: var(--red-soft);
  color: var(--red);
}

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px 32px;
  color: var(--text-mute);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  color: var(--text-dim);
}
.footer-links a:hover {
  color: var(--cyan);
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
  .layout {
    padding: 16px;
    gap: 20px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .kpi-value {
    font-size: 32px;
  }
  .footer {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 20px 16px 28px;
  }
}
