@import url('https://api.fontshare.com/v2/css?f[]=cabinet-grotesk@100,200,300,400,500,600,700,800,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap');

:root {
    --bg-dark: #1D1D20;
    --primary-card-bg: #404042;
    --secondary-card-bg: #575757;
    --result-card: #2B2B2B; 
    --border-color: #404042;
    --border-color2: #727272;
    --text: #ffffff;
    --black: #000000;
    --text-muted: #BEBEBE;
    --green: #AED0B6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

button,
select,
input,
textarea {
    font-family: inherit; 
}

body {
    font-family: 'DM Sans', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    position: relative;
    z-index: 1200;
    border-bottom: 1px solid var(--green);
    font-family: 'Cabinet Grotesk', sans-serif;
    padding: 20px 80px; /* Let padding define height for responsiveness */
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--text);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-title {
    font-size: 2.2rem;
    font-weight: 600;
}

.header-buttons {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text);
    padding: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.header-btn:hover {
    color: var(--green);
}

.header-btn-icon {
    width: 20px;
    height: 20px;
}

.mobile-feature-banner { display: none; }

/* ▼▼▼ MOBILE DRAWER STYLES - LOGICALLY GROUPED ▼▼▼ */
.menu-btn {
  display: none; /* Hide hamburger on desktop by default */
  background: none;
  border: none;
  padding: 12px;
  cursor: pointer;
}

.drawer-overlay {
  position: fixed;
  top: var(--header-height, 83px); /* Use JS-calculated variable */
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  top: var(--header-height, 83px); /* Use JS-calculated variable */
  right: 0;
  width: 80%;
  max-width: 300px;
  height: calc(100% - var(--header-height, 83px));
  background: var(--result-card);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1100;
  display: flex;
  flex-direction: column;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.drawer-close {
  background: none;
  border: none;
  padding: 1rem;
  align-self: flex-end;
  cursor: pointer;
}

/* This is for the cloned buttons inside the drawer */
.drawer-buttons {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}
/* ▲▲▲ END OF MOBILE DRAWER STYLES ▲▲▲ */


.container {
    max-width: 100%;
    padding: 64px 80px;
    width: 100%;
}

h1 {
	font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 30px;
    color: var(--text);
}

/* ... (the rest of your original CSS rules are unchanged) ... */

.icon-bg {
    background-color: var(--green);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;      /* vertical center */
    justify-content: center;  /* horizontal center */
    line-height: 1;
    vertical-align: middle;
}

.icon-bg > img {
    width: 20px;
    height: 20px;
    display: block;
    object-fit: contain;
}

.calculator-inputs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
}

.input-group {
    max-width: 100%;
    width: 306px;
    flex-shrink: 0; 
    background-color: var(--primary-card-bg);
    border-radius: 4px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: var(--text);
    font-size: 1.0rem;
}

.input-field-wrapper {
    display: flex;
    gap: 8px;
}

.input-field-wrapper input {
    flex: 1; 
    background-color: var(--primary-card-bg);
    border: 1px solid var(--green);
    border-radius: 0px;
    color: var(--text);
    padding: 10px;
    outline: none;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1.5rem;
}

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

.input-field-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 600;
}

.input-field-wrapper input:not(:placeholder-shown) {
    color: var(--text);
    font-weight: 600; 
}

.input-field-wrapper .prefix,
.input-field-wrapper .suffix {
    height: 58px;
    padding: 16px 8px;
    font-family: 'Cabinet Grotesk', sans-serif;
    color: var(--text);
	background-color: #58585B;
	border: 1px solid var(--green);
    display: flex;
    align-items: center;
    border-radius: 0px;
    font-size: 24px;
    font-weight: 700;
}

.results-box {
    background-color: var(--result-card);
    border: 1px solid var(--green);
    border-radius: 4px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--green);
    position: relative;
}

.results-header h2 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
}

.settings-btn {
    background: var(--primary-card-bg);
    border: 1px solid var(--green);
    color: var(--text);
    border-radius: 0px;
    padding: 12px;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.summary-grid {
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 16px 48px; /* Row gap and column gap */
}

.summary-item {
    display: flex;
    flex-direction: column; /* Stack main value and sub-label vertically */
    gap: 4px;
    width: auto; /* Override fixed width */
}

.summary-main {
    display: flex;
    align-items: baseline; /* Aligns the text nicely */
    justify-content: space-between;
    gap: 12px;
}

.chart-div {
    flex-direction: column;        
    align-items: flex-start;
    gap: 6px;
  }

.summary-item .label {
    color: var(--text);
    font-size: 1rem;
    font-weight: 400;
    flex-shrink: 0;
    width: auto; /* Allow label width to be flexible */
}

.summary-main .value-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-left: auto; /* Push to the right */
}

.summary-item .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    flex-grow: 1; /* Allow value to take space */
    width: auto;
}

.value.highlighted {
    color: var(--green); /* Or your preferred highlight color */
    font-weight: 700;
}

.savings-percent {
    font-size: 1rem;
    font-weight: 700;
    color: var(--green); /* Red for the negative percentage */
    background-color: rgba(174, 208, 182, 0.1);
    padding: 4px;
    white-space: nowrap;
    margin-left: 8px;
    border-radius: 4px;
}

.summary-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: left;
    margin-left: 0;
    padding-right: 30px; /* Aligns it under the percentage */
    min-height: 1.2em; /* Prevents layout shift when text appears */
    margin-top: 4px;
}

.summary-sub.hidden, .savings-percent.hidden {
    visibility: hidden;
}

.summary-sub .savings {
    font-weight: 700;
    color: var(--green); /* Green for the savings amount */
}

.mobile-legend { 
  display: none; 
}

.tenure-savings-container.hidden, .header-prepayment-cta.hidden {
    display: none;
}

.tenure-savings-container {
    padding: 16px 0;
    margin: 0 24px;
    font-size: 0.875rem;
    color: var(--text);
    font-weight: 500;
}

.tenure-highlight {
    color: var(--green);
    font-weight: 600;
    font-size: 1rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 24px 108px;
    padding: 24px;
}

.summary-item {
    display: flex;
    width: 320px;
    flex-direction: column;
    gap: 8px;
    width: auto;
}

.summary-item .label {
    font-size: 1rem;
    width: 180px;
    color: var(--text);
}

.summary-item .value {
    font-size: 1.5rem;
    width: 140px;
    text-align: end;
    font-weight: 600;
    color: var(--text);
}

.amortization-table-container {
    border-radius: 0px;
    margin: 0px 24px 24px 24px;
    overflow: hidden;
}

.amortization-table {
    width: 100%;
    border-collapse: collapse;
}

.year-row td {
    background-color: var(--primary-card-bg);
    border-bottom: 1px solid var(--green);
    padding: 16px 20px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.year-row td .year-cell{
  display: flex;
  align-items: center;
  justify-content: space-between; /* <-- separates year and icon */
  width: 100%;
}

.year-row.open td {
    border-bottom: none;
}

.year-row:last-of-type td {
    border-bottom: none;
}

.toggle-icon {
    transition: transform 0.3s ease-in-out;
}

.year-row.open .toggle-icon {
    transform: rotate(180deg);
}

.details-container-row td {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--primary-card-bg);
}

.details-table td {
    padding: 16px 24px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    border-right: 1px solid var(--border-color2);
    border-bottom: 1px solid var(--border-color2); 
}

.details-table th {
    background-color: var(--green);
    color: var(--black); 
    font-size: 1rem;
    font-weight: 500;
    padding: 8px 24px;
    text-align: right;
    border-right: 1px solid var(--border-color2);
    border-bottom: 1px solid var(--border-color2); 
}

.details-table th:last-child,
.details-table td:last-child {
    border-right: none;
}

.details-table tr > th:first-child,
.details-table tr > td:first-child {
    text-align: left;
}

.summary-row {
    background-color: var(--secondary-card-bg);
    font-weight: 700;
    border-bottom: 1px solid var(--green);
}

.summary-row td {
    border-bottom: none;
}

.hidden {
    display: none;
}

.date-warning {
    color: #FF8A8A;
    padding: 0 24px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    font-style: italic;
    text-align: left;
}

.placeholder-row td {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    background-color: var(--primary-card-bg);
}

.modal-card {
    position: absolute;
    top: 80%;
    right: 20px;
    margin-top: 4px;
    background-color: var(--result-card);
    border-radius: 0px;
    border: 1px solid var(--green);
    width: 100%;
    max-width: 280px;
    z-index: 1000;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal-card.hidden {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.modal-card h3 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 20px 16px 16px 16px;
    text-align: left;
    color: var(--text);
}

.modal-card .divider {
    height: 1px;
    background-color: var(--green);
}

.modal-card label {
    font-size: 0.875rem;
    margin: 16px 16px 8px 16px;
    display: block;
    color: var(--text);
    font-weight: 500;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--green);
    padding: 24px;
}

.date-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--primary-card-bg);
    border: 1px solid var(--green);
    border-radius: 0px;
    padding: 12px 16px;
    margin: 0px 16px 20px 16px;
}

.date-input-wrapper [data-toggle] {
    cursor: pointer;
}

.date-input-wrapper input {
    flex-grow: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Cabinet Grotesk', sans-serif;
}

.date-input-wrapper .material-symbols-outlined {
    color: var(--text-muted);
}

.prepayment-cta-container {
    margin-top: 40px;
}

.prepayment-btn-wrapper {
    display: inline-block;
    background-color: #CEE4D3;
    border-radius: 0px;
    transition: transform 0.2s ease-out;
}

.btn-layered {
    display: block;
    position: relative;
    border: none;
    border-radius: 0px;
    padding: 16px 20px;
    font-size: 1.25rem;
    font-weight: 500;
    font-family: 'Cabinet Grotesk', sans-serif;
    cursor: pointer;
    background-color: #AED0B6;
    color: var(--black);
    transition: all 0.2s ease-out;
}

.prepayment-btn-wrapper:hover .btn-layered {
    transform: translate(-6px, -6px);
    background-color: var(--secondary-card-bg);
    color: var(--text);
}

.prepayment-btn-wrapper:active .btn-layered {
    transform: translate(-2px, -2px);
    transition: transform 0.1s;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 80px;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.prepayment-modal-card {
    background-color: var(--result-card);
    border: 1px solid var(--green);
    border-radius: 0px;
    width: 100%;
    height: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--green);
    padding: 24px;
}

.modal-header h2 {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    flex-grow: 1;
    overflow-y: auto;
}

.date-picker-icon {
    width: 20px;
    height: 20px;
}

.modal-tabs {
    display: flex;
}

.tab-btn {
    background: none;
    border: none;
    padding: 4px 0px;
    font-size: 1rem;
    font-weight: 500;
    width: 100px;
    cursor: pointer;
    position: relative;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--green);
    transform: scaleX(0);
    transition: transform 0.3s ease-in-out;
}

.tab-btn.active {
    color: var(--text);
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.prepayment-table-container {
    display: inline-block; 
    border: 1px solid var(--border-color2);
    overflow: hidden;
}

.prepayment-table-container .details-table {
    table-layout: fixed;
    width: auto;
}

.prepayment-table-container .details-table th {
    text-align: left;
    width: 100%;
    table-layout: fixed;
}

.prepayment-table-container .details-table th:nth-child(3) {
    text-align: right;
}

.prepayment-table-container .details-table td:nth-child(3) .input-field-wrapper{
  display: flex;       /* already is, but keep it explicit here */
  width: 100%;
}

.prepayment-table-container .details-table td:nth-child(3) input{
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;        /* critical: allows flex child to grow/shrink to fill */
  text-align: right;   /* keep your right align; remove if not needed */
}

.prepayment-table-container .details-table th,
.prepayment-table-container .details-table td {
    width: 33.33%; 
    max-width: 250px;
}

.prepayment-table-container .details-table td {
    padding: 8px 24px;
}

.prepayment-table-container .details-table tfoot td {
    border-right: none;
}

.prepayment-table-container .details-table th:last-child {
    text-align: right;
}



.prepayment-table-container .prepayment-date-cell .input-field-wrapper {
    /* This is the first key step */
    display: flex;
    /* This vertically centers the text and the icon */
    align-items: center;
    /* This ensures the wrapper fills the entire table cell */
    width: 100%;
}

.prepayment-table-container .input-field-wrapper .prefix {
    font-family: 'Cabinet Grotesk', sans-serif;
    color: var(--text);
    text-align: right;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    background: none;
    height: auto;
    padding: 0px;
}

.prepayment-table-container .prepayment-date-cell .input-field-wrapper input {
    /* THIS IS THE MAGIC PROPERTY */
    flex-grow: 1;
    /* This is a common flexbox fix to prevent inputs from overflowing */
    min-width: 0;
}

.prepayment-table-container td:not(.prepayment-date-cell) .input-field-wrapper {
    border: none;
    background: none;
    padding: 0;
    margin: 0;
}

/* ===== THIS IS THE CORRECTED RULE FOR THE TABLE INPUTS ===== */
.prepayment-table-container .input-field-wrapper input {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    padding: 0px;
    border: none;
    background: none;
    outline: none;
}

.prepayment-table-container input::placeholder {
    color: var(--text-muted);
}

.add-row-btn {
    padding: 8px 16px 8px 0px;
    font-family: 'Cabinet Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    color: var(--green);
}

.radio-group{
    background-color: var(--primary-card-bg);
    max-width: 308px;
    padding: 24px;
    display: flex;
    cursor: pointer;
    border: 1px solid var(--green);
}

.radio-group input[type="radio"] {
    appearance: none;
    width: 0;
    height: 0;
    visibility: hidden;
    display: none;
}

.radio-group label {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    gap: 12px;
    align-items: center;
    user-select: none;
}

.radio-group input[type="radio"] + label::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    background-image: url('assets/radio.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.2s ease;
    flex-shrink: 0;
}

.radio-group input[type="radio"]:checked + label::before {
    background-image: url('assets/radio-selected.svg');
}

.how-to-use-modal-card {
    background-color: var(--result-card);
    border: 1px solid var(--green);
    border-radius: 0px;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column; 
}

.how-to-use-body {
    padding: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}

.youtube-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
}

.youtube-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: none;
}

.summary-mobile { display: none; }
.summary-desktop { display: table-row; }

.header-prepayment-cta {
    box-sizing: border-box;
    content-visibility: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    margin: 24px;
    padding: 16px 24px;
    position: relative;
    width: calc(100% - 48px);
    height: 100%;
}

.header-prepayment-cta-border {
    position: absolute;
    border: 1px solid #aed0b6;
    inset: 0;
    pointer-events: none;
}

.header-prepayment-cta-content {
    flex-basis: 0;
    content-visibility: auto;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    align-items: center;
    justify-content: center;
    line-height: 0;
    min-height: 1px;
    min-width: 1px;
    position: relative;
    flex-shrink: 0;
}

.header-prepayment-cta-title {
    font-family: 'Cabinet Grotesk', sans-serif;
    font-weight: bold;
    font-style: normal;
    position: relative;
    flex-shrink: 0;
    font-size: 24px;
    width: 100%;
    color: var(--text);
}

.header-prepayment-cta-title p {
    line-height: 1.4;
}

.header-prepayment-cta-description {
    display: flex;
    flex-direction: column;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    justify-content: flex-end;
    position: relative;
    flex-shrink: 0;
    font-size: 16px;
    width: 100%;
    color: var(--text-muted);
}

.header-prepayment-cta-description p {
    line-height: 1.4;
}

.chart-container {
    width: 100%;
    margin: 0 auto;
    flex: 1;
    max-width: 450px;
    max-height: 450px;
}

.chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

.chart2-container {
    max-height: 600px;
    margin: 0 auto;
    flex: 2;
    max-width: 450px;
    max-height: 370px;
}

.chart2-container canvas {
    max-width: 100%;
    height: auto !important;
}

.charts-div {
    display: flex;
    gap: 40px; /* Add some space between the charts */
    align-items: flex-start; /* Align items to the start of the cross axis */
}

/* Restore .summary-item width */
.summary-item {
    display: flex;
    width: 100%; 
    flex-direction: column;
    gap: 8px;
}

/* ▼▼▼ RESPONSIVE STYLES - CLEANLY MERGED ▼▼▼ */

@media (max-width: 1118px) {
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 16px 0;
  }
  
  /* Stack charts vertically on tablet */
  .charts-div {
    flex-direction: column;
    gap: 24px;
  }
  
  .chart-container {
    width: 100%;
    max-width: 450px;
    max-height: 450px;
    flex: none;
  }
  
  .chart2-container {
    width: 100%;
    max-width: 100%;
    max-height: 370px;
    flex: none;
  }
  
  .chart-container canvas,
  .chart2-container canvas {
    width: 100% !important;
    height: auto !important;
  }
}

@media (max-width: 760px) {

        .container { 
        padding: 24px; /* Adjust padding for smaller screens */
    }
    .calculator-inputs { 
        flex-direction: column; 
        width: 100%; /* Ensure inputs take full width */
    }
    .input-group {
        width: 100%; /* Ensure input groups take full width */
    }
    .summary-grid { 
        grid-template-columns: 1fr; 
    }
    .header {
        padding: 16px 24px; /* Adjust header padding on mobile */
    }
    
    /* Show hamburger & hide desktop buttons */
    .menu-btn {
        display: block;
    }
    .header-buttons {
        display: none;
    }

    .mobile-feature-banner{
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--green);
    color: var(--black);
    padding: 12px 24px;            /* aligns with your mobile header/container gutters */
    font-weight: 500;
    font-size: 1rem;
  }

  /* Kill desktop header row – legend replaces it on mobile */
  .details-table { width: 100%; border: none; }
  .details-table thead { display: none; }
   .details-table tbody tr,
  .details-table tfoot tr {
    display: block;
    width: 100%;
  }
    
  .details-table thead { display: none; }        /* legend replaces the thead */

  /* Make sure the cell that wraps the table doesn’t clip edges */
  .details-container-row td { padding: 0; }

  .details-table td {
    box-sizing: border-box;  /* padding won’t cause overflow */
  }

  .details-table tbody td:first-child,            /* Month */
  .details-table tbody td:nth-child(2),           /* To Principal */
  .details-table tbody td:nth-child(3),           /* To Interest  */
  .details-table tbody td:nth-child(4),           /* Total Payment */
  .details-table tbody td:last-child {            /* Balance */
    font-size: 14px;
  }

    .summary-desktop { display: none; }
  .summary-mobile  { display: table-row; }

  /* mobile summary block styling */
  .details-table tfoot .summary-row td { padding: 0; }

  .details-table tfoot .summary-row:not(.summary-mobile) {
  display: none !important;
}

    .details-table tfoot tr.summary-row.summary-mobile > td {
        box-sizing: border-box;
    }

  .summary-block {
    background: var(--secondary-card-bg);
    padding: 8px 16px;
    width: 100%;
    /* box-sizing: border-box; */
  }

  .summary-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    width: 100%;
  }

  .summary-title { font-weight: 500; font-size: 0.875rem; }
  .summary-balance { font-weight: 500; }

  .summary-values {
    display: grid;
    grid-template-columns: 32.5% 32.5% 35%;
    width: 100%; /* Ensure full width */
    box-sizing: border-box;
  }
  .summary-values.with-prepay {
    grid-template-columns: 25% 25% 25% 25%;
    width: 100%;
  }
  .summary-values .sv {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
  }
  .summary-values .sv:last-child { text-align: right; }

  /* ---------- Legend (green card) ---------- */
  .mobile-legend { display: block; }

  .legend-wrap{
    display: flex;
    flex-direction: column;
    background: var(--green);
    color: var(--black);
    width: 100%;
    box-sizing: border-box;
    padding: 8px 16px;
  }

  /* Row 1: Month (left) | Balance (right) */
  .legend-row.legend-top{
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .legend-title{ font-size: 0.875rem; font-weight: 500; }
  .legend-title.legend-right{
    margin-left: auto;
    text-align: right;
  }

  /* Row 2: labels 30% | 30% | 40% */
  .legend-row.legend-bottom{
    display: flex;
    align-items: center;
    margin-top: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    gap: 0; /* keep exact widths */
  }
  .legend-bottom .col-30{ flex: 0 0 32.5%; }
  .legend-bottom .col-40{ flex: 0 0 35%; margin-left: auto; text-align: right; }

  /* ---------- Rows (data) ---------- */
  .details-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    border-bottom: 1px solid var(--border-color2);
  }

  /* Month (top line, left) */
  .details-table tbody td:first-child {
    padding: 8px 0px 4px 16px;
    order: 0;
    flex: 1 1 50%;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 500;
    text-align: left !important;
  }

  /* Numbers line: 30% | 30% | 40%  */
  .details-table tbody td:nth-child(2),
  .details-table tbody td:nth-child(3),
  .details-table tbody td:nth-child(4) {
    order: 1;
    border: none;
    background: transparent;
    font-weight: 500;
    font-size: 0.875rem;
  }

  .details-table tbody td:nth-child(2) { width: 32.5%; padding: 4px 0px 8px 16px; text-align: left !important; }   /* To Principal */
  .details-table tbody td:nth-child(3) { width: 32.5%; padding: 4px 0px 8px 0px; text-align: left !important; }   /* To Interest  */
  .details-table tbody td:nth-child(4) { width: 35%; padding: 4px 16px 8px 0px; text-align: right !important; }  /* Total Payment */

  /* base for all four */
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(2),
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(3),
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(4),
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(5) {
  flex: 0 0 25%;
}

/* alignments */
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(2),
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(3) {
  text-align: left !important;   /* Principal, Interest */
}
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(4),
.details-table tbody tr:has(td:nth-child(6)) td:nth-child(5) {
  text-align: right !important;  /* Total, Prepayment */
}

  /* Balance (own line, right-aligned with label) */
  .details-table tbody td:last-child {
    padding: 8px 16px 4px 0px;
    order: 0;
    flex: 1 1 50%;
    border: none;                 /* remove the old divider */
    background: transparent;
    font-weight: 500;
    text-align: right !important;
  }
  .details-table tbody td:last-child::before {
    content: none;
  }

  /* Summary row keeps dark style */
  .details-table .summary-row td {
    background: var(--secondary-card-bg);
    color: var(--text);
    font-weight: 700;
  }

  .details-table tfoot tr.summary-row.summary-mobile {
  display: table-row !important;
}

  .details-table tfoot tr.summary-row.summary-mobile > td{
  display: table-cell !important;
  padding: 0 !important;          /* kill the 24px TD padding */
  border-left: 0 !important;      /* avoid internal vertical rules */
  border-right: 0 !important;
  width: auto; 
}

.details-table tfoot tr.summary-row.summary-mobile > td > .summary-block {
  display: block;
  width: 100%;
  padding: 8px 16px;
  box-sizing: border-box;
}

.btn-layered, .results-header .settings-btn {display: none;}
.header-prepayment-cta { display: none; } /* Hidden on tablet and below */

/* Ensure charts stack vertically on mobile */
.charts-div {
  flex-direction: column;
  gap: 20px;
}

.chart-container {
  width: 100%;
  max-width: 450px;
  max-height: 450px;
  flex: none;
}

.chart2-container {
  width: 100%;
  max-width: 100%;
  max-height: 370px;
  flex: none;
}

.chart-container canvas,
.chart2-container canvas {
  width: 100% !important;
  height: auto !important;
}

/* If the container clips the bleed, unclip on mobile */
.amortization-table-container { overflow: visible; }

.modal-overlay {
    padding: 24px;
}

   .modal-header h2{
     font-size: 20px;   
   }

}

/* Phones (≤480px) — global font-size shrink */
@media (max-width: 480px) {

    .mobile-feature-banner{
    padding: 12px 20px;            /* aligns with your mobile header/container gutters */
    font-weight: 500;
    font-size: 0.825rem;
  }

  .icon-bg {
    width: 20px; height: 20px;
    display: inline-flex;
    align-items: center;      /* vertical center */
    justify-content: center;  /* horizontal center */
    line-height: 1;
    vertical-align: middle;
  }  

  .icon-bg > img {
    width: 12px; height: 12px;
    display: block;
    object-fit: contain;
    }
  /* Header */
  header { padding: 12px 16px; }
  .header-title { font-size: 1.4rem; }      /* was 2.2rem */
  .header-btn   { font-size: 0.9rem; }

  /* Inputs */
  .input-group label { font-size: 1rem; margin-bottom: 12px;}
  .input-field-wrapper input { font-size: 1.25rem; height: 48px; }  /* was 1.5rem */
  .input-field-wrapper { display: flex; align-items: center; }
  .input-field-wrapper .prefix,
  .input-field-wrapper .suffix { font-size: 1rem; width: auto; height: 48px;}

    .input-field-wrapper .prefix img,
  .input-field-wrapper .suffix img {
    width: 20px;
    height: 20px;
    display: block;             /* no inline baseline */
  }

  /* Result summary */
  .summary-item .label { font-size: 1rem; }
  .summary-item .value { font-size: 1.rem; }        /* was 1.5rem */
  .savings-percent      { font-size: 0.85rem; }
  .tenure-savings-container { font-size: 0.85rem; }

  /* Year row / table */
  .year-row td { font-size: 1rem; }
  .details-table th,
  .details-table td { font-size: 0.875rem; }

  /* Mobile legend you added */
  .legend-title { font-size: 1rem; }
  .legend-row.legend-bottom { font-size: 0.875rem; }

  /* Buttons & popover */
  .btn-layered { font-size: 1rem; }
  .modal-card h3 { font-size: 1rem; }
  .date-input-wrapper input { font-size: 1rem; }

  .amortization-table-container {
    margin-left: 0;
    margin-right: 0;
    margin-bottom: o;
  }

    .summary-grid {
    grid-template-columns: 1fr;   /* single column */
    gap: 12px;
    padding: 16px;
  }

  .summary-item { width: 100%; }

  .summary-main {
    flex-direction: column;        /* stack label then value */
    align-items: flex-start;
    gap: 6px;
  }

  .summary-item .label {
    width: auto;                   /* don’t reserve desktop width */
    font-size: 0.95rem;
  }

  /* values on their own line, left-aligned */
  .summary-item .value,
  .summary-main .value-group {
    margin-left: 0;
    text-align: left;
  }

  /* keep percent snug next to value */
  .summary-main .value-group { gap: 6px; }

  .savings-percent { font-size: 0.85rem; }
  .summary-sub { padding-right: 0; margin-top: 2px; }

  .modal-overlay {
    padding: 20px;
}
}
