:root {
  --bg: #091019;
  --bg-soft: #0f1824;
  --panel: rgba(13, 24, 36, 0.92);
  --panel-strong: rgba(15, 28, 42, 0.96);
  --line: rgba(123, 161, 201, 0.18);
  --line-strong: rgba(123, 161, 201, 0.34);
  --text: #ebf3ff;
  --muted: #8fa6bf;
  --accent: #76d0ff;
  --accent-strong: #0d91d0;
  --good: #35d38a;
  --warn: #ffb454;
  --bad: #ff7d74;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.5 "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(42, 109, 168, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(24, 177, 128, 0.16), transparent 24%),
    linear-gradient(160deg, #07111b 0%, #08101a 34%, #0d1724 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr) 380px;
  gap: 14px;
  height: 100vh;
  padding: 14px;
}

.sidebar,
.details,
.main {
  min-height: 0;
}

.sidebar,
.details {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.panel {
  background: linear-gradient(180deg, rgba(16, 27, 40, 0.98), rgba(9, 18, 28, 0.94));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero,
.toolbar,
.meta-strip,
.details-panel,
.sidebar .panel {
  padding: 18px;
}

.hero {
  background:
    radial-gradient(circle at right top, rgba(118, 208, 255, 0.18), transparent 44%),
    linear-gradient(180deg, rgba(18, 33, 48, 0.98), rgba(8, 17, 27, 0.96));
}

.hero h1,
.toolbar h2,
.details-header h3,
.panel-heading h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.subtitle,
#summary,
.panel-meta,
.muted {
  color: var(--muted);
}

.summary-cards,
.graph-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.stat-card {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(9, 17, 27, 0.72);
}

.stat-card strong {
  display: block;
  font-size: 20px;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 14, 22, 0.92);
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: rgba(118, 208, 255, 0.62);
  box-shadow: 0 0 0 3px rgba(118, 208, 255, 0.12);
}

button {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

button.primary {
  background: linear-gradient(180deg, rgba(18, 121, 175, 0.95), rgba(12, 83, 121, 0.95));
  border-color: rgba(118, 208, 255, 0.36);
}

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

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

.control-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-heading,
.toolbar,
.details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-copy {
  min-width: 0;
}

.toolbar h2 {
  font-size: 28px;
  margin-bottom: 4px;
}

.toolbar-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 118px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.badge.ready {
  background: rgba(18, 57, 35, 0.9);
  border-color: rgba(53, 211, 138, 0.35);
  color: #9ff1bf;
}

.badge.blocked {
  background: rgba(76, 22, 22, 0.9);
  border-color: rgba(255, 125, 116, 0.36);
  color: #ffc2bc;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 18, 28, 0.78);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.crumb.active {
  color: var(--text);
  border-color: rgba(118, 208, 255, 0.42);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(10, 18, 28, 0.82);
  border: 1px solid var(--line);
  color: var(--muted);
}

.stat-pill strong {
  color: var(--text);
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#graph {
  width: 100%;
  height: 100%;
  min-height: 640px;
  display: block;
  cursor: grab;
}

#graph.dragging {
  cursor: grabbing;
}

.edge {
  stroke-linecap: round;
  opacity: 0.76;
}

.edge.blocker {
  stroke-dasharray: 6 6;
}

.node {
  cursor: pointer;
}

.node-label {
  fill: var(--text);
  font: 600 11px/1 "IBM Plex Mono", "SFMono-Regular", monospace;
  pointer-events: none;
}

.node-label.shadow {
  fill: rgba(7, 14, 22, 0.92);
  stroke: rgba(7, 14, 22, 0.92);
  stroke-width: 5px;
  stroke-linejoin: round;
}

.stage-hint {
  position: absolute;
  right: 16px;
  bottom: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(9, 17, 27, 0.78);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.hovercard {
  position: absolute;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 16, 24, 0.96);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.32);
  pointer-events: none;
  z-index: 10;
}

.results {
  display: grid;
  gap: 8px;
  max-height: 28vh;
  overflow: auto;
}

.result {
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(7, 14, 22, 0.82);
  cursor: pointer;
}

.result:hover {
  border-color: rgba(118, 208, 255, 0.4);
  transform: translateY(-1px);
}

.result strong {
  display: block;
  margin-bottom: 4px;
}

.legend {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-line {
  width: 18px;
  height: 0;
  border-top: 2px solid currentColor;
}

.details-panel {
  height: 100%;
  overflow: auto;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.detail-section {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.detail-section h4 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.kv {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.kv strong {
  color: var(--muted);
  font-size: 12px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(7, 14, 22, 0.82);
  color: var(--text);
  font-size: 12px;
}

pre {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(7, 14, 22, 0.84);
  color: #cce2ff;
  font: 12px/1.45 "IBM Plex Mono", "SFMono-Regular", monospace;
}

.empty {
  padding: 18px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1440px) {
  .shell {
    grid-template-columns: 320px minmax(0, 1fr) 340px;
  }

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

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar,
  .details {
    overflow: visible;
  }

  #graph {
    min-height: 520px;
  }
}
