:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #000;
    background-color: var(--light-bg);
    padding: 0;
    margin: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

main {
    padding: 20px 0;
}

h1 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: #000;
    text-align: center;
}

h2 {
    font-size: 1.125rem;
    margin: 1.2rem 0 0.8rem;
    color: #ff6b6b;
}

h3 {
    font-size: 1rem;
    margin: 1rem 0 0.5rem;
    color: #000;
}

h4 {
    font-size: 0.9375rem;
    margin: 1rem 0 0.5rem;
    color: #000;
}

.calculator-grid {
    display: flex;
    flex-direction: column;
  
}

.calculator-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    overflow: hidden;
}

.calculator-card.expanded {
    transform: translateZ(0);
    z-index: 10;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: #000;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    color: #000;
}

input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
    color: #000;
}

.btn-calculate {
    background-color: var(--teal);
    color: white;
    flex: 1;
}

.btn-reset {
    background-color: var(--secondary);
    color: white;
    flex: 1;
}

.export-buttons {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.btn-export {
    background-color: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.result-section {
    display: none;
}

.result-section.visible {
    display: block;
}

/* VERTICAL RESULT LAYOUT */
.vertical-results {
    margin-top: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem;
    border-bottom: 1px solid #eee;
}

.result-item:nth-child(odd) {
    background-color: #f9f9f9;
}

.result-label {
    font-weight: bold;
    color: #000;
    font-size: 1.125rem;
}

.result-value {
    color: #000;
    font-weight: bold;
    font-size: 1.25rem;
}

.chart-container {
    height: 300px;
    background-color: white;
    border-radius: var(--border-radius);
    margin: 1.5rem 0;
    padding: 1rem;
    position: relative;
}

/* AD CONTAINER WHITE BACKGROUND */
.ad-container {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem 0;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
}

.ad-label {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px 5px;
    font-size: 0.4375rem;
    border-radius: 3px;
}

/* Custom ratio inputs - initially hidden */
.custom-ratio-inputs {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: var(--border-radius);
}

/* Warnings and validation messages */
.warning {
    color: #e74c3c;
    font-weight: bold;
    margin-top: 5px;
    font-size: 0.5625rem;
    padding: 0.5rem;
    background-color: #ffeeee;
    border-radius: 4px;
    border-left: 4px solid #e74c3c;
}

.caution {
    color: #e67e22;
    font-weight: bold;
    margin-top: 5px;
    font-size: 0.5625rem;
    padding: 0.5rem;
    background-color: #fff4e6;
    border-radius: 4px;
    border-left: 4px solid #e67e22;
}

.error {
    color: #c0392b;
    font-weight: bold;
    margin-top: 5px;
    font-size: 0.5625rem;
    padding: 0.5rem;
    background-color: #ffe6e6;
    border-radius: 4px;
    border-left: 4px solid #c0392b;
}

.success {
    color: #27ae60;
    font-weight: bold;
    margin-top: 5px;
    font-size: 0.5625rem;
    padding: 0.5rem;
    background-color: #eaffea;
    border-radius: 4px;
    border-left: 4px solid #27ae60;
}

/* Related Tools Styles */
#related-tools {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.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);
}

/* Input alignment fixes */
.input-row {
    display: grid;
    gap: 1rem;
}

/* Text-only results for export */
.text-results {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.text-results h2 {
    margin-top: 0;
    color: #ff6b6b;
    border-bottom: 2px solid var(--teal);
    padding-bottom: 10px;
}

.text-results .result-item {
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
}

.text-results .result-label {
    font-weight: bold;
    display: inline-block;
    width: 200px;
    color: #000;
}

/* Mobile Layout (≤767px) */
#ad-left, #ad-right, #ad-tablet {
    display: none;
}

#ad-mobile {
    display: block;
    width: 100%;
    height: 100px;
}

.desktop-related {
    display: none;
}

.input-row {
    grid-template-columns: 1fr;
}

/* Tablet Layout (768px–1024px) */
@media (min-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    h4 {
        font-size: 1rem;
    }

    button {
        font-size: 0.875rem;
    }

    #ad-mobile, #ad-left, #ad-right {
        display: none;
    }

    #ad-tablet {
    display: block;
    width: 300px;
    height: 250px;
    margin: 20px auto;
    
    }

    .calculator-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .input-row {
        grid-template-columns: 1fr 1fr;
    }

    .custom-ratio-inputs {
        grid-template-columns: 1fr 1fr;
    }

    .desktop-related {
        display: none;
    }

    .export-buttons {
        flex-direction: row;
    }
}

/* Desktop Layout (≥1025px) */
@media (min-width: 1025px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.125rem;
    }

    button {
        font-size: 1rem;
    }

    .calculator-grid {
        display: grid;
        grid-template-columns: 300px 1fr 300px;
        gap: 20px;
    }

    #ad-mobile, #ad-tablet {
        display: none;
    }

    #ad-left, #ad-right {
        display: block;
    }

    .ad-sidebar {
        position: sticky;
        top: 20px;
        height: fit-content;
    }

    #ad-left {
        width: 300px;
        height: 250px;
        margin-bottom: 20px;
        margin-top: 0px;
    }

    #ad-right {
        width: 300px;
        height: 600px;
        margin-top: 0px;
    }

    .input-row {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .desktop-related {
        display: block;
    }

    .mobile-related {
        display: none;
    }

    .export-buttons {
        justify-content: flex-start;
    }

    /* Specific alignment for input groups */
    .align-group-1 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 1rem;
    }
    
    .align-group-2 {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 1rem;
    }
}

/* Print styles */
@media print {
    .ad-container, .related-tools, .btn-calculate, .btn-reset, .export-buttons, .chart-container {
        display: none !important;
    }
    
    .calculator-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .result-section.visible {
        display: block !important;
    }
    
    .text-results {
        display: block !important;
    }
}

/* Export container styling */
#export-container {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 800px;
    padding: 20px;
    background: white;
    z-index: 10000;
    font-family: 'Times New Roman', Times, serif;
    line-height: 1.6;
}

.export-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #2c3e50;
    padding-bottom: 10px;
}

.export-header h1 {
    color: #000;
    margin-bottom: 5px;
}

.export-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
}

.export-section h2 {
    color: #ff6b6b;
    border-bottom: 1px solid #4ecdc4;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.export-result-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #eee;
    page-break-inside: avoid;
}

.export-result-label {
    font-weight: bold;
    color: #000;
}

.export-result-value {
    color: #000;
}

.export-footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    color: #000;
    font-size: 0.5625rem;
}

/* New styles for interest rate display */
.interest-rate-display {
    padding: 0.75rem;
    background-color: #f0f8ff;
    border: 1px solid #c0d6e4;
    border-radius: var(--border-radius);
    font-weight: bold;
    color: #000;
}

.fha-notice {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: var(--border-radius);
    padding: 0.75rem;
    margin-top: 0.5rem;
    color: #000;
}

.input-error {
    border-color: #e74c3c;
    background-color: #ffeeee;
}

.va-loan-note {
    background-color: #e8f4f8;
    border-left: 4px solid #3d5a80;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    color: #000;
}

/* 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;
}

.highlight {
    color: #ff6b6b;
    font-size: 1.25rem;
}

.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;
    color: #000;
}

.mobile-table th {
    background-color: #4ecdc4;
    font-weight: bold;
    font-size: 1rem;
}

.mobile-table tr:nth-child(even) {
    background-color: #fafafa;
}