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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logo-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.logo-container a {
    text-decoration: none;
    display: inline-block;
}

.logo {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s ease;
    display: block;
}

.logo:hover {
    transform: scale(1.05);
}

.page-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    font-weight: 500;
    border: 2px solid transparent;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.calculator-wrapper {
    margin-bottom: 40px;
}

.info-section-fullwidth {
    width: 100%;
    margin: 40px 0;
    grid-column: 1 / -1;
}

.calculator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.calculator-form-section {
    position: sticky;
    top: 20px;
}

.calculator-card {
    background: var(--card-background);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.calculator-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.label-text {
    flex: 1;
}

.currency,
.percentage,
.years {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.interest-rate-container {
    display: flex;
    gap: 12px;
    width: 100%;
}

.interest-rate-container input {
    flex: 1;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: var(--card-background);
    color: var(--text-primary);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
}

.result-note {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 16px;
    text-align: center;
    font-style: italic;
}

.affordability-info {
    color: white;
    line-height: 1.7;
    margin-top: 16px;
}

.affordability-info p {
    margin-bottom: 12px;
}

.affordability-info p:last-child {
    margin-bottom: 0;
}

.affordability-info h4 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 12px;
}

.affordability-info ul {
    margin: 12px 0;
    padding-left: 24px;
    color: white;
}

.affordability-info li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.example-payment {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-weight: 500;
}

.range-bar-container {
    margin-top: 20px;
}

.range-bar-wrapper {
    position: relative;
    width: 100%;
}

.range-bar {
    position: relative;
    width: 100%;
    height: 50px;
    background: #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 35px;
    border: 2px solid #cbd5e1;
}

.range-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: all 0.3s ease;
    border-radius: 6px;
    z-index: 1;
    min-height: 50px;
}

.range-bar-labels {
    position: relative;
    width: 100%;
    height: 30px;
    margin-top: 8px;
}

.range-label {
    background: rgba(30, 41, 59, 0.95);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.range-label.range-label-start {
    position: absolute;
    left: 0;
    transform: translateX(0);
}

.range-label.range-label-lower,
.range-label.range-label-upper {
    position: absolute;
    transform: translateX(-50%);
}

.range-label.range-label-end {
    position: absolute;
    right: 0;
    transform: translateX(0);
}

.range-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.9rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-green {
    background: #10b981;
}

.legend-yellow {
    background: #f59e0b;
}

.legend-red {
    background: #ef4444;
}

.interest-rate-dropdown {
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: var(--card-background);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 150px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.interest-rate-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.interest-rate-dropdown:hover {
    border-color: var(--primary-color);
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.calculate-btn,
.reset-btn {
    flex: 1;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    border: none;
}

.calculate-btn {
    background: var(--primary-color);
    color: white;
}

.calculate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculate-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: var(--secondary-color);
    color: white;
}

.reset-btn:hover {
    background: #475569;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.reset-btn:active {
    transform: translateY(0);
}

.results {
    animation: fadeIn 0.5s ease;
}

.results.hidden {
    display: none;
}

.results:not(.hidden) {
    display: block;
}

.results-section.hidden {
    display: none;
}

.results-placeholder {
    background: var(--card-background);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
}

.results-placeholder.hidden {
    display: none;
}

.placeholder-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.placeholder-icon {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.placeholder-content {
    text-align: left;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-top: 20px;
}

.placeholder-content p {
    margin-bottom: 16px;
}

.placeholder-content p:last-child {
    margin-bottom: 0;
}

.placeholder-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 24px;
    color: white;
    box-shadow: var(--shadow);
}

.result-card-highlight {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-size: 1rem;
    opacity: 0.9;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.result-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    color: white;
}

.result-card-highlight {
    border: 2px solid rgba(255, 255, 255, 0.3);
    margin-top: 20px;
}

.result-item.highlight {
    background: rgba(255, 255, 255, 0.1);
    padding: 16px;
    border-radius: 8px;
    margin-top: 8px;
}

.result-item.highlight .result-value {
    color: #10b981;
    font-size: 1.6rem;
}

.overpayment-type-dropdown {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: var(--card-background);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.overpayment-type-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.overpayment-type-dropdown:hover {
    border-color: var(--primary-color);
}

.hidden {
    display: none;
}

.info-section,
.faq-section {
    background: var(--card-background);
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}

.info-section h2,
.faq-section h2 {
    color: var(--text-primary);
    font-size: 2rem;
    margin-bottom: 30px;
    text-align: center;
}

.info-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.info-item {
    padding: 20px;
    background: var(--background);
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
}

.info-item h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.info-item p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.faq-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.faq-item {
    padding: 24px;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.faq-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.faq-item h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.faq-item p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

.balance-table-container {
    background: var(--card-background);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.table-title {
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-align: center;
}

.table-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 20px;
    font-style: italic;
}

.result-card .result-note {
    color: rgba(255, 255, 255, 0.8);
}

.table-wrapper {
    overflow-x: auto;
}

.balance-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

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

.balance-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
}

.balance-table th:first-child {
    border-top-left-radius: 8px;
}

.balance-table th:last-child {
    border-top-right-radius: 8px;
}

.balance-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

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

.balance-table tbody tr:last-child {
    border-bottom: none;
}

.balance-table td {
    padding: 12px 16px;
    color: var(--text-primary);
}

.balance-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.balance-table td:not(:first-child) {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.balance-table td.paid-off {
    color: var(--success-color);
    font-weight: 600;
}

footer {
    text-align: center;
    color: white;
    opacity: 0.9;
    padding: 20px 0;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .calculator-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .info-section-fullwidth {
        margin: 30px 0;
    }

    .calculator-form-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .container {
        max-width: 100%;
    }

    .logo {
        width: 60px;
        height: 60px;
    }

    header h1 {
        font-size: 2rem;
    }

    .calculator-card {
        padding: 24px;
    }

    .info-section,
    .faq-section {
        padding: 24px;
    }

    .info-section h2,
    .faq-section h2 {
        font-size: 1.75rem;
    }

    .info-content {
        grid-template-columns: 1fr;
    }

    .form-group input {
        font-size: 1rem;
    }

    .interest-rate-container {
        flex-direction: column;
    }

    .interest-rate-dropdown {
        min-width: 100%;
        font-size: 1rem;
    }

    .overpayment-type-dropdown {
        font-size: 1rem;
    }

    .calculate-btn,
    .reset-btn {
        font-size: 1rem;
        padding: 14px 24px;
    }

    .button-group {
        flex-direction: column;
    }

    .result-value {
        font-size: 1.3rem;
    }

    .result-title {
        font-size: 1.1rem;
    }

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

    .balance-table-container {
        padding: 16px;
    }

    .table-title {
        font-size: 1.1rem;
    }

    .range-bar-labels {
        font-size: 0.7rem;
        padding: 0 4px;
    }

    .range-label {
        padding: 1px 4px;
        font-size: 0.65rem;
    }

    .legend-item {
        font-size: 0.85rem;
    }

    .results-placeholder {
        padding: 24px;
    }

    .placeholder-title {
        font-size: 1.3rem;
    }

    .placeholder-content {
        font-size: 0.95rem;
    }

    .balance-table th,
    .balance-table td {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .page-nav {
        gap: 10px;
    }

    .nav-link {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

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

    .logo {
        width: 50px;
        height: 50px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .calculator-card {
        padding: 20px;
    }

    .info-section,
    .faq-section {
        padding: 20px;
    }

    .info-section h2,
    .faq-section h2 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .info-item,
    .faq-item {
        padding: 16px;
    }

    .info-item h3,
    .faq-item h3 {
        font-size: 1.1rem;
    }

    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

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