/* === DESIGN TOKENS === */
#hbagxx_calculator_wrapper {
    --primary: #0B1F51;      /* Navy */
    --text: #2B3445;         /* Body Text */
    --accent: #0B1F51;       /* Button/Header */
    --accent-hover: #AFC8FF; /* Hover State */
    
    --bg: #F8FAFC;
    --border: #cbd5e1;       
    --card: #FFFFFF;
    --success: #10B981;
    --warning: #EF4444;      
    --hba-color: #10B981;    
    --radius: 6px;           
}

/* --- Reset & Base --- */
#hbagxx_calculator_wrapper * { box-sizing: border-box; margin: 0; padding: 0; }
#hbagxx_calculator_wrapper { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.5; 
    padding: 15px; 
    min-height: 100vh;
    overflow-x: hidden; 
}

/* --- Layout Container --- */
#hbagxx_calculator_wrapper .hbagxx_calculator-container { 
    max-width: 1000px; 
    margin: 1rem auto; 
    background: var(--card); 
    border-radius: 10px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    border: 1px solid #e2e8f0; 
    position: relative;
}

/* Grid: Input Left (1fr), Results Right (1.1fr) */
#hbagxx_calculator_wrapper .hbagxx_calculator-grid { display: grid; grid-template-columns: 1fr 1.1fr; } 

#hbagxx_calculator_wrapper .hbagxx_input-section, 
#hbagxx_calculator_wrapper .hbagxx_results-section, 
#hbagxx_calculator_wrapper .hbagxx_results-placeholder { padding: 20px; } 

#hbagxx_calculator_wrapper .hbagxx_input-section { 
    border-right: 1px solid #e2e8f0; 
    background: var(--card); 
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}
#hbagxx_calculator_wrapper .hbagxx_results-section, 
#hbagxx_calculator_wrapper .hbagxx_results-placeholder { 
    background: var(--bg); 
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

#hbagxx_calculator_wrapper .hbagxx_section-title { 
    color: var(--primary); 
    font-size: 1.15rem; 
    font-weight: 700; 
    margin-bottom: 20px; 
    padding-bottom: 10px; 
    border-bottom: 2px solid #e2e8f0; 
}

/* --- Form Elements --- */
#hbagxx_calculator_wrapper .hbagxx_form-grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 15px; 
}

#hbagxx_calculator_wrapper .hbagxx_input-group { position: relative; display: flex; flex-direction: column; }

#hbagxx_calculator_wrapper .hbagxx_input-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 600; 
    color: #1e293b; 
    font-size: 0.8rem; 
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

#hbagxx_calculator_wrapper input[type="text"], 
#hbagxx_calculator_wrapper input[type="number"], 
#hbagxx_calculator_wrapper select {
    width: 100%; 
    padding: 10px 12px; 
    border: 1.5px solid var(--border); 
    border-radius: var(--radius);
    font-size: 14px; 
    font-weight: 500;
    background: #ffffff; 
    color: #334155; 
    transition: all 0.2s; 
    font-family: inherit;
}

#hbagxx_calculator_wrapper input:focus, 
#hbagxx_calculator_wrapper select:focus { 
    outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px #eff6ff; 
}

#hbagxx_calculator_wrapper .hbagxx_select-wrapper { position: relative; }
#hbagxx_calculator_wrapper .hbagxx_select-wrapper::after {
    content: "▼"; font-size: 0.7rem; color: #475569;
    position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none;
}
#hbagxx_calculator_wrapper select { 
    appearance: none; -webkit-appearance: none; padding-right: 30px; 
    text-overflow: ellipsis; white-space: nowrap; overflow: hidden; 
}

#hbagxx_calculator_wrapper .hbagxx_input-desc { font-size: 0.75rem; color: #64748b; margin-top: 4px; display: block; font-weight: 400; line-height: 1.3; }
#hbagxx_calculator_wrapper .hbagxx_hidden { display: none !important; }

#hbagxx_calculator_wrapper .hbagxx_input-group.hbagxx_error input, 
#hbagxx_calculator_wrapper .hbagxx_input-group.hbagxx_error select { border-color: var(--warning); background-color: #fef2f2; }
#hbagxx_calculator_wrapper .hbagxx_inline-error { color: var(--warning); font-size: 0.75rem; margin-top: 4px; display: none; font-weight: 600; }
#hbagxx_calculator_wrapper .hbagxx_input-group.hbagxx_error .hbagxx_inline-error { display: block; }

#hbagxx_calculator_wrapper .hbagxx_penal-warning { color: #b91c1c; font-size: 0.75rem; margin-top: 4px; display: none; font-weight: 600; }
#hbagxx_calculator_wrapper .hbagxx_info-tooltip { cursor: help; color: #64748b; font-size: 1rem; margin-left: 4px; position: relative; display: inline-block; vertical-align: middle; }
#hbagxx_calculator_wrapper .hbagxx_info-tooltip:hover { color: var(--primary); }
#hbagxx_calculator_wrapper .hbagxx_capacity-warning { font-size: 0.7rem; color: #b45309; text-transform: none; text-align: left; margin-top: 4px; font-weight: 600; display: none; line-height: 1.2; }

/* --- Buttons --- */
#hbagxx_calculator_wrapper .hbagxx_action-buttons { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
#hbagxx_calculator_wrapper button {
    padding: 12px 20px; 
    border-radius: var(--radius); cursor: pointer; 
    font-size: 15px; 
    font-weight: 600; width: 100%; border: none; 
    transition: 0.2s; text-transform: uppercase; letter-spacing: 0.5px;
}

#hbagxx_calculator_wrapper #hbagxx_calculateBtn { background: var(--accent); color: white; box-shadow: 0 2px 4px rgba(11, 31, 81, 0.15); }
#hbagxx_calculator_wrapper #hbagxx_calculateBtn:hover { background: var(--accent-hover); color: var(--primary); }

#hbagxx_calculator_wrapper #hbagxx_resetBtn { background: #f8fafc; color: #475569; border: 1.5px solid #cbd5e1; }
#hbagxx_calculator_wrapper #hbagxx_resetBtn:hover { background: #f1f5f9; color: #0f172a; border-color: #94a3b8; }

#hbagxx_calculator_wrapper #hbagxx_printReportBtn { background: var(--card); border: 1.5px solid var(--accent); color: var(--accent); margin-top: 15px; }
#hbagxx_calculator_wrapper #hbagxx_printReportBtn:hover { background: var(--bg); }

/* --- Results Area --- */
#hbagxx_calculator_wrapper .hbagxx_results-placeholder { 
    height: 100%; min-height: 300px; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; text-align: center; color: #64748b; 
}
#hbagxx_calculator_wrapper .hbagxx_results-placeholder svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.3; }
#hbagxx_calculator_wrapper .hbagxx_results-placeholder h3 { font-size: 1.1em; font-weight: bold; margin-bottom: 0.5em; color: var(--primary); }
#hbagxx_calculator_wrapper .hbagxx_results-placeholder p { font-size: 0.85rem; max-width: 80%; }

#hbagxx_calculator_wrapper .hbagxx_result-card {
    background: var(--card); padding: 16px; border-radius: 8px; 
    box-shadow: 0 1px 4px rgba(0,0,0,0.04); margin-bottom: 16px;
    border-left: 4px solid var(--primary); animation: slideDown 0.4s ease-out;
    transition: all 0.3s ease;
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

#hbagxx_calculator_wrapper .hbagxx_result-header { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; margin-bottom: 10px; font-weight: 700; }

#hbagxx_calculator_wrapper .hbagxx_sub-heading {
    grid-column: 1 / -1;
    color: var(--primary);
    font-size: 1rem; 
    font-weight: 700;
    margin-top: 10px;
    margin-bottom: 0;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#hbagxx_calculator_wrapper .hbagxx_burden-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}
#hbagxx_calculator_wrapper .hbagxx_burden-side {
    padding: 15px 10px; 
    border-radius: 8px;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
#hbagxx_calculator_wrapper .hbagxx_burden-hba { background: #f0fdf4; border: 1px solid #bbf7d0; }
#hbagxx_calculator_wrapper .hbagxx_burden-bank { background: #fef2f2; border: 1px solid #fecaca; }
#hbagxx_calculator_wrapper .hbagxx_vs-badge {
    background: #f1f5f9; color: #64748b; font-weight: 800;
    border-radius: 50%; width: 32px; height: 32px; 
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 2px solid #fff;
}

#hbagxx_calculator_wrapper .hbagxx_pro-tip-box {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #1e3a8a;
    line-height: 1.4;
    animation: slideDown 0.5s ease-out;
}

#hbagxx_calculator_wrapper .hbagxx_savings-card { border-left-color: var(--success); background-color: #f0fdf4; }

#hbagxx_calculator_wrapper .hbagxx_chart-container { margin-top: 15px; }
#hbagxx_calculator_wrapper .hbagxx_bar-wrapper { margin-bottom: 12px; }
#hbagxx_calculator_wrapper .hbagxx_bar-label { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 6px; font-weight: 600; color: var(--text); }
#hbagxx_calculator_wrapper .hbagxx_progress-bg { background: #E2E8F0; height: 18px; border-radius: 9px; overflow: hidden; position: relative; }
#hbagxx_calculator_wrapper .hbagxx_progress-fill { height: 100%; border-radius: 9px; transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; padding: 0 8px; color: white; font-size: 0.7rem; font-weight: bold; white-space: nowrap;}

#hbagxx_calculator_wrapper .hbagxx_fill-bank { background-color: var(--warning); width: 0%; }
#hbagxx_calculator_wrapper .hbagxx_fill-hba { background-color: var(--hba-color); width: 0%; }

#hbagxx_calculator_wrapper .hbagxx_breakdown-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; }
#hbagxx_calculator_wrapper .hbagxx_breakdown-table th { text-align: left; padding: 10px 0; border-bottom: 2px solid #e2e8f0; color: #64748b; font-size: 0.8rem; text-transform: uppercase; }
#hbagxx_calculator_wrapper .hbagxx_breakdown-table td { padding: 10px 0; border-bottom: 1px solid #f1f5f9; vertical-align: top;}
#hbagxx_calculator_wrapper .hbagxx_breakdown-table td:last-child, 
#hbagxx_calculator_wrapper .hbagxx_breakdown-table th:last-child { text-align: right; font-weight: 600; color: var(--text); }
#hbagxx_calculator_wrapper .hbagxx_breakdown-table tr:last-child td { border-bottom: none; }
#hbagxx_calculator_wrapper .hbagxx_total-row td { font-weight: 700; font-size: 0.9rem; border-top: 2px solid #e2e8f0; padding-top: 12px; }
#hbagxx_calculator_wrapper .hbagxx_grand-total td { font-size: 1rem; color: var(--primary); padding-top: 12px; border-top: 2px solid #e2e8f0; }

#hbagxx_calculator_wrapper .hbagxx_disclaimer { font-size: 0.8rem; color: #475569; background: #f8fafc; padding: 15px; border-radius: 6px; margin-top: 16px; line-height: 1.5; border: 1px solid #e2e8f0; }
#hbagxx_calculator_wrapper .hbagxx_disclaimer h4 { color: var(--primary); margin-bottom: 6px; font-size: 0.85rem; }
#hbagxx_calculator_wrapper .hbagxx_disclaimer ul { padding-left: 20px; margin-bottom: 10px; }
#hbagxx_calculator_wrapper .hbagxx_disclaimer ul:last-child { margin-bottom: 0; }
#hbagxx_calculator_wrapper .hbagxx_disclaimer li { margin-bottom: 4px; }

/* --- Responsive Adjustments --- */
@media (min-width: 768px) {
    #hbagxx_calculator_wrapper .hbagxx_form-grid { grid-template-columns: 1fr 1fr; } 
    #hbagxx_calculator_wrapper .hbagxx_full-width { grid-column: 1 / -1; }
    #hbagxx_calculator_wrapper .hbagxx_action-buttons { flex-direction: row; }
    #hbagxx_calculator_wrapper #hbagxx_calculateBtn { flex: 2; }
    #hbagxx_calculator_wrapper #hbagxx_resetBtn { flex: 1; }
}

@media (max-width: 899px) { 
    #hbagxx_calculator_wrapper .hbagxx_calculator-container { 
        margin: 0; 
        border-radius: 0; 
        border: none; 
        box-shadow: none;
    }
    #hbagxx_calculator_wrapper .hbagxx_burden-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    #hbagxx_calculator_wrapper .hbagxx_vs-badge {
        margin: 0 auto;
        transform: rotate(90deg);
    }
    #hbagxx_calculator_wrapper .hbagxx_calculator-grid { 
        display: flex; 
        flex-direction: column; 
    } 
    #hbagxx_calculator_wrapper .hbagxx_input-section { 
        border-right: none; 
        border-bottom: 2px solid #e2e8f0; 
        border-radius: 0;
        padding: 20px 15px;
    }
    #hbagxx_calculator_wrapper .hbagxx_results-section, 
    #hbagxx_calculator_wrapper .hbagxx_results-placeholder {
        border-radius: 0;
        padding: 20px 15px;
        min-height: auto;
    }
    #hbagxx_calculator_wrapper { padding: 0; background: var(--card); } 
}

@media (max-width: 480px) {
    #hbagxx_calculator_wrapper .hbagxx_breakdown-table th, 
    #hbagxx_calculator_wrapper .hbagxx_breakdown-table td { padding: 8px 0; font-size: 0.75rem; word-break: break-word; }
    #hbagxx_calculator_wrapper .hbagxx_grand-total td { font-size: 0.9rem; }
    #hbagxx_calculator_wrapper .hbagxx_result-card { padding: 12px; margin-bottom: 12px; overflow: hidden; }
    #hbagxx_calculator_wrapper .hbagxx_bar-label { font-size: 0.75rem; }
    #hbagxx_calculator_wrapper #hbagxx_compHbaEmi, 
    #hbagxx_calculator_wrapper #hbagxx_compBankEmi { font-size: 1.15rem !important; }
    #hbagxx_calculator_wrapper .hbagxx_burden-side { padding: 12px 8px; }
    #hbagxx_calculator_wrapper .hbagxx_action-buttons button { padding: 14px 20px; font-size: 14px; }
    #hbagxx_calculator_wrapper .hbagxx_section-title { font-size: 1.05rem; }
    #hbagxx_calculator_wrapper .hbagxx_sub-heading { font-size: 0.9rem; }
}

/* Base Print Rules - Though the JS handles real isolation, keeping this for redundancy */
@media print {
    body { background: white; padding: 0; font-size: 10pt; }
    #hbagxx_calculator_wrapper .hbagxx_calculator-container { box-shadow: none; border: none; margin: 0; }
    #hbagxx_calculator_wrapper .hbagxx_input-section, 
    #hbagxx_calculator_wrapper .hbagxx_results-placeholder, 
    #hbagxx_calculator_wrapper button, 
    #hbagxx_calculator_wrapper .hbagxx_action-buttons, 
    #hbagxx_calculator_wrapper .hbagxx_info-tooltip { display: none !important; }
    #hbagxx_calculator_wrapper .hbagxx_results-section { display: block !important; padding: 0 !important; background: white; }
    #hbagxx_calculator_wrapper .hbagxx_result-card, 
    #hbagxx_calculator_wrapper .hbagxx_pro-tip-box { border: 1px solid #e2e8f0; box-shadow: none; break-inside: avoid; }
    #hbagxx_calculator_wrapper .hbagxx_progress-bg { background: #f1f5f9 !important; border: 1px solid #cbd5e1; }
    #hbagxx_calculator_wrapper .hbagxx_fill-bank { background-color: #EF4444 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    #hbagxx_calculator_wrapper .hbagxx_fill-hba { background-color: #10B981 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}