:root {
  --bg: #0d1622;
  --bg-soft: #111e30;
  --panel: #17263a;
  --panel-soft: #1b2d44;
  --border: #30455f;
  --text: #f2f7ff;
  --muted: #9eb3d1;
  --accent: #35b09f;
  --ok: #87de9d;
  --warn: #ffc986;
  --danger: #ff8d85;
}

* {
  box-sizing: border-box;
}

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 0% -12%, rgba(53, 176, 159, 0.22), transparent),
    radial-gradient(900px 520px at 110% 0%, rgba(255, 201, 134, 0.16), transparent),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 22, 35, 0.8);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.topbar p {
  margin: 0.28rem 0 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.topbar-metrics {
  display: flex;
  gap: 0.44rem;
  flex-wrap: wrap;
}

.topbar-metrics span {
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 0.28rem 0.5rem;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.73rem;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.connection .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 6px rgba(255, 201, 134, 0.2);
}

.connection.live .dot {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(135, 222, 157, 0.2);
}

.two-pane {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 23rem 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 0.84rem;
  background: linear-gradient(180deg, rgba(27, 45, 68, 0.9), rgba(17, 30, 47, 0.94));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  padding: 0.66rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 0.87rem;
}

.panel-header span,
.panel-header code {
  color: var(--muted);
  font-size: 0.73rem;
}

.panel-tools {
  padding: 0.58rem 0.74rem;
  border-bottom: 1px solid rgba(48, 69, 95, 0.6);
}

.panel-tools input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.56rem;
  background: #0c1726;
  color: var(--text);
  padding: 0.46rem 0.58rem;
  font-size: 0.8rem;
}

.panel-tools input::placeholder {
  color: var(--muted);
}

.workflows-pane {
  min-height: 0;
}

.workflow-filters {
  display: flex;
  gap: 0.38rem;
  padding: 0.5rem 0.74rem;
  border-bottom: 1px solid rgba(48, 69, 95, 0.6);
}

.filter-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(11, 21, 34, 0.9);
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0.18rem 0.52rem;
  cursor: pointer;
}

.filter-chip.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(53, 176, 159, 0.2);
}

.workflow-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.62rem;
  display: flex;
  flex-direction: column;
  gap: 0.58rem;
}

.workflow-card {
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: rgba(12, 23, 35, 0.86);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workflow-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(53, 176, 159, 0.24);
}

.workflow-main {
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  width: 100%;
  padding: 0.56rem;
  cursor: pointer;
}

.workflow-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.workflow-head strong {
  font-size: 0.84rem;
}

.workflow-head time {
  color: var(--muted);
  font-size: 0.68rem;
}

.workflow-id {
  display: block;
  margin-top: 0.34rem;
  color: #d6e6ff;
  font-size: 0.67rem;
  line-height: 1.34;
  word-break: break-all;
}

.workflow-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  margin-top: 0.4rem;
}

.workflow-metrics span {
  border: 1px solid rgba(158, 179, 209, 0.46);
  border-radius: 999px;
  padding: 0.11rem 0.44rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.workflow-metrics span.tone-ok {
  color: var(--ok);
  border-color: rgba(135, 222, 157, 0.52);
}

.workflow-metrics span.tone-warn {
  color: var(--warn);
  border-color: rgba(255, 201, 134, 0.52);
}

.workflow-metrics span.tone-fail {
  color: var(--danger);
  border-color: rgba(255, 141, 133, 0.58);
}

.workflow-metrics span.tone-neutral {
  color: var(--muted);
  border-color: rgba(158, 179, 209, 0.46);
}

.workflow-error {
  margin: 0.4rem 0 0;
  color: var(--danger);
  font-size: 0.7rem;
  line-height: 1.35;
}

.pin-toggle {
  border: none;
  border-top: 1px solid rgba(48, 69, 95, 0.58);
  background: rgba(13, 24, 37, 0.96);
  color: var(--muted);
  padding: 0.32rem;
  font-size: 0.71rem;
  cursor: pointer;
}

.pin-toggle.active {
  color: #122131;
  background: rgba(53, 176, 159, 0.94);
}

.canvas-pane {
  min-height: 0;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 0.56rem 0.72rem;
  border-bottom: 1px solid rgba(48, 69, 95, 0.6);
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.toolbar-group span,
.toolbar-group button {
  border: 1px solid var(--border);
  border-radius: 0.46rem;
  background: rgba(11, 21, 34, 0.9);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0.22rem 0.46rem;
}

.toolbar-group button {
  cursor: pointer;
}

.toolbar-group button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.canvas-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(158, 179, 209, 0.2) 1px, transparent 0);
  background-size: 20px 20px;
  cursor: grab;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: top left;
}

.canvas-edges {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.canvas-edge {
  fill: none;
  stroke: rgba(120, 157, 196, 0.5);
  stroke-width: 2;
}

.canvas-edge.active {
  stroke: rgba(70, 214, 193, 0.9);
  stroke-width: 2.4;
}

.canvas-nodes {
  position: absolute;
  inset: 0;
}

.canvas-node {
  position: absolute;
  width: 236px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 0.74rem;
  background: linear-gradient(160deg, rgba(15, 27, 43, 0.95), rgba(12, 23, 36, 0.95));
  color: inherit;
  text-align: left;
  padding: 0.52rem 0.58rem;
  cursor: pointer;
}

.canvas-node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(53, 176, 159, 0.3);
}

.canvas-node header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.canvas-node header strong {
  font-size: 0.79rem;
}

.canvas-node header time {
  color: var(--muted);
  font-size: 0.66rem;
}

.node-meta {
  margin-top: 0.32rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.67rem;
}

.node-badges {
  margin-top: 0.34rem;
  display: flex;
  gap: 0.32rem;
  flex-wrap: wrap;
}

.node-badges span {
  border: 1px solid rgba(158, 179, 209, 0.44);
  border-radius: 999px;
  padding: 0.1rem 0.42rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.node-badges span.tone-ok {
  color: var(--ok);
  border-color: rgba(135, 222, 157, 0.52);
}

.node-badges span.tone-warn {
  color: var(--warn);
  border-color: rgba(255, 201, 134, 0.52);
}

.node-badges span.tone-fail {
  color: var(--danger);
  border-color: rgba(255, 141, 133, 0.58);
}

.node-badges span.tone-neutral {
  color: var(--muted);
  border-color: rgba(158, 179, 209, 0.46);
}

.canvas-inspector {
  position: absolute;
  top: 0.66rem;
  right: 0.66rem;
  width: min(30rem, 44%);
  max-height: calc(100% - 1.32rem);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 0.74rem;
  background: rgba(9, 18, 31, 0.92);
  backdrop-filter: blur(7px);
  padding: 0.58rem;
  z-index: 5;
}

.canvas-inspector header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.canvas-inspector h3 {
  margin: 0;
  font-size: 0.84rem;
}

.canvas-inspector header span {
  color: var(--muted);
  font-size: 0.7rem;
}

.inspector-meta {
  margin-top: 0.42rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.inspector-meta code,
.inspector-meta span {
  border: 1px solid rgba(158, 179, 209, 0.42);
  border-radius: 0.45rem;
  padding: 0.14rem 0.38rem;
  color: var(--muted);
  font-size: 0.67rem;
}

.canvas-inspector details {
  margin-top: 0.52rem;
  border: 1px solid rgba(48, 69, 95, 0.75);
  border-radius: 0.6rem;
  background: rgba(8, 15, 25, 0.9);
  padding: 0.42rem 0.5rem;
}

.canvas-inspector summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.72rem;
}

.canvas-inspector pre {
  margin: 0.38rem 0 0;
  max-height: 13rem;
  overflow: auto;
  border: 1px solid rgba(48, 69, 95, 0.75);
  border-radius: 0.48rem;
  background: #09121f;
  padding: 0.46rem;
  font-size: 0.69rem;
}

.inspector-list {
  margin: 0.42rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.inspector-list li {
  border: 1px solid rgba(48, 69, 95, 0.75);
  border-radius: 0.52rem;
  background: rgba(8, 15, 25, 0.86);
  padding: 0.32rem 0.4rem;
}

.inspector-list.compact li {
  padding: 0.28rem 0.34rem;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.row-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-head code {
  font-size: 0.68rem;
}

.row-meta {
  margin-top: 0.26rem;
  display: flex;
  gap: 0.34rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.66rem;
}

.ops-mini-grid {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.32rem;
}

.ops-mini-grid span {
  border: 1px solid rgba(48, 69, 95, 0.75);
  border-radius: 0.46rem;
  padding: 0.16rem 0.36rem;
  color: var(--muted);
  font-size: 0.67rem;
  background: rgba(8, 15, 25, 0.86);
}

.inspector-footer {
  margin-top: 0.56rem;
  border-top: 1px solid rgba(48, 69, 95, 0.75);
  padding-top: 0.46rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.pill {
  border: 1px solid rgba(158, 179, 209, 0.46);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.63rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tone-ok {
  color: var(--ok);
  border-color: rgba(135, 222, 157, 0.52);
}

.tone-warn {
  color: var(--warn);
  border-color: rgba(255, 201, 134, 0.52);
}

.tone-fail {
  color: var(--danger);
  border-color: rgba(255, 141, 133, 0.58);
}

.tone-neutral {
  color: var(--muted);
  border-color: rgba(158, 179, 209, 0.46);
}

.muted-copy {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.empty-state {
  border: 1px dashed rgba(158, 179, 209, 0.44);
  border-radius: 0.7rem;
  padding: 1rem 0.8rem;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 0.2rem;
  color: var(--text);
  font-size: 0.88rem;
}

.empty-state p {
  margin: 0;
  font-size: 0.74rem;
}

.empty-state.center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(24rem, 92%);
}

.empty-state.error {
  border-color: rgba(255, 141, 133, 0.58);
  background: rgba(63, 27, 30, 0.34);
}

@media (max-width: 1400px) {
  .canvas-inspector {
    width: min(28rem, 50%);
  }
}

@media (max-width: 1200px) {
  .two-pane {
    grid-template-columns: 1fr;
  }

  .workflows-pane {
    max-height: 22rem;
  }

  .canvas-inspector {
    width: min(32rem, calc(100% - 1.32rem));
  }
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-metrics {
    width: 100%;
  }

  .canvas-inspector {
    position: static;
    width: auto;
    max-height: none;
    margin: 0.65rem;
  }

  .canvas-stage {
    min-width: 100%;
  }
}
