
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.calculator {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 30px;
    position: relative;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

h2 {
    color: #3498db;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.result-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.result-card p {
    margin: 10px 0;
    display: flex;
    justify-content: space-between;
    color: #555;
}

.result-card p span {
    color: canvastext;
    font-weight: 500;
}

.savings {
    color: #27ae60 !important;
    font-weight: 700 !important;
}

.negative-savings {
    color: #e74c3c !important;
    font-weight: 700 !important;
}

.chart-container {
    margin-top: 30px;
    height: 480px;
    overflow: visible;
    padding-bottom: 20px;
}

.chart-container.dual {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: auto;
}

.chart-panel {
    background: #f8f9fa;
    padding: 16px;
    padding-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    height: 420px;
    overflow: visible;
}

.chart-panel h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.chart-panel canvas {
    width: 100%;
    height: calc(100% - 50px);
    display: block;
}

.print-button {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s;
}

.print-button:hover {
    background-color: #2980b9;
}

@media print {
    /* Hide elements that shouldn't be printed */
    .no-print {
        display: none !important;
    }
    
    body {
        background-color: white;
        padding: 0;
        margin: 0;
    }
    
    .calculator {
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
        border: none;
        padding: 10px;
        page-break-inside: avoid;
        background: transparent;
    }
    
    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
        page-break-after: avoid;
    }
    
    h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
        page-break-after: avoid;
    }
    
    h3 {
        font-size: 1rem;
        margin-bottom: 10px;
        page-break-after: avoid;
    }
    
    /* Make inputs look like static text when printed */
    input[type="number"] {
        border: none;
        padding: 0;
        background: transparent;
        font-weight: 600;
        -moz-appearance: textfield;
        appearance: textfield;
        color: #000;
        display: inline;
    }
    
    /* Remove number input spinners for print */
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    .input-section {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 15px;
        page-break-inside: avoid;
    }
    
    .current-loan,
    .new-loan {
        border: none;
        background: transparent;
        padding: 0;
    }
    
    .input-group {
        margin-bottom: 10px;
        display: flex;
        flex-direction: column;
    }
    
    label {
        font-size: 0.85rem;
        margin-bottom: 3px;
        font-weight: 500;
    }
    
    .results {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        margin-bottom: 15px;
        page-break-inside: avoid;
    }
    
    .result-card {
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        padding-bottom: 10px;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .result-card p {
        margin: 5px 0;
        font-size: 0.9rem;
        color: #555;
    }
    
    .result-card p span {
        color: canvastext;
        font-weight: 500;
    }
    
    /* Chart containers - prevent page breaks inside */
    .chart-container {
        page-break-inside: avoid;
        page-break-before: auto;
        margin-top: 15px;
        margin-bottom: 15px;
        height: auto;
        max-height: 350px;
        padding: 0;
        overflow: visible;
        border: none;
        border-radius: 0;
        background: transparent;
    }
    
    .chart-container h3 {
        margin-top: 0;
        margin-bottom: 10px;
        font-size: 1rem;
    }
    
    .chart-container > canvas {
        max-height: 320px !important;
        height: 320px !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .chart-container.dual {
        page-break-inside: avoid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
        height: auto;
        max-height: none;
        border: none;
        padding: 0;
        margin-top: 15px;
        overflow: visible;
    }
    
    .chart-panel {
        page-break-inside: avoid;
        background: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        height: auto;
        max-height: 330px;
        overflow: visible;
    }
    
    .chart-panel h3 {
        margin-bottom: 8px;
        margin-top: 0;
        font-size: 0.95rem;
    }
    
    .chart-panel canvas {
        height: 280px !important;
        max-height: 280px !important;
        max-width: 100% !important;
        width: 100% !important;
        display: block;
    }
    
    /* Try to keep large comparison chart on its own page if needed */
    .chart-container:last-of-type {
        page-break-before: auto;
    }
    
    /* Simplify colors for print */
    .savings {
        color: #27ae60 !important;
        font-weight: 700 !important;
    }
    
    .negative-savings {
        color: #e74c3c !important;
        font-weight: 700 !important;
    }
}

@media (max-width: 768px) {
    .input-section,
    .results {
        grid-template-columns: 1fr;
    }
    
    .calculator {
        padding: 15px;
    }

    .chart-container.dual {
        grid-template-columns: 1fr;
    }
    
    .print-button {
        position: static;
        width: 100%;
        margin-bottom: 15px;
    }
}

    
