:root {
    --gold: #fbbf24;
    --red: #ef4444;
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: #0b0f1a;
    color: var(--text-main);
    padding: 40px 20px;
    margin: 0;
}

.calculator-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* Quiz Specific (Keeps quiz centered and narrow) */
.quiz-narrow {
    max-width: 600px;
}

.quiz-question {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
}

.quiz-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.quiz-options button {
    flex: 1;
    background: #1e293b;
    border: 1px solid var(--border);
    color: white;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}

.quiz-options button.selected {
    background: var(--gold);
    color: var(--bg-dark);
    font-weight: bold;
}

/* Calculator Specific Styling */
.calc-header {
    text-align: center;
    margin-bottom: 40px;
}

.calc-header h1 {
    color: var(--gold);
    font-size: 2.5rem;
    margin: 0 0 10px 0;
}

.calc-header p {
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 40px;
    align-items: flex-start;
}

.input-group {
    background: var(--bg-dark);
    padding: 30px;
    border-radius: 16px;
    margin-bottom: 25px;
    border: 1px solid var(--border);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 20px;
}

input[type=range] {
    flex-grow: 1;
    accent-color: var(--gold);
    cursor: pointer;
}

.value-display {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
    min-width: 100px;
}

.input-hint {
    font-size: 1rem;
    color: #64748b;
    margin-top: 15px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-card {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 12px;
    border-top: 4px solid #475569;
}

.stat-card.featured {
    grid-column: span 2;
    border-top-color: var(--gold);
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.stat-card h2 {
    font-size: 2.4rem;
    margin: 5px 0;
    color: var(--gold);
}

.stat-card h3 {
    font-size: 1.4rem;
    margin: 5px 0;
    font-family: monospace;
}

.calc-visual {
    background: var(--bg-dark);
    padding: 30px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-self: stretch;
    border: 1px solid var(--border);
    min-height: 0;
    /* Alain */
}

.chart-container {
    flex: 1;
    min-height: 400px;
    position: relative;
    width: 100%;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 20px;
    font-size: 0.9rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

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

.dot.gold {
    background: var(--gold);
}

.dot.red {
    background: var(--red);
}

/* Main Action Button (Pulse) */
.main-action {
    width: 100%;
    padding: 18px;
    background: var(--gold);
    color: var(--bg-dark);
    border: none;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
}

/* Pulse Animation */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
    }

    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(251, 191, 36, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
    }
}

.pulse-btn {
    animation: pulse 2s infinite;
}

.explain-btn {
    background: var(--gold);
    color: var(--bg-dark);
    border: none;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.3s;
    padding: 20px;
}

/* RESPONSIVE OPTIMIZATIONS */
@media (max-width: 900px) {
    body {
        font-family: 'Inter', -apple-system, sans-serif;
        background-color: #0b0f1a;
        color: var(--text-main);
        margin: 0;
        padding: 5px;
        /* Reduced padding for mobile */
        min-height: 100vh;
        /* Changed from height: 100vh */
        display: flex;
        flex-direction: column;
        /* Stack vertically */
        align-items: center;
        justify-content: flex-start;
        /* Align to top to remove bottom gap */
        overflow-y: auto;
        /* Allow scrolling if content is long */
        overflow-x: hidden;
        /* Hard stop for horizontal scrolling */
    }

    .calculator-container {
        max-width: 1200px;
        width: 100%;
        margin: 0 auto;
        background: var(--card-bg);
        padding: 25px;
        /* Slightly tighter padding */
        border-radius: 24px;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
        border: 1px solid var(--border);
        height: auto;
        /* Ensure it only takes the space it needs */
    }

    .calc-header {
        margin-bottom: 10px;
    }

    .calc-header h1 {
        font-size: 1.4rem;
    }

    .calc-header p {
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .calc-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        flex: 1;
        min-height: 0;
    }

    .input-group {
        padding: 15px;
        margin-bottom: 10px;
    }

    .value-display {
        font-size: 1.4rem;
    }

    .stats-grid {
        gap: 8px;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-card h2 {
        font-size: 1.8rem;
    }

    .stat-card h3 {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .calc-visual {
        min-height: 200px;
        padding: 15px;
        /* Alain */
        flex: 1;
    }

    .chart-container {
        min-height: 250px;
    }

    .chart-legend {
        margin-top: 10px;
        font-size: 0.7rem;
    }

    .input-hint {
        display: none;
    }

}

@media (max-height: 700px) {
    .calc-header p {
        display: none;
    }

    .stat-card.featured {
        display: none;
    }
}

@media (max-width: 600px) {
    body {
        padding: 10px 5px;
        display: block;
        /* Disable flex centering on mobile for better scrolling */
    }

    .calculator-container {
        margin-top: 0;
        border-radius: 15px;
        /* Sharper corners look better on small edges */
        padding: 15px;
    }

    /* Ensure the scroll wrappers don't force extra height */
    .quiz-scroll-wrapper,
    .calc-scroll-wrapper {
        max-height: none;
        overflow: visible;
    }
}

/* --- Modal Overlay & Background --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 26, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    padding: 20px 15px;
    overflow-y: auto; /* This is key for mobile */
    display: flex;    /* Use flex for centering */
    justify-content: center;
    align-items: flex-start; /* Start at top so header isn't cut off */
}

/* --- Modal Content Box --- */
.modal-content {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 24px;
    width: 100%;
    max-width: 500px; 
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border);
    color: var(--text-main);
    /* Remove the 50px margin which was causing the offset */
    margin: 20px 0; 
}

/* --- DESKTOP WIDE SETTING --- */
@media (min-width: 768px) {
    .modal-content {
        max-width: 800px;
        padding: 40px;
        /* Center horizontally on desktop, keep vertical margin reasonable */
        margin: 40px auto; 
    }
}

    /* Optional: Make the Leak List two columns on desktop to fill space */
    .leak-list {
        display: grid;
        /* Fixed widths: Column 1 is 300px, Column 2 is 300px */
        /* Change 'auto' to 'max-content' to hug the text tightly */
        grid-template-columns: repeat(2, minmax(150px, 1fr));
        gap: 10px 60px;
        /* 10px vertical, 60px horizontal gap */
        justify-content: start;
        /* Align the whole grid to the left */
        list-style: none;
        padding: 0;
    }

    .leak-list li {
        display: flex;
        justify-content: space-between;
        /* Space between label and $ value within the column */
        align-items: center;
        padding: 8px 0;
    }
}

/* --- Close Button (X) --- */
.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
}

.close-modal:hover {
    color: var(--gold);
}

/* --- Insight Blocks --- */
.modal-content .insight-block {
    background: var(--bg-dark);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
}

/* --- ROI Section: Desktop Fix --- */
@media (min-width: 768px) {
    .modal-content {
        max-width: 800px;
        padding: 40px;
    }

    /* Uses Grid to create a massive gap between the two elements */
    .roi-split-row {
        display: grid;
        grid-template-columns: 180px 1fr;
        /* Fixed narrow input, flexible result space */
        gap: 100px;
        /* This creates the big physical gap you need */
        align-items: center;
        margin-top: 15px;
    }

    .roi-display-wrapper {
        text-align: left;
    }

    .leak-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 40px;
    }
}

/* --- ROI Elements --- */
.roi-input-wrapper,
.roi-display-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.roi-input {
    background: #0f172a;
    border: 2px solid var(--border);
    color: var(--gold);
    padding: 10px;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: 700;
    width: 100%;
    outline: none;
    text-align: center;
    transition: border-color 0.3s;
}

.roi-input:focus {
    border-color: var(--gold);
}

#customROIResult {
    font-size: 1.8rem;
    /* Made slightly larger for emphasis */
    font-weight: 800;
    color: #4ade80;
    display: block;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 600px) {
    .modal-content {
        margin: 10px auto;
        /* Keeps it tight on small screens */
        padding: 20px;
    }

    .roi-split-row {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .roi-input-wrapper {
        width: 100%;
    }

    .roi-display-wrapper {
        width: 100%;
        text-align: center;
        border-top: 1px solid var(--border);
        padding-top: 0;
    }
}

/* --- Buttons --- */
.modal-actions {
    margin-top: 25px;
    text-align: center;
}

.cta-button {
    display: inline-block;
    /* Changed to inline-block for desktop look */
    max-width: 280px;
    background: var(--gold);
    color: var(--bg-dark);
    text-decoration: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-weight: 800;
    text-transform: uppercase;
    transition: 0.3s ease;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .roi-split-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal-content {
        padding: 20px;
        border-radius: 16px;
    }

    .cta-button {
        width: 80%;
        /* Back to full width on mobile */
    }
}

/* Narrow the input specifically on Desktop */
@media (min-width: 768px) {
    .modal-content {
        max-width: 800px;
        padding: 40px;
        margin: 600px auto;
    }

    /* Fixed width for the input wrapper so it doesn't push against the result */
    .roi-input-wrapper {
        flex: 0 0 100px;
        /* Locks the input to 200px width on desktop */
    }

    .leak-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 300px;
    }

.roi-input {
    background: #0f172a;
    border: 2px solid var(--border);
    color: var(--gold);
    padding: 10px;
    /* Reduced padding */
    border-radius: 10px;
    font-size: 1.3rem;
    /* Slightly smaller font to prevent overflow */
    font-weight: 700;
    width: 100%;
    outline: none;
    text-align: center;
}

/* Hide specific insight blocks on mobile to save vertical space */
@media (max-width: 600px) {
    .desktop-only-insight {
        display: none !important;
    }

    /* Optional: Adjust modal margin further for small phones */
    .modal-content {
        margin: 5px auto;
        padding: 15px;
    }
}

.back-link {
    transition: color 0.3s ease;
    padding: 5px 0;
}

.back-link:hover {
    color: var(--gold) !important;
    text-decoration: underline;
}

/* Container for the side-by-side layout */
.audit-recovery-grid {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Reduce space between audit header and list */
.audit-column p {
    margin-bottom: 8px !important; /* Shaved off 7px from your original 15px */
}

/* DESKTOP: Switch to two columns */
@media (min-width: 768px) {
    .audit-recovery-grid {
        display: grid;
        grid-template-columns: 1.2fr 1fr;
        /* Audit column slightly wider */
        gap: 40px;
        align-items: start;
        border-bottom: 1px solid var(--border);
        padding-bottom: 20px;
        margin-bottom: 20px;
    }

    .recovery-column {
        background: rgba(251, 191, 36, 0.03);
        /* Subtle highlight for the result side */
        padding: 20px;
        border-radius: 12px;
        border: 1px solid rgba(251, 191, 36, 0.1);
    }

    /* Resetting your previous leak-list grid to keep it in one column inside its container */
    .leak-list {
        display: block !important;
        grid-template-columns: repeat(2, 1fr); 
        gap: 5px 30px; /* Reduced vertical gap to 5px and horizontal to 30px */
    }

    .leak-list li {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    }
}

/* Fix for your existing .modal-content margin error (600px was likely a typo) */
@media (min-width: 768px) {
    .modal-content {
        margin: 40px auto !important;
    }
}

/* Remove the gap between the waste note and the ROI header */
#totalWasteReported {
    margin-bottom: 0;
}

/* Target the ROI Analysis Header specifically */
.roi-section-header, 
.modal-content h3:nth-of-type(2) { 
    margin-top: 10px !important; /* Forces a small 10px gap instead of the default large margin */
    margin-bottom: 5px;
}

/* Adjust the paragraph directly above the Investment input */
.roi-input-wrapper label,
.roi-input-wrapper span {
    margin-bottom: 2px;
}