#manage-timetable {
    max-width: 1400px;
    margin: 1rem auto;
    color: #e2e8f0;
    padding: 0.5rem;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.85rem;
    /* Drastically reduced base font size */
}

.dashboard-title {
    color: #00e5ff;
    margin-bottom: 10px;
    font-size: 1.3rem;
    text-align: center;
}

/* Section Switcher */
.section-selector-container {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.section-selector-container label {
    font-weight: 600;
    color: #00e5ff;
    margin-bottom: 0;
    font-size: 0.85rem;
}

.main-dropdown {
    max-width: 300px;
    font-size: 0.85rem;
    padding: 0.3rem 0.5rem;
    border-color: #00e5ff;
    text-align: center;
    border-radius: 4px;
    background: #0b1120;
    color: #fff;
}

/* Visibility Toggle */
.hidden {
    display: none !important;
}

/* Cards */
.manage-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.centered-card {
    max-width: 550px;
    margin: 0 auto;
}

.full-width {
    width: 100%;
}

.manage-card h3 {
    color: #00e5ff;
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
}

/* Forms */
input[type="text"],
input[type="number"],
input[type="time"],
select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.6rem;
    background: #0b1120;
    color: #fff;
    border: 1px solid #334155;
    border-radius: 4px;
    outline: none;
    font-size: 0.85rem;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
select:focus {
    border-color: #00e5ff;
}

.multi-select {
    height: 75px;
    /* Much shorter */
}

.time-inputs {
    display: flex;
    align-items: center;
    margin-bottom: 0.6rem;
}

.time-inputs input {
    margin-bottom: 0;
}

.time-separator {
    padding: 0 8px;
    font-weight: bold;
    color: #94a3b8;
    font-size: 0.8rem;
}

/* The horizontal wrapper for the Days */
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 5px;
}

/* Aligns the text perfectly with the boxes inside the grid */
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Single checkbox label (e.g., "Is this a Lunch Break?") */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Removes the invisible browser margins that push the boxes up */
.checkbox-label input[type="checkbox"],
.checkbox-grid input[type="checkbox"] {
    margin: 0;
}

.form-grid label {
    display: block;
    margin-bottom: 5px;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.8rem;
}

.days-label {
    display: block;
    margin-bottom: 6px;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.8rem;
}

/* Buttons */
.btn-submit {
    width: 100%;
    background: #00e5ff;
    color: #000;
    padding: 0.4rem;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background: #00b4cc;
}

.btn-delete {
    background: #ef4444;
    color: #fff;
    padding: 0.2rem 0.4rem;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: 0.2s;
}

.btn-delete:hover {
    background: #dc2626;
}

.delete-form {
    margin: 0;
}

/* Lists & Tables */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem;
    border-bottom: 1px solid #1e293b;
    font-size: 0.85rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.8rem;
    font-size: 0.8rem;
}

.data-table th,
.data-table td {
    border: 1px solid #1e293b;
    padding: 0.4rem;
    text-align: left;
}

.data-table th {
    background: #162032;
    color: #00e5ff;
}

.lunch-row {
    background: rgba(0, 229, 255, 0.05);
}

/* Utilities */
.day-badge {
    display: inline-block;
    background: #1e293b;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.7rem;
    margin: 2px;
}

.text-cyan {
    color: #00e5ff;
}

.text-muted {
    color: #64748b;
}

.mt-1 {
    margin-top: 0.6rem;
}

.helper-text {
    display: block;
    margin-bottom: 8px;
    color: #94a3b8;
    font-size: 0.75rem;
}

.divider {
    border: 0;
    margin: 10px 0;
}

/* Messages */
.message-container {
    margin-bottom: 1rem;
}

.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.alert-success {
    background: rgba(0, 229, 255, 0.1);
    border-left: 3px solid #00e5ff;
    color: #00e5ff;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
    color: #ef4444;
}

/* ==========================================
   2D GRID TIMETABLE LOGIC
   ========================================== */
.entries-scroll-container {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.entries-scroll-container::-webkit-scrollbar {
    width: 6px;
}

.entries-scroll-container::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}

.class-group-header {
    background: #162032;
    color: #00e5ff;
    padding: 0.6rem 1rem;
    margin: 1.5rem 0 0 0;
    border-radius: 6px 6px 0 0;
    font-size: 1rem;
    border: 1px solid #1e293b;
    border-bottom: none;
}

.class-group-header:first-child {
    margin-top: 0;
}

.grid-table {
    margin-top: 0;
    margin-bottom: 1.5rem;
    table-layout: fixed;
    /* Forces columns to be equal width */
    text-align: center;
}

.grid-table th {
    background: rgba(30, 41, 59, 0.5);
    color: #00e5ff;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-align: center;
}

.grid-table td {
    text-align: center;
}

.period-col {
    background: rgba(30, 41, 59, 0.2);
    color: #94a3b8;
    white-space: nowrap;
}

.period-col strong {
    color: #fff;
    font-size: 0.9rem;
}

.lunch-cell {
    letter-spacing: 10px;
    font-weight: bold;
    color: #00e5ff;
    opacity: 0.7;
}

.grid-cell {
    position: relative;
    height: 65px;
    /* Keeps empty cells uniform */
    vertical-align: middle;
}

.cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cell-subject {
    font-weight: 700;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.cell-teacher {
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 2px;
}

/* Tiny Delete Button */
.inline-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    margin: 0;
}

.btn-micro-delete {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 3px;
    width: 18px;
    height: 18px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    /* Faded out so it isn't distracting */
    transition: opacity 0.2s, background-color 0.2s;
}

/* Lights up when hovering over the specific cell */
.grid-cell:hover .btn-micro-delete {
    opacity: 0.8;
}

.btn-micro-delete:hover {
    background: #dc2626;
    opacity: 1 !important;
}

.empty-state-alert {
    color: #94a3b8;
    background: transparent;
    border: 1px dashed #334155;
}

/* ==========================================
   MOBILE RESPONSIVENESS
   ========================================== */
@media screen and (max-width: 768px) {
    #manage-timetable {
        padding: 10px;
        margin: 0 auto;
    }

    /* Stack the section selector vertically */
    .section-selector-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }

    .dashboard-title {
        margin-bottom: 5px;
    }

    /* Make dropdown full width */
    .main-dropdown {
        max-width: 100%;
        width: 100%;
    }

    /* Stack form inputs vertically */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .checkbox-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 12px 8px;
    }

    /* 1. FIX THE HEADER: Make it a distinct rounded box */
    .class-group-header {
        border-bottom: 1px solid #1e293b;
        border-radius: 6px;
        margin-bottom: 10px;
    }

    /* 2. STOP CONTAINER SCROLL: Keep header pinned */
    .entries-scroll-container {
        overflow-x: hidden;
    }

    /* 3. MAKE ONLY THE TABLE SCROLLABLE */
    .grid-table {
        display: block !important;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth swiping on iOS */
        border-radius: 6px;
    }

    /* 4. PREVENT TEXT CRUSHING */
    .grid-table th,
    .grid-table td,
    .period-col {
        white-space: nowrap !important;
        padding: 12px 20px !important;
    }

    .grid-cell {
        height: auto;
    }
}