* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    height: 100vh;
    height: -webkit-fill-available;
    padding: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
}

/* Container to fill the screen */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 6px 10px;
    box-sizing: border-box;
    background: white;
    gap: 5px;
    overflow: hidden;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
    font-size: 36px;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
}

/* Trolley selection */
.trolley-selection {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    justify-content: center;
}

.trolley-selection label {
    font-weight: 600;
    color: #555;
    font-size: 19px;
}

.trolley-selection select {
    padding: 8px 12px;
    font-size: 19px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.trolley-selection select:focus {
    outline: none;
    border-color: #667eea;
}

/* Group selection */
.group-selection {
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-selection label {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    font-size: 19px;
}

.group-selection select {
    padding: 8px 12px;
    font-size: 19px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.group-selection select:focus {
    outline: none;
    border-color: #667eea;
}

/* Room tallies */
.room-tally-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    flex-shrink: 0;
}

.room-tally {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    border: 1px solid #e5e7eb;
}

/* Room buttons */
.room-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
    flex-shrink: 0;
}

.room-button {
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 19px;
    font-weight: 600;
    color: black;
    transition: all 0.3s;
    min-width: 120px;
    background: white;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.room-button:focus {
    outline: none;
}

.room-button:active {
    opacity: 0.8;
}

.room-button.selected-room {
    border: 2px solid #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    background: #f0f4ff;
}

/* Laptop grid */
.laptop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(70px, 10vw, 110px), 1fr));
    gap: clamp(5px, 1vh, 10px);
    width: 100%;
    flex: 1;
    align-content: stretch;
    grid-auto-rows: 1fr;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px;
    min-height: 0; /* Important for flex child scrolling */
}

.laptop-button {
    padding: 12px 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s;
    color: black;
    background: white;
    min-height: 100px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.laptop-button:focus {
    outline: none;
}

.laptop-button:active {
    opacity: 0.8;
}

/* Only apply hover effects on devices that support hover (not touch) */
@media (hover: hover) and (pointer: fine) {
    .laptop-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border-color: #667eea;
    }
    
    .room-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

.laptop-button.borrowed {
    border: 2px solid #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.room-label {
    font-size: 17px;
    color: white;
    font-weight: bold;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    min-width: 70px;
    text-align: center;
}

/* Buttons */
button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 19px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

button:focus {
    outline: none;
}

@media (hover: hover) and (pointer: fine) {
    button:hover {
        background: #5568d3;
        transform: translateY(-1px);
    }
}

button:active {
    transform: translateY(0);
    opacity: 0.9;
}

button.secondary {
    background: #999;
}

@media (hover: hover) and (pointer: fine) {
    button.secondary:hover {
        background: #777;
    }
}
/* Responsive Design for Tablets and iPads */
@media (max-width: 1024px) {
    body {
        padding: 0;
    }

    .container {
        padding: 8px 12px;
        gap: 8px;
    }

    .laptop-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .laptop-button {
        min-height: 110px;
        padding: 12px 8px;
    }

    .room-button {
        padding: 12px 16px;
        min-width: 110px;
    }

    .controls {
        gap: 10px;
    }

    button {
        padding: 11px 18px;
    }

    .trolley-selection,
    .group-selection {
        gap: 10px;
    }

    .trolley-selection label,
    .group-selection label {
    }

    .trolley-selection select,
    .group-selection select {
        padding: 9px 12px;
    }

    input[type="text"],
    input[type="date"],
    select {
        padding: 9px 12px;
        font-size: 14px;
    }

    table {
        font-size: 13px;
    }

    th, td {
        padding: 11px 13px;
        font-size: 13px;
    }

    .stat-value {
        font-size: 26px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        padding: 8px 10px;
        gap: 6px;
        max-width: 100%;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }

    .subtitle {
        font-size: 13px;
        margin-bottom: 15px;
    }

    .laptop-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 6px;
    }

    .laptop-button {
        min-height: 85px;
        padding: 8px 4px;
        font-size: 12px;
        border-radius: 6px;
    }

    .room-label {
        font-size: 11px;
        padding: 4px 6px;
        margin-top: 5px;
    }

    .room-buttons {
        gap: 10px;
        margin-bottom: 15px;
    }

    .room-button {
        padding: 10px 14px;
        font-size: 13px;
        min-width: 100px;
    }

    .controls {
        gap: 10px;
        margin-bottom: 15px;
    }

    button {
        padding: 10px 16px;
        font-size: 13px;
    }

    .trolley-selection,
    .group-selection {
        gap: 8px;
    }

    .trolley-selection label,
    .group-selection label {
        font-size: 13px;
    }

    .trolley-selection select,
    .group-selection select {
        padding: 8px 10px;
        font-size: 13px;
    }

    input[type="text"],
    input[type="date"],
    select {
        padding: 8px 10px;
        font-size: 13px;
    }

    .filter-group {
        gap: 4px;
    }

    .filter-group label {
        font-size: 13px;
    }

    .filter-group input,
    .filter-group select {
        padding: 7px 9px;
        font-size: 13px;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 9px 11px;
        font-size: 12px;
    }

    .action-badge,
    .room-badge,
    .device-badge {
        font-size: 12px;
        padding: 4px 8px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-label {
        font-size: 12px;
    }

    .stat-value {
        font-size: 22px;
        margin-top: 8px;
    }

    .refresh-info {
        font-size: 12px;
    }

    .pagination-info {
        font-size: 13px;
        margin: 0 12px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 6px 8px;
        gap: 5px;
    }

    .laptop-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 5px;
    }

    .laptop-button {
        min-height: 70px;
        padding: 6px 3px;
        font-size: 10px;
    }

    .room-button {
        padding: 6px 10px;
        font-size: 11px;
        min-width: 75px;
    }

    button {
        padding: 7px 12px;
        font-size: 11px;
    }

    .controls {
        gap: 6px;
    }

    .trolley-selection,
    .group-selection {
        flex-direction: row;
        gap: 5px;
        align-items: center;
    }

    .trolley-selection label,
    .group-selection label {
        font-size: 11px;
    }

    .trolley-selection select,
    .group-selection select {
        padding: 6px 8px;
        font-size: 12px;
    }

    .room-buttons {
        gap: 5px;
    }

    .room-tally {
        padding: 6px 10px;
        font-size: 11px;
    }
}