:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #f5f3ff;
    --secondary: #a855f7;
    --bg-main: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.8);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(99, 102, 241, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center {
    text-align: center;
}

.w-100 {
    width: 100% !important;
}

/* Navbar */
.navbar {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .logo-text {
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .logo-text {
        font-size: 0.8rem;
    }
}

@media (max-width: 428px) {
    .logo-text {
        display: none;
    }
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

@media (max-width: 576px) {
    .nav-links {
        gap: .8rem;
    }

    .nav-link {
        font-size: .8rem;
    }
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: color 0.3s;
}

.nav-link:hover {
    color: var(--primary);
}

.btn-login {
    text-decoration: none;
    background: var(--primary);
    color: white;
    padding: 10px 24px;
    border-radius: 99px;
    font-weight: 700;
    transition: transform 0.3s, background 0.3s;
}

.btn-login:hover {
    background: var(--primary-dark);
}

/* Hero Section */
.hero-section {
    padding: 60px 0 40px;
    text-align: center;
}

.badge {
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bg-primary {
    background-color: var(--primary-light) !important;
    color: var(--primary) !important;
}

.main-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 30px;
    line-height: 1.5;
}

/* Search Box */
.search-box-wrapper {
    max-width: 600px;
    margin: 20px auto 0;
    position: relative;
}

.search-box {
    background: white;
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.search-icon {
    font-size: 1.25rem;
    color: #94a3b8;
}

.search-clear {
    position: absolute;
    right: 20px;
    font-size: 1.25rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: color 0.2s;
}

.search-clear:hover {
    color: #64748b;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 1.1rem;
    font-weight: 500;
}

@media (max-width: 576px) {
    .search-box input {
        font-size: .8rem;
    }
}

.search-results-overlay {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    display: none;
}

.result-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.result-item:hover {
    background: #f8fafc;
}

/* Discovery Section */
.discovery-section {
    padding-top: 40px;
    padding-bottom: 80px;
}

.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.nav-header h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.btn-back {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #f8fafc;
    border-color: var(--primary);
    color: var(--primary);
}

/* Category Cards */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.category-card {
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 15px 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 15px;
}

.category-card:hover {
    border-color: #6366f1;
    box-shadow: none;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover::before {
    opacity: 1;
}

.card-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
    display: block;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.card-label {
    font-weight: 600;
    color: #334155;
    font-size: 1rem;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

/* Active State for Cards */
.category-card.active {
    border-color: #6366f1;
    background: #f5f3ff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.selection-indicator {
    margin-left: auto;
    color: #6366f1;
    font-size: 1.25rem;
    display: none;
    position: relative;
    z-index: 1;
}

.category-card.active .selection-indicator {
    display: block;
}

/* Grouped Layout Styles */
.grouped-item-list {
    width: 100%;
}

.category-group {
    margin-bottom: 30px;
}

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.05em;

    position: sticky;
    top: calc(72px + 87px);
    z-index: 99;
}

.group-header i {
    font-size: 1.25rem;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.group-header .active i,
.group-header .select-all-btn:hover i {
    background: #fff;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.category-bg {
    background: #f2f5f9;
    border-left: 4px solid #6366f1;
    margin-top: 20px;
    margin-bottom: 15px;
}

.select-all-btn {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 50px;
    border: 1px solid #6366f1;
    color: #6366f1;
    background: transparent;
    transition: all 0.2s;
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.select-all-btn:hover,
.select-all-btn.active {
    background: #6366f1;
    color: white;
}

.select-sub-all-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6366f1;
    padding: 0 5px;
    white-space: nowrap;
    background: none;
    border: none;
    cursor: pointer;
}

.select-sub-all-btn:hover {
    color: #4f46e5;
}

.subgroup-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 5px;
    margin-bottom: 15px;

    /* Sticky fixes - Keep background but restore margin */
    background: var(--bg-main);

    position: sticky;
    top: calc(72px + 60px + 85px);
    z-index: 98;
}

.subgroup-header span {
    font-weight: 600;
    color: #64748b;
    font-size: 0.95rem;
    white-space: nowrap;
}

.header-line {
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

/* Sub-category card adjustments */
.sub-cat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 15px 20px;
}

.sub-cat-card .selection-indicator {
    position: absolute;
    top: 10px;
    right: 15px;
}

/* Selection Item */
.selection-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.selection-item:hover {
    border-color: #6366f1;
    background: #f8fafc;
}

.selection-item.selected {
    border-color: #6366f1;
    background: #f5f3ff;
}

.item-info {
    flex: 1;
}

.item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 2px;
}

.item-desc {
    font-size: 0.8rem;
    color: #64748b;
    line-height: 1.3;
}

.selection-item i {
    font-size: 1.25rem;
    color: #cbd5e1;
}

.selection-item.selected i {
    color: #10b981;
}

/* Modal and Animations kept same as before but ensured they don't break */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 40px;
    width: 90%;
    max-width: 450px;
    border-radius: 24px;
    position: relative;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s ease-out;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.success-icon {
    font-size: 4rem;
    color: #10b981;
    margin-bottom: 24px;
}

.modal-actions {
    display: grid;
    gap: 12px;
    margin-top: 25px;
}

.btn-primary-large {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
}

.btn-secondary-large {
    background: #f1f5f9;
    color: var(--text-main);
    border: none;
    padding: 14px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
}

/* Main Footer */
.main-footer {
    padding: 60px 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 80px;
    text-align: center;
    color: var(--text-muted);
}

/* Wizard Header Refinement */
.wizard-header {
    text-align: center;
    margin-bottom: 40px;
    background: white;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);

    position: sticky;
    top: 72px;
    z-index: 100;
}

.top-nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-bottom: 20px; */
}

.header-titles h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 40px;
    text-align: center;
}

.header-titles p {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.step-progress {
    /* margin-bottom: 24px; */
    display: flex;
    justify-content: center;
}

/* Selected Items Bar in Header */
.selected-items-bar {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 12px;
    /* margin-bottom: 24px; */
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-sm {
    padding: 10px 18px !important;
    font-size: 0.85rem !important;
}

.btn-lg {
    padding: 16px 40px !important;
    font-size: 1.1rem !important;
}

/* Step Dots */
.step-dots {
    display: flex;
    gap: 10px;
}

.dot {
    width: 8px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 50%;
    transition: all 0.3s;
}

.dot.active {
    background: var(--primary);
    transform: scale(1.25);
}

/* Buttons */
.btn-primary-action,
.btn-success-sm {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-action:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-secondary-outline:hover:not(:disabled) {
    border-color: var(--text-main);
    color: var(--text-main);
}

.btn-secondary-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bottom-actions  {
    margin-top: 20px;
    position: fixed;
    z-index: 100;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: white;
    .btn-primary-action {
        width: 100%;
    }
}

/* --- Responsiveness & Mobile Optimizations --- */

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .main-title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .wizard-header {
        padding: 16px;
        top: 68px;
        /* Adjust sticky top if navbar height changes */
    }

    .header-titles h2 {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }

    .category-grid,
    .secondary-grid,
    .item-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 576px) {

    /* Global Font Reductions */
    body {
        font-size: 14px;
    }

    .navbar {
        padding: 0.75rem 0;
    }

    /* Hero Section */
    .hero-section {
        padding: 40px 0 20px;
    }

    .main-title {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }

    /* Headers */
    .nav-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 25px;
    }

    .nav-header h2 {
        font-size: 1.5rem;
    }

    .wizard-header {
        padding: 15px;
        top: 60px;
        /* Tighter sticky positioning */
    }

    .group-header {
        top: calc(60px + 69px);
        /* Recalculate sticky offsets */
        font-size: 1rem;
    }

    .subgroup-header {
        top: calc(60px + 60px + 66px);
    }

    .header-titles h2 {
        font-size: 1.35rem;
        margin-bottom: 20px;
    }

    /* Grids to Single Column */
    .category-grid,
    .secondary-grid,
    .item-grid {
        grid-template-columns: 1fr;
        /* Force single column */
    }

    /* Cards & Items */
    .category-card {
        padding: 12px 15px;
    }

    .card-icon {
        font-size: 1.25rem;
    }

    .card-label {
        font-size: 0.95rem;
    }

    .selection-item {
        padding: 10px 12px;
    }

    .item-title {
        font-size: 0.9rem;
    }

    .item-desc {
        font-size: 0.75rem;
    }

    /* Buttons */
    .btn-primary-action,
    .btn-secondary-outline {
        padding: 10px 16px;
        font-size: 0.9rem;
        /* width: 100%; */
        /* Full width buttons on mobile */
        justify-content: center;
    }

    .top-nav-controls {
        gap: 10px;
    }

    .top-nav-controls button span {
        display: none;
        /* Hide text "Cancel"/"Next" if space is tight? Maybe just generic "Back" */
    }
}

/* Sticky State Overrides */
.wizard-header.is-stuck,
.group-header.is-stuck,
.subgroup-header.is-stuck {
    border-radius: 0 !important;
    border-top: none;
    border-left: none;
    border-right: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    /* Subtle shadow when stuck */

    /* Full Bleed Logic */
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);

    /* Responsive Content Centering (Matches Container 1100px + 20px padding) */
    padding-left: max(20px, calc(50vw - 550px + 20px));
    padding-right: max(20px, calc(50vw - 550px + 20px));

    transition: all 0.2s ease;
}

.wizard-header.is-stuck {
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding-top: 15px;
    /* Reduce padding when stuck for slimmer look */
    padding-bottom: 15px;
}