

:root {
    
    --bg-canvas: #F3F0EB;       
    --bg-surface: #FFFFFF;      
    --bg-input: #FAFAF8;        
    
    --text-primary: #1A1918;    
    --text-secondary: #5E5C59;  
    --text-tertiary: #8C8A85;   

    --brand-primary: #2C4F38;   
    --brand-hover: #1F3A29;     
    --brand-accent: #C76D48;    
    
    --border-subtle: #E6E2DA;   
    --border-focus: #2C4F38;    

    
    --success-bg: #E3F0E6;
    --success-text: #216E39;
    --danger-bg: #FFEBE9;
    --danger-text: #CC3300;

    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.08);

    
    --z-base: 1;
    --z-drawer: 100;
    --z-toggle: 110;
    --z-tooltip: 10000;
}


input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}



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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}


h1, h2, h3, legend, .header h1 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 4rem;
}

.container {
    max-width: 1200px; 
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}



.header {
    
    background: transparent;
    color: var(--text-primary);
    padding: 60px 0 40px 0;
    margin: 0;
    text-align: center;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 40px;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 12px;
    color: var(--brand-primary);
}

.header p {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}



.content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}



.calculator-layout {
    position: relative;
    width: 100%;
    
}



.calculator-layout #loading,
.calculator-layout #error {
    grid-column: 1 / -1; 
}


@media (min-width: 1800px) {
    
    .container,
    .content {
        max-width: 1700px;
    }

    .calculator-layout {
        display: grid;
        grid-template-columns: minmax(0, 7fr) minmax(0, 13fr); 
        column-gap: 32px;
    }


    
    .calculator-layout #loading,
    .calculator-layout #error {
        grid-column: 2;
    }
}



.form-section {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-md);
    
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-subtle);
    position: relative;
    width: 100%;
    
}



.form-header-sticky {
    position: sticky;
    top: -24px; 
    z-index: 20; 
    background: var(--bg-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin: -24px -24px 24px -24px; 
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); 
}

.form-header-sticky h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.5rem;
    color: var(--brand-primary);
}


.form-section > h2 {
    display: none; 
}


@media (max-width: 899px) {
    .form-section {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 70vh;
        width: 100vw;
        z-index: var(--z-drawer);
        transform: translateY(0);
        transition: transform 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
        border-radius: var(--radius-md) var(--radius-md) 0 0; 
    }

    
    .form-header-sticky {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    
    body.drawer-closed .form-section {
        transform: translateY(100%);
    }
}



@media (min-width: 900px) and (max-width: 1799px) {
    .calculator-layout {
        padding-left: 60px;
        padding-right: 20px;
    }

    .form-section {
        position: fixed;
        top: 0;
        left: 0;
        width: max(800px, 60vw);
        height: 100vh;
        z-index: var(--z-drawer);
        border-radius: 0;
        transform: translateX(0); 
        transition: transform 0.3s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.15);
    }

    
    body.drawer-closed .form-section {
        transform: translateX(calc(-100% + 40px));
        overflow: hidden;
    }

    
    body.drawer-closed .form-section .form-header-sticky {
        width: 40px;
        margin-left: auto;
        margin-right: -24px; 
        border-right: 2px solid var(--brand-primary);
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    
    body.drawer-closed .form-section .form-header-sticky h2 {
        display: none; 
    }

    
    body.drawer-closed .form-section .form-header-sticky {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
}


@media (min-width: 1800px) {
    .form-section {
        position: relative;
        width: 100%;
        height: auto;
        min-width: unset;
        max-width: none;
        transform: translateX(0);
        transition: transform 0.3s ease;
        overflow-y: visible;
        border-radius: var(--radius-md);
    }

    
    .form-header-sticky {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    
    body.drawer-closed .form-section {
        transform: translateX(calc(-100% + 60px));
    }

}



.drawer-toggle {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: var(--z-toggle);
    padding: 4px;
}

.drawer-toggle:hover {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    transform: scale(1.1);
}

.drawer-toggle:active {
    transform: scale(0.95);
}

.drawer-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
    transition: transform 0.2s ease;
}





@media (max-width: 899px) {
    .icon-arrow-left,
    .icon-arrow-right {
        display: none !important;
    }
    .icon-hamburger,
    .icon-close {
        display: none;
    }
    body.drawer-open .icon-close {
        display: block;
    }
    body.drawer-open .icon-hamburger {
        display: none;
    }
    body.drawer-closed .icon-close {
        display: none;
    }
    body.drawer-closed .icon-hamburger {
        display: block;
    }
}


@media (min-width: 900px) and (max-width: 1799px) {
    .icon-hamburger,
    .icon-close {
        display: none !important;
    }
    .icon-arrow-left,
    .icon-arrow-right {
        display: none;
    }
    
    body.drawer-open .icon-arrow-left {
        display: block;
    }
    body.drawer-closed .icon-arrow-right {
        display: block;
    }
}



.drawer-toggle-mobile {
    position: fixed;
    bottom: calc(70vh + 16px); 
    left: 50%;
    transform: translateX(-50%);
    transition: bottom 0.3s ease, background 0.2s ease, box-shadow 0.2s ease;

    
    width: 160px; 
    height: 48px;
    border-radius: 24px; 

    
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;

    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    z-index: var(--z-toggle);
}


body.drawer-closed .drawer-toggle-mobile {
    bottom: 24px;
}


.drawer-toggle-mobile:hover {
    transform: translateX(-50%); 
    background: var(--bg-input);
    box-shadow: var(--shadow-hover);
}

.drawer-toggle-mobile:active {
    transform: translateX(-50%) scale(0.98);
}


.drawer-toggle-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

@media (min-width: 900px) {
    .drawer-toggle-mobile {
        display: none;
    }
}


@media (max-width: 899px) {
    .drawer-toggle-mobile .icon-arrow {
        transition: transform 0.3s ease;
    }

    
    body.drawer-open .drawer-toggle-mobile .icon-arrow {
        transform: rotate(180deg);
    }

    
    body.drawer-closed .drawer-toggle-mobile .icon-arrow {
        transform: rotate(0deg);
    }
}


.drawer-toggle-desktop {
    position: relative; 
    
}

@media (max-width: 899px) {
    .drawer-toggle-desktop {
        display: none;
    }
}


@media (min-width: 1800px) {
    .drawer-toggle-desktop {
        display: none;
    }
}

.form-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--brand-primary);
}


fieldset {
    border: none;
    padding: 0;
    margin: 0 0 24px 0;
    border-radius: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    align-items: start;
}

fieldset:last-child {
    margin-bottom: 0;
}

legend {
    grid-column: 1 / -1;
    padding: 0;
    margin-bottom: 12px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    width: 100%;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}


fieldset > p,
fieldset > table,
fieldset > .form-group-full,
fieldset > #cpf_status,
fieldset > .add-row-btn {
    grid-column: 1 / -1;
}




@media (min-width: 1800px) {
    fieldset {
        grid-template-columns: repeat(3, 1fr);
    }
}



@media (min-width: 1800px) {
    .form-section .interest-rate-table {
        min-width: 450px;
    }

    .form-section .upfront-costs-table {
        min-width: 800px;
    }

    .form-section .progressive-table {
        min-width: 800px;
    }
}



.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; 
}


.form-group:not(.form-group-checkbox) > label {
    min-height: 2.5em;
    line-height: 1.25;
    
    display: flex;
    align-items: flex-end;
    column-gap: 4px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(44, 79, 56, 0.1); 
}


input:invalid:not(:focus):not(:placeholder-shown) {
    border-color: var(--danger-text);
}

input:invalid:focus {
    border-color: var(--danger-text);
    box-shadow: 0 0 0 3px var(--danger-bg);
}

.form-text {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    margin-top: 0;
    line-height: 1.4;
}


.radio-group {
    
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 8px;
    row-gap: 4px;
    align-items: center;
    margin-top: 4px;
}

.radio-group input[type="radio"] {
    justify-self: start;
}

.radio-group label,
.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: normal;
}

.form-group-checkbox {
    
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group-checkbox input[type="checkbox"] {
    margin: 0;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--brand-primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}


.input-suffix-pct {
    position: relative;
    display: block;
    width: 100%;
}

.input-suffix-pct input {
    padding-right: 28px !important; 
}

.input-suffix-pct::after {
    content: "%";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 0.9rem;
    pointer-events: none;
    line-height: 1;
}


td .input-suffix-pct input {
    padding-right: 20px !important;
}

td .input-suffix-pct::after {
    right: 4px;
    font-size: 0.8rem;
}


#cpf_status {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 20px;
}

#cpf_needed_display {
    font-size: 0.9rem;
    line-height: 1.5;
}

#cpf_needed_display small {
    color: var(--text-tertiary);
}

#downpayment_breakdown {
    margin-top: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

.breakdown-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    align-items: start;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
}

.breakdown-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    min-height: 2.5em;
    line-height: 1.25;
}

.breakdown-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.cash-breakdown-details {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.cash-breakdown-details > div {
    margin-bottom: 2px;
}



.results-section {
    background: transparent; 
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

.results-section h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-primary);
}


.headline-metrics {
    margin-bottom: 40px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: left; 
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.metric-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    display: block;
    font-size: 2rem; 
    font-weight: 700;
    color: var(--brand-primary);
    font-family: Georgia, serif; 
}


.summary-metric-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--border-subtle);
}

.summary-metric-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

@media (max-width: 900px) {
    .summary-metric-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .summary-metric-row {
        grid-template-columns: 1fr;
    }
}


.sale-year-selector {
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sale-year-selector:hover {
    border-color: var(--brand-primary);
}

.sale-year-selector:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(44, 79, 56, 0.1);
}



.table-section {
    margin-top: 40px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 30px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.table-section h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}


table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    font-size: 0.9rem;
}


th, td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border-subtle);
    border-right: none;
    border-left: none;
    border-top: none;
}

th:first-child, td:first-child {
    text-align: left;
    padding-left: 8px;
}

th {
    background-color: transparent; 
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-subtle);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--bg-canvas); 
}


.mortgage-breakdown,
.tax-breakdown {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.mortgage-breakdown strong,
.tax-breakdown strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}


.upfront-costs-table td input,
.interest-rate-table td input,
.progressive-table td input,
.progressive-table td select {
    border: none;
    background: transparent;
    width: 100%;
    font-size: 0.9rem;
    padding: 4px;
    text-align: right;
    color: var(--text-primary);
}


.interest-rate-table {
    table-layout: fixed;
}

.interest-rate-table th:nth-child(1),
.interest-rate-table td:nth-child(1) {
    width: 30%;
}

.interest-rate-table th:nth-child(2),
.interest-rate-table td:nth-child(2) {
    width: 40%;
}

.interest-rate-table th:nth-child(3),
.interest-rate-table td:nth-child(3) {
    width: 30%;
}

.upfront-costs-table td input:focus,
.interest-rate-table td input:focus,
.progressive-table td input:focus,
.progressive-table td select:focus {
    background: var(--bg-input);
    box-shadow: none;
    border-bottom: 2px solid var(--brand-primary);
    border-radius: 0;
}


tr[data-locked] {
    background-color: var(--bg-input);
}

tr[data-locked] input[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: transparent;
}

.progressive-table .tooltip-icon {
    margin-left: 6px;
}



@media (min-width: 901px) {
    .progressive-table {
        table-layout: fixed;
    }

    .progressive-table th:nth-child(1),
    .progressive-table td:nth-child(1) {
        width: 25%; 
    }

    .progressive-table th:nth-child(2),
    .progressive-table td:nth-child(2) {
        width: 10%; 
    }

    .progressive-table th:nth-child(3),
    .progressive-table td:nth-child(3) {
        width: 15%; 
    }

    .progressive-table th:nth-child(4),
    .progressive-table td:nth-child(4) {
        width: 10%; 
    }

    .progressive-table th:nth-child(5),
    .progressive-table td:nth-child(5) {
        width: 10%; 
    }

    .progressive-table th:nth-child(6),
    .progressive-table td:nth-child(6) {
        width: 10%; 
    }

    .progressive-table th:nth-child(7),
    .progressive-table td:nth-child(7) {
        width: 20%; 
    }
}


.progressive-table .milestone-name-small {
    font-size: 0.85rem !important;
    text-align: left !important;
}



button {
    font-family: inherit;
    transition: all 0.2s ease;
}

.add-row-btn {
    background-color: var(--bg-surface);
    color: var(--brand-primary);
    border: 1px solid var(--brand-primary);
    padding: 10px 20px;
    border-radius: 50px; 
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 10px;
}

.add-row-btn:hover {
    background-color: var(--brand-primary);
    color: white;
}

.add-row-btn:active {
    transform: scale(0.98);
}

.remove-row-btn, .remove-cost-row-btn, .remove-progressive-row-btn {
    background-color: transparent;
    color: var(--text-tertiary);
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
}

.remove-row-btn:hover:not(:disabled), 
.remove-cost-row-btn:hover:not(:disabled),
.remove-progressive-row-btn:hover:not(:disabled) {
    background-color: var(--danger-bg);
    color: var(--danger-text);
}

.remove-row-btn:active:not(:disabled),
.remove-cost-row-btn:active:not(:disabled),
.remove-progressive-row-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.remove-row-btn:disabled,
.remove-cost-row-btn:disabled,
.remove-progressive-row-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}



.loading {
    text-align: center;
    padding: 40px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.error {
    background-color: var(--danger-bg);
    border: 1px solid rgba(204, 51, 0, 0.2);
    color: var(--danger-text);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.tooltip-icon {
    display: inline-block;
    cursor: help;
    margin-left: 4px;
    font-size: 0; 
    vertical-align: middle;
}

.tooltip-icon::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    vertical-align: middle;
    --icon-color: #666; 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7.5" fill="none" stroke="%23666" stroke-width="1.5"/><text x="8" y="11.5" text-anchor="middle" font-size="11" font-weight="bold" fill="%23666">i</text></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: help;
}


.tooltip-icon.info::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7.5" fill="none" stroke="%232196F3" stroke-width="1.5"/><text x="8" y="11.5" text-anchor="middle" font-size="11" font-weight="bold" fill="%232196F3">i</text></svg>');
}

.tooltip-icon.success::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7.5" fill="none" stroke="%234CAF50" stroke-width="1.5"/><text x="8" y="11.5" text-anchor="middle" font-size="11" font-weight="bold" fill="%234CAF50">i</text></svg>');
}

.tooltip-icon.warning::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7.5" fill="none" stroke="%23FF9800" stroke-width="1.5"/><text x="8" y="11.5" text-anchor="middle" font-size="11" font-weight="bold" fill="%23FF9800">i</text></svg>');
}

.tooltip-icon.error {
    background-color: transparent;
    border: none;
    color: inherit;
    padding: 0;
    margin-bottom: 0;
}

.tooltip-icon.error::before {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="7.5" fill="none" stroke="%23f44336" stroke-width="1.5"/><text x="8" y="11.5" text-anchor="middle" font-size="11" font-weight="bold" fill="%23f44336">i</text></svg>');
}



@media (max-width: 900px) {
    .content {
        gap: 40px;
    }

    .form-section {
        padding: 24px;
    }

    .header h1 {
        font-size: 2rem;
    }
    
    .header {
        padding: 40px 0 20px 0;
    }

    .metrics-grid {
        grid-template-columns: 1fr; 
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .header p {
        font-size: 1rem;
    }

    .form-section {
        padding: 20px;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    .table-section {
        padding: 20px;
        
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 8px 6px;
    }
}


.custom-tooltip {
    position: fixed;
    background: var(--text-primary);
    color: var(--bg-surface);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    max-width: 250px;
    z-index: 10000;
    pointer-events: none; 
    opacity: 0;           
    transition: opacity 0.1s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1.4;
}



.table-scroll-wrapper {
  grid-column: 1 / -1;  
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;  
  max-height: 600px;  
  -webkit-overflow-scrolling: touch;  
  position: relative;
}

@media (min-width: 1001px) and (max-width: 1799px) {
  .table-scroll-wrapper {
    overflow-x: auto;  
  }

  
  .table-scroll-wrapper::before,
  .table-scroll-wrapper::after {
    display: none;
  }
}


@media (max-width: 1000px) {
  .table-scroll-wrapper::before,
  .table-scroll-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;  
    z-index: 1;
    opacity: 0.6;
  }
  
  
  .table-scroll-wrapper::before {
    left: 0;
    background: linear-gradient(to right, 
      var(--bg-surface), 
      transparent
    );
  }
  
  
  .table-scroll-wrapper::after {
    right: 0;
    background: linear-gradient(to left, 
      var(--bg-surface), 
      transparent
    );
  }
}


@media (min-width: 901px) {
  .interest-rate-table,
  .progressive-table {
    table-layout: fixed;  
  }
}

@media (max-width: 900px) {
  .interest-rate-table,
  .upfront-costs-table,
  .progressive-table {
    table-layout: auto;
    min-width: 600px;  
  }
  
  
  .progressive-table {
    min-width: 700px;
  }
}

@media (max-width: 600px) {
  .interest-rate-table {
    min-width: 500px;
  }
  
  .upfront-costs-table {
    min-width: 650px;  
  }
  
  .progressive-table {
    min-width: 750px;  
  }
}


@media (max-width: 900px) {
  th, td {
    padding: 12px 10px;  
    min-height: 44px;    
  }
  
  
  .upfront-costs-table td input,
  .interest-rate-table td input,
  .progressive-table td input,
  .progressive-table td select {
    min-width: 80px;     
    min-height: 44px;    
    padding: 10px 8px;   
    font-size: 16px;     
  }
}

@media (max-width: 600px) {
  th, td {
    padding: 12px 8px;
    white-space: nowrap;  
  }
  
  
  .upfront-costs-table td input,
  .interest-rate-table td input,
  .progressive-table td input {
    min-width: 70px;
    font-size: 16px;  
  }
  
  
  .upfront-costs-table td:first-child input,
  .progressive-table td:first-child input {
    min-width: 120px;
  }
}


@media (max-width: 900px) {
  tr[data-locked] {
    background-color: var(--bg-input);  
  }
  
  tr[data-locked] input[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
    min-width: 70px;  
  }
}

@media (max-width: 900px) {
  .progressive-table td:first-child {
    min-width: 140px;  
  }
  
  .progressive-table .milestone-name-small {
    font-size: 0.85rem !important;
    text-align: left !important;
    white-space: normal;  
    line-height: 1.3;
  }
}


@media (max-width: 900px) {
  .remove-row-btn,
  .remove-cost-row-btn {
    min-width: 60px;     
    min-height: 44px;
    padding: 8px 12px;
    white-space: nowrap;
  }
  
  
  input[type="checkbox"] {
    width: 24px;   
    height: 24px;
    margin: 10px;  
  }
}


@media (max-width: 900px) {
  .ledger-table {
    table-layout: auto;
    min-width: 900px;  
  }
}


@media (max-width: 600px) {
  .ledger-table {
    min-width: 950px;
  }

  #exitSummaryTable {
    min-width: 650px;  
  }
}




@media (min-width: 1800px) {
    .ledger-table {
        min-width: 850px; 
    }

    
}







.table-scroll-wrapper table thead th,
.table-section table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--bg-surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}



.table-scroll-wrapper table th:first-child,
.table-scroll-wrapper table td:first-child,
.table-section table th:first-child,
.table-section table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background-color: var(--bg-surface);
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}



.table-scroll-wrapper table thead th:first-child,
.table-section table thead th:first-child {
  z-index: 5;
  box-shadow:
    2px 0 4px rgba(0, 0, 0, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.06);
}



tr:hover td:first-child {
  background-color: var(--bg-canvas);
}

tr[data-locked] td:first-child {
  background-color: var(--bg-input);
}




.blog-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}


.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0 0 30px 0;
    font-size: 0.9rem;
}

.breadcrumbs li:not(:last-child)::after {
    content: "›";
    margin: 0 8px;
    color: var(--text-tertiary);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumbs a:hover {
    color: var(--brand-primary);
}


.blog-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.blog-header h1 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--brand-primary);
    margin-bottom: 12px;
}

.blog-header p {
    color: var(--text-secondary);
    font-size: 1.15rem;
}


.article-header {
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.article-header h1 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.article-meta .updated {
    color: var(--text-tertiary);
    font-style: italic;
}

.reading-time {
    color: var(--text-tertiary);
}


.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.article-content h2 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 48px;
    margin-bottom: 16px;
    font-size: 1.75rem;
    color: var(--text-primary);
}

.article-content h3 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 32px;
    margin-bottom: 12px;
    font-size: 1.35rem;
    color: var(--text-primary);
}

.article-content p {
    margin-bottom: 1.5em;
}

.article-content .lead {
    font-size: 1.25rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.article-content a {
    color: var(--brand-primary);
    text-decoration: underline;
    transition: color 0.2s ease;
}

.article-content a:hover {
    color: var(--brand-hover);
}

.article-content ul,
.article-content ol {
    margin-bottom: 1.5em;
    padding-left: 1.5em;
}

.article-content li {
    margin-bottom: 0.5em;
}


.article-content table {
    width: 100%;
    margin: 24px 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.95rem;
}

.article-content th,
.article-content td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.article-content th {
    background-color: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-subtle);
}

.article-content tr:hover td {
    background-color: var(--bg-canvas);
}


.table-of-contents {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 24px;
    border-radius: var(--radius-md);
    margin: 32px 0;
    box-shadow: var(--shadow-soft);
}

.table-of-contents h2 {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.table-of-contents ol {
    margin: 0;
    padding-left: 20px;
}

.table-of-contents li {
    margin: 8px 0;
}

.table-of-contents a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.table-of-contents a:hover {
    color: var(--brand-primary);
}


.callout {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--brand-accent);
    padding: 20px 24px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 32px 0;
    box-shadow: var(--shadow-soft);
}

.callout h3 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.callout p {
    margin: 0;
    color: var(--text-secondary);
}

.callout a {
    color: var(--brand-primary);
    font-weight: 500;
}


.article-footer {
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border-subtle);
}


.article-cta {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-cta:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.article-cta h3 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.article-cta p {
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.cta-button {
    display: inline-block;
    background: var(--brand-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.cta-button:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
}

.cta-button:active {
    transform: scale(0.98);
}


.article-list {
    margin-top: 20px;
}

.article-preview {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.article-preview:last-child {
    border-bottom: none;
}

.article-preview h2 {
    font-family: Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.article-preview h2 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.article-preview h2 a:hover {
    color: var(--brand-primary);
}

.article-preview time {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.article-preview p {
    margin: 12px 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.read-more {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.read-more:hover {
    color: var(--brand-hover);
}


@media (max-width: 900px) {
    .article-header h1 {
        font-size: 2rem;
    }

    .article-content h2 {
        font-size: 1.5rem;
        margin-top: 36px;
    }
}

@media (max-width: 600px) {
    .blog-container {
        padding: 20px 16px;
    }

    .article-header h1 {
        font-size: 1.75rem;
    }

    .article-content {
        font-size: 1rem;
    }

    .article-content h2 {
        font-size: 1.35rem;
    }

    .article-meta {
        flex-direction: column;
        gap: 8px;
    }

    .table-of-contents {
        padding: 20px;
    }

    .article-cta {
        padding: 24px 20px;
    }
}
