@media (max-width: 768px) {
    /* --- Unify reservation and schedule block mobile layout --- */
    #reservations-container tbody tr,
    #schedule-container tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 0.5rem;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.65rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    #reservations-container td,
    #schedule-container td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.15rem 0;
        border-bottom: none;
        font-size: 0.88rem;
        line-height: 1.3;
    }
    /* Per-column order and spanning for both blocks */
    #reservations-container td:nth-child(1),
    #schedule-container td:nth-child(1) { order: 1; text-align: left; }
    #reservations-container td:nth-child(2),
    #schedule-container td:nth-child(2) { order: 2; }
    #reservations-container td:nth-child(3),
    #schedule-container td:nth-child(3) { order: 3; }
    #reservations-container td:nth-child(4),
    #schedule-container td:nth-child(4) { order: 4; }
    /* Activity row: always last, full width, left-aligned */
    #reservations-container td:nth-child(5),
    #schedule-container td:nth-child(7) {
        order: 5;
        grid-column: 1 / -1;
        justify-content: flex-start;
        text-align: left;
    }
    /* Label styling for both blocks */
    #reservations-container td::before,
    #schedule-container td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #004466;
        flex: 0 0 auto;
        margin-right: 0.75rem;
        font-size: 0.8rem;
        text-transform: uppercase;
        text-align: left;
        display: inline-block;
        min-width: 4.5em;
    }
    /* Keep time + calendar icon together and inset the time slightly */
    #reservations-container td:nth-child(2) {
        padding-right: 0.6rem;
    }
    #reservations-container td:nth-child(2) .value {
        white-space: nowrap;
    }
    /* Slight spacing for calendar link so it doesn't wrap */
    #reservations-container .calendar-link {
        margin-left: 0.35rem;
        display: inline-block;
        flex: 0 0 auto;
    }
}
/* Reserve (green) button */
.reserve-btn {
    background-color: #28a745 !important;
    color: #fff !important;
    border: none;
}
.reserve-btn:hover {
    background-color: #218838 !important;
}

/* Waitlist (blue) button */
.waitlist-btn {
    background-color: #007bff !important;
    color: #fff !important;
    border: none;
}
.waitlist-btn:hover {
    background-color: #0056b3 !important;
}
/* Ensure signup buttons share a consistent size */
.signup-btn {
    display: inline-block;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px !important;
    min-height: 1.7em !important;
    padding: 0.35rem 0.9rem !important;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 0.9rem;
}

/* Gray out the signup button when disabled */
.signup-btn.grayed-out-btn,
.signup-btn:disabled {
    background-color: #bbb !important;
    color: #888 !important;
    border: 1px solid #aaa !important;
    cursor: not-allowed !important;
    opacity: 0.7;
}
/* Collapsible section styles */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    outline: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
}
.collapse-toggle {
    font-size: 1em;
    transition: transform 0.2s;
}
.collapsible-content.collapsed {
    display: none;
}
/* General Body Styling */
html, body {
    height: 100%;
    width: 100%;
    color-scheme: light dark;
}

body {
    min-height: 100vh;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f7f6;
}

/* --- Unified Button Styles --- */
.button, button, .gxp-action-btn {
    display: inline-block;
    background-color: #007bff;
    color: #fff;
    padding: 0.35rem 0.9rem;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.82rem !important;
    cursor: pointer;
    transition: background-color 0.3s;
    min-width: 70px !important;
    min-height: 1.7em !important;
    box-sizing: border-box;
    margin: 0 0.15em;
}
.button:hover, button:hover, .gxp-action-btn:hover {
    background-color: #0056b3;
}

/* --- Compact Layout --- */
main {
    padding: 1rem 0.5rem;
    max-width: 900px;
    margin: 0 auto;
}
section {
    background-color: #fff;
    padding: 0.7rem 0.5rem;
    margin-bottom: 0.7rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.login-container {
    max-width: 420px;
    margin: 2.5rem auto;
    padding: 1.2rem 1rem 1.5rem 1rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    line-height: 1.45;
}
.form-group {
    margin-bottom: 0.9rem;
}

/* Login form controls: aligned, same size */
.login-container form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.login-container .form-group {
    width: 100%;
    max-width: 360px;
}
.login-container label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}
.login-container .form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.5rem;
    font-size: 0.95rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
}
.login-container .button {
    margin-top: 0.6rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

/* Slightly larger logo in the login header */
.login-container .header-icon {
    width: 28px !important;
    height: 28px !important;
    margin-right: 0.6rem;
    vertical-align: middle;
}
h2 {
    margin-top: 0;
    color: #004466;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.3rem;
    font-size: 1.05rem;
}
.schedule-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.schedule-controls label {
    font-size: 0.8rem;
    white-space: nowrap;
}
.schedule-controls select {
    width: auto;
    padding: 0.25rem 0.5rem;
    font-size: 0.87rem;
}
th, td {
    padding: 0.45rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

/* --- Responsive Tweaks for Mobile --- */
@media (max-width: 768px) {
    main {
        padding: 0.5rem 0.2rem;
    }
    section {
        padding: 0.5rem 0.2rem;
        margin-bottom: 0.5rem;
    }
    .login-container {
        margin: 1.2rem auto;
        padding: 0.7rem 0.5rem 1rem 0.5rem;
    }
    .header-buttons {
        gap: 0.4rem;
    }
    .button, button, .gxp-action-btn {
        font-size: 0.82rem !important;
        padding: 0.22rem 0.6rem !important;
        min-width: 70px !important;
        min-height: 1.7em !important;
    }
    th, td {
        padding: 0.28rem;
        font-size: 0.92rem;
    }
    #reservations-container tbody tr {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 0.5rem !important;
    }
    #reservations-container td {
        font-size: 0.92rem;
        padding: 0.28rem !important;
    }
    .reservation-mobile-layout {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 0.1rem 0.5rem !important;
        align-items: center !important;
        padding: 0.2rem 0.1rem !important;
    }
    .reservation-mobile-layout td {
        font-size: 0.92rem;
        padding: 0.18rem !important;
    }
    .reservation-mobile-layout td:nth-child(1) { grid-row: 1; grid-column: 1; text-align: left !important; }
    .reservation-mobile-layout td:nth-child(2) { grid-row: 1; grid-column: 2; }
    .reservation-mobile-layout td:nth-child(5) { grid-row: 2; grid-column: 1; text-align: left !important; }
    .reservation-mobile-layout td:nth-child(3) { grid-row: 2; grid-column: 2; }
    .reservation-mobile-layout td:nth-child(4) { display: none; }
    .reservation-mobile-layout td:nth-child(6) { display: none; }
    .reservation-mobile-layout td:nth-child(7) {
        grid-row: 3;
        grid-column: 1 / span 2;
        text-align: left !important;
        font-weight: 500;
        font-size: 0.98em;
        padding-top: 0.1em;
    }
}

/* --- End Compact/Unified Styles --- */

/* ===== Mobile Portrait Responsive ===== */
@media (max-width: 768px) {
    /* Header */
    header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    header h1 {
        font-size: 1.15rem;
        flex: 1 1 auto;
    }

    .header-icon {
        width: 22px !important;
        height: 22px !important;
        max-width: 22px !important;
        max-height: 22px !important;
        min-width: 22px !important;
        min-height: 22px !important;
        object-fit: contain;
        margin-right: 7px;
        vertical-align: middle;
        display: inline-block;
        font-size: initial !important;
    }

    .header-buttons {
        gap: 0.5rem;
    }

    .header-buttons .button,
    .header-buttons button {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    /* Main */
    main {
        padding: 0.75rem;
    }

    section {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    h2 {
        font-size: 1.15rem;
    }

    /* Schedule controls – keep Day & Time on one row */
    .schedule-controls {
        display: grid;
        grid-template-columns: auto 1fr auto 1fr;
        align-items: center;
        gap: 0.25rem 0.5rem;
    }

    .schedule-controls label {
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .schedule-controls select {
        width: auto;
        padding: 0.35rem;
        font-size: 0.9rem;
    }

    /* Tables → card layout */
    #reservations-container table,
    #schedule-container table {
        border: 0;
    }

    #reservations-container thead,
    #schedule-container thead {
        display: none;
    }

    #reservations-container tbody tr,
    #schedule-container tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 0.5rem;
        background: #fff;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.65rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    #reservations-container tbody tr:hover,
    #schedule-container tbody tr:hover {
        background: #f8f9fa;
    }

    #reservations-container td,
    #schedule-container td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.15rem 0;
        border-bottom: none;
        font-size: 0.88rem;
        line-height: 1.3;
    }

    /* Reservation cards: 2-column paired rows (no nested media overrides) */
    /* Mobile reservation layout handled by the unified rules above. */
    #reservations-container td::before,
    #schedule-container td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #004466;
        flex: 0 0 auto;
        margin-right: 0.75rem;
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    /* Schedule cards: 2-column paired rows */
    #schedule-container tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 0.5rem;
    }

    #schedule-container td:nth-child(1) { order: 1; } /* Date */
    #schedule-container td:nth-child(2) { order: 2; } /* Time */
    #schedule-container td:nth-child(5) { order: 3; } /* Openings */
    #schedule-container td:nth-child(6) { order: 4; } /* Note */
    #schedule-container td:nth-child(4) { order: 5; } /* Duration */
    #schedule-container td:nth-child(3) { order: 6; } /* Action */
    #schedule-container td:nth-child(7) { order: 7; grid-column: 1 / -1; justify-content: flex-start; } /* Activity — full width, left-aligned */

    /* Grayed-out styling for card layout */
    #schedule-container tbody tr.grayed-out {
        opacity: 0.5;
    }

    /* === Dark mode overrides for mobile cards === */
    html.dark #reservations-container tbody tr,
    html.dark #schedule-container tbody tr {
        background: #1e1e1e !important;
        border-color: #444 !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    }

    html.dark #reservations-container tbody tr:hover,
    html.dark #schedule-container tbody tr:hover {
        background: #252525 !important;
    }

    html.dark #reservations-container td,
    html.dark #schedule-container td {
        color: #ffffff !important;
    }

    html.dark #reservations-container td::before,
    html.dark #schedule-container td::before {
        color: #b8e8ff !important;
    }

    html.dark #schedule-container tbody tr.grayed-out td {
        color: #aaa !important;
    }

    html.dark #schedule-container tbody tr.grayed-out td::before {
        color: #7ab !important;
    }
}

/* ===== Dark Mode (class-based + media query fallback) ===== */

/* Media query fallback — for browsers where JS detection fails */
@media (prefers-color-scheme: dark) {
    body { background-color: #121212; color: #f5f5f5; }
    header { background-color: #0a2d40; }
    section { background-color: #1e1e1e; box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
    h2 { color: #8ad4f0; border-bottom-color: #333; }
    th { background-color: #2a2a2a; color: #f0f0f0; }
    td { border-bottom-color: #333; color: #ffffff !important; }
    tbody tr:hover { background-color: #2a2a2a; }
    td a { color: #8cc8ff !important; }
    .signup-link { background-color: #1a6fdb; color: #fff !important; }
    .signup-link:hover { background-color: #1558b0; }
    .grayed-out { opacity: 0.5; }
    .grayed-out td { color: #ccc !important; }
    .login-container { background-color: #1e1e1e; box-shadow: 0 4px 8px rgba(0,0,0,0.5); }
    .form-group input { background-color: #2a2a2a; color: #f5f5f5; border-color: #555; }
    .form-group label { color: #f0f0f0; }
    .schedule-controls select { background-color: #2a2a2a; color: #f5f5f5; border: 1px solid #555; }
    .schedule-controls label { color: #f0f0f0; }
    .flash.error { background-color: #3b1418; color: #f5a5ad; border-color: #5c2228; }
    .flash.info { background-color: #0f2d35; color: #7ed4e6; border-color: #1a4a56; }
    p.error { color: #f5a5ad; }
    .icon-wrapper::after { background-color: rgba(255,255,255,0.9); color: #111; }
}

html.dark body { background-color: #121212; color: #f5f5f5; }
html.dark header { background-color: #0a2d40; }
html.dark section { background-color: #1e1e1e; box-shadow: 0 2px 4px rgba(0,0,0,0.4); }
html.dark h2 { color: #8ad4f0; border-bottom-color: #333; }
html.dark th { background-color: #2a2a2a; color: #f0f0f0; }
html.dark td { border-bottom-color: #333; color: #ffffff !important; }
html.dark tbody tr:hover { background-color: #2a2a2a; }
html.dark td a { color: #8cc8ff !important; }
html.dark .signup-link { background-color: #1a6fdb; color: #fff !important; }
html.dark .signup-link:hover { background-color: #1558b0; }
html.dark .grayed-out { opacity: 0.5; }
html.dark .grayed-out td { color: #ccc !important; }
html.dark .login-container { background-color: #1e1e1e; box-shadow: 0 4px 8px rgba(0,0,0,0.5); }
html.dark .form-group input { background-color: #2a2a2a; color: #f5f5f5; border-color: #555; }
html.dark .form-group label { color: #f0f0f0; }
html.dark .schedule-controls select { background-color: #2a2a2a; color: #f5f5f5; border: 1px solid #555; }
html.dark .schedule-controls label { color: #f0f0f0; }
html.dark .flash.error { background-color: #3b1418; color: #f5a5ad; border-color: #5c2228; }
html.dark .flash.info { background-color: #0f2d35; color: #7ed4e6; border-color: #1a4a56; }
html.dark p.error { color: #f5a5ad; }
html.dark .icon-wrapper::after { background-color: rgba(255,255,255,0.9); color: #111; }

/* Dark mode + mobile cards (both selectors) */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    #reservations-container tbody tr,
    #schedule-container tbody tr {
        background: #1e1e1e;
        border-color: #333;
        box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    }
    #reservations-container tbody tr:hover,
    #schedule-container tbody tr:hover { background: #252525; }
    #reservations-container td::before,
    #schedule-container td::before { color: #b8e8ff !important; }
    #reservations-container td,
    #schedule-container td { color: #ffffff !important; }
    #schedule-container tbody tr.grayed-out td { color: #aaa !important; }
    #schedule-container tbody tr.grayed-out td::before { color: #7ab !important; }
}

@media (max-width: 768px) {
    html.dark #reservations-container tbody tr,
    html.dark #schedule-container tbody tr {
        background: #1e1e1e;
        border-color: #333;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    html.dark #reservations-container tbody tr:hover,
    html.dark #schedule-container tbody tr:hover {
        background: #252525;
    }

    html.dark #reservations-container td::before,
    html.dark #schedule-container td::before {
        color: #b8e8ff !important;
    }

    html.dark #reservations-container td,
    html.dark #schedule-container td {
        color: #ffffff !important;
    }

    html.dark #schedule-container tbody tr.grayed-out td {
        color: #aaa !important;
    }

    html.dark #schedule-container tbody tr.grayed-out td::before {
        color: #7ab !important;
    }
}

.icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
        text-align: right;
        font-size: 0.92rem;
        padding: 0.28rem !important;
    min-height: 24px;
    max-width: 24px;
    max-height: 24px;
    padding: 0;
    margin: 0;
}
.header-icon {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    object-fit: contain;
    margin-right: 7px;
    vertical-align: middle;
    display: inline-block;
    font-size: initial !important;
}
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.2rem;
}
header h1 {
    margin: 0;
    font-size: 1.15rem;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Cancel (red) button */
.cancel-btn {
    background-color: #dc3545 !important;
    color: #fff !important;
    border: none !important;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}
.cancel-btn:hover {
    background-color: #c82333 !important;
}
.cancel-btn:disabled {
    background-color: #999 !important;
    color: #fff !important;
    cursor: not-allowed !important;
}

#refresh-btn {
    background-color: #28a745 !important;
    color: #fff !important;
    border: none !important;
}
#refresh-btn:hover {
    background-color: #218838 !important;
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}
.header-buttons .button,
.header-buttons button {
    font-size: 0.82rem !important;
    padding: 0.22rem 0.6rem !important;
    min-width: 70px !important;
    min-height: 1.7em !important;
}


