/* --- 1. VARIABLES & THEME --- */
    #hplxx_calculator_wrapper {
      --primary-color: #0B1F51;    /* Navy */
      --text-color: #2B3445;       /* Body Text */
      --bg-color: #F8FAFC;
      --white: #FFFFFF;
      --border-color: #E2E8F0;
      --danger-color: #EF4444;     /* Red */
      --info-bg: #EFF6FF;
      --info-text: #1E40AF;
      --warning-bg: #FFFBEB;
      --warning-text: #B45309;
      --success-bg: #ECFDF5;
      --success-text: #065F46;
    }

    #hplxx_calculator_wrapper * { box-sizing: border-box; margin: 0; padding: 0; }

    #hplxx_calculator_wrapper {
      font-family: 'Inter', sans-serif;
      background-color: var(--bg-color);
      color: var(--text-color);
      line-height: 1.6;
      padding: 20px;
      -webkit-font-smoothing: antialiased;
    }

    /* --- 2. LAYOUT --- */
    #hplxx_calculator_wrapper .hplxx_calculator-container {
      max-width: 1100px;
      margin: 0 auto;
      background: var(--white);
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.07);
      border: 1px solid var(--border-color);
      overflow: hidden;
    }

    #hplxx_calculator_wrapper .hplxx_calculator-grid {
      display: grid;
      grid-template-columns: 1fr 1.1fr; /* Split View Desktop */
      min-height: 600px;
    }

    #hplxx_calculator_wrapper .hplxx_input-section, #hplxx_calculator_wrapper .hplxx_results-section { padding: 35px; }

    #hplxx_calculator_wrapper .hplxx_input-section {
      background-color: #ffffff;
      border-right: 1px solid var(--border-color);
      display: flex;
      flex-direction: column;
    }

    #hplxx_calculator_wrapper .hplxx_results-section {
      background-color: #fafbfd;
      display: flex;
      flex-direction: column;
      min-width: 0;
      position: relative;
    }
    
    #hplxx_calculator_wrapper .hplxx_section-title {
      color: var(--primary-color);
      font-size: 18px;
      font-weight: 800;
      margin-bottom: 20px;
      padding-bottom: 10px;
      border-bottom: 2px solid var(--border-color);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    /* --- 3. INPUTS & CONTROLS --- */
    
    #hplxx_calculator_wrapper .hplxx_type-selector {
        display: flex;
        gap: 10px;
        margin-bottom: 25px;
        background: #F1F5F9;
        padding: 5px;
        border-radius: 8px;
    }
    
    #hplxx_calculator_wrapper .hplxx_type-btn {
        flex: 1;
        padding: 14px 10px;
        border: none;
        background: transparent;
        color: #64748B;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        border-radius: 6px;
        transition: all 0.2s;
        text-align: center;
    }
    
    #hplxx_calculator_wrapper .hplxx_type-btn.hplxx_active {
        background: var(--white);
        color: var(--primary-color);
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        font-weight: 700;
        border: 1px solid var(--border-color);
    }
    
    /* Accessibility Focus Styles */
    #hplxx_calculator_wrapper .hplxx_type-btn:focus-visible, 
    #hplxx_calculator_wrapper .hplxx_input-field:focus-visible,
    #hplxx_calculator_wrapper button:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }

    #hplxx_calculator_wrapper .hplxx_input-group { margin-bottom: 20px; position: relative; }
    
    #hplxx_calculator_wrapper .hplxx_input-group label {
      display: block; 
      margin-bottom: 8px;
      font-weight: 700; 
      color: var(--primary-color);
      font-size: 13px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    #hplxx_calculator_wrapper .hplxx_input-helper {
        display: block;
        font-size: 11px;
        color: #64748B;
        margin-top: -4px;
        margin-bottom: 8px;
        font-style: italic;
    }

    #hplxx_calculator_wrapper .hplxx_input-wrapper { position: relative; width: 100%; }

    #hplxx_calculator_wrapper .hplxx_input-field {
        width: 100%;
        padding: 16px; 
        border: 1px solid var(--border-color);
        border-radius: 8px;
        font-size: 16px; 
        background-color: var(--white);
        font-family: 'Inter', sans-serif;
        color: var(--primary-color);
        font-weight: 500;
        transition: border-color 0.2s;
    }

    #hplxx_calculator_wrapper .hplxx_input-field:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(11, 31, 81, 0.1);
    }

    #hplxx_calculator_wrapper .hplxx_input-field.hplxx_error {
        border-color: var(--danger-color);
        background-color: #FEF2F2;
    }

    #hplxx_calculator_wrapper .hplxx_error-msg {
        color: var(--danger-color);
        font-size: 12px;
        margin-top: 6px;
        font-weight: 600;
        display: none; 
        animation: fadeIn 0.3s;
    }
    
    #hplxx_calculator_wrapper .hplxx_action-buttons { 
        margin-top: auto; 
        padding-top: 20px; 
        display: grid; 
        gap: 12px; 
    }
    
    #hplxx_calculator_wrapper button.hplxx_primary-btn {
      background-color: var(--primary-color); 
      color: white; 
      border: none; 
      padding: 18px; 
      border-radius: 8px;
      font-weight: 700; 
      font-size: 16px; 
      cursor: pointer; 
      transition: background-color 0.2s;
      width: 100%;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    
    #hplxx_calculator_wrapper button.hplxx_primary-btn:hover { background-color: #1a3a7a; }
    
    #hplxx_calculator_wrapper button.hplxx_secondary-btn {
      background-color: white; 
      color: var(--text-color); 
      border: 1px solid var(--border-color); 
      padding: 14px; 
      border-radius: 8px;
      font-weight: 600; 
      cursor: pointer;
      width: 100%;
    }

    /* --- 4. RESULTS UI --- */
    #hplxx_calculator_wrapper .hplxx_hero-card {
        background-color: var(--white);
        border-radius: 8px;
        border: 1px solid var(--border-color);
        border-left: 6px solid var(--primary-color);
        margin-bottom: 25px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
        padding: 25px;
        text-align: center;
        display: none; 
        transform: translateY(10px);
        transition: opacity 0.4s ease, transform 0.4s ease;
        opacity: 0;
    }
    
    #hplxx_calculator_wrapper .hplxx_hero-card.hplxx_visible { 
        display: block; 
        opacity: 1; 
        transform: translateY(0); 
    }

    #hplxx_calculator_wrapper .hplxx_hero-label { font-size: 13px; color: var(--primary-color); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
    #hplxx_calculator_wrapper .hplxx_hero-value { font-size: 42px; font-weight: 800; color: var(--primary-color); margin-bottom: 5px; line-height: 1; }
    #hplxx_calculator_wrapper .hplxx_hero-subtext { font-size: 14px; color: #64748B; font-weight: 500; }

    #hplxx_calculator_wrapper .hplxx_breakdown-box {
        background: var(--white);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 20px;
        display: none; 
    }
    
    #hplxx_calculator_wrapper .hplxx_breakdown-header {
        background: #F1F5F9;
        padding: 12px 20px;
        font-size: 13px;
        font-weight: 700;
        color: var(--primary-color);
        text-transform: uppercase;
        border-bottom: 1px solid var(--border-color);
    }

    #hplxx_calculator_wrapper .hplxx_result-row {
        display: flex;
        justify-content: space-between;
        padding: 12px 20px;
        border-bottom: 1px solid #F1F5F9;
        font-size: 14px;
        color: #334155;
    }
    #hplxx_calculator_wrapper .hplxx_result-row:last-child { border-bottom: none; }
    #hplxx_calculator_wrapper .hplxx_result-val { font-weight: 700; color: var(--primary-color); }
    #hplxx_calculator_wrapper .hplxx_result-val.hplxx_negative { color: var(--danger-color); }
    #hplxx_calculator_wrapper .hplxx_text-sm { font-size: 12px; color: #64748B; font-weight: 400; }
    
    #hplxx_calculator_wrapper .hplxx_rule-note {
        background-color: var(--info-bg); color: var(--info-text); padding: 12px; border-radius: 6px; font-size: 13px; margin-top: 20px; border-left: 3px solid #3B82F6; line-height: 1.5; display: none;
    }

    #hplxx_calculator_wrapper .hplxx_teaching-warning {
        background-color: var(--warning-bg);
        color: var(--warning-text);
        padding: 20px;
        border-radius: 8px;
        border: 1px solid #FCD34D;
        text-align: center;
        margin-top: 20px;
        display: none;
    }

    #hplxx_calculator_wrapper .hplxx_negative-warning {
        background-color: var(--warning-bg);
        color: var(--warning-text);
        padding: 15px;
        border-radius: 8px;
        border-left: 4px solid var(--warning-text);
        font-size: 13px;
        margin-top: 15px;
        display: none;
        line-height: 1.5;
    }

    #hplxx_calculator_wrapper .hplxx_lnd-warning {
        background-color: #FEF2F2;
        color: #B91C1C;
        padding: 15px;
        border-radius: 8px;
        border: 1px solid #FCA5A5;
        font-size: 13px;
        margin-top: 15px;
        display: none;
        line-height: 1.5;
    }

    #hplxx_calculator_wrapper .hplxx_info-warning {
        background-color: var(--info-bg);
        color: var(--info-text);
        padding: 15px;
        border-radius: 8px;
        border-left: 4px solid var(--info-text);
        font-size: 13px;
        margin-top: 15px;
        display: none;
        line-height: 1.5;
    }
    
    /* Global Error Banner */
    #hplxx_calculator_wrapper #hplxx_global_error {
        position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
        background: #DC2626; color: white; padding: 12px 24px; border-radius: 30px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2); z-index: 1000; font-weight: 600;
        display: none; animation: slideDown 0.3s;
    }

    #hplxx_calculator_wrapper .hplxx_disclaimer-box {
        margin-top: 40px;
        border-top: 2px dashed #E2E8F0;
        padding-top: 20px;
        font-size: 11px;
        color: #64748B;
        text-align: justify;
        display: none;
    }

    @keyframes fadeIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
    @keyframes slideDown { from { top: -50px; } to { top: 20px; } }

    /* Reduced Motion */
    @media (prefers-reduced-motion: reduce) {
        #hplxx_calculator_wrapper * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    }

    /* Responsive */
    @media (max-width: 900px) {
      #hplxx_calculator_wrapper .hplxx_calculator-grid { grid-template-columns: 1fr; }
      #hplxx_calculator_wrapper .hplxx_input-section { border-right: none; border-bottom: 1px solid var(--border-color); padding: 25px; }
      #hplxx_calculator_wrapper .hplxx_results-section { padding: 25px; }
    }
    
    /* PRINT STYLES - FIXED TO HIDE WORDPRESS HEADER/FOOTER */
    @media print {
        /* 1. Hide everything globally on the page */
        body, body * {
            visibility: hidden;
        }

        /* 2. Reset visibility specifically for the calculator wrapper */
        #hplxx_calculator_wrapper, 
        #hplxx_calculator_wrapper * {
            visibility: visible;
        }

        /* 3. Position the calculator wrapper at the absolute top-left of the paper */
        #hplxx_calculator_wrapper {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            margin: 0;
            padding: 0;
            background: white;
            z-index: 9999;
        }

        /* 4. Formatting adjustments for the calculator itself during print */
        #hplxx_calculator_wrapper .hplxx_calculator-container { box-shadow: none; border: none; max-width: 100%; margin: 0; }
        
        /* Hide input sections during print */
        #hplxx_calculator_wrapper .hplxx_input-section, 
        #hplxx_calculator_wrapper .hplxx_type-selector, 
        #hplxx_calculator_wrapper .hplxx_section-title, 
        #hplxx_calculator_wrapper .hplxx_input-group, 
        #hplxx_calculator_wrapper .hplxx_action-buttons, 
        #hplxx_calculator_wrapper .hplxx_teaching-warning { 
            display: none !important; 
        }

        /* Ensure results are displayed */
        #hplxx_calculator_wrapper .hplxx_calculator-grid { display: block; }
        #hplxx_calculator_wrapper .hplxx_results-section { width: 100%; padding: 20px; display: block !important; }
        
        /* Ensure disclaimer and results are visible */
        #hplxx_calculator_wrapper .hplxx_disclaimer-box { display: block; border-top: 1px solid #000; color: #000; }
        #hplxx_calculator_wrapper .hplxx_hero-card, 
        #hplxx_calculator_wrapper .hplxx_breakdown-box { 
            border: 1px solid #000; 
            box-shadow: none; 
            page-break-inside: avoid; 
            margin-bottom: 20px; 
            display: block !important; 
            opacity: 1 !important; 
            transform: none !important;
        }
        #hplxx_calculator_wrapper .hplxx_breakdown-header { background: #eee; -webkit-print-color-adjust: exact; }
    }