        /* Scrollbar styling for better visibility */
        ::-webkit-scrollbar {
            width: 12px;
            height: 12px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f5f7;
        }
        
        ::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 6px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

        /* Grid Layout - Viewport sizing */
        html {
            height: 100%;
            overflow: hidden;
        }

        body {
            height: 100%;
            margin: 0;
            padding: 0;
            background-color: #f5f7fa;
            overflow: hidden;
        }

        .app-container {
            height: 100%;
            display: flex;
            flex-direction: column;
        }

        .app-header {
            background: linear-gradient(135deg, #0d6efd 0%, #0dcaf0 100%);
            color: white;
            padding: 1rem 1.5rem;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .app-header h1 {
            font-size: 1.5rem;
            font-weight: 700;
            margin: 0;
        }

        .app-header p {
            margin: 0.25rem 0 0 0;
            font-size: 0.85rem;
            opacity: 0.95;
        }

        /* Main Board Layout */
        .board-wrapper {
            display: flex;
            flex: 1;
            min-height: 0;
            overflow: hidden;
        }

        /* Canvas Area with Grid */
        .canvas-area {
            flex: 1;
            background: #f8f9fa;
            overflow: hidden;
            position: relative;
            padding: 1rem;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            min-height: 0;  /* Important for flex children */
        }

        /* Grid Container */
        .grid-wrapper {
            flex: 1;
            overflow: hidden;
            border: 2px solid #dee2e6;
            border-radius: 8px;
            background: white;
            display: flex;
            flex-direction: column;
            min-height: 0;  /* Important for flex children */
        }

        /* Grid Header with Module Names */
        .grid-header {
            display: flex;
            flex-direction: row;
            overflow: hidden;
            border-bottom: 2px solid #dee2e6;
            background: #f8f9fa;
            flex-shrink: 0;
            min-height: 80px;
        }

        .grid-corner {
            flex-shrink: 0;
            width: 200px;
            padding: 0.75rem;
            background: #e9ecef;
            border-right: 2px solid #dee2e6;
            font-weight: 600;
            color: #495057;
            font-size: 0.8rem;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        /* Module Headers Container */
        #moduleHeaders {
            display: flex;
            flex-direction: row;
            flex: 1;
            overflow-x: auto;
            overflow-y: hidden;
        }

        .module-header {
            flex-shrink: 0;
            width: 200px;
            padding: 0.75rem;
            background: #f8f9fa;
            border-right: 1px solid #dee2e6;
            font-weight: 600;
            color: #0d6efd;
            font-size: 0.75rem;
            text-align: center;
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 70px;
            overflow-wrap: break-word;
            word-break: break-word;
        }

        /* Grid Body */
        .grid-body {
            display: flex;
            flex: 1;
            overflow: hidden;
            min-height: 0;  /* Important for flex children */
            gap: 0;
        }

        /* Degree Row Headers */
        .degree-headers {
            flex-shrink: 0;
            width: 200px;
            border-right: 2px solid #dee2e6;
            background: #f8f9fa;
            overflow-y: auto;
            overflow-x: hidden;
            min-height: 0;  /* Critical: allows scrolling within flex container */
        }

        .degree-header {
            padding: 0.75rem;
            border-bottom: 1px solid #dee2e6;
            font-weight: 500;
            color: #495057;
            font-size: 0.75rem;
            height: 100px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            text-align: center;
            overflow-wrap: break-word;
            word-break: break-word;
            background: #fafbfc;
            gap: 0.5rem;
        }

        .degree-header-name {
            font-weight: 600;
        }

        .degree-progress-bar {
            width: 90%;
            height: 18px;
            background: #e9ecef;
            border-radius: 4px;
            overflow: hidden;
            margin-top: 0.25rem;
        }

        .degree-progress-fill {
            height: 100%;
            background: #ffc107;
            transition: width 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.65rem;
            font-weight: 600;
            color: #333;
        }

        .degree-progress-fill.complete {
            background: #198754;
            color: white;
        }

        .degree-header.is-master {
            background: #fff8e1;
            border-left: 3px solid #ffc107;
        }

        .degree-header.is-certificate {
            background: #e8f4f8;
            border-left: 3px solid #0dcaf0;
        }

        /* Grid Cells Container */
        #gridCells {
            flex: 1;
            min-height: 0;  /* Critical: allows scrolling within flex container */
            overflow-x: auto;
            overflow-y: auto;
            display: block;  /* Use block layout instead of flex */
        }

        .grid-row {
            display: flex;
            flex-shrink: 0;
            min-height: 100px;
            height: 100px;
            border-bottom: 1px solid #dee2e6;
        }

        .grid-cell {
            flex-shrink: 0;
            width: 200px;
            border-right: 1px solid #dee2e6;
            padding: 0.5rem;
            background: white;
            position: relative;
            overflow: auto;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            align-content: flex-start;
        }

        .grid-cell.has-module {
            background: #f0f7ff;
            opacity: 0.7;
        }

        .grid-cell.no-module {
            background: #f8f9fa;
        }

        /* Course Card in Grid */
        .grid-course-card {
            background: white;
            border: 2px solid #0d6efd;
            border-radius: 6px;
            padding: 0.5rem;
            font-size: 0.7rem;
            cursor: grab;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            flex-shrink: 0;
            transition: all 0.2s ease;
            user-select: none;
            min-width: 180px;
        }

        .grid-course-card:hover {
            box-shadow: 0 3px 8px rgba(13, 110, 253, 0.3);
            transform: translateY(-2px);
        }

        .grid-course-card.dragging {
            opacity: 0.5;
            cursor: grabbing;
        }

        .grid-course-name {
            font-weight: 600;
            color: #333;
        }

        .grid-course-credits {
            font-size: 0.65rem;
            color: #666;
        }

        /* Legend */
        .grid-legend {
            display: flex;
            gap: 2rem;
            padding: 0.75rem;
            background: white;
            border-radius: 6px;
            border: 1px solid #dee2e6;
            font-size: 0.85rem;
            flex-shrink: 0;
            flex-wrap: wrap;
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .legend-color {
            width: 30px;
            height: 30px;
            border-radius: 4px;
            border: 2px solid #dee2e6;
        }

        /* Modules Panel */
        .modules-panel {
            height: 220px;
            background: white;
            border-top: 2px solid #dee2e6;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border-radius: 6px;
            flex-shrink: 0;
        }

        .modules-panel-header {
            padding: 1rem 1.5rem;
            background: var(--light-color);
            border-bottom: 1px solid #dee2e6;
            font-weight: 600;
            font-size: 0.9rem;
            color: #495057;
        }

        .modules-search {
            padding: 0.75rem 1.5rem;
            border-bottom: 1px solid #dee2e6;
        }

        .modules-search input {
            width: 100%;
            padding: 0.5rem;
            font-size: 0.85rem;
            border: 1px solid #dee2e6;
            border-radius: 4px;
        }

        .modules-list-container {
            flex: 1;
            overflow-x: auto;
            padding: 1rem 1.5rem;
            display: flex;
            gap: 1rem;
        }

        .module-section {
            flex-shrink: 0;
        }

        .module-section-title {
            font-size: 0.75rem;
            font-weight: 700;
            color: #666;
            margin-bottom: 0.5rem;
            text-transform: uppercase;
        }

        .courses-list {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .draggable-course {
            background: white;
            border: 2px solid #0d6efd;
            border-radius: 6px;
            padding: 0.5rem 0.75rem;
            cursor: grab;
            font-size: 0.8rem;
            white-space: nowrap;
            transition: all 0.2s ease;
            user-select: none;
        }

        .draggable-course:hover {
            background: #f0f7ff;
            transform: translateY(-2px);
            box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
        }

        .draggable-course.dragging {
            opacity: 0.5;
            cursor: grabbing;
        }

        .draggable-course-name {
            font-weight: 600;
            color: #333;
        }

        .draggable-course-credits {
            font-size: 0.7rem;
            color: #666;
        }

        /* Empty state for modules */
        .modules-empty-state {
            padding: 1.5rem;
            text-align: center;
            color: #999;
        }