:root {
  --bg-0: #05070d;
  --bg-1: #08101b;
  --bg-2: #0c1524;
  --bg-3: #111d31;
  --surface-1: rgba(11, 20, 34, 0.9);
  --surface-2: rgba(12, 23, 39, 0.86);
  --surface-3: rgba(19, 30, 49, 0.92);
  --line-soft: rgba(120, 168, 255, 0.2);
  --line-mid: rgba(120, 168, 255, 0.35);
  --text-main: #e8f1ff;
  --text-soft: #9eb2d4;
  --text-dim: #6d7f9f;
  --brand: #3a83ff;
  --brand-cyan: #21d4c5;
  --brand-violet: #6f68ff;
  --good: #2fe0a9;
  --warn: #f4a83e;
  --bad: #ff5f70;
  --mono: "IBM Plex Mono", "SF Mono", "SFMono-Regular", Menlo, monospace;
  --sf: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
  --body: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--body);
  color: var(--text-main);
  background:
    radial-gradient(circle at 8% -8%, rgba(58, 131, 255, 0.22), transparent 36%),
    radial-gradient(circle at 100% 0%, rgba(33, 212, 197, 0.16), transparent 32%),
    radial-gradient(circle at 92% 100%, rgba(111, 104, 255, 0.12), transparent 33%),
    linear-gradient(155deg, #05070d, #0a1220 42%, #060a12 100%);
}

.grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(133, 183, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(133, 183, 255, 0.06) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at center, black 34%, transparent 92%);
}

h1,
h2,
h3,
h4,
.brand {
  font-family: var(--sf);
  margin: 0;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
  position: relative;
  z-index: 1;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(8, 14, 25, 0.95), rgba(10, 18, 32, 0.92)),
    linear-gradient(120deg, rgba(58, 131, 255, 0.08), transparent 40%);
  border-right: 1px solid rgba(146, 192, 255, 0.14);
  padding: 1.35rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(8px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1rem;
  font-weight: 700;
}

.mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.62rem;
  display: grid;
  place-items: center;
  font-size: 0.92rem;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-cyan));
  box-shadow: 0 0 0 1px rgba(167, 205, 255, 0.4), 0 12px 24px rgba(19, 91, 210, 0.32);
}

.build-tag {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  color: #8fb0e3;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 0.3rem;
}

.side-nav a {
  font-family: var(--mono);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9db3d8;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  padding: 0.58rem 0.62rem;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(58, 131, 255, 0.14);
  border-color: rgba(120, 168, 255, 0.4);
  color: #e8f3ff;
}

.side-module {
  margin-top: 0.3rem;
  background: rgba(12, 22, 37, 0.7);
  border: 1px solid rgba(120, 168, 255, 0.2);
  border-radius: 0.8rem;
  padding: 0.8rem;
}

.module-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #95b1dc;
}

.latency-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.latency-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
}

.latency-list span {
  color: #9db3d8;
}

.latency-list strong {
  color: #d9ecff;
  font-weight: 600;
}

.side-links {
  margin-top: auto;
  display: grid;
  gap: 0.35rem;
}

.side-links a {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8eb1e4;
}

.side-links a:hover {
  color: #dff0ff;
}

.main-area {
  padding: 1.3rem;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0;
  color: #8ba6cf;
  font-family: var(--mono);
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.top-bar h1 {
  margin-top: 0.42rem;
  font-size: clamp(1.45rem, 2.8vw, 2.4rem);
  line-height: 1.02;
  text-wrap: balance;
}

.top-actions {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
}

.top-actions button {
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(13, 22, 36, 0.9);
  color: #b7cbee;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  transition: border-color 200ms ease, transform 200ms ease, color 200ms ease;
}

.top-actions button:hover {
  transform: translateY(-1px);
  border-color: var(--line-mid);
  color: #eaf4ff;
}

.top-actions .primary {
  background: linear-gradient(120deg, rgba(40, 111, 255, 0.95), rgba(62, 95, 224, 0.95), rgba(33, 212, 197, 0.9));
  color: #f7fcff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(28, 87, 206, 0.34);
}

.kpis {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.72rem;
}

.kpi-card {
  background: linear-gradient(155deg, rgba(11, 21, 36, 0.94), rgba(12, 23, 40, 0.82));
  border: 1px solid var(--line-soft);
  border-radius: 0.95rem;
  padding: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(171, 208, 255, 0.08), 0 14px 26px rgba(4, 8, 16, 0.34);
}

.kpi-label {
  margin: 0;
  color: #8daad2;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.kpi-card h2 {
  margin-top: 0.48rem;
  font-size: clamp(1.2rem, 1.8vw, 1.65rem);
  font-variant-numeric: tabular-nums;
}

.kpi-card small {
  display: block;
  margin-top: 0.3rem;
  color: #6f89b2;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
}

.content-grid {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.95fr);
}

.panel {
  background: linear-gradient(165deg, var(--surface-1), var(--surface-2));
  border: 1px solid var(--line-soft);
  border-radius: 0.95rem;
  padding: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(171, 208, 255, 0.06), 0 14px 30px rgba(4, 8, 15, 0.42);
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.panel-head h3 {
  font-size: 1.05rem;
}

.panel-head span {
  color: #7592bf;
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: right;
}

.graph-panel {
  grid-row: span 2;
}

.graph-wrap {
  border: 1px solid rgba(120, 168, 255, 0.22);
  border-radius: 0.8rem;
  background:
    radial-gradient(circle at 12% 8%, rgba(58, 131, 255, 0.12), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(33, 212, 197, 0.09), transparent 26%),
    linear-gradient(160deg, rgba(8, 15, 26, 0.95), rgba(8, 13, 22, 0.92));
  overflow: hidden;
}

#algoGraph {
  width: 100%;
  display: block;
}

.graph-edge {
  stroke: rgba(104, 163, 255, 0.44);
  stroke-linecap: round;
  transition: stroke 170ms ease, stroke-width 170ms ease, opacity 170ms ease;
}

.graph-edge.hot {
  stroke: rgba(38, 232, 211, 0.84);
}

.graph-node circle {
  stroke-width: 2;
  transition: filter 160ms ease, stroke 160ms ease;
}

.graph-node text {
  font-family: var(--mono);
  font-size: 11px;
  text-anchor: middle;
  pointer-events: none;
  fill: #d8eaff;
  letter-spacing: 0.02em;
}

.graph-node .node-sub {
  fill: #8dafdd;
  font-size: 9px;
}

.graph-node.core circle {
  fill: rgba(30, 63, 130, 0.84);
  stroke: rgba(116, 175, 255, 0.95);
}

.graph-node.proprietary circle {
  fill: rgba(18, 62, 64, 0.9);
  stroke: rgba(80, 233, 218, 0.95);
}

.graph-node.support circle {
  fill: rgba(42, 39, 92, 0.88);
  stroke: rgba(150, 148, 255, 0.95);
}

.graph-node.active circle {
  filter: drop-shadow(0 0 10px rgba(56, 197, 255, 0.6));
}

.graph-node {
  cursor: grab;
}

.graph-node.dragging {
  cursor: grabbing;
}

.graph-footer {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.coherence-box p {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #87a7d7;
}

.coherence-box strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.18rem;
  color: #dff4ff;
}

.graph-scale {
  min-width: 220px;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7395c7;
  position: relative;
  padding-top: 0.58rem;
}

.graph-scale::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0.36rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 95, 112, 0.55), rgba(244, 168, 62, 0.72), rgba(47, 224, 169, 0.86));
}

.impact-stack {
  display: grid;
  gap: 0.42rem;
}

.impact-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.impact-row p {
  margin: 0;
  font-size: 0.84rem;
  color: #dcecff;
}

.impact-row small {
  display: block;
  margin-top: 0.16rem;
  color: #7592bf;
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.live-metric {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: #7bf6d1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.impact-bar {
  height: 0.42rem;
  background: rgba(101, 138, 192, 0.2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.32rem;
}

.impact-bar i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(100deg, rgba(58, 131, 255, 0.88), rgba(33, 212, 197, 0.88));
  transition: width 160ms ease;
}

.snippet-block + .snippet-block {
  margin-top: 0.66rem;
}

.snippet-label {
  margin: 0 0 0.4rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: #8eb1e5;
  letter-spacing: 0.08em;
}

pre {
  margin: 0;
  background: rgba(7, 13, 23, 0.9);
  border: 1px solid rgba(120, 168, 255, 0.2);
  border-radius: 0.72rem;
  padding: 0.7rem;
  overflow: auto;
}

code {
  color: #c7ddff;
  font-family: var(--mono);
  font-size: 0.71rem;
  line-height: 1.5;
}

.pipeline {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
}

.stage {
  position: relative;
  padding: 0.58rem 0.48rem;
  border-radius: 0.64rem;
  border: 1px solid rgba(120, 168, 255, 0.26);
  background: linear-gradient(150deg, rgba(16, 29, 49, 0.95), rgba(12, 22, 36, 0.84));
  text-align: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #cde4ff;
}

.stage:not(:last-child)::after {
  content: ">";
  position: absolute;
  right: -0.48rem;
  top: 50%;
  transform: translateY(-50%);
  color: #7b9ed3;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.hardware-grid {
  margin-top: 0.72rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.hardware-grid article {
  background: rgba(10, 19, 32, 0.8);
  border: 1px solid rgba(120, 168, 255, 0.18);
  border-radius: 0.68rem;
  padding: 0.64rem;
}

.hardware-grid h4 {
  font-size: 0.9rem;
}

.hardware-grid p {
  margin: 0.3rem 0 0;
  color: #89a7d6;
  font-size: 0.77rem;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.54rem;
}

.insight-grid article {
  border: 1px solid rgba(120, 168, 255, 0.2);
  border-radius: 0.7rem;
  background: rgba(11, 20, 33, 0.76);
  padding: 0.62rem;
}

.insight-title {
  margin: 0;
  color: #8cb0e2;
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.insight-grid strong {
  display: block;
  margin-top: 0.34rem;
  color: #dbebff;
  font-size: 0.78rem;
  line-height: 1.4;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.56rem 0.3rem;
  border-bottom: 1px solid rgba(120, 168, 255, 0.16);
  font-size: 0.74rem;
}

th {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: #8cb0e2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td {
  color: #d6e8ff;
  text-transform: lowercase;
}

#incidentTableBody tr {
  transition: background 180ms ease;
}

#incidentTableBody tr.pulse {
  background: rgba(44, 124, 255, 0.16);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.badge.danger {
  color: #ffd4da;
  background: rgba(255, 95, 112, 0.2);
  border: 1px solid rgba(255, 95, 112, 0.35);
}

.badge.warn {
  color: #ffe0b6;
  background: rgba(244, 168, 62, 0.17);
  border: 1px solid rgba(244, 168, 62, 0.35);
}

.badge.info {
  color: #cce8ff;
  background: rgba(58, 131, 255, 0.18);
  border: 1px solid rgba(58, 131, 255, 0.34);
}

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

  .pipeline {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage:nth-child(3)::after,
  .stage:nth-child(5)::after {
    content: none;
  }

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

@media (max-width: 1020px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(146, 192, 255, 0.14);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .graph-panel {
    grid-row: auto;
  }

  .insight-grid,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .stage::after {
    content: none !important;
  }
}

@media (max-width: 760px) {
  .main-area {
    padding: 1rem 0.82rem;
  }

  .top-bar {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-actions button {
    flex: 1 1 auto;
  }

  .kpis,
  .side-nav,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-head span {
    text-align: left;
  }
}

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