

/* CSS Variables */
        :root {
            --primary: #2c3e50;
            --secondary: #ff6b6b;
            --accent: #3d5a80;
            --light-bg: #f8f9fa;
            --teal: #4ecdc4;
            --border-color: #e0e0e0;
            --text-color: #000000;
            --text-light: #666;
            --warning: #e74c3c;
            --success: #2ecc71;
        }

        /* Base Styles */
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Times New Roman', Times, serif;
            font-size: 1rem;
            line-height: 1.6;
            color: var(--text-color);
            background-color: var(--light-bg);
        }

        h1, h2, h3, h4, p, span, label, input, select, button, a, li {
            font-family: 'Times New Roman', Times, serif;
        }

        h1 {
            font-size: 1.25rem;
            margin-bottom: 1rem;
            color: var(--primary);
            text-align: center;
        }

        h2 {
            font-size: 1.375rem;
            margin-bottom: 0.75rem;
            color: #ff6b6b;
        }

        h3 {
            font-size: 1.25rem;
            margin-bottom: 0.5rem;
            color: #000;
        }

        h4 {
            font-size: 1.125rem;
            color: #000;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 0 10px;
        }

        /* Mobile Layout */
        .content-wrapper {
            display: flex;
            flex-direction: column;
            margin: 0px 0 20px 0;
        }

        .main-content {
            width: 100%;
            order: 1;
        }

        .sidebar {
            width: 100%;
        }

        .sidebar-left {
            order: 2;
        }

        .sidebar-right {
            order: 3;
        }

        /* Calculator Styles */
        .calculator {
            background-color: white;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 1.5rem;
            margin-bottom: 1.5rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .form-section {
            margin-bottom: 1.5rem;
            padding-bottom: 1.5rem;
            border-bottom: 1px solid var(--border-color);
        }

        .form-group {
            margin-bottom: 1rem;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            font-weight: bold;
        }

        input, select {
            width: 100%;
            padding: 0.75rem;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 1rem;
            font-family: 'Times New Roman', Times, serif;
        }

        .checkbox-group {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .checkbox-group input {
            width: auto;
        }

        .button-group {
            display: flex;
            gap: 1rem;
            margin-top: 1.5rem;
        }

        button {
            padding: 0.75rem 1.5rem;
            border: none;
            border-radius: 4px;
            font-size: 1rem;
            cursor: pointer;
            flex: 1;
            font-family: 'Times New Roman', Times, serif;
        }

        .btn-calculate {
            background-color: var(--teal);
            color: white;
            position: relative;
        }

        .btn-reset {
            background-color: var(--secondary);
            color: white;
        }

        /* Spinner animation styles */
        .btn-calculate .spinner {
            display: none;
            width: 20px;
            height: 20px;
            border: 2px solid #ffffff;
            border-radius: 50%;
            border-top-color: transparent;
            animation: spin 0.8s linear infinite;
            margin-right: 8px;
        }

        .btn-calculate.calculating {
            pointer-events: none;
            opacity: 0.7;
        }

        .btn-calculate.calculating .spinner {
            display: inline-block;
        }

        .btn-calculate.calculating .btn-text {
            display: none;
        }

        @keyframes spin {
            to {
                transform: rotate(360deg);
            }
        }

        /* Results Section */
        .results {
            background-color: white;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 1.5rem;
            margin-top: 1.5rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
            display: none;
        }

        .result-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid var(--border-color);
        }

        .result-label {
            font-weight: bold;
        }

        .result-value {
            color: var(--accent);
            font-weight: bold;
            font-size: 1.25rem;
        }

        .export-options {
            display: flex;
            gap: 1rem;
            margin-top: 1.5rem;
        }

        .export-btn {
            background-color: var(--accent);
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            text-decoration: none;
            text-align: center;
            flex: 1;
            font-family: 'Times New Roman', Times, serif;
            cursor: pointer;
            border: none;
            font-size: 1rem;
        }

        /* Amortization Schedule */
        .amortization {
            margin-top: 1.5rem;
            overflow-x: auto;
        }

        .amortization-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }

        .amortization-table th,
        .amortization-table td {
            padding: 0.75rem;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
        }

        .amortization-table th {
            background-color: var(--light-bg);
            font-weight: bold;
            font-size: 1rem;
        }

        /* Chart Containers */
        .chart-container {
            margin-top: 1.5rem;
            background-color: white;
            border-radius: 8px;
            padding: 1.5rem;
            border: 1px solid var(--border-color);
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .chart-placeholder {
            height: 200px;
            background-color: var(--light-bg);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-light);
            margin-top: 1rem;
        }

        /* Ad Zones */
        .ad-zone {
            background-color: white;
            border: 1px dashed var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1.5rem;
            border-radius: 4px;
            color: var(--text-light);
            font-family: 'Times New Roman', Times, serif;
        }

        #ad-left, #ad-right, #ad-tablet, #ad-mobile {
            display: none;
        }

        /* Related Tools */
        #related-tools {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
            width: 100%;
        }

        .tools-list {
            list-style: none;
        }

        .tools-list li {
            padding: 10px 0;
            border-bottom: 1px solid var(--border-color);
        }

        .tools-list li:last-child {
            border-bottom: none;
        }

        .tools-list a {
            color: #000;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .tools-list a:hover {
            color: var(--teal);
        }

        /* Amortization Tabs */
        .amortization-tabs {
            display: flex;
            margin-bottom: 1rem;
            border-bottom: 1px solid var(--border-color);
        }

        .amortization-tab {
            padding: 0.5rem 1rem;
            background: none;
            border: none;
            cursor: pointer;
            font-family: 'Times New Roman', Times, serif;
            font-size: 1rem;
            color: var(--text-light);
        }

        .amortization-tab.active {
            color: var(--primary);
            border-bottom: 2px solid var(--teal);
        }

        .amortization-content {
            display: none;
        }

        .amortization-content.active {
            display: block;
        }

        /* Monthly Amortization Pagination */
        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 1rem;
            gap: 1rem;
        }

        .pagination button {
            padding: 0.5rem 1rem;
            background-color: var(--light-bg);
            border: 1px solid var(--border-color);
            border-radius: 4px;
            cursor: pointer;
            flex: none;
        }

        .pagination button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .pagination-info {
            font-size: 1rem;
            color: var(--text-light);
        }

        /* Small Pie Chart */
        .small-chart {
            height: 200px !important;
        }

        /* Sticky sidebar elements */
        .sticky-sidebar {
            position: sticky;
            top: 20px;
        }

        /* Advanced Features Section */
        .advanced-feature {
            background-color: #f0f8ff;
            border-left: 4px solid var(--teal);
            padding: 1rem;
            margin-top: 1rem;
            border-radius: 4px;
            display: none;
        }

        .advanced-feature.active {
            display: block;
        }

        /* Refinance-specific fields */
        .refinance-fields {
            display: none;
        }

        .refinance-fields.active {
            display: block;
        }

        /* Custom loan term input */
        #custom-loan-term-container {
            display: none;
            margin-top: 0.5rem;
        }

        #custom-loan-term-container.active {
            display: block;
        }

        /* Advanced Enhancements Section - FIXED: Now visible by default */
        #advanced-enhancements-section {
            display: block;
        }

        /* Funding Fee Info Box */
        .funding-fee-info {
            background-color: #f0f8ff;
            border-left: 4px solid var(--teal);
            padding: 1rem;
            margin-top: 1rem;
            border-radius: 4px;
            font-size: 1rem;
        }

        .funding-fee-info h4 {
            margin-bottom: 0.5rem;
            color: #000;
            font-size: 1.125rem;
        }

        /* Loading Indicator */
        .loading {
            display: none;
            text-align: center;
            padding: 1rem;
            color: var(--accent);
        }

        .loading.active {
            display: block;
        }

        /* Validation Errors */
        .validation-errors {
            background-color: #ffe6e6;
            border-left: 4px solid var(--warning);
            padding: 1rem;
            margin-top: 1rem;
            border-radius: 4px;
            font-size: 1rem;
            display: none;
        }

        .validation-errors.active {
            display: block;
        }

        .validation-errors ul {
            margin-left: 1.5rem;
        }

        .validation-errors li {
            margin-bottom: 0.5rem;
        }

        /* Tooltip */
        .tooltip {
            position: relative;
            display: inline-block;
            margin-left: 5px;
            cursor: help;
        }

        .tooltip .tooltip-text {
            visibility: hidden;
            width: 250px;
            background-color: var(--primary);
            color: white;
            text-align: center;
            border-radius: 6px;
            padding: 10px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -125px;
            opacity: 0;
            transition: opacity 0.3s;
            font-size: 1rem;
            line-height: 1.4;
        }

        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }

        /* Tablet Layout */
        @media (min-width: 768px) and (max-width: 1024px) {
            .content-wrapper {
                margin: 0px 0 20px 0;
            }
            
            h1 {
                font-size: 1.25rem;
            }
            
            h2 {
                font-size: 1.25rem;
                color: #ff6b6b;
            }
            
            h3 {
                font-size: 1.125rem;
                color: #000;
            }

            h4 {
                font-size: 1rem;
                color: #000;
            }

            #ad-tablet, #related-tools {
                display: block;
            }

            .ad-zone {
                margin: 0 auto 1.5rem;
            }

            #ad-tablet {
                width: 300px;
                height: 250px;
                margin-top: 10px;
            }

            .related-tools {
                width: 100%;
                margin: 0 auto;
            }

            .amortization-tab {
                font-size: 0.875rem;
            }
        }

        /* Desktop Layout */
        @media (min-width: 1025px) {
            h1 {
                font-size: 1.5rem;
            }
            
            h2 {
                font-size: 1.375rem;
                color: #ff6b6b;
            }
            
            h3 {
                font-size: 1.25rem;
                color: #000;
            }

            h4 {
                font-size: 1.125rem;
                color: #000;
            }

            .content-wrapper {
                flex-direction: row;
                gap: 20px;
                align-items: flex-start;
            }

            .sidebar {
                width: 300px;
            }

            .sidebar-left {
                order: 1;
            }

            .main-content {
                order: 2;
                flex: 1;
            }

            .sidebar-right {
                order: 3;
            }

            #ad-left, #ad-right, #related-tools {
                display: block;
            }

            #ad-left {
                width: 300px;
                height: 250px;
            }

            #ad-right {
                width: 300px;
                height: 600px;
            }

            /* Fixed Sticky Positioning for Sidebar Elements */
            .sidebar-left,
            .sidebar-right {
                position: sticky;
                top: 20px;
                align-self: flex-start;
                height: fit-content;
            }

            .form-row {
                display: flex;
                gap: 1rem;
            }

            .form-row .form-group {
                flex: 1;
            }

            .amortization-tab {
                font-size: 1rem;
            }
        }

        /* Mobile Ads */
        @media (max-width: 767px) {
            .content-wrapper {
                margin: 0px 0 20px 0;
            }
            
            h1 {
                font-size: 1.25rem;
            }

            h2 {
                font-size: 1.125rem;
                color: #ff6b6b;
            }

            h3 {
                font-size: 1rem;
                color: #000;
            }

            h4 {
                font-size: 0.9375rem;
                color: #000;
            }

            #ad-mobile, #related-tools {
                display: block;
            }

            #ad-mobile {
                width: 320px;
                height: 100px;
                margin: 10px auto 1.5rem;
            }

            .amortization-tab {
                font-size: 0.875rem;
            }
        }

        /* Mobile Responsive Fix for Calculator Container */
        @media (max-width: 767px) {
            .calculator {
                padding: 1rem;
                margin: 0 0 1rem 0;
                width: 100%;
                overflow-x: hidden;
            }
            
            .form-section {
                margin-bottom: 1rem;
                padding-bottom: 1rem;
            }
            
            .form-row {
                flex-direction: column;
                gap: 0.5rem;
            }
            
            .button-group {
                flex-direction: column;
                gap: 0.5rem;
            }
            
            .export-options {
                flex-direction: column;
                gap: 0.5rem;
            }
            
            input, select {
                font-size: 1rem;
                padding: 0.5rem;
            }
            
            .amortization-table {
                font-size: 1rem;
            }
            
            .amortization-table th,
            .amortization-table td {
                padding: 0.5rem 0.25rem;
            }
            
            .chart-container {
                padding: 1rem;
                margin-top: 1rem;
            }
            
            .result-item {
                flex-direction: column;
                gap: 0.25rem;
            }
            
            .funding-fee-info {
                font-size: 1rem;
                padding: 0.75rem;
            }
            
            .tooltip .tooltip-text {
                width: 200px;
                margin-left: -100px;
                font-size: 1rem;
            }
        }

        /* Additional fix for very small screens */
        @media (max-width: 480px) {
            .calculator {
                padding: 0.75rem;
                border-radius: 4px;
            }
            
            h1 {
                font-size: 1.25rem;
                margin-bottom: 0.75rem;
            }
            
            h2 {
                font-size: 1.125rem;
                margin-bottom: 0.5rem;
                color: #ff6b6b;
            }

            h3 {
                font-size: 1rem;
                color: #000;
            }

            h4 {
                font-size: 0.9375rem;
                color: #000;
            }
            
            .form-section strong {
                font-size: 1rem;
            }
            
            .checkbox-group {
                font-size: 1rem;
            }
            
            button {
                padding: 0.5rem 1rem;
                font-size: 1rem;
            }
        }

        /* Add breadcrumb styles */
        .breadcrumb {
            padding: 0px 10px;
            color: #000;
            margin-bottom: 5px;
            font-size: 1rem;
        }

        .breadcrumb a {
            color: #000;
            text-decoration: none;
            transition: color 0.3s;
        }

        .breadcrumb a:hover {
            color: var(--secondary);
            text-decoration: underline;
        }

.mobile-table {
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #eee;
    border-radius: 8px;
}
.mobile-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
}
.mobile-table th, .mobile-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
}
.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}