:root {
    /* Primary Brand Colors */
    --primary: #274c77;
    --primary-dark: #1c3a5d;
    --primary-light: #3a5f8d;
    --primary-rgb: 39, 76, 119;
    
    /* Secondary Brand Colors */
    --secondary: #6096ba;
    --secondary-dark: #4a7ba0;
    --secondary-light: #7aa7c9;
    --secondary-rgb: 96, 150, 186;
    
    /* Accent Colors */
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    
    /* Light Theme */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-surface: #f1f5f9;
    --bg-input: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    --border-dark: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(39, 76, 119, 0.12), 0 10px 10px -5px rgba(39, 76, 119, 0.06);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    
    /* Loan Colors */
    --loan-1: #274c77;
    --loan-2: #6096ba;
    --loan-3: #f59e0b;
    --loan-4: #8b5cf6;
    
    /* Transition */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE STYLES ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
	padding: 10px;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";padding-top: 70px;
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

/* ===== LAYOUT CONTAINERS ===== */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 3vw, 2rem);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.025em;
}

h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
}

h2 {
    font-size: clamp(1.5rem, 3vw, 1.875rem);
}

h3 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
}

p {
    margin-bottom: 1rem;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== HEADER ===== */
.app-header {
    position: relative;
    background: var(--bg-body);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    padding: 1.25rem 0;
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}


.brand-text {
    flex: 1;
}

.brand-text h1 {
    margin-bottom: 0.25rem;
    font-weight: 800;
}

.brand-text p {
    color: var(--text-muted);
    font-size: clamp(0.875rem, 1.5vw, 0.9375rem);
    line-height: 1.4;
}

/* ===== CONTROL BAR ===== */
.control-bar {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: clamp(1.25rem, 2vw, 1.75rem);
    margin: 1.5rem 0;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.control-info {
    flex: 1;
    min-width: 300px;
}

.control-info h3 {
    margin-bottom: 0.5rem;
}

.control-info p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.loan-counter {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-surface);
    padding: 0.375rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.counter-btn {
    padding: clamp(0.625rem, 1.5vw, 0.75rem) clamp(1rem, 2vw, 1.25rem);
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: clamp(0.8125rem, 1.5vw, 0.875rem);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.counter-btn:hover:not(.active) {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
    transform: translateY(-1px);
}

.counter-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ===== MAIN GRID - RESPONSIVE LAYOUT ===== */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
    margin: 2rem 0;
}

@media (min-width: 1024px) {
    .main-grid.grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .main-grid.grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .main-grid.grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1280px) {
    .main-grid.grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== LOAN CARD ===== */
.loan-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: clamp(1.25rem, 2vw, 1.75rem);
    box-shadow: var(--shadow-md);
    border-top: 5px solid var(--loan-1);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.loan-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--border-medium);
}

.loan-card[data-loan="1"] { border-top-color: var(--loan-1); }
.loan-card[data-loan="2"] { border-top-color: var(--loan-2); }
.loan-card[data-loan="3"] { border-top-color: var(--loan-3); }
.loan-card[data-loan="4"] { border-top-color: var(--loan-4); }

.loan-card.best {
    border-color: var(--accent-success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), var(--bg-card));
    animation: pulse-glow 2s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from {
        box-shadow: var(--shadow-xl), 0 0 20px rgba(16, 185, 129, 0.1);
    }
    to {
        box-shadow: var(--shadow-xl), 0 0 30px rgba(16, 185, 129, 0.2);
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.loan-number {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.loan-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.loan-card.best .loan-circle {
    background: var(--accent-success);
    color: white;
}

.loan-name-input {
    background: transparent;
    border: none;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    max-width: 200px;
    padding: 0.25rem 0;
    outline: none;
    border-bottom: 2px solid transparent;
    transition: border-color var(--transition-fast);
}

.loan-name-input:focus {
    border-bottom-color: var(--primary);
}

.loan-badge {
    padding: 0.375rem 0.875rem;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    white-space: nowrap;
    flex-shrink: 0;
}

.loan-card.best .loan-badge {
    background: var(--accent-success);
    color: white;
}

/* ===== COMPACT FORM ===== */
.compact-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
}

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

.form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.value-display {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: right;
    min-width: 100px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-input::placeholder {
    color: var(--text-light);
    opacity: 0.7;
}

.input-icon {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    pointer-events: none;
}

/* Remove number input spinners */
.form-input::-webkit-inner-spin-button,
.form-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* ===== ADVANCED SLIDER ===== */
.slider-container {
    margin-top: 0.75rem;
}

.modern-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--bg-surface), var(--border-light));
    border-radius: 3px;
    outline: none;
    margin: 0.5rem 0;
    cursor: pointer;
}

.modern-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid var(--bg-card);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.modern-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-xl);
}

.modern-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid var(--bg-card);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    font-weight: 500;
}

/* ===== ACTION SECTION ===== */
.action-section {
    display: flex;
    justify-content: center;
    gap: clamp(0.75rem, 2vw, 1rem);
    margin: 3rem 0;
    flex-wrap: wrap;
}

.btn {
    padding: clamp(0.875rem, 1.5vw, 1rem) clamp(1.5rem, 2.5vw, 2rem);
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: clamp(0.875rem, 1.5vw, 0.9375rem);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
    text-align: center;
    min-height: 48px;
    min-width: 140px;
    white-space: nowrap;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(40, 40);
        opacity: 0;
    }
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 14px 0 rgba(var(--primary-rgb), 0.25);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(var(--primary-rgb), 0.35);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== RESULTS SECTION ===== */
.results-section {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    margin: 3rem 0;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ===== BEST CHOICE BANNER ===== */
.best-choice-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(39, 76, 119, 0.1));
    border: 2px solid var(--accent-success);
    border-radius: var(--radius-lg);
    padding: clamp(1.5rem, 2.5vw, 2rem);
    margin-bottom: 2.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: slideIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.best-choice-banner::before {
    content: 'BEST CHOICE';
    position: absolute;
    top: 25px;
    right: -38px;
    background: var(--accent-success);
    color: white;
    padding: 0.375rem 2.5rem;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    transform: rotate(45deg);
    box-shadow: var(--shadow);
    z-index: 1;
}

.best-choice-title {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    font-weight: 800;
    color: var(--accent-success);
    margin-bottom: 0.5rem;
}

.savings-amount {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 900;
    color: var(--accent-success);
    margin: 0.75rem 0;
    line-height: 1.1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===== CHARTS CONTAINER ===== */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
    gap: clamp(1rem, 2vw, 2rem);
    margin: 2.5rem 0;
}

.chart-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    height: clamp(250px, 40vh, 350px);
    position: relative;
    border: 1px solid var(--border-light);
    transition: transform var(--transition-normal);
}

.chart-card:hover {
    transform: translateY(-2px);
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== RESULTS GRID ===== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: clamp(1rem, 1.5vw, 1.5rem);
    margin: 2.5rem 0;
}

.result-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: clamp(1.25rem, 2vw, 1.75rem);
    text-align: center;
    border-top: 4px solid var(--loan-1);
    transition: all var(--transition-normal);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

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

.result-card[data-loan="1"] { border-top-color: var(--loan-1); }
.result-card[data-loan="2"] { border-top-color: var(--loan-2); }
.result-card[data-loan="3"] { border-top-color: var(--loan-3); }
.result-card[data-loan="4"] { border-top-color: var(--loan-4); }

.result-card.best {
    border-top-color: var(--accent-success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-surface));
    position: relative;
    overflow: hidden;
}

.result-card.best::before {
    content: '🏆 BEST';
    position: absolute;
    top: 10px;
    right: -30px;
    background: var(--accent-success);
    color: white;
    padding: 0.25rem 2rem;
    font-size: 0.75rem;
    font-weight: 800;
    transform: rotate(45deg);
}

.result-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-value {
    font-size: clamp(1.5rem, 2.5vw, 1.75rem);
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.result-subtext {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* ===== COMPARISON TABLE ===== */
.comparison-table {
    width: 100%;
    overflow-x: auto;
    margin: 2rem 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    -webkit-overflow-scrolling: touch;
}

.comparison-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 700px;
}

.comparison-table th {
    background: var(--bg-surface);
    padding: 1.25rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-light);
    position: sticky;
    left: 0;
    white-space: nowrap;
}

.comparison-table th:first-child {
    border-radius: var(--radius-lg) 0 0 0;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-surface);
}

.comparison-table td {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
    transition: background-color var(--transition-fast);
}

.comparison-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-card);
    font-weight: 600;
    color: var(--text-secondary);
}

.comparison-table tr:hover td {
    background: rgba(var(--primary-rgb), 0.03);
}

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

/* ===== INFO SECTIONS ===== */
.info-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
    margin: 3rem 0;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: clamp(1.5rem, 2vw, 2rem);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
    transition: transform var(--transition-normal);
}

.info-card:hover {
    transform: translateY(-2px);
}

.info-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.info-card ul {
    list-style: none;
    padding-left: 0;
}

.info-card li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    line-height: 1.5;
}

.info-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.info-card li strong {
    color: var(--text-primary);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ===== LOADING STATES ===== */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--border-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ENHANCEMENTS ===== */
@media (max-width: 1024px) {
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .brand {
        justify-content: center;
        text-align: center;
    }
    
    .control-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .loan-counter {
        justify-content: center;
    }
    
    .quick-actions {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .main-grid.grid-4 {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-card {
        height: 280px;
    }
    
    .action-section {
        flex-direction: space-responsive;
    }
    
    .btn {
        width: 100%;
    }
    
    .loan-card {
        padding: 1.25rem;
    }
    
    .results-section {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .control-bar {
        padding: 1rem;
    }
    
    .loan-counter {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .counter-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .comparison-table {
        margin: 1rem -1rem;
        width: calc(100% + 2rem);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .info-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .brand {
        flex-direction: column;
        text-align: center;
    }
    
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .loan-number {
        margin-bottom: 0.5rem;
    }
    
    .loan-badge {
        align-self: flex-start;
    }
    
    .form-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .value-display {
        text-align: left;
        min-width: auto;
    }
    
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .counter-btn,
    .loan-card {
        min-height: 44px;
    }
    
    .form-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    .modern-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }
    
    /* Reduce hover effects on touch devices */
    .loan-card:hover,
    .result-card:hover,
    .chart-card:hover,
    .info-card:hover {
        transform: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .app-header,
    .control-bar,
    .action-section,
    .ad-container,
    .footer-links,
    .btn-secondary {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    .loan-card,
    .results-section,
    .info-card {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .chart-card {
        height: 300px !important;
    }
    
    a {
        color: black !important;
        text-decoration: underline;
    }
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-light: #000000;
        --border-medium: #000000;
        --border-dark: #000000;
    }
    
    .loan-card,
    .result-card,
    .chart-card,
    .info-card {
        border: 2px solid black;
    }
    
    .btn-primary {
        border: 2px solid black;
    }
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: var(--radius-sm);
    border: 2px solid var(--bg-surface);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* ===== iOS SAFARI FIXES ===== */
@supports (-webkit-touch-callout: none) {
    .app-header {
        padding-top: max(1.25rem, env(safe-area-inset-top));
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
@media (prefers-reduced-transparency: reduce) {
    .app-header {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bg-body);
    }
}

/* ===== ERROR STATES ===== */
.form-input.error {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.05);
}

.error-message {
    color: var(--accent-danger);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== SUCCESS STATES ===== */
.success-message {
    color: var(--accent-success);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease;
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    width: 200px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--primary-rgb), 0.1);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== RESPONSIVE SPACING ===== */
.space-responsive {
    padding: clamp(1rem, 3vw, 2rem);
    margin: clamp(1rem, 2vw, 1.5rem) 0;
}

/* ===== GRID FALLBACK ===== */
@supports not (display: grid) {
    .main-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 1.5rem;
    }
    
    .loan-card {
        flex: 1 1 300px;
        max-width: calc(50% - 1.5rem);
    }
    
    @media (max-width: 768px) {
        .loan-card {
            max-width: 100%;
        }
    }
}

/* ===== FINAL POLISH ===== */
*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

img {
    max-width: 100%;
    height: auto;
}

/* Ensure smooth rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}
/* ===== SIMPLE BUTTON STYLES ===== */

/* Base Button */
.btn {
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 48px;
    min-width: 140px;
    justify-content: center;
}

/* Primary Button (Compare) */
.btn-primary {
    background: linear-gradient(135deg, #274c77, #1c3a5d);
    color: white;
    box-shadow: 0 4px 12px rgba(39, 76, 119, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 76, 119, 0.35);
}

/* Secondary Button (Reset, Save) */
.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
}

/* Quick Demo Button */
#quickCompare {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
    animation: pulse 2s infinite;
}

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

#quickCompare:hover {
    animation: none;
    transform: translateY(-2px);
}

/* Theme Toggle */
#themeToggle {
    background: white;
    color: #475569;
    border: 2px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Counter Buttons */
.counter-btn {
    padding: 0.75rem 1.25rem;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.counter-btn:hover {
    border-color: #274c77;
    color: #274c77;
}

.counter-btn.active {
    background: #274c77;
    color: white;
    border-color: #274c77;
}

/* Dark Mode */
[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}

[data-theme="dark"] .btn-secondary:hover {
    background: #475569;
}

[data-theme="dark"] #themeToggle {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #475569;
}

/* Mobile */
@media (max-width: 768px) {
    .btn {
        width: 100%;
        min-width: auto;
    }
    
    .counter-btn {
        flex: 1;
        text-align: center;
    }
}