#job-view-window-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 20, 30, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

#job-view-window-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#job-view-window {
    background: linear-gradient(145deg, #2c3e50, #212f3c);
    color: #ecf0f1;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    width: 95%;
    max-width: 1800px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #4a627a;
    transform: translateY(-20px) scale(0.98);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease-out;
}

#job-view-window-overlay.visible #job-view-window {
    transform: translateY(0) scale(1);
}

.job-view-header {
    padding: 15px 25px;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #4a627a;
    flex-shrink: 0;
}

.job-view-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.4);
}

#job-view-close-btn {
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 2.2em;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s, color 0.2s;
}

#job-view-close-btn:hover {
    transform: rotate(90deg) scale(1.1);
    color: #e74c3c;
}

.job-view-controls {
    padding: 15px 25px 15px 25px;
    display: flex;
    gap: 15px;
    border-bottom: 1px solid #4a627a;
    flex-shrink: 0;
    align-items: flex-end;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1 1 300px;
}

.control-group label {
    font-size: 0.9em;
    color: #bdc3c7;
    font-weight: bold;
}

.control-group select {
    width: 100%;
    background-color: #34495e;
    border: 1px solid #4a627a;
    color: #ecf0f1;
    padding: 10px 12px;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
    height: 44px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.control-group select:focus {
    border-color: #1abc9c;
    outline: none;
    box-shadow: 0 0 8px rgba(26, 188, 156, 0.4);
}

.job-view-controls option {
    background-color: #34495e;
    color: #ecf0f1;
}

.job-view-controls .control-group:nth-child(2) {
    position: relative;
}

#job-view-item-filter {
    width: 100%;
    background-color: #121827;
    border: 1px solid #3c4b6c;
    color: #cdd8f0;
    padding: 6px;
    border-radius: 3px;
    box-sizing: border-box;
    text-align: center;
    font-size: 1.1em;
}

#job-view-item-filter:focus {
    border-color: #1abc9c;
    outline: none;
    box-shadow: 0 0 5px rgba(26, 188, 156, 0.5);
}

#recipe-datalist {
    background-color: #1e2a45;
    border: 1px solid #3c4b6c;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    color: #cdd8f0;
}

#recipe-datalist option {
    padding: 8px 12px;
    color: #cdd8f0;
    background-color: #1e2a45;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#recipe-datalist option:hover {
    background-color: #2a3b5c;
}

.job-view-body {
    padding: 0;
    overflow: hidden;
    flex-grow: 1;
    display: flex;
    position: relative;
}

#job-graph-container {
    flex-grow: 1;
    height: 100%;
    width: 100%;
    position: relative;
}

.placeholder-text {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #7f8c8d;
    font-size: 1.2em;
}

#vis-html-node-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* NEW: Utility class to promote an element to its own GPU layer for performance. */
.gpu-layer {
    will-change: transform;
    transform: translateZ(0);
}


/* Base HTML Node Styling */
.vis-html-node {
    display: flex;
    align-items: center;
    background-color: #2c3e50;
    border: 2px solid #5a728a;
    border-radius: 40px;
    padding: 6px;
    transition: box-shadow 0.2s, border-color 0.2s, background-color 0.5s ease, opacity 0.4s ease;
    white-space: nowrap;
    min-width: 200px;
    min-height: 70px;
    box-sizing: border-box;
    pointer-events: all;
    z-index: 10;
    cursor: pointer;
    transform-origin: center center;
    position: relative; /* All positioning is now relative inside the positioner */
}

.vis-html-node.active {
    border-color: #1abc9c;
    box-shadow: 0 0 15px rgba(26, 188, 156, 0.6);
}

/* --- ANIMATIONS --- */
@keyframes sheen-animation {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
}

@keyframes pulse-animation {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
    100% { filter: brightness(1); }
}

/* Player Job Node specific styling */
.vis-html-node.player-job-node {
    z-index: 5;
    border-color: #00c7e0;
    box-shadow: 0 0 15px rgba(0, 199, 224, 0.6);
    position: relative;
    overflow: visible;
}

.progress-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    border-radius: 40px;
    overflow: hidden;
}

.progress-bar-fill {
    position: relative;
    height: 100%;
    background-color: #4A90E2;
    width: var(--progress-width, 0%);
    transition: width 0.4s ease-out, background-color 0.5s ease;
    overflow: hidden;
    border-radius: 40px;
}

.progress-bar-sheen {
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    opacity: 0;
    will-change: transform;
    transform: translateZ(0);
}

.vis-html-node.player-job-node.is-active .progress-bar-sheen {
    animation: sheen-animation 1.5s ease-in-out infinite;
    opacity: 1;
}

.vis-html-node.player-job-node.is-complete .progress-bar-fill {
    background-color: #27ae60;
    animation: pulse-animation 2.5s ease-in-out infinite;
}

.vis-html-node.player-job-node.is-complete {
    border-color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
}

.vis-html-node.player-job-node.is-complete.highlight-orange {
    border-color: #27ae60 !important;
    box-shadow: 0 0 18px rgba(46, 204, 113, 0.8) !important;
}

.vis-html-node.player-job-node.highlight-orange {
    border-color: #ffa500 !important;
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.6) !important;
}

/* Node content must be above the progress bar */
.node-icon-container,
.node-content,
.node-crew-container {
    position: relative;
    z-index: 1;
}

.node-icon-container {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #212f3c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    margin-right: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.node-icon-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    padding: 0 5px;
}

.node-name {
    font-size: 1.0em;
    font-weight: 600;
    color: #ecf0f1;
    margin-bottom: 2px;
    width: 100%;
    text-align: center;
}

.node-total-amount {
    font-size: 1.2em;
    font-weight: 700;
    color: #f1c40f;
    text-align: center;
}

.node-crew-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 100%;
    padding-left: 10px;
    border-left: 1px solid #4a627a;
    margin-left: 10px;
    flex-shrink: 0;
}

.node-total-crew {
    font-size: 0.9em;
    font-weight: 600;
    color: #ecf0f1;
}

.node-daily-output {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8em;
    color: #1abc9c;
    background-color: #212f3c;
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid #4a627a;
    pointer-events: all;
    cursor: pointer;
    z-index: 1;
}

/* Exploded Node Specifics */
.exploded-node {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #756e6e;
    overflow: hidden;
    padding: 0 !important;
    box-shadow: none !important;
    border: 2px solid;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: unset !important;
    min-height: unset !important;
    position: absolute;
    pointer-events: all;
    cursor: pointer;
    z-index: 15;
}

.exploded-node img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.exploded-node:hover {
    background-color: #4CAF50;
}

/* Filter Dropdown Specifics */
.recipe-filter-container {
    position: relative;
    width: 100%;
}

.recipe-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #34495e;
    border: 1px solid #4a627a;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.recipe-dropdown.active {
    display: block;
}

.recipe-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #ecf0f1;
    transition: background-color 0.2s;
}

.recipe-dropdown-item:hover {
    background-color: #2c3e50;
}

.recipe-dropdown-item.no-match {
    color: #bdc3c7;
    text-align: center;
    font-style: italic;
    cursor: default;
}

.vis-html-node.faded {
    opacity: 0.35;
    transition: opacity 0.4s ease;
    pointer-events: none;
}


.vis-html-node::before {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    border-radius: 42px; /* Slightly larger than the node's border-radius */
    opacity: 0;
    z-index: -1;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

@keyframes glow-green {
    0% { transform: scale(1.0); opacity: 0.7; }
    50% { transform: scale(1.1); } /* Add scaling */
    100% { transform: scale(1.0); opacity: 0; }
}

.vis-html-node.new-job-pulse::before {
    background-color: rgba(26, 188, 53, 0.89);
    animation: glow-green 1.0s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes glow-red {
    0% { transform: scale(1.0); opacity: 0.7; }
    50% { transform: scale(0.9); } /* Add scaling */
    100% { transform: scale(1.0); opacity: 0; }
}

.vis-html-node.job-removed-pulse::before {
    background-color: rgba(231, 76, 60, 0.9);
    animation: glow-red 1.0s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes glow-fuse-impact {
    from { transform: scale(1.0); opacity: 0.8; }
    to { transform: scale(1.25); opacity: 0; }
}
.vis-html-node.fuse-impact-glow {
    animation: border-fuse-impact 1.2s ease-out;
}
.vis-html-node.fuse-impact-glow::before {
    background-color: #ffc300;
    box-shadow: 0 0 35px 10px rgba(255, 195, 0, 0.75);
    animation: glow-fuse-impact 1.2s ease-out;
}
@keyframes border-fuse-impact {
    50% { border-color: #ffc300; }
}

.node-anim-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    transition: background-color 0.5s ease;
}

.high-performance-mode .vis-html-node {
    box-shadow: none !important;
}

.high-performance-mode .vis-html-node.active {
    border-color: #1abc9c; /* Keep border for feedback */
}

/* Disable all pseudo-element glow animations in high-performance mode */
.high-performance-mode .vis-html-node::before {
    animation: none !important;
    background: none !important;
    box-shadow: none !important;
}

.node-positioner {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 200px;
    min-height: 70px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.faction-progress-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    display: flex; /* Use flexbox to stack segments horizontally */
    border-radius: 40px;
    flex-direction: row;
}

/* --- MODIFIED: Progress Bar Fill Styling --- */

/* Base style for all fill segments (player and aggregate) */
.faction-progress-bar-fill {
    height: 100%;
    transition: width 0.4s ease-out, background-color 0.5s ease;
}

/* Style specifically for the player node's single fill bar */
.player-job-node .faction-progress-bar-fill {
    position: relative; /* Needed for the sheen effect */
    width: var(--progress-width, 0%);
    background-color: rgba(74, 144, 226, 0.51);
    overflow: hidden;
}

/* Faction-specific colors for the aggregate node segments */
.faction-progress-bar-fill.oni {
    background-color: rgba(23, 124, 182, 0.24); /* Modern Blue */
}

.faction-progress-bar-fill.mud {
    background-color: rgba(191, 47, 30, 0.36); /* Strong Red */
}

.faction-progress-bar-fill.ustur {
    background-color: rgba(223, 181, 7, 0.35); /* Golden Yellow */
}

/* Ensure node content is always on top of the background fill */
.node-icon-container,
.node-content,
.node-crew-container {
    position: relative;
    z-index: 1;
}

/*
================================================
Faction-Specific Colors for Player Job Nodes
================================================
*/

/* --- ONI Player Node --- */
.vis-html-node.player-job-node.faction-oni {
    border-color: #5DADE2; /* Blue */
    box-shadow: 0 0 15px rgba(93, 173, 226, 0.6);
}

.vis-html-node.player-job-node.faction-oni .progress-bar-fill {
    background-color: rgba(93, 173, 226, 0.53);
}

.vis-html-node.player-job-node.is-complete.faction-oni {
    border-color: rgba(133, 193, 233, 0.6); /* Lighter Blue */
}

.vis-html-node.player-job-node.is-complete.faction-oni .progress-bar-fill {
    background-color: rgba(133, 193, 233, 0.62);
}


/* --- MUD Player Node --- */
.vis-html-node.player-job-node.faction-mud {
    border-color: #E74C3C; /* Red */
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.6);
}

.vis-html-node.player-job-node.faction-mud .progress-bar-fill {
    background-color: rgba(231, 76, 60, 0.54);
}

.vis-html-node.player-job-node.is-complete.faction-mud {
    border-color: rgba(241, 148, 138, 0.55); /* Lighter Red */
}

.vis-html-node.player-job-node.is-complete.faction-mud .progress-bar-fill {
    background-color: rgba(241, 148, 138, 0.55);
}


/* --- Ustur Player Node --- */
.vis-html-node.player-job-node.faction-ustur {
    border-color: #F1C40F; /* Yellow */
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6);
}

.vis-html-node.player-job-node.faction-ustur .progress-bar-fill {
    background-color: rgba(241, 196, 15, 0.51);
}

.vis-html-node.player-job-node.is-complete.faction-ustur {
    border-color: rgba(247, 220, 111, 0.62); /* Lighter Yellow */
}

.vis-html-node.player-job-node.is-complete.faction-ustur .progress-bar-fill {
    background-color: rgba(247, 220, 111, 0.62);
}

.recipe-dropdown-item.custom-filter {
    color: #1abc9c; /* Teal color to stand out */
    font-weight: bold;
    font-style: italic;
}

/*
================================================
Node Appearance & Disappearance Animations
================================================
*/

@keyframes fade-in-scale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fade-out-scale {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Animate a node appearing for the first time */
.vis-html-node.appearing {
    animation: fade-in-scale 1.5s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Animate a node disappearing */
.vis-html-node.disappearing {
    animation: fade-out-scale 2.0s ease-out forwards;
    pointer-events: none;
}

.floating-text-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 20;
}

.node-positioner.is-animating {
    z-index: 99 !important;
}

.floating-text {
    position: absolute;
    font-size: 1.5em;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    pointer-events: none;
    /* The animation name is now determined by the plus/minus class */
}

.floating-text.plus {
    color: #2ecc71; /* Bright Green */
    animation: float-up-and-fade 2s ease-out forwards;
}

.floating-text.minus {
    color: #e74c3c; /* Bright Red */
    animation: float-down-and-fade 2s ease-out forwards;
}

/* MODIFIED: Renamed the original keyframe for upward movement */
@keyframes float-up-and-fade {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px); /* Float UP */
        opacity: 0;
    }
}

/* NEW: Add this keyframe for downward movement */
@keyframes float-down-and-fade {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(60px); /* Float DOWN */
        opacity: 0;
    }
}

#job-graph-container .vis-network canvas {
    will-change: transform;
    transform: translateZ(0);
}

/* --- Explosion Decoration Styles --- */
#vis-html-decor-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5; /* Behind nodes (z-index: 10) */
}

.aggregate-label {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 4px black;
    white-space: nowrap;
    will-change: transform;
    transform-origin: center center;
}

.separator-line {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    background-image: linear-gradient(to right, rgba(231, 76, 60, 0.8) 50%, transparent 50%);
    background-size: 15px 2px;
    transform-origin: left center;
    will-change: transform;
}