body {
    font-family: Arial, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

h1 {
    background-color: #343a40;
    color: white;
    padding: 15px;
    margin: 0;
    text-align: center;
}

.calculator {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.input-section, .summary-section, .amortization-section {
    width: 100%;
}

.input-group {
    margin-bottom: 30px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="number"] {
    width: 70%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px 0 0 4px;
    box-sizing: border-box;
}

.currency-group {
    display: flex;
}

.currency-group select {
    width: 30%;
    padding: 10px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.input-with-unit {
    display: flex;
}

.input-with-unit input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-with-unit span {
    padding: 10px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.tenure-group {
    display: flex;
}

.tenure-group input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.tenure-group select {
    padding: 10px;
    background: #e9ecef;
    border: 1px solid #ced4da;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

input[type="range"] {
    width: 100%;
    margin-top: 10px;
}

input[type="range"]::-webkit-slider-thumb {
    background: #007bff;
    border: 1px solid #007bff;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    background: #007bff;
    border: 1px solid #007bff;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    cursor: pointer;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: #6c757d;
}

.summary-section h3 {
    margin-top: 0;
}

.amortization-section h3 {
    margin-top: 30px; /* Adds gap above "Amortization Schedule" */
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.summary-item span:last-child {
    font-weight: bold;
}

#pie-chart {
    max-width: 250px;
    margin: 20px auto 0;
}

.custom-legend {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    gap: 20px;
}

.custom-legend span {
    font-size: 14px;
    display: flex;
    align-items: center;
}

.custom-legend .color-box {
    width: 12px;
    height: 12px;
    margin-right: 5px;
}

.custom-legend .principal-color {
    background-color: #36A2EB;
}

.custom-legend .interest-color {
    background-color: #FF6384;
}

.amortization-table {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
}

#amortization-table table {
    width: 100%;
    border-collapse: collapse;
}

#amortization-table table th,
#amortization-table table td {
    padding: 10px;
    text-align: right;
    border: 1px solid #ddd;
}

#amortization-table table th {
    background-color: #f1f1f1;
    position: sticky;
    top: 0;
}

/* Mobile-friendly adjustments */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        width: auto;
    }

    .calculator {
        padding: 10px;
    }

    input[type="number"] {
        width: 60%;
    }

    .currency-group select {
        width: 40%;
    }

    .input-with-unit span,
    .tenure-group select {
        padding: 8px;
    }

    #pie-chart {
        max-width: 200px;
    }

    .amortization-table {
        max-height: 200px;
    }
}