.governance-flow {
  position: relative;
}

.governance-flow__stage {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 18px;
  margin-top: 34px;
}

.governance-flow__lane {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(18, 31, 22, 0.88), rgba(10, 16, 12, 0.92));
  padding: 24px;
}

.governance-flow__lane h3 {
  margin-bottom: 20px;
}

.governance-flow__diagram {
  display: block;
  width: 100%;
  min-height: 220px;
  color: var(--green);
}

.governance-flow__diagram marker path {
  fill: rgba(118, 255, 143, 0.82);
}

.gfc-node rect,
.gfc-evidence rect {
  fill: rgba(118, 255, 143, 0.075);
  stroke: rgba(118, 255, 143, 0.36);
  stroke-width: 1.4;
}

.gfc-node text,
.gfc-evidence text,
.gfc-govern-gate text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-anchor: middle;
}

.gfc-evidence text {
  fill: var(--green);
  font-size: 9px;
}

.gfc-path,
.gfc-evidence-link {
  fill: none;
  stroke: rgba(118, 255, 143, 0.72);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.gfc-path--late {
  stroke: rgba(255, 107, 107, 0.72);
  stroke-dasharray: 6 7;
}

.gfc-govern-gate {
  cursor: pointer;
  outline: none;
}

.gfc-govern-gate rect {
  fill: rgba(118, 255, 143, 0.14);
  stroke: rgba(118, 255, 143, 0.7);
  stroke-width: 1.8;
  filter: drop-shadow(0 0 18px rgba(118, 255, 143, 0.18));
}

.gfc-govern-gate path {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gfc-govern-gate:hover rect,
.gfc-govern-gate:focus-visible rect {
  stroke: var(--text);
  filter: drop-shadow(0 0 26px rgba(118, 255, 143, 0.3));
}

.gfc-pulse {
  fill: var(--green);
  filter: drop-shadow(0 0 10px rgba(118, 255, 143, 0.8));
}

.gfc-pulse--fast {
  offset-path: path("M124 101 H244");
  animation: gfc-move 2.6s linear infinite;
}

.gfc-pulse--late {
  fill: var(--danger);
  offset-path: path("M307 142 V174 H166");
  animation: gfc-move 3.2s linear infinite 0.65s;
}

.gfc-pulse--governed-a {
  offset-path: path("M124 102 H184");
  animation: gfc-move 2.2s linear infinite;
}

.gfc-pulse--governed-b {
  offset-path: path("M300 102 H344");
  animation: gfc-move 2.2s linear infinite 1.1s;
}

.governance-flow__lane--governed:has(.gfc-govern-gate:hover) .gfc-pulse,
.governance-flow__lane--governed:has(.gfc-govern-gate:focus-visible) .gfc-pulse,
.governance-flow__lane--governed.is-paused .gfc-pulse {
  animation-play-state: paused;
}

.governance-flow__tooltip {
  position: absolute;
  right: 28px;
  top: 74px;
  z-index: 2;
  max-width: 278px;
  padding: 16px 18px;
  border: 1px solid rgba(118, 255, 143, 0.42);
  border-radius: 16px;
  background: rgba(5, 8, 6, 0.95);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.3);
  color: var(--muted);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 180ms ease;
}

.governance-flow__tooltip strong {
  display: block;
  color: var(--text);
  margin-bottom: 8px;
}

.governance-flow__tooltip ul {
  margin: 0;
  padding-left: 18px;
}

.governance-flow__lane--governed:has(.gfc-govern-gate:hover) .governance-flow__tooltip,
.governance-flow__lane--governed:has(.gfc-govern-gate:focus-visible) .governance-flow__tooltip,
.governance-flow__lane--governed.is-tooltip-open .governance-flow__tooltip {
  opacity: 1;
  transform: translateY(0);
}

.governance-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

body.governance-modal-open {
  overflow: hidden;
}

.governance-modal.is-open {
  display: flex;
}

.governance-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}

.governance-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  border: 1px solid rgba(118, 255, 143, 0.36);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(18, 31, 22, 0.98), rgba(5, 8, 6, 0.98));
  padding: 34px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

.governance-modal__panel h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.governance-modal__panel p {
  color: var(--muted);
}

.governance-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(118, 255, 143, 0.08);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

@keyframes gfc-move {
  from {
    offset-distance: 0%;
  }
  to {
    offset-distance: 100%;
  }
}

@media (max-width: 900px) {
  .governance-flow__stage {
    grid-template-columns: 1fr;
  }

  .governance-flow__tooltip {
    right: 18px;
    left: 18px;
    top: auto;
    bottom: 18px;
    max-width: none;
  }
}

@media (max-width: 560px) {
  .governance-flow__lane {
    padding: 18px;
    border-radius: 18px;
  }

  .governance-flow__diagram {
    min-height: 190px;
  }

  .governance-modal__panel {
    padding: 28px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gfc-pulse {
    animation: none;
    display: none;
  }
}
