:root {
            /* Modern color palette */
            --primary: #274c77;
            --primary-dark: #6096ba;
            --secondary: #8b5cf6;
            --success: #10b981;
            --warning: #f59e0b;
            --danger: #ef4444;
            --info: #3b82f6;
            
            /* Light theme */
            --bg-primary: #ffffff;
            --bg-secondary: #f8fafc;
            --bg-tertiary: #f1f5f9;
            --text-primary: #274c77;
            --text-secondary: #6096ba;
            --text-muted: #64748b;
            --accent-primary: #274c77;
            --accent-secondary: #6096ba;
            --accent-success: #10b981;
            --accent-warning: #f59e0b;
            --accent-danger: #ef4444;
            --border-light: #e2e8f0;
            --border-medium: #cbd5e1;
            --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
            --shadow-md: 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);
            --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
            --radius-xl: 1rem;
            --radius-2xl: 1.5rem;
        }

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

        html {
            scroll-behavior: smooth;
            font-size: 16px;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.6;
            transition: background-color 0.3s ease, color 0.3s ease;
            min-height: 100vh;padding-top: 70px;
        }

        /* Typography */
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Poppins', sans-serif;
            font-weight: 600;
            line-height: 1.2;
        }

        .container {
            width: 100%;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1rem;
        }

        /* Header */
        .headernew {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1rem;
            border-bottom: 1px solid var(--border-light);
            background-color: var(--bg-primary);
            position: relative;
            box-shadow: var(--shadow-sm);
        }

        .logo-text h1 {
            font-size: 1.25rem;
            font-weight: 700;
            line-height: 1.2;
        }

        .logo-text p {
            color: var(--text-muted);
            font-size: 0.75rem;
        }

        @media (min-width: 640px) { 
            .logo-text h1 {
                font-size: 1.5rem;
            }
            
            .logo-text p {
                display: block;
                font-size: 0.875rem;
            }
        }

        .theme-toggle {
            background: transparent;
            border: none;
            border-radius: var(--radius-md);
            padding: 0.5rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            cursor: pointer;
            transition: all 0.2s ease;
            color: var(--text-secondary);
        }

        .theme-toggle:hover {
            color: var(--accent-primary);
            transform: translateY(-1px);
        }

        .theme-toggle svg {
            width: 1.25rem;
            height: 1.25rem;
        }

        /* Mobile menu toggle */
        .mobile-menu-toggle {
            display: none;
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-size: 1.25rem;
            cursor: pointer;
        }

        @media (max-width: 768px) {
            .mobile-menu-toggle {
                display: block;
            }
            
            .headernew {
                padding: 0.75rem 0;
            }
        }

        /* Main Grid Layout - Mobile First */
        .main-grid {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            margin: 1.5rem 0 2rem;
        }

        @media (min-width: 1024px) {
            .main-grid {
                display: grid;
                grid-template-columns: 2fr 1fr;
                gap: 2rem;
            }
        }

        /* Cards */
        .card {
            background: var(--bg-secondary);
            border-radius: var(--radius-xl);
            box-shadow: var(--shadow-md);
            padding: 1.25rem;
            margin-bottom: 1.25rem;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

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

        @media (min-width: 640px) {
            .card {
                padding: 1.5rem;
            }
        }

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

        .card-title {
            font-size: 1.125rem;
            font-weight: 600;
            color: var(--text-primary);
        }

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

        /* Loan Type Selector - Mobile Optimized */
        .loan-type-selector {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.5rem;
            margin-bottom: 1.5rem;
        }

        @media (min-width: 640px) {
            .loan-type-selector {
                grid-template-columns: repeat(3, 1fr);
                gap: 0.75rem;
            }
        }

        @media (min-width: 1024px) {
            .loan-type-selector {
                grid-template-columns: repeat(5, 1fr);
            }
        }

        .loan-type-btn {
            padding: 0.75rem 0.5rem;
            border: 2px solid var(--border-light);
            border-radius: var(--radius-md);
            background: var(--bg-primary);
            color: var(--text-secondary);
            font-weight: 500;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 0.75rem;
            min-height: 50px;
        }

        .loan-type-btn:hover {
            border-color: var(--accent-primary);
            transform: translateY(-2px);
        }

        .loan-type-btn.active {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            border-color: transparent;
            box-shadow: var(--shadow-md);
        }

        @media (min-width: 640px) {
            .loan-type-btn {
                font-size: 0.875rem;
                padding: 0.875rem 0.5rem;
                min-height: 60px;
            }
        }

        /* Form Grid - Responsive */
        .form-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1rem;
        }

        @media (min-width: 640px) {
            .form-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 1.25rem;
            }
        }

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

        .form-label {
            display: block;
            font-size: 0.875rem;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 0.5rem;
        }

        .form-input {
            width: 100%;
            padding: 0.75rem 1rem;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-md);
            font-size: 1rem;
            color: var(--text-primary);
            transition: all 0.2s ease;
        }

        .form-input:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
        }

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

        @media (min-width: 640px) {
            .input-group {
                flex-direction: row;
            }
        }

        .input-group .form-input {
            flex: 1;
        }

        .input-group .form-select {
            width: 100%;
            min-width: 120px;
        }

        @media (min-width: 640px) {
            .input-group .form-select {
                width: auto;
            }
        }

        .form-select {
            padding: 0.75rem 1rem;
            background: var(--bg-primary);
            border: 1px solid var(--border-light);
            border-radius: var(--radius-md);
            font-size: 1rem;
            color: var(--text-primary);
            cursor: pointer;
        }

        .form-select:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
        }

        .form-hint {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 0.25rem;
            line-height: 1.4;
        }

        /* Range Slider */
        .range-slider {
            width: 100%;
            margin-top: 0.5rem;
            -webkit-appearance: none;
            height: 6px;
            background: var(--border-light);
            border-radius: 3px;
            outline: none;
        }

        .range-slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background: var(--accent-primary);
            cursor: pointer;
            border: 2px solid var(--bg-primary);
            box-shadow: var(--shadow-md);
        }

        .range-labels {
            display: flex;
            justify-content: space-between;
            margin-top: 0.25rem;
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        /* Buttons - Touch Friendly */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            padding: 0.875rem 1.5rem;
            border-radius: var(--radius-md);
            font-weight: 600;
            font-size: 0.875rem;
            cursor: pointer;
            transition: all 0.2s ease;
            border: none;
            min-height: 44px;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            box-shadow: var(--shadow-md);
        }

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

        .btn-secondary {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            border: 1px solid var(--border-light);
        }

        .btn-secondary:hover, .btn-secondary:active {
            background: var(--border-light);
        }

        .btn-group {
            display: grid;
            grid-template-columns: 1fr;
            gap: 0.75rem;
            margin-top: 1.5rem;
        }

        @media (min-width: 640px) {
            .btn-group {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        /* EMI Summary - Mobile Stacked */
        .emi-summary {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        @media (min-width: 640px) {
            .emi-summary {
                grid-template-columns: repeat(2, 1fr);
            }
        }

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

        .summary-card {
            background: var(--bg-primary);
            border-radius: var(--radius-lg);
            padding: 1.25rem;
            text-align: center;
            box-shadow: var(--shadow-sm);
        }

        .summary-card.highlight {
            background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), transparent);
            border: 2px solid var(--accent-primary);
        }

        .summary-label {
            font-size: 0.875rem;
            color: var(--text-muted);
            margin-bottom: 0.5rem;
        }

        .summary-value {
            font-size: 1.5rem;
            font-weight: 700;
            color: var(--accent-primary);
            margin-bottom: 0.5rem;
        }

        @media (min-width: 768px) {
            .summary-value {
                font-size: 1.75rem;
            }
        }

        .summary-card.highlight .summary-value {
            color: var(--accent-primary);
        }

        .summary-subvalue {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        /* Charts - Mobile Responsive */
        .chart-container {
            position: relative;
            height: 250px;
            margin-bottom: 1.5rem;
        }

        @media (min-width: 768px) {
            .chart-container {
                height: 300px;
            }
        }

        /* Payment Breakdown - Mobile Stacked */
        .payment-breakdown {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        @media (min-width: 640px) {
            .payment-breakdown {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        .breakdown-card {
            background: var(--bg-primary);
            border-radius: var(--radius-lg);
            padding: 1.25rem;
        }

        .breakdown-card h4 {
            font-size: 1rem;
            margin-bottom: 1rem;
            color: var(--text-primary);
        }

        .breakdown-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.75rem;
            font-size: 0.875rem;
        }

        .breakdown-item:last-child {
            margin-bottom: 0;
        }

        /* Table Container - Mobile Scrollable */
        .table-container {
            width: 100%;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin: 1rem 0;
            border: 1px solid var(--border-light);
            border-radius: var(--radius-md);
            background: var(--bg-secondary);
        }

        /* Amortization Table */
        .amortization-table {
            width: 100%;
            min-width: 700px;
            border-collapse: collapse;
        }

        .amortization-table th,
        .amortization-table td {
            padding: 0.75rem 1rem;
            text-align: left;
            border-bottom: 1px solid var(--border-light);
            font-size: 0.875rem;
        }

        .amortization-table th {
            background: var(--bg-tertiary);
            font-weight: 600;
            color: var(--text-primary);
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .amortization-table tr:hover td {
            background: var(--bg-primary);
        }

        /* Sidebar - Mobile Hidden by Default */
        .sidebar-column {
            display: none;
        }

        @media (min-width: 1024px) {
            .sidebar-column {
                display: block;
            }
        }

        .sidebar-section {
            margin-bottom: 1.5rem;
        }

        .history-list {
            max-height: 300px;
            overflow-y: auto;
        }

        .history-item {
            padding: 0.875rem;
            border-radius: var(--radius-md);
            background: var(--bg-primary);
            margin-bottom: 0.75rem;
            cursor: pointer;
            transition: all 0.2s ease;
            border-left: 3px solid var(--accent-primary);
        }

        .history-item:hover {
            background: var(--bg-tertiary);
        }

        .history-title {
            font-weight: 600;
            margin-bottom: 0.25rem;
            font-size: 0.875rem;
        }

        .history-details {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        /* Prepayment Section */
        .prepayment-section {
            margin-top: 1.5rem;
            padding-top: 1.5rem;
            border-top: 1px solid var(--border-light);
        }

        .prepayment-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1rem;
            margin-top: 1rem;
        }

        @media (min-width: 768px) {
            .prepayment-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 1.25rem;
            }
        }

        /* Mobile Menu Overlay */
        .mobile-menu-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            display: none;
            align-items: center;
            justify-content: center;
        }

        .mobile-menu-content {
            background: var(--bg-primary);
            border-radius: var(--radius-xl);
            padding: 2rem;
            width: 90%;
            max-width: 400px;
            max-height: 80vh;
            overflow-y: auto;
        }

        .mobile-menu-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
        }

        .mobile-menu-close {
            background: transparent;
            border: none;
            color: var(--text-secondary);
            font-size: 1.5rem;
            cursor: pointer;
        }

        /* Tooltips */
        .tooltip {
            position: relative;
            display: inline-block;
        }

        .tooltip .tooltip-text {
            visibility: hidden;
            width: 280px;
            background-color: var(--bg-secondary);
            color: var(--text-primary);
            text-align: left;
            border-radius: var(--radius-md);
            padding: 0.75rem;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            transform: translateX(-50%);
            opacity: 0;
            transition: opacity 0.3s;
            box-shadow: var(--shadow-lg);
            font-size: 0.875rem;
            line-height: 1.5;
        }

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

        .info-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--bg-tertiary);
            color: var(--text-muted);
            font-size: 0.75rem;
            margin-left: 0.25rem;
            cursor: help;
        }

        /* Loading Spinner */
        .spinner {
            display: none;
            width: 40px;
            height: 40px;
            border: 3px solid var(--border-light);
            border-top-color: var(--accent-primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 0 auto;
        }

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

        /* Print Styles */
        @media print {
            .headernew, .sidebar-column, .footer, .btn-group, .mobile-ad, .mobile-menu-toggle, .theme-toggle, .noprint2 {
                display: none !important;
            }
            
            .card {
                box-shadow: none;
                border: 1px solid #ccc;
            }
            
            .main-grid {
                display: block;
            }
            
            .chart-container {
                height: 200px;
            }
        }

        /* Touch device optimizations */
        @media (hover: none) and (pointer: coarse) {
            .btn:active {
                transform: scale(0.98);
            }
            
            .form-input:focus,
            .form-select:focus {
                box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
            }
        }

        /* Prevent zoom on input focus for iOS */
        @media (max-width: 768px) {
            input[type="number"],
            input[type="text"],
            select {
                font-size: 16px;
            }
        }