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

:root {
    /* Light theme variables */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --container-bg: white;
    --text-color: #2c3e50;
    --header-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    --section-bg: #f8f9fa;
    --border-color: #e9ecef;
    --input-bg: white;
    --shadow: rgba(0, 0, 0, 0.1);
    --hover-shadow: rgba(0, 0, 0, 0.2);
    --table-hover: #f8f9fa;
    --table-even: #fdfdfd;
    --table-even-hover: #f0f0f0;
    --gradual-bg: #f0f8ff;
    --gradual-border: #3498db;
    --year-total-bg: #e8f4f8;
    --year-total-border: #3498db;
    --savings-positive-bg: #d4edda;
    --savings-positive-text: #155724;
    --savings-negative-bg: #f8d7da;
    --savings-negative-text: #721c24;
}

[data-theme="dark"] {
    /* Dark theme variables */
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --container-bg: #2d3748;
    --text-color: #e2e8f0;
    --header-gradient: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    --section-bg: #1a202c;
    --border-color: #4a5568;
    --input-bg: #2d3748;
    --shadow: rgba(0, 0, 0, 0.3);
    --hover-shadow: rgba(0, 0, 0, 0.4);
    --table-hover: #374151;
    --table-even: #1f2937;
    --table-even-hover: #374151;
    --gradual-bg: #1a365d;
    --gradual-border: #3182ce;
    --year-total-bg: #1e3a8a;
    --year-total-border: #3b82f6;
    --savings-positive-bg: #065f46;
    --savings-positive-text: #6ee7b7;
    --savings-negative-bg: #7f1d1d;
    --savings-negative-text: #fca5a5;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--container-bg);
    border-radius: 15px;
    box-shadow: 0 20px 40px var(--shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}

header {
    background: var(--header-gradient);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

header h1 {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.quick-instructions {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    padding: 8px 12px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 15px;
    text-decoration: none;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.instruction-step:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.step-number {
    background: rgba(255, 255, 255, 0.3);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.step-text {
    font-size: 0.8rem;
}

.step-connector {
    width: 20px;
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.3));
    margin: 0 4px;
}

.calculator-section {
    padding: 30px;
    background: var(--section-bg);
    transition: all 0.3s ease;
}

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

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

#principal {
    font-family: 'Courier New', monospace;
    text-align: right;
}

#loan-start-date {
    font-family: inherit;
    cursor: pointer;
}

#loan-start-date::-webkit-calendar-picker-indicator {
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

#loan-start-date::-webkit-calendar-picker-indicator:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary,
.btn-secondary {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-secondary {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
}

.btn-primary:hover,
.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.results-section {
    padding: 30px;
}

.emi-result {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.emi-result h2 {
    margin-bottom: 20px;
    text-align: center;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.result-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.result-item .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.result-item .value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
}

.prepayment-section {
    background: var(--section-bg);
    padding: 25px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.prepayment-section h2 {
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.strategy-tabs {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 2px;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    padding: 12px 8px;
    border: none;
    background: #e9ecef;
    color: #6c757d;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #dee2e6;
}

.tab-content {
    display: none;
}

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

.chart-section {
    background: var(--section-bg);
    padding: 25px;
    border-radius: 12px;
    margin-top: 30px;
    transition: all 0.3s ease;
}

.chart-section h2 {
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.charts-grid.comparison {
    grid-template-columns: 1fr;
}

.chart-container {
    position: relative;
    height: 400px;
    background: var(--container-bg);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px var(--shadow);
    transition: all 0.3s ease;
}

.chart-container h3 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.loan-closure-info {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.loan-closure-info h3 {
    margin-bottom: 10px;
}

.closure-dates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.closure-date-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 6px;
}

.closure-date-item .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 5px;
}

.closure-date-item .value {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
}

.installment-section {
    background: var(--section-bg);
    padding: 25px;
    border-radius: 12px;
    margin-top: 30px;
    transition: all 0.3s ease;
}

.installment-section h2 {
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.table-controls {
    margin-bottom: 20px;
}

.table-options {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

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

.option-group label {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

.table-container {
    position: relative;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.installment-table {
    background: var(--container-bg);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.installment-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.installment-table th {
    background: var(--header-gradient);
    color: white;
    padding: 6px 4px;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    font-size: 0.7rem;
    line-height: 1.2;
}

.installment-table td {
    padding: 4px 3px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.7rem;
    line-height: 1.3;
    color: var(--text-color);
}

.installment-table tbody tr:hover {
    background-color: var(--table-hover);
}

.installment-table tbody tr:nth-child(even) {
    background-color: var(--table-even);
}

.installment-table tbody tr:nth-child(even):hover {
    background-color: var(--table-even-hover);
}

.currency {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
}

.year-header {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    color: white !important;
    font-weight: bold;
    font-size: 0.75rem;
    padding: 4px 3px;
}

.year-total {
    background-color: var(--year-total-bg) !important;
    color: var(--text-color) !important;
    font-weight: bold;
    border-top: 2px solid var(--year-total-border);
    font-size: 0.65rem;
    padding: 3px 2px;
}

.part-payment-row {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107;
}

.part-payment-row td {
    font-weight: bold;
    color: #856404;
}

.rate-change-row {
    background-color: #d1ecf1 !important;
    border: 2px solid #17a2b8;
}

.rate-change-row td {
    font-weight: bold;
    color: #0c5460;
}

.comparison-header {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%) !important;
    color: white !important;
    font-size: 0.65rem;
    padding: 5px 3px;
}

.savings-positive {
    background-color: var(--savings-positive-bg) !important;
    color: var(--savings-positive-text) !important;
    font-weight: bold;
    font-size: 0.6rem;
}

.savings-negative {
    background-color: var(--savings-negative-bg) !important;
    color: var(--savings-negative-text) !important;
    font-weight: bold;
    font-size: 0.6rem;
}

.comparison-column {
    border-left: 2px solid #dee2e6;
}

.advanced-scenarios {
    background: var(--section-bg);
    padding: 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.scenario-section {
    margin-bottom: 25px;
    padding: 15px;
    background: var(--container-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.scenario-section h4 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.scenario-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--section-bg);
    border-radius: 4px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.scenario-item input,
.scenario-item select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.remove-btn:hover {
    background: #c82333;
}

.scenario-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.scenario-summary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ffd700, #ff6b6b, #4ecdc4, #45b7d1);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

.scenario-summary h4 {
    margin-bottom: 15px;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.scenario-summary h4::before {
    content: '🎯';
    font-size: 1.2em;
}

.scenario-summary h4::after {
    content: '✨';
    font-size: 1.2em;
}

.event-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.event-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.event-part-payment {
    background: #ffc107;
    color: #212529;
}

.event-rate-change {
    background: #17a2b8;
    color: white;
}

.event-emi-change {
    background: #28a745;
    color: white;
}

.footer {
    background: var(--header-gradient);
    color: white;
    text-align: center;
    padding: 25px 30px;
    margin-top: 0;
    transition: all 0.3s ease;
}

.footer-content p {
    margin: 8px 0;
    font-size: 0.95rem;
}

.footer-content strong {
    color: #667eea;
    font-weight: 700;
}

.footer-content p:first-child {
    font-size: 1rem;
    font-weight: 600;
}

.footer-content p:last-child {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 5px;
}

.gradual-increase-controls {
    background: var(--gradual-bg);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--gradual-border);
    transition: all 0.3s ease;
}

.gradual-increase-controls label {
    color: var(--text-color);
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.gradual-increase-controls input {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.scenario-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.gradual-item {
    background: var(--gradual-bg) !important;
    border: 1px solid var(--gradual-border);
}

.gradual-item input[disabled] {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.prepayment-results {
    margin-top: 20px;
}

.savings-card {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.savings-card h3 {
    margin-bottom: 15px;
    text-align: center;
}

.savings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.savings-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 6px;
    text-align: center;
}

.savings-item .label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.9;
    margin-bottom: 3px;
}

.savings-item .value {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .theme-toggle {
        top: 15px;
        right: 15px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .container {
        margin: 0;
        border-radius: 10px;
        max-width: 100%;
    }

    header {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.6rem;
        line-height: 1.2;
    }

    header p {
        font-size: 0.95rem;
    }

    .quick-instructions {
        gap: 8px;
        margin-top: 10px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .instruction-item {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .instruction-item .step {
        font-size: 0.65rem;
    }

    .instruction-item .text {
        font-size: 0.7rem;
    }

    .instruction-arrow {
        font-size: 1rem;
        display: none; /* Hide arrows on tablet */
    }

    .calculator-section,
    .results-section {
        padding: 15px;
    }

    .prepayment-section,
    .chart-section {
        padding: 15px;
        margin-top: 20px;
    }

    .strategy-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        border-radius: 0;
        box-shadow: none;
    }

    .tab-btn {
        padding: 16px 8px;
        font-size: 0.85rem;
        text-align: center;
        border-radius: 8px;
        margin-bottom: 0;
        min-width: auto;
        line-height: 1.2;
        word-wrap: break-word;
    }

    .tab-btn:nth-child(3),
    .tab-btn:nth-child(4) {
        margin-top: 4px;
    }

    .result-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .result-item {
        padding: 12px;
    }

    .result-item .value {
        font-size: 1.2rem;
    }

    .savings-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .savings-item {
        padding: 8px;
    }

    .savings-item .value {
        font-size: 1rem;
    }

    .closure-dates {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .closure-date-item {
        padding: 12px;
    }

    .chart-container {
        height: 280px;
        padding: 5px;
        overflow: hidden;
    }

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

    .chart-container h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }

    .loan-closure-info {
        padding: 15px;
    }

    .loan-closure-info h3 {
        font-size: 1.1rem;
    }

    .installment-section {
        padding: 15px;
        margin-top: 20px;
    }

    .table-options {
        flex-direction: column;
        gap: 15px;
    }

    .option-group {
        justify-content: center;
    }

    .installment-table {
        margin: 0 -5px;
        border-radius: 6px;
    }

    .installment-table table {
        font-size: 0.65rem;
        min-width: 100%;
    }

    .installment-table th,
    .installment-table td {
        padding: 4px 3px;
        min-width: 50px;
    }

    .installment-table th {
        font-size: 0.6rem;
        line-height: 1.1;
        padding: 6px 4px;
    }

    .installment-table td {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    .currency {
        font-size: 0.55rem;
        min-width: 70px;
    }

    /* Better table scrolling on tablet */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

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

    .input-group label {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }

    .input-group input,
    select {
        padding: 14px 12px;
        font-size: 1rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 14px 20px;
        font-size: 1rem;
        margin-top: 12px;
    }

    .emi-result {
        padding: 20px 15px;
    }

    .emi-result h2 {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }

    .savings-card {
        padding: 15px;
    }

    .savings-card h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    /* Gradual EMI tablet improvements */
    .gradual-increase-controls {
        padding: 15px;
    }

    .gradual-increase-controls > div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        margin-bottom: 15px !important;
    }

    .gradual-increase-controls > div[style*="grid-template-columns"] > div:last-child {
        grid-column: 1 / -1;
    }

    .gradual-increase-controls label {
        font-size: 0.9rem !important;
        margin-bottom: 6px;
    }

    .gradual-increase-controls input {
        padding: 12px 10px;
        font-size: 1rem;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .theme-toggle {
        top: 10px;
        right: 10px;
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .quick-instructions {
        gap: 6px;
        margin-top: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .instruction-item {
        padding: 4px 6px;
        font-size: 0.7rem;
        flex: 0 0 auto;
    }

    .instruction-item .step {
        font-size: 0.6rem;
    }

    .instruction-item .text {
        font-size: 0.65rem;
    }

    .instruction-arrow {
        display: none; /* Hide arrows on mobile */
    }

    .calculator-section,
    .results-section,
    .prepayment-section,
    .chart-section {
        padding: 12px;
    }

    .strategy-tabs {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .tab-btn {
        padding: 14px 10px;
        font-size: 0.9rem;
        border-radius: 8px;
    }

    .tab-btn:nth-child(3),
    .tab-btn:nth-child(4) {
        margin-top: 0;
    }

    .savings-grid {
        grid-template-columns: 1fr;
    }

    .result-item .value {
        font-size: 1.1rem;
    }

    .chart-container {
        height: 250px;
        padding: 3px;
        overflow: hidden;
    }

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

    .input-group input,
    select {
        padding: 12px 10px;
        font-size: 0.95rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    .installment-section {
        padding: 10px;
    }

    .installment-table {
        margin: 0 -5px; /* Extend table to screen edges */
        border-radius: 0;
    }

    .installment-table table {
        font-size: 0.6rem;
        min-width: 100%;
    }

    .installment-table th,
    .installment-table td {
        padding: 4px 2px;
        min-width: 45px;
    }

    .installment-table th {
        font-size: 0.55rem;
        line-height: 1.1;
        padding: 6px 3px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .installment-table td {
        font-size: 0.55rem;
        line-height: 1.2;
    }

    .currency {
        font-size: 0.5rem;
        min-width: 60px;
    }

    /* Better table scrolling on mobile */
    .table-container {
        margin: 0 -10px;
        padding: 0 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .year-header {
        font-size: 0.6rem;
        padding: 3px 2px;
    }

    .year-total {
        font-size: 0.5rem;
        padding: 2px 1px;
    }

    .comparison-header {
        font-size: 0.5rem;
        padding: 3px 2px;
    }

    .savings-positive,
    .savings-negative {
        font-size: 0.45rem;
    }

    .advanced-scenarios {
        padding: 15px;
    }

    .scenario-section {
        padding: 10px;
        margin-bottom: 15px;
    }

    .scenario-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .scenario-item input,
    .scenario-item select {
        width: 100%;
    }

    /* Gradual EMI mobile improvements - vertical layout */
    .gradual-increase-controls {
        padding: 10px;
        margin: 10px 0;
    }

    .gradual-increase-controls > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        margin-bottom: 12px !important;
    }

    .gradual-increase-controls label {
        font-size: 0.85rem !important;
        margin-bottom: 4px;
        font-weight: 600;
    }

    .gradual-increase-controls input {
        padding: 10px 8px;
        font-size: 0.9rem;
        border-radius: 4px;
        width: 100%;
    }

    .gradual-increase-controls button {
        width: 100%;
        padding: 10px;
        font-size: 0.9rem;
        margin-top: 5px;
    }

    .event-timeline {
        flex-direction: column;
        gap: 4px;
    }

    .event-badge {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
}

/* E
nhanced Optimized Strategy Results */
.scenario-summary .savings-highlight {
    background: rgba(255, 255, 255, 0.15);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #ffd700;
}

.scenario-summary .savings-amount {
    font-size: 1.3rem;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.scenario-summary .comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.scenario-summary .comparison-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.scenario-summary .comparison-item strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    opacity: 0.9;
}

.scenario-summary .comparison-item .value {
    font-size: 1.1rem;
    font-weight: 700;
}

.scenario-summary .strategy-badge {
    display: inline-block;
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 2px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

/*
 Enhanced timeline and closure information */
.scenario-summary .timeline-info {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    border-left: 3px solid #4ecdc4;
}

.scenario-summary .savings-callout {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.1));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
    text-align: center;
}

.scenario-summary .strategy-summary {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.scenario-summary .closure-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.scenario-summary .closure-date-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.scenario-summary .closure-date-item .label {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.scenario-summary .closure-date-item .value {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

/* 
PDF Export Button Styling */
#export-pdf {
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
    border: none;
    color: white;
    font-weight: 600;
    border-radius: 8px;
}

#export-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

#export-pdf:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.3);
}

/* Export section animation */
#export-section {
    animation: slideInUp 0.5s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}