:root {
    --primary: #2c3e50;
    --secondary: #ff6b6b;
    --accent: #3d5a80;
    --light-bg: #f8f9fa;
    --teal: #4ecdc4;
    --border-color: #e0e0e0;
    --text-color: #000000;
    --text-light: #666;
}

* {
    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);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 10px;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #000;
    text-align: center;
}

h2 {
    font-size: 1.375rem;
    margin-bottom: 15px;
    color: #ff6b6b;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 10px;
    color: #000;
}

h4 {
    font-size: 1.125rem;
    color: #000;
}

.main-content {
    display: flex;
    flex-direction: column;
}

/* Calculator Form Styles */
.calculator-form {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #000;
}

input, select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    color: #000;
}

.input-with-toggle {
    display: flex;
    gap: 10px;
}

.toggle-button {
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0 15px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 1rem;
}

.toggle-button.active {
    background-color: var(--teal);
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
}

/* Results Section */
.results-section {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    margin-top: 20px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.result-item {
    text-align: center;
    padding: 15px;
    background-color: var(--light-bg);
    border-radius: 8px;
}

.result-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #000;
    margin: 10px 0;
}

.result-label {
    font-size: 1rem;
    color: #000;
}

/* Cost Breakdown Section */
.cost-breakdown {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: #000;
}

.cost-item:last-child {
    border-bottom: none;
    font-weight: bold;
    font-size: 1.1rem;
}

.cost-label {
    color: #000;
}

.cost-value {
    font-weight: bold;
    color: #000;
}

/* Chart Placeholders */
.chart-container {
    margin: 20px 0;
    height: 200px;
    background-color: var(--light-bg);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    width: 100%;
    font-size: 1rem;
    color: #000;
}

.btn-primary {
    background-color: #4ecdc4;
    color: white;
    position: relative;
}

.btn-secondary {
    background-color: #ff6b6b;
    color: white;
}

.export-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.export-btn {
    background-color: var(--accent);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    flex: 1;
    font-size: 1rem;
}

/* Spinner */
.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    position: absolute;
    left: calc(50% - 10px);
    top: calc(50% - 10px);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Ad Zones */
.ad-zone {
    background-color: var(--light-bg);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    text-align: center;
}

#ad-left, #ad-right {
    display: none;
}

#ad-tablet, #ad-mobile {
    margin-top: 20px;
}

#ad-mobile {
    height: 100px;
}

#ad-tablet {
    height: 250px;
}

/* Related Tools */
#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);
    color: #000;
}

.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 Table */
.amortization-table-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
}

.amortization-table th, .amortization-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    color: #000;
}

.amortization-table th {
    background-color: var(--light-bg);
    position: sticky;
    top: 0;
    font-size: 1rem;
}

.amortization-table td {
    font-size: 1rem;
}

/* Pie Chart */
.pie-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.pie-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(
        var(--teal) 0% var(--principal-percent),
        var(--secondary) var(--principal-percent) 100%
    );
    margin-bottom: 15px;
    position: relative;
}

.pie-chart-center {
    position: absolute;
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
}

.chart-legend {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #000;
}

.legend-color {
    width: 15px;
    height: 15px;
    border-radius: 3px;
}

.legend-principal {
    background-color: var(--teal);
}

.legend-interest {
    background-color: var(--secondary);
}

/* Desktop Layout */
@media (min-width: 1025px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.375rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    h4 {
        font-size: 1.125rem;
    }

    .main-content {
        flex-direction: row;
        gap: 20px;
        align-items: flex-start;
    }

    .content-area {
        flex: 1;
        min-width: 0; /* Prevents flex overflow issues */
    }

    .sidebar {
        width: 300px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        gap: 20px;
        height: 100vh; /* Key change - full viewport height */
        position: sticky;
        top: 0;
        overflow-y: auto; /* Allows scrolling if content is too tall */
    }

    /* Remove individual sticky from ad-left since sidebar is now sticky */
    #ad-left {
        display: flex;
        height: 250px;
        position: static; /* Now relative to sticky sidebar */
    }

    #ad-right {
        display: flex;
        height: 600px;
        position: static; /* Now relative to sticky sidebar */
    }

    #ad-tablet, #ad-mobile {
        display: none;
    }

    /* FIXED: Related tools positioning */
    #related-tools {
        position: static; /* No longer needs sticky since sidebar is sticky */
        height: auto;
        margin-top: 0;
        /* Remove the max-height and overflow since sidebar handles scrolling */
    }

    #related-tools-mobile {
        display: none;
    }
}

/* Tablet Layout */
@media (min-width: 768px) and (max-width: 1024px) {
    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.125rem;
    }

    h4 {
        font-size: 1rem;
    }

    #ad-tablet {
        display: flex;
        margin: 20px auto 0;
        width: 300px;
    }

    #ad-left, #ad-right, #ad-mobile {
        display: none;
    }

    .button-group {
        margin-bottom: 10px;
    }

    #related-tools {
        display: none;
    }

    #related-tools-mobile {
        display: block;
        background: white;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        margin-top: 20px;
    }
}

/* Mobile Layout */
@media (max-width: 767px) {
    h1 {
        font-size: 1.25rem;
    }

    h2 {
        font-size: 1.125rem;
    }

    h3 {
        font-size: 1rem;
    }

    h4 {
        font-size: 0.9375rem;
    }

    #ad-mobile {
        display: flex;
        width: 320px;
        margin: 20px auto;
    }

    #ad-left, #ad-right, #ad-tablet {
        display: none;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-row .form-group {
        min-width: 100%;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    #related-tools {
        display: none;
    }

    #related-tools-mobile {
        display: block;
        background: white;
        padding: 20px;
        border-radius: 8px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        margin-top: 20px;
    }
}

/* 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;
    }