.emi-calculator-container {
    max-width: 1000px;
    margin: 0 auto;
    margin-bottom: 2rem;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.emi-calculator-container h2 {
    text-align: center;
    color: #1f2937;
    margin-top: 0;
    margin-bottom: 10px;
}

.calculator-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: 0.8fr 1.1fr 0.9fr;
    align-items: flex-start;
}

.input-section,
.result-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
}

.input-group label {
    font-weight: 500;
    color: #4b5563;
}

.styled-input-1 {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    width: 100%;
    background-color: white;
    color: #4b5563;
}

.styled-input-2 {
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 16px;
    width: 100%;
    background-color: white;
    color: #4b5563;
}

/* Override theme styles for hover, active, and focus states */
.emi-calculator-container input[type="text"],
.emi-calculator-container input[type="number"],
.emi-calculator-container select {
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 6px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Apply a light highlight on focus/active, overriding theme styles */
.emi-calculator-container input[type="text"]:focus,
.emi-calculator-container input[type="number"]:focus,
.emi-calculator-container select:focus,
.emi-calculator-container input[type="text"]:active,
.emi-calculator-container input[type="number"]:active,
.emi-calculator-container select:active {
    outline: none;
    border-color: #007BFF;
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.1);
    background-color: white;
}

.styled-input-2,
input[type="text"],
input[type="number"],
select {
    text-align: center;
}

/* Custom arrow for select dropdown */
select.styled-input-2 {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L10 12L14 8' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 5px center;
    background-size: 20px 20px;
    padding-right: 40px;
    /* Make space for icon */
    cursor: pointer;
}

.emi-start-wrapper {
    display: flex;
    gap: 10px;
}

.result-card {
    border-radius: 10px;
    border: 1px solid #ddd;
    overflow: hidden;
}

.result-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    border-bottom: 1px solid #ddd;
}

.result-item span {
    padding: 10px 12px;
}

.result-item:last-child {
    border-bottom: none;
}

.result-item span:first-child {
    color: #6b7280;
    line-height: 1.2;
}

.result-item span:last-child {
    font-weight: 500;
    color: #1f2937;
    border-left: 1px solid #ddd;
    flex-grow: 1;
    font-size: 16px;
}

.amortization-section {
    margin-top: 0;
}

.amortization-section h3 {
    color: #1f2937;
    margin-bottom: 8px;
    text-align: center;
    margin-top: 5px;
}

.schedule-container {
    overflow-x: auto;
}

#tenure-calc-table {
    min-width: 800px;
    border-collapse: collapse;
    width: 80%;
    margin: 0 auto;
}

.amortization-section>p {
    width: 80%;
    margin: 5px auto 0;
    font-size: 15px;
    color: #6b7280;
    text-align: center;
}

#tenure-calc-table th,
#tenure-calc-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table th,
.schedule-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e5e7eb;
}

.schedule-table th {
    background: #f3f4f6;
    font-weight: 500;
    color: #4b5563;
}

.schedule-table tr:hover {
    background: #f9fafb;
}

/* Chart Holder Fix: center and stack */
.chart-holder {
    padding-top: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #e5e7eb;
}

/* Chart Container */
.chart-container {
    position: relative;
    max-width: 180px;
    width: 100%;
    height: 180px;
    /* Set a fixed height */
    margin: 10px auto 0;
    /* Add small top margin, remove bottom */
}

/* Chart Legend Below the Chart */
.chart-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    /* Reduce space between chart and legend */
    flex-wrap: wrap;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #374151;
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

.principal-color {
    background-color: #10b981;
}

.interest-color {
    background-color: #3b82f6;
}

.tenure-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.small-loader {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #10b981;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.year-header td,
.total-row td {
    background: #f3f4f6;
    font-weight: 500;
    color: #4b5563;
}

.toggle-icon {
    color: #2563eb;
    font-weight: 500;
    margin-right: 8px;
    cursor: pointer;
}

.show-mobile-only {
    display: none;
}

.hide-mobile {
    display: table-cell;
}

/* Remove number spinner */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    appearance: textfield;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.download-button {
    background-color: #0072aa;
    color: white;
    padding: 10px 15px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease,
        transform 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.download-button:hover {
    background-color: #0072aa;
    /* Keep same as default */
    transform: none;
}

.download-button:active {
    transform: scale(0.97);
}

.download-button:focus {
    /* Remove focus outline */
    outline: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    /* Keep same as default */
}

.download-button:disabled {
    background-color: #005a87;
    cursor: not-allowed;
    transform: none;
}

.button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    animation: spin 0.8s linear infinite;
}

.table-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 250px;
    /* Reserve vertical space to prevent CLS */
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #6b7280;
    font-size: 16px;
    width: 80%;
    margin: 0 auto;
}

.faq-list {
    margin-top: 1rem;
}

.faq-list dt {
    font-weight: 500;
    font-size: 1.1em;
}

.faq-list dd {
    margin-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    padding-left: 1rem;
    padding-bottom: 10px;
    border-bottom: 1px dashed #ddd;
}

/* Responsive styles */
@media (max-width: 768px) {
    .emi-calculator-container {
        padding-left: 0;
        padding-right: 0;
        background: white;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #ddd;
        border-bottom: 1px solid #ddd;
    }

    .result-card,
    .chart-section {
        border-radius: 0;
    }

    .chart-section {
        border-top: none;
    }

    .legend-item {
        font-size: 16px;
        line-height: 0.2;
    }

    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .result-section {
        margin-top: 20px;
    }

    .schedule-container {
        overflow-x: auto;
        margin: 0 auto;
        max-width: 100%;
    }

    #tenure-calc-table {
        min-width: 800px;
        /* Keep the desktop min-width to force scroll */
        width: 100%;
    }

    .table-placeholder {
        width: 100%;
        border-radius: 0;
    }

    .amortization-section>p {
        width: 100%;
        padding: 0 10px;
    }

    .amortization-section {
        margin-top: 10px;
    }

    .styled-input-1,
    .styled-input-2 {
        font-size: 17px;
        color: #4b5563;
    }

    .styled-input-2 {
        width: 80%;
        max-width: 250px;
        margin: 0 auto;
    }

    .styled-input-1 {
        width: 80%;
        margin: 0 auto;
    }

    .input-section {
        align-items: center;
        text-align: center;
    }

    .input-group {
        width: 90%;
        max-width: 310px;
    }

    .input-group>div,
    .emi-start-wrapper {
        justify-content: center;
    }

    .input-group input,
    .input-group select,
    .emi-start-wrapper input,
    .emi-start-wrapper select {
        text-align: center;
    }

    .input-group label {
        text-align: center;
        width: 100%;
    }

    .styled-input,
    input[type="text"],
    input[type="number"],
    select {
        text-align: center;
    }

    .hide-mobile {
        display: table-cell;
    }

    .show-mobile-only {
        display: none;
    }

    .chart-legend {
        gap: 9px;
    }
}