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

:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #6ee7b7;
    --secondary: #8b5cf6;
    --accent: #f59e0b;
    --info: #3b82f6;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-900);
    min-height: 100vh;
    color: white;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(10px);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-700);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 10px;
    border-radius: 12px;
}

.logo-text h1 {
    font-size: 1.5rem;
    color: white;
    font-weight: 700;
}

.tagline {
    color: var(--gray-400);
    font-size: 0.8rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--primary-light);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
}

.sync-dot.active {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-icon {
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    overflow: hidden;
}

/* Integration Map */
.integration-map {
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.map-header h2 {
    font-size: 1.25rem;
    color: white;
}

.map-legend {
    display: flex;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--gray-400);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green { background: var(--primary); }
.dot.blue { background: var(--info); }
.dot.gray { background: var(--gray-500); }

/* Map Canvas */
.map-canvas {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.05) 0%, transparent 70%);
    border-radius: 16px;
    border: 1px solid var(--gray-700);
    min-height: 500px;
}

/* Central Hub */
.hub-node {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.hub-inner {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.5);
    position: relative;
    z-index: 2;
}

.hub-icon {
    font-size: 2rem;
}

.hub-label {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
}

.hub-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-radius: 50%;
    animation: ringPulse 3s ease-out infinite;
}

.hub-ring.ring-2 {
    width: 180px;
    height: 180px;
    animation-delay: 1s;
}

@keyframes ringPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* System Nodes */
.system-node {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-200px) rotate(calc(-1 * var(--angle)));
    background: var(--gray-800);
    border: 2px solid var(--gray-600);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.system-node:hover {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-200px) rotate(calc(-1 * var(--angle))) scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.system-node.syncing {
    border-color: var(--info);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

.system-node.syncing .status-dot {
    background: var(--info);
    animation: pulse 1s infinite;
}

.node-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.node-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
}

.node-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--gray-400);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-dot.connected {
    background: var(--primary);
}

.status-dot.disabled {
    background: var(--danger);
}

/* Connection Lines */
.connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.connection-line {
    stroke: var(--gray-600);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 8 4;
}

.connection-line.active {
    stroke: var(--primary);
    stroke-dasharray: none;
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.5));
}

/* Data Packets */
.data-packets {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.data-packet {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary);
    z-index: 5;
}

/* Side Panel */
.side-panel {
    background: var(--gray-800);
    border-left: 1px solid var(--gray-700);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.panel-card {
    background: var(--gray-900);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--gray-700);
}

.panel-card h3 {
    font-size: 0.9rem;
    color: var(--gray-300);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Integration List */
.integration-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.integration-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-800);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.integration-item.disabled {
    opacity: 0.5;
}

.integration-item:hover {
    background: var(--gray-700);
}

.integration-icons {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1.25rem;
}

.integration-icons .arrow {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.integration-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.integration-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
}

.integration-desc {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.integration-toggle {
    width: 36px;
    height: 20px;
    background: var(--gray-600);
    border-radius: 10px;
    position: relative;
    transition: all 0.2s;
}

.integration-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s;
}

.integration-toggle.active {
    background: var(--primary);
}

.integration-toggle.active::after {
    left: 18px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--gray-800);
    border-radius: 8px;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* Event Log */
.log-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.log-header h3 {
    margin-bottom: 0;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--danger);
    font-weight: 600;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: livePulse 1s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.event-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 300px;
}

.event-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: var(--gray-800);
    border-radius: 8px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.event-icon {
    font-size: 1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-700);
    border-radius: 6px;
    flex-shrink: 0;
}

.event-content {
    flex: 1;
}

.event-text {
    font-size: 0.8rem;
    color: var(--gray-300);
    line-height: 1.4;
}

.event-time {
    font-size: 0.7rem;
    color: var(--gray-500);
    margin-top: 4px;
}

/* Footer */
.footer {
    background: var(--gray-800);
    padding: 16px 24px;
    border-top: 1px solid var(--gray-700);
    text-align: center;
}

.footer p {
    color: var(--gray-400);
    font-size: 0.875rem;
    max-width: 900px;
    margin: 0 auto;
}

.footer strong {
    color: var(--gray-300);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .side-panel {
        border-left: none;
        border-top: 1px solid var(--gray-700);
    }

    .map-canvas {
        min-height: 400px;
    }

    .system-node {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-150px) rotate(calc(-1 * var(--angle)));
    }
}

@media (max-width: 640px) {
    .header {
        flex-direction: column;
        gap: 12px;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .map-legend {
        display: none;
    }

    .system-node {
        width: 90px;
        padding: 10px;
        transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-120px) rotate(calc(-1 * var(--angle)));
    }

    .node-icon {
        font-size: 1.5rem;
    }

    .node-label {
        font-size: 0.65rem;
    }

    .hub-inner {
        width: 70px;
        height: 70px;
    }
}
