:root {
  --workflow-blue: #356d8a;
  --workflow-green: #2e7d6e;
  --workflow-grey: #59636f;
  --workflow-purple: #7a2d7f;
  --workflow-amber: #a46522;
  --workflow-canvas: #edf1f4;
  --workflow-panel: #ffffff;
  --workflow-line: #d5dee7;
}

body.workflow-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #f4f6f8;
}

body.workflow-panel-expanded {
  overflow: hidden;
}

.workflow-page .site-header {
  flex: 0 0 auto;
}

.workflow-page .top-nav a[aria-current="page"] {
  background: #eef2f7;
  color: var(--ink);
}

.workflow-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 20px;
}

.workflow-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 0 2px 16px;
}

.workflow-summary__copy {
  min-width: 0;
  max-width: 1040px;
}

.workflow-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #728095;
  font-size: 0.76rem;
  font-weight: 700;
}

.workflow-breadcrumb a {
  color: var(--workflow-blue);
  text-decoration: none;
}

.workflow-breadcrumb a:hover,
.workflow-breadcrumb a:focus-visible {
  color: var(--workflow-green);
  outline: none;
}

.workflow-summary .eyebrow {
  margin-bottom: 5px;
  color: var(--workflow-green);
}

.workflow-summary h1 {
  max-width: none;
  margin: 0 0 6px;
  font-size: 1.55rem;
  line-height: 1.15;
}

.workflow-summary__copy > p:last-child {
  max-width: 940px;
  margin: 0;
  color: #5d6a7d;
  font-size: 0.9rem;
  line-height: 1.45;
}

.workflow-summary__meta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 0 0 auto;
}

.map-facts {
  display: flex;
  align-items: stretch;
  margin: 0;
}

.map-facts > div {
  min-width: 70px;
  padding: 0 14px;
  border-left: 1px solid var(--workflow-line);
  text-align: center;
}

.map-facts dt {
  color: #778497;
  font-size: 0.66rem;
  font-weight: 760;
  text-transform: uppercase;
}

.map-facts dd {
  margin: 3px 0 0;
  color: #243044;
  font-size: 1rem;
  font-weight: 820;
}

.workflow-browser {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--workflow-line);
  border-radius: 8px;
  background: var(--workflow-panel);
  box-shadow: 0 16px 38px rgba(20, 39, 63, 0.08);
}

.workflow-navigation {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--workflow-line);
  background: #f8fafb;
}

.workflow-navigation__heading {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--workflow-line);
}

.workflow-navigation__eyebrow {
  margin: 0 0 5px;
  color: var(--workflow-green);
  font-size: 0.7rem;
  font-weight: 820;
  text-transform: uppercase;
}

.workflow-navigation h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.map-navigation__group {
  padding: 16px 10px 4px;
}

.map-navigation__group + .map-navigation__group {
  margin-top: 5px;
  border-top: 1px solid #e3e8ee;
}

.map-navigation__group > p {
  margin: 0 8px 8px;
  color: #738094;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.map-navigation__item {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  min-height: 56px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #536174;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.map-navigation__item:hover,
.map-navigation__item:focus-visible {
  background: #eef3f4;
  color: #243044;
  outline: none;
}

.map-navigation__item.is-active {
  background: #e7f2ef;
  color: #193f3a;
}

.map-navigation__item.is-active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--workflow-green);
  content: "";
}

.map-navigation__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #cdd7e0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--workflow-blue);
  font-size: 0.68rem;
  font-weight: 840;
}

.map-navigation__label {
  display: block;
  min-width: 0;
}

.map-navigation__label strong,
.map-navigation__label small {
  display: block;
  overflow-wrap: anywhere;
}

.map-navigation__label strong {
  color: inherit;
  font-size: 0.79rem;
  font-weight: 760;
  line-height: 1.3;
}

.map-navigation__label small {
  margin-top: 3px;
  color: #7a8798;
  font-size: 0.66rem;
  font-weight: 680;
  line-height: 1.2;
  text-transform: uppercase;
}

.map-navigation__group--pending {
  margin: 14px 10px 0;
  padding: 16px 0 6px;
  border-top: 1px solid #e3e8ee;
}

.map-navigation__group--pending .map-navigation__item {
  cursor: default;
  opacity: 0.62;
}

.map-panel {
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.map-toolbar,
.map-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 12px 0 16px;
  min-width: 0;
}

.map-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  border-bottom: 1px solid var(--workflow-line);
}

.map-toolbar__identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #344257;
  font-size: 0.82rem;
  font-weight: 760;
}

.map-toolbar__identity span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-toolbar__accent {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--workflow-green);
  box-shadow: 0 0 0 4px rgba(46, 125, 110, 0.12);
}

.map-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  justify-self: end;
}

.map-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 300px;
  padding: 3px;
  border: 1px solid #cbd5df;
  border-radius: 7px;
  background: #eef2f5;
}

.map-mode-switch__button {
  min-width: 0;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #667589;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 780;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease;
}

.map-mode-switch__button:hover,
.map-mode-switch__button:focus-visible {
  color: #244d48;
  outline: none;
}

.map-mode-switch__button.is-active {
  background: #ffffff;
  color: #1f5f56;
  box-shadow: 0 1px 4px rgba(36, 48, 68, 0.16);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  background: #ffffff;
  color: #405066;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #8dbdaf;
  background: #edf7f4;
  color: var(--workflow-green);
  outline: none;
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button svg,
.map-statusbar svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button--quiet {
  border-color: transparent;
}

.zoom-value {
  width: 50px;
  color: #627085;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  text-align: center;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--workflow-line);
}

.map-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background-color: var(--workflow-canvas);
  background-image:
    linear-gradient(rgba(89, 99, 111, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(89, 99, 111, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
  touch-action: none;
}

.map-viewport:focus-visible {
  outline: 2px solid var(--workflow-green);
  outline-offset: -2px;
}

.map-viewport.is-dragging {
  cursor: grabbing;
}

.map-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-content svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  background: #f4f6f8;
  box-shadow: 0 14px 30px rgba(36, 48, 68, 0.14);
  user-select: none;
}

.map-content .reference-template-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(36, 48, 68, 0.14);
  user-select: none;
}

.map-content svg .map-node,
.map-content svg .map-connection,
.map-content svg [data-exchange-id],
.map-content svg [data-map-tooltip="true"] {
  transition:
    filter 160ms ease,
    opacity 160ms ease;
}

.map-content svg text.map-input-summary {
  font-size: 13px;
}

.map-content svg text.map-input-title {
  font-size: 15.5px;
}

.map-content svg text.map-exchange-summary {
  font-size: 12.5px;
}

.map-content svg .map-node,
.map-content svg [data-map-tooltip="true"]:hover,
.map-content svg [data-map-tooltip="true"]:focus-visible {
  cursor: pointer;
  outline: none;
}

.map-content svg .map-node {
  pointer-events: all;
}

.map-content svg > rect[width][height] {
  pointer-events: none;
}

.map-content svg .map-connection {
  pointer-events: none;
}

.map-content svg [id^="group-"],
.map-content svg [id^="lane-"],
.map-content svg [id^="phase-"],
.map-content svg [id^="group-"] *,
.map-content svg [id^="lane-"] *,
.map-content svg [id^="phase-"] * {
  pointer-events: none !important;
}

.map-content svg .map-node.is-node-hovered,
.map-content svg .map-node:focus-visible {
  filter:
    drop-shadow(0 0 5px var(--map-highlight-color))
    drop-shadow(0 7px 7px rgba(36, 48, 68, 0.18));
}

.map-content svg .map-node.is-node-hovered > rect:first-of-type,
.map-content svg .map-node.is-node-hovered > polygon:first-of-type,
.map-content svg .map-node:focus-visible > rect:first-of-type,
.map-content svg .map-node:focus-visible > polygon:first-of-type {
  stroke-width: 2.8 !important;
}

.map-content svg.has-node-selection .map-node,
.map-content svg.has-node-selection .map-connection,
.map-content svg.has-node-selection [data-exchange-id] {
  opacity: 0.16;
}

.map-content svg.has-node-selection .map-node.is-primary-node,
.map-content svg.has-node-selection .map-node.is-connected-node,
.map-content svg.has-node-selection .map-connection.is-active-connection,
.map-content svg.has-node-selection .map-connection.is-active-exchange,
.map-content svg.has-node-selection [data-exchange-id].is-active-exchange {
  opacity: 1;
}

.map-content svg .map-node.is-primary-node {
  filter:
    drop-shadow(0 0 7px var(--map-highlight-color))
    drop-shadow(0 8px 8px rgba(36, 48, 68, 0.24));
}

.map-content svg .map-node.is-connected-node {
  filter:
    drop-shadow(0 0 4px var(--map-highlight-color))
    drop-shadow(0 5px 6px rgba(36, 48, 68, 0.18));
}

.map-content svg .map-node.is-primary-node > rect:first-of-type,
.map-content svg .map-node.is-primary-node > polygon:first-of-type {
  stroke-width: 3.4 !important;
}

.map-content svg .map-node.is-connected-node > rect:first-of-type,
.map-content svg .map-node.is-connected-node > polygon:first-of-type {
  stroke-width: 2.8 !important;
}

.map-content svg .map-connection.is-active-connection path,
.map-content svg .map-connection.is-active-exchange path,
.map-content svg path.map-connection.is-active-exchange,
.map-content svg path.map-connection.is-active-connection {
  stroke-width: 3 !important;
  stroke-opacity: 1 !important;
  filter: drop-shadow(0 0 3px var(--map-highlight-color));
}

.map-content svg [data-exchange-id].is-active-exchange:not(path) {
  filter: drop-shadow(0 0 4px var(--map-highlight-color));
}

.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 10px 12px;
  border: 1px solid var(--workflow-line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  color: #667589;
  font-size: 0.8rem;
  font-weight: 720;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 24px rgba(36, 48, 68, 0.09);
}

.map-loading[hidden] {
  display: none;
}

.map-tooltip {
  position: absolute;
  z-index: 8;
  width: min(340px, calc(100% - 20px));
  padding: 12px 13px;
  border: 1px solid #bdc9d4;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.98);
  color: #344257;
  box-shadow: 0 16px 34px rgba(20, 39, 63, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.map-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.map-tooltip__type {
  display: block;
  margin-bottom: 4px;
  color: var(--workflow-green);
  font-size: 0.61rem;
  font-weight: 840;
  text-transform: uppercase;
}

.map-tooltip strong {
  display: block;
  color: #243044;
  font-size: 0.82rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.map-tooltip p {
  margin: 6px 0 7px;
  color: #536175;
  font-size: 0.72rem;
  line-height: 1.42;
}

.map-tooltip__detail {
  display: block;
  padding-top: 7px;
  border-top: 1px solid #e0e6eb;
  color: #68778b;
  font-size: 0.65rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.node-inspector {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: min(350px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #cad4de;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(20, 39, 63, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.node-inspector.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.node-inspector__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.node-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 5px;
  background: #e8f3f0;
  color: var(--workflow-green);
  font-size: 0.64rem;
  font-weight: 840;
  text-transform: uppercase;
}

.node-status[data-status="research-prototype"] {
  background: #e8f1f6;
  color: var(--workflow-blue);
}

.node-status[data-status="planned"] {
  background: #f3e9f4;
  color: var(--workflow-purple);
}

.node-status[data-status="external"] {
  background: #eef0f2;
  color: var(--workflow-grey);
}

.node-inspector h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.28;
}

.node-inspector > p {
  margin: 0 0 14px;
  color: #536175;
  font-size: 0.82rem;
  line-height: 1.5;
}

.node-inspector__details {
  display: grid;
  gap: 10px;
  margin: 0;
}

.node-inspector__details > div {
  padding-top: 9px;
  border-top: 1px solid #e1e6eb;
}

.node-inspector__details dt {
  margin-bottom: 3px;
  color: #7a8798;
  font-size: 0.64rem;
  font-weight: 820;
  text-transform: uppercase;
}

.node-inspector__details dd {
  margin: 0;
  color: #344257;
  font-size: 0.76rem;
  line-height: 1.42;
}

.map-statusbar {
  border-top: 1px solid var(--workflow-line);
  color: #718095;
  font-size: 0.7rem;
  font-weight: 680;
}

.map-statusbar > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-statusbar a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--workflow-blue);
  font-weight: 800;
  text-decoration: none;
}

.map-statusbar a:hover,
.map-statusbar a:focus-visible {
  color: var(--workflow-green);
  outline: none;
}

.map-panel:fullscreen {
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  background: #ffffff;
}

.map-panel.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 100;
  grid-template-rows: 52px minmax(0, 1fr) 34px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

@media (max-width: 1040px) {
  .workflow-summary__meta {
    display: none;
  }

  .workflow-browser {
    grid-template-columns: 242px minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  body.workflow-page {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .workflow-page .site-header__inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px 0;
  }

  .workflow-page .top-nav {
    justify-content: flex-start;
  }

  .workflow-shell {
    display: block;
    width: min(100% - 24px, 1680px);
    padding: 14px 0 18px;
  }

  .workflow-summary {
    align-items: flex-start;
    padding-bottom: 14px;
  }

  .workflow-summary h1 {
    font-size: 1.32rem;
  }

  .workflow-browser {
    display: block;
    overflow: visible;
  }

  .workflow-navigation {
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--workflow-line);
  }

  .workflow-navigation__heading {
    padding: 14px 14px 10px;
  }

  .map-navigation {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 10px 12px;
    scrollbar-width: thin;
  }

  .map-navigation__group {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    padding: 0;
  }

  .map-navigation__group + .map-navigation__group {
    margin: 0;
    padding-left: 8px;
    border-top: 0;
    border-left: 1px solid #e3e8ee;
  }

  .map-navigation__group > p,
  .map-navigation__group--pending {
    display: none;
  }

  .map-navigation__item {
    width: 200px;
    min-height: 52px;
  }

  .map-panel {
    height: 620px;
  }

  .map-toolbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .map-toolbar__identity {
    display: none;
  }

  .map-mode-switch {
    justify-self: start;
  }

  .map-toolbar__actions {
    grid-column: 2;
  }
}

@media (max-width: 560px) {
  .workflow-page .site-header__inner {
    align-items: center;
    flex-direction: row;
    min-height: 54px;
    padding: 6px 0;
  }

  .workflow-page .top-nav {
    display: none;
  }

  .workflow-summary__copy > p:last-child {
    font-size: 0.82rem;
  }

  .workflow-breadcrumb {
    overflow: hidden;
    white-space: nowrap;
  }

  .workflow-summary h1 {
    font-size: 1.18rem;
  }

  .map-toolbar {
    grid-template-columns: 1fr;
    grid-template-rows: 39px 43px;
    align-content: center;
    padding: 4px 8px;
  }

  .map-toolbar__identity {
    display: none;
  }

  .map-toolbar__actions {
    grid-column: 1;
    justify-content: center;
    justify-self: center;
    width: 100%;
    min-width: 0;
  }

  .map-mode-switch {
    justify-self: center;
    width: min(230px, 100%);
  }

  .toolbar-divider,
  #actual-size {
    display: none;
  }

  .zoom-value {
    width: 42px;
  }

  .map-panel {
    height: 560px;
    grid-template-rows: 90px minmax(0, 1fr) 34px;
  }

  .map-panel:fullscreen,
  .map-panel.is-expanded {
    grid-template-rows: 90px minmax(0, 1fr) 34px;
  }

  .node-inspector {
    top: auto;
    right: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    max-height: 72%;
    transform: translateY(12px);
  }

  .node-inspector.is-open {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-navigation__item,
  .icon-button,
  .map-mode-switch__button,
  .map-tooltip,
  .node-inspector,
  .map-content svg .map-node,
  .map-content svg .map-connection,
  .map-content svg [data-exchange-id] {
    transition: none;
  }
}
