/* --- CSS Start --- */
:root {
    --primary-color: #007bff; /* Blue accent */
    --secondary-color: #17a2b8; /* Teal accent */
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef; /* This is the color value we need for JS */
    --dark-gray: #6c757d;
    --text-color: #212529;
    --label-color: #495057;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top */
    min-height: 100vh;
    background-color: #2D3748; /* Light gray page background */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    color: var(--text-color);
}

.calculator-container {
    background-color: #ffffff; /* White container background */
    padding: 30px 40px;
    border-radius: 10px; /* Slightly less rounded */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 750px;
    box-sizing: border-box;
}

h1 {
    color: var(--text-color);
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.8em;
    font-weight: 600;
}

.subtitle {
    text-align: center;
    color: var(--dark-gray);
    margin-bottom: 35px;
    font-size: 0.95em;
}

.input-section {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px; /* Space between input rows */
}

.input-row {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.input-row label {
    flex-basis: 120px; /* Fixed base width for labels */
    flex-grow: 0;
    color: var(--label-color);
    font-size: 0.9em;
}

.input-control-group {
    flex-basis: calc(100% - 140px); /* Take remaining space */
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

input[type="range"] {
    flex-grow: 1;
    height: 6px;
    cursor: pointer;
    appearance: none;
    width: 100%; /* Ensure slider takes width within its group */
    background: var(--medium-gray);
    border-radius: 3px;
    outline: none;
    transition: opacity .2s;
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none; /* Reset default border */
}
 input[type="range"]::-moz-range-track {
    background: var(--medium-gray);
    height: 6px;
    border-radius: 3px;
}


.input-value-display {
    flex-basis: 100px; /* Fixed width for text input/display */
    flex-shrink: 0;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: right;
    background-color: var(--light-gray);
    min-width: 80px; /* Ensure minimum width */
}
.input-value-display.percentage {
    background-color: transparent;
    border: none;
    text-align: left;
    font-size: 0.85em;
    color: var(--dark-gray);
    flex-basis: 60px; /* Smaller width for percentage */
     min-width: 50px;
}

/* Specific override for down payment layout */
.input-row.down-payment .input-control-group {
     gap: 5px; /* Reduce gap for percentage */
}


/* Results Summary Section */
.results-summary {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    justify-content: space-around; /* Distribute items */
    gap: 20px;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--medium-gray);
}

.result-block {
    text-align: center;
    flex: 1; /* Allow blocks to grow/shrink */
    min-width: 120px; /* Minimum width before wrapping */
}

.result-label {
    font-size: 0.7em;
    color: var(--dark-gray);
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 500;
}

.result-value {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

/* Chart Section */
.chart-container {
    margin-top: 35px;
    padding-top: 25px;
    border-top: 1px solid var(--medium-gray);
    position: relative;
    height: 300px; /* Fixed height */
    width: 100%;
}

#loanChart {
     max-height: 300px;
}

.error-message {
    color: #dc3545; /* Bootstrap danger color */
    text-align: center;
    margin-top: 20px;
    font-weight: 500;
    padding: 10px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
}

/* Hide results and chart initially */
.results-summary, .chart-container {
    display: none;
}
/* --- CSS End --- */
