/* ============================================================
   App Explorer - Styles
   ============================================================ */

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 220px 1fr 0px;
    background: #0f1923;
    color: #d0d8e0;
    font-size: 13px;
}

body.panel-open {
    grid-template-columns: 220px 1fr 340px;
}

/* ---- Toolbar ---- */
.toolbar {
    grid-row: 1;
    grid-column: 1 / -1;
    background: #16213e;
    border-bottom: 1px solid #2a3a5c;
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 6px;
    flex-wrap: wrap;
    overflow-y: auto;
    z-index: 100;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    background: linear-gradient(90deg, #5a9cf5, #e0e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-title-icon {
    font-size: 11px;
    background: none;
    -webkit-text-fill-color: #2979ff;
    color: #2979ff;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.toolbar-sep {
    width: 1px;
    height: 24px;
    background: #2a3a5c;
    margin: 0 6px;
    flex-shrink: 0;
}

.toolbar-label {
    font-size: 11px;
    color: #7a8a9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
    white-space: nowrap;
}

.tb-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #b0bec5;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.15s;
}

.tb-btn:hover {
    background: #243656;
    color: #e0e8f0;
}

.tb-btn.active {
    background: #2979ff;
    color: #fff;
    border-color: #2979ff;
}

.tb-btn-sm {
    padding: 2px 6px;
    font-size: 11px;
}

.domain-chip {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #9aa8b8;
    padding: 2px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 11px;
    white-space: nowrap;
    transition: all 0.15s;
    user-select: none;
}

.domain-chip:hover {
    background: #243656;
}

.domain-chip.active {
    background: #1a3a5c;
    color: #e0e8f0;
    border-color: #4a7abf;
}

.domain-chip.inactive {
    opacity: 0.4;
}

.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #1a3a5c;
    border: 1px solid #4a7abf;
    color: #b0bec5;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    margin-right: 4px;
    margin-bottom: 4px;
}

.domain-chips-container {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

/* ---- Legend Panel ---- */
.legend-panel {
    grid-row: 2;
    grid-column: 1;
    background: #121e30;
    border-right: 1px solid #2a3a5c;
    overflow-y: auto;
    padding: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #7a8a9e;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 14px 8px;
    position: sticky;
    top: 0;
    background: #121e30;
}

.legend-content {
    padding: 0 10px 14px;
}

.legend-section {
    margin-bottom: 14px;
}

.legend-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.legend-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 4px;
}

.legend-section-controls {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

.legend-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #5a6a7e;
    padding: 1px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
}

.legend-btn:hover {
    background: #243656;
    color: #e0e8f0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.legend-item:hover {
    background: #1a2a44;
}

.legend-item.hidden {
    opacity: 0.35;
}

.legend-item.zero-count {
    opacity: 0.35;
}

.legend-item-label {
    font-size: 12px;
    color: #b0bec5;
    flex: 1;
}

.legend-item-count {
    font-size: 11px;
    color: #5a6a7e;
}

.legend-shape-preview {
    flex-shrink: 0;
}

/* ---- Scope Section (in Filters panel) ---- */
.scope-section {
    padding: 8px 10px 10px;
    border-bottom: 1px solid #2a3a5c;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.scope-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 7px;
    padding: 0 4px;
}

.scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(41, 121, 255, 0.12);
    border: 1px solid #2979ff;
    color: #5a9cf5;
    padding: 4px 8px 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    max-width: 100%;
}

.scope-chip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scope-chip-x {
    cursor: pointer;
    color: #4a7abf;
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
    padding: 0 1px;
    transition: color 0.15s;
}

.scope-chip-x:hover {
    color: #e0e8f0;
}

/* ---- Graph Container ---- */
.graph-container {
    grid-row: 2;
    grid-column: 2;
    overflow: hidden;
    position: relative;
    background: #0f1923;
}

#graphSvg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ---- Tooltip ---- */
.tooltip {
    position: absolute;
    display: none;
    background: #1a2a44;
    border: 1px solid #3a5a8c;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    pointer-events: none;
    z-index: 200;
    max-width: 280px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.tooltip-title {
    font-weight: 600;
    color: #e0e8f0;
    margin-bottom: 2px;
}

.tooltip-sub {
    color: #7a8a9e;
    font-size: 11px;
}

/* ---- Side Panel ---- */
.side-panel {
    grid-row: 2;
    grid-column: 3;
    background: #121e30;
    border-left: 1px solid #2a3a5c;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
}

body.panel-open .side-panel {
    display: flex;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #2a3a5c;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: #e0e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.close-btn {
    background: none;
    border: none;
    color: #7a8a9e;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.close-btn:hover {
    color: #e0e8f0;
}

.panel-body {
    overflow-y: auto;
    flex: 1;
    padding: 12px 16px;
}

.panel-section {
    margin-bottom: 16px;
}

.panel-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.panel-field {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12px;
}

.panel-field-label {
    color: #7a8a9e;
}

.panel-field-value {
    color: #d0d8e0;
    text-align: right;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-field-value-group {
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 200px;
    flex-shrink: 0;
}

.panel-field-value-group .panel-field-value {
    max-width: 160px;
}

.scope-field-btn {
    background: none;
    border: none;
    color: #4a7abf;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.panel-field:hover .scope-field-btn,
.topic-chip .scope-field-btn {
    opacity: 1;
}

.scope-field-btn:hover {
    color: #e0e8f0;
}

.topic-chip .scope-field-btn {
    font-size: 12px;
}

.panel-field-value a {
    color: #5a9cf5;
    text-decoration: none;
}

.panel-field-value a:hover {
    text-decoration: underline;
}

.panel-purpose {
    font-size: 12px;
    color: #9aa8b8;
    line-height: 1.5;
    margin-top: 4px;
}

.panel-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #1a2a44;
    border-radius: 4px;
    margin-bottom: 4px;
}

.panel-metric-label {
    font-size: 12px;
    color: #9aa8b8;
}

.panel-metric-value {
    font-size: 16px;
    font-weight: 700;
    color: #e0e8f0;
}

.panel-conn-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
}

.panel-conn-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.panel-conn-item:hover {
    background: #1a2a44;
}

.conn-type-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.conn-name {
    color: #b0bec5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conn-app-badge {
    font-size: 9px;
    color: #4a90d9;
    background: rgba(74, 144, 217, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ---- Expandable Connection Items ---- */
.panel-conn-item-expandable {
    list-style: none;
    margin-bottom: 2px;
}

.panel-conn-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.panel-conn-row:hover {
    background: #1a2a44;
}

.panel-eye-btn {
    background: none;
    border: none;
    color: #3a4a5e;
    cursor: pointer;
    padding: 2px;
    line-height: 0;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.panel-eye-btn:hover {
    color: #5a9cf5;
    background: rgba(41, 121, 255, 0.12);
}

.panel-expand-chevron {
    color: #3a4a5e;
    padding: 2px 4px;
    font-size: 10px;
    line-height: 1;
    transition: color 0.15s, transform 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}

.panel-expand-chevron:hover {
    color: #9aa8b8;
}

.panel-expand-chevron.expanded {
    transform: rotate(90deg);
    color: #5a9cf5;
}

.panel-conn-detail {
    padding: 4px 8px 6px 28px;
    font-size: 11px;
}

.panel-conn-detail-row {
    display: flex;
    gap: 8px;
    padding: 2px 0;
    align-items: baseline;
}

.panel-conn-detail-label {
    color: #5a6a7e;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 36px;
}

.panel-conn-detail-value {
    color: #9aa8b8;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    max-height: 40px;
    overflow-y: auto;
}

.panel-conn-detail-value a {
    color: #5a9cf5;
    text-decoration: none;
}

.panel-conn-detail-value a:hover {
    text-decoration: underline;
}

.panel-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.panel-action-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #b0bec5;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    transition: all 0.15s;
}

.panel-action-btn:hover {
    background: #243656;
    color: #e0e8f0;
}

.panel-action-btn.active-action {
    background: #2979ff22;
    border-color: #2979ff;
    color: #5a9cf5;
}

/* ---- SVG Graph Elements ---- */
.node {
    cursor: pointer;
}

.node.dimmed {
    opacity: 0.08;
}

.node.search-match .node-shape {
    stroke: #ffeb3b !important;
    stroke-width: 3px !important;
}

.node.highlighted .node-shape {
    stroke-width: 2.5px;
}

.node.selected .node-shape {
    filter: url(#glow);
    stroke-width: 3px;
}

.node-label {
    fill: #d0d8e0;
    font-size: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.node-label.visible {
    opacity: 1;
}

.node-label-bg {
    fill: rgba(15, 25, 35, 0.85);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.node-label-bg.visible {
    opacity: 1;
}

.link {
    stroke-opacity: 0.25;
    fill: none;
    transition: stroke-opacity 0.2s;
}

.link.dimmed {
    stroke-opacity: 0.03;
}

.link.highlighted {
    stroke-opacity: 0.9;
    stroke-width: 2px;
}

.link.highlighted-out {
    stroke-opacity: 0.9;
    stroke-width: 2.5px;
}

.link.highlighted-in {
    stroke-opacity: 0.7;
    stroke-width: 2px;
}

/* Pulse animation for directional flow */
@keyframes pulse-flow {
    0%   { stroke-dashoffset: 20; }
    100% { stroke-dashoffset: 0; }
}

.link.pulsing {
    stroke-dasharray: 10 10;
    animation: pulse-flow 0.8s linear infinite;
}

/* ---- Scrollbar styling ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #2a3a5c;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a5a8c;
}

/* ---- Compass Rose ---- */
.compass-rose {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 100;
    pointer-events: none;
}

.compass-grid {
    display: grid;
    grid-template-columns: repeat(3, 28px);
    grid-template-rows: repeat(3, 28px);
    gap: 2px;
}

.compass-zoom {
    display: flex;
    gap: 2px;
}

.compass-btn {
    pointer-events: all;
    background: rgba(22, 33, 62, 0.85);
    border: 1px solid #2a3a5c;
    color: #9aa8b8;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    backdrop-filter: blur(2px);
    user-select: none;
}

.compass-btn:hover {
    background: rgba(36, 54, 86, 0.95);
    color: #e0e8f0;
    border-color: #4a7abf;
}

.compass-btn:active {
    background: rgba(41, 121, 255, 0.25);
    border-color: #2979ff;
    color: #fff;
}

.compass-center {
    font-size: 14px;
    color: #7a8a9e;
}

/* ---- Loading overlay ---- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: #0f1923;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-text {
    color: #7a8a9e;
    font-size: 14px;
}

/* ---- Error Frame ---- */
.error-frame {
    border: 1px solid #c85000;
    border-radius: 10px;
    padding: 32px 40px;
    background: rgba(200, 80, 0, 0.07);
    max-width: 520px;
    width: 90%;
    text-align: center;
}

.error-frame-icon {
    font-size: 36px;
    color: #e07030;
    margin-bottom: 14px;
    line-height: 1;
}

.error-frame-title {
    font-size: 18px;
    font-weight: 700;
    color: #e0a050;
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

.error-frame-body {
    font-size: 13px;
    color: #9aa8b8;
    line-height: 1.6;
    text-align: left;
}

.error-frame-body p {
    margin-bottom: 10px;
}

.error-frame-code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    color: #e07030;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid #3a2a1a;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 10px 0;
    word-break: break-all;
}

.error-frame-hint {
    font-size: 12px;
    color: #7a8a9e;
    margin-top: 10px;
}

/* ---- Login Screen ---- */
.login-screen {
    position: fixed;
    inset: 0;
    background: #0f1923;
    z-index: 1000;
}

.login-bg-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---- Login Modal ---- */
.login-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 25, 35, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-modal {
    background: #16213e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 48px 56px;
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.login-modal-title {
    color: #e0e6ed;
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 32px;
    letter-spacing: -0.02em;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #000;
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.15s;
}

.login-btn:hover {
    background: #2b2b2b;
}

.github-logo {
    width: 20px;
    height: 20px;
}

/* ---- Toolbar User ---- */
.toolbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    color: #b0bec5;
    font-family: inherit;
    font-size: 12px;
    transition: background 0.15s, border-color 0.15s;
}

.user-menu-btn:hover {
    background: #1a2a44;
    border-color: #2a3a5c;
}

.user-menu-caret {
    font-size: 10px;
    opacity: 0.6;
}

.user-menu-dropdown {
    display: none;
    position: fixed;
    min-width: 120px;
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 200;
}

.user-menu-dropdown.open {
    display: block;
}

.user-menu-item {
    display: block;
    padding: 8px 12px;
    color: #b0bec5;
    text-decoration: none;
    font-size: 12px;
    white-space: nowrap;
}

.user-menu-item:hover {
    background: #243656;
    color: #e0e8f0;
}

/* Cluster boundary circles (Clusters layout) */
.cluster-hull {
    fill: #4A90D9;
    fill-opacity: 0.05;
    stroke: #2a3a5c;
    stroke-width: 1.5;
    pointer-events: none;
}

.cluster-hull-label {
    fill: #9aa8b8;
    font-size: 13px;
    pointer-events: none;
}

/* Generic toolbar dropdown (cluster field picker) */
.tb-dropdown {
    display: none;
    position: fixed;
    min-width: 140px;
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    z-index: 200;
}

.tb-dropdown.open {
    display: block;
}

.tb-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    color: #b0bec5;
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
}

.tb-dropdown-item:hover {
    background: #243656;
    color: #e0e8f0;
}

.tb-dropdown-item.active {
    color: #4A90D9;
}

.user-avatar {
    border-radius: 50%;
    vertical-align: middle;
}

.user-avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: #4A90D9;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.user-name {
    font-size: 12px;
    color: #b0bec5;
    white-space: nowrap;
}

/* ---- Physics Tweaker Panel ---- */
.physics-tweaker-panel {
    grid-row: 2;
    grid-column: 2;
    justify-self: start;
    width: 260px;
    background: #121e30;
    border-right: 1px solid #2a3a5c;
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.physics-tweaker-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

.tweaker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #7a8a9e;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 14px 8px;
    flex-shrink: 0;
    border-bottom: 1px solid #2a3a5c;
}

.tweaker-reset-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #5a6a7e;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
}

.tweaker-reset-btn:hover {
    background: #243656;
    color: #e0e8f0;
}

.tweaker-presets {
    display: flex;
    gap: 6px;
    padding: 6px 14px;
    border-bottom: 1px solid #2a3a5c;
    flex-wrap: wrap;
}

.tweaker-preset-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #5a6a7e;
    padding: 3px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.15s;
}

.tweaker-preset-btn:hover {
    background: #243656;
    color: #e0e8f0;
    border-color: #3a5a8c;
}

.tweaker-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px 14px;
}

.tweaker-row {
    margin-bottom: 12px;
}

.tweaker-label {
    font-size: 11px;
    color: #7a8a9e;
    margin-bottom: 3px;
}

.tweaker-control {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.tweaker-step-btn {
    background: none;
    border: none;
    color: #546e7a;
    font-size: 14px;
    line-height: 1;
    width: 20px;
    height: 20px;
    padding: 0;
    cursor: pointer;
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
}

.tweaker-step-btn:hover {
    color: #e0e0e0;
    background: rgba(255,255,255,0.08);
}

.tweaker-slider {
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #1a2a44;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.tweaker-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2979ff;
    border: 2px solid #121e30;
    cursor: pointer;
    transition: background 0.15s;
}

.tweaker-slider::-webkit-slider-thumb:hover {
    background: #5a9cf5;
}

.tweaker-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2979ff;
    border: 2px solid #121e30;
    cursor: pointer;
}

.tweaker-slider::-moz-range-track {
    height: 4px;
    background: #1a2a44;
    border-radius: 2px;
}

.tweaker-value {
    font-size: 11px;
    color: #b0bec5;
    min-width: 42px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tweaker-step-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #2a3a54;
    border-radius: 4px;
    background: #1a2a44;
    color: #b0bec5;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.tweaker-step-btn:hover {
    background: #2979ff;
    color: #fff;
}

/* ---- Toolbar Search Trigger ---- */
.search-trigger-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    border-radius: 6px;
    padding: 5px 14px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 220px;
}

.search-trigger-bar:hover {
    background: #243656;
    border-color: #4a7abf;
}

.search-trigger-icon {
    font-size: 13px;
    color: #5a6a7e;
    line-height: 1;
    flex-shrink: 0;
}

.search-trigger-text {
    font-size: 12px;
    color: #5a6a7e;
    flex: 1;
    white-space: nowrap;
}

.search-trigger-hint {
    font-size: 10px;
    color: #4a5a6e;
    background: #0f1923;
    border: 1px solid #2a3a5c;
    border-radius: 3px;
    padding: 1px 6px;
    flex-shrink: 0;
    font-family: monospace;
}

/* ---- Search Modal ---- */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 50px;
}

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

.search-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 16, 24, 0.55);
}

.search-modal-content {
    position: relative;
    width: 96%;
    max-width: 1440px;
    max-height: calc(100vh - 100px);
    background: #121e30;
    border: 1px solid #2a3a5c;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-right 0.25s ease, width 0.25s ease;
}

/* When side panel is open from search, shift modal left to make room */
.search-modal.search-panel-open .search-modal-content {
    margin-right: 440px;
}

.search-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 28px;
    border-bottom: 1px solid #2a3a5c;
    flex-shrink: 0;
}

.search-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 28px;
    border-bottom: 1px solid #1e2d42;
    flex-shrink: 0;
}

.search-results-hidden-note {
    font-size: 12px;
    color: #5a6a7e;
    font-style: italic;
    margin-left: 10px;
}

.search-modal-icon {
    font-size: 18px;
    color: #5a6a7e;
    flex-shrink: 0;
    line-height: 1;
}

.search-modal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e0e8f0;
    font-size: 17px;
    outline: none;
    padding: 4px 0;
    font-family: inherit;
}

.search-modal-input::placeholder {
    color: #4a5a6e;
}

.search-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.search-visualize-btn {
    background: rgba(41, 121, 255, 0.12);
    border: 1px solid rgba(41, 121, 255, 0.3);
    color: #5a9cf5;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
    display: none;
}

.search-visualize-btn.visible {
    display: inline-block;
}

.search-visualize-btn:hover {
    background: rgba(41, 121, 255, 0.22);
    border-color: rgba(41, 121, 255, 0.5);
    color: #82b4ff;
}

.search-modal-close {
    background: none;
    border: none;
    color: #5a6a7e;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.search-modal-close:hover {
    color: #e0e8f0;
}

/* ---- Search Autocomplete ---- */
.search-modal-body {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.search-autocomplete {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    background: #121e30;
    border-bottom: 1px solid #2a3a5c;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-autocomplete.visible {
    display: block;
}

.search-ac-section-title {
    font-size: 10px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 28px 4px;
}

.search-ac-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 28px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
    color: #b0bec5;
}

.search-ac-item:hover,
.search-ac-item.active {
    background: rgba(41, 121, 255, 0.1);
}

.search-ac-item-icon {
    font-size: 11px;
    color: #5a6a7e;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.search-ac-item-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-ac-item-hint {
    font-size: 11px;
    color: #4a5a6e;
    flex-shrink: 0;
}

.search-ac-match {
    color: #5a9cf5;
    font-weight: 600;
}

/* ---- Search Results ---- */
.search-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: none;
}

.search-results.visible {
    display: flex;
    flex-direction: column;
}

.search-results-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    border-bottom: 1px solid #1e2d42;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: #121e30;
    z-index: 2;
}

.search-results-count {
    font-size: 12px;
    color: #5a6a7e;
}

.search-sort-controls {
    display: flex;
    gap: 4px;
}

.search-sort-btn {
    background: #1a2a44;
    border: 1px solid #2a3a5c;
    color: #7a8a9e;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
}

.search-sort-btn:hover {
    background: #243656;
    color: #e0e8f0;
}

.search-sort-btn.active {
    background: rgba(41, 121, 255, 0.15);
    border-color: #2979ff;
    color: #5a9cf5;
}

.search-results-table {
    width: 100%;
}

.search-result-header {
    display: flex;
    align-items: center;
    padding: 8px 28px;
    font-size: 10px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #1e2d42;
    position: sticky;
    top: 47px;
    background: #121e30;
    z-index: 1;
    user-select: none;
}

.search-result-header .search-result-cell {
    transition: color 0.15s;
    cursor: pointer;
    position: relative;
}

.search-result-header .search-result-cell:hover {
    color: #9aa8b8;
}

.search-result-row {
    display: flex;
    align-items: center;
    padding: 10px 28px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #1a2535;
    background: rgba(15, 25, 35, 0.6);
}

.search-result-row:hover {
    background: rgba(41, 121, 255, 0.08);
}

.search-result-row.exact-match {
    background: rgba(41, 121, 255, 0.06);
    border-left: 3px solid rgba(41, 121, 255, 0.4);
    padding-left: 25px;
}

.search-result-row.exact-match:hover {
    background: rgba(41, 121, 255, 0.12);
}

.search-result-row.selected {
    background: rgba(90, 156, 245, 0.14);
    border-left: 3px solid #5a9cf5;
    padding-left: 25px;
}

.search-result-row.selected:hover {
    background: rgba(90, 156, 245, 0.18);
}

.search-result-cell {
    font-size: 12px;
    color: #b0bec5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.search-result-cell.col-scope {
    width: 28px;
    flex-shrink: 0;
    padding-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.search-result-cell.col-icon {
    width: 28px;
    flex-shrink: 0;
    padding-right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.search-result-cell.col-name {
    flex: 1;
    min-width: 80px;
    font-weight: 600;
    font-size: 14px;
    color: #e0e8f0;
}

.search-result-cell.col-domain {
    width: 120px;
    flex-shrink: 0;
}

.search-result-cell.col-type {
    width: 120px;
    flex-shrink: 0;
}

.search-result-cell.col-framework {
    width: 100px;
    flex-shrink: 0;
}

.search-result-cell.col-team {
    width: 140px;
    flex-shrink: 0;
}

.search-result-cell.col-incoming {
    width: 50px;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #7a8a9e;
}

.search-result-cell.col-match {
    width: 180px;
    flex-shrink: 0;
    padding-right: 0;
}

/* Column resize handles */
.col-resize-handle {
    position: absolute;
    right: 0;
    top: 2px;
    bottom: 2px;
    width: 6px;
    cursor: col-resize;
    z-index: 3;
    transition: background 0.15s;
    border-right: 1px solid #2a3a5c;
}

.col-resize-handle:hover,
.col-resize-handle.dragging {
    border-right-color: rgba(41, 121, 255, 0.6);
    background: rgba(41, 121, 255, 0.15);
}

/* Visible column dividers on data rows */
.search-result-cell.col-domain,
.search-result-cell.col-type,
.search-result-cell.col-framework,
.search-result-cell.col-team,
.search-result-cell.col-incoming,
.search-result-cell.col-match {
    border-left: 1px solid #1e2d42;
    padding-left: 8px;
}

.search-match-highlight {
    color: #ffeb3b;
    font-weight: 600;
}

.search-no-results {
    padding: 48px 28px;
    text-align: center;
    color: #5a6a7e;
    font-size: 13px;
}

.sort-arrow {
    font-size: 9px;
    margin-left: 3px;
}

/* Scope (eye) button in search results */
.search-scope-btn {
    background: none;
    border: none;
    color: #3a4a5e;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 0;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.search-scope-btn:hover {
    color: #5a9cf5;
    background: rgba(41, 121, 255, 0.12);
}

/* Wider side-panel when opened from search modal */
body.search-panel-open .side-panel {
    z-index: 510;
}

body.search-panel-open.panel-open {
    grid-template-columns: 220px 1fr 440px;
}

/* ---- Search Expand (Chevron / Connections) ---- */
.search-result-cell.col-chevron {
    width: 28px;
    flex-shrink: 0;
    padding-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.search-expand-btn {
    background: none;
    border: none;
    color: #3a4a5e;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 10px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s, transform 0.2s;
}

.search-expand-btn:hover {
    color: #9aa8b8;
}

.search-expand-btn.expanded {
    transform: rotate(90deg);
    color: #5a9cf5;
}

.search-result-expand {
    background: rgba(18, 30, 48, 0.8);
    border-bottom: 1px solid #1a2535;
    padding: 4px 28px 8px 84px;
}

.search-expand-empty {
    font-size: 11px;
    color: #4a5a6e;
    padding: 6px 0;
}

.search-expand-list {
    display: flex;
    flex-direction: column;
}

.search-expand-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 12px;
    color: #9aa8b8;
}

.search-expand-item:hover {
    background: rgba(41, 121, 255, 0.08);
}

.search-expand-scope {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.search-expand-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.search-expand-type {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
    background: rgba(122, 138, 158, 0.15);
    color: #7a8a9e;
}

.search-expand-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #b0bec5;
}

/* ---- Version Footer ---- */
.version-footer {
    border-top: 1px solid #2a3a5c;
    padding: 4px 14px;
    text-align: left;
    font-size: 11px;
    font-style: italic;
    color: #5a6a7e;
    margin-top: auto;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Settle Indicator (post-load, while the simulation cools) ---- */
.settle-indicator {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #16273b;
    border: 1px solid #2a3a5c;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 12px;
    color: #7a8a9e;
    z-index: 900;
    transition: opacity 0.3s;
    pointer-events: none;
}

.settle-indicator.hidden {
    opacity: 0;
}

.settle-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #2a3a5c;
    border-top-color: #5a9cf5;
    border-radius: 50%;
    animation: settle-spin 0.8s linear infinite;
}

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

/* ---- Scope chip grouping (AND/OR layout) ---- */
.scope-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.scope-group-multi {
    border: 1px dashed #2a3a5c;
    border-radius: 10px;
    padding: 5px;
}

.scope-bool-op {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #5a6a7e;
    padding: 0 4px;
    flex-shrink: 0;
}

.scope-bool-paren {
    font-size: 14px;
    color: #5a6a7e;
    flex-shrink: 0;
}

/* ---- Search results CSV export ---- */
.search-export-btn {
    background: none;
    border: 1px solid #2a3a5c;
    border-radius: 4px;
    color: #7a8a9e;
    font-size: 11px;
    padding: 3px 10px;
    cursor: pointer;
    margin-left: auto;
    margin-right: 10px;
    transition: color 0.15s, border-color 0.15s;
}

.search-export-btn:hover {
    color: #e0e8f0;
    border-color: #5a9cf5;
}

/* ---- Help Overlay ---- */
.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none;
}

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

.help-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 10, 18, 0.7);
}

.help-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 560px;
    max-width: 94%;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    background: #121e30;
    border: 1px solid #2a3a5c;
    border-radius: 10px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #2a3a5c;
}

.help-header h2 {
    margin: 0;
    font-size: 15px;
    color: #e0e8f0;
}

.help-body {
    overflow-y: auto;
    padding: 6px 20px 16px;
}

.help-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5a9cf5;
    margin: 16px 0 6px;
}

.help-section ul {
    margin: 0;
    padding-left: 18px;
    color: #9aa8b8;
    font-size: 13px;
    line-height: 1.7;
}

.help-section code {
    background: #1a2940;
    border: 1px solid #2a3a5c;
    border-radius: 3px;
    padding: 0 4px;
    font-size: 12px;
    color: #7fc6f5;
}

.help-kbd {
    display: inline-block;
    background: #1a2940;
    border: 1px solid #2a3a5c;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0 6px;
    font-size: 11px;
    color: #9aa8b8;
    vertical-align: middle;
}
