        :root {
            --primary: #0ea5e9;
            --primary-gradient: linear-gradient(135deg, #0ea5e9, #0d9488);
            --secondary: #0f172a;
            --bg: #f8fafc;
            --bg-card: #ffffff;
            --white: #ffffff;
            --text-main: #1e293b;
            --text-muted: #64748b;
            --border: #cbd5e1;
            --border-subtle: rgba(0, 0, 0, 0.05);
            --warning: #f59e0b;
            --danger: #ef4444;
            --radius-btn: 14px;
            --radius-input: 14px;
            --radius-card: 32px;
            --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
            --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
            --max-width: 1440px;
            --gap-standard: 24px;
            --form-row-gap: 20px;
            --form-col-gap: 32px;
            --label-margin: 8px;
        }

        .animate-in {
            animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
        }

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

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

        *,
        *::before,
        *::after {
            box-sizing: border-box;
        }

        html,
        body {
            overflow-x: hidden;
            width: 100%;
            margin: 0;
            padding: 0;
        }

        body.portal-light {
            background: var(--bg);
            color: var(--text-main) !important;
            font-family: 'Outfit', sans-serif;
            margin: 0;
            padding: 0;
            overflow-x: hidden;
            width: 100%;
            overflow-y: auto;
            padding-bottom: 40px;
        }

        .portal-container {
            max-width: var(--max-width);
            margin: 0 auto;
            padding: 20px 24px;
        }

        .portal-header {
            display: grid;
            grid-template-columns: 48px 1fr 48px;
            width: 100%;
            align-items: center;
            gap: 20px;
            margin-bottom: 20px;
            text-align: center;
            position: relative;
            z-index: 20;
        }

        .header-back-btn {
            width: 54px;
            height: 54px;
            border-radius: 50%;
            background: white;
            border: 1px solid #cbd5e1;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--secondary);
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
            box-shadow: var(--shadow-sm);
            justify-self: start;
        }

        .header-back-btn:hover {
            border-color: var(--primary);
            color: var(--primary);
            transform: scale(1.05);
        }

        .portal-header-info {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .portal-header h1 {
            font-size: 28px;
            font-weight: 800;
            color: var(--primary);
            margin: 0;
            line-height: 1.2;
            letter-spacing: -0.5px;
        }

        .portal-header p {
            color: var(--text-muted);
            font-size: 18px;
            margin: 0;
            line-height: 1.4;
            opacity: 0.8;
        }



        .portal-card {
            background: var(--white);
            border-radius: var(--radius-card);
            box-shadow: var(--shadow-lg);
            border: 1px solid var(--border-subtle);
            padding: 32px;
            margin-bottom: var(--gap-standard);
            position: relative;
        }

        .step-indicator {
            display: flex;
            justify-content: space-between;
            margin-bottom: 40px;
            position: relative;
        }

        .step-indicator::before {
            content: '';
            position: absolute;
            top: 20px;
            left: 0;
            right: 0;
            height: 2px;
            background: #e2e8f0;
            z-index: 1;
        }

        .step {
            position: relative;
            z-index: 2;
            background: var(--bg);
            padding: 0 10px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
        }

        .step-number {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: #e2e8f0;
            color: var(--text-muted);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 16px;
            transition: all 0.3s;
            border: 2px solid var(--bg);
        }

        .step.active .step-number,
        .step.completed .step-number {
            background: var(--primary);
            color: white;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2);
        }

        .step.completed .step-number {
            font-size: 0;
        }

        .step.completed .step-number::after {
            content: '✓';
            font-size: 16px;
            font-weight: 800;
        }



        .step-label {
            font-size: 15px;
            font-weight: 600;
            color: var(--text-muted);
        }

        .step.active .step-label {
            color: var(--primary);
        }

        .portal-section {
            display: none;
            scroll-margin-top: 100px;
        }

        .portal-section.active {
            display: block;
            animation: fadeIn 0.4s ease-out;
        }

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

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

        .portal-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 20px;
        }

        .portal-form-group {
            margin-bottom: 20px;
        }

        .portal-label {
            display: block;
            font-size: 15px;
            font-weight: 600;
            color: var(--secondary) !important;
            margin-bottom: var(--label-margin);
            margin-top: 0;
            letter-spacing: -0.2px;
        }

        input.portal-input,
        select.portal-select,
        .portal-input,
        .portal-select {
            display: block;
            width: 100% !important;
            height: 52px !important;
            min-height: 52px !important;
            padding: 0 20px !important;
            background: #ffffff !important;
            border: 1px solid var(--border) !important;
            border-radius: var(--radius-input) !important;
            font-family: inherit !important;
            font-size: 16px !important;
            line-height: 52px !important;
            box-sizing: border-box !important;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
            color: var(--text-main) !important;
            appearance: none !important;
            -webkit-appearance: none !important;
            -moz-appearance: none !important;
        }

        .portal-select {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
            background-repeat: no-repeat !important;
            background-position: right 16px center !important;
            background-size: 20px !important;
            padding-right: 48px !important;
        }

        .portal-input {
            line-height: 50px !important;
            /* Center text in inputs */
        }

        .portal-input:focus,
        .portal-select:focus {
            border-color: var(--primary) !important;
            outline: none;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
        }

        .portal-input[readonly],
        .portal-input:disabled,
        .portal-select:disabled {
            cursor: not-allowed;
            background-color: #f1f5f9 !important;
            color: #64748b !important;
            border-color: #e2e8f0 !important;
            opacity: 1;
            box-shadow: none;
            -webkit-text-fill-color: #64748b;
        }

        .phone-input-container {
            display: flex;
            align-items: center;
            width: 100%;
            height: 56px;
            padding: 0 20px;
            border: 1px solid #cbd5e1 !important;
            border-radius: var(--radius-input);
            background-color: #fff !important;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
            box-sizing: border-box;
        }

        .phone-input-container:focus-within {
            border-color: var(--primary) !important;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
        }

        .phone-input-container span {
            margin-right: 8px;
            font-weight: 600;
            color: var(--secondary);
            font-size: 16px;
        }

        .phone-input-container input {
            border: none !important;
            outline: none !important;
            background: transparent !important;
            width: 100%;
            height: 100%;
            font-size: 16px;
            color: var(--secondary);
            padding: 0 !important;
            margin: 0 !important;
            font-family: inherit;
        }

        /* ========================================
           MODERN EXAM SELECTION SYSTEM
           ======================================== */

        /* Category Filter Chips */
        .category-filter-container {
            margin-bottom: 13px;
            padding-bottom: 10px;
            border-bottom: 2px solid #f1f5f9;
        }

        .category-chips {
            display: flex;
            gap: 8px;
            overflow-x: auto;
            padding: 4px 0;
            scrollbar-width: none;
            -ms-overflow-style: none;
        }

        @media (min-width: 769px) {
            .category-chips {
                flex-wrap: wrap;
                overflow-x: visible;
            }
        }

        .category-chips::-webkit-scrollbar {
            display: none;
        }

        .category-chip {
            height: 54px;
            padding: 0 24px;
            background: #ffffff;
            border: 1px solid #cbd5e1;
            border-radius: 27px;
            color: var(--text-muted);
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            white-space: nowrap;
        }

        .category-chip:hover {
            background: #f1f5f9;
            border-color: var(--primary);
            color: var(--primary);
        }

        .category-chip.active {
            background: var(--primary);
            border-color: var(--primary);
            color: white;
            box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
        }

        /* Exam Pack Grid - Responsive with fixed vertical rhythm */
        .exam-groups-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 16px;
            /* 8px base unit */
            margin-top: 0;
        }

        /* Modern Exam Pack Component */
        .exam-group-card {
            background: white;
            border: 1px solid var(--border-subtle);
            border-radius: var(--radius-card);
            padding: 28px;
            cursor: pointer;
            transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
            display: flex;
            flex-direction: column;
            gap: 16px;
            position: relative;
            overflow: hidden;
            box-sizing: border-box;
            max-width: 100%;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
        }

        .exam-group-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: var(--primary-gradient);
            opacity: 0;
            transition: opacity 0.3s;
        }

        .exam-group-card:hover {
            border-color: var(--primary);
            box-shadow: 0 15px 35px rgba(14, 165, 233, 0.08);
            transform: translateY(-6px);
        }

        .exam-group-card:hover::before {
            opacity: 0.5;
        }

        .exam-group-card.selected {
            border-color: var(--primary);
            background: linear-gradient(135deg, rgba(14, 165, 233, 0.03), rgba(13, 148, 136, 0.02));
            box-shadow: 0 0 0 1px var(--primary), 0 12px 32px rgba(14, 165, 233, 0.15);
        }

        .exam-group-card.selected::before {
            opacity: 1;
        }

        /* Card Header with Icon and Toggle */
        .exam-card-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 12px;
        }

        .exam-card-title-section {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            flex: 1;
        }

        .exam-card-icon {
            font-size: 24px;
            flex-shrink: 0;
            line-height: 1;
        }

        .exam-group-title {
            font-family: 'Outfit', sans-serif;
            font-weight: 700;
            font-size: 18px;
            color: var(--secondary);
            line-height: 1.3;
            margin: 0;
            letter-spacing: -0.3px;
        }

        /* Apple-style Toggle Switch */
        .exam-toggle {
            position: relative;
            width: 48px;
            height: 28px;
            flex-shrink: 0;
        }

        .exam-toggle input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #e2e8f0;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 28px;
        }

        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 22px;
            width: 22px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border-radius: 50%;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }

        .exam-toggle input:checked+.toggle-slider {
            background: var(--primary-gradient);
        }

        .exam-toggle input:checked+.toggle-slider:before {
            transform: translateX(20px);
        }

        /* Flex Tag Cloud for Exams */
        .exam-badge-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 4px;
        }

        .exam-badge {
            background: #f1f5f9;
            color: #475569;
            padding: 6px 12px;
            border-radius: 16px;
            font-size: 14px;
            font-weight: 500;
            line-height: 1.2;
            transition: all 0.2s;
        }

        .exam-group-card.selected .exam-badge {
            background: rgba(14, 165, 233, 0.1);
            color: var(--primary);
        }

        /* Marketplace View for Isolated Exams */
        .marketplace-container {
            margin-top: 20px;
        }

        .marketplace-header {
            border-bottom: 3px solid #f1f5f9;
            margin-bottom: 13px;
            padding-bottom: 10px;
        }

        .marketplace-title {
            font-size: 22px;
            font-weight: 800;
            color: var(--secondary);
            margin: 0 0 8px 0;
            letter-spacing: -0.5px;
        }

        .marketplace-subtitle {
            font-size: 15px;
            color: var(--text-muted);
            margin: 0;
            line-height: 1.5;
            opacity: 0.85;
        }

        /* Sticky Search Bar */
        .marketplace-search {
            position: sticky;
            top: 0;
            z-index: 10;
            background: var(--bg);
            padding: 16px 0;
            margin-bottom: 24px;
            border-bottom: 1px solid transparent;
            transition: all 0.3s;
        }

        .marketplace-search.is-sticky {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            border-bottom-color: #e2e8f0;
            padding: 12px 0;
        }

        .search-input-wrapper {
            position: relative;
        }

        .search-input-wrapper::before {
            content: '🔍';
            position: absolute;
            left: 16px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 18px;
            opacity: 0.5;
        }

        /* Payment Loading Overlay */
        .payment-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.95);
            z-index: 10000;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(10px);
            transition: all 0.4s ease;
        }

        .payment-overlay.active {
            display: flex;
        }

        .payment-loader {
            width: 64px;
            height: 64px;
            border: 6px solid #f3f3f3;
            border-top: 6px solid var(--primary);
            border-radius: 50%;
            animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
            margin-bottom: 24px;
            box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
        }

        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }

        .payment-overlay h2 {
            font-size: 24px;
            font-weight: 700;
            color: var(--secondary);
            margin: 0 0 8px 0;
        }

        .payment-overlay p {
            color: var(--text-muted);
            font-size: 16px;
            margin: 0;
        }

        .marketplace-search input {
            width: 100%;
            padding: 18px 20px 18px 52px;
            background: white;
            border: 2px solid #e2e8f0;
            border-radius: 28px;
            font-family: 'Outfit', sans-serif;
            font-size: 16px;
            transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
            line-height: 1.25;
            box-sizing: border-box;
        }

        .marketplace-search input:focus {
            border-color: var(--primary);
            outline: none;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
        }

        /* Marketplace Grid - Unified with Exam Packs */
        .marketplace-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 16px;
            margin-bottom: 24px;
        }

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

        .marketplace-category-title {
            grid-column: 1 / -1;
            font-size: 14px;
            font-weight: 700;
            color: var(--secondary);
            margin: 24px 0 8px 4px;
            display: flex;
            align-items: center;
            gap: 8px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            opacity: 0.7;
        }

        .marketplace-card {
            background: white;
            border: 1px solid var(--border-subtle);
            border-radius: 20px;
            padding: 24px;
            cursor: pointer;
            transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
            display: flex;
            flex-direction: column;
            gap: 12px;
            position: relative;
            overflow: hidden;
            box-sizing: border-box;
            max-width: 100%;
            min-width: 0;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
        }

        /* Progress bar on top (same as exam-group-card) */
        .marketplace-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: var(--primary-gradient);
            opacity: 0;
            transition: opacity 0.3s;
        }

        .marketplace-card:hover {
            border-color: var(--primary);
            transform: translateY(-4px);
            box-shadow: 0 10px 25px rgba(14, 165, 233, 0.1);
        }

        .marketplace-card:hover::before {
            opacity: 0.5;
        }

        .marketplace-card.selected {
            border-color: var(--primary);
            background: linear-gradient(to bottom, rgba(14, 165, 233, 0.03), white);
            box-shadow: 0 0 0 1px var(--primary), 0 8px 32px rgba(14, 165, 233, 0.15);
        }

        .marketplace-card.selected::before {
            opacity: 1;
        }

        /* Header with icon, title and toggle */
        .marketplace-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
        }

        .marketplace-card-title-section {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
        }

        .marketplace-card .icon {
            font-size: 24px;
            line-height: 1;
            flex-shrink: 0;
        }

        .marketplace-card .title {
            font-size: 18px;
            font-weight: 700;
            color: var(--text-main);
            line-height: 1.3;
            text-align: left;
            letter-spacing: -0.3px;
        }

        /* Remove old checkmark, use toggle instead */
        .marketplace-card .checkmark {
            display: none;
        }


        /* Selected Exams Pills */
        .selected-pills-container {
            margin-top: 24px;
            padding-top: 24px;
            border-top: 2px solid #f1f5f9;
        }

        .selected-pills-title {
            font-size: 15px;
            font-weight: 600;
            color: var(--text-muted);
            margin-bottom: 12px;
        }

        .selected-pills-list {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .exam-pill {
            background: var(--primary);
            color: white;
            padding: 8px 16px;
            border-radius: 24px;
            font-size: 15px;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s;
        }

        .exam-pill .remove {
            cursor: pointer;
            font-size: 18px;
            font-weight: 700;
            line-height: 1;
            opacity: 0.8;
            transition: opacity 0.2s;
        }

        .exam-pill .remove:hover {
            opacity: 1;
        }

        /* Floating Actions Container */
        .floating-actions-container {
            position: fixed;
            bottom: 32px;
            right: 32px;
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 1000;
            pointer-events: none;
            /* Container is transparent to clicks */
        }

        .floating-actions-container.visible {
            pointer-events: auto;
        }

        /* Floating Price Button */
        .floating-cart-btn {
            background: var(--primary-gradient);
            color: white;
            padding: 0 28px;
            height: 48px;
            border-radius: 24px;
            box-shadow: 0 10px 25px rgba(14, 165, 233, 0.4);
            display: flex;
            align-items: center;
            gap: 12px;
            border: none;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            opacity: 0;
            transform: translateY(20px);
            pointer-events: none;
            /* Initially disabled */
        }

        /* Floating Clear Button */
        .floating-clear-btn {
            background: #ef4444;
            color: white;
            width: 48px;
            height: 48px;
            border-radius: 50%;
            box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4);
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            opacity: 0;
            transform: translateY(20px);
            pointer-events: none;
            /* Initially disabled */
        }

        /* Visibility States controlled by container or individual keys if needed, 
           but here we sync them mostly. Ideally applied to buttons. */
        .floating-cart-btn.visible,
        .floating-clear-btn.visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .floating-cart-btn:hover,
        .floating-clear-btn:hover {
            transform: scale(1.05) translateY(-2px);
        }

        .floating-cart-btn:hover {
            box-shadow: 0 15px 30px rgba(14, 165, 233, 0.5);
        }

        .floating-clear-btn:hover {
            box-shadow: 0 15px 30px rgba(239, 68, 68, 0.5);
        }

        .floating-cart-btn .cart-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.2);
            width: 28px;
            height: 28px;
            border-radius: 50%;
        }

        .floating-cart-btn .price-text {
            font-size: 18px;
            font-weight: 700;
            letter-spacing: -0.5px;
        }

        @media (max-width: 768px) {

            /* Container Optimization */
            .portal-container {
                width: 100%;
                max-width: 100vw;
                padding: 16px;
                overflow-x: hidden;
            }

            /* Stepper Optimization */
            .step-label {
                display: none;
                /* Hide labels on mobile */
            }

            .step-number {
                width: 28px;
                height: 28px;
                font-size: 12px;
            }

            .step-indicator {
                margin-bottom: 24px;
            }

            /* Category Chips Wrapping */
            .category-chips {
                flex-wrap: wrap;
                overflow-x: visible;
                height: auto;
                justify-content: flex-start;
                /* Align left */
            }

            .category-chip {
                font-size: 16px;
                padding: 10px 16px;
                flex-grow: 1;
                /* Make chips fill available space */
                text-align: center;
            }

            /* Grid Single Column */
            .portal-grid,
            .exam-groups-grid {
                grid-template-columns: 1fr;
                /* Full width cards */
            }

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

            /* Card Adjustments */
            .exam-group-card,
            .marketplace-card {
                padding: 16px;
                /* Reduced padding */
                width: 100%;
                box-sizing: border-box;
                /* Ensure padding doesn't add to width */
            }

            /* Floating Actions */
            .floating-actions-container {
                bottom: 24px;
                right: 16px;
                /* Slightly closer to edge but safe */
                z-index: 9999;
                /* Ensure on top */
            }

            .floating-cart-btn {
                height: 48px;
                padding: 0 20px;
                font-size: 15px;
            }

            .floating-cart-btn .price-text {
                font-size: 16px;
            }

            .floating-clear-btn {
                width: 48px;
                height: 48px;
            }

            .floating-cart-btn .cart-icon {
                width: 32px;
                height: 32px;
                padding: 6px;
            }

            .exam-badge {
                white-space: normal;
                text-align: center;
                max-width: 100%;
            }

            /* Fix Action Buttons on Mobile */
            .portal-actions {
                flex-direction: column;
                gap: 12px;
            }

            .portal-actions.dual {
                display: flex;
                /* Ensure flex is active */
                flex-direction: column-reverse;
                /* Primary button usually on top or bottom depending on preference, but visually stacking them is key. Often Next on top is better, or side-by-side if they fit. User asked for 'like step 1'. */
                gap: 12px;
            }

            .portal-actions.dual button {
                width: 100%;
                margin: 0;
            }

            /* Enforce Container Padding */
            .portal-container {
                padding: 16px !important;
                width: 100%;
                max-width: 100vw;
                overflow-x: hidden;
            }
        }

        /* Success Step Animations */
        @keyframes successPop {
            0% {
                transform: scale(0.5);
                opacity: 0;
            }

            50% {
                transform: scale(1.1);
            }

            100% {
                transform: scale(1);
                opacity: 1;
            }
        }

        .success-checkmark-animated {
            width: 80px;
            height: 80px;
            background: #10b981;
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 40px;
            margin: 0 auto 24px;
            box-shadow: 0 10px 20px rgba(16, 185, 129, 0.2);
            animation: successPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
        }

        .confirmation-card {
            background: white;
            padding: 32px;
            border-radius: 24px;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
            max-width: 500px;
            margin: 0 auto 32px;
            border: 1px solid #eef2f6;
            text-align: left;
        }

        .conf-row {
            display: flex;
            justify-content: space-between;
            padding: 12px 0;
            border-bottom: 1px solid #f1f5f9;
        }

        .conf-row:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }

        .conf-label {
            color: #64748b;
            font-weight: 500;
        }

        .conf-value {
            color: #1e293b;
            font-weight: 600;
            text-align: right;
        }

        .conf-value.folio {
            color: var(--primary);
            font-family: monospace;
            font-size: 18px;
            letter-spacing: 1px;
        }

        /* Legacy compatibility - hide old collapsible */
        .collapsible-header {
            display: none;
        }

        .collapsible-content {
            max-height: none !important;
            overflow: visible !important;
            padding: 0 !important;
        }

        .collapsible-section {
            margin-bottom: 0 !important;
        }

        .exams-search-wrapper {
            position: relative;
            margin-bottom: 20px;
        }

        .exams-search-results {
            max-height: 200px;
            overflow-y: auto;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            z-index: 10;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            display: none;
        }

        .exam-search-item {
            padding: 12px 16px;
            cursor: pointer;
            border-bottom: 1px solid #f1f5f9;
        }

        .exam-search-item:hover {
            background: #f8fafc;
            color: var(--primary);
        }

        .selected-exams-list {
            display: flex;
            flex-wrap: wrap;
            gap: 16px;
            margin-top: 24px;
        }

        .exam-tag {
            background: var(--bg);
            border: 1px solid #e2e8f0;
            border-radius: 30px;
            padding: 6px 14px;
            font-size: 13px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .exam-tag .remove {
            cursor: pointer;
            color: var(--danger);
            font-weight: 700;
        }

        .summary-row {
            display: flex;
            justify-content: space-between;
            padding: 12px 0;
            border-bottom: 1px solid #f1f5f9;
        }

        .summary-row.total {
            border-bottom: none;
            margin-top: 20px;
            font-size: 20px;
            font-weight: 700;
            color: var(--primary);
        }

        .portal-actions {
            display: grid;
            gap: 16px;
            margin-top: 6px;
            padding-top: 24px;
            border-top: 2px solid #f1f5f9;
        }

        .portal-actions.dual {
            grid-template-columns: 1fr 1fr;
        }

        .btn-portal {
            height: 54px;
            padding: 0 32px;
            border-radius: var(--radius-btn);
            font-weight: 800;
            font-size: 18px;
            cursor: pointer;
            transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            border: none;
            letter-spacing: -0.3px;
            line-height: 1;
            width: 100%;
            position: relative;
            overflow: hidden;
        }

        .btn-portal i,
        .btn-portal svg,
        .btn-portal span.icon {
            font-size: 20px;
            width: 20px;
            height: 20px;
        }

        .btn-primary {
            background: var(--primary-gradient) !important;
            color: white !important;
            box-shadow: 0 10px 20px rgba(14, 165, 233, 0.2);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            filter: brightness(1.1);
            box-shadow: 0 15px 30px rgba(14, 165, 233, 0.3);
        }

        .btn-secondary {
            background-color: #f1f5f9 !important;
            color: #475569 !important;
            border: 1px solid #e2e8f0 !important;
        }

        .btn-success {
            background: var(--primary-gradient) !important;
            color: white !important;
            box-shadow: 0 10px 20px rgba(13, 148, 136, 0.2);
        }

        .success-checkmark-animated {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #10b981;
            color: white;
            font-size: 40px;
            margin: 0 auto 24px;
            animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        /* Autocomplete signal */
        #p-rut-loading {
            position: absolute;
            right: 10px;
            top: 35px;
            font-size: 12px;
            color: var(--primary);
            display: none;
        }

        /* Mobile Logic Overrides */
        @media (max-width: 768px) {
            .portal-container {
                width: 100%;
                max-width: 100vw;
                padding: calc(env(safe-area-inset-top, 0px) + 16px) 20px 24px 20px !important;
                overflow-x: hidden;
                box-sizing: border-box;
                position: relative;
            }

            .portal-header {
                display: flex;
                flex-direction: row;
                justify-content: space-between;
                align-items: center;
                gap: 16px;
                margin-bottom: 32px;
                text-align: center;
                width: 100%;
            }

            .header-back-btn {
                width: 48px;
                height: 48px;
                flex-shrink: 0;
                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
            }

            .portal-header-info {
                flex: 1;
                text-align: center;
            }

            .portal-header h1 {
                font-size: 26px;
                letter-spacing: -0.5px;
                margin: 0;
            }

            .portal-header p {
                font-size: 17px;
                margin: 0;
                opacity: 0.8;
            }

            .header-logo {
                display: none;
            }

            .portal-card {
                padding: 24px 20px;
                border-radius: 28px;
                width: 100% !important;
            }

            .portal-grid {
                display: block;
                /* Fallback to block */
                width: 100%;
            }

            .portal-grid>* {
                width: 100%;
                margin-bottom: 16px;
            }

            .btn-portal {
                width: 100%;
                height: 52px !important;
                font-size: 17px !important;
                border-radius: 14px;
                box-shadow: 0 8px 20px rgba(14, 165, 233, 0.15);
            }

            /* Prevent vertical alignment issues on mobile inputs/selects */
            .portal-input,
            .portal-select {
                font-size: 16px !important;
                padding-top: 15px !important;
                padding-bottom: 15px !important;
                height: 52px !important;
                line-height: normal !important;
            }

            .portal-actions.dual {
                display: flex;
                flex-direction: column-reverse;
                gap: 16px;
                padding-top: 32px;
            }

            .marketplace-title {
                font-size: 24px !important;
                margin-bottom: 8px !important;
            }

            .marketplace-subtitle {
                font-size: 17px !important;
                opacity: 0.8;
            }

            .exam-groups-grid {
                grid-template-columns: 1fr !important;
                gap: 16px;
                width: 100% !important;
                max-width: 100% !important;
                box-sizing: border-box;
                overflow: visible;
            }

            .marketplace-grid {
                grid-template-columns: 1fr !important;
                gap: 16px;
                width: 100% !important;
                max-width: 100% !important;
                box-sizing: border-box;
                overflow: visible;
            }

            .portal-content-wrapper {
                display: block;
                width: 100%;
                box-sizing: border-box;
                overflow: visible;
            }

            .step-indicator {
                margin-bottom: 24px;
                padding: 0 5px;
                width: 100%;
                justify-content: space-around;
            }

            .step {
                padding: 0;
                min-width: 0;
            }

            .step-indicator::before {
                left: 10%;
                right: 10%;
                top: 15px;
            }

            .step-label {
                display: none;
            }

            .step-number {
                width: 28px;
                height: 28px;
                font-size: 12px;
            }

            /* Hide desktop summary sidebar on mobile */
            .summary-sidebar {
                display: none;
            }


            /* Ensure 16px font to prevent zoom on iOS and perfect vertical centering */
            .portal-input,
            .portal-select,
            .phone-prefix-box,
            .phone-input-container input,
            .marketplace-search input {
                font-size: 16px !important;
                padding-top: 15px !important;
                padding-bottom: 15px !important;
                height: 52px !important;
                line-height: normal !important;
            }

            /* Adjust category chips for mobile */
            .category-chips {
                -webkit-overflow-scrolling: touch;
            }

            /* Compact exam cards on mobile */


            .exam-group-card,
            .marketplace-card {
                padding: 16px;
                width: 100% !important;
                box-sizing: border-box;
                max-width: 100% !important;
                min-width: 0;
            }

            .exam-group-title {
                font-size: 15px;
                word-break: break-word;
                min-width: 0;
            }

            .exam-card-title-section,
            .marketplace-card-title-section {
                min-width: 0;
            }

            .marketplace-card .icon {
                font-size: 28px;
            }

            .marketplace-card .title {
                font-size: 12px;
            }

        }


        .floating-total {
            position: fixed;
            bottom: 25px;
            right: 25px;
            background: var(--primary-gradient);
            color: white;
            padding: 12px 20px;
            border-radius: 50px;
            box-shadow: var(--shadow-lg);
            display: none;
            align-items: center;
            gap: 10px;
            font-weight: 800;
            font-size: 16px;
            z-index: 1000;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
            border: 2px solid rgba(255, 255, 255, 0.2);
            user-select: none;
        }

        .floating-total:hover {
            transform: scale(1.05);
            filter: brightness(1.1);
            box-shadow: var(--shadow-xl);
        }

        .floating-total.active {
            display: flex;
            animation: slideInUp 0.5s ease-out;
        }

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

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

        .portal-input.error {
            border-color: var(--danger) !important;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1) !important;
        }

        .portal-input.error:focus {
            border-color: var(--danger) !important;
            box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2) !important;
        }

        .btn-tiny {
            background: #f1f5f9;
            color: var(--primary);
            border: 1px solid #e2e8f0;
            padding: 6px 12px;
            border-radius: 8px;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
        }

        .btn-tiny:hover {
            background: var(--primary);
            color: white;
            border-color: var(--primary);
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 3px solid #f1f5f9;
            margin-bottom: 13px;
            padding-bottom: 10px;
        }

        .section-title {
            font-size: 22px;
            font-weight: 800;
            color: var(--secondary);
            margin-bottom: 0px !important;
            letter-spacing: -0.5px;
        }

        /* Modal Styles Redesign - Global Standardized */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(8px);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 9999;
        }

        .modal-content {
            background: white;
            padding: 32px;
            border-radius: 24px;
            max-width: 400px;
            width: 90%;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            text-align: center;
            display: flex;
            flex-direction: column;
            gap: 20px;
            /* Standard Gap */
            animation: modalScaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        @keyframes modalScaleIn {
            from {
                opacity: 0;
                transform: scale(0.95);
            }

            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        .modal-content h3 {
            margin: 0;
            color: var(--secondary);
            font-size: 20px;
            font-weight: 700;
        }

        .modal-content p {
            color: var(--text-muted);
            margin: 0;
            line-height: 1.5;
            font-size: 15px;
        }

        /* Phone Input Container - Symmetrical Standard */
        .phone-input-modal-container {
            display: flex;
            align-items: center;
            width: 100%;
            height: 52px;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            background-color: #fff !important;
            transition: all 0.2s;
            overflow: hidden;
            box-sizing: border-box;
        }

        .phone-input-modal-container:focus-within {
            border-color: var(--primary) !important;
            box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
        }

        .phone-input-modal-prefix {
            background: #f1f5f9;
            /* Standard soft background */
            border-right: 1px solid #e2e8f0;
            padding: 0 16px;
            color: var(--secondary);
            font-weight: 600;
            font-size: 16px;
            height: 100%;
            display: flex;
            align-items: center;
            width: 85px;
            justify-content: center;
            flex-shrink: 0;
        }

        .phone-input-modal-container input {
            border: none !important;
            outline: none !important;
            background: transparent !important;
            width: 100%;
            height: 100%;
            font-size: 18px;
            color: var(--secondary);
            padding: 0 16px !important;
            margin: 0 !important;
            font-family: 'Outfit', sans-serif;
            letter-spacing: 1px;
            box-shadow: none !important;
        }

        .phone-input-modal-container input::placeholder {
            letter-spacing: 2px;
            color: #cbd5e1;
            opacity: 0.8;
        }

        /* Modal Actions Hierarchy */
        .modal-actions {
            display: flex;
            gap: 12px;
            margin-top: 8px;
            /* Extra separation from body */
        }

        .modal-btn {
            height: 48px;
            flex: 1;
            font-weight: 600;
            border-radius: 12px;
            transition: all 0.2s;
            border: none;
            cursor: pointer;
            font-family: 'Outfit', sans-serif;
            font-size: 15px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

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

        .modal-btn-primary:hover {
            filter: brightness(1.1);
            transform: translateY(-1px);
        }

        .modal-btn-secondary {
            background: #f1f5f9;
            color: #64748b;
        }

        .modal-btn-secondary:hover {
            background: #e2e8f0;
        }

        .portal-content-wrapper {
            display: grid;
            grid-template-columns: 1fr;
            gap: 24px;
        }
