/* --- BRANDING & BASE STYLES --- */
:root {
    --title-color: #23373E;    
    --body-text: #22395C;      
    --action-orange: #FF9900;  
    --accent-teal: #59817E;    
    --success-green: #28a745;  
    --success-bg: #e6f9ec;     
    --success-text: #155724;   
    --card-bg: rgba(255, 255, 255, 0.97); 
    --border-color: #dee2e6;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    margin: 0;
    padding: 40px 20px; 
    color: var(--body-text); 
    line-height: 1.6; 
    background-color: transparent;
}

.container { 
    max-width: 1200px;
    margin: 0 auto; 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: 8px; 
    box-shadow: 0 12px 30px rgba(0,0,0,0.2); 
    position: relative;
}

/* Language Toggle */
.lang-toggle {
    position: absolute;
    top: 25px;
    right: 40px;
    display: flex;
    gap: 8px;
    z-index: 100;
}
.lang-toggle a {
    text-decoration: none;
    color: var(--title-color);
    font-weight: bold;
    opacity: 0.5;
    transition: 0.2s;
    font-size: 1.1em;
}
.lang-toggle a.active {
    color: var(--action-orange);
    opacity: 1;
}
.lang-toggle a:hover { opacity: 1; }

h1, h2, h3, h4, h5, h6 { color: var(--title-color) !important; }

.header-section { display: flex; align-items: center; justify-content: space-between; border-bottom: 3px solid var(--accent-teal); padding-bottom: 20px; margin-bottom: 30px; margin-top: 20px;}
.header-section img { max-height: 60px; }
.header-titles h2 { margin: 0; font-size: 2em; }
.header-titles p { margin: 0; font-size: 1.1em; color: var(--body-text); opacity: 0.8;}

/* Grid layouts enforcing splits */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.top-3-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.full-width { grid-column: span 2; }
.form-group { margin-bottom: 15px; }

label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--title-color); }
/* Prevent the asterisk from altering the label's line-height */
.req { color: var(--action-orange); font-weight: bold; font-size: 1.2em; line-height: 0.8; vertical-align: bottom;}

input[type="text"], input[type="number"], select { 
    width: 100%; padding: 12px; border: 1px solid #ced4da; border-radius: 6px; box-sizing: border-box; font-size: 1em; transition: border-color 0.2s; color: var(--body-text);
}
input:focus, select:focus { border-color: var(--accent-teal); outline: none; }

.button-container { text-align: center; margin-top: 25px; }
.action-buttons { display: flex; justify-content: center; gap: 15px; margin-top: 30px; flex-wrap: wrap; }

.btn-action { 
    background-color: var(--action-orange); 
    color: var(--title-color); 
    padding: 12px 30px; 
    border: none; 
    border-radius: 30px; 
    cursor: pointer; 
    font-size: 1.1em; 
    font-weight: normal; 
    transition: transform 0.2s, background-color 0.2s; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn-action:hover { background-color: #e68a00; transform: translateY(-2px); }
button[type="submit"].btn-action { padding: 12px 60px; }

/* Dynamic Pump UI */
.pump-row-headers label { margin-bottom: 0; font-size: 0.9em; }
.pump-container { display: flex; flex-direction: column; gap: 0px; }
.pump-row { background: transparent; border: none; padding: 0; box-shadow: none; margin-bottom: 5px;}

.row-actions { display: flex; flex-direction: column; gap: 4px; width: 32px; flex-shrink: 0; justify-content: center; align-items: center;}

.btn-row-action, .qty-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    font-weight: normal;
    font-size: 20px; 
    font-family: Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    padding: 0;
    margin: 0;
    line-height: 1; 
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}
.btn-row-action:hover, .qty-btn:hover { transform: scale(1.05); box-shadow: 0 4px 6px rgba(0,0,0,0.15); }

.btn-row-action { color: white; }
.btn-remove-row { background-color: #dc3545; }
.btn-add-row { background-color: var(--success-green); }

.qty-btn { background-color: var(--action-orange); color: var(--title-color); }
.qty-input { width: 16px !important; text-align: center; border: none !important; pointer-events: none; font-weight: normal; font-size: 1.1em !important; color: var(--title-color) !important; padding: 0 !important; background: transparent; margin: 0; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty-input[type=number] { -moz-appearance: textfield; }

/* Custom box */
.custom-box { border: 1.5px dashed #ccc; border-radius: 8px; background: #fdfdfd; padding: 15px;}
.custom-box input { margin-bottom: 0; }
.custom-box-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 15px; align-items: end; }

@media (max-width: 950px) {
    .pump-row-headers { display: none; }
    .form-grid        { grid-template-columns: 1fr; }
    .top-3-cols       { grid-template-columns: 1fr; }
    .custom-box       { margin-left: 0 !important; margin-right: 0 !important; }
    .custom-box-grid  { grid-template-columns: 1fr; gap: 10px; }
    .form-section     { padding: 12px; }
    .summary-grid     { grid-template-columns: 1fr 1fr; }
    .comparison-grid  { grid-template-columns: 1fr; }
    .footnote-content { grid-template-columns: 1fr; }
    .disclaimer-full  { grid-column: span 1; }
}

@media (max-width: 600px) {
    /* --- General Layout & Screen Space --- */
    body { padding: 15px 10px; }
    .container { padding: 20px 15px; }
    
    /* --- Header & Language Toggle --- */
    .lang-toggle { right: 15px; top: 15px; }
    .header-section { flex-direction: column; text-align: center; gap: 15px; padding-top: 20px; }
    .header-titles h2 { font-size: 1.6em; }
    
    /* --- Looptijd & Tijdseenheid (Side-by-side) --- */
    .time-group { 
        display: flex !important;
        flex-direction: row !important; 
        align-items: flex-end; 
        gap: 10px; 
    }
    
    /* --- Pump & Aggregate Row Grid Restructuring --- */
    /* 1. Force the main container into a strict 3-row CSS Grid */
    .pump-input-group {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "actions qty"
            "variant variant"
            "working stage";
        gap: 12px 10px !important;
    }
    
    /* 2. Break out the inner flex wrappers so the inputs join the main grid */
    .pump-input-group > div { display: contents !important; }

    /* Row 1: Actions (Left) & Qty (Right) */
    .row-actions {
        grid-area: actions;
        flex-direction: row !important;
        justify-content: flex-start;
        align-items: center;
        width: auto !important;
        gap: 10px;
    }
    .qty-controls {
        grid-area: qty;
        justify-self: end;
        width: auto !important;
        gap: 8px;
    }
    
    /* Row 2: Variant Select (Full Width) */
    .pump-input-group > div:nth-child(1) > div:nth-child(2) { grid-area: variant; }
    
    /* Row 3: Working Profile & Stage (Half width each) */
    .pump-input-group > div:nth-child(2) > div:nth-child(1) { grid-area: working; }
    .pump-input-group > div:nth-child(2) > div:nth-child(2) { grid-area: stage; }
    
    /* --- Touch-Friendly, Perfect Circle Buttons --- */
    .btn-row-action, .qty-btn { 
        width: 44px !important; 
        height: 44px !important; 
        font-size: 22px; 
        border-radius: 50% !important; 
        flex-shrink: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        /* REMOVED: display: flex !important; so your JS can hide the buttons again! */
    }
    
    .qty-input { width: 30px !important; }
    
    /* Makes main calculation buttons full-width */
    .action-buttons { flex-direction: column; align-items: stretch; gap: 12px; }
    .btn-action { width: 100%; box-sizing: border-box; } 
    
    /* --- Comparison Vertical Fix --- */
    .comparison-grid { 
        display: flex !important; 
        flex-direction: column !important; 
        gap: 15px;
    }
    .data-value { text-align: right; word-break: break-word; }

    /* --- Results Summary & Impact Box --- */
    .summary-grid { 
        display: flex !important;
        flex-direction: column !important;
        gap: 15px; 
        padding: 15px; 
    }
    .summary-item { 
        border-right: none !important;
        border-bottom: 1px dashed #dee2e6;
        padding-bottom: 15px; 
        width: 100%;
        align-items: center;
    }
    .summary-item:last-child { 
        border-bottom: none; 
        padding-bottom: 0; 
    }
    .impact-box { flex-direction: column; text-align: center; }
    
    /* --- Email Paywall --- */
    #email-wall form { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
    #email-wall input[type="email"] { width: 100% !important; max-width: none !important; }
    #email-wall button { margin-left: 0 !important; }
    
    /* --- Table Scrolling --- */
    .footnote-content > div { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .emission-table { min-width: 450px; }
}

/* Force inner boxes to align at the bottom */
.time-group { display: flex; gap: 15px; align-items: flex-end;}
.time-group > div { flex: 1; }

.results-wrapper { margin-top: 40px; border-top: 1px dashed #8fa8a6; padding-top: 25px; }
#pdf-report { background: transparent; }

/* Extremely compressed and centered summary grid layout */
.summary-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    background: #fff; 
    border: 1px solid var(--border-color); 
    padding: 2px 5px; /* Extremely tight padding */
    border-radius: 6px; 
    margin-bottom: 15px; /* Reduced margin to save vertical space */
    align-items: center; 
}
.summary-item { 
    text-align: center; 
    border-right: 1px solid #eee; 
    display: flex; 
    flex-direction: column; 
}
.summary-item:last-child { border-right: none; }

.summary-label { 
    display: flex;
    flex: 1;
    align-items: flex-end; /* Pushes titles down to a uniform horizontal baseline */
    justify-content: center;
    color: #999; 
    text-transform: uppercase; 
    font-size: 0.65em; 
    letter-spacing: 1px; 
    padding-bottom: 5px; 
}

.summary-value { 
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: flex-start; /* Values hang naturally below the baseline */
    font-size: 1.05em; 
    font-weight: 800; 
    color: var(--title-color); 
    line-height: 1.1; 
}

.comparison-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 20px; margin-bottom: 25px; }
.comparison-col { background: #fff; padding: 20px; border: 1px solid var(--border-color); border-radius: 6px; }
.comparison-col h4 { margin-top: 0; border-bottom: 2px solid var(--border-color); padding-bottom: 12px; font-size: 1.2em; text-align: center; }

.col-savings { background-color: var(--success-bg); border: 2px solid var(--success-green); }
.col-savings h4 { border-bottom-color: #c3e6cb; color: var(--success-text) !important; }

.data-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 1em; border-bottom: 1px dashed #eee; padding-bottom: 6px; }
.data-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.data-label { color: var(--body-text); opacity: 0.9; }
.data-value { font-weight: bold; color: var(--title-color); }

.highlight-green { color: var(--success-green); font-weight: 900; font-size: 1.1em; }
.divider { height: 10px; }

.totals-row { border-top: 2px solid var(--title-color); padding-top: 10px; margin-top: 5px; }
.totals-row .data-label { color: var(--title-color); font-weight: bold; }
.totals-row .data-value { color: var(--title-color); font-size: 1.15em; font-weight: 900; }

.totals-row-savings { border-top: 3px solid var(--success-green); padding-top: 10px; margin-top: 5px; }
.totals-row-savings .data-label { color: var(--success-text); font-weight: bold; text-transform: uppercase;}
.totals-row-savings .data-value { color: var(--success-green); font-size: 1.25em; font-weight: 900; }

.citypump-box { background-color: var(--success-bg); border: 1px solid var(--success-green); border-radius: 6px; padding: 20px; margin-bottom: 20px; border-left: 5px solid var(--success-green); }
.citypump-box h4 { margin-top: 0; color: var(--success-text) !important; font-size: 1.1em; margin-bottom: 8px; }
.citypump-box p { margin-bottom: 0; font-size: 0.95em; color: var(--success-text); }

.impact-box { display: flex; gap: 20px; background: #fff; border: 1px solid var(--border-color); border-radius: 6px; padding: 15px 20px; align-items: center; margin-bottom: 20px; }
.impact-icon { font-size: 2.2em; }
.impact-text h4 { margin: 0 0 5px 0; font-size: 1em;}
.impact-text p { margin: 0; font-size: 0.9em; opacity: 0.9; }

.footnote { margin-top: 20px; font-size: 0.8em; color: var(--body-text); border-top: 1px solid #ddd; padding-top: 15px; opacity: 0.8; }
.footnote-content { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; background: #fff; }
.disclaimer-full { grid-column: span 2; font-style: italic; margin-bottom: 10px;}
.emission-table { width: 100%; border-collapse: collapse; margin-top: 5px; font-size: 0.9em; }
.emission-table th, .emission-table td { padding: 4px; border-bottom: 1px solid #eee; text-align: left; }
.emission-table th { background-color: #f8f9fa; color: var(--title-color);}

/* --- NEW STYLES: Dotted Lines & Loader --- */
.form-separator {
    margin-top: 30px;
    border-top: 1px dashed #8fa8a6;
    padding-top: 25px;
}

.loader-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
    display: none; /* hidden by default */
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

@media print {
    @page { size: A4 portrait; margin: 12mm; }
    body { background-color: #fff; background-image: none; padding: 0; font-size: 10pt; }
    .container { box-shadow: none; padding: 0; max-width: 100%; margin: 0; }
    .lang-toggle, form, .action-buttons, p.intro-text { display: none !important; } 
    .header-section { border-bottom: 2px solid var(--accent-teal); margin-bottom: 20px; padding-bottom: 10px; margin-top: 0;}
    .results-wrapper { margin-top: 0; padding-top: 0; border-top: none; }
    .comparison-grid { gap: 10px; margin-bottom: 15px; }
    .comparison-col { padding: 12px; }
    .data-row { font-size: 0.95em; margin-bottom: 8px; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .comparison-col, .citypump-box, .impact-box, .citypump-suggestion { page-break-inside: avoid; }
}