:root {
    --cyan-glow-rgba: 0, 212, 255; --purple-glow-rgba: 138, 43, 226;
    --pink-glow-rgba: 255, 20, 147; --neon-red-rgba: 229, 115, 115;
    --neon-green-rgba: 129, 199, 132; --cyan-glow: rgba(var(--cyan-glow-rgba), 0.8);
    --purple-glow: rgba(var(--purple-glow-rgba), 0.7); --pink-glow: rgba(var(--pink-glow-rgba), 0.7);
    --neon-red: rgb(var(--neon-red-rgba)); --neon-green: rgb(var(--neon-green-rgba)); 
    --panel-border: rgba(var(--cyan-glow-rgba), 0.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* --- GLOBAL PAUSE FOR ANIMATIONS --- */
.app-is-paused * {
    animation-play-state: paused !important;
}

.animations-disabled .data-grid-background {
    display: none;
}

@font-face { 
    font-family: 'Snowstorm'; 
    /* This path remains correct for your file structure */
    src: url('/assets/fonts/snowstorm.otf') format('opentype'); 
}

body { font-family: 'Snowstorm', Arial, sans-serif; background-color: #0a0a0a; color: white; overflow-x: hidden; }

html {
    scroll-behavior: smooth;
}


/* --- START: HOLOGRAPHIC DATA GRID BACKGROUND (NEWLY ADDED) --- */

.data-grid-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    perspective: 1200px;
    overflow: hidden;
}

.edge-vignette {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.6) 100%);
    z-index: 10;
    pointer-events: none;
}

.grid-layer {
    position: absolute;
    width: 200%;
    height: 400%;
    top: -100%;
    left: -50%;
    animation: gridScroll 20s linear infinite;
}

.grid-layer-1 {
    transform: rotateX(75deg) translateZ(-100px);
    opacity: .4;
}

.grid-layer-2 {
    transform: rotateX(70deg) translateZ(-250px);
    opacity: .8;
    animation-duration: 15s;
}

.grid-layer-3 {
    transform: rotateX(65deg) translateZ(-400px);
    animation: gridScroll 15s linear infinite;
    opacity: 0.8;
}

.hex-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(30deg, rgba(var(--cyan-glow-rgba), .3) 1px, transparent 1px), 
        linear-gradient(150deg, rgba(var(--cyan-glow-rgba), .3) 1px, transparent 1px), 
        linear-gradient(90deg, rgba(var(--cyan-glow-rgba), .3) 1px, transparent 1px);
    background-size: 52px 30px;
    animation: hexPulse 6s ease-in-out infinite alternate;
}

.hex-grid.layer-2 {
    background-image: 
        linear-gradient(30deg, rgba(var(--purple-glow-rgba), 0.2) 1px, transparent 1px),
        linear-gradient(150deg, rgba(var(--purple-glow-rgba), 0.2) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--purple-glow-rgba), 0.2) 1px, transparent 1px);
}

.hex-grid.layer-3 {
    background-image: 
        linear-gradient(30deg, rgba(var(--pink-glow-rgba), 0.15) 1px, transparent 1px),
        linear-gradient(150deg, rgba(var(--pink-glow-rgba), 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(var(--pink-glow-rgba), 0.15) 1px, transparent 1px);
}

.scanline {
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(var(--cyan-glow-rgba), 0.3) 20%,
        rgba(var(--cyan-glow-rgba), 1) 50%, 
        rgba(var(--cyan-glow-rgba), 0.3) 80%,
        transparent 100%
    );
    box-shadow: 0 0 30px rgba(var(--cyan-glow-rgba), 0.8);
    animation: scanlineMove 15s linear infinite;
}

.flicker-zone {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(var(--cyan-glow-rgba), 0.4) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    animation: gridFlicker 45s infinite;
}

.flicker-zone:nth-child(2) {
    animation-delay: -15s;
    background: radial-gradient(circle, rgba(var(--purple-glow-rgba), 0.3) 0%, transparent 70%);
}

.flicker-zone:nth-child(3) {
    animation-delay: -30s;
    background: radial-gradient(circle, rgba(var(--pink-glow-rgba), 0.3) 0%, transparent 70%);
}

.atmosphere {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 10%, rgba(var(--cyan-glow-rgba), .12) 0, transparent 50%), 
        radial-gradient(ellipse at 80% 20%, rgba(var(--purple-glow-rgba), .08) 0, transparent 50%), 
        radial-gradient(ellipse at 50% 90%, rgba(var(--pink-glow-rgba), .06) 0, transparent 50%);
    animation: atmosphereShift 30s ease-in-out infinite;
}

@keyframes gridScroll {
    from { transform: rotateX(70deg) translateZ(-200px) translateY(0); }
    to { transform: rotateX(70deg) translateZ(-200px) translateY(52px); }
}

@keyframes hexPulse {
    from { opacity: .6; }
    to { opacity: 1; }
}

@keyframes scanlineMove {
    0% { top: -10px; opacity: 0; }
    2% { opacity: 1; }
    98% { opacity: 1; }
    100% { top: 100vh; opacity: 0; }
}

@keyframes gridFlicker {
    0%, 98% { opacity: 0; }
    1% { opacity: 0.8; }
    2% { opacity: 0.4; }
    3% { opacity: 0.9; }
    4% { opacity: 0; }
}

@keyframes atmosphereShift {
    0%, to { transform: scale(1) rotate(0); }
    50% { transform: scale(1.1) rotate(.5deg); }
}

/* --- END: HOLOGRAPHIC DATA GRID BACKGROUND --- */


#ticker-container { position: sticky; top: 70px; height: 40px; background-color: rgba(10,10,10,.8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--panel-border); z-index: 999; overflow: hidden; display: flex; transition: top 0.3s ease-in-out; }
#ticker-wrapper {
    display: flex;
    /* The animation property is removed from here */
    will-change: transform;
}
.ticker-segment { display: flex; align-items: center; }
.ticker-item { display: inline-flex; align-items: center; padding: 0 20px; font-size: 1.1em; color: #ccc; white-space: nowrap; }
.ticker-item .positive { color: var(--neon-green); margin-left: 8px; } .ticker-item .negative { color: var(--neon-red); margin-left: 8px; } .ticker-item .neutral {
    color: #ccc; /* Standard text color for no change */
    margin-left: 8px;
}
.ticker-separator { border-left: 1px solid var(--panel-border); height: 20px; }
@keyframes ticker-scroll { from { transform: translateX(0%); } to { transform: translateX(-100%); } }

.dashboard-header{position:sticky;top:0;background:rgba(26,26,26,.95);border-bottom:2px solid var(--panel-border);display:flex;align-items:center;justify-content:space-between;padding:0 30px;z-index:1000;height:70px}
.header-left, .header-right { flex: 1; } .header-right { display: flex; justify-content: flex-end; } .header-branding {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px; /* Space between text block and banner */
}

/* Header scroll behavior */
.dashboard-header {
    /* ... existing styles ... */
    transition: transform 0.3s ease-in-out; /* Add this line */
}

.dashboard-header.hidden {
    transform: translateY(-100%);
}

.dashboard-header.hidden + #ticker-container {
    top: 0;
}

.branding-text-container {
    display: flex;
    flex-direction: column; /* Stacks the title and 'by' line vertically */
    align-items: center;   /* Centers them horizontally */
}

/* The unique style for "RR Hub" */
.main-title {
    font-size: 2em; /* Make it larger */
    font-weight: bold;
    line-height: 1; /* Tighten the line height */
    /* This creates the unique gradient text effect */
    background: linear-gradient(45deg, var(--cyan-glow), var(--pink-glow));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 4px rgba(var(--cyan-glow-rgba), 0.3);
}

/* The smaller "by" line */
.by-line {
    font-size: 1em;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: -2px; /* Nudge it a bit closer to the main title */
}

.header-branding img { max-height: 50px; width: auto; filter: drop-shadow(0 0 8px rgba(var(--cyan-glow-rgba), 0.5)); transition: filter 0.3s ease; }
.header-branding img:hover { filter: drop-shadow(0 0 12px rgba(var(--cyan-glow-rgba), 0.8)); }
.header-info{font-size:1.1em;color:var(--cyan-glow)}.dashboard-container{padding:20px;max-width:1600px;margin:auto}
.main-tabs{display:flex;flex-wrap:wrap;gap:5px;border-bottom:1px solid var(--panel-border)}.main-tab-button{background:transparent;border:none;border-bottom:3px solid transparent;color:#ccc;padding:15px 25px;font-family:inherit;font-size:1.2em;cursor:pointer;transition:all .3s ease;text-transform:uppercase}.main-tab-button:hover{color:#fff;background:rgba(var(--cyan-glow-rgba),.1)}.main-tab-button.active{color:var(--cyan-glow);text-shadow:0 0 4px var(--cyan-glow);border-bottom-color:var(--cyan-glow)}.main-tab-content{display:none;margin-top:20px}.main-tab-content.active{display:block;animation:fadeIn .5s ease-in-out}
.analysis-controls{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:20px;padding:10px;background:rgba(0,0,0,.2);border-radius:8px}.analysis-controls select{background:rgba(0,0,0,.7);border:1px solid var(--panel-border);color:#fff;padding:8px 12px;font-family:inherit;font-size:1.1em;border-radius:5px}.time-controls button{font-size:1em;padding:8px 16px;background:rgba(0,0,0,.5);border:1px solid var(--panel-border);color:#ccc;cursor:pointer;border-radius:4px;transition:all .2s ease}.time-controls button.active{background:rgba(var(--cyan-glow-rgba),.3);color:#fff;border-color:var(--cyan-glow)}
.sub-tab-view{display:none}
.sub-tab-view.active {
    display: grid;
    gap: 30px;
}

/* Rule 1: ONLY apply the two-column layout to the market tabs */
#subTabView-globalMarket.active,
#subTabView-stateMarket.active {
    grid-template-columns: 2.5fr 1fr;
}

/* Rule 2: Create a two-column layout for the BOTTOM row of the Indexes tab */
#subTabView-indexes.active {
    grid-template-columns: 1fr;
}

/* Rule 3: Create a single, full-width column layout for the Indicators tab */
#subTabView-indicators.active {
    grid-template-columns: 1fr;
}

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { background: rgba(0,0,0,0.2); padding: 15px; border-radius: 8px; text-align: center; border: 1px solid transparent; }
.stat-label { font-size: 0.9em; text-transform: uppercase; color: #ccc; margin-bottom: 8px; }
.stat-value { font-size: 1.8em; font-weight: bold; color: var(--cyan-glow); }
.red-positive-scheme .positive {
    color: var(--neon-red); /* ...make .positive elements RED. */
}

/* --- DEFINITIVE COLOR SCHEME SWAP --- */

    /* Default Scheme (Green = Positive) */
    .stat-value.positive, .price-change.positive, #indexTable .positive, .ticker-item .positive { color: var(--neon-green); }
    .stat-value.negative, .price-change.negative, #indexTable .negative, .ticker-item .negative { color: var(--neon-red); }
    .stat-value.inflation-increase {
        color: var(--neon-red);
    }
    .stat-value.inflation-decrease {
        color: var(--neon-green);
    }

    /* Override Scheme (Red = Positive) */
    .red-positive-scheme .stat-value.positive,
    .red-positive-scheme .price-change.positive,
    .red-positive-scheme #indexTable .positive,
    .red-positive-scheme .ticker-item .positive {
        color: var(--neon-red);
    }

    .red-positive-scheme .stat-value.negative,
    .red-positive-scheme .price-change.negative,
    .red-positive-scheme #indexTable .negative,
    .red-positive-scheme .ticker-item .negative {
        color: var(--neon-green);
    }
    .red-positive-scheme .stat-card .stat-change.positive {
        color: var(--neon-red);
    }
    .red-positive-scheme .stat-card .stat-change.negative {
        color: var(--neon-green);
    }

.layout-main-sidebar{grid-template-columns:2.5fr 1fr}.dashboard-panel{background:rgba(42,42,42,.9);border:1px solid var(--panel-border);border-radius:10px;padding:25px;backdrop-filter:blur(10px);box-shadow:0 5px 25px rgba(0,0,0,.5);display:flex;flex-direction:column}.panel-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;border-bottom:1px solid var(--panel-border);padding-bottom:15px;gap:15px;flex-wrap:wrap}.panel-title{font-size:1.5em;color:var(--cyan-glow);text-transform:uppercase;text-shadow:0 0 4px var(--cyan-glow);margin:0;padding:0;border:none;flex-shrink:0; flex-grow: 1;}
.chart-view-controls,.panel-controls{display:flex;gap:10px;align-items:center;flex-shrink:0;}.chart-view-controls button,.panel-controls button,.copy-chart-btn{font-size:.9em;padding:6px 12px;background:rgba(0,0,0,.5);border:1px solid var(--panel-border);color:#ccc;cursor:pointer;border-radius:4px;transition:all 0.2s ease}.chart-view-controls button.active,.copy-chart-btn:hover{background:rgba(var(--cyan-glow-rgba),.3);color:#fff;border-color:var(--cyan-glow)}.panel-controls select{font-size:.9em;background:rgba(0,0,0,.7);border:1px solid var(--panel-border);border-radius:5px;padding:8px 12px;color:#fff;font-family:inherit}

.hide-for-export { display: none !important; }
.export-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(10,10,10,0.7); color: white; display: flex; align-items: center; justify-content: center; font-size: 1.5em; z-index: 20; backdrop-filter: blur(5px); border-radius: 10px; }

.chart-export-area { flex-grow: 1; display: flex; flex-direction: column; }
.chart-container{position:relative;height:400px;flex-grow:1}.market-list{max-height:450px;overflow-y:auto}.market-item{display:flex;align-items:center;padding:10px;border:2px solid transparent;border-bottom:1px solid rgba(var(--cyan-glow-rgba),.1);transition:all .3s ease;cursor:pointer}.market-item:hover{background:rgba(var(--cyan-glow-rgba),.1)}.market-item.primary{border-color:var(--cyan-glow);background:rgba(var(--cyan-glow-rgba),.15)}.market-item.secondary{border-color:var(--purple-glow);background:rgba(var(--purple-glow-rgba),.15)}.resource-icon img{width:35px;height:35px;margin-right:15px}.market-info{flex-grow:1}.resource-name{font-size:1.3em;font-weight:700;color:#fff}.price-change.positive{color:var(--neon-green)}.price-change.negative{color:var(--neon-red)}.switch{position:relative;display:inline-block;width:50px;height:26px}.switch input{opacity:0;width:0;height:0}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#333;transition:.4s;border-radius:26px;border:1px solid var(--panel-border)}.slider:before{position:absolute;content:"";height:18px;width:18px;left:4px;bottom:3px;background-color:#fff;transition:.4s;border-radius:50%}input:checked+.slider{background-color:var(--cyan-glow)}input:checked+.slider:before{transform:translateX(24px)}
/* Fix for mobile pinch-to-zoom on charts */
.chart-container canvas {
    touch-action: none;
}
#indexTableContainer{max-height:700px;overflow-y:auto}#indexTable{width:100%;border-collapse:collapse}#indexTable td,#indexTable th{padding:8px;text-align:center;border:1px solid var(--panel-border); font-size: 1.8em; }#indexTable td .change{font-size:.8em;opacity:.7}
#indexTable .positive { color: var(--neon-green); } #indexTable .negative { color: var(--neon-red); }
.chart-watermark { position: absolute; top: 15px; left: 50%; transform: translateX(-50%); max-height: 40px; width: auto; opacity: 0.15; pointer-events: none; }
::-webkit-scrollbar{width:8px}::-webkit-scrollbar-track{background:rgba(0,0,0,.3)}::-webkit-scrollbar-thumb{background:var(--cyan-glow);border-radius:4px}
.market-item .resource-price {
    font-size: 1.2em; /* You can adjust this value */
    font-weight: bold;
}

/* New container for all chart controls */
.panel-controls-group {
    display: flex;
    gap: 20px; /* Space between control groups */
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Style for the time buttons inside a chart panel */
.panel-time-controls button {
    font-size: 0.9em;
    padding: 6px 12px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--panel-border);
    color: #ccc;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.panel-time-controls button.active,
.panel-time-controls button:hover {
    background: rgba(var(--cyan-glow-rgba), 0.3);
    color: #fff;
    border-color: var(--cyan-glow);
}
.chart-render-area {
    position: relative; /* This is needed for the watermark to position correctly */
    flex-grow: 1;
    display: flex;
}
.ticker-segment-title {
    display: inline-flex;
    align-items: center;
    padding: 0 30px; /* More padding to stand out */
    font-size: 1.2em;
    font-weight: bold;
    color: var(--cyan-glow); /* Bright color for the title */
    text-transform: uppercase;
    white-space: nowrap;
}

/* This defines the scrolling animation we will apply via JavaScript */
@keyframes ticker-scroll {
    from { transform: translateX(0%); }
    to { transform: translateX(-100%); } /* Animate the full width of one segment */
}

/* --- Settings Button --- */
.header-btn {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 2em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn:hover {
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
}

/* --- Settings Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(10px);
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Make sure it's on top of everything */
}

.modal-overlay.visible {
    display: flex; /* Show the modal */
}

.modal-content {
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    /* Add these three lines */
    display: flex;
    flex-direction: column;
    max-height: 85vh; /* Set max height to 85% of the viewport height */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--panel-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8em;
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
}

.close-btn {
    background: none;
    border: none;
    font-size: 2.5em;
    line-height: 1;
    color: #ccc;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: white;
}

.modal-body {
    padding: 25px;
}

.modal-body h4 {
    margin: 0 0 10px 0;
    font-size: 1.2em;
    text-transform: uppercase;
}

.setting-description {
    color: #ccc;
    font-size: 1em;
    margin-bottom: 20px;
}

.setting-option {
    margin-bottom: 15px;
}

.setting-option label {
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.setting-option input[type="radio"] {
    margin-right: 15px;
    transform: scale(1.5); /* Make radio buttons bigger */
    accent-color: var(--cyan-glow);
}

.modal-footer {
    padding: 20px;
    text-align: right;
    border-top: 1px solid var(--panel-border);
}

.save-btn {
    background: rgba(var(--cyan-glow-rgba), 0.2);
    border: 1px solid var(--cyan-glow);
    color: white;
    padding: 10px 20px;
    font-size: 1.1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: inherit; /* Inherit the Snowstorm font */
    text-transform: uppercase; /* Match other buttons */
}

.save-btn:hover {
    background: rgba(var(--cyan-glow-rgba), 0.4);
}

/* --- Color Preview Spans --- */
/* This is for the first option (Green = Positive) */
#schemeGreenPositive + label .preview-positive { color: var(--neon-green); }
#schemeGreenPositive + label .preview-negative { color: var(--neon-red); }

/* This is for the second option (Red = Positive) */
#schemeRedPositive + label .preview-positive { color: var(--neon-red); }
#schemeRedPositive + label .preview-negative { color: var(--neon-green); }

/* ADD ALL OF THESE NEW RULES FOR THE TOOLS PAGE */

/* --- Tool Card Styling --- */
.tool-card {
    display: flex;
    background: rgba(42, 42, 42, 0.9);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    margin-bottom: 30px;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.tool-card-content {
    padding: 30px;
    flex: 3; /* Content takes up more space */
}

.tool-card-title {
    font-size: 2em;
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
    margin: 0 0 15px 0;
}

.tool-card-description {
    font-size: 1.1em;
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 25px;
}

.tool-card-button {
    background: rgba(var(--cyan-glow-rgba), 0.2);
    border: 1px solid var(--cyan-glow);
    color: white;
    padding: 12px 25px;
    font-size: 1.2em;
    font-family: inherit;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-card-button:hover {
    background: rgba(var(--cyan-glow-rgba), 0.4);
    transform: translateY(-2px);
}

.tool-card-image {
    flex: 2; /* Image takes up less space */
    min-width: 300px;
    background-size: cover;
    background-position: center;
}

.tool-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Tool Modal Styling --- */
.tool-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 2vw;
}

.tool-modal.visible {
    display: flex;
}

.tool-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    background: #1A222F; /* Match editor background */
    border: 2px solid var(--panel-border);
    border-radius: 10px;
    overflow: hidden;
}

.tool-modal-close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    background: none;
    border: none;
    color: #ccc;
    font-size: 2.5em;
    line-height: 1;
    cursor: pointer;
    z-index: 10; /* Increased Z-Index */
    transition: all 0.2s ease;
}

.tool-modal-close-btn:hover {
    color: var(--cyan-glow);
}

/* New Rules for Modal Layout */
.tool-modal-content {
    /* We change this to a flex column to stack the header and iframe */
    display: flex;
    flex-direction: column;
}

.tool-modal-header {
    flex-shrink: 0; /* Prevents the header from shrinking */
    position: relative;
    height: 40px; /* Give the header a fixed height */
    background: #1A222F; /* Match the modal background */
}

/* We must now adjust the button's position to be inside this new header */
.tool-modal-close-btn {
    position: absolute;
    top: 50%; /* Center vertically in the new header */
    right: 15px;
    transform: translateY(-50%);
}

.tool-modal-iframe {
    /* The iframe should take up all remaining space */
    flex-grow: 1;
    height: 100%;
}

.tool-modal-iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: none;
}
#animatedGlobeContainer {
    width: 100%;
    height: 70vh; /* Viewport height */
    min-height: 500px;
}

#mapPainterContainer .map-painter-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
#homeGlobePanel {
    background: transparent;
    border: none;
    padding: 0;
    backdrop-filter: none;
    box-shadow: none;
}
#mapPainterContainer {
    flex-grow: 1;
}
/* --- Homepage Specific Styles --- */
.welcome-panel {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
}

.welcome-title {
    font-size: 2.8em;
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
    text-transform: uppercase;
}

.welcome-subtitle {
    font-size: 1.3em;
    color: #ccc;
    max-width: 800px;
    margin: 10px auto 0 auto;
}

.globe-note {
    text-align: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    margin-top: 20px;
    font-size: 1.1em;
    color: #ccc;
}

#economicBriefingContainer, #usefulLinksContainer {
    margin-top: 30px;
}

.stat-card .stat-change {
    font-size: 1.1em;
    margin-top: 8px;
    color: #ccc;
}

.stat-card .stat-change.positive { color: var(--neon-green); }
.stat-card .stat-change.negative { color: var(--neon-red); }

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.link-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--panel-border);
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: white;
    transition: all 0.2s ease;
}

.link-card:hover {
    transform: translateY(-5px);
    border-color: var(--cyan-glow);
    background: rgba(var(--cyan-glow-rgba), 0.1);
}

.link-title {
    font-size: 1.4em;
    color: var(--cyan-glow);
    margin-bottom: 8px;
}

.link-description {
    font-size: 1em;
    color: #ccc;
}
/* --- Support Modal & Button Styles --- */
#supportBtn {
    margin-left: 15px; /* Add some space next to the settings gear */
}

.support-link-btn {
    display: inline-block;
    background: rgba(var(--cyan-glow-rgba), 0.2);
    border: 1px solid var(--cyan-glow);
    color: white;
    padding: 15px 30px;
    font-size: 1.3em;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    transition: all 0.2s ease;
    margin: 5px;
}

.support-link-btn:hover {
    background: rgba(var(--cyan-glow-rgba), 0.4);
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(var(--cyan-glow-rgba), 0.3);
}
/* --- Custom Google Translate Widget Styles --- */
.setting-divider {
    border: none;
    height: 1px;
    background-color: var(--panel-border);
    margin: 30px 0 25px 0;
}

.custom-translate-wrapper {
    position: relative; /* Crucial for positioning the dropdown */
    display: inline-block;
}

.custom-translate-button {
    background: rgba(0,0,0,0.7);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 8px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 1.1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 200px; /* Give it a fixed width */
    transition: all 0.2s ease;
}
.custom-translate-button:hover {
    border-color: var(--cyan-glow);
}
.custom-translate-button .arrow {
    font-size: 0.8em;
    margin-left: 10px;
}

.custom-translate-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #2a2a2a;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    max-height: 400px;
    overflow-y: auto;
    z-index: 2001; /* Above the modal overlay */
    display: none; /* Hidden by default */
}

.custom-translate-dropdown.visible {
    display: block;
}

.custom-translate-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    color: #ccc;
    text-align: left;
    font-family: inherit;
    font-size: 1em;
    cursor: pointer;
}
.custom-translate-dropdown button:hover,
.custom-translate-dropdown button.selected {
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
    background-color: rgba(var(--cyan-glow-rgba), 0.1);
}

/* Custom Scrollbar for the Dropdown */
.custom-translate-dropdown::-webkit-scrollbar { width: 8px; }
.custom-translate-dropdown::-webkit-scrollbar-track { background: rgba(0,0,0,.3); }
.custom-translate-dropdown::-webkit-scrollbar-thumb { background: var(--cyan-glow); border-radius: 4px; }
/* --- Changelog Modal Styles --- */
.changelog-body {
    overflow-y: auto; /* Automatically add a scrollbar when needed */
    padding: 15px 25px 25px 25px; /* Adjust padding for scrollbar */
}

.changelog-section-title {
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
    font-size: 1.4em !important;
    margin-bottom: 15px !important;
    text-align: center;
}

.changelog-description, .changelog-footer {
    font-size: 1.1em;
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 20px;
}

.changelog-list {
    list-style-type: '◉ ';
    padding-left: 25px;
    font-size: 1.1em;
    color: #ccc;
    line-height: 1.7;
}

.changelog-list li {
    padding-left: 10px;
    margin-bottom: 12px;
}

.changelog-list b {
    color: #fff;
    font-weight: normal;
}

/* --- Map Tooltip Styling --- */
.map-tooltip {
    position: absolute; /* Changed from fixed to work better with scrolling pages */
    display: none;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-family: 'Snowstorm', Arial, sans-serif;
    font-size: 1.1em;
    z-index: 3000; /* Ensure it's on top of everything */
    pointer-events: none; /* Make it non-interactive by default */
    white-space: nowrap;
    backdrop-filter: blur(5px);
}

.map-tooltip-btn {
    background: rgba(var(--cyan-glow-rgba), 0.2);
    border: 1px solid var(--cyan-glow);
    color: white;
    padding: 6px 12px;
    font-size: 0.9em;
    font-family: inherit;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    width: 100%;
}

.map-tooltip-btn:hover {
    background: rgba(var(--cyan-glow-rgba), 0.4);
}

#mapsTab {
    display: none; /* Initially hidden like other tabs */
    flex-direction: column; /* Stacks toolbar and map container vertically */
    height: 85vh; /* Give the tab a fixed height to contain the map */
}

#mapsTab.active {
    display: flex; /* Use flex when active */
}

.map-viewer-toolbar {
    background: rgba(42, 42, 42, .9);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    justify-content: space-between; /* Pushes control groups to opposite ends */
    align-items: center;
    flex-wrap: wrap; /* Allows controls to stack on small screens */
    gap: 20px;
    flex-shrink: 0; /* Prevents the toolbar from shrinking */
    position: relative; /* Allows z-index to work */
    z-index: 10;        /* Ensures it's on top of the map */
}

.map-viewer-toolbar .map-control-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.map-viewer-toolbar button, .map-viewer-toolbar select {
    font-size: 1em;
    padding: 8px 16px;
    background: rgba(0,0,0,.5);
    border: 1px solid var(--panel-border);
    color: #ccc;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    transition: all .2s ease;
}

.map-viewer-toolbar button:hover, .map-viewer-toolbar select:hover {
    border-color: var(--cyan-glow);
    color: #fff;
}

.map-viewer-toolbar button.active {
     background: rgba(var(--cyan-glow-rgba),.3);
     color:#fff;
     border-color:var(--cyan-glow);
}

.map-tooltip-bar strong {
    color: var(--cyan-glow);
    margin-right: 15px;
}

#mapViewerContainer {
    position: relative; /* Needed for positioning the map canvas/svg inside */
    width: 100%;
    flex-grow: 1; /* This makes the container fill all available vertical space */
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    overflow: hidden; /* Ensures the map render stays within the rounded corners */
    border: 1px solid var(--panel-border);
}
.map-viewer-svg {
    touch-action: none; /* Disables browser scrolling/pinching on the map, allowing D3 to handle it */
    background-color: rgb(10, 20, 38);
}

/* --- Loading Screen --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #0a0a0a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
    opacity: 1;
    visibility: visible;
}

#loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader {
    border: 5px solid rgba(var(--cyan-glow-rgba), 0.2);
    border-top: 5px solid var(--cyan-glow);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.loader-text {
    color: var(--cyan-glow);
    margin-top: 20px;
    font-size: 1.2em;
    text-shadow: 0 0 4px var(--cyan-glow);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Chart Refresh Animation --- */
.chart-loading {
    animation: pulse-glow 0.8s ease-in-out;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 10px rgba(var(--cyan-glow-rgba), 0), inset 0 0 10px rgba(var(--cyan-glow-rgba), 0);
    }
    50% {
        box-shadow: 0 0 20px rgba(var(--cyan-glow-rgba), 0.5), inset 0 0 15px rgba(var(--cyan-glow-rgba), 0.3);
    }
    100% {
        box-shadow: 0 0 10px rgba(var(--cyan-glow-rgba), 0), inset 0 0 10px rgba(var(--cyan-glow-rgba), 0);
    }
}

/* --- START: MOBILE OPTIMIZATIONS --- */

@media (max-width: 768px) {
    /* ... The .data-grid-background rule ... */
    .data-grid-background {
        display: none;
    }

    /*
     * PHASE 1, STEP 2 (DEFINITIVE FIX): FIX WIDE TABLE & GRID OVERFLOW
    */
    #indexTableContainer {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* THIS IS THE NEW FIX: Force grid children to shrink */
    #subTabView-indexes .dashboard-panel {
        min-width: 0;
    }

    /* --- Mobile Market Tab Reordering --- */
    /* Change the market tab containers to use flexbox on mobile */
    #subTabView-globalMarket.active,
    #subTabView-stateMarket.active {
        display: flex;
        flex-direction: column;
    }

    /* Reorder the panels using the 'order' property */

    /* 1. Watchlist Panel (third in HTML) -> move to top */
    #subTabView-globalMarket.active > div:nth-of-type(3),
    #subTabView-stateMarket.active > div:nth-of-type(3) {
        order: 1;
    }

    /* 2. KPI Cards (first in HTML) -> move to middle */
    #subTabView-globalMarket.active > div:nth-of-type(1),
    #subTabView-stateMarket.active > div:nth-of-type(1) {
        order: 2;
    }

    /* 3. Chart Panel (second in HTML) -> move to bottom */
    #subTabView-globalMarket.active > div:nth-of-type(2),
    #subTabView-stateMarket.active > div:nth-of-type(2) {
        order: 3;
    }

    /* Header & Tabs */
    .main-title {
        font-size: 1.5em; /* Shrink "RR Hub" title */
    }
    .main-tab-button {
        padding: 12px 10px; /* Less padding on tabs */
        font-size: 1em;
    }

    /* Main Content Titles */
    .welcome-title {
        font-size: 2em;
    }
    .panel-title {
        font-size: 1.2em;
    }

    /* KPI Cards */
    .stat-label {
        font-size: 0.8em;
    }
    .stat-value {
        font-size: 1.5em;
    }
    .kpi-grid {
        gap: 10px; /* Reduce gap between cards */
    }

    /* Index Table */
    #indexTable td, #indexTable th {
        font-size: 1em; /* Drastically reduce table font size */
        padding: 6px 4px;
    }

    /* Market Watchlist */
    .resource-name {
        font-size: 1.1em;
    }
    .resource-price {
        font-size: 1em;
    }

    /* Tool Cards */
    .tool-card {
        flex-direction: column; /* Stack image on top of content */
    }
    .tool-card-title {
        font-size: 1.5em;
    }
    .tool-card-description {
        font-size: 1em;
    }

    /* General Controls */
    .panel-controls-group, .analysis-controls {
        gap: 10px;
        justify-content: center; /* Center controls */
    }
    .panel-controls button, .panel-controls select, .chart-view-controls button {
        padding: 4px 8px;
        font-size: 0.8em;
    }
    .dashboard-container {
        padding: 10px; /* Reduce main page padding */
    }
    .dashboard-panel {
        padding: 15px; /* Reduce panel padding */
    }
    .dashboard-header {
        padding: 0 10px; /* Reduce side padding */
        height: 60px; /* Make header shorter */
    }
    .header-branding {
        gap: 8px; /* Less space between title and banner */
    }
    .header-branding img {
        max-height: 35px; /* Make banner image smaller */
    }
    .header-info {
        font-size: 0.8em; /* Shrink "Last Updated" text */
    }
    .header-btn {
        font-size: 1.5em; /* Make icons smaller */
    }
    #ticker-container {
        top: 60px; /* Match the new, shorter header height */
    }
    .ticker-item {
        font-size: 0.9em; /* Shrink ticker text */
        padding: 0 12px;
    }
    #animatedGlobeContainer {
        height: 45vh;
        min-height: 320px;
    }
    .map-tooltip {
        font-size: 0.9em;
        padding: 8px 12px;
    }
    .desktop-only-setting {
        display: none;
    }
}

/* --- Floating Footer --- */
.dashboard-footer {
    position: sticky;
    bottom: 0;
    background: rgba(26, 26, 26, .95);
    border-top: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 1000;
    height: 40px;
    font-size: 1.1em;
    color: #ccc;
    backdrop-filter: blur(10px);
}

.footer-left, .footer-right { flex: 1; }
.footer-center { flex: 2; text-align: center; }
.footer-right { text-align: right; }
.dashboard-footer a {
    color: var(--cyan-glow);
    text-decoration: none;
    transition: color 0.2s ease;
}
.dashboard-footer a:hover {
    text-decoration: underline;
    color: #fff;
}

/* Mobile adjustments for footer */
@media (max-width: 768px) {
    .dashboard-footer {
        padding: 0 15px;
        font-size: 0.9em;
        height: 35px;
    }
}

/* The main container is a flex column */
#mapViewerContainer {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    flex-grow: 1;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

/* The toolbar takes up its natural space at the top */
.map-viewer-toolbar {
    flex-shrink: 0;
}

/* The new wrapper for the map grows to fill all remaining space */
/* It also acts as the "room" for our floating tooltip */
.map-render-wrapper {
    flex-grow: 1;
    position: relative; /* THIS IS THE KEY */
    overflow: hidden; /* Ensures map stays within its bounds */
}


/* The tooltip bar is a "ghost" that floats inside the wrapper */
.map-tooltip-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

/* --- NEW: Setting to Disable Neon Glow Effects --- */

.glow-disabled .panel-title,
.glow-disabled .main-tab-button.active,
.glow-disabled .welcome-title,
.glow-disabled .modal-header h2,
.glow-disabled .header-btn:hover,
.glow-disabled .loader-text,
.glow-disabled .map-color-swatch.active,
.glow-disabled .custom-translate-dropdown button:hover,
.glow-disabled .custom-translate-dropdown button.selected {
    text-shadow: none !important;
}

/* Specific override for box-shadow on the map painter swatch */
.glow-disabled .map-color-swatch.active {
    box-shadow: none !important;
}

/* Taller chart container for Compare Mode */
#compareChartContainer {
    height: 550px; /* Taller default height for desktop */
}

/* Backwards compatibility for mobile */
@media (max-width: 768px) {
    #compareChartContainer {
        height: 400px; /* Revert to a more mobile-friendly height */
    }
}

#subTabView-compareMode .dashboard-panel {
    position: relative; /* Establishes a stacking context */
    z-index: 1;         /* Ensures it's layered, value can be low */
}

/* --- NEW: Custom Dropdown for Compare Mode --- */
.custom-select-wrapper {
    position: relative; /* This is the anchor for the invisible select */
    display: inline-block;
}

.custom-select-display {
    /* This is our "fake" dropdown display */
    display: block;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 5px;
    padding: 8px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9em;
    min-width: 200px; /* Give it a consistent width */
    cursor: pointer;
    user-select: none; /* Prevents text selection */
}

.custom-select-display::after {
    /* A little dropdown arrow */
    content: '▼';
    font-size: 0.8em;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.custom-select-actual {
    /* This is the REAL, invisible select element */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* Make it completely transparent */
    cursor: pointer;
}

/* --- NEW: Sub-Tab Navigation for Economic Analysis --- */
.sub-tabs {
    display: none; /* Initially hidden */
    flex-wrap: wrap;
    gap: 5px;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 20px; /* Space between tabs and content */
    justify-content: center;
}

.sub-tab-button {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #ccc;
    padding: 12px 20px; /* Slightly less padding than main tabs */
    font-family: inherit;
    font-size: 1.1em; /* Slightly smaller font */
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.sub-tab-button:hover {
    color: #fff;
    background: rgba(var(--cyan-glow-rgba), 0.1);
}

.sub-tab-button.active {
    color: var(--cyan-glow);
    text-shadow: 0 0 4px var(--cyan-glow);
    border-bottom-color: var(--cyan-glow);
}