:root {
    --primary-color: #34c759;
    --secondary-color: #28a745;
    --chart-blue: #4A90E2;
    --chart-orange: #F5A623;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
header {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    padding: 20px 0;
    color: white;
}
header h1 {
    margin: 0;
    font-size: 2rem;
    text-align: center;
}
.mortgage-section {
    padding: 40px 0;
    width: 100%;
    box-sizing: border-box;
}
.container-align {
    padding-left: calc((100% - 1200px) / 2 + 20px);
    max-width: 1200px;
    box-sizing: border-box;
}
.mortgage-section h3 {
    font-size: 1.8rem;
    margin: 0 0 10px;
    color: #333;
    text-align: left;
}
.mortgage-section .description {
    font-size: 1rem;
    color: #666;
    margin: 0 0 20px;
    line-height: 1.6;
    text-align: left;
}
.mortgage-section .container {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    gap: 2.5%;
}
.left-panel {
    flex: 0 0 30%;
    min-width: 350px;
    box-sizing: border-box;
}
.right-panel {
    flex: 0 0 67.5%;
    min-width: 450px;
    box-sizing: border-box;
}
.mortgage-calculator {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.form-group {
    margin-bottom: 15px;
    padding-bottom: 10px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}
.form-group input.invalid, .form-group select.invalid {
    border-color: #dc3545;
}
.form-group .error-message {
    display: block;
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 5px;
}
.toggle-advanced {
    display: block;
    margin: 10px 0;
    color: #007bff;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}
.toggle-advanced:hover {
    color: #0056b3;
}
.advanced-fields {
    display: none;
}
.advanced-fields.show {
    display: block;
}
.down-payment-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.down-payment-toggle label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}
.calculate-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s;
}
.calculate-btn:disabled {
    background: #a0a0a0;
    cursor: not-allowed;
}
.calculate-btn:not(:disabled):hover {
    background: var(--secondary-color);
}
.powered-by {
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
    color: #666;
}
.related-calculators {
    margin-top: 30px;
}
.related-calculators h3 {
    margin-bottom: 15px;
}
.related-card {
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.1);
    margin-bottom: 10px;
}
.related-card a {
    text-decoration: none;
    color: #007bff;
    font-weight: 600;
}
.related-card a:hover {
    text-decoration: underline;
}
.result-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.result-section h3 {
    margin-bottom: 15px;
}
.charts-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 20px auto;
    max-width: 800px;
    width: 100%;
    padding-bottom: 60px;
}
.chart-container {
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    flex: 1;
    max-width: 40%;
}
.pie-chart-container {
    max-width: 60%;
}
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}
.chart-legend > div {
    flex: 0 0 33.33%;
    box-sizing: border-box;
    padding: 5px;
    text-align: center;
}
#mortgageChart {
    width: 100% !important;
    height: 400px !important;
    display: block;
}
#areaChart {
    width: 100% !important;
    height: 300px !important;
    display: block;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.results-table th, .results-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}
.results-table th {
    background: #f1f1f1;
    font-weight: 600;
}
.amortization-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    display: none;
}
.amortization-table.show {
    display: table;
}
.amortization-table th, .amortization-table td {
    padding: 8px;
    border: 1px solid #ddd;
    text-align: right;
}
.amortization-table th {
    background: #f1f1f1;
    font-weight: 600;
}
.amortization-table td:first-child, .amortization-table th:first-child {
    text-align: left;
}
.toggle-amortization {
    display: block;
    margin: 10px 0;
    color: #007bff;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}
.toggle-amortization:hover {
    color: #0056b3;
}
.show-more {
    display: block;
    margin: 10px auto;
    padding: 8px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}
.show-more:hover {
    background: #0056b3;
}
.article-section {
    margin-top: 20px;
}
.article-section h3 {
    margin-bottom: 20px;
}
.article-section h4 {
    margin-bottom: 15px;
}
.article-section p {
    margin-bottom: 20px;
    line-height: 1.6;
}
.article-section ul {
    margin-bottom: 20px;
    padding-left: 20px;
}
.article-section ul li {
    margin-bottom: 8px;
    line-height: 1.6;
}
.table-of-contents {
    background: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 20px;
}
.table-of-contents h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}
.table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.table-of-contents ul li {
    margin-bottom: 8px;
}
.table-of-contents ul li a {
    color: #007bff;
    text-decoration: none;
}
.table-of-contents ul li a:hover {
    text-decoration: underline;
}
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    display: none;
}
.back-to-top:hover {
    background: var(--secondary-color);
}
@media (max-width: 1200px) {
    .container-align {
        padding-left: 20px;
    }
    .charts-wrapper {
        max-width: 600px;
    }
}
@media (max-width: 768px) {
    .mortgage-section .container {
        flex-direction: column;
    }
    .left-panel, .right-panel {
        min-width: 100%;
    }
    .amortization-table {
        font-size: 0.9rem;
    }
    .charts-wrapper {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
    }
    .chart-container, .pie-chart-container {
        max-width: 100%;
    }
    #mortgageChart {
        height: 320px !important;
    }
    #areaChart {
        height: 250px !important;
    }
    .mortgage-section h3 {
        font-size: 1.5rem;
    }
    .mortgage-section .description {
        font-size: 0.9rem;
        padding-right: 15px;
    }
    .article-section h3 {
        font-size: 1.2rem;
    }
    .article-section p, .article-section ul li {
        font-size: 0.9rem;
    }
}