.mm-root {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Light blue canvas background (Meta-ish) */
.mm-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #eef4ff;
}

.mm-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(180deg, rgba(238, 244, 255, 0.92), rgba(238, 244, 255, 0.78));
  backdrop-filter: blur(6px);
  z-index: 20;
  transition: opacity 160ms ease;
}
.mm-loading[hidden] {
  opacity: 0;
  pointer-events: none;
}
.mm-loading .mm-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(24, 119, 242, 0.25);
  border-top-color: rgba(24, 119, 242, 0.95);
  border-radius: 999px;
  animation: mmspin 0.8s linear infinite;
}
@keyframes mmspin {
  to { transform: rotate(360deg); }
}
.mm-loading .mm-loading-text {
  font-size: 0.95rem;
  color: rgba(0, 0, 0, 0.7);
}

.mm-controls {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mm-controls .mm-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(24, 119, 242, 0.16);
  background: rgba(255, 255, 255, 0.82);
  color: rgba(0, 0, 0, 0.72);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.mm-controls .mm-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(24, 119, 242, 0.3);
}
.mm-controls .mm-btn:active { transform: translateY(0); }
.mm-controls .mm-btn:focus-visible {
  outline: 2px solid rgba(24, 119, 242, 0.5);
  outline-offset: 2px;
}

.mm-zoom-hud {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 25;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(24, 119, 242, 0.16);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  font-size: 0.9rem;
  color: rgba(0, 0, 0, 0.68);
  user-select: none;
}

.mm-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}
.mm-viewport.is-grabbing {
  cursor: grabbing;
}

/* The element that we pan/zoom */
.mm-content {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* Mermaid */
.mm-content .mermaid {
  display: block;
  margin: 0;
}

/* Keep SVG crisp and allow huge diagrams */
.mm-content svg {
  max-width: none !important;
  height: auto;
}

/* Nós clicáveis: cursor pointer (JS pinta cores por estágio; clicáveis = traço forte, demais = muted) */
.mm-content .clickable,
.mm-content .clickable_step,
.mm-content [data-mm-clickable="1"] {
  cursor: pointer;
}
/* Nós não clicáveis: cursor default para deixar claro que não abrem modal */
.mm-content svg .node:not(.clickable_step):not([class*="clickable_step"]),
.mm-content [data-mm-clickable="0"] {
  cursor: default;
}

/* Meta map: preserve/enforce Mermaid diagram colors (clusters + nodes) */
.mm-content svg .cluster rect,
.mm-canvas svg .cluster rect {
  fill: #eef4ff;
  stroke: #6c757d;
  stroke-width: 2px;
}
.mm-content svg [id="REQ"] rect,
.mm-content svg [id^="REQ-"] rect,
.mm-canvas svg [id="REQ"] rect,
.mm-canvas svg [id^="REQ-"] rect {
  fill: #cfe2ff !important;
  stroke: #0d6efd !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="WAB"] rect,
.mm-content svg [id^="WAB-"] rect,
.mm-canvas svg [id="WAB"] rect,
.mm-canvas svg [id^="WAB-"] rect {
  fill: #fff3cd !important;
  stroke: #ffc107 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="CON"] rect,
.mm-content svg [id^="CON-"] rect,
.mm-canvas svg [id="CON"] rect,
.mm-canvas svg [id^="CON-"] rect {
  fill: #ffe5d0 !important;
  stroke: #fd7e14 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="TMP"] rect,
.mm-content svg [id^="TMP-"] rect,
.mm-canvas svg [id="TMP"] rect,
.mm-canvas svg [id^="TMP-"] rect {
  fill: #ffe5d0 !important;
  stroke: #fd7e14 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="LIVE"] rect,
.mm-content svg [id^="LIVE-"] rect,
.mm-canvas svg [id="LIVE"] rect,
.mm-canvas svg [id^="LIVE-"] rect {
  fill: #d1fae5 !important;
  stroke: #10b981 !important;
  stroke-width: 2px !important;
}
/* Nodes: default (fallback) */
.mm-content svg .node rect,
.mm-content svg .node path,
.mm-content svg .node polygon,
.mm-canvas svg .node rect,
.mm-canvas svg .node path,
.mm-canvas svg .node polygon {
  fill: #e9ecef;
  stroke: #6c757d;
  stroke-width: 2px;
}

/* Nodes by stage (jornada de implantação) – same as cluster colors */
.mm-content svg [id="REQ"] .node rect,
.mm-content svg [id^="REQ-"] .node rect,
.mm-content svg [id="REQ"] .node path,
.mm-content svg [id^="REQ-"] .node path,
.mm-content svg [id="REQ"] .node polygon,
.mm-content svg [id^="REQ-"] .node polygon,
.mm-canvas svg [id="REQ"] .node rect,
.mm-canvas svg [id^="REQ-"] .node rect,
.mm-canvas svg [id="REQ"] .node path,
.mm-canvas svg [id^="REQ-"] .node path,
.mm-canvas svg [id="REQ"] .node polygon,
.mm-canvas svg [id^="REQ-"] .node polygon {
  fill: #cfe2ff !important;
  stroke: #0d6efd !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="WAB"] .node rect,
.mm-content svg [id^="WAB-"] .node rect,
.mm-content svg [id="WAB"] .node path,
.mm-content svg [id^="WAB-"] .node path,
.mm-content svg [id="WAB"] .node polygon,
.mm-content svg [id^="WAB-"] .node polygon,
.mm-canvas svg [id="WAB"] .node rect,
.mm-canvas svg [id^="WAB-"] .node rect,
.mm-canvas svg [id="WAB"] .node path,
.mm-canvas svg [id^="WAB-"] .node path,
.mm-canvas svg [id="WAB"] .node polygon,
.mm-canvas svg [id^="WAB-"] .node polygon {
  fill: #fff3cd !important;
  stroke: #ffc107 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="CON"] .node rect,
.mm-content svg [id^="CON-"] .node rect,
.mm-content svg [id="CON"] .node path,
.mm-content svg [id^="CON-"] .node path,
.mm-content svg [id="CON"] .node polygon,
.mm-content svg [id^="CON-"] .node polygon,
.mm-canvas svg [id="CON"] .node rect,
.mm-canvas svg [id^="CON-"] .node rect,
.mm-canvas svg [id="CON"] .node path,
.mm-canvas svg [id^="CON-"] .node path,
.mm-canvas svg [id="CON"] .node polygon,
.mm-canvas svg [id^="CON-"] .node polygon {
  fill: #ffe5d0 !important;
  stroke: #fd7e14 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="TMP"] .node rect,
.mm-content svg [id^="TMP-"] .node rect,
.mm-content svg [id="TMP"] .node path,
.mm-content svg [id^="TMP-"] .node path,
.mm-content svg [id="TMP"] .node polygon,
.mm-content svg [id^="TMP-"] .node polygon,
.mm-canvas svg [id="TMP"] .node rect,
.mm-canvas svg [id^="TMP-"] .node rect,
.mm-canvas svg [id="TMP"] .node path,
.mm-canvas svg [id^="TMP-"] .node path,
.mm-canvas svg [id="TMP"] .node polygon,
.mm-canvas svg [id^="TMP-"] .node polygon {
  fill: #ffe5d0 !important;
  stroke: #fd7e14 !important;
  stroke-width: 2px !important;
}
.mm-content svg [id="LIVE"] .node rect,
.mm-content svg [id^="LIVE-"] .node rect,
.mm-content svg [id="LIVE"] .node path,
.mm-content svg [id^="LIVE-"] .node path,
.mm-content svg [id="LIVE"] .node polygon,
.mm-content svg [id^="LIVE-"] .node polygon,
.mm-canvas svg [id="LIVE"] .node rect,
.mm-canvas svg [id^="LIVE-"] .node rect,
.mm-canvas svg [id="LIVE"] .node path,
.mm-canvas svg [id^="LIVE-"] .node path,
.mm-canvas svg [id="LIVE"] .node polygon,
.mm-canvas svg [id^="LIVE-"] .node polygon {
  fill: #d1fae5 !important;
  stroke: #10b981 !important;
  stroke-width: 2px !important;
}
.mm-content svg .nodeLabel,
.mm-content svg .node label,
.mm-content svg .edgeLabel,
.mm-canvas svg .nodeLabel,
.mm-canvas svg .node label,
.mm-canvas svg .edgeLabel {
  fill: #212529;
}
.mm-content svg .edgePath path,
.mm-content svg path.edge-path,
.mm-canvas svg .edgePath path,
.mm-canvas svg path.edge-path {
  stroke: #6c757d;
}
.mm-content svg marker path,
.mm-canvas svg marker path {
  fill: #6c757d;
  stroke: #6c757d;
}

/* Legenda: jornada de implantação */
.mm-legend {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 15;
  padding: 8px 12px 10px;
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.72);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  pointer-events: none;
  user-select: none;
  max-width: 200px;
}
.mm-legend-title {
  font-weight: 700;
  margin: 0 0 8px 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(0, 0, 0, 0.5);
}
.mm-legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mm-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}
.mm-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1.5px solid;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.mm-legend-swatch.req { background: #cfe2ff; border-color: #0d6efd; }
.mm-legend-swatch.wab { background: #fff3cd; border-color: #ffc107; }
.mm-legend-swatch.con,
.mm-legend-swatch.tmp { background: #ffe5d0; border-color: #fd7e14; }
.mm-legend-swatch.live { background: #d1fae5; border-color: #10b981; }
.mm-legend-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  font-size: 0.68rem;
  color: rgba(0, 0, 0, 0.5);
  min-width: 24px;
}
.mm-legend-label { font-weight: 600; color: rgba(0, 0, 0, 0.88); }
.mm-legend-desc { color: rgba(0, 0, 0, 0.5); font-size: 0.68rem; margin-left: 2px; }

/* Active legend item: highlight code */
.mm-legend-item.is-active .mm-legend-code {
  color: rgba(0, 0, 0, 0.85);
}
@media (min-width: 768px) {
  .mm-legend { bottom: 10px; padding: 10px 14px 12px; }
  .mm-legend-title { margin-bottom: 8px; }
  .mm-legend-list { gap: 5px; }
}

/* ===== RPG-INSPIRED VISUAL ENHANCEMENTS ===== */

/* Smooth node transitions */
.mm-content svg .node,
.mm-canvas svg .node {
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* Hover shadow only on clickable nodes */
.mm-content svg .node.clickable_step:hover,
.mm-content svg .node[class*="clickable_step"]:hover,
.mm-canvas svg .node.clickable_step:hover,
.mm-canvas svg .node[class*="clickable_step"]:hover {
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.15));
}
.mm-content svg [id*="REQ"] .node.clickable_step:hover rect,
.mm-content svg [id*="REQ"] .node[class*="clickable_step"]:hover rect,
.mm-canvas svg [id*="REQ"] .node.clickable_step:hover rect,
.mm-canvas svg [id*="REQ"] .node[class*="clickable_step"]:hover rect {
  filter: drop-shadow(0 0 12px rgba(13, 110, 253, 0.4));
}
.mm-content svg [id*="WAB"] .node.clickable_step:hover rect,
.mm-content svg [id*="WAB"] .node[class*="clickable_step"]:hover rect,
.mm-canvas svg [id*="WAB"] .node.clickable_step:hover rect,
.mm-canvas svg [id*="WAB"] .node[class*="clickable_step"]:hover rect {
  filter: drop-shadow(0 0 12px rgba(255, 193, 7, 0.4));
}
.mm-content svg [id*="CON"] .node.clickable_step:hover rect,
.mm-content svg [id*="TMP"] .node.clickable_step:hover rect,
.mm-content svg [id*="CON"] .node[class*="clickable_step"]:hover rect,
.mm-content svg [id*="TMP"] .node[class*="clickable_step"]:hover rect,
.mm-canvas svg [id*="CON"] .node.clickable_step:hover rect,
.mm-canvas svg [id*="TMP"] .node.clickable_step:hover rect,
.mm-canvas svg [id*="CON"] .node[class*="clickable_step"]:hover rect,
.mm-canvas svg [id*="TMP"] .node[class*="clickable_step"]:hover rect {
  filter: drop-shadow(0 0 12px rgba(253, 126, 20, 0.4));
}
.mm-content svg [id*="LIVE"] .node.clickable_step:hover rect,
.mm-content svg [id*="LIVE"] .node[class*="clickable_step"]:hover rect,
.mm-canvas svg [id*="LIVE"] .node.clickable_step:hover rect,
.mm-canvas svg [id*="LIVE"] .node[class*="clickable_step"]:hover rect {
  filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.4));
}

/* Cluster (subgraph) title styling */
.mm-content svg .cluster-label,
.mm-canvas svg .cluster-label {
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Edge/arrow styling - subtle animation on hover */
.mm-content svg .edgePath path,
.mm-canvas svg .edgePath path {
  stroke-dasharray: none;
  transition: stroke-width 0.15s ease;
}

/* Completed node pulse animation */
@keyframes mmNodePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(25, 135, 84, 0); }
}

.mm-node-done {
  animation: mmNodePulse 2s ease-in-out infinite;
}

/* Icon container styling for Mermaid icons */
.mm-content svg .icon,
.mm-canvas svg .icon {
  fill: currentColor;
  width: 24px;
  height: 24px;
}

/* Better text rendering in nodes */
.mm-content svg .nodeLabel,
.mm-canvas svg .nodeLabel {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 12px;
  font-weight: 500;
}

/* Progress indicator styling */
.mm-progress-badge {
  position: absolute;
  top: 8px;
  right: 80px;
  z-index: 15;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.65);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  pointer-events: none;
  user-select: none;
}

.mm-progress-badge .progress-icon {
  color: #198754;
  margin-right: 4px;
}

/* Mobile responsiveness */
@media (max-width: 576px) {
  .mm-legend {
    left: 4px;
    bottom: 4px;
    padding: 6px 8px;
    font-size: 0.6rem;
    max-width: 160px;
  }
  .mm-legend-swatch {
    width: 10px;
    height: 10px;
  }
  .mm-legend-item {
    gap: 6px;
  }
  .mm-stage-indicator {
    top: 10px;
    right: 50px;
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 16px;
  }
  .mm-stage-icon {
    width: 10px;
    height: 10px;
  }
}

/* Stage indicator animations */
.mm-stage-indicator {
  animation: stageIndicatorPulse 0.4s ease-out;
}
@keyframes stageIndicatorPulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* Legend active item animation */
.mm-legend-item.is-active .mm-legend-swatch {
  animation: legendSwatchGlow 1.5s ease-in-out infinite;
}
@keyframes legendSwatchGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 0 4px currentColor; }
  50% { box-shadow: 0 0 0 3px rgba(255,255,255,0.9), 0 0 10px currentColor; }
}