/* tools/emi-calculator/emi.css */

/* Styles for the EMI Calculator tool - Total Redesign (Focus on .emi-calculator-card) */

/* --- Overall Tool Page Layout --- */
.tool-page-main {
    padding: 4rem 0 5rem; 
    background-color: var(--bg-main);
    overflow-x: hidden; /* Prevent horizontal scroll from any element breaking layout */
}

.tool-container {
    max-width: 1400px; /* Adjusted max-width for the overall tool content */
    margin: 0 auto;
    padding: 0 var(--space-xl); /* Ensure horizontal padding to keep content off edges */
}

/* --- Tool Header (Title & Description - at the top of the main tool-container) --- */
.tool-header {
    text-align: center;
    margin-top: 2rem; 
    margin-bottom: 4rem; 
}

.tool-icon-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem; 
    margin-bottom: 1.2rem; 
}

.tool-icon {
    font-size: 3.5rem; 
    color: var(--accent-color);
}

.tool-header h1 {
    font-size: clamp(2.5rem, 6vw, 4rem); 
    font-weight: 900; 
    color: var(--text-primary);
    line-height: 1.15;
    margin-bottom: 0;
    letter-spacing: -0.03em; 
}

.tool-description {
    font-size: clamp(1rem, 2.5vw, 1.25rem); 
    color: var(--text-secondary);
    line-height: 1.7;
    max-width: 700px;
    margin: 0.8rem auto 0 auto;
}

/* --- Error Message Container --- */
.error-message-container {
    background-color: #fef2f2; 
    border: 1px solid #ef4444; 
    color: #b91c1c; 
    padding: 1rem 1.5rem; 
    border-radius: 10px; 
    margin-bottom: 2rem; 
    display: flex;
    align-items: center;
    gap: 0.75rem; 
    font-size: var(--fs-base); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
    text-align: left; 
}
html[data-theme="dark"] .error-message-container {
    background-color: #3f0f0f;
    border-color: #dc2626;
    color: #ef4444;
}
.error-message-container p { 
    margin: 0;
}


/* --- Main Calculator Card REDESIGN & RESPONSIVENESS --- */
.emi-calculator-card { 
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px; 
    box-shadow: 0 15px 50px rgba(0,0,0,0.1); 
    
    height: 85vh; /* Fixed height for larger screens */
    display: flex; 
    flex-direction: column; 
    overflow: hidden; /* Important to contain internal scrolls */

    margin-bottom: 4rem; 
    max-width: 1400px; /* Adjusted max-width for the calculator card */
    margin-left: auto;
    margin-right: auto;
    transition: all 0.3s ease-out; 
}
html[data-theme="dark"] .emi-calculator-card {
    box-shadow: 0 15px 50px rgba(0,0,0,0.25);
}

/* Inner Grid for Calculator Content (below tabs) */
.calculator-grid-wrapper {
    flex-grow: 1; 
    display: grid;
    grid-template-columns: 1.5fr 1fr; /* Input panel is significantly bigger than result */
    gap: 0; /* Gaps handled by panel padding/borders */
    overflow: hidden; /* Crucial to prevent outer scrollbar */
}

/* Input Panel (left side/top) */
.input-panel {
    display: flex;
    flex-direction: column;
    height: 100%; 
    position: relative;
    padding: var(--space-xl) var(--space-xxl) var(--space-xl) var(--space-xl); /* Generous padding */
    border-right: 1px solid var(--border-color); 
    overflow-y: auto; /* Allow internal scrolling for long forms */
    padding-bottom: var(--space-lg); /* Ensure padding for scroll area */
    background-color: var(--bg-main); 
}
html[data-theme="dark"] .input-panel {
    border-right-color: var(--border-grid-gray-dark);
    background-color: var(--bg-card); 
}
.input-panel::-webkit-scrollbar { width: 6px; }
.input-panel::-webkit-scrollbar-track { background: var(--bg-highlight); border-radius: 10px; }
.input-panel::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 10px; }
.input-panel::-webkit-scrollbar-thumb:hover { background: var(--btn-primary-hover); }


/* Result Display Panel (right side/bottom) */
.results-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute space vertically */
    height: 100%; 
    position: relative;
    overflow-y: auto; /* Internal scrolling for results */
    padding: var(--space-xl); /* Generous padding */
    background-color: var(--bg-card); 
}
.results-panel::-webkit-scrollbar { width: 6px; }
.results-panel::-webkit-scrollbar-track { background: var(--bg-highlight); border-radius: 10px; }
.results-panel::-webkit-scrollbar-thumb { background: var(--accent-color); border-radius: 10px; }
.results-panel::-webkit-scrollbar-thumb:hover { background: var(--btn-primary-hover); }


/* --- Tabs Navigation (Integrated into Card) --- */
.tabs-container {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    padding: 0.8rem 1.5rem; 
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-highlight); 
    flex-shrink: 0; 
    border-radius: 24px 24px 0 0; 
    position: relative;
    z-index: 2; 
}
html[data-theme="dark"] .tabs-container {
    background-color: var(--bg-main); 
}

.m3-tabs {
    display: flex;
    flex-grow: 1;
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    scrollbar-width: none; 
    -ms-overflow-style: none; 
    border-bottom: none; 
    padding-bottom: 0; 
    align-items: stretch; 
    gap: 0.5rem; 
}
.m3-tabs::-webkit-scrollbar { display: none; }

.m3-tab {
    flex-shrink: 0; 
    padding: 0.8rem 1.2rem; 
    background: transparent;
    border: none;
    font-size: var(--fs-sm); 
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s, background-color 0.2s, transform 0.1s;
    border-radius: 10px; 
    margin: 0.2rem; 
}

.m3-tab::after { 
    content: '';
    position: absolute;
    bottom: -0.5rem; 
    left: 50%;
    transform: translateX(-50%) scaleX(0); 
    width: calc(100% - 1rem); 
    height: 3px;
    background-color: var(--accent-color);
    border-radius: 2px;
    transition: transform 0.3s ease-out;
}

.m3-tab:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, var(--bg-highlight) 92%); 
    color: var(--text-primary);
    transform: translateY(-2px); 
}
html[data-theme="dark"] .m3-tab:hover {
    background-color: color-mix(in srgb, var(--accent-color) 12%, var(--bg-main) 88%);
}

.m3-tab.active {
    color: var(--accent-color);
    font-weight: 600;
    background-color: var(--bg-main); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
}
.m3-tab.active::after { 
    transform: translateX(-50%) scaleX(1);
}
html[data-theme="dark"] .m3-tab.active {
    background-color: var(--bg-card); 
}

.tab-scroll-button {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 36px; 
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.4rem; 
    color: var(--text-secondary);
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
    flex-shrink: 0;
    z-index: 5; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.tab-scroll-button:hover {
    background-color: var(--bg-highlight);
    color: var(--text-primary);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}
.tab-scroll-button:disabled {
    opacity: 0.4; 
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.tab-scroll-button.prev { margin-right: 0.75rem; } 
.tab-scroll-button.next { margin-left: 0.75rem; } 


.m3-tab-panels {
    padding: var(--space-xl); /* Padding for the main content area of the tab panels */
    flex-grow: 1; 
    overflow-y: hidden; /* Managed by input-panel and results-panel */
    display: flex; 
    flex-direction: column; 
}

.m3-tab-panel {
    display: none; 
    flex-grow: 1; 
    overflow-y: auto; /* Internal scrolling for content within each panel */
    padding-right: var(--space-xs); /* For scrollbar space */
    -webkit-overflow-scrolling: touch; 
    scrollbar-width: thin; 
    scrollbar-color: var(--accent-color) var(--bg-highlight); 
}
.m3-tab-panel::-webkit-scrollbar {
  width: 8px;
}
.m3-tab-panel::-webkit-scrollbar-track {
  background: var(--bg-highlight);
  border-radius: 10px;
}
.m3-tab-panel::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 10px;
}
.m3-tab-panel::-webkit-scrollbar-thumb:hover {
  background: var(--btn-primary-hover);
}

.m3-tab-panel.active {
    display: flex; 
    flex-direction: column; 
    height: 100%; 
}

.section-title-within-tab {
    font-size: clamp(1.6rem, 3.5vw, 2.2rem); 
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: left; 
}

/* --- Calculator Layouts (Input/Quick Result/Full Result) --- */
.calculator-sub-layout { /* This is the main content of each tab panel (e.g. domestic u2r) */
    display: flex;
    flex-direction: column; 
    gap: var(--space-xl); 
    align-items: stretch; 
    flex-grow: 1; 
}
.input-area-wrapper {
    flex-shrink: 0; 
    margin-bottom: 0; 
    padding: 0 0.5rem; 
}

/* --- Form Styles --- */
.form-group {
    margin-bottom: 1.5rem; 
}
.form-group label {
    font-size: var(--fs-md); 
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem; 
}
.form-control {
    width: 100%;
    padding: 0.85rem 1.2rem; 
    font-size: var(--fs-base); 
    border: 1px solid var(--border-color);
    border-radius: 10px; 
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(76, 81, 191, 0.2); 
}
html[data-theme="dark"] .form-control {
    background-color: var(--bg-card);
}
html[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.form-text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: 0.6rem; 
    display: block;
    line-height: 1.5;
}

/* NEW: Two-column grid for loan details form */
.loan-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns */
    gap: 1rem 2rem; /* Row gap, column gap */
    align-items: flex-start; /* Align items to the top of their cells */
}

.loan-details-grid .form-actions {
    grid-column: 1 / -1; /* Make action buttons span full width */
    margin-top: 1rem; /* Adjust margin as it's within the grid */
}

/* Ensure the tenure input group is inline */
.tenure-input-group {
    display: flex;
    gap: 0.5rem;
}
.tenure-input-group input {
    flex-grow: 1;
}
.tenure-input-group select {
    flex-shrink: 0;
    width: auto; /* Allow select to take natural width */
    min-width: 80px; /* Give it a minimum width */
}


.form-actions {
    display: flex;
    gap: 1rem; 
    margin-top: 2rem; 
    flex-wrap: wrap;
}
.form-actions .btn {
    flex-grow: 1;
    max-width: 250px; 
    font-size: var(--fs-base); 
    padding: 0.9rem 1.5rem; 
    border-radius: 10px; 
}
.form-actions.full-width .btn {
    max-width: none; /* Allow buttons to take full width */
}


/* --- Quick Result Display --- */
.quick-result-display-wrapper { 
    background-color: var(--bg-highlight); 
    border-radius: 16px;
    padding: var(--space-xl); 
    text-align: center;
    margin-bottom: var(--space-xl); 
    box-shadow: inset 0 0 8px rgba(0,0,0,0.05);
    display: flex; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; 
    /* Highlight styles */
    /* Updated: Use an even lighter tint for the grid SVG for a reduced opacity feel */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' width='28' height='28' fill='none' stroke='%23e0e4f8'%3e%3cpath d='M0 .5H28M.5 0V28'/%3e%3c/svg%3e"); /* Very Light Indigo tint for light theme */
    background-size: 28px 28px;
    background-position: top left;
    border: 1px solid var(--accent-color); /* Stronger border */
    box-shadow: 0 8px 25px rgba(76, 81, 191, 0.2); /* More prominent shadow */
}
html[data-theme="dark"] .quick-result-display-wrapper {
    background-color: var(--bg-main);
    /* Updated: Dark theme specific grid SVG with a lighter accent color stroke */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' width='28' height='28' fill='none' stroke='%239aa6f5'%3e%3cpath d='M0 .5H28M.5 0V28'/%3e%3c/svg%3e"); /* Darker theme, but still lighter tint */
    border-color: var(--accent-color);
    box-shadow: 0 8px 25px rgba(129, 140, 248, 0.25);
}
.emi-value-display { 
    font-size: clamp(2.5rem, 6vw, 4rem); 
    font-weight: 900;
    color: var(--accent-color);
    line-height: 1;
    margin-bottom: 0.5rem; 
    letter-spacing: -0.05em;
}
.emi-words-display { 
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-lg); 
}
.download-report-btn { 
    font-size: var(--fs-sm);
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 0; 
}


/* --- Summary Results Grid (Below Quick Result) --- */
.summary-results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: var(--space-md); 
    margin-bottom: var(--space-xl); 
}

.result-item {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 12px; 
    padding: 1rem 1.2rem; 
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem; 
}
html[data-theme="dark"] .result-item {
    background-color: var(--bg-card); 
}

.result-label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.result-value {
    font-size: var(--fs-base);
    color: var(--text-primary);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-item.total-highlight {
    background-color: color-mix(in srgb, var(--accent-color) 10%, transparent); 
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(76, 81, 191, 0.15); 
}
html[data-theme="dark"] .result-item.total-highlight {
    background-color: color-mix(in srgb, var(--accent-color) 15%, transparent);
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.15);
}
.result-item.total-highlight .result-label {
    color: var(--text-primary); 
}
.result-item.total-highlight .result-value {
    font-size: var(--fs-lg); 
    color: var(--accent-color); 
}

/* Updated: .results-panel and .payment-summary alignment */
.results-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Distribute space vertically to push last item to bottom */
    height: 100%; 
    position: relative;
    overflow-y: auto; 
    padding: var(--space-xl); 
    background-color: var(--bg-card); 
}
.results-panel > *:not(.payment-summary) {
    flex-shrink: 0; /* Prevent other sections from shrinking */
    margin-bottom: var(--space-xl); /* Add default spacing between sections */
}

.payment-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem 1.5rem;
    margin-top: auto; /* Pushes itself to the bottom, taking available space if it needs to */
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-bottom: 0; /* Remove bottom margin if it's the last element */
    /* Ensure it's centered if it has less than 100% width, though it uses grid now */
    max-width: 100%; /* Ensure it doesn't overflow */
    box-sizing: border-box; /* Include padding/border in width */
}
/* If you meant a button *within* payment-summary should be centered at bottom,
   that would require a button within .payment-summary, and then styling it.
   Assuming current structure, .payment-summary itself is the 'button/summary' area. */


/* Pie Chart Visualization Redesign */
.visualization-card {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack title, chart/legend, and summary vertically */
    align-items: center; /* Center content horizontally */
    justify-content: space-between; /* Space out elements top-to-bottom */
    min-height: 250px; /* Ensure it has enough height */
}
html[data-theme="dark"] .visualization-card {
    background-color: var(--bg-card);
}

.visualization-card .column-title { /* Ensure title has proper spacing */
    margin-bottom: 1rem; 
}

.chart-container {
    display: flex;
    flex-direction: column; /* Stacked on small screens */
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem; /* Adjust top margin within flex container */
    flex-grow: 1; /* Allow chart area to grow */
}
@media (min-width: 768px) { /* Side-by-side on larger screens */
    .chart-container {
        flex-direction: row;
        align-items: center; /* Vertically center items */
        justify-content: center;
    }
    .legend {
        padding-left: 2rem; /* More spacing from chart on desktop */
    }
}

.pie-chart-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background-color: var(--border-color); /* Default background if no data */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.08);
    /* NEW: Enhanced border/shadow for pie chart */
    border: 3px solid var(--border-color); /* Thicker border */
    box-shadow: 0 0 0 5px rgba(0,0,0,0.05), inset 0 0 10px rgba(0,0,0,0.08); /* Outer subtle glow, inner shadow */
}
html[data-theme="dark"] .pie-chart-wrapper {
    background-color: var(--border-grid-gray-dark);
    box-shadow: 0 0 0 5px rgba(255,255,255,0.02), inset 0 0 10px rgba(255,255,255,0.05);
}

.pie-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--accent-color) 0% 50%, #e74c3c 50% 100%); /* Default example */
    transition: background 0.5s ease-in-out;
}

.pie-chart-label {
    position: absolute;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: 500;
    text-align: center;
    line-height: 1.2; /* Better alignment for two lines */
}
.pie-chart-label span {
    display: block;
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.2rem;
}

.legend {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    padding-left: 0; /* Reset for mobile */
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}
.principal-color { background-color: var(--accent-color); }
.interest-color { background-color: #e74c3c; } /* Fixed color for consistency in charts */
html[data-theme="dark"] .interest-color { background-color: #ff8a80; } /* Dark theme specific interest color */


.amortization-section {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
html[data-theme="dark"] .amortization-section {
    background-color: var(--bg-card);
}


.amortization-section .column-title {
    margin-bottom: 1.5rem;
}

.table-responsive {
    overflow-x: auto; /* Allows horizontal scrolling of the table if content is too wide */
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    padding-bottom: 5px; /* Space for scrollbar */
}

.styled-table {
    width: 100%; /* Important: Table should take full available width in its container */
    border-collapse: separate; 
    border-spacing: 0;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    min-width: 600px; /* This ensures it's scrollable if narrower than content */
}

.styled-table thead th {
    background-color: var(--accent-color);
    color: var(--btn-primary-text);
    padding: 0.8rem 1rem;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid var(--accent-color);
    position: sticky;
    top: 0;
    z-index: 10;
}
/* Rounded corners for first and last header cells */
.styled-table thead th:first-child {
    border-top-left-radius: 12px;
}
.styled-table thead th:last-child {
    border-top-right-radius: 12px;
}

.styled-table tbody tr {
    transition: background-color 0.2s ease;
}
.styled-table tbody tr:nth-child(even) {
    background-color: var(--bg-highlight);
}
html[data-theme="dark"] .styled-table tbody tr:nth-child(even) {
    background-color: var(--bg-main);
}
.styled-table tbody tr:hover {
    background-color: color-mix(in srgb, var(--accent-color) 5%, var(--bg-highlight) 95%);
}
html[data-theme="dark"] .styled-table tbody tr:hover {
    background-color: color-mix(in srgb, var(--accent-color) 8%, var(--bg-main) 92%);
}


.styled-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: right; /* Default align numbers to right */
}
.styled-table td:first-child { text-align: center; } /* Align # to center */
.styled-table td:nth-child(2) { text-align: left; } /* Align Payment Date to left */

/* Prepayment row styling */
.styled-table tbody tr.prepayment-row {
    background-color: color-mix(in srgb, var(--accent-color) 10%, transparent);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent-color); /* Stronger border */
}
html[data-theme="dark"] .styled-table tbody tr.prepayment-row {
    background-color: color-mix(in srgb, var(--accent-color) 15%, transparent);
    border-bottom: 2px solid var(--accent-color);
}
.styled-table tbody tr.prepayment-row td {
    color: inherit; /* Ensure text color is inherited */
}
.styled-table tbody tr.prepayment-row td:nth-child(5) {
    color: var(--text-secondary); /* Dashes for interest on prepayment */
}


.subsidy-note {
    margin-top: 1.5rem; 
    padding: 0.8rem 1.2rem; 
    background-color: var(--bg-highlight);
    border: 1px solid var(--border-color);
    border-radius: 10px; 
    font-size: var(--fs-sm); 
}
html[data-theme="dark"] .subsidy-note {
    background-color: var(--bg-main); 
}

.breakdown-title {
    margin-top: 2.5rem; 
    margin-bottom: 0.8rem; 
    text-align: left;
}

.calculation-breakdown-box {
    background-color: var(--bg-main);
    border: 1px dashed var(--border-color);
    border-radius: 10px; 
    padding: 1.2rem; 
    font-family: 'Fira Code', monospace;
    font-size: var(--fs-sm);
    color: var(--text-primary);
    white-space: pre-wrap; 
    word-break: break-all; 
    overflow-x: auto; 
    max-height: 250px; 
}
html[data-theme="dark"] .calculation-breakdown-box {
    background-color: var(--bg-card);
}

.result-actions {
    margin-top: 2.5rem; 
    justify-content: flex-end; 
}


/* --- Info/FAQ/CTA sections (general card styles) --- */
.info-section, .faq-section, .support-tool-cta { 
    /* The .card class already gives it base styles */
    padding: var(--space-xxl); 
    margin-top: 4rem;
    margin-bottom: 4rem;
    border-radius: 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); 
}

.info-section .column-title, .faq-section .column-title, .support-tool-cta h3 { 
    font-size: var(--fs-xl); 
    font-weight: 700;
    margin-bottom: 1rem; 
    text-align: left;
}
.info-section p, .faq-section p, .support-tool-cta p { 
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem; 
    padding: 0 0.5rem; 
}
.info-section p:last-of-type { 
    margin-bottom: 0;
}
.info-section .info-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}
.info-section .info-list li {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
    padding-right: 0.5rem;
}
.info-section .info-list li::before {
    content: '•';
    color: var(--accent-color);
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Specific styling for the How-To list */
.how-to-list { 
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-top: 1rem;
}
.how-to-list li {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.6;
    padding-right: 0.5rem;
}
.how-to-list li strong {
    color: var(--text-primary);
}


/* Support Tool CTA */
.support-tool-cta { 
    text-align: center;
}
.support-tool-cta .support-tool-icon {
    font-size: 4rem; 
    color: var(--accent-color);
    margin-bottom: 1.5rem; 
}
.support-tool-cta p {
    max-width: 600px; /* Keep text centered and readable */
    margin-left: auto;
    margin-right: auto;
}
.support-tool-cta .coffee-btn-small {
    font-size: var(--fs-base); 
    padding: 0.9rem 1.8rem; 
    border-radius: 10px; 
}

/* --- PDF Name Modal --- */
/* (These styles are usually in popup.css, but kept here for completeness based on prev context) */
.modal-overlay { 
    display: none; /* Controlled by JS */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0; /* For transition */
    visibility: hidden; /* For transition */
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(20px);
}
.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: var(--space-xl);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    position: relative;
    max-width: 450px;
    width: 90%;
    text-align: center;
    opacity: 0; /* For transition */
    transform: scale(0.95); /* For transition */
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.modal-overlay.visible .modal-content {
    opacity: 1;
    transform: scale(1);
}


.modal-content .modal-title {
    font-size: var(--fs-xl); 
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
.modal-content .modal-description {
    font-size: var(--fs-base); 
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.modal-content .modal-close-btn { 
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.8rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    padding: 5px;
    line-height: 1;
    border-radius: 50%;
}
.modal-content .modal-close-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-highlight);
}
.modal-content .form-control {
    text-align: center;
    font-size: var(--fs-base);
    padding: 0.85rem 1rem;
    border-radius: 10px;
}
.modal-content .modal-confirm-btn {
    width: 100%;
    font-size: var(--fs-base);
    padding: 0.9rem 1.5rem;
    border-radius: 10px;
}


/* --- Responsive Adjustments --- */
@media (max-width: 992px) { /* Tablets and larger mobiles */
    .tool-page-main {
        padding: 2.5rem 0 3.5rem;
    }
    .tool-header {
        margin-top: 2rem; 
        margin-bottom: 2.5rem;
    }
    .tool-icon {
        font-size: 2.5rem;
    }
    .tool-header h1 {
        font-size: clamp(1.8rem, 4.5vw, 2.5rem);
    }
    .tool-description {
        font-size: var(--fs-base);
        margin-top: 0.5rem;
    }

    .emi-calculator-card {
        padding: var(--space-lg); /* Adjusted padding for smaller screens */
        height: auto; /* Allow height to adjust on smaller screens */
        min-height: 70vh; /* Keep a minimum height */
    }

    /* Stack inner grid columns into a single column on smaller screens */
    .calculator-grid-wrapper {
        grid-template-columns: 1fr; /* Single column layout */
        gap: var(--space-xl); /* Adjusted gap between stacked panels */
        padding: var(--space-md); /* Adjusted padding */
    }
    .input-panel {
        padding-right: 0;
        border-right: none; /* Remove vertical divider */
        padding-bottom: var(--space-lg); /* Add bottom padding when stacked */
        border-bottom: 1px solid var(--border-color); /* Add a bottom border */
    }
    html[data-theme="dark"] .input-panel {
        border-bottom-color: var(--border-grid-gray-dark);
        border-right-color: transparent; 
    }
    .results-panel {
        padding-left: 0;
        padding-top: var(--space-lg); /* Add top padding when stacked */
        margin-top: 0; 
        border-top: 1px solid var(--border-color); /* Add a top border */
    }
    html[data-theme="dark"] .results-panel {
        border-top-color: var(--border-grid-gray-dark);
    }

    /* Mobile specific adjustments to payment-summary */
    .payment-summary {
        margin-top: var(--space-xl); /* Reset from auto for mobile */
    }


    .m3-tab {
        padding: 0.8rem 1.2rem;
        font-size: var(--fs-sm);
    }
    .tab-scroll-button {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }
    .section-title-within-tab {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }

    .loan-details-grid {
        grid-template-columns: 1fr; /* Stack columns on smaller screens */
        gap: 1rem;
    }
    .loan-details-grid .form-actions {
        grid-column: auto; /* Revert span behavior */
    }
    
    .calculator-sub-layout {
        flex-direction: column; 
        gap: 1.5rem;
    }
    .input-area-wrapper {
        min-width: unset; 
        width: 100%;
    }
    .quick-result-display-wrapper { 
        font-size: var(--fs-base);
        padding: 1.5rem; 
        margin-bottom: var(--space-lg); 
    }
    .emi-value-display {
        font-size: 2.5rem; 
    }
    .emi-words-display {
        font-size: var(--fs-sm);
        margin-bottom: var(--space-md); 
    }
    .download-report-btn {
        font-size: var(--fs-xs); 
        padding: 0.6rem 1.2rem;
    }

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
    }
    .form-actions .btn {
        max-width: 100%;
        font-size: var(--fs-sm);
        padding: 0.7rem 1.2rem;
    }

    .result-area { /* This class is not explicitly in current HTML. Using generic card/section styles */
        padding: 1.5rem;
        margin-top: 0; 
    }
    .result-area .column-title {
        font-size: var(--fs-base);
        margin-bottom: 1rem;
    }
    .result-grid {
        grid-template-columns: 1fr; 
        gap: 0.75rem;
    }
    .result-item {
        padding: 0.6rem 0.8rem;
    }
    .result-label {
        font-size: var(--fs-xs);
    }
    .result-value {
        font-size: var(--fs-sm);
    }
    .result-item.total-highlight .result-value {
        font-size: var(--fs-base);
    }
    .subsidy-note, .warning-note {
        padding: 0.6rem 0.8rem;
        font-size: var(--fs-xs);
    }
    .breakdown-title {
        margin-top: 1.5rem;
    }
    .calculation-breakdown-box {
        padding: 0.8rem;
        font-size: 0.75rem;
    }
    .result-actions {
        margin-top: 1.5rem;
    }

    .info-section, .faq-section, .support-tool-cta {
        padding: 2.5rem; 
        margin-top: 3rem;
        margin-bottom: 3rem;
        border-radius: 16px; 
        box-shadow: 0 5px 15px rgba(0,0,0,0.05); 
    }
    .info-section .column-title, .faq-section .column-title, .support-tool-cta h3 { 
        font-size: var(--fs-lg); 
        margin-bottom: 0.75rem; 
    }
    .info-section p, .faq-section p, .support-tool-cta p {
        font-size: var(--fs-sm);
        margin-bottom: 0.5rem; 
        padding: 0; 
    }
    .info-list li,
    .how-to-list li {
        font-size: var(--fs-sm);
        padding-right: 0; 
    }
    .tariff-slabs-table {
        font-size: var(--fs-sm);
    }
    .tariff-slabs-table th, .tariff-slabs-table td {
        padding: 0.7rem;
    }
    .how-to-list li {
        font-size: var(--fs-sm);
    }

    .support-tool-cta .support-tool-icon {
        font-size: 3rem;
    }
    .support-tool-cta .coffee-btn-small {
        font-size: var(--fs-xs);
        padding: 0.6rem 1.2rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
    .modal-content .modal-title {
        font-size: var(--fs-base);
    }
    .modal-content .modal-description {
        font-size: var(--fs-sm);
    }
    .modal-content .form-control {
        font-size: var(--fs-sm);
    }
    .modal-content .modal-confirm-btn {
        font-size: var(--fs-sm);
    }
    .modal-content .modal-close-btn {
        width: 36px;
        height: 36px;
        font-size: 1.3rem;
    }
}

@media (max-width: 576px) { /* Smaller mobiles */
    .tool-page-main {
        padding: 1.5rem 0 2rem;
    }
    .tool-header {
        margin-top: 1.5rem; 
        margin-bottom: 1.5rem;
    }
    .tool-icon {
        font-size: 2rem;
    }
    .tool-header h1 {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }
    .tool-description {
        font-size: var(--fs-sm);
        margin-top: 0.4rem;
    }

    /* Mobile: Card 100% width, 5px padding left/right */
    .emi-calculator-card {
        padding: 1rem 5px; /* Top/bottom 1rem, left/right 5px */
        width: calc(100% - 10px); /* 100% minus total horizontal padding */
        margin-left: 5px; /* Push to the right to make up for padding */
        margin-right: 5px;
        height: auto; 
        min-height: 60vh; 
        box-sizing: border-box; /* Include padding in the width calculation */
    }
    /* Adjust input and results panels within the tighter card padding */
    .input-panel, .results-panel {
        padding: var(--space-md) var(--space-sm); /* Reduced internal padding for very small screens */
    }


    .m3-tabs {
        padding-bottom: 0.3rem;
        gap: 0.2rem;
    }
    .m3-tab {
        padding: 0.6rem 0.8rem;
        font-size: var(--fs-xs);
    }
    .tab-scroll-button {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    .section-title-within-tab {
        font-size: 1.2rem;
        margin-bottom: 0.8rem;
    }

    .quick-result-display-wrapper {
        font-size: var(--fs-sm);
        padding: 1rem; /* Tighter padding */
        margin-bottom: var(--space-md); /* Less space */
    }
    .emi-value-display {
        font-size: 2rem; /* Adjusted for very small mobile */
    }
    .emi-words-display {
        font-size: var(--fs-xs); /* Smaller words display */
        margin-bottom: var(--space-xs); /* Less space */
    }
    .download-report-btn {
        font-size: var(--fs-xs);
        padding: 0.5rem 1rem;
    }


    .form-group label {
        font-size: var(--fs-sm);
    }
    .form-control {
        padding: 0.5rem 0.75rem;
        font-size: var(--fs-sm);
    }
    .form-text {
        font-size: 0.7rem;
    }
    .form-actions {
        margin-top: 0.8rem;
    }
    .form-actions .btn {
        font-size: var(--fs-xs);
        padding: 0.5rem 0.8rem;
    }

    .result-area { /* This class is not explicitly in current HTML. Using generic card/section styles */
        padding: 1rem;
        margin-top: 0; 
    }
    .result-area .column-title {
        font-size: var(--fs-sm);
    }
    .result-item {
        padding: 0.5rem 0.6rem;
    }
    .result-label {
        font-size: 0.65rem;
    }
    .result-value {
        font-size: var(--fs-xs);
    }
    .result-item.total-highlight .result-value {
        font-size: var(--fs-sm);
    }
    .subsidy-note, .warning-note {
        padding: 0.5rem 0.6rem;
        font-size: 0.7rem;
    }
    .breakdown-title {
        margin-top: 1rem;
    }
    .calculation-breakdown-box {
        padding: 0.6rem;
        font-size: 0.7rem;
    }

    .info-section, .faq-section, .support-tool-cta {
        padding: 1.5rem; 
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
    }
    .info-section .column-title, .faq-section .column-title, .support-tool-cta h3 {
        font-size: var(--fs-sm);
        margin-bottom: 0.5rem; 
    }
    .info-section p, .faq-section p, .support-tool-cta p {
        font-size: var(--fs-xs);
        margin-bottom: 0.4rem; 
        padding: 0; 
    }
    .info-list li,
    .how-to-list li {
        font-size: var(--fs-xs);
        padding-right: 0;
        margin-bottom: 0.3rem; 
    }
    .tariff-slabs-table {
        font-size: 0.6rem; 
    }
    .tariff-slabs-table th, .tariff-slabs-table td {
        padding: 0.4rem;
    }
    .how-to-list li strong {
        font-size: var(--fs-xs);
    }

    .support-tool-cta .support-tool-icon {
        font-size: 2.2rem;
    }
    .support-tool-cta .coffee-btn-small {
        font-size: var(--fs-xs);
        padding: 0.5rem 1rem;
    }

    .modal-content {
        padding: 1rem;
    }
    .modal-content .modal-title {
        font-size: var(--fs-sm);
    }
    .modal-content .modal-description {
        font-size: var(--fs-xs);
    }
    .modal-content .form-control {
        font-size: var(--fs-xs);
    }
    .modal-content .modal-confirm-btn {
        font-size: var(--fs-xs);
    }
    .modal-content .modal-close-btn {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }
}