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

:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --info: #0891b2;
    --light: #f3f4f6;
    --border: #d1d5db;
    --text: #1f2937;
    --text-muted: #6b7280;
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f97316;
    --danger: #ef4444;
    --info: #06b6d4;
    --light: #1f2937;
    --border: #374151;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --bg: #111827;
    --bg-secondary: #1f2937;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    min-height: 100vh;
    padding: 1rem;
    animation: fadeIn 0.5s ease-out;
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes successCheck {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

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

.card {
    background: var(--bg);
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    animation: fadeIn 0.6s ease-out;
    transition: background 0.3s, box-shadow 0.3s;
}

[data-theme="dark"] .card {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: space-between;
}

.header > div {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem;
    border-radius: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.icon-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.2), transparent);
    pointer-events: none;
}

.icon-box svg {
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.icon-box:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.4);
}

.icon-box:hover svg {
    transform: rotate(10deg) scale(1.1);
}

[data-theme="dark"] .icon-box {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .icon-box:hover {
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.5);
}

.dark-mode-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.dark-mode-toggle:hover {
    background: var(--light);
    border-color: var(--primary);
}

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

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.language-toggle {
    background: none;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: var(--text);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    min-width: 40px;
    height: 40px;
}

.language-toggle:hover {
    background: var(--light);
    border-color: var(--primary);
}

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

h1 {
    font-size: 1.875rem;
    font-weight: bold;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0.25rem 0;
    line-height: 1.3;
}

.slider-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(37, 99, 235, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
}

/* Range Slider */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: var(--light);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    margin: 0.75rem 0;
    transition: background 0.2s;
    display: block;
}

.slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: var(--light);
    border-radius: 5px;
    border: 1px solid var(--border);
}

.slider::-moz-range-track {
    width: 100%;
    height: 6px;
    background: var(--light);
    border-radius: 5px;
    border: 1px solid var(--border);
}

.slider::-moz-range-progress {
    background-color: var(--primary);
    height: 6px;
    border-radius: 5px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
    margin-top: -6px;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    transition: all 0.2s;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.info-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0;
    transition: color 0.2s;
}

.info-btn:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
}

.input-wrapper {
    position: relative;
}

input[type="number"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg);
    color: var(--text);
}

input[type="number"]::placeholder,
select::placeholder {
    color: var(--text-muted);
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[type="number"]:disabled {
    background: var(--light);
    cursor: not-allowed;
    opacity: 0.6;
}

input[type="number"].error {
    border-color: var(--danger);
    background: rgba(220, 38, 38, 0.05);
}

.validation-error {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
    animation: slideInUp 0.2s ease-out;
}

.input-suffix {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
}

.period-inputs {
    display: flex;
    gap: 0.75rem;
}

.period-inputs input {
    flex: 1;
}

.period-inputs select {
    width: auto;
    min-width: 120px;
}

.input-wrapper.period-picker {
    display: flex;
    gap: 0.75rem;
}

.input-wrapper.period-picker input {
    flex: 1;
}

.input-wrapper.period-picker select {
    width: auto;
    min-width: 120px;
}

.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0.5rem 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-radius: 0.25rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.checkbox-wrapper label {
    cursor: pointer;
    margin: 0;
}

.hint {
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 0.5rem;
    animation: slideInUp 0.3s ease-out;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--light);
}

.btn {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

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

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.05);
}

.btn-tertiary {
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(22, 163, 74, 0.3);
}

.btn-tertiary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.4);
}

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

#results {
    margin-top: 2rem;
    animation: slideInUp 0.5s ease-out;
}

.results-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.result-card {
    padding: 1.5rem;
    border-radius: 0.75rem;
    border-left: 4px solid;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 100%);
    pointer-events: none;
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.result-card.blue {
    background: #eff6ff;
    border-color: var(--primary);
}

.result-card.green {
    background: #f0fdf4;
    border-color: var(--success);
}

.result-card.purple {
    background: #faf5ff;
    border-color: #9333ea;
}

.result-card.orange {
    background: #fff7ed;
    border-color: var(--warning);
}

[data-theme="dark"] .result-card.blue {
    background: rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .result-card.green {
    background: rgba(34, 197, 74, 0.1);
}

[data-theme="dark"] .result-card.purple {
    background: rgba(147, 51, 234, 0.1);
}

[data-theme="dark"] .result-card.orange {
    background: rgba(249, 115, 22, 0.1);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.result-header span {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.result-icon {
    font-size: 1.5rem;
}

.result-value {
    font-size: 1.75rem;
    font-weight: bold;
    position: relative;
    z-index: 1;
}

.result-card.blue .result-value {
    color: var(--primary);
}

.result-card.green .result-value {
    color: var(--success);
}

.result-card.purple .result-value {
    color: #9333ea;
}

.result-card.orange .result-value {
    color: var(--warning);
}

.method-badge {
    display: inline-block;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(34, 197, 94, 0.1) 100%);
    border: 2px solid var(--primary);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0.5rem 0 1rem 0;
    animation: slideInUp 0.4s ease-out;
    transition: background 0.3s, border-color 0.3s;
}

[data-theme="dark"] .method-badge {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(34, 197, 74, 0.15) 100%);
}

.summary {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--light) 0%, rgba(219, 234, 254, 0.5) 100%);
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary);
    animation: slideInUp 0.5s ease-out;
    transition: background 0.3s;
}

[data-theme="dark"] .summary {
    background: linear-gradient(135deg, #1f2937 0%, rgba(31, 41, 55, 0.8) 100%);
}

.summary h3 {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#summaryContent {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

#summaryContent p {
    margin: 0.25rem 0;
}

.summary-highlight {
    font-size: 0.875rem;
    color: var(--success);
    margin-top: 0.5rem;
    font-weight: 600;
}

/* New Sections: Affordability, Amortization, Transparency */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-helper {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1rem;
}

.toggle-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text);
    transition: transform 0.3s;
}

.toggle-btn.active {
    transform: rotate(180deg);
}

/* Affordability Section */
.affordability-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.05) 0%, rgba(34, 197, 94, 0.02) 100%);
    border-radius: 0.75rem;
    border-left: 4px solid var(--success);
}

.affordability-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.affordability-bar {
    height: 1.5rem;
    background: #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    position: relative;
}

.affordability-bar .bar-fill {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.affordability-text {
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

/* Amortization Section */
.amortization-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(59, 130, 246, 0.02) 100%);
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary);
}

.schedule-table {
    overflow-x: auto;
    margin-top: 1rem;
}

.schedule-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.schedule-table th {
    background: var(--bg-secondary);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
}

.schedule-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.schedule-table tr:hover {
    background: var(--bg-secondary);
}

/* Transparency Section */
.transparency-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(59, 130, 246, 0.02) 100%);
    border-radius: 0.75rem;
    border-left: 4px solid var(--info);
}

.transparency-content p {
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0.75rem 0;
    color: var(--text);
}

.footer-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.footer-text a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-text a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Section Styling */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(37, 99, 235, 0.05);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.section-header:hover {
    background: rgba(37, 99, 235, 0.1);
}

[data-theme="dark"] .section-header {
    background: rgba(59, 130, 246, 0.1);
}

[data-theme="dark"] .section-header:hover {
    background: rgba(59, 130, 246, 0.15);
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.toggle-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--primary);
    transition: transform 0.2s;
}

.toggle-btn.active {
    transform: rotate(180deg);
}

/* Amortization Schedule */
.amortization-section,
.comparison-section {
    margin-top: 2rem;
    animation: slideInUp 0.5s ease-out;
}

.schedule-table {
    overflow-x: auto;
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
}

[data-theme="dark"] .schedule-table {
    background: var(--bg-secondary);
}

.table-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
    font-weight: 600;
    color: var(--primary);
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0.75rem;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--light);
    font-size: 0.875rem;
}

.table-row:last-child {
    border-bottom: none;
}

.table-row:nth-child(odd) {
    background: rgba(37, 99, 235, 0.02);
}

[data-theme="dark"] .table-row:nth-child(odd) {
    background: rgba(59, 130, 246, 0.1);
}

.loading-text,
.info-text {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.875rem;
}

/* Comparison Section */
.comparison-result {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.comparison-card {
    padding: 1rem;
    background: var(--light);
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary);
}

[data-theme="dark"] .comparison-card {
    background: var(--bg-secondary);
}

.comparison-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.comparison-value {
    font-weight: 600;
    color: var(--text);
}

.comparison-difference {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
    font-weight: 600;
}

.difference-positive {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.difference-negative {
    background: rgba(220, 38, 38, 0.2);
    color: var(--danger);
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

[data-theme="dark"] .popup-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.popup-content {
    background: var(--bg);
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 32rem;
    width: 100%;
    padding: 1.5rem;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideInUp 0.3s ease-out;
    transition: background 0.3s;
}

.popup-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
}

.popup-close:hover {
    background: var(--light);
    color: var(--text);
}

.popup-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.popup-icon {
    background: rgba(37, 99, 235, 0.15);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1.5rem;
    min-width: 3rem;
    text-align: center;
}

.popup-header h3 {
    font-size: 1.125rem;
    font-weight: bold;
    color: var(--text);
    margin-top: 0.25rem;
}

#popupDescription {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.popup-formula {
    background: rgba(37, 99, 235, 0.08);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
    transition: background 0.3s;
}

[data-theme="dark"] .popup-formula {
    background: rgba(59, 130, 246, 0.15);
}

.formula-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

#formulaContent {
    font-size: 0.8rem;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    margin: 0;
    word-break: break-word;
}

.popup-button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.popup-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

/* Success Notification */
.success-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--success);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(22, 163, 74, 0.3);
    animation: slideInUp 0.3s ease-out;
    z-index: 2000;
}

.success-notification::before {
    content: '✓';
    display: inline-block;
    margin-right: 0.75rem;
    font-weight: bold;
    font-size: 1.25rem;
    animation: successCheck 0.4s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
    .card {
        padding: 1.25rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

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

    .form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn {
        width: 100%;
        padding: 0.75rem 1rem;
    }

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

    .table-header,
    .table-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .slider {
        height: 5px;
    }

    .affordability-section,
    .amortization-section,
    .transparency-section,
    .summary,
    .comparison-section {
        padding: 1rem;
        margin-top: 1rem;
    }

    .section-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .schedule-table {
        font-size: 0.75rem;
    }

    .schedule-table th,
    .schedule-table td {
        padding: 0.5rem;
    }

    .label-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .slider-value {
        margin-top: 0.25rem;
    }

    input[type="number"],
    select {
        font-size: 16px !important;
    }

    .success-notification {
        top: auto;
        bottom: 2rem;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        max-width: 90vw;
    }
}

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

    .card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    h1 {
        font-size: 1.1rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    h3 {
        font-size: 1rem;
    }

    .subtitle {
        font-size: 0.65rem;
    }

    .form-group {
        gap: 0.25rem;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .input-wrapper.period-picker {
        flex-direction: row;
        gap: 0.5rem;
    }

    .input-wrapper.period-picker input {
        flex: 1;
    }

    .input-wrapper.period-picker select {
        min-width: auto;
        flex: 1;
    }

    .helper-text {
        font-size: 0.7rem;
    }

    .result-card {
        padding: 0.75rem;
    }

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

    button {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }

    .affordability-bar {
        height: 1.25rem;
    }

    .schedule-table {
        font-size: 0.65rem;
    }

    .schedule-table th,
    .schedule-table td {
        padding: 0.4rem;
    }
}