/* ======================================================================
   1. BASE & TAB MODULE CSS (Unified & Explicitly Parent Scoped)
   ====================================================================== */
.calculator-module * { 
    box-sizing: border-box; 
}

.calculator-module {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: #2C3E50;
    line-height: 1.6;
    max-width: 1200px;
    margin: 0 auto;
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;

    /* Design tokens */
    --brand-blue: #003366;
    --accent-teal: #00B2A9;
    --text-dark: #2C3E50;
    --light-bg: #F5F7FA;
    --border-light: #E5E7EB;
    --rounded-3xl: 1.5rem;
    --rounded-2xl: 1rem;
}

/* Tab navigation */
.calculator-module .tab-nav {
    display: flex;
    background: #F5F7FA;
    border-bottom: 1px solid #E5E7EB;
    flex-wrap: wrap;
}

.calculator-module .tab-btn {
    flex: 1;
    padding: 18px 20px;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    color: #2C3E50;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calculator-module .tab-btn:hover { 
    background: #EBF0F5; 
}

.calculator-module .tab-btn.active {
    background: #FFFFFF;
    color: #003366;
    border-bottom: 4px solid #00B2A9;
}

.calculator-module .tab-content {
    padding: 30px 20px;
    background: #FFFFFF;
    min-height: 400px;
}

.calculator-module .tab-pane { 
    display: none; 
}

.calculator-module .tab-pane.active { 
    display: block; 
}

/* Global Button Scoped Layout Styles */
.calculator-module .results-buttons {
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.calculator-module .primary-btn, 
.calculator-module .grey-btn, 
.calculator-module .teal-btn, 
.calculator-module .tertiary-btn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: none;
    transition: all 0.3s ease;
    text-align: center;
}

.calculator-module .primary-btn:hover, 
.calculator-module .grey-btn:hover, 
.calculator-module .teal-btn:hover, 
.calculator-module .tertiary-btn:hover {
    transform: translateY(-2px);
}

.calculator-module .primary-btn { background-color: #003366; color: #FFFFFF; }
.calculator-module .grey-btn { background-color: #6B7280; color: #FFFFFF; }
.calculator-module .teal-btn { background-color: #00B2A9; color: #FFFFFF; }
.calculator-module .tertiary-btn { background-color: #D4AF37; color: #003366; }

@media (max-width: 640px) {
    .calculator-module .results-buttons button { 
        flex: 1 1 100%; 
    }
}

/* ======================================================================
   2. TABS 1 & 2: COMPARISON TABLES CSS (Parent Scoped Container)
   ====================================================================== */
.calculator-module .comparison-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 51, 102, 0.08);
    overflow: hidden;
}

.calculator-module .comparison-intro {
    padding: 2.5rem 2rem 0.5rem 2rem;
    background: #FFFFFF;
    text-align: left;
}

.calculator-module .comparison-intro h2 {
    font-family: 'Satoshi', sans-serif;
    font-weight: 500;
    font-size: 1.85rem;
    color: #003366;
    margin: 0 0 0.75rem 0;
    line-height: 1.25;
}

.calculator-module .comparison-intro p {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 1.05rem;
    color: #2C3E50;
    margin: 0;
    line-height: 1.6;
}

.calculator-module .dropdown-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: #FFFFFF;
    padding: 1.5rem 2rem;
    border-bottom: none;
}

.calculator-module .select-label {
    font-weight: 600;
    color: #003366;
    white-space: nowrap;
}

.calculator-module .brand-select {
    flex: 1;
    min-width: 280px;
    padding: 14px 3.5rem 14px 18px;
    font-size: 1.1rem;
    border: 2px solid #003366;
    border-radius: 8px;
    background: #FFFFFF;
    color: #2C3E50;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23003366' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='1 1 6 7 11 1'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 12px;
}

.calculator-module .brand-select:focus {
    outline: none;
    border-color: #00B2A9;
    box-shadow: 0 0 0 4px rgba(0, 178, 169, 0.2);
}

.calculator-module .brand-reset-btn {
    background: #00B2A9;
    color: #FFFFFF;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.calculator-module .brand-reset-btn:hover {
    background: #003366;
    transform: translateY(-2px);
}

.calculator-module .table-wrapper {
    overflow-x: auto;
    padding: 0 2rem 2rem;
    -webkit-overflow-scrolling: touch;
}

.calculator-module .brand-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    min-width: 900px;
    border: 3px solid #003366;
    border-radius: 10px;
    background-color: #FFFFFF;
}

.calculator-module .brand-table th,
.calculator-module .brand-table td {
    padding: 1.25rem 1.5rem;
    text-align: left;
    vertical-align: top;
    border: 1px solid #003366; 
}

.calculator-module .brand-table thead tr th:first-child { border-top-left-radius: 7px; }
.calculator-module .brand-table thead tr th:last-child { border-top-right-radius: 7px; }

.calculator-module .brand-table th {
    background: #003366;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 1.1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.calculator-module .metric-col { width: 28%; font-weight: 600; color: #003366; background: #F5F7FA; }
.calculator-module .ez-col { width: 36%; background: #F8FBFF; }
.calculator-module .other-col { width: 36%; }

.calculator-module .ez-text, 
.calculator-module .other-text {
    color: #2C3E50;
    font-size: 1rem;
    margin: 0;
    line-height: 1.5;
}

.calculator-module .disclaimer-section {
    margin: 0 2rem 2rem;
    border: 2px solid #E5E9F0;
    border-radius: 12px;
    overflow: hidden;
}

.calculator-module .accordion-header {
    width: 100%;
    background: #FFFFFF;
    border: none;
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #003366;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.calculator-module .accordion-header .arrow {
    display: inline-block;
    width: 12px;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23003366' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='1 1 6 7 11 1'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
    transition: transform 0.4s ease;
}

.calculator-module .accordion-content {
    padding: 0 1.5rem 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s ease;
    background: #FFFFFF;
    font-size: 0.95rem;
}

.calculator-module .accordion-content.open {
    padding: 0.75rem 1.5rem 1.5rem;
    max-height: 500px;
    background: #FFFFFF;
}

/* Scoped Mobile Table Styling Rules */
@media (max-width: 768px) {
    .calculator-module .comparison-intro { padding: 2rem 1.25rem 0.5rem 1.25rem; }
    .calculator-module .comparison-intro h2 { font-size: 1.5rem; }
    .calculator-module .dropdown-header { padding: 1rem 1.25rem 1.5rem 1.25rem !important; }

    .calculator-module .brand-table { min-width: 100%; border: none; background: transparent; }
    .calculator-module .brand-table thead { display: none; }
    
    .calculator-module .brand-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 1.5rem;
        border: 2px solid #E5E9F0; 
        border-radius: 12px;
        overflow: hidden;
        background: #FFFFFF;
    }
    .calculator-module .brand-table td {
        display: block;
        width: 100%;
        border: none; 
        border-bottom: 1px solid #E5E9F0; 
        padding: 1rem 1.25rem;
    }
    .calculator-module .brand-table td:last-child { border-bottom: none; }
    .calculator-module .brand-table td:before {
        content: attr(data-label);
        font-weight: 700;
        color: #003366;
        display: block;
        margin-bottom: 0.5rem;
    }
}

/* ======================================================================
   3. TAB 3: CALCULATOR SPECIFIC CSS (FULLY UPDATED WITH GRANULAR PROVIDER FIELD & LABEL SPACING)
   ====================================================================== */

/* Main calculator container */
.calculator-module .calculator-light-bg {
    background: var(--light-bg);
}
.calculator-module .calculator-max-container {
    max-width: 1280px;
    margin: 0 auto;
}
.calculator-module .calculator-rounded-2xl {
    border-radius: var(--rounded-2xl);
}

/* Grid system - equal width columns on desktop */
.calculator-module .calculator-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 2rem;
}
@media (min-width: 1024px) {
    .calculator-module .calculator-grid-cols-12 {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}
.calculator-module .calculator-col-span-6 {
    grid-column: span 6 / span 6;
}
@media (max-width: 1023px) {
    .calculator-module .calculator-col-span-6 {
        grid-column: span 12 / span 12;
    }
}

.calculator-module .calculator-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

/* Spacing utilities */
.calculator-module .calculator-gap-8 { gap: 2rem; }
.calculator-module .calculator-gap-6 { gap: 1.5rem; }
.calculator-module .calculator-gap-4 { gap: 1rem; }
.calculator-module .calculator-gap-3 { gap: 0.75rem; }
.calculator-module .calculator-mt-12 { margin-top: 3rem; }
.calculator-module .calculator-mb-10 { margin-bottom: 2.5rem; }
.calculator-module .calculator-mb-6 { margin-bottom: 1.5rem; }
.calculator-module .calculator-space-y-8 > * + * { margin-top: 2rem; }
.calculator-module .calculator-space-y-4 > * + * { margin-top: 1rem; }

/* Headings */
.calculator-module .calculator-heading-2xl {
    font-size: 1.85rem;
    font-weight: 600;
    color: var(--brand-blue);
    line-height: 1.25;
}
.calculator-module .calculator-heading-3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--brand-blue);
}

/* ======================================================================
   LABELS - GRANULAR CONTROL (EXPANDED FOR INDIVIDUAL FIELD LABEL SPACING)
   ====================================================================== */
.calculator-module .calculator-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

/* Base label spacing inside provider fields */
.calculator-module #provider-fields .calculator-label {
    margin-top: 0.5rem !important;
}

/* 1. Select Provider label - minimal top margin (right after dropdown) */
.calculator-module #provider-fields .select-provider-label {
    margin-top: 1 !important;
}

/* 2. Provider Name label (manual mode) - minimal top margin */
.calculator-module #provider-fields .provider-name-label {
    margin-top: 1 !important;
}

/* 3. Setup Fee label - uniform top spacing */
.calculator-module #provider-fields .setup-fee-label {
    margin-top: 1rem !important;
}

/* 4. Annual Admin Fee label */
.calculator-module #provider-fields .annual-admin-label {
    margin-top: 0.01rem !important;
}

/* 5. Audit Fee label */
.calculator-module #provider-fields .audit-fee-label {
    margin-top: 0.01rem !important;
}

/* 6. Notes label - last label */
.calculator-module #provider-fields .notes-label {
    margin-top: 0.01rem !important;
}

/* Future-proof granular label classes */
.calculator-module #provider-fields .select-provider-label,
.calculator-module #provider-fields .provider-name-label,
.calculator-module #provider-fields .setup-fee-label,
.calculator-module #provider-fields .annual-admin-label,
.calculator-module #provider-fields .audit-fee-label,
.calculator-module #provider-fields .notes-label {
    /* Individual overrides can be placed here */
}

/* Cards */
.calculator-module .calculator-card {
    background-color: #FFFFFF;
    box-shadow: 0 10px 15px -3px rgb(0 51 102 / 0.08);
    border-radius: var(--rounded-3xl);
    padding: 2rem;
}

/* Form inputs & selects - smaller font size for all dropdowns */
.calculator-module .calculator-select,
.calculator-module .calculator-balance-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--border-light);
    border-radius: var(--rounded-3xl);
    font-size: 1.0rem;
    background: #FFFFFF;
    color: var(--text-dark);
    box-sizing: border-box;
}
.calculator-module .calculator-select:focus,
.calculator-module .calculator-balance-input:focus {
    border-color: var(--accent-teal);
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 178, 169, 0.2);
}

/* Balance input - $ symbol removed from the field itself */
.calculator-module .calculator-balance-input {
    padding-left: 1.25rem;
}

/* ======================================================================
   PROVIDER FIELDS - FULLY GRANULAR SPACING CONTROL (INDIVIDUALLY CONTROLLED)
   ====================================================================== */

/* Base spacing for all provider field rows */
.calculator-module #provider-fields > div {
    margin-bottom: 0.01rem !important;
}

/* 1. Select Provider dropdown row - increased spacing to match other fields */
.calculator-module #provider-fields .select-provider-row,
.calculator-module #provider-fields > div:first-child {
    margin-bottom: 0.01rem !important;
}

/* 2. Provider Name row (when Enter Manually is selected) - increased spacing */
.calculator-module #provider-fields .provider-name-row,
.calculator-module #provider-fields > div:first-of-type {
    margin-bottom: 0.01rem !important;
    margin-top: 1rem !important;
}

/* 3. Setup Fee row */
.calculator-module #provider-fields .setup-fee-row {
    margin-bottom: 0.01rem !important;
    margin-top: 1rem !important;
}

/* 4. Annual Admin Fee row - ZERO spacing to next field */
.calculator-module #provider-fields .annual-admin-row {
    margin-bottom: 0.01rem !important;
}

/* 5. Audit Fee row - ZERO spacing to next field */
.calculator-module #provider-fields .audit-fee-row {
    margin-bottom: 0.01rem !important;
}

/* 6. Notes row - ZERO spacing (last field) */
.calculator-module #provider-fields .notes-row,
.calculator-module #provider-fields > div:last-child {
    margin-bottom: 0 !important;
}

/* Manual provider fields - full width, left aligned, each on its own row */
.calculator-module #provider-fields > div {
    grid-column: span 2 !important;
}

/* ======================================================================
   TAB CONTENT BACKGROUND FIX (FULL LIGHT GREY COVERAGE)
   ====================================================================== */
/* Extend light grey background to the FULL padded tab-content area */
.calculator-module .tab-content,
.calculator-module .tab-pane.active {
    background-color: var(--light-bg) !important;
    padding: 30px 20px;
}

/* Inner calculator cards remain white for contrast */
.calculator-module .calculator-card {
    background: #FFFFFF;
}

/* Range slider */
.calculator-module .calculator-slider {
    width: 100%;
    accent-color: var(--accent-teal);
    background: linear-gradient(to right, var(--accent-teal) 0%, #D4AF37 100%);
    height: 6px;
    border-radius: 9999px;
    -webkit-appearance: none;
}
.calculator-module .calculator-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    background: #D4AF37;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--brand-blue);
}

/* Checkbox groups - button-style for planned changes */
.calculator-module .calculator-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.calculator-module .calculator-checkbox-group.calculator-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}
.calculator-module .calculator-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 12px 20px;
    border: 2px solid var(--border-light);
    border-radius: 9999px;
    transition: all 0.2s ease;
}
.calculator-module .calculator-checkbox-label:hover {
    border-color: var(--accent-teal);
    background: #F8FBFF;
}
.calculator-module .calculator-checkbox-label:has(input:checked) {
    border-color: var(--accent-teal);
    background: #F0FAF8;
}
.calculator-module .calculator-accent-teal {
    accent-color: var(--accent-teal);
}

/* Trustee options */
.calculator-module .calculator-flex-center-gap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.calculator-module .calculator-flex-gap-4 {
    display: flex;
    gap: 1rem;
}
.calculator-module .calculator-trustee-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid var(--border-light);
    border-radius: var(--rounded-3xl);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.calculator-module .calculator-trustee-option:hover {
    border-color: var(--accent-teal);
}
.calculator-module .calculator-trustee-option:has(:checked) {
    border-color: var(--accent-teal);
}

/* Results section */
.calculator-module .calculator-hidden { display: none !important; }
.calculator-module .calculator-overflow-x-auto { overflow-x: auto; }

/* Results pricing table */
.calculator-module .calculator-results-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 2px solid var(--brand-blue);
    border-radius: 10px;
    overflow: hidden;
    background-color: #FFFFFF;
    table-layout: fixed;
}
.calculator-module .calculator-results-table th,
.calculator-module .calculator-results-table td {
    border: 1px solid var(--brand-blue);
    padding: 18px 12px;
    text-align: left;
}
.calculator-module .calculator-results-table th:nth-child(2),
.calculator-module .calculator-results-table th:nth-child(3),
.calculator-module .calculator-results-table td:nth-child(2),
.calculator-module .calculator-results-table td:nth-child(3) {
    width: 30%;
}
.calculator-module .calculator-table-header-row th {
    background-color: #E5E7EB;
    color: var(--brand-blue);
}

/* Chart container */
.calculator-module .calculator-chart-container {
    height: 256px;
}

/* Pros & Cons - side-by-side on desktop (already using grid-cols-2) */
.calculator-module #ez-pros-cons,
.calculator-module #other-pros-cons {
    background-color: #FFFFFF;
    box-shadow: 0 10px 15px -3px rgb(0 51 102 / 0.08);
    border-radius: var(--rounded-3xl);
    padding: 2rem;
}

/* Pros & Cons - remove bullets but keep icons */
.calculator-module #ez-pros-cons ul,
.calculator-module #other-pros-cons ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

/* Low-cost providers disclaimer - smaller font */
.calculator-module .low-cost-disclaimer {
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Tax deductible checkbox + label - centred */
.calculator-module .tax-deductible-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* What If Scenario tiles - light border + clickable */
.calculator-module .what-if-tile {
    border: 2px solid var(--border-light);
    border-radius: var(--rounded-3xl);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.calculator-module .what-if-tile:hover {
    background: #F8FBFF;
    border-color: var(--accent-teal);
}

/* Extra spacing before accordion */
.calculator-module .calculator-mt-16 {
    margin-top: 4rem !important;
}

/* Expandable details */
.calculator-module .calculator-expandable {
    border: 1px solid var(--brand-blue);
    border-radius: 8px;
    padding: 4px 16px;
    background: #FFFFFF;
    margin-bottom: 1rem;
}
.calculator-module .calculator-expandable summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--brand-blue);
    padding: 12px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.calculator-module .calculator-expandable-content {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: rgba(44, 62, 80, 0.8);
    line-height: 1.6;
}

/* Final utility classes used in JS-rendered content */
.calculator-module .text-center { text-align: center; }
.calculator-module .font-semibold { font-weight: 600; }
.calculator-module .font-medium { font-weight: 500; }
.calculator-module .calculator-text-success { color: #00B2A9; }
.calculator-module .calculator-text-error { color: #DC2626; !important}
.calculator-module .calculator-brand-blue { color: var(--brand-blue); }

/* Responsive adjustments */
@media (max-width: 768px) {
    .calculator-module .tab-content {
        padding: 1.5rem;
    }
    
    .calculator-module .calculator-card {
        padding: 1.5rem;
    }
    
    .calculator-module .calculator-grid {
        gap: 1.5rem;
    }
}