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

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    color: var(--text);
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.stats {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 300;
}

.stats strong {
    color: var(--accent);
    font-weight: 600;
}

.legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.blue   { background: rgba(59, 130, 246, 0.8); }
.legend-dot.yellow { background: rgba(234, 179, 8, 0.9); }

.btn {
    padding: 9px 22px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.graph-wrapper {
    position: relative;
    flex: 1;
    min-height: 600px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#graph {
    position: absolute;
    inset: 0;
    background: #0f172a;
}

.loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0f172a;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 300;
    z-index: 10;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.error-message {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff6b6b;
    font-size: 1rem;
    background: #0f172a;
    z-index: 10;
    padding: 20px;
    text-align: center;
}

.tooltip {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 16px;
    max-width: 340px;
    pointer-events: none;
    z-index: 20;
    line-height: 1.5;
    box-shadow: var(--shadow);
}

.tooltip .tooltip-kind {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 4px;
}

.tooltip .tooltip-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    word-break: break-word;
}

.tooltip .tooltip-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.tooltip .tooltip-uri {
    font-size: 0.72rem;
    color: var(--text-muted);
    word-break: break-all;
}

.tooltip.pinned {
    pointer-events: auto;
    max-height: 60vh;
    overflow-y: auto;
}

.tooltip .tooltip-divider {
    border-top: 1px solid var(--border);
    margin: 10px 0 8px;
}

.tooltip .tooltip-section {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tooltip .tooltip-loading {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.tooltip-instances-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tooltip-instances-list li a {
    display: block;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.82rem;
    transition: background 0.15s;
    word-break: break-all;
}

.tooltip-instances-list li a:hover {
    background: var(--border);
    color: var(--accent-light);
}
