/* ========== 拓扑设计模块样式 ========== */

/* 整体布局 */
.topo-layout {
  display: grid;
  grid-template-columns: 280px 1fr 360px;
  gap: 12px;
  height: calc(100vh - 180px);
  min-height: 600px;
}

.topo-panel {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topo-panel-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, #1a73e8 0%, #00b4d8 100%);
  color: white;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topo-panel-header .topo-actions {
  display: flex;
  gap: 6px;
}

.topo-panel-header button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.topo-panel-header button:hover { background: rgba(255,255,255,0.35); }

.topo-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* 设备添加表单 */
.topo-form-group {
  margin-bottom: 10px;
}
.topo-form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 600;
}
.topo-form-group input,
.topo-form-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}
.topo-form-group input:focus,
.topo-form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.topo-btn-add {
  width: 100%;
  padding: 8px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}
.topo-btn-add:hover { background: var(--primary-dark); }

/* 设备列表 */
.topo-device-list {
  margin-top: 14px;
}
.topo-device-list-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topo-device-item {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.topo-device-item:hover {
  background: #e8f0fe;
  border-color: var(--primary);
}
.topo-device-item.selected {
  background: #e8f0fe;
  border-color: var(--primary);
  border-left: 3px solid var(--primary);
}
.topo-device-item.linking {
  background: #fff3e0;
  border-color: var(--warning);
}

.topo-device-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.topo-device-info {
  flex: 1;
  min-width: 0;
}
.topo-device-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topo-device-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topo-device-del {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.topo-device-del:hover { opacity: 1; }

/* 拓扑画布 */
.topo-canvas-wrap {
  position: relative;
  background: #fafbfc;
  background-image:
    linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
}

.topo-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}
.topo-canvas.mode-link { cursor: crosshair; }
.topo-canvas.mode-delete { cursor: not-allowed; }

/* SVG设备节点 */
.topo-node {
  cursor: move;
}
.topo-node rect.topo-node-bg {
  fill: white;
  stroke: var(--primary);
  stroke-width: 2;
  rx: 6;
  ry: 6;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.topo-node.selected rect.topo-node-bg {
  stroke: var(--accent);
  stroke-width: 3;
}
.topo-node.linking rect.topo-node-bg {
  stroke: var(--warning);
  stroke-dasharray: 4,2;
}
.topo-node-text {
  font-size: 12px;
  font-weight: 600;
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}
.topo-node-ip {
  font-size: 10px;
  fill: var(--text-secondary);
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.topo-link {
  stroke: #9aa0a6;
  stroke-width: 2;
  fill: none;
  transition: stroke 0.2s;
}
.topo-link:hover { stroke: var(--primary); stroke-width: 3; }
.topo-link.selected { stroke: var(--accent); stroke-width: 3; }
.topo-link-label {
  font-size: 10px;
  fill: var(--text-secondary);
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

/* 画布工具栏 */
.topo-canvas-toolbar {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  background: white;
  padding: 6px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.topo-canvas-toolbar button {
  background: #f1f3f4;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.topo-canvas-toolbar button:hover { background: #e8f0fe; }
.topo-canvas-toolbar button.active {
  background: var(--primary);
  color: white;
}

.topo-canvas-tip {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}

.topo-empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  text-align: center;
  pointer-events: none;
}
.topo-empty-hint .big-icon {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* 配置生成面板 */
.topo-config-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}
.topo-config-tab {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-secondary);
  font-weight: 600;
  transition: all 0.2s;
}
.topo-config-tab:hover { color: var(--primary); }
.topo-config-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.topo-config-content {
  display: none;
}
.topo-config-content.active {
  display: block;
}

.topo-stp-root {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 12px;
  font-size: 12px;
}
.topo-stp-root label {
  font-weight: 600;
  margin-right: 6px;
}
.topo-stp-root select {
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
}

.topo-config-output {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 8px;
}

.topo-config-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.topo-config-actions button {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.topo-btn-primary {
  background: var(--primary);
  color: white;
}
.topo-btn-primary:hover { background: var(--primary-dark); }
.topo-btn-success {
  background: var(--accent);
  color: white;
}
.topo-btn-success:hover { background: #00a843; }
.topo-btn-secondary {
  background: #f1f3f4;
  color: var(--text);
}
.topo-btn-secondary:hover { background: #e8eaed; }

/* 端口配置表 */
.topo-ports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.topo-ports-table th {
  background: #f1f3f4;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}
.topo-ports-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.topo-ports-table input,
.topo-ports-table select {
  width: 100%;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
}

/* 设备类型颜色 */
.topo-color-switch { background: #1a73e8; }
.topo-color-router { background: #00b4d8; }
.topo-color-firewall { background: #ff5722; }
.topo-color-pc { background: #607d8b; }
.topo-color-server { background: #9c27b0; }
.topo-color-ap { background: #4caf50; }
.topo-color-cloud { background: #00bcd4; }

/* 提示信息 */
.topo-info-box {
  background: #e3f2fd;
  border-left: 3px solid var(--primary);
  padding: 10px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.topo-info-box strong { color: var(--primary); }

.topo-stat {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
}
.topo-stat-item {
  background: #f1f3f4;
  padding: 6px 10px;
  border-radius: 4px;
  flex: 1;
  text-align: center;
}
.topo-stat-item strong {
  display: block;
  font-size: 18px;
  color: var(--primary);
}

/* ================================================
   华为 eSPN 风格拓扑图样式
   ================================================ */

/* 画布背景：深色网管风格 */
.topo-canvas-wrap.espn {
  background: #1a2332;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* 分层背景区域 */
.topo-layer-bg {
  fill: rgba(255,255,255,0.025);
  stroke: rgba(255,255,255,0.08);
  stroke-width: 1;
  stroke-dasharray: 4,4;
  rx: 8;
  ry: 8;
}
.topo-layer-label {
  font-size: 11px;
  font-weight: 600;
  fill: rgba(255,255,255,0.35);
  letter-spacing: 1px;
  pointer-events: none;
  user-select: none;
}

/* 设备节点：华为机箱风格 */
.topo-node.espn rect.topo-node-bg {
  fill: #2a3a52;
  stroke: #3d5a80;
  stroke-width: 1.5;
  rx: 4;
  ry: 4;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
}
.topo-node.espn.selected rect.topo-node-bg {
  stroke: #4fc3f7;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 8px rgba(79,195,247,0.6));
}
.topo-node.espn.linking rect.topo-node-bg {
  stroke: #ffb74d;
  stroke-dasharray: 5,3;
  filter: drop-shadow(0 0 8px rgba(255,183,77,0.6));
}
.topo-node.espn .topo-node-text {
  fill: #e3f2fd;
  font-size: 11px;
  font-weight: 700;
}
.topo-node.espn .topo-node-ip {
  fill: #90a4ae;
  font-size: 9px;
}
.topo-node.espn .topo-node-model {
  fill: #78909c;
  font-size: 8px;
  text-anchor: middle;
}

/* 设备状态角标 */
.topo-status-badge {
  stroke: #1a2332;
  stroke-width: 1.5;
}
.topo-status-badge.online { fill: #4caf50; }
.topo-status-badge.offline { fill: #9e9e9e; }
.topo-status-badge.warning { fill: #ff9800; }
.topo-status-badge.error { fill: #f44336; }

.topo-status-pulse {
  fill: none;
  opacity: 0;
}
.topo-status-pulse.online { stroke: #4caf50; stroke-width: 2; }
.topo-node.espn.selected .topo-status-pulse {
  animation: topoPulse 1.5s ease-out infinite;
}
@keyframes topoPulse {
  0% { opacity: 0.8; r: 4; }
  100% { opacity: 0; r: 12; }
}

/* 机箱端口指示灯 */
.topo-port-led {
  fill: #2e7d32;
  transition: fill 0.3s;
}
.topo-port-led.up { fill: #66bb6a; }
.topo-port-led.down { fill: #37474f; }
.topo-port-led.warn { fill: #ffa726; }

/* 华为风格设备图标底色 */
.topo-device-chassis {
  /* 交换机：横向机箱 */
}
.topo-chassis-switch {
  fill: #1565c0;
}
.topo-chassis-router {
  fill: #00838f;
}
.topo-chassis-firewall {
  fill: #c62828;
}
.topo-chassis-pc {
  fill: #455a64;
}
.topo-chassis-server {
  fill: #6a1b9a;
}
.topo-chassis-ap {
  fill: #2e7d32;
}
.topo-chassis-cloud {
  fill: #00838f;
}

/* 链路：华为eSPN风格 */
.topo-link.espn {
  stroke: #37474f;
  stroke-width: 2;
  fill: none;
  transition: stroke 0.3s, stroke-width 0.3s;
}
.topo-link.espn.up {
  stroke: #4caf50;
  stroke-width: 2.5;
}
.topo-link.espn.warn {
  stroke: #ffa726;
  stroke-width: 2.5;
  stroke-dasharray: 6,3;
}
.topo-link.espn.down {
  stroke: #f44336;
  stroke-width: 2;
  stroke-dasharray: 4,4;
}
.topo-link.espn.trunk {
  stroke-width: 3.5;
}
.topo-link.espn.aggregation {
  stroke-width: 5;
  opacity: 0.85;
}
.topo-link.espn.selected {
  stroke: #4fc3f7;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 4px rgba(79,195,247,0.8));
}
.topo-link.espn:hover {
  stroke: #29b6f6;
  stroke-width: 3.5;
}

/* 链路流量流动动画 */
.topo-link-flow {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 4,12;
  animation: topoFlow 1s linear infinite;
  pointer-events: none;
}
.topo-link-flow.up { stroke: #81c784; }
.topo-link-flow.warn { stroke: #ffb74d; animation: topoFlow 1.5s linear infinite; }
.topo-link-flow.down { stroke: #ef5350; animation: none; opacity: 0; }
@keyframes topoFlow {
  to { stroke-dashoffset: -16; }
}

/* 链路标签 */
.topo-link-label-bg.espn {
  fill: #263648;
  stroke: #37474f;
  stroke-width: 0.5;
  rx: 3;
}
.topo-link-label.espn {
  fill: #b0bec5;
  font-size: 9px;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}
.topo-link-label.espn.speed {
  fill: #4fc3f7;
  font-weight: 600;
}

/* 悬停详情卡片 */
.topo-tooltip {
  position: absolute;
  background: linear-gradient(135deg, #1a2a3e 0%, #0f1a28 100%);
  border: 1px solid #4fc3f7;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
  color: #e3f2fd;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 0 12px rgba(79,195,247,0.2);
  pointer-events: none;
  z-index: 100;
  display: none;
  font-family: 'Segoe UI', sans-serif;
}
.topo-tooltip.show { display: block; }
.topo-tooltip-title {
  font-size: 14px;
  font-weight: 700;
  color: #4fc3f7;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(79,195,247,0.3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.topo-tooltip-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  line-height: 1.5;
}
.topo-tooltip-row .label {
  color: #78909c;
}
.topo-tooltip-row .value {
  color: #cfd8dc;
  font-weight: 600;
}
.topo-tooltip-row .value.ok { color: #66bb6a; }
.topo-tooltip-row .value.warn { color: #ffa726; }
.topo-tooltip-row .value.err { color: #ef5350; }
.topo-tooltip-section {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.topo-tooltip-section-title {
  font-size: 10px;
  color: #78909c;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

/* 图例 */
.topo-legend {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(26,35,50,0.92);
  border: 1px solid rgba(79,195,247,0.3);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  color: #b0bec5;
  z-index: 10;
  font-family: 'Segoe UI', sans-serif;
}
.topo-legend-title {
  color: #4fc3f7;
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(79,195,247,0.2);
}
.topo-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  line-height: 1.4;
}
.topo-legend-color {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
.topo-legend-color.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* 缩放控件 */
.topo-zoom-controls {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(26,35,50,0.92);
  border: 1px solid rgba(79,195,247,0.3);
  border-radius: 6px;
  padding: 4px;
  z-index: 10;
}
.topo-zoom-controls button {
  background: transparent;
  border: none;
  color: #b0bec5;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.2s;
}
.topo-zoom-controls button:hover {
  background: rgba(79,195,247,0.2);
  color: #4fc3f7;
}
.topo-zoom-level {
  color: #78909c;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin: 2px 0;
}

/* 画布工具栏（eSPN深色风格） */
.topo-canvas-wrap.espn .topo-canvas-toolbar {
  background: rgba(26,35,50,0.92);
  border: 1px solid rgba(79,195,247,0.3);
}
.topo-canvas-wrap.espn .topo-canvas-toolbar button {
  background: transparent;
  color: #b0bec5;
}
.topo-canvas-wrap.espn .topo-canvas-toolbar button:hover {
  background: rgba(79,195,247,0.2);
  color: #4fc3f7;
}
.topo-canvas-wrap.espn .topo-canvas-toolbar button.active {
  background: #1565c0;
  color: white;
}

/* 画布提示条 */
.topo-canvas-wrap.espn .topo-canvas-tip {
  background: rgba(79,195,247,0.9);
  color: #0f1a28;
  font-weight: 600;
}

/* 空状态提示 */
.topo-canvas-wrap.espn .topo-empty-hint {
  color: #546e7a;
}
.topo-canvas-wrap.espn .topo-empty-hint .big-icon {
  opacity: 0.3;
}

/* 链路聚合标识 */
.topo-agg-badge {
  fill: #1565c0;
  stroke: #42a5f5;
  stroke-width: 0.5;
}
.topo-agg-badge-text {
  fill: white;
  font-size: 8px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}

/* 设备类型徽章 */
.topo-type-badge {
  pointer-events: none;
}
.topo-type-badge-text {
  fill: white;
  font-size: 8px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

/* 流量方向箭头（链路中点） */
.topo-flow-arrow {
  fill: #4fc3f7;
  opacity: 0.7;
  pointer-events: none;
}

/* 告警闪烁 */
.topo-alert-blink {
  animation: topoBlink 1s ease-in-out infinite;
}
@keyframes topoBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 统计面板（深色风格） */
.topo-canvas-wrap.espn ~ .topo-panel .topo-stat-item,
.topo-stat-item.espn {
  background: #263648;
  color: #b0bec5;
}
.topo-stat-item.espn strong {
  color: #4fc3f7;
}

/* ============ 设备工具箱（可拖拽卡片） ============ */
.topo-toolbox-title {
  font-size: 11px;
  color: var(--text-secondary, #5f6368);
  margin: 2px 0 6px;
  padding: 0 2px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.topo-toolbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}
.topo-toolbox.espn,
.topo-canvas-wrap.espn ~ .topo-toolbox {
  border-bottom-color: rgba(255,255,255,0.08);
}
.topo-tool-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  background: var(--bg-card, #f1f3f4);
  border: 1px solid rgba(0,0,0,0.06);
  cursor: grab;
  user-select: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #202124);
  transition: all 0.15s ease;
}
.topo-tool-card:hover {
  background: var(--primary-bg, #e8f0fe);
  border-color: var(--primary, #1a73e8);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(26,115,232,0.15);
}
.topo-tool-card:active {
  cursor: grabbing;
  transform: scale(0.97);
}
.topo-tool-card .topo-tool-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}
.topo-tool-card .topo-tool-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 拖拽时的画布视觉反馈 ============ */
.topo-canvas-wrap.drop-active {
  outline: 2px dashed var(--primary, #1a73e8);
  outline-offset: -6px;
  background: rgba(26,115,232,0.04);
}
.topo-canvas-wrap.espn.drop-active {
  outline-color: #4fc3f7;
  background: rgba(79,195,247,0.06);
}
.topo-canvas-wrap.dragging-from-toolbox .topo-empty-hint::after {
  content: "← 从左侧拖拽设备放到此处";
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary, #1a73e8);
  font-weight: 600;
}
.topo-canvas-wrap.espn.dragging-from-toolbox .topo-empty-hint::after {
  color: #4fc3f7;
}
.topo-canvas-wrap.dragging-from-toolbox:not(.drop-active) .topo-empty-hint::after {
  content: "← 拖到此处添加设备";
}
.topo-tool-card[draggable="true"] {
  -webkit-user-drag: element;
}

/* ============ 设备连线端口手柄 ============ */
.topo-link-handle {
  cursor: crosshair;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.topo-node:hover .topo-link-handle,
.topo-link-handle:hover {
  opacity: 1;
}
.topo-link-handle-dot {
  fill: #1a73e8;
  stroke: #fff;
  stroke-width: 1.5;
  transition: r 0.15s ease;
}
.topo-link-handle-inner {
  fill: #fff;
  opacity: 0.9;
}
.topo-link-handle:hover .topo-link-handle-dot {
  fill: #4fc3f7;
}
.espn .topo-link-handle-dot {
  fill: #4fc3f7;
  stroke: rgba(255,255,255,0.6);
}
.espn .topo-link-handle-inner {
  fill: #0d1117;
}
.topo-link-handle-hit {
  cursor: crosshair;
}

/* ============ 临时拖拽连线 ============ */
.topo-link-draft {
  stroke: #1a73e8;
  stroke-width: 2.5;
  fill: none;
  opacity: 0.8;
  pointer-events: none;
  animation: topo-dash 0.6s linear infinite;
}
.espn .topo-link-draft {
  stroke: #4fc3f7;
}
.topo-link-draft-end {
  fill: #1a73e8;
  opacity: 0.9;
  pointer-events: none;
}
.espn .topo-link-draft-end {
  fill: #4fc3f7;
}
@keyframes topo-dash {
  to { stroke-dashoffset: -10; }
}

/* ============ 连线引导提示条 ============ */
.topo-link-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,115,232,0.9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(26,115,232,0.35);
  pointer-events: none;
  z-index: 5;
  animation: topo-hint-pulse 1.6s ease-in-out infinite;
}
.espn .topo-link-hint {
  background: rgba(79,195,247,0.9);
  box-shadow: 0 2px 10px rgba(79,195,247,0.35);
}
@keyframes topo-hint-pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; transform: translateX(-50%) scale(1.03); }
}

/* ================================================================
   勾画拓扑功能样式 (华为eSPN风格绘图模式)
   ================================================================ */

.draw-layout {
  display: grid;
  grid-template-columns: 180px 1fr 220px;
  gap: 0;
  height: calc(100vh - 100px);
  min-height: 680px;
}

/* ---- 左侧工具栏 ---- */
.draw-toolbar {
  background: #1a2332;
  border-right: 1px solid rgba(79,195,247,0.15);
  overflow-y: auto;
  padding: 12px;
}

.draw-toolbar-section {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.draw-toolbar-section:last-child {
  border-bottom: none;
}

.draw-toolbar-title {
  font-size: 11px;
  font-weight: 700;
  color: #4fc3f7;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* 工具按钮 */
.draw-tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.draw-tool-btn {
  background: #263648;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  width: 100%;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #b0bec5;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.15s ease;
}
.draw-tool-btn:hover {
  background: #2e4a68;
  border-color: rgba(79,195,247,0.4);
  color: #4fc3f7;
}
.draw-tool-btn.active {
  background: #1565c0;
  border-color: #4fc3f7;
  color: white;
  box-shadow: 0 0 8px rgba(79,195,247,0.4);
}

/* 设备图标按钮 */
.draw-stamps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.draw-stamp-btn {
  background: #263648;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  padding: 6px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}
.draw-stamp-btn:hover {
  background: #2e4a68;
  border-color: rgba(79,195,247,0.4);
}
.draw-stamp-btn.active {
  background: #1565c0;
  border-color: #4fc3f7;
  box-shadow: 0 0 8px rgba(79,195,247,0.4);
}
.draw-stamp-btn span {
  font-size: 9px;
  color: #b0bec5;
  font-weight: 600;
}
.draw-stamp-btn.active span {
  color: white;
}

/* 颜色选择器 */
.draw-colors {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.draw-color-btn {
  width: 100%;
  height: 28px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.draw-color-btn:hover {
  transform: scale(1.1);
  border-color: rgba(255,255,255,0.4);
}
.draw-color-btn.active {
  border-color: white;
  box-shadow: 0 0 8px rgba(255,255,255,0.5);
}

/* 工具栏属性行 */
.draw-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}
.draw-toolbar-row label {
  color: #90a4ae;
  font-size: 12px;
  white-space: nowrap;
  min-width: 40px;
}
.draw-toolbar-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: #37474f;
  border-radius: 2px;
  outline: none;
}
.draw-toolbar-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4fc3f7;
  cursor: pointer;
}
.draw-toolbar-row input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.draw-range-val {
  color: #4fc3f7;
  font-size: 11px;
  font-weight: 600;
  min-width: 30px;
  text-align: right;
}
.draw-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: #b0bec5 !important;
  font-size: 12px !important;
}
.draw-checkbox input {
  cursor: pointer;
  accent-color: #4fc3f7;
}

/* ---- 中间画布区 ---- */
.draw-canvas-area {
  display: flex;
  flex-direction: column;
  background: #0f1a28;
  overflow: hidden;
}

.draw-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1a2332;
  border-bottom: 1px solid rgba(79,195,247,0.15);
  flex-shrink: 0;
}
.draw-canvas-title {
  font-size: 13px;
  font-weight: 600;
  color: #4fc3f7;
}
.draw-canvas-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.draw-action-btn {
  background: #263648;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #b0bec5;
  font-size: 14px;
  transition: all 0.15s ease;
}
.draw-action-btn:hover {
  background: #2e4a68;
  border-color: rgba(79,195,247,0.4);
  color: #4fc3f7;
}
.draw-action-btn.danger:hover {
  background: #c62828;
  border-color: #ef5350;
  color: white;
}
.draw-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.1);
  margin: 0 4px;
}

/* 画布容器 */
.draw-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #1a2332;
}
.draw-canvas-wrap.grid-on {
  background-image:
    linear-gradient(rgba(79,195,247,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79,195,247,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
}
#draw-canvas {
  display: block;
  cursor: crosshair;
  position: absolute;
  top: 0;
  left: 0;
}
#draw-canvas.tool-pencil { cursor: crosshair; }
#draw-canvas.tool-line { cursor: crosshair; }
#draw-canvas.tool-arrow { cursor: crosshair; }
#draw-canvas.tool-rect { cursor: crosshair; }
#draw-canvas.tool-ellipse { cursor: crosshair; }
#draw-canvas.tool-text { cursor: text; }
#draw-canvas.tool-eraser { cursor: cell; }
#draw-canvas.tool-select { cursor: default; }
#draw-canvas.stamp-mode { cursor: copy; }

/* 状态栏 */
.draw-status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15,26,40,0.9);
  border-top: 1px solid rgba(79,195,247,0.15);
  display: flex;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 11px;
  color: #78909c;
  font-family: 'Consolas', monospace;
  z-index: 5;
}
.draw-status-bar span {
  white-space: nowrap;
}

/* 空状态提示 */
.draw-empty-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #546e7a;
  text-align: center;
  pointer-events: none;
  font-size: 14px;
}
.draw-empty-hint .big-icon {
  font-size: 48px;
  margin-bottom: 8px;
  opacity: 0.3;
}

/* ---- 右侧属性面板 ---- */
.draw-properties {
  background: #1a2332;
  border-left: 1px solid rgba(79,195,247,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.draw-prop-header {
  padding: 10px 14px;
  background: linear-gradient(135deg, #1a73e8 0%, #00b4d8 100%);
  color: white;
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0;
}
.draw-prop-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.draw-layer-list {
  margin-bottom: 14px;
}
.draw-layer-empty {
  font-size: 12px;
  color: #546e7a;
  text-align: center;
  padding: 12px;
}
.draw-layer-item {
  background: #263648;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 5px;
  padding: 8px 10px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.draw-layer-item:hover {
  background: #2e4a68;
  border-color: rgba(79,195,247,0.3);
}
.draw-layer-item.active {
  background: #1565c0;
  border-color: #4fc3f7;
}
.draw-layer-item .layer-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.draw-layer-item .layer-info {
  flex: 1;
  min-width: 0;
}
.draw-layer-item .layer-name {
  font-size: 12px;
  font-weight: 600;
  color: #e3f2fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draw-layer-item .layer-meta {
  font-size: 10px;
  color: #78909c;
}
.draw-layer-item .layer-del {
  background: transparent;
  border: none;
  color: #ef5350;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.6;
  padding: 0 4px;
}
.draw-layer-item .layer-del:hover {
  opacity: 1;
}

.draw-prop-section {
  margin-bottom: 14px;
}
.draw-prop-title {
  font-size: 11px;
  font-weight: 700;
  color: #4fc3f7;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.draw-prop-info {
  background: #263648;
  border-radius: 5px;
  padding: 8px 10px;
}
.draw-prop-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 3px 0;
  color: #b0bec5;
}
.draw-prop-row span:last-child {
  color: #e3f2fd;
  font-weight: 600;
}
.draw-prop-tips {
  background: #263648;
  border-radius: 5px;
  padding: 10px;
}
.draw-prop-tips p {
  font-size: 11px;
  color: #90a4ae;
  margin-bottom: 4px;
  line-height: 1.5;
}

/* 文字输入弹窗 */
.draw-text-input {
  position: absolute;
  z-index: 100;
  background: #1a2332;
  border: 2px solid #4fc3f7;
  border-radius: 4px;
  padding: 4px 8px;
  color: white;
  font-size: 14px;
  outline: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  min-width: 120px;
}

/* 响应式 */
@media (max-width: 1200px) {
  .draw-layout {
    grid-template-columns: 180px 1fr 220px;
  }
}
@media (max-width: 768px) {
  .draw-layout {
    grid-template-columns: 60px 1fr 0;
  }
  .draw-toolbar-section .draw-toolbar-title,
  .draw-stamps span,
  .draw-toolbar-row label,
  .draw-toolbar-row .draw-range-val {
    display: none;
  }
  .draw-properties {
    display: none;
  }
}
