:root {
  --bg: #071019;
  --bg2: #0a1521;
  --panel: #0e1b29;
  --panel2: #112233;
  --line: #1d3448;
  --muted: #8ea3b5;
  --text: #edf6fb;
  --cyan: #59e1cf;
  --blue: #6ea8ff;
  --amber: #f0bd65;
  --rose: #f07d8b;
  --green: #7fe19b;
  --shadow: 0 22px 60px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 75% -20%, #153f50 0, transparent 35%), var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100vh;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(5, 13, 21, .88);
  backdrop-filter: blur(18px);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 30px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--cyan), #2a90b2);
  display: grid;
  place-items: center;
  color: #04221f;
  font: 700 20px 'Space Grotesk';
  box-shadow: 0 0 32px rgba(89, 225, 207, .28);
}

.brand strong {
  display: block;
  font: 700 18px 'Space Grotesk';
  letter-spacing: .06em;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .11em;
  text-transform: uppercase;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #8fa5b6;
  text-align: left;
  padding: 12px 14px;
  border-radius: 11px;
  font: 600 14px inherit;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: .2s;
}

.nav-item span {
  font-size: 17px;
}

.nav-item:hover,
.nav-item.active {
  background: #102435;
  color: var(--text);
}

.nav-item.active {
  box-shadow: inset 3px 0 var(--cyan);
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 18px 5px 0;
  display: grid;
  gap: 12px;
}

.sidebar-foot label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .09em;
}

.sidebar-foot input,
.sidebar-foot select {
  width: 100%;
  margin-top: 6px;
}

main {
  padding: 28px 36px 48px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--cyan);
  font: 600 10px 'Space Grotesk';
  letter-spacing: .18em;
  margin: 0 0 7px;
}

.topbar h1 {
  font: 600 30px 'Space Grotesk';
  margin: 0;
}

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

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(127, 225, 155, .1);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: linear-gradient(150deg, rgba(18, 38, 55, .94), rgba(10, 25, 37, .94));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.metric small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.metric strong {
  font: 600 25px 'Space Grotesk';
  display: block;
  margin-top: 6px;
}

.metric em {
  font-style: normal;
  color: var(--cyan);
  font-size: 11px;
}

.panel {
  background: linear-gradient(160deg, rgba(14, 27, 41, .98), rgba(7, 20, 31, .98));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

h2 {
  font: 600 21px 'Space Grotesk';
  margin: 0 0 5px;
}

.panel-head p,
.lead {
  color: var(--muted);
  margin: 0;
  font-size: 13px;
}

.controls {
  display: flex;
  gap: 8px;
}

.network-controls {
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

input,
select,
textarea {
  background: #091722;
  border: 1px solid #234058;
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: 500 13px inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(89, 225, 207, .08);
}

.graph-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid #264359;
  background: #112637;
  color: #c3d4df;
  font: 700 17px/1 inherit;
  cursor: pointer;
}

.icon-button:hover,
.ghost:hover {
  border-color: #3a6684;
  filter: brightness(1.08);
}

.network-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 620px;
}

.graph-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background-image:
    linear-gradient(rgba(70, 105, 128, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 105, 128, .05) 1px, transparent 1px);
  background-size: 28px 28px;
}

.graph-wrap.dragging #graph {
  cursor: grabbing;
}

#graph {
  width: 100%;
  height: 620px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.edge {
  stroke: #29445a;
  stroke-width: 1;
  opacity: .48;
  pointer-events: none;
  transition: opacity .16s, stroke .16s, stroke-width .16s;
}

.edge.edge-active {
  stroke: var(--cyan);
  stroke-width: 2.2;
  opacity: .95;
}

.edge.edge-dimmed {
  opacity: .1;
}

.node {
  cursor: pointer;
}

.node.fixed {
  cursor: grab;
}

.node.dragging {
  cursor: grabbing;
}

.node .hit-target {
  fill: transparent;
  stroke: transparent;
  stroke-width: 0;
  filter: none;
  pointer-events: all;
}

.node circle.main-node {
  stroke: #071019;
  stroke-width: 2.5;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .4));
  transition: opacity .16s, stroke .16s, stroke-width .16s;
}

.node:hover circle.main-node {
  stroke: var(--text);
}

.node.selected circle.main-node {
  stroke: var(--amber);
  stroke-width: 4;
}

.node.connected circle.main-node {
  stroke: var(--cyan);
  stroke-width: 3;
}

.node.fixed circle.main-node {
  stroke: #f0bd65;
}

.node.dimmed circle,
.node.dimmed .node-label {
  opacity: .22;
}

.node text,
.node-label {
  fill: #d8e6ee;
  font: 600 11px system-ui, sans-serif;
  pointer-events: none;
  paint-order: stroke;
  stroke: #06111a;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.node-label.hidden {
  display: none;
}

.graph-status {
  position: absolute;
  left: 18px;
  top: 15px;
  background: rgba(4, 13, 21, .78);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  padding: 8px 10px;
  pointer-events: none;
}

.legend {
  position: absolute;
  left: 18px;
  bottom: 16px;
  background: rgba(4, 13, 21, .78);
  border: 1px solid var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 80%;
}

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

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: block;
}

.inspector {
  border-left: 1px solid var(--line);
  padding: 22px;
  background: rgba(8, 20, 30, .76);
  overflow: auto;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 100px 20px;
}

.empty-state span {
  font-size: 38px;
  color: #29485e;
}

.empty-state h3 {
  color: var(--text);
  margin: 13px 0 6px;
}

.artifact-kicker {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--cyan);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.artifact-title {
  font: 600 20px 'Space Grotesk';
  line-height: 1.25;
  margin: 12px 0;
}

.confidence-bar {
  height: 6px;
  background: #1a3041;
  border-radius: 9px;
  overflow: hidden;
  margin: 10px 0 18px;
}

.confidence-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.kv {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.kv div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.kv small {
  color: var(--muted);
  display: block;
  font-size: 10px;
  text-transform: uppercase;
}

.kv code {
  font-size: 11px;
  color: #cce2ed;
  word-break: break-word;
}

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

.chip {
  border: 1px solid #2a465a;
  color: #a9bfcd;
  border-radius: 99px;
  padding: 4px 8px;
  font-size: 10px;
}

.table-wrap {
  max-height: 650px;
  overflow: auto;
}

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

th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .09em;
  padding: 13px 20px;
  background: #0a1925;
  position: sticky;
  top: 0;
}

td {
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

tr:hover td {
  background: #102433;
}

.confidence-pill {
  border-radius: 99px;
  padding: 4px 8px;
  background: #163043;
  color: var(--cyan);
  font-size: 11px;
}

.query-grid {
  display: grid;
  grid-template-columns: 38% 62%;
  min-height: 620px;
}

.query-composer {
  padding: 34px;
  border-right: 1px solid var(--line);
}

.query-composer textarea {
  width: 100%;
  height: 180px;
  resize: vertical;
  margin: 22px 0 12px;
  line-height: 1.55;
}

.primary,
.ghost {
  border-radius: 9px;
  padding: 10px 15px;
  border: 0;
  font: 600 13px inherit;
  cursor: pointer;
}

.primary {
  background: linear-gradient(130deg, var(--cyan), #54b7e1);
  color: #062522;
}

.primary:hover {
  filter: brightness(1.08);
}

.ghost {
  background: #112637;
  color: #c3d4df;
  border: 1px solid #264359;
}

.compact {
  padding: 8px 10px;
  min-height: 34px;
}

.query-composer .primary {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}

.answer-card {
  padding: 34px;
  overflow: auto;
}

.answer-card .empty-state {
  padding-top: 120px;
}

.answer-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.answer-head h2 {
  font-size: 25px;
}

.score-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--cyan) var(--score), #193244 0);
  position: relative;
}

.score-ring:after {
  content: '';
  position: absolute;
  inset: 5px;
  background: var(--panel);
  border-radius: 50%;
}

.score-ring b {
  z-index: 1;
  font-size: 12px;
}

.summary {
  font-size: 15px;
  line-height: 1.65;
  color: #d3e3eb;
  border-left: 3px solid var(--cyan);
  padding-left: 15px;
}

.claim {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 13px;
  margin-top: 9px;
  background: #0a1925;
}

.claim small {
  color: var(--cyan);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: .1em;
}

.claim p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.missing {
  margin-top: 16px;
  border: 1px solid rgba(240, 189, 101, .35);
  background: rgba(240, 189, 101, .07);
  color: #f2cf91;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
}

.review-list {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.review {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  background: #0a1925;
}

.review h3 {
  font-size: 15px;
  margin: 0 0 6px;
}

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

.review-meta {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.state {
  padding: 4px 8px;
  border-radius: 99px;
  font-size: 10px;
  background: #173246;
  color: var(--blue);
}

.state.open {
  color: var(--amber);
}

.review-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.template-grid {
  display: grid;
  grid-template-columns: 35% 65%;
  min-height: 650px;
}

.template-grid > div {
  padding: 30px;
}

.template-list {
  display: grid;
  gap: 7px;
  margin-top: 20px;
  max-height: 460px;
  overflow: auto;
}

.template-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  display: flex;
  justify-content: space-between;
}

.template-item small {
  color: var(--muted);
}

.editor {
  border-left: 1px solid var(--line);
  background: #081620;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.editor textarea {
  width: 100%;
  height: 520px;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 16px;
  background: #163245;
  border: 1px solid #2b5269;
  border-radius: 10px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .25s;
  font-size: 13px;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.error {
  border-color: var(--rose);
  color: #ffc4cc;
}

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

  .brand div,
  .nav-item:not(.active) {
    font-size: 0;
  }

  .brand {
    padding-left: 3px;
  }

  .nav-item {
    justify-content: center;
  }

  .sidebar-foot {
    display: none;
  }

  main {
    padding: 22px 18px 36px;
  }

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

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

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

  .inspector,
  .query-composer,
  .editor {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .network-controls,
  .controls {
    width: 100%;
  }

  .network-controls input,
  .network-controls select {
    flex: 1 1 170px;
    min-width: 0;
  }

  .graph-actions {
    width: 100%;
  }

  .graph-actions .compact {
    flex: 1;
  }

  .legend {
    max-height: 120px;
    overflow: auto;
  }
}
