/* General Body Styles */
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background-color: #12181b;
    color: #e0e0e0;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* Container for centering content */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header Styles */
.header {
    background-color: #1f2933;
    padding: 1rem 2rem;
    border-bottom: 1px solid #323f4b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #ffffff;
}

.header-link {
    text-decoration: none;
    color: inherit;
}

.header h1 .icon {
    color: #38bdf8; /* A nice accent color */
    margin-right: 10px;
}

/* Ticker display in header */
.header-ticker-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #12181b;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid #323f4b;
}

.ticker-label {
    font-size: 0.9rem;
    color: #9facb8;
}

.ticker-symbol {
    font-size: 1.1rem;
    font-weight: bold;
    color: #38bdf8;
}

/* Main Content Area */
.main-content {
    background-color: #1f2933;
    border-radius: 8px;
    padding: 2.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Removed text-align: center; */
}

.top-bar {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid #323f4b;
}

.top-bar .nav-button {
    justify-self: start;
}

.search-section {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Search Form Styles */
.search-form {
    display: flex;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}

.search-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1rem;
    border: 1px solid #323f4b;
    border-radius: 6px;
    background-color: #12181b;
    color: #e0e0e0;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3);
}

.search-button, .nav-button {
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: bold;
    color: #ffffff;
    background-color: #38bdf8;
    border: 1px solid #38bdf8;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.search-button:hover, .nav-button:hover {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
}

.nav-button.secondary {
    background-color: transparent;
    color: #9facb8;
    border-color: #323f4b;
}

.nav-button.secondary:hover {
    background-color: #323f4b;
    color: #e0e0e0;
    border-color: #323f4b;
}


/* --- START OF MODIFIED SECTION --- */
.plot-container {
    margin-top: 2rem;
    /* background-color: #ffffff; */ /* <-- REMOVED explicit white background */
    background-color: transparent; /* Make container background transparent */
    border-radius: 8px;
    padding: 0.5rem; /* Reduced padding slightly */
    display: block;
    max-width: 100%;
    position: relative;
    margin-left: auto;
    margin-right: auto;
}
/* --- END OF MODIFIED SECTION --- */

.plot-container img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* --- ADDED RULE --- */
/* Ensure ApexCharts container doesn't override with its own bg */
#monthly-chart .apexcharts-canvas {
     background: transparent !important; /* Force transparent background */
}
/* --- END ADDED RULE --- */


/* Spinner for loading states */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #323f4b; /* Light grey border */
    border-top: 5px solid #38bdf8; /* Blue color for the spinning part */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 2rem auto; /* Center the spinner */
}

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

.error-message {
    color: #f87171; /* A red for errors */
    font-weight: bold;
    margin-top: 1rem;
    text-align: center; /* Center error messages */
}

/* Footer Styles */
.footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: #9facb8;
}

/* --- Financial Summary Styles --- */
#financial-summary-container {
    margin-bottom: 2.5rem;
}
.financial-summary {
    background-color: #12181b;
    border: 1px solid #323f4b;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    position: relative; /* Needed for info button */
}
.summary-header {
    text-align: left;
    margin-bottom: 1.5rem;
}
.summary-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: #ffffff;
}
.summary-header span {
    font-size: 1rem;
    color: #9facb8;
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}
.summary-card {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.summary-label {
    font-size: 0.8rem;
    color: #9facb8;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}
.summary-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #e0e0e0;
}
.summary-value.score {
    font-size: 1.5rem;
}
.summary-value.positive { color: #22c55e; }
.summary-value.negative { color: #ef4444; }
.summary-value.neutral { color: #eab308; }


/* --- Advanced Analysis Page Styles --- */

/* Tab styling */
.tabs {
    border-bottom: 1px solid #323f4b;
    margin-bottom: 2.5rem;
}

.tabs ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    justify-content: center; /* Center tabs */
    flex-wrap: wrap; /* Allow tabs to wrap on small screens */
}

.tabs li {
    margin-bottom: -1px; /* To make the active border overlap the main border */
}

.tabs a {
    display: block;
    padding: 0.75rem 1.5rem;
    border-bottom: 2px solid transparent;
    color: #9facb8;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent tab text wrapping */
}

.tabs a:hover {
    color: #ffffff;
}

.tabs li.is-active a {
    color: #38bdf8;
    font-weight: bold;
    border-bottom-color: #38bdf8;
}

/* Tab pane styling */
.tab-pane { display: none; }
.tab-pane.is-active { display: block; }

/* Analysis text styling */
.text-analysis-container {
    background-color: #12181b;
    border: 1px solid #323f4b;
    border-radius: 6px;
    padding: 1.5rem;
    text-align: left;
}

.analysis-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: #e0e0e0;
    margin: 0;
}

/* --- Interactive Probability Calculator --- */
.interactive-calculator {
    border: 1px solid #323f4b;
    border-radius: 8px;
    padding: 1.5rem;
    background-color: #12181b;
}

.interactive-calculator h3 {
    font-size: 1.2rem; /* Adjusted for sidebar */
    color: #ffffff;
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
}

.interactive-calculator p {
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.date-selector-group {
    display: flex;
    flex-direction: column; /* Stack date selectors */
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.date-selector label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-align: left;
}

.date-inputs {
    display: flex;
    gap: 0.5rem;
}

.date-inputs select,
.date-inputs input[type="number"] {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    border: 1px solid #323f4b;
    border-radius: 6px;
    background-color: #1f2933;
    color: #e0e0e0;
}

.date-inputs input[type="number"] {
    width: 60px; /* Smaller width for day input */
}

.date-input-field {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    border: 1px solid #323f4b;
    border-radius: 6px;
    background-color: #1f2933;
    color: #e0e0e0;
    box-sizing: border-box;
}
.date-input-field::-webkit-calendar-picker-indicator {
    filter: invert(1);
}


.slider-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.slider-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    font-size: 0.9rem;
}

#probability-results-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #323f4b;
}

.probability-result-display {
    display: grid; /* Changed to grid */
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Responsive columns */
    gap: 1rem; /* Adjust gap */
    align-items: center;
    justify-items: center; /* Center items in grid cells */
}

.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 2rem; /* Adjusted size for grid layout */
    font-weight: bold;
    color: #38bdf8;
    margin-bottom: 0.25rem; /* Reduced margin */
}

.stat-value.positive-return {
    color: #22c55e; /* green-500 */
}

.stat-value.negative-return {
    color: #ef4444; /* red-500 */
}

.stat-label {
    font-size: 0.8rem; /* Adjusted size */
    color: #9facb8;
}

.probability-summary {
    font-size: 0.9rem;
    color: #9facb8;
    margin-top: 1rem;
    text-align: center;
}

/* --- Plot Section on Results Page --- */
.plot-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #323f4b;
}

/* --- Tab Layouts --- */
.monthly-layout,
.cumulative-layout { /* Keep for potential future use, but not used for cumulative now */
    display: flex;
    gap: 2rem;
    align-items: flex-start; /* Align items top */
}

.monthly-layout .interactive-calculator,
.cumulative-layout .interactive-plot-controls { /* Keep for potential future use */
    flex: 0 0 300px; /* Sidebar width */
    display: flex;
    flex-direction: column;
    position: sticky; /* Make sidebar sticky */
    top: 2rem; /* Adjust top offset as needed */
}

.monthly-layout .interactive-calculator #probability-results-container {
    border-top: none;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Align results top */
}

.monthly-layout .results-area,
.cumulative-layout .plot-section { /* Keep for potential future use */
    flex: 1; /* Content takes remaining space */
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    min-width: 0; /* Prevent flex item from overflowing */
}

/* Ensure plot container within results area takes full width */
.results-area .plot-section .plot-container {
    width: 100%;
}


/* --- Cumulative Plot Controls (Removed Usage) --- */
.interactive-plot-controls {
    /* Styles remain but the element is removed from cumulative tab */
    background-color: #12181b;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #323f4b;
}

.interactive-plot-controls h4 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #ffffff;
    font-size: 1.2rem;
}

#cumulative-plot-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px; /* Limit height and allow scroll */
    overflow-y: auto;
    padding-right: 10px; /* Space for scrollbar */
}

.checkbox-label {
    display: flex;
    align-items: center;
    background-color: #1f2933;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid #323f4b;
}

.checkbox-label:hover {
    background-color: #2a3745;
}

.checkbox-label input[type="checkbox"] {
    display: none; /* Hide the default checkbox */
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #4a5568;
    border-radius: 4px;
    margin-right: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
    flex-shrink: 0; /* Prevent shrinking */
}

.checkbox-custom svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 3;
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset 0.3s ease-in-out;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background-color: #38bdf8;
    border-color: #38bdf8;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom svg {
    stroke-dashoffset: 0;
}

#cumulative-plot-form .search-button {
    width: 100%;
}


/* --- Optimal Periods Table Styles --- */
.optimal-tables-container {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.optimal-table {
    flex: 1;
    min-width: 450px;
    max-width: 900px;
    background-color: #1f2933; /* Use main content bg */
    border: 1px solid #323f4b;
    border-radius: 8px;
    overflow-x: auto;
}

.optimal-table h4 {
    padding: 0.75rem 1rem;
    margin: 0;
    font-size: 1.1rem;
    text-align: center;
    color: #ffffff;
    border-bottom: 1px solid #323f4b;
}

.optimal-table.best-long h4 {
    background-color: rgba(34, 197, 94, 0.1);
    border-bottom: 2px solid #22c55e;
}

.optimal-table.worst-short h4 {
    background-color: rgba(239, 68, 68, 0.1);
    border-bottom: 2px solid #ef4444;
}

.optimal-table table {
    width: 100%;
    border-collapse: collapse;
}

.optimal-table th, .optimal-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #323f4b;
    vertical-align: middle;
    white-space: nowrap;
}

.optimal-table th {
    background-color: #12181b;
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #9facb8;
}

.optimal-table tbody th[scope="row"] {
    font-weight: 500;
    color: #e0e0e0;
}

.optimal-table tbody tr:last-child td {
    border-bottom: none;
}

.optimal-table tbody tr:hover {
    background-color: #2a3745;
}

.optimal-table th.sortable {
    cursor: pointer;
    position: relative; /* Needed for sort icon */
    padding-right: 20px; /* Space for sort icon */
}

.optimal-table th.sortable:hover {
    background-color: #2a3745;
}

.optimal-table th.sortable::after {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
}

.optimal-table th.sortable.asc::after {
    border-bottom-color: #9facb8; /* Triangle pointing up */
}

.optimal-table th.sortable.desc::after {
    border-top-color: #9facb8; /* Triangle pointing down */
}

/* --- Financial Dashboard Styles --- */
.period-selector {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    background-color: #12181b;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid #323f4b;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.period-selector label {
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.3s;
    color: #9facb8; /* Default color */
}

.period-selector input[type="radio"] {
    display: none;
}

.period-selector input[type="radio"]:checked + label {
    background-color: #38bdf8;
    color: #ffffff;
    font-weight: bold;
}

.financial-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); /* Responsive grid */
    gap: 2rem;
}


/* Data bar styles */
.data-bar-container {
    width: 100%;
    min-width: 100px;
    height: 22px;
    background-color: #12181b;
    border: 1px solid #323f4b;
    border-radius: 4px;
    position: relative;
    overflow: hidden; /* Ensure bar stays within container */
}

.data-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease-in-out; /* Smooth transition for width changes */
}

.data-bar.positive { background-color: #22c55e; }
.data-bar.negative { background-color: #ef4444; }
.data-bar.win-rate-bar { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }

.data-bar-label {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    color: #ffffff;
    font-weight: bold;
    font-size: 0.8rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    white-space: nowrap; /* Prevent label wrapping */
}

/* --- Info Button Styles --- */
.info-button {
    position: absolute;
    top: 0rem; /* Adjust if padding changes */
    right: 2.5rem;/* <-- MODIFIED */
    width: 24px;
    height: 24px;
    background-color: rgba(50, 63, 75, 0.7); /* Slightly transparent dark background */
    color: #e0e0e0; /* Light text */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #323f4b;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: background-color 0.2s;
}
.info-button:hover {
     background-color: rgba(80, 93, 105, 0.9);
}

.info-button::after {
    content: attr(data-info);
    position: absolute;
    bottom: 125%; /* Position above the button */
    right: 0;
    width: 280px;
    background-color: #12181b;
    color: #e0e0e0;
    text-align: left;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #323f4b;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none; /* The tooltip itself shouldn't be interactive */
    font-size: 0.85rem;
    font-family: 'Roboto', sans-serif;
    font-weight: normal;
    line-height: 1.5;
}

.info-button:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Visually Hidden Class */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Styles for Sub-tabs (MODIFIED) --- */
.sub-tabs {
    display: none; /* Hide sub-tab buttons */
}

#sub-tab-content {
    display: flex;
    flex-direction: column;
}

/* Override inline styles from results.html to show all panes */
#seasonality .sub-tab-pane {
    display: block;
}

#cumulative {
    order: 1;
}

#correlation {
    order: 2;
}

#monthly {
    order: 3;
}


/* --- Responsive Styles --- */

/* For tablets and smaller desktops */
@media (max-width: 1024px) {
    .top-bar {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .top-bar .nav-button {
        justify-self: center;
    }
    .optimal-tables-container {
        flex-direction: column;
        align-items: center;
    }
    .optimal-table {
        width: 100%;
        max-width: 900px; /* Give it a max-width for readability */
    }

    /* Stack layouts on smaller screens */
    .cumulative-layout, /* Kept for potential future use */
    .monthly-layout {
        flex-direction: column;
    }
    .cumulative-layout .interactive-plot-controls, /* Kept for potential future use */
    .monthly-layout .interactive-calculator {
        flex: 1 1 auto; /* Allow it to take full width */
        width: 90%;
        position: static; /* Remove sticky positioning */
        margin-bottom: 2rem; /* Add space below sidebar */
    }
    .financial-dashboard-grid {
         grid-template-columns: 1fr; /* Single column */
         minmax(0, 1fr); /* Ensure it doesn't overflow */
    }
}

/* --- MOBILE STYLES START --- */
@media (max-width: 640px) {
    .main-content {
        padding: 1.5rem 0rem; /* <-- MODIFIED */
    }
    .header {
        padding: 0.8rem 1rem; /* Tighter padding */
    }
     .header h1 {
        font-size: 1.5rem;
    }
    .header .header-ticker-display {
        display: none; /* Remove ticker display on mobile */
    }
    
    /* Compact Top-bar */
    .top-bar {
        padding-bottom: 1.5rem; /* Reduce bottom padding */
        margin-bottom: 1.5rem; /* Reduce margin below */
        gap: 1rem; /* Reduce gap */
    }
    .top-bar .nav-button {
        display: none; /* Hide 'New Search' button */
    }
    .search-form {
        flex-direction: row; /* Put button next to input */
        gap: 0.5rem; /* Tighter gap */
    }
    .search-input {
        flex-grow: 1; /* Let the input grow */
    }
    .search-button {
        width: auto; /* Override full-width */
        flex-shrink: 0; /* Prevent button from shrinking */
        padding: 12px 20px; /* Adjust padding */
    }
    .nav-button { /* Keep .nav-button rule for other buttons if needed */
        width: 100%;
        padding: 12px;
    }
    
    .plot-container {
        padding: 0.5rem;
    }
    
    /* Compact Info Button */
    .info-button {
        top: 0rem;
        right: 2.25rem; /* <-- MODIFIED */
        width: 22px;
        height: 22px;
    }
    .info-button::after {
        width: 200px; /* Smaller tooltip */
        font-size: 0.8rem;
    }

    /* Main Tabs Scrolling */
    .tabs ul {
        justify-content: flex-start; /* Align tabs left */
        overflow-x: auto; /* Allow horizontal scroll for tabs */
        padding-bottom: 5px; /* Space for scrollbar */
    }
     .tabs a {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    /* Sub-tabs Readability (Rule is hidden, but kept for reference) */
    .sub-tabs {
        padding: 0.3rem; /* Tighter padding on the container */
    }
    .sub-tabs a {
        padding: 0.5rem 1rem; /* Was 0.6rem 1.2rem */
        font-size: 0.9rem; /* Was 0.95rem */
    }

    /* --- MORE COMPACT Probability Calculator --- */
    .interactive-calculator {
        padding: 1rem; /* Was 1.5rem */
    }
    .interactive-calculator h3 {
        font-size: 1.1rem; /* Was 1.2rem */
        margin-bottom: 0.75rem; /* Was 1rem */
    }
    .interactive-calculator p {
        font-size: 0.85rem; /* Was 0.9rem */
        margin-bottom: 1rem; /* Was 1.5rem */
    }
    .date-selector-group {
        gap: 0.75rem; /* Was 1rem */
        margin-bottom: 1rem; /* Was 1.5rem */
    }
    .date-selector label {
        font-size: 0.85rem; /* Was 0.9rem */
        margin-bottom: 0.25rem; /* Was 0.5rem */
    }
    .date-inputs {
        /* flex-direction: column; /* Stack month/day */
        gap: 0.5rem; /* Was 0.8rem */
    }
    .date-inputs select,
    .date-inputs input[type="number"] {
        padding: 8px; /* Was 10px */
        font-size: 0.85rem; /* Was 0.9rem */
    }
    .date-inputs input[type="number"] {
        /* width: 100%; */ /* <-- REMOVED */
        flex: 1; /* <-- ADDED: Will take 1 part of the available space */
    }
    .date-inputs select {
        flex: 1; /* <-- ADDED: Give the month select 1 part of the space */
    }
    .slider-group {
        gap: 0.75rem; /* Was 1rem */
        margin-bottom: 1rem; /* Was 1.5rem */
    }
    .slider-container label {
        font-size: 0.85rem; /* Was 0.9rem */
    }
    #probability-results-container {
        margin-top: 1rem; /* Was 1.5rem */
        padding-top: 1rem; /* Was 1.5rem */
    }
    .probability-result-display {
        grid-template-columns: repeat(2, 1fr); /* 2 columns */
        gap: 0.6rem; /* Was 0.8rem */
    }
    .stat-value {
        font-size: 1.3rem; /* Was 1.5rem */
    }
    .stat-label {
        font-size: 0.7rem; /* Was 0.75rem */
    }
    /* --- END MORE COMPACT Probability Calculator --- */
    
    
    /* --- SUPER COMPACT Financial Summary --- */
    #financial-summary-container {
        margin-bottom: 1.5rem; /* Was 2.5rem */
    }
    .financial-summary {
        padding: 0.75rem 1rem; /* Was 1rem 1.25rem */
    }
    .summary-header {
        margin-bottom: 0.75rem; /* Was 1rem */
        text-align: center; /* Center header */
    }
    .summary-header h2 {
        font-size: 1.2rem; /* Was 1.5rem */
    }
    .summary-header span {
        font-size: 0.8rem; /* Was 1rem */
    }
    .summary-grid {
        /* Tighter grid, min 90px */
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 0.5rem; /* Was 0.75rem */
    }
    .summary-card {
        text-align: center; /* Center card content */
        padding: 0.25rem; /* Add a little internal padding */
    }
    .summary-label {
        font-size: 0.7rem; /* Was 0.75rem */
        margin-bottom: 0; /* Was 0.25rem */
        white-space: nowrap; /* Prevent wrapping */
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .summary-value {
        font-size: 1rem; /* Was 1.05rem */
    }
     .summary-value.score {
        font-size: 1.1rem; /* Was 1.2rem */
    }
    /* --- END SUPER COMPACT Financial Summary --- */


    /* Compact Optimal Periods Card View */
    .optimal-table {
        min-width: unset; /* Remove min-width */
    }
    .optimal-table thead {
        position: absolute;
        clip: rect(1px, 1px, 1px, 1px);
        padding: 0;
        border: 0;
        height: 1px;
        width: 1px;
        overflow: hidden;
    }

    .optimal-table tr {
        display: block;
        margin-bottom: 1rem; /* Was 1.5rem */
        border: 1px solid #323f4b;
        border-radius: 6px; /* Was 8px */
        padding: 0;
        background-color: #12181b; /* Card background */
    }
     .optimal-table tr:last-child {
        margin-bottom: 0;
    }

    .optimal-table td, .optimal-table th[scope="row"] {
        display: block;
        text-align: right; /* Align value to the right */
        border-bottom: 1px solid #323f4b;
        padding: 0.75rem; /* Was 0.75rem 1rem */
        white-space: normal; /* Allow wrapping */
        min-height: 1.5em; /* Ensure min height */
    }
    .optimal-table td:last-child,
    .optimal-table tbody tr:last-child td:last-child {
        border-bottom: none;
    }
     .optimal-table td[data-title]::before,
     .optimal-table th[scope="row"]::before { /* Also add label for first cell if needed */
        content: attr(data-title); /* Use JS to add data-title if not present */
        float: left; /* Label on the left */
        font-weight: bold;
        color: #9facb8;
        padding-right: 0.75rem; /* Was 10px */
        white-space: nowrap;
    }
    
    /* --- Heatmap Mobile Adjustments --- */
    #monthly .results-area {
        display: none; /* Hide heatmap container */
    }
    
    #monthly-chart {
        min-height: 600px; /* Reduce default height on mobile */
        max-height: 80vh; /* Add a max height */
    }
    
}
/* --- MOBILE STYLES END --- */


@media (max-width: 360px) {
    .container {
        padding: 1rem; /* Reduce main container padding (was 2rem) */
    }

    .main-content {
        padding: 1rem 0; /* <-- MODIFIED */
    }

    .header h1 {
        font-size: 1.3rem; /* Slightly smaller title */
    }
    
    .search-input,
    .search-button {
        padding: 10px 12px; /* Further reduce padding */
        font-size: 0.9rem; /* Further reduce font */
    }
     .nav-button {
         padding: 10px 12px;
         font-size: 0.9rem;
     }

    /* Make summary grid more flexible */
    .summary-grid {
        /* Use 80px as the minimum for 3-col layout */
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 0.4rem; /* Tighter gap */
    }

    .summary-value {
        font-size: 0.9rem; /* Smaller value font */
    }
    .summary-value.score {
        font-size: 1rem; /* Smaller score font */
    }
    .summary-label {
        font-size: 0.65rem; /* Smaller label font */
    }
    
    /* Make probability stats more compact */
    .probability-result-display {
        /* Single column for smallest screens */
        grid-template-columns: 1fr; 
        gap: 0.4rem; /* Tighter gap */
    }
    .stat-value {
        font-size: 1.1rem; /* Smaller stat font */
    }
    .stat-label {
        font-size: 0.65rem; /* Smaller label font */
    }

    /* Reduce padding on table-cards */
    .optimal-table td, .optimal-table th[scope="row"] {
        padding: 0.5rem; /* Was 0.6rem */
        font-size: 0.85rem;
    }
    .optimal-table td[data-title]::before {
        font-size: 0.8rem;
    }
    
    /* Reduce padding on main tabs */
    .tabs a {
        padding: 0.5rem 0.7rem; /* Was 0.6rem 0.8rem */
        font-size: 0.8rem; /* Was 0.85rem */
    }
    
    /* Reduce padding on sub-tabs */
    .sub-tabs a {
        padding: 0.4rem 0.8rem; /* Was 0.5rem 1rem */
        font-size: 0.85rem; /* Was 0.9rem */
    }
    
    /* Reduce padding on interactive calculator sidebar */
    .interactive-calculator {
        padding: 0.75rem; /* Was 1rem */
    }
    .interactive-calculator h3 {
        font-size: 1rem; /* Was 1.1rem */
    }
    .interactive-calculator p {
        font-size: 0.8rem; /* Was 0.85rem */
        margin-bottom: 0.75rem;
    }
    .date-inputs select, .date-inputs input[type="number"] {
        font-size: 0.8rem; /* Was 0.85rem */
    }
    .slider-container label {
        font-size: 0.8rem; /* Was 0.85rem */
    }

}