```python
def read_config(text: str) -> dict[str, str]:
    config = {}
    lines = text.splitlines()
    
    for line in lines:
        # Skip empty lines and comments
        if not line.strip() or line.startswith('#'):
            continue
        
        parts = line.split('=', 1)
        
        if len(parts) != 2:
            raise ValueError("Invalid line format")
        
        key, value = parts
        
        # Strip whitespace around the key and value
        config[key.strip()] = value.strip()
    
    return config
```