* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  color: #38bdf8;
}

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

.header-actions button {
  padding: 6px 14px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #334155;
  color: #e2e8f0;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.header-actions button:hover {
  background: #475569;
  border-color: #64748b;
}

#btn-scan-real {
  background: #059669;
  border-color: #047857;
}

#btn-scan-real:hover {
  background: #047857;
}

#btn-discover {
  background: #1d4ed8;
  border-color: #2563eb;
}

#btn-discover:hover {
  background: #2563eb;
}

#btn-clear {
  background: #991b1b;
  border-color: #b91c1c;
}

#btn-clear:hover {
  background: #b91c1c;
}

.container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  background: #1e293b;
  border-right: 1px solid #334155;
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  margin-bottom: 8px;
  margin-top: 12px;
}

.sidebar h2:first-child {
  margin-top: 0;
}

.hint {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-template {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: grab;
  transition: background 0.15s;
  font-size: 13px;
}

.device-template:hover {
  background: #334155;
}

.device-template:active {
  cursor: grabbing;
}

.device-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.mode-buttons {
  display: flex;
  gap: 4px;
}

.mode-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #334155;
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.mode-btn.active {
  background: #1d4ed8;
  border-color: #2563eb;
}

.mode-btn:hover {
  background: #475569;
}

.mode-btn.active:hover {
  background: #2563eb;
}

.properties {
  background: #0f172a;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
}

.properties label {
  display: block;
  margin-bottom: 4px;
  color: #94a3b8;
  font-size: 11px;
}

.properties input, .properties select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #475569;
  border-radius: 4px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 12px;
  margin-bottom: 6px;
}

.properties .delete-btn {
  width: 100%;
  padding: 4px;
  border: 1px solid #b91c1c;
  border-radius: 4px;
  background: #991b1b;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
}

.properties .delete-btn:hover {
  background: #b91c1c;
}

.canvas-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#topology-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

#topology-canvas.mode-connect {
  cursor: crosshair;
}

.tooltip {
  position: absolute;
  padding: 4px 8px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  font-size: 11px;
  color: #e2e8f0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

.hidden {
  display: none;
}

.scan-progress {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px 20px;
  min-width: 300px;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.scan-status {
  font-size: 13px;
  font-weight: 600;
  color: #38bdf8;
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #38bdf8);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.scan-detail {
  font-size: 11px;
  color: #64748b;
}

.device-count {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: #94a3b8;
  z-index: 5;
}

.btn-primary {
  font-weight: 600;
}
