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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
    position: fixed;
    width: 100%;
}

/* Password Screen */
.password-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.password-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.logo {
    width: 200px;
    height: auto;
    margin-bottom: 30px;
}

.password-container h2 {
    color: #D32F2F;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

#passwordInput {
    width: 100%;
    padding: 15px;
    font-size: 1.8rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
    letter-spacing: 8px;
    font-weight: 600;
    background: #fafafa;
}

#passwordInput:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.password-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.password-num-btn {
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: #D32F2F;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.password-num-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    background: #C62828;
}

.password-num-btn.zero {
    grid-column: 1 / 3;
}

.password-backspace-btn {
    background: #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.login-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: #D32F2F;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: none;
}

.login-btn:active {
    transform: scale(0.98);
}

.error-msg {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 0.9rem;
    min-height: 20px;
}

/* Main App */
.app-container {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    display: flex;
    padding: 12px;
    box-sizing: border-box;
}

.app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: white;
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding-bottom: 6px;
    border-bottom: 2px solid #f0f0f0;
}

.logo-header {
    height: 45px;
    width: auto;
}

/* Tables Grid */
.tables-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    align-content: start;
    padding: 6px 0;
}

.table-card {
    background: white;
    border: 2px solid #D32F2F;
    border-radius: 10px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 85px;
    position: relative;
}

.table-card:active {
    transform: scale(0.96);
    background: #D32F2F;
}

.table-card:active .table-card-number {
    color: white;
}

.table-card-number {
    font-size: 2rem;
    font-weight: 700;
    color: #D32F2F;
    line-height: 1;
}

.no-tables {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.2rem;
}

/* Filter Section */
.filter-section {
    flex-shrink: 0;
    padding-top: 10px;
    border-top: 2px solid #f0f0f0;
}

.filter-display-wrapper {
    position: relative;
    margin-bottom: 8px;
}

#filterDisplay {
    width: 100%;
    padding: 8px 40px 8px 10px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    background: #fafafa;
    color: #333;
    font-weight: 600;
}

#filterDisplay:focus {
    outline: none;
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.filter-clear-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: #ff4757;
    color: white;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-clear-btn:active {
    transform: translateY(-50%) scale(0.95);
    background: #e84118;
}

.filter-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.filter-num-btn {
    padding: 24px 10px;
    font-size: 1.3rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: #D32F2F;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.filter-num-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    background: #C62828;
}

.filter-num-btn.zero {
    grid-column: 1 / 3;
}

.filter-backspace-btn {
    background: #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Scrollbar styling */
.tables-grid::-webkit-scrollbar {
    width: 8px;
}

.tables-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.tables-grid::-webkit-scrollbar-thumb {
    background: #D32F2F;
    border-radius: 10px;
}

.tables-grid::-webkit-scrollbar-thumb:hover {
    background: #C62828;
}

/* Prevent text selection on touch */
.table-card, .login-btn, .password-num-btn, .filter-num-btn, .filter-clear-btn {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Tablet optimization */
@media (max-width: 1024px) {
    .app-content {
        padding: 12px;
        gap: 10px;
    }
    
    .logo-header {
        height: 45px;
    }
    
    .tables-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 8px;
    }
    
    .table-card {
        min-height: 75px;
        padding: 16px 10px;
    }
    
    .table-card-number {
        font-size: 1.7rem;
    }
    
    .filter-num-btn {
        padding: 20px 8px;
        font-size: 1.2rem;
    }
}
