I had an O27 layout for a long time, and a pretty large selection of locos. There's a little misinformation in the posts above.
At least some, maybe most Lionel F3 diesels WILL run on O27 track. I'm pretty sure the 2243 Texas Special was originally sold in an O27 set. GG-1s will definitely negotiate O27 track and switches with no issues. The giant 773 Hudson WILL go around O27 curves, although it looks ridiculous and the overhang may threaten nearby structures. Pretty much any Postwar or MPC-era Lionel, Marx, etc., is fine EXCEPT the Berkshires (which have a longer wheelbase than the Hudson) and the Fairbanks-Morse Trainmaster.
MTH RailKing diesels, at least the ones with 4-axle trucks, and steam locos with up to six driving wheels should be fine too. But with rubber tires on both sides of the same axle, these may slow noticeably because the wheels cannot "skid" around these sharp curves, which is essential to smooth operation.
One point of confusion about "what will run on O27" involves 1121 / 1122 and 5121 / 5122 switches. These had large plastic motor boxes to cover the switch coils, and in the case of the 5122, a target indicator that sticks up showing the track direction. If your track plan includes switches and S-curves, you may have issues with pilots ("cow-catchers"), railings, and cab roofs hitting the switch indicators. Also, see my comment about Marx O27 switches below.
S-curves are a bad design practice that should be avoided if possible. No matter what, it's important to allow sufficient clearance between adjacent tracks. There are no real "standards." Experiment with your largest equipment, or borrow some large equipment to test with.
Sharp curves result in a lot of centrifugal force. I strongly advise you to put some type of border or safety barrier around the edge of your door to keep trains on the platform and off the floor! This can be plexiglass, or even just a wall made of 1 x 4s around the edges (which will help to stiffen the platform.)
I have experience with O27 and O31 switches, including Lionel O22s. The O22s have some nice features such as being able to swap the switch motor to the opposite side, and an option to power them from fixed voltage. But I wouldn't really call them "refined." They are pretty bumpy; trains tend to rumble through them with a lot of bouncing. At 50 years old, it'll be hard to find some without a lot of wear. I'm pretty sure Fasttrack O31 switches would be smoother.
One problem with upgrading beyond O27 is that the cost of switches increases dramatically, and the geometry of the larger curves is limiting; you end up with much shorter straightaways. One of the best O27 switches was made by Marx. It has a flat, featureless metal box to cover the switch coils. A large section of rail pivots on a center point, so it's not realistic LOOKING. But it works very well with many types of locos.
If saving money is an issue, consider using manual switches on the front side where they can be reached, and save the electrically controlled switches for the middle and back of the layout.
Honestly if I were going to build a small tabletop layout today, I would beg, borrow, or steal to get 6 x 10 or at least 5 x 9. And I would use O36 track and switches from Atlas. If your platform is deeper than 36" you'll need to allow a 14"-16" access aisle along the back wall so you can get back there to reach derailments, clean the track, etc. Welcome to a fun adventure!!