#content:has(> .topology-v2-page) {
  max-width: none;
  margin: 0;
  padding: 24px clamp(18px, 2vw, 34px) 40px;
}

.topology-v2-page {
  min-width: 0;
  width: 100%;
}

.topology-commandbar,
.topology-tools,
.diagram-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 14px;
}

.topology-commandbar label,
.topology-tools label {
  min-width: 180px;
  margin: 0;
}

.topology-mode {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel2);
}

.topology-mode button.active {
  color: #fff;
  background: var(--brand);
}

.topology-tools .muted {
  flex: 1 1 320px;
  align-self: center;
}

.diagram-actions {
  align-items: stretch;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.tool-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 10px;
  border-right: 1px solid var(--border);
}

.tool-group:last-child {
  border-right: 0;
}

.tool-group > span {
  width: 100%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-group button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tool-group .snap-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.tool-group .snap-control input {
  width: auto;
  margin: 0;
}

.selection-count {
  margin-left: 7px;
  color: var(--text);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.diagram-actions button,
.diagram-actions select {
  min-height: 36px;
}

#saveDiagram.dirty::after {
  content: " •";
  color: #fff3a3;
}

.topology-workspace {
  display: grid;
  grid-template-columns: minmax(170px, 210px) minmax(420px, 1fr) minmax(
      210px,
      270px
    );
  width: 100%;
  min-height: 680px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel2);
}

.topology-workspace.elements-collapsed {
  grid-template-columns: minmax(520px, 1fr) minmax(220px, 270px);
}

.topology-workspace.inspector-collapsed {
  grid-template-columns: minmax(180px, 210px) minmax(520px, 1fr);
}

.topology-workspace.elements-collapsed.inspector-collapsed {
  grid-template-columns: minmax(620px, 1fr);
}

.topology-workspace.elements-collapsed .topology-elements,
.topology-workspace.inspector-collapsed .topology-inspector {
  display: none;
}

.topology-workspace.operational {
  grid-template-columns: minmax(420px, 1fr) minmax(210px, 270px);
}

.topology-elements,
.topology-inspector {
  position: static;
  top: auto;
  display: block;
  min-width: 0;
  height: auto;
  padding: 16px;
  overflow: auto;
  color: var(--text);
  background: var(--panel);
}

.topology-inspector.compact {
  min-height: 0;
  padding: 14px;
}

.topology-elements {
  border-right: 1px solid var(--border);
}

.topology-inspector {
  border-left: 1px solid var(--border);
}

.topology-elements h3,
.topology-inspector h3 {
  margin-top: 0;
}

.topology-elements label {
  display: block;
  margin: 10px 0;
}

.topology-elements label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 7px;
}

.topology-elements input[type="checkbox"],
.pdf-sections input[type="checkbox"] {
  width: auto;
  flex: 0 0 auto;
}

.topology-elements .badge {
  margin-left: auto;
}

.topology-elements hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.topology-canvas {
  position: relative;
  min-width: 0;
  min-height: 680px;
  overflow: hidden;
  background-color: #0d1522;
  background-image: radial-gradient(
    circle,
    rgba(124, 148, 181, 0.16) 1px,
    transparent 1px
  );
  background-size: 22px 22px;
}

.topology-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 680px;
  touch-action: none;
  user-select: none;
}

.canvas-hint {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 7px;
  color: #aebbd0;
  background: rgba(8, 14, 24, 0.82);
  font-size: 11px;
  pointer-events: none;
}

.diagram-node {
  cursor: grab;
}

.diagram-node:active {
  cursor: grabbing;
}

.diagram-node > rect,
.diagram-node > path,
.diagram-node > polygon,
.diagram-node > ellipse {
  fill: #1b283b;
  stroke: #6f8bff;
  stroke-width: 2;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.24));
}

.diagram-node.kind-network > path {
  fill: #152b43;
  stroke: #4b9fff;
  stroke-width: 2.5;
}

.diagram-node.kind-vlan > rect {
  fill: #302a49;
  stroke: #aa8cff;
  stroke-width: 2.5;
}

.diagram-node.kind-asset > rect {
  fill: #252d3b;
  stroke: #8ea2bd;
}

.diagram-node.kind-wan > path {
  fill: #203452;
  stroke: #69a8ff;
}

.diagram-node.kind-firewall > polygon {
  fill: #3b2430;
  stroke: #ff728d;
}

.diagram-node.kind-router > polygon,
.diagram-node.kind-switch > rect {
  fill: #18363b;
  stroke: #43d0c1;
}

.diagram-node.kind-server > rect,
.diagram-node.kind-database > rect {
  fill: #2c2942;
  stroke: #ad8eff;
}

.diagram-node.kind-system > rect {
  fill: #342e1c;
  stroke: #edbd56;
}

.diagram-node.selected > :first-child {
  stroke: #fff;
  stroke-width: 4;
}

.diagram-node.locked {
  opacity: 0.82;
  cursor: not-allowed;
}

.diagram-node text,
.site-container text,
.diagram-legend text {
  fill: #eef4ff;
  font-family: Helvetica, Arial, sans-serif;
  pointer-events: none;
}

.topo-icon {
  font-size: 18px;
  font-weight: 700;
}

.topo-name {
  font-size: 13px;
  font-weight: 700;
}

.topo-detail,
.topo-source {
  fill: #aab8ca !important;
  font-size: 10px;
}

.diagram-node.kind-network .topo-name {
  font-size: 14px;
}

.diagram-node.kind-vlan .topo-name {
  font-size: 12px;
}

.lock-mark {
  fill: #f1c96e !important;
  font-size: 14px;
}

.site-container rect {
  fill: rgba(24, 37, 57, 0.45);
  stroke: #536cf0;
  stroke-width: 2;
  stroke-dasharray: 9 6;
}

.site-container text {
  font-size: 15px;
  font-weight: 700;
}

.diagram-edge > path {
  fill: none;
  stroke: #9aacbf;
  stroke-width: 2.5;
  transition:
    stroke 0.15s ease,
    stroke-width 0.15s ease;
}

.diagram-edge:hover > path {
  stroke: #ffffff;
  stroke-width: 4;
}

.diagram-edge path,
#arrow path {
  fill: #8496ae;
}

.diagram-edge text {
  fill: #e6edf7;
  font-size: 11px;
  font-weight: 650;
  pointer-events: none;
}

.edge-label rect {
  fill: #111b2a;
  stroke: #53647c;
  stroke-width: 1;
  opacity: 0.96;
}

.selection-marquee {
  fill: rgba(111, 139, 255, 0.16);
  stroke: #8ca4ff;
  stroke-width: 2;
  stroke-dasharray: 7 5;
}

.alignment-guide,
.spacing-guide {
  fill: none;
  stroke: #55d7ff;
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  pointer-events: none;
}

.spacing-guide {
  stroke: #f3c75f;
}

.diagram-legend rect {
  fill: rgba(17, 27, 43, 0.94);
  stroke: #384a63;
}

.diagram-legend text {
  font-size: 12px;
}

.diagram-legend .legend-title {
  font-size: 14px;
  font-weight: 700;
}

.topology-inspector dl {
  display: grid;
  grid-template-columns: minmax(76px, 0.8fr) minmax(0, 1.2fr);
  gap: 8px;
  margin: 16px 0;
  font-size: 12px;
}

.topology-inspector dt {
  color: var(--muted);
}

.topology-inspector dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.pdf-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 16px;
}

.pdf-sections label {
  margin: 0;
}

body.diagram-presentation aside,
body.diagram-presentation main > header,
body.diagram-presentation .topology-v2-page .page-head,
body.diagram-presentation .topology-commandbar,
body.diagram-presentation .diagram-actions,
body.diagram-presentation .topology-elements,
body.diagram-presentation .topology-inspector,
body.diagram-presentation .canvas-hint {
  display: none !important;
}

body.diagram-presentation main,
body.diagram-presentation #content,
body.diagram-presentation .topology-v2-page,
body.diagram-presentation #topologyV2Body,
body.diagram-presentation .topology-workspace,
body.diagram-presentation .topology-canvas,
body.diagram-presentation .topology-canvas svg {
  width: 100vw;
  height: 100vh;
  max-width: none;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

body.diagram-presentation .topology-workspace {
  display: block;
}

#exitPresentation {
  position: fixed;
  z-index: 1000;
  right: 18px;
  top: 18px;
}

@media (max-width: 1180px) {
  .topology-workspace,
  .topology-workspace.operational {
    grid-template-columns: 180px minmax(420px, 1fr);
  }

  .topology-inspector {
    grid-column: 1 / -1;
    min-height: 170px;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .topology-workspace.operational .topology-inspector {
    grid-column: auto;
    border-top: 0;
    border-left: 1px solid var(--border);
  }
}

@media (max-width: 1500px) {
  .diagram-actions {
    gap: 5px;
  }

  .tool-group {
    padding: 6px 8px;
  }

  .tool-group button,
  .tool-group select {
    padding: 8px 9px;
    font-size: 12px;
  }
}

@media (max-width: 820px) {
  #content:has(> .topology-v2-page) {
    padding: 16px 12px 80px;
  }

  .topology-workspace,
  .topology-workspace.operational {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .topology-elements,
  .topology-inspector {
    flex: none;
    max-height: none;
    border: 0;
    border-bottom: 1px solid var(--border);
  }

  .topology-inspector {
    min-height: 160px;
  }

  .topology-canvas,
  .topology-canvas svg {
    min-height: 520px;
  }

  .pdf-sections {
    grid-template-columns: 1fr;
  }
}
