        :root {
            --bg-primary: #0f1117;
            --bg-secondary: #1a1d27;
            --bg-card: #1e2130;
            --bg-card-hover: #252940;
            --bg-input: #14161f;
            --border: #2a2e3f;
            --border-focus: #6366f1;
            --text-primary: #f1f3f9;
            --text-secondary: #8b90a5;
            --text-muted: #5c6078;
            --accent: #6366f1;
            --accent-light: #818cf8;
            --accent-bg: rgba(99, 102, 241, 0.12);
            --green: #22c55e;
            --green-bg: rgba(34, 197, 94, 0.12);
            --yellow: #eab308;
            --yellow-bg: rgba(234, 179, 8, 0.12);
            --red: #ef4444;
            --red-bg: rgba(239, 68, 68, 0.12);
            --blue: #3b82f6;
            --blue-bg: rgba(59, 130, 246, 0.12);
            --orange: #f97316;
            --orange-bg: rgba(249, 115, 22, 0.12);
            --radius: 12px;
            --radius-sm: 8px;
            --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
            --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

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

        body {
            font-family: 'Inter', -apple-system, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
            min-height: 100vh;
        }

        .app {
            max-width: 1440px;
            margin: 0 auto;
            padding: 24px;
        }

        /* Header */
        .header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 32px;
            flex-wrap: wrap;
            gap: 16px;
        }

        .header h1 {
            font-size: 24px;
            font-weight: 700;
            background: linear-gradient(135deg, var(--accent-light), #a78bfa);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .header-subtitle {
            font-size: 13px;
            color: var(--text-muted);
        }

        /* Search */
        .search-container {
            position: relative;
            width: 360px;
        }

        .search-container .material-icons-outlined {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            font-size: 20px;
        }

        .search-input {
            width: 100%;
            padding: 10px 16px 10px 44px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            color: var(--text-primary);
            font-size: 14px;
            font-family: inherit;
            transition: border-color var(--transition);
        }

        .search-input:focus {
            outline: none;
            border-color: var(--border-focus);
            box-shadow: 0 0 0 3px var(--accent-bg);
        }

        .search-input::placeholder {
            color: var(--text-muted);
        }

        /* Stats */
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 16px;
            margin-bottom: 32px;
        }

        .stat-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 20px;
            transition: all var(--transition);
        }

        .stat-card:hover {
            background: var(--bg-card-hover);
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }

        .stat-label {
            font-size: 12px;
            font-weight: 500;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .stat-value {
            font-size: 28px;
            font-weight: 700;
            line-height: 1;
        }

        .stat-icon {
            width: 32px;
            height: 32px;
            border-radius: var(--radius-sm);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 12px;
        }

        .stat-icon .material-icons-outlined {
            font-size: 18px;
        }

        /* Tabs */
        .tabs {
            display: flex;
            gap: 4px;
            margin-bottom: 24px;
            background: var(--bg-secondary);
            padding: 4px;
            border-radius: var(--radius);
            width: fit-content;
        }

        .tab {
            padding: 8px 20px;
            font-size: 13px;
            font-weight: 500;
            color: var(--text-secondary);
            background: transparent;
            border: none;
            border-radius: var(--radius-sm);
            cursor: pointer;
            transition: all var(--transition);
            font-family: inherit;
        }

        .tab:hover {
            color: var(--text-primary);
        }

        .tab.active {
            background: var(--accent);
            color: white;
            box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
        }

        /* Table */
        .table-container {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            overflow: hidden;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th {
            padding: 12px 16px;
            font-size: 11px;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            text-align: left;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
            position: sticky;
            top: 0;
            z-index: 1;
        }

        td {
            padding: 14px 16px;
            font-size: 13px;
            border-bottom: 1px solid var(--border);
            vertical-align: middle;
        }

        tr:last-child td {
            border-bottom: none;
        }

        tr:hover td {
            background: var(--bg-card-hover);
        }

        .clickable-row {
            cursor: pointer;
        }

        /* Badges */
        .badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 10px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 600;
            white-space: nowrap;
        }

        .badge-new {
            background: var(--blue-bg);
            color: var(--blue);
        }

        .badge-active {
            background: var(--green-bg);
            color: var(--green);
        }

        .badge-warning {
            background: var(--yellow-bg);
            color: var(--yellow);
        }

        .badge-danger {
            background: var(--red-bg);
            color: var(--red);
        }

        .badge-neutral {
            background: rgba(139, 144, 165, 0.12);
            color: var(--text-secondary);
        }

        .badge-accent {
            background: var(--accent-bg);
            color: var(--accent-light);
        }

        .badge-orange {
            background: var(--orange-bg);
            color: var(--orange);
        }

        /* Detail Panel */
        .detail-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 100;
            backdrop-filter: blur(4px);
        }

        .detail-overlay.open {
            display: block;
        }

        .detail-panel {
            position: fixed;
            right: 0;
            top: 0;
            bottom: 0;
            width: min(700px, 92vw);
            background: var(--bg-primary);
            border-left: 1px solid var(--border);
            z-index: 101;
            overflow-y: auto;
            padding: 32px;
            transform: translateX(100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .detail-overlay.open .detail-panel {
            transform: translateX(0);
        }

        .detail-close {
            position: absolute;
            top: 20px;
            right: 20px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-secondary);
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all var(--transition);
        }

        .detail-close:hover {
            background: var(--bg-card-hover);
            color: var(--text-primary);
        }

        .detail-header {
            margin-bottom: 28px;
        }

        .detail-header h2 {
            font-size: 20px;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .detail-header p {
            font-size: 13px;
            color: var(--text-secondary);
        }

        .detail-section {
            margin-bottom: 24px;
        }

        .detail-section h3 {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .detail-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .detail-field {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 12px;
        }

        .detail-field-label {
            font-size: 11px;
            color: var(--text-muted);
            margin-bottom: 4px;
        }

        .detail-field-value {
            font-size: 14px;
            font-weight: 500;
        }

        /* Deadline cards */
        .deadline-list {
            display: grid;
            gap: 12px;
        }

        .deadline-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 16px 20px;
            display: flex;
            align-items: center;
            gap: 16px;
            transition: all var(--transition);
            cursor: pointer;
        }

        .deadline-card:hover {
            background: var(--bg-card-hover);
            transform: translateX(4px);
        }

        .deadline-date {
            text-align: center;
            min-width: 56px;
        }

        .deadline-date .day {
            font-size: 22px;
            font-weight: 700;
            line-height: 1;
        }

        .deadline-date .month {
            font-size: 11px;
            color: var(--text-secondary);
            text-transform: uppercase;
        }

        .deadline-info {
            flex: 1;
        }

        .deadline-info .title {
            font-weight: 600;
            font-size: 14px;
        }

        .deadline-info .subtitle {
            font-size: 12px;
            color: var(--text-secondary);
        }

        .deadline-days-left {
            font-size: 12px;
            font-weight: 600;
            padding: 4px 12px;
            border-radius: 20px;
        }

        /* Team cards */
        .team-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 16px;
        }

        .team-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            padding: 20px;
            transition: all var(--transition);
            cursor: pointer;
        }

        .team-card:hover {
            background: var(--bg-card-hover);
            transform: translateY(-2px);
            box-shadow: var(--shadow);
        }

        .team-card-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .team-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 16px;
        }

        .team-card-stats {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
        }

        .team-stat {
            text-align: center;
        }

        .team-stat .num {
            font-size: 18px;
            font-weight: 700;
        }

        .team-stat .lbl {
            font-size: 10px;
            color: var(--text-muted);
            text-transform: uppercase;
        }

        /* Task items */
        .task-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
            transition: background var(--transition);
        }

        .task-item:hover {
            background: var(--bg-card-hover);
        }

        .task-item:last-child {
            border-bottom: none;
        }

        .task-checkbox {
            width: 20px;
            height: 20px;
            border: 2px solid var(--border);
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all var(--transition);
            flex-shrink: 0;
        }

        .task-checkbox:hover {
            border-color: var(--accent);
        }

        .task-checkbox.done {
            background: var(--green);
            border-color: var(--green);
        }

        .task-checkbox.done::after {
            content: '✔';
            color: white;
            font-size: 12px;
            font-weight: 700;
        }

        .task-info {
            flex: 1;
            min-width: 0;
        }

        .task-name {
            font-size: 13px;
            font-weight: 500;
        }

        .task-name.done {
            text-decoration: line-through;
            color: var(--text-muted);
        }

        .task-name a {
            color: var(--accent-light);
            text-decoration: underline;
        }
        .task-name a:hover {
            color: var(--accent);
        }
        .task-name code {
            background: rgba(255, 255, 255, 0.08);
            color: var(--orange);
            padding: 1px 4px;
            border-radius: 3px;
            font-family: monospace;
            font-size: 0.9em;
        }

        /* Markdown Body Rendering */
        .markdown-body {
            line-height: 1.5;
            word-break: break-word;
        }
        .markdown-body p {
            margin: 0 0 6px 0;
        }
        .markdown-body p:last-child {
            margin-bottom: 0;
        }
        .markdown-body a {
            color: var(--accent-light);
            text-decoration: underline;
        }
        .markdown-body a:hover {
            color: var(--accent);
        }
        .markdown-body ul, .markdown-body ol {
            margin: 4px 0 6px 20px;
            padding: 0;
        }
        .markdown-body li {
            margin-bottom: 2px;
        }
        .markdown-body code {
            background: rgba(255, 255, 255, 0.08);
            color: var(--orange);
            padding: 1px 5px;
            border-radius: 4px;
            font-family: monospace;
            font-size: 0.9em;
        }
        .markdown-body pre {
            background: var(--bg-primary);
            border: 1px solid var(--border);
            padding: 8px 12px;
            border-radius: 6px;
            overflow-x: auto;
            margin: 6px 0;
        }
        .markdown-body pre code {
            background: none;
            padding: 0;
            color: var(--text-primary);
        }
        .markdown-body blockquote {
            border-left: 3px solid var(--accent);
            padding-left: 10px;
            color: var(--text-muted);
            margin: 6px 0;
        }
        .markdown-body strong {
            font-weight: 600;
            color: var(--text-primary);
        }
        .md-toolbar-btn {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: 2px 7px;
            border-radius: 4px;
            font-size: 11px;
            cursor: pointer;
            transition: all .15s;
        }
        .md-toolbar-btn:hover {
            background: var(--bg-card-hover);
            border-color: var(--accent);
        }

        /* Global Tasks Filter Bar Controls */
        .gtf-select, .gtf-input {
            width: 100%;
            height: 36px;
            padding: 6px 10px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            line-height: 1.4;
            box-sizing: border-box;
            vertical-align: middle;
            appearance: auto;
        }
        .gtf-select:focus, .gtf-input:focus {
            outline: none;
            border-color: var(--border-focus);
            box-shadow: 0 0 0 1px var(--accent-bg);
        }

        .task-meta {
            font-size: 11px;
            color: var(--text-muted);
            display: flex;
            gap: 12px;
            margin-top: 2px;
        }

        .task-subtask {
            padding-left: 24px;
            background: var(--bg);
            border: 1px dashed var(--border);
            margin-left: 12px;
            margin-bottom: 2px;
            font-size: 13px;
            color: var(--text-muted);
        }

        .drag-over {
            border: 2px dashed var(--accent) !important;
            opacity: 0.7;
        }

        .drop-zone {
            height: 12px;
            margin: -6px 0;
            z-index: 50;
            position: relative;
            transition: all 0.2s;
            cursor: move;
        }

        .drop-zone.drag-over-zone {
            height: 36px;
            margin: 6px 0;
            background: rgba(var(--accent-rgb), 0.1);
            border: 2px dashed var(--accent);
            border-radius: var(--radius-sm);
        }

        .drop-zone-sub {
            margin-left: 24px;
        }

        /* Delegation modal */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.6);
            z-index: 200;
            backdrop-filter: blur(4px);
            align-items: center;
            justify-content: center;
        }

        .modal-overlay.open {
            display: flex;
        }

        .modal {
            background: var(--bg-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            width: min(500px, 90vw);
            max-height: 80vh;
            overflow-y: auto;
            padding: 32px;
        }

        .modal h2 {
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 20px;
        }

        .form-group {
            margin-bottom: 16px;
        }

        .form-label {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 6px;
            display: block;
        }

        .form-select,
        .form-input {
            width: 100%;
            padding: 10px 14px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 14px;
            font-family: inherit;
        }

        .form-select:focus,
        .form-input:focus {
            outline: none;
            border-color: var(--border-focus);
        }

        .btn {
            padding: 10px 20px;
            border-radius: var(--radius-sm);
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            border: 1px solid var(--border);
            font-family: inherit;
            transition: all var(--transition);
        }

        .btn-primary {
            background: var(--accent);
            color: white;
            border-color: var(--accent);
        }

        .btn-primary:hover {
            background: var(--accent-light);
        }

        .btn-ghost {
            background: transparent;
            color: var(--text-secondary);
        }

        .btn-ghost:hover {
            color: var(--text-primary);
            background: var(--bg-card);
        }

        .btn-row {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 24px;
        }

        /* Links & Loading */
        a,
        .link {
            color: var(--accent-light);
            text-decoration: none;
            cursor: pointer;
        }

        a:hover,
        .link:hover {
            text-decoration: underline;
        }

        .loading {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 60px;
            color: var(--text-muted);
            gap: 12px;
        }

        .spinner {
            width: 24px;
            height: 24px;
            border: 3px solid var(--border);
            border-top-color: var(--accent);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* Responsive */
        @media (max-width: 768px) {
            .app {
                padding: 16px;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
            }

            .search-container {
                width: 100%;
            }

            .stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .detail-grid {
                grid-template-columns: 1fr;
            }

            .table-container {
                overflow-x: auto;
            }

            table {
                min-width: 800px;
            }
        }

        /* ===== BUILDINGS UI ===== */
        .buildings-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: var(--bg-primary);
            z-index: 500;
            flex-direction: column;
        }
        .buildings-overlay.open {
            display: flex;
        }
        .buildings-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 24px;
            border-bottom: 1px solid var(--border);
            background: var(--bg-secondary);
            flex-shrink: 0;
        }
        .buildings-header h2 {
            font-size: 18px;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .buildings-body {
            display: grid;
            grid-template-columns: 1fr 6px 420px;
            flex: 1;
            overflow: hidden;
            gap: 0;
        }
        .buildings-list-panel {
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border-right: none;
        }
        .buildings-resizer {
            width: 6px;
            cursor: col-resize;
            background: var(--border);
            z-index: 10;
            position: relative;
            transition: background 0.15s ease;
        }
        .buildings-resizer:hover,
        .buildings-resizer.active {
            background: var(--blue);
        }
        .buildings-search-bar {
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
            background: var(--bg-secondary);
            flex-shrink: 0;
        }
        .buildings-search-bar input {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
        }
        .buildings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
            gap: 10px;
            padding: 16px;
            overflow-y: auto;
            flex: 1;
            align-content: start;
        }
        .building-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 0;
            min-height: 76px;
            cursor: pointer;
            transition: all var(--transition);
            overflow: hidden;
        }
        .building-card:hover {
            border-color: var(--accent);
            background: var(--bg-card-hover);
            box-shadow: 0 2px 12px rgba(99,102,241,0.15);
        }
        .building-card.active {
            border-color: var(--accent);
            box-shadow: 0 0 0 2px var(--accent);
        }
        .building-card-thumb {
            width: 76px;
            min-width: 76px;
            height: 76px;
            background: var(--bg-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 26px;
            color: var(--text-muted);
            flex-shrink: 0;
            border-right: 1px solid var(--border);
            overflow: hidden;
        }
        .building-card-thumb img {
            width: 76px;
            height: 76px;
            object-fit: cover;
        }
        .building-card-body {
            padding: 10px 14px;
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 3px;
        }
        .building-card-address {
            font-size: 13px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .building-card-city {
            font-size: 12px;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .building-card-meta {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
            margin-top: 2px;
        }
        .building-card-code {
            font-size: 10px;
            font-weight: 700;
            background: var(--accent-bg);
            color: var(--accent-light);
            padding: 1px 6px;
            border-radius: 4px;
            letter-spacing: 0.3px;
            white-space: nowrap;
        }
        .building-card-tag {
            font-size: 10px;
            color: var(--text-muted);
            background: var(--bg-secondary);
            padding: 1px 5px;
            border-radius: 3px;
        }
        .buildings-map-panel {
            position: relative;
            flex-shrink: 0;
        }
        #buildingsMap {
            width: 100%;
            height: 100%;
            min-height: 300px;
        }

        /* Building Side Panel */
        .building-sidepanel {
            position: fixed;
            right: 0;
            top: 0;
            bottom: 0;
            width: min(560px, 92vw);
            background: var(--bg-primary);
            border-left: 1px solid var(--border);
            z-index: 600;
            overflow-y: auto;
            transform: translateX(100%);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
        }
        .building-sidepanel.open {
            transform: translateX(0);
        }
        .bsp-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 20px 24px 16px;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            position: sticky;
            top: 0;
            background: var(--bg-primary);
            z-index: 1;
        }
        .bsp-header h3 {
            font-size: 16px;
            font-weight: 700;
        }
        .bsp-body {
            padding: 20px 24px;
            flex: 1;
        }
        .bsp-section {
            margin-bottom: 24px;
        }
        .bsp-section-title {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.6px;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .bsp-field {
            margin-bottom: 10px;
        }
        .bsp-field-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 4px;
        }
        .bsp-field-label {
            font-size: 11px;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            gap: 5px;
        }
        .bsp-field input,
        .bsp-field select,
        .bsp-field textarea {
            width: 100%;
            padding: 7px 10px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
            transition: border-color var(--transition);
        }
        .bsp-field input:focus,
        .bsp-field select:focus,
        .bsp-field textarea:focus {
            outline: none;
            border-color: var(--border-focus);
        }
        .bsp-field-bool {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            cursor: pointer;
        }
        .bsp-toggle {
            width: 36px;
            height: 20px;
            border-radius: 10px;
            background: var(--border);
            position: relative;
            transition: background var(--transition);
            flex-shrink: 0;
        }
        .bsp-toggle.on {
            background: var(--green);
        }
        .bsp-toggle::after {
            content: '';
            position: absolute;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: white;
            top: 3px;
            left: 3px;
            transition: left var(--transition);
        }
        .bsp-toggle.on::after {
            left: 19px;
        }
        /* Verification Ampel */
        .bsp-ampel {
            font-size: 13px;
            cursor: pointer;
            title: '';
        }
        .bsp-footer {
            padding: 16px 24px;
            border-top: 1px solid var(--border);
            display: flex;
            gap: 8px;
            flex-shrink: 0;
            position: sticky;
            bottom: 0;
            background: var(--bg-primary);
        }
        .bsp-save-status {
            font-size: 12px;
            color: var(--green);
            align-self: center;
            margin-left: auto;
        }

        .chat-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: var(--accent-bg);
            color: var(--accent-light);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            text-decoration: none;
            font-size: 13px;
            font-weight: 500;
            transition: var(--transition);
            white-space: nowrap;
        }

        .chat-btn:hover {
            background: var(--accent);
            color: white;
            border-color: var(--accent);
        }

        .chat-btn .material-icons-outlined {
            font-size: 18px;
        }

        .chat-btn:focus {
            outline: none;
        }

        /* Chat Sidebar */
        .chat-sidebar {
            position: fixed;
            top: 0;
            right: -420px;
            width: 420px;
            height: 100vh;
            background: var(--bg-secondary);
            border-left: 1px solid var(--border);
            z-index: 2000;
            transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            display: flex;
            flex-direction: column;
            box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
        }

        .chat-sidebar.open {
            right: 0;
        }

        .chat-sidebar-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border);
            background: var(--bg-card);
        }

        .chat-sidebar-header h3 {
            font-size: 15px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .chat-sidebar-header h3 .material-icons-outlined {
            font-size: 20px;
            color: var(--accent-light);
        }

        .chat-sidebar-close {
            background: none;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 4px;
            border-radius: 6px;
            transition: var(--transition);
        }

        .chat-sidebar-close:hover {
            background: var(--bg-card-hover);
            color: var(--text-primary);
        }

        .chat-sidebar-body {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .chat-sidebar-body iframe {
            width: 100%;
            height: 100%;
            border: none;
        }

        .chat-fallback {
            flex: 1;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 32px;
            text-align: center;
            gap: 16px;
        }

        .chat-fallback.show {
            display: flex;
        }

        .chat-fallback .chat-icon-large {
            font-size: 64px;
            color: var(--accent);
            opacity: 0.6;
        }

        .chat-fallback p {
            color: var(--text-secondary);
            font-size: 14px;
            line-height: 1.6;
        }

        .chat-open-link {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 12px 28px;
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius-sm);
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            text-decoration: none;
        }

        .chat-open-link:hover {
            background: var(--accent-light);
            transform: translateY(-1px);
        }

        .chat-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.3);
            z-index: 1999;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }

        .chat-overlay.open {
            opacity: 1;
            pointer-events: auto;
        }

        /* Settings Modal */
        .settings-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 3000;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .settings-overlay.open {
            display: flex;
        }

        .settings-modal {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--radius);
            width: 90vw;
            max-width: 1100px;
            max-height: 85vh;
            overflow-y: auto;
            box-shadow: var(--shadow);
        }

        .settings-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 20px 40px;
            border-bottom: 1px solid var(--border);
        }

        .settings-header h2 {
            font-size: 18px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .settings-header h2 .material-icons-outlined {
            color: var(--accent-light);
        }

        .settings-body {
            padding: 24px 40px;
        }

        .settings-section {
            margin-bottom: 24px;
        }

        .settings-section h3 {
            font-size: 14px;
            font-weight: 600;
            margin-bottom: 12px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .import-zone {
            border: 2px dashed var(--border);
            border-radius: var(--radius-sm);
            padding: 32px;
            text-align: center;
            cursor: pointer;
            transition: var(--transition);
        }

        .import-zone:hover,
        .import-zone.dragover {
            border-color: var(--accent);
            background: var(--accent-bg);
        }

        .import-zone .material-icons-outlined {
            font-size: 40px;
            color: var(--text-muted);
            margin-bottom: 8px;
        }

        .import-zone p {
            color: var(--text-secondary);
            font-size: 13px;
        }

        .import-zone .filename {
            color: var(--accent-light);
            font-weight: 600;
            font-size: 14px;
            margin-top: 8px;
        }

        .import-row {
            display: flex;
            gap: 12px;
            align-items: center;
            margin-top: 16px;
        }

        .import-row select,
        .import-row input {
            flex: 1;
        }

        select {
            background: var(--bg-input);
            color: var(--text-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 10px 12px;
            font-size: 13px;
            width: 100%;
        }

        select:focus {
            border-color: var(--border-focus);
            outline: none;
        }

        .sql-preview {
            background: var(--bg-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            padding: 16px;
            font-family: 'Courier New', monospace;
            font-size: 12px;
            color: var(--text-secondary);
            max-height: 300px;
            overflow-y: auto;
            white-space: pre;
            margin-top: 12px;
            display: none;
        }

        .sql-preview.show {
            display: block;
        }

        .import-actions {
            display: flex;
            gap: 8px;
            margin-top: 16px;
            justify-content: flex-end;
        }

        /* Make.com Scenarios */
        .scenario-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .scenario-card {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            background: var(--bg-primary);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            transition: var(--transition);
        }

        .scenario-card:hover {
            border-color: var(--accent);
        }

        .scenario-info {
            flex: 1;
            min-width: 0;
        }

        .scenario-name {
            font-size: 13px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .scenario-meta {
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .scenario-status {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 12px;
            flex-shrink: 0;
        }

        .scenario-status.active {
            background: var(--green);
        }

        .scenario-status.inactive {
            background: var(--text-muted);
        }

        .scenario-status.paused {
            background: var(--orange);
        }

        .scenario-run {
            background: var(--accent);
            color: white;
            border: none;
            border-radius: var(--radius-sm);
            padding: 6px 12px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 4px;
            flex-shrink: 0;
        }

        .scenario-run:hover {
            background: var(--accent-light);
        }

        .scenario-run:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .scenarios-loading {
            text-align: center;
            padding: 20px;
            color: var(--text-muted);
            font-size: 13px;
        }

        /* Chat Sidebar */
        .chat-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.3);
            z-index: 1999;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }

        .chat-overlay.open {
            opacity: 1;
            pointer-events: auto;
        }

        .chat-sidebar {
            position: fixed;
            top: 0;
            right: -420px;
            width: 400px;
            height: 100vh;
            background: var(--bg-card);
            border-left: 1px solid var(--border);
            z-index: 2000;
            transition: right 0.3s ease;
            display: flex;
            flex-direction: column;
        }

        .chat-sidebar.open {
            right: 0;
        }

        .chat-sidebar-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border);
        }

        .chat-sidebar-header h3 {
            font-size: 16px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .chat-sidebar-close {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
        }

        .chat-sidebar-close:hover {
            color: var(--text-primary);
            background: var(--bg-hover);
        }

        .chat-sidebar-body {
            flex: 1;
            overflow-y: auto;
            padding: 12px;
        }

        /* Chat Messages */
        .chat-space-select {
            width: 100%;
            margin-bottom: 12px;
        }

        .chat-msg {
            padding: 8px 12px;
            margin-bottom: 6px;
            border-radius: 8px;
            background: var(--bg-primary);
        }

        .chat-msg-sender {
            font-size: 11px;
            font-weight: 600;
            color: var(--accent-light);
            margin-bottom: 2px;
        }

        .chat-msg-text {
            font-size: 13px;
            color: var(--text-primary);
            line-height: 1.4;
            white-space: pre-wrap;
        }

        .chat-msg-time {
            font-size: 10px;
            color: var(--text-muted);
            margin-top: 2px;
        }

        .chat-empty {
            text-align: center;
            color: var(--text-muted);
            padding: 32px;
            font-size: 13px;
        }

        .chat-composer {
            padding: 12px;
            border-top: 1px solid var(--border);
            display: flex;
            gap: 8px;
            align-items: flex-end;
        }

        .chat-composer textarea {
            flex: 1;
            resize: none;
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 8px 12px;
            font-size: 13px;
            font-family: inherit;
            background: var(--bg-primary);
            color: var(--text-primary);
            min-height: 38px;
            max-height: 100px;
            line-height: 1.4;
        }

        .chat-composer textarea:focus {
            outline: none;
            border-color: var(--accent-light);
        }

        .chat-send-btn {
            background: var(--accent-light);
            color: white;
            border: none;
            border-radius: 8px;
            width: 38px;
            height: 38px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.2s;
        }

        .chat-send-btn:hover {
            background: var(--accent);
        }

        .chat-send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Module Dropdown */
        .module-dropdown {
            position: relative;
            display: inline-block;
        }

        .module-dropdown-content {
            display: none;
            position: absolute;
            background-color: var(--bg-card);
            min-width: 200px;
            box-shadow: var(--shadow);
            z-index: 1000;
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            top: 100%;
            right: 0;
            /* margin removed to prevent hover losing focus */
        }

        .module-dropdown-content a {
            color: var(--text-primary);
            padding: 12px 16px;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            transition: background var(--transition);
            cursor: pointer;
        }

        .module-dropdown-content a:hover {
            background-color: var(--bg-card-hover);
        }

        .module-dropdown:hover .module-dropdown-content {
            display: block;
        }

        /* VDI VM Status Badges */
        .vdi-status-badge {
            font-size: 11px;
            padding: 2px 6px;
            border-radius: var(--radius-xs, 4px);
            font-weight: 600;
        }
        .vdi-status-running {
            background-color: rgba(34, 197, 94, 0.15);
            color: #22c55e;
        }
        .vdi-status-terminated {
            background-color: rgba(239, 68, 68, 0.15);
            color: #ef4444;
        }
        .vdi-status-stopping {
            background-color: rgba(249, 115, 22, 0.15);
            color: #f97316;
        }
        .vdi-status-pending {
            background-color: rgba(234, 179, 8, 0.15);
            color: #eab308;
        }
        .vdi-status-unknown {
            background-color: rgba(156, 163, 175, 0.15);
            color: #9ca3af;
        }

        /* Module UI Overlay */
        .module-ui-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: var(--bg-primary);
            z-index: 2000;
            flex-direction: column;
        }

        .module-ui-overlay.open {
            display: flex;
        }

        .module-ui-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 24px;
            background: var(--bg-card);
            border-bottom: 1px solid var(--border);
        }

        .module-ui-title {
            font-size: 18px;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .module-ui-close {
            background: none;
            border: none;
            color: var(--text-secondary);
            cursor: pointer;
            padding: 8px;
            border-radius: var(--radius-sm);
            transition: all var(--transition);
        }

        .module-ui-close:hover {
            background: var(--bg-card-hover);
            color: var(--text-primary);
        }

        .module-ui-iframe {
            flex: 1;
            width: 100%;
            border: none;
            background: #fff;
            /* or transparent if modules should handle it */
        }

        /* ===== TASK FIELDS ===== */
        .tf-btn {
            background: none;
            border: 1px solid var(--border);
            border-radius: 4px;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 11px;
            padding: 2px 6px;
            margin-left: 6px;
            transition: all var(--transition);
            flex-shrink: 0;
        }
        .tf-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

        #tfModal { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.55); z-index:9999; align-items:center; justify-content:center; }
        #tfModal.open { display:flex; }
        #tfModalBox {
            background: var(--bg-secondary, #1e2130);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 24px;
            width: 560px;
            max-width: 95vw;
            max-height: 85vh;
            overflow-y: auto;
        }
        #tfModalBox h3 { margin: 0 0 16px; font-size: 15px; display:flex; align-items:center; gap:8px; }
        .tf-field-row { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
        .tf-field-row label { flex:0 0 160px; font-size:12px; color:var(--text-muted); }
        .tf-field-row .tf-input-wrap { flex:1; }
        .tf-field-row .tf-input-wrap input,
        .tf-field-row .tf-input-wrap select,
        .tf-field-row .tf-input-wrap textarea { width:100%; box-sizing:border-box; background:var(--bg-primary); border:1px solid var(--border); border-radius:6px; padding:6px 10px; color:var(--text-primary); font-size:13px; }
        .tf-field-row .tf-input-wrap textarea { resize:vertical; min-height:60px; font-family:inherit; }
        .tf-ampel { font-size:16px; flex-shrink:0; cursor:help; }
        .tf-list-table { width:100%; border-collapse:collapse; font-size:12px; margin-bottom:6px; }
        .tf-list-table th { text-align:left; padding:4px 8px; color:var(--text-muted); border-bottom:1px solid var(--border); }
        .tf-list-table td { padding:4px 8px; border-bottom:1px solid var(--border); }
        .tf-list-table td input { width:100%; background:var(--bg-primary); border:1px solid var(--border); border-radius:4px; padding:3px 6px; color:var(--text-primary); font-size:12px; }
        .tf-required { color:var(--red); margin-left:2px; }
        .badge-pill {
            cursor: pointer;
            background: var(--bg-secondary, rgba(255,255,255,0.05));
            color: var(--text-primary);
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 11px;
            border: 1px solid var(--border);
            transition: all 0.2s;
            display: inline-block;
        }
        .badge-pill:hover {
            background: var(--primary, #4f46e5);
            color: #fff;
            border-color: var(--primary, #4f46e5);
        }
