:root {
    /* Color Palette - Kinetic Industrialism v2 */
    --bg-void: #050505;
    /* Deepest Void */
    --bg-void-slate: #0a0e14;
    /* Panel Background */
    --bg-glass: rgba(5, 5, 5, 0.95);
    /* Glass Overlay */

    --accent-cyan: #00F0FF;
    /* System Highlights */
    --accent-green: #39FF14;
    /* Active / Normal State */
    --accent-orange: #FF5F00;
    /* Alerts / Flux State */
    --accent-purple: #bd00ff;
    /* Special / Magic */

    --text-primary: #e6f6ff;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-active: #00F0FF;
    --bg-panel: rgba(15, 20, 30, 0.6);

    /* Typography */
    --font-heading: 'Exo 2', sans-serif;
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing & Layout */
    --header-height: 60px;
    /* Slim Horizon Bar */
    --footer-height: 40px;
    /* Status Deck */
    --sidebar-width: 300px;
    /* Neural Tree */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-void);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden;
    height: 100vh;
    font-size: 14px;
}

/* Viewport Glow */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 150px rgba(0, 240, 255, 0.05);
    pointer-events: none;
    z-index: 9999;
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

a {
    color: var(--text-primary);
    text-decoration: none;
}

/* --- Main Layout Grid --- */
.foundry-shell {
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--footer-height);
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    width: 100vw;
}

/* 1. Horizon Bar (Header) */
.horizon-bar {
    grid-column: 1 / -1;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.horizon-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.brand {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    display: none;
    /* Deprecated */
}

/* Logo Styles */
.logo-container {
    position: relative;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    cursor: pointer;
    overflow: hidden;
    /* Mask the sheen */
    border-radius: 4px;
    /* Optional: Slight rounding if images are square, otherwise remove */
}

.logo-base,
.logo-active {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.logo-active {
    opacity: 0;
    /* Hidden by default */
}

.logo-container:hover .logo-active {
    opacity: 1;
    /* Show yellow on hover */
}

.logo-container:hover .logo-base {
    opacity: 0;
    /* Hide blue on hover */
}

/* Sheen Effect */
/* Sheen Effect */
.logo-sheen {
    position: absolute;
    top: 15%;
    /* Centered vertically (100-70)/2 */
    left: 150%;
    width: 20%;
    /* Narrow vertical bar */
    height: 70%;
    /* Reduced height as requested */
    background: linear-gradient(to right,
            transparent,
            rgba(255, 255, 255, 0.8),
            transparent);
    /* No skew - Vertical */
    animation: sheen-pingpong 5s infinite ease-in-out;
    pointer-events: none;
}

@keyframes sheen-pingpong {
    0% {
        left: 150%;
    }

    /* Start Right */
    45% {
        left: -50%;
    }

    /* Move to Left */
    50% {
        left: -50%;
    }

    /* Pause */
    95% {
        left: 150%;
    }

    /* Move back to Right */
    100% {
        left: 150%;
    }
}

/* Sidebar (System Menu) */
.system-menu {
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--border-subtle);
    /* height: 100%; Removed to allow flow in .neural-tree */
    /* overflow: hidden; Removed */
    display: flex;
    flex-direction: column;
}

.system-menu .menu-header {
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    background: var(--bg-void-slate);
}

.system-menu .menu-items {
    flex: 1;
    display: none; /* hidden by default */
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.system-menu.active .menu-items {
    display: flex;
}

.system-menu .menu-btn {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 12px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1px;
}

.system-menu .menu-btn:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--accent-cyan);
    padding-left: 20px;
}



.version-tag {
    font-size: 10px;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    padding: 2px 6px;
    border-radius: 4px;
}

.context-crumb {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.horizon-center {
    display: flex;
    gap: 20px;
}

.status-pill {
    font-family: var(--font-mono);
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

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

.dot.green {
    background: var(--accent-green);
    box-shadow: 0 0 5px var(--accent-green);
}

.dot.orange {
    background: var(--accent-orange);
    box-shadow: 0 0 5px var(--accent-orange);
}

.horizon-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Command Terminal */
.command-terminal-wrapper {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    width: 400px;
    height: 36px;
    transition: all 0.2s ease;
}

.command-terminal-wrapper:focus-within {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.05);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.cmd-prompt {
    color: var(--accent-green);
    font-family: var(--font-mono);
    font-weight: bold;
    margin-right: 8px;
    user-select: none;
}

.command-terminal-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    flex: 1;
    outline: none;
    padding: 0;
}

.command-terminal-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.5;
}

.cmd-shortcut {
    color: var(--text-muted);
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    padding: 2px 5px;
    margin-left: 8px;
}

/* 2. Neural Tree (Sidebar) */
.neural-tree {
    grid-row: 2 / 3;
    grid-column: 1 / 2;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
}

.tree-header {
    padding: 15px 20px;
    font-size: 12px;
    color: var(--accent-cyan);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: bold;
}

.tree-section {
    margin-bottom: 10px;
}

.tree-title {
    padding: 10px 20px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.tree-item {
    padding: 8px 20px 8px 30px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.2s;
}

.tree-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.tree-item.active {
    color: var(--accent-green);
    border-left-color: var(--accent-green);
    background: rgba(57, 255, 20, 0.05);
}

/* 3. Viewport (Main) */
.viewport {
    grid-row: 2 / 3;
    grid-column: 2 / 3;
    background: var(--bg-void);
    padding: 0;
    position: relative;
    /* Flex container to hold fixed header + scrollable content */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viewport-header {
    height: 50px;
    background: rgba(10, 14, 20, 0.4);
    /* Subtle contrast */
    border-bottom: none;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.viewport-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    /* HTMX swap target */
}

/* Adjust Terminal for Viewport Header */
.viewport-header .command-terminal-wrapper {
    width: 100%;
    /* max-width: 600px; Remove max-width if you want full uniformity, or keep it */
    background: rgba(0, 0, 0, 0.2);
    border: none;
    /* Cleaner look in sub-header? Or keep border? */
    border-bottom: 1px solid transparent;
    /* Placeholder */
}

.viewport-header .command-terminal-wrapper:focus-within {
    background: rgba(0, 240, 255, 0.05);
}

/* Dashboard Grid inside Viewport */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(150px, auto);
    gap: 20px;
    padding: 30px;
}

.dash-card {
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.dash-card.wide {
    grid-column: span 2;
}

.dash-card.full {
    grid-column: 1 / -1;
}

/* 4. Status Deck (Footer) */
.status-deck {
    grid-row: 3 / 4;
    grid-column: 1 / -1;
    background: #000;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.deck-left,
.deck-right {
    display: flex;
    gap: 20px;
}

.deck-item {
    display: flex;
    gap: 5px;
}

.deck-val {
    color: var(--accent-cyan);
}

/* --- Component View Styles --- */
.component-header {
    padding: 30px;
    border-bottom: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, var(--bg-void-slate) 0%, var(--bg-void) 100%);
}

.component-tabs {
    display: flex;
    gap: 30px;
    padding: 0 30px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-void-slate);
}

.tab-btn {
    padding: 15px 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

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

.tab-btn.active {
    color: var(--accent-green);
    border-bottom-color: var(--accent-green);
}

.component-body {
    padding: 30px;
}

/* Form Elements */
input,
textarea,
select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 8px;
    font-family: var(--font-mono);
    width: 100%;
}

input:focus {
    border-color: var(--accent-cyan);
    outline: none;
}

.btn {
    background: rgb(13, 15, 25);
    border: 1px solid rgb(18, 22, 35);
    color: rgb(24, 28, 38);
    padding: 8px 16px;
    font-family: var(--font-mono);
    text-transform: uppercase;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn .material-symbols-outlined {
    color: var(--accent-cyan);
    font-size: 18px;
}

.btn:hover {
    background: rgb(20, 25, 40);
    border-color: var(--accent-cyan);
    color: var(--text-secondary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.btn.danger {
    background: rgba(255, 0, 0, 0.2);
    border-color: rgba(255, 0, 0, 0.4);
    color: #ffcccc;
}

.btn.danger:hover {
    background: rgba(255, 0, 0, 0.4);
    border-color: #ff0000;
    color: white;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.2);
}

/* Flux Overlay */
.flux-overlay {
    position: fixed;
    bottom: 50px;
    right: 20px;
    width: 400px;
    height: 500px;
    z-index: 2000;
}

.flux-window {
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid var(--accent-orange);
    box-shadow: 0 0 30px rgba(255, 95, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.flux-header {
    background: var(--accent-orange);
    color: #000;
    padding: 10px 15px;
    font-family: var(--font-heading);
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flux-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 12px;
}

.flux-msg {
    margin-bottom: 10px;
    line-height: 1.4;
}

.flux-msg.user {
    color: var(--accent-cyan);
}

.flux-msg.system {
    color: var(--accent-orange);
}

.flux-input-area {
    padding: 10px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.5);
}

#flux-input {
    border: 1px solid var(--accent-orange);
    color: var(--accent-orange);
}

.hidden {
    display: none !important;
}

/* --- VISUAL MAP --- */
#foundry-map {
    position: absolute;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: var(--footer-height);
    background: radial-gradient(circle at 50% 50%, #1a1f2e 0%, #0a0d14 100%);
    overflow: hidden;
    z-index: 900;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#foundry-map.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.map-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgba(10, 14, 20, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

.map-title {
    font-family: var(--font-heading);
    color: var(--accent-cyan);
    font-size: 14px;
    letter-spacing: 1px;
}

.map-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-controls .divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 5px;
}

.map-controls .zoom-level {
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 12px;
    width: 40px;
    text-align: center;
}

.btn.small {
    font-size: 11px;
    padding: 4px 10px;
}

.btn.icon-only {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

/* NODES - GLASSMORPHISM */
.map-node {
    position: absolute;
    width: 240px;
    /* Wider for details */
    background: rgba(15, 20, 30, 0.6);
    /* Darker, slightly transparent */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    /* Accent top */
    border-radius: 12px;
    padding: 0;
    cursor: grab;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    user-select: none;
    display: flex;
    flex-direction: column;
}

.map-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
    z-index: 5;
}

.map-node:active {
    cursor: grabbing;
}

/* Special Node: Foundry Hub */
.map-node.hub-node {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.15);
    width: 280px;
    z-index: 10;
    cursor: default !important; /* Stationary */
}

.map-node.hub-node:hover {
    transform: none; /* No hover lift for stationary */
    box-shadow: 0 0 50px rgba(0, 240, 255, 0.3);
}

.map-node.hub-node .node-header {
    background: rgba(0, 240, 255, 0.2);
    color: #fff;
    border-bottom: 1px solid rgba(0, 240, 255, 0.3);
}

.map-node.hub-node .node-icon {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
    0%, 100% { text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }
    50% { text-shadow: 0 0 20px rgba(0, 240, 255, 1); }
}
    user-select: none;
    z-index: 10;
    color: var(--text-primary);
    font-family: var(--font-mono);

    /* Glass Effect */
    backdrop-filter: blur(12px) saturate(180%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
    overflow: hidden;
}

.map-node:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.2), 0 8px 32px rgba(0, 0, 0, 0.5);
    transform: translateY(-4px) scale(1.02);
    z-index: 20;
    background: rgba(15, 20, 30, 0.7);
}

.map-node:active {
    cursor: grabbing;
    background: rgba(20, 25, 35, 0.95);
}

.map-node.connecting-source {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px var(--accent-green);
}

/* Node Internals */
.node-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 11px;
    color: var(--text-primary);
}

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

.node-body {
    padding: 10px;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.node-footer {
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-status {
    display: flex;
    align-items: center;
    gap: 4px;
}

.node-status .dot {
    width: 4px;
    height: 4px;
}

/* Category Colors */
.map-node[data-category="CORE"] {
    border-top-color: var(--accent-cyan);
}

.map-node[data-category="AGENT"] {
    border-top-color: var(--accent-purple);
}

.map-node[data-category="EDGE"] {
    border-top-color: var(--accent-orange);
}

.map-node[data-category="EDU"] {
    border-top-color: var(--accent-green);
}

.map-connection-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.map-connection {
    stroke: var(--text-muted);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.2s;
    pointer-events: auto;
    /* Allow clicking the line */
    cursor: pointer;
}

.map-connection:hover {
    stroke: var(--accent-orange);
    stroke-width: 3;
}

.map-connection.temp {
    stroke: var(--accent-green);
    opacity: 0.6;
}

/* Map Modal - Glass */
.map-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s;
}

.map-modal.hidden {
    display: none;
}

.map-modal-content {
    background: rgba(20, 25, 35, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 24px;
    border-radius: 16px;
    width: 320px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.map-modal h4 {
    margin: 0;
    color: var(--accent-cyan);
}

.map-modal input,
.map-modal select {
    width: 100%;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    border-radius: 4px;
    margin-top: 5px;
}

.map-modal .modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn.danger {
    border-color: #ff4444;
    color: #ff4444;
}

.btn.danger:hover {
    background: rgba(255, 68, 68, 0.1);
}

/* Schema Modal Specifics */
#schema-textarea {
    height: 300px;
    background: rgba(0, 0, 0, 0.5);
    color: var(--accent-cyan);
    font-size: 11px;
    line-height: 1.4;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px;
    resize: none;
    font-family: var(--font-mono);
}

#schema-textarea:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

/* Global Button Styling */
button,
.btn,
.tab-btn {
    border-radius: 5px !important;
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

/* Icon Alignment */
.material-symbols-outlined {
    vertical-align: middle;
    line-height: normal;
    /* Fix height */
    display: inline-flex;
    align-items: center;
}

/* Flex Buttons for Icon Centering */
.btn,
.tab-btn,
.tree-item,
.node-card {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tree-item {
    justify-content: flex-start;
    /* Tree items left align */
}

.node-card {
    flex-direction: column;
    /* Node cards vertical */
}

/* --- Command Grid Layout --- */
.command-layout {
    display: grid;
    grid-template-areas:
        "foundry foundry"
        "core agents";
    grid-template-columns: 250px 1fr;
    gap: 20px;
    margin-top: 20px;
    min-width: 800px;
    min-height: 65vh;
    align-content: start;
    position: relative;
    /* Circuit Lines Overlay */
}

/* Vertical Stem from Foundry */
.command-layout::before {
    content: '';
    position: absolute;
    top: 60px;
    /* Below Foundry Card */
    left: 50%;
    width: 2px;
    height: 50px;
    background: repeating-linear-gradient(to bottom, #777 0, #777 2px, transparent 2px, transparent 4px);
    opacity: 0.6;
    z-index: 0;
}

/* Horizontal Bus */
.command-layout::after {
    content: '';
    position: absolute;
    top: 110px;
    left: 125px;
    /* Center of Core Column roughly */
    right: 25%;
    /* Center of Agent Column roughly */
    height: 2px;
    background: repeating-linear-gradient(to right, #777 0, #777 2px, transparent 2px, transparent 4px);
    opacity: 0.6;
    z-index: 0;
}

.cmd-foundry {
    grid-area: foundry;
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
    border-bottom: none;
    margin-bottom: 60px;
    /* Increased for lines */
    position: relative;
    z-index: 10;
}

.cmd-core {
    grid-area: core;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-right: none;
    padding-right: 20px;
    position: relative;
    z-index: 10;
}

/* Cyan Drop Line for Core */
.cmd-core::before {
    content: '';
    position: absolute;
    top: -30px;
    /* From Bus */
    left: 50%;
    width: 2px;
    height: 30px;
    background: repeating-linear-gradient(to bottom, var(--accent-cyan) 0, var(--accent-cyan) 2px, transparent 2px, transparent 4px);
    box-shadow: 0 0 5px var(--accent-cyan);
    z-index: 0;
}

.cmd-agents {
    grid-area: agents;
    display: flex;
    flex-wrap: wrap;
    align-content: start;
    gap: 15px;
    position: relative;
}

/* Green Drop Line for Agents */
.cmd-agents::before {
    content: '';
    position: absolute;
    top: -20px;
    /* From Bus */
    left: 20%;
    /* Align somewhat with cards */
    width: 1px;
    height: 20px;
    background: repeating-linear-gradient(to bottom, var(--accent-green) 0, var(--accent-green) 5px, transparent 5px, transparent 10px);
    box-shadow: 0 0 5px var(--accent-green);
}

.cmd-agents {
    grid-area: agents;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-content: flex-start;
}

/* Glass Node Card (Matches Map Node) */
.node-card-glass {
    background: var(--bg-panel);
    /* Active slate */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px 15px;
    min-width: 180px;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Override glass background for command structure */
.command-layout .node-card-glass {
    background: transparent;
}

.node-card-glass:hover {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.node-card-glass.root {
    background: rgba(13, 15, 25, 0.9);
    border: 1px solid var(--accent-cyan);
    min-width: 250px;
    justify-content: center;
    padding: 15px;
}

.node-card-glass.core {
    border-left: 2px solid var(--accent-orange);
}

.node-card-glass.agent {
    border-left: 2px solid var(--accent-green);
}

.nc-icon {
    font-size: 18px;
    color: var(--text-secondary);
}

.nc-info {
    display: flex;
    flex-direction: column;
}

.nc-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
}

.nc-type {
    font-size: 10px;
    color: var(--text-muted);
}

/* Stealth Bump Button */
.btn-bump {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 2px solid rgba(0, 0, 0, 0.8);
    /* Tactile Bump */
    color: var(--text-secondary);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-bump:hover {
    background: rgba(30, 35, 45, 0.8);
    border-color: var(--text-muted);
    transform: translateY(-1px);
    color: var(--text-primary);
}

.btn-bump:active {
    border-bottom: 1px solid rgba(0, 0, 0, 0.8);
    transform: translateY(1px);
    box-shadow: none;
}

/* Metrics Panel */
.metrics-panel {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-panel);
    padding: 12px 8px;
    border-radius: 6px;
    margin-bottom: 20px;
    gap: 12px;
}

.metric-item {
    text-align: center;
}

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

.metric-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--accent-green);
    transition: background-color 0.5s ease;
}

.metric-value.updated {
    background-color: rgba(0, 255, 0, 0.2);
    animation: pulseGreen 1s ease-out;
}

@keyframes pulseGreen {
    0% {
        background-color: rgba(0, 255, 0, 0.4);
    }

    100% {
        background-color: transparent;
    }
}