/* Reset and Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-main: #0a0a0a;
    --bg-panel: #0a0a0a;
    --border-color: #262626; /* neutral-800 */
    --border-light: rgba(38, 38, 38, 0.5);
    
    --text-primary: #d4d4d4; /* neutral-300 */
    --text-heading: #f5f5f5; /* neutral-100 */
    --text-muted: #737373; /* neutral-500 */
    
    --accent-red: #ef4444;
    --accent-amber: #f59e0b;
    --accent-green: #10b981;
    --accent-cyan: #06b6d4;
    
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Scrollbar Utility */
.hide-scrollbar::-webkit-scrollbar {
    display: none;
}
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Header / Status Bar */
.dashboard-header {
    height: 40px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-main);
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.globe-icon {
    font-size: 14px;
}

.logo-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-heading);
}

.divider {
    height: 16px;
    width: 1px;
    background-color: var(--border-color);
}

.system-stats {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 16px;
}

.system-stats span span {
    font-weight: 500;
}

.header-right {
    gap: 24px;
}

/* Omnibar Search */
.search-wrap {
    position: relative;
    flex: 1;
    max-width: 420px;
    margin: 0 16px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #0a0a0a;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 0 8px;
    height: 26px;
    transition: border-color 0.15s ease;
}

.search-box:hover, .search-box:focus-within {
    border-color: var(--text-muted);
}

.search-icon {
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-heading);
    font-family: var(--font-mono);
    font-size: 11px;
    height: 100%;
}

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

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #050505;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    max-height: 360px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.search-results.hidden {
    display: none;
}

.search-group-label {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 10px 4px;
    border-bottom: 1px solid var(--border-light);
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background-color 0.15s ease;
}

.search-result-item:hover {
    background-color: rgba(23, 23, 23, 0.7);
}

.search-result-name {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-heading);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-result-article {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-primary);
}

.search-empty {
    padding: 12px 10px;
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.stat-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.meta-label {
    color: var(--text-muted);
}

.meta-value {
    font-weight: 500;
}

/* Helpers */
.text-emerald { color: var(--accent-green) !important; }
.text-amber { color: var(--accent-amber) !important; }
.text-red { color: var(--accent-red) !important; }
.text-white { color: var(--text-heading) !important; }

.btn-scan {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-scan:hover {
    background-color: #171717;
    border-color: var(--text-muted);
    color: var(--text-heading);
}

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

/* Main Layout Grid */
.dashboard-main {
    flex: 1;
    display: grid;
    grid-template-columns: 3fr 6fr 3fr;
    background-color: var(--border-color);
    gap: 1px;
    height: calc(100vh - 40px - 72px);
    overflow: hidden;
}

/* Panel Containers */
.panel-left, .panel-center, .panel-right {
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.panel-header {
    height: 36px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Pulse Indicator */
.pulse-indicator {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-green);
    animation: simplePulse 2s infinite;
}

@keyframes simplePulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Intelligence Feed Styles */
.feed-container {
    display: flex;
    flex-direction: column;
}

.feed-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.feed-item:hover {
    background-color: rgba(23, 23, 23, 0.5);
}

.feed-item.active {
    background-color: rgba(23, 23, 23, 0.8);
    border-left: 2px solid var(--text-primary);
}

.feed-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.feed-source {
    color: var(--text-primary);
}

.feed-text {
    font-size: 12px;
    line-height: 1.5;
    color: #d4d4d4;
    transition: color 0.15s ease;
}

.feed-item:hover .feed-text {
    color: var(--text-heading);
}

.sentiment-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 2px;
}

.sentiment-tag.critical { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.sentiment-tag.high { background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.sentiment-tag.emerald { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.sentiment-tag.neutral { background: rgba(115, 115, 115, 0.1); color: var(--text-muted); }

/* Center Topology Graph Panel */
.panel-center {
    background-color: #080808;
}

.topology-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    background-color: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 2px;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    pointer-events: none;
}

.graph-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    opacity: 0.025;
    background-image: linear-gradient(var(--text-heading) 1px, transparent 1px),
                      linear-gradient(90deg, var(--text-heading) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

#network-graph {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* D3 SVG Elements styling */
.link-line {
    transition: stroke 0.25s ease, stroke-width 0.25s ease;
}

.node-circle {
    transition: fill 0.2s ease, stroke 0.2s ease;
    cursor: pointer;
}

.node-label {
    fill: #a3a3a3;
    font-family: var(--font-mono);
    font-size: 10px;
    transition: fill 0.2s ease, font-weight 0.2s ease;
}

.node-group.selected .node-label {
    fill: var(--text-heading);
    font-weight: 700;
}

/* Zoom Widget */
.zoom-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zoom-controls button {
    width: 28px;
    height: 28px;
    background-color: rgba(10, 10, 10, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.zoom-controls button:hover {
    background-color: #171717;
    color: var(--text-heading);
}

/* Right Entity Inspector Panel */
.inspector-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.inspector-empty {
    color: var(--text-muted);
    text-align: center;
    padding-top: 48px;
    font-size: 12px;
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.entity-name {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.entity-description {
    font-size: 12px;
    color: var(--text-muted);
}

.risk-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 2px;
    border: 1px solid transparent;
}

.risk-tag.critical { border-color: rgba(239, 68, 68, 0.4); text-color: var(--accent-red); background: rgba(239, 68, 68, 0.08); color: var(--accent-red); }
.risk-tag.high { border-color: rgba(245, 158, 11, 0.4); text-color: var(--accent-amber); background: rgba(245, 158, 11, 0.08); color: var(--accent-amber); }
.risk-tag.elevated { border-color: rgba(245, 158, 11, 0.2); text-color: var(--accent-amber); background: rgba(245, 158, 11, 0.04); color: #f59e0b; }
.risk-tag.low { border-color: rgba(16, 185, 129, 0.4); text-color: var(--accent-green); background: rgba(16, 185, 129, 0.08); color: var(--accent-green); }

/* Metrics Grid Table */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background-color: var(--border-color);
    border: 1px solid var(--border-color);
}

.metric-item {
    background-color: var(--bg-panel);
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.metric-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

.metric-value.impact-num {
    font-family: var(--font-mono);
    font-size: 18px;
}

/* Micro Trajectory Chart Widget */
.chart-widget {
    border: 1px solid var(--border-color);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.chart-canvas-wrapper {
    height: 64px;
    position: relative;
    width: 100%;
}

.sparkline-svg {
    width: 100%;
    height: 100%;
}

/* Dependencies Section */
.dependencies-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dep-header {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.dep-list {
    display: flex;
    flex-direction: column;
}

.dep-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(38, 38, 38, 0.4);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dep-item:hover {
    background-color: rgba(23, 23, 23, 0.5);
}

.dep-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dep-arrow {
    font-size: 12px;
    color: #404040;
    transition: transform 0.2s ease;
}

.dep-arrow.inbound {
    transform: rotate(180deg);
}

.dep-name {
    color: var(--text-primary);
}

.dep-value {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
}

/* Dossier Header Area */
.dossier-header {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.dossier-image-wrap {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    background-color: #0d0d0d;
    border: 1px solid #404040;
    position: relative;
    overflow: hidden;
    padding: 2px;
}

.dossier-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) contrast(125%);
    opacity: 0.7;
    transition: all 0.5s ease;
}

.dossier-image-wrap:hover .dossier-img {
    filter: grayscale(0%) contrast(100%);
    opacity: 1;
}

.scanline-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(10,10,10,0) 50%, rgba(0,0,0,0.25) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.5;
}

.vignette-overlay {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 15px rgba(10, 10, 10, 1);
    pointer-events: none;
}

.dossier-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 80px;
    padding-top: 4px;
}

.dossier-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.system-id {
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: auto;
}

/* Wikipedia Context Section */
.wiki-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wiki-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.wiki-title {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.wiki-source-link {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s ease;
}

.wiki-source-link:hover {
    color: var(--text-heading);
}

.wiki-brief {
    font-size: 12px;
    line-height: 1.6;
    color: #a3a3a3; /* neutral-400 */
    text-align: justify;
    margin: 0;
}

.wiki-loader {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 0;
}

/* WHY / Reasoning Section */
.why-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.why-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.why-title {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.why-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 8px 0;
}

.why-item {
    border: 1px solid var(--border-color);
    border-left: 2px solid var(--text-muted);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.why-item.critical { border-left-color: var(--accent-red); }
.why-item.high { border-left-color: var(--accent-amber); }
.why-item.medium { border-left-color: var(--accent-amber); }
.why-item.low { border-left-color: var(--accent-green); }

.why-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 10px;
}

.why-item-score {
    font-weight: 700;
}

.why-item-article {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-heading);
}

.why-item-article a {
    color: inherit;
    text-decoration: none;
}

.why-item-article a:hover {
    text-decoration: underline;
}

.why-item-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.why-item-path {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 10px;
}

.why-path-node {
    background-color: #0d0d0d;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 1px 6px;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.why-path-node:hover {
    border-color: var(--text-muted);
    color: var(--text-heading);
}

.why-path-node.endpoint {
    color: var(--text-heading);
    font-weight: 700;
}

.why-path-arrow {
    color: #404040;
}

/* Watchlist Panel Styles */
.watchlist-section {
    height: 72px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 6px 16px 4px 16px;
    flex-shrink: 0;
    overflow: hidden;
}
.watchlist-header {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.watchlist-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
}
.watchlist-container::-webkit-scrollbar {
    height: 3px;
}
.watchlist-container::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 2px;
}
.watchlist-loading {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    align-self: center;
}
.watchlist-card {
    min-width: 175px;
    max-width: 220px;
    background-color: #0e0e0e;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.15s ease;
}
.watchlist-card:hover {
    border-color: var(--text-muted);
    background-color: #171717;
}
.card-top, .card-mid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.card-ticker {
    font-weight: 700;
    color: var(--text-heading);
    font-size: 11px;
}
.card-price {
    color: #a3a3a3;
    font-size: 11px;
}
.card-sentiment {
    font-size: 9px;
}
.card-change {
    font-size: 9px;
    font-weight: 600;
}
.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.card-vol {
    font-size: 8px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.card-driver {
    font-size: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
    flex: 1;
}

