/* --- CSS Variables --- */
#dcrghryx_calculator_wrapper {
    --primary: #0B1F51;      
    --text: #2B3445;         
    --accent: #0B1F51;       
    --accent-hover: #AFC8FF; 
    
    --bg: #F8FAFC;
    --border: #cbd5e1;       
    --card: #FFFFFF;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --radius: 6px;           
}

#dcrghryx_calculator_wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
#dcrghryx_calculator_wrapper { font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; padding: 20px; }

#dcrghryx_calculator_wrapper .dcrghryx_calculator-container { 
    max-width: 1200px; 
    margin: 2rem auto; 
    background: var(--card); 
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.07); 
    border: 1px solid #e2e8f0; 
    overflow: hidden; 
}

#dcrghryx_calculator_wrapper .dcrghryx_calculator-grid { display: grid; grid-template-columns: 1fr 1.1fr; } 

#dcrghryx_calculator_wrapper .dcrghryx_input-section, 
#dcrghryx_calculator_wrapper .dcrghryx_results-section, 
#dcrghryx_calculator_wrapper .dcrghryx_results-placeholder { padding: 30px; }

#dcrghryx_calculator_wrapper .dcrghryx_input-section { border-right: 1px solid #e2e8f0; background: var(--card); }
#dcrghryx_calculator_wrapper .dcrghryx_results-section, 
#dcrghryx_calculator_wrapper .dcrghryx_results-placeholder { background: var(--bg); }

#dcrghryx_calculator_wrapper .dcrghryx_section-title { 
    color: var(--primary); 
    font-size: 1.25rem; 
    font-weight: 700; 
    margin-bottom: 24px; 
    padding-bottom: 12px; 
    border-bottom: 2px solid #e2e8f0; 
}

#dcrghryx_calculator_wrapper .dcrghryx_form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
    row-gap: 20px;
}

#dcrghryx_calculator_wrapper .dcrghryx_full-width { grid-column: 1 / -1; }

#dcrghryx_calculator_wrapper .dcrghryx_input-group { position: relative; display: flex; flex-direction: column; }

#dcrghryx_calculator_wrapper .dcrghryx_input-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 600; 
    color: #1e293b; 
    font-size: 0.85rem; 
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Fix for Dropdown Clipping */
#dcrghryx_calculator_wrapper input[type="text"], 
#dcrghryx_calculator_wrapper input[type="number"], 
#dcrghryx_calculator_wrapper input[type="date"], 
#dcrghryx_calculator_wrapper select, 
#dcrghryx_calculator_wrapper .dcrghryx_input-display {
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid var(--border); 
    border-radius: var(--radius);
    font-size: 16px; 
    background: #ffffff; 
    color: #334155; 
    transition: all 0.2s; 
    font-family: inherit;
    min-height: 46px; 
    line-height: 1.5; 
    height: auto;     
}

#dcrghryx_calculator_wrapper select { padding-right: 35px; }

#dcrghryx_calculator_wrapper ::placeholder { color: #94a3b8; }
#dcrghryx_calculator_wrapper input[type="date"] { color: #334155; }

#dcrghryx_calculator_wrapper .dcrghryx_input-display {
    background-color: #f8fafc;
    color: #0f172a;
    font-weight: 600;
    cursor: default;
    display: flex;
    align-items: center; 
}

#dcrghryx_calculator_wrapper .dcrghryx_select-wrapper { position: relative; }
#dcrghryx_calculator_wrapper .dcrghryx_select-wrapper::after {
    content: "▼"; font-size: 0.7rem; color: #475569;
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none;
    z-index: 2;
}
#dcrghryx_calculator_wrapper select { appearance: none; -webkit-appearance: none; }

#dcrghryx_calculator_wrapper input:focus, 
#dcrghryx_calculator_wrapper select:focus { 
    outline: none; border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 3px #eff6ff; 
}

#dcrghryx_calculator_wrapper .dcrghryx_date-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

#dcrghryx_calculator_wrapper .dcrghryx_input-desc { font-size: 0.8rem; color: #64748b; margin-top: 4px; display: block; text-transform: none; font-weight: 400; letter-spacing: normal;}

#dcrghryx_calculator_wrapper .dcrghryx_hidden { display: none !important; }

#dcrghryx_calculator_wrapper .dcrghryx_input-group.dcrghryx_error input, 
#dcrghryx_calculator_wrapper .dcrghryx_input-group.dcrghryx_error select { border-color: var(--error); background-color: #fef2f2; }
#dcrghryx_calculator_wrapper .dcrghryx_inline-error { color: var(--error); font-size: 0.8rem; margin-top: 4px; display: none; font-weight: 500; }
#dcrghryx_calculator_wrapper .dcrghryx_input-group.dcrghryx_error .dcrghryx_inline-error { display: block; }

#dcrghryx_calculator_wrapper .dcrghryx_checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

#dcrghryx_calculator_wrapper .dcrghryx_checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    min-height: auto; 
}

#dcrghryx_calculator_wrapper .dcrghryx_action-buttons { margin-top: 30px; grid-column: 1 / -1; display: flex; gap: 15px; }
#dcrghryx_calculator_wrapper button {
    padding: 16px 24px; border-radius: var(--radius); cursor: pointer; 
    font-size: 16px; font-weight: 700; width: 100%; border: none; 
    transition: 0.2s; text-transform: uppercase; letter-spacing: 0.5px;
}

#dcrghryx_calculator_wrapper #dcrghryx_calculateBtn { flex: 2; background: var(--accent); color: white; box-shadow: 0 4px 6px -1px rgba(11, 31, 81, 0.2); }
#dcrghryx_calculator_wrapper #dcrghryx_calculateBtn:hover { background: var(--accent-hover); color: var(--primary); }

#dcrghryx_calculator_wrapper #dcrghryx_resetBtn { flex: 1; background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; }
#dcrghryx_calculator_wrapper #dcrghryx_resetBtn:hover { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

#dcrghryx_calculator_wrapper #dcrghryx_printReportBtn { background: var(--card); border: 2px solid var(--accent); color: var(--accent); margin-top: 15px; }
#dcrghryx_calculator_wrapper #dcrghryx_printReportBtn:hover { background: var(--bg); }

#dcrghryx_calculator_wrapper .dcrghryx_results-placeholder { 
    height: 100%; min-height: 400px; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; text-align: center; color: #64748b; 
}
#dcrghryx_calculator_wrapper .dcrghryx_results-placeholder svg { width: 64px; height: 64px; margin-bottom: 1.5rem; opacity: 0.4; }

#dcrghryx_calculator_wrapper .dcrghryx_result-card {
    background: var(--card); padding: 24px; border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); margin-bottom: 20px;
    border-left: 5px solid var(--primary); animation: slideDown 0.4s ease-out;
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

#dcrghryx_calculator_wrapper .dcrghryx_result-header { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; margin-bottom: 8px; font-weight: 700; }
#dcrghryx_calculator_wrapper .dcrghryx_result-value { font-size: 2.2rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
#dcrghryx_calculator_wrapper .dcrghryx_result-subtext { font-size: 0.95rem; color: #64748b; margin-top: 8px; }

#dcrghryx_calculator_wrapper .dcrghryx_chart-container { margin-top: 25px; }
#dcrghryx_calculator_wrapper .dcrghryx_bar-wrapper { margin-bottom: 15px; }
#dcrghryx_calculator_wrapper .dcrghryx_bar-label { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; font-weight: 600; }
#dcrghryx_calculator_wrapper .dcrghryx_progress-bg { background: #E2E8F0; height: 16px; border-radius: 8px; overflow: hidden; }
#dcrghryx_calculator_wrapper .dcrghryx_progress-fill { height: 100%; border-radius: 8px; transition: width 1s ease-out; }
#dcrghryx_calculator_wrapper .dcrghryx_fill-primary { background-color: var(--primary); }
#dcrghryx_calculator_wrapper .dcrghryx_fill-warning { background-color: var(--warning); }
#dcrghryx_calculator_wrapper .dcrghryx_fill-error { background-color: var(--error); }

#dcrghryx_calculator_wrapper .dcrghryx_breakdown-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.95rem; }
#dcrghryx_calculator_wrapper .dcrghryx_breakdown-table td { padding: 12px 0; border-bottom: 1px solid #eee; }
#dcrghryx_calculator_wrapper .dcrghryx_breakdown-table td:last-child { text-align: right; font-weight: 600; color: var(--text); }
#dcrghryx_calculator_wrapper .dcrghryx_breakdown-table tr:last-child td { border-bottom: none; }

#dcrghryx_calculator_wrapper .dcrghryx_disclaimer { font-size: 0.8rem; color: #64748b; background: #f1f5f9; padding: 15px; border-radius: 8px; margin-top: 20px; line-height: 1.5; border: 1px solid #e2e8f0; }

/* Print-only footer hidden on screen */
#dcrghryx_calculator_wrapper .dcrghryx_print-only-disclaimer { display: none; }

@media (max-width: 900px) { 
    #dcrghryx_calculator_wrapper .dcrghryx_calculator-container { margin: 0; border-radius: 0; }
    #dcrghryx_calculator_wrapper .dcrghryx_calculator-grid { grid-template-columns: 1fr; } 
    #dcrghryx_calculator_wrapper .dcrghryx_input-section { border-right: none; border-bottom: 1px solid #e2e8f0; }
    #dcrghryx_calculator_wrapper { padding: 0; }
    #dcrghryx_calculator_wrapper .dcrghryx_result-value { font-size: 2rem; }
    #dcrghryx_calculator_wrapper .dcrghryx_action-buttons { flex-direction: column; }
}

/* Fix for Mobile Breakdown Readability */
@media (max-width: 600px) {
    #dcrghryx_calculator_wrapper .dcrghryx_form-grid { grid-template-columns: 1fr; }
    #dcrghryx_calculator_wrapper .dcrghryx_date-grid { gap: 8px; }
    #dcrghryx_calculator_wrapper .dcrghryx_input-section, 
    #dcrghryx_calculator_wrapper .dcrghryx_results-section { padding: 20px; }
    
    #dcrghryx_calculator_wrapper .dcrghryx_breakdown-table { font-size: 0.8rem; }
    #dcrghryx_calculator_wrapper .dcrghryx_breakdown-table td { padding: 8px 0; }
}

/* --- OPTIMIZED SINGLE-PAGE PRINT STYLES --- */
@media print {
    @page {
        size: A4;
        margin: 0.8cm; /* Tighter margins to fit more content */
    }
    
    /* NUCLEAR OPTION: Crush all non-wrapper elements to 0x0 size */
    /* This prevents hidden elements from creating blank pages */
    body * {
        visibility: hidden;
        height: 0;
        overflow: hidden;
    }

    /* Restore the wrapper and its children */
    #dcrghryx_calculator_wrapper, 
    #dcrghryx_calculator_wrapper * {
        visibility: visible;
        height: auto;
        overflow: visible;
    }

    #dcrghryx_calculator_wrapper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white !important;
        font-family: 'Times New Roman', serif;
        z-index: 99999;
    }
    
    #dcrghryx_calculator_wrapper .dcrghryx_calculator-container { 
        box-shadow: none; 
        border: none; 
        margin: 0; 
        width: 100%;
        max-width: 100%;
    }

    /* Hide interactive UI */
    #dcrghryx_calculator_wrapper .dcrghryx_input-section, 
    #dcrghryx_calculator_wrapper .dcrghryx_results-placeholder, 
    #dcrghryx_calculator_wrapper .dcrghryx_action-buttons, 
    #dcrghryx_calculator_wrapper button,
    #dcrghryx_calculator_wrapper #dcrghryx_printReportBtn { 
        display: none !important; 
    }

    /* COMPACT LAYOUT ENGINE */
    #dcrghryx_calculator_wrapper .dcrghryx_results-section { 
        display: block !important; 
        padding: 0;
    }

    #dcrghryx_calculator_wrapper .dcrghryx_section-title {
        font-size: 16pt; /* Smaller title */
        text-align: center;
        border-bottom: 2px solid #000;
        color: #000;
        margin-bottom: 15px; /* Reduced margin */
        padding-bottom: 5px;
    }

    /* Compact Cards */
    #dcrghryx_calculator_wrapper .dcrghryx_result-card {
        break-inside: avoid;
        border: 1px solid #ccc;
        border-left: 5px solid #000 !important; 
        box-shadow: none;
        margin-bottom: 10px; /* Reduced margin */
        padding: 12px 15px; /* Reduced padding */
        animation: none;
        background: white;
    }
    
    #dcrghryx_calculator_wrapper .dcrghryx_result-header { 
        color: #333; 
        margin-bottom: 4px;
        font-size: 9pt;
    }
    
    #dcrghryx_calculator_wrapper .dcrghryx_result-value { 
        color: #000; 
        font-size: 18pt; /* Reduced from 24pt */
        line-height: 1.2;
    }

    #dcrghryx_calculator_wrapper .dcrghryx_result-subtext {
        font-size: 10pt;
    }
    
    /* Compact Table */
    #dcrghryx_calculator_wrapper .dcrghryx_breakdown-table {
        margin-top: 5px;
        font-size: 10pt;
    }

    #dcrghryx_calculator_wrapper .dcrghryx_breakdown-table td {
        padding: 5px 0; /* Tight rows */
        border-bottom: 1px dotted #ccc;
    }

    /* Chart */
    #dcrghryx_calculator_wrapper .dcrghryx_chart-container {
        margin-top: 15px;
    }
    #dcrghryx_calculator_wrapper .dcrghryx_progress-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #dcrghryx_calculator_wrapper .dcrghryx_progress-bg { border: 1px solid #ccc; height: 12px; }

    /* Footer Disclaimer */
    #dcrghryx_calculator_wrapper .dcrghryx_print-only-disclaimer {
        display: block !important;
        margin-top: 20px;
        padding-top: 10px;
        border-top: 1px solid #000;
        font-size: 8pt; /* Smaller disclaimer font */
        text-align: justify;
        color: #000;
        page-break-inside: avoid;
    }
    
    #dcrghryx_calculator_wrapper .dcrghryx_disclaimer { border: none; background: none; padding: 0; color: #000; font-size: 9pt; }
}
