<?php
$report = ['php' => PHP_VERSION, 'time' => date('c'), 'db' => 'unknown', 'tables' => []];
try {
    $tables = ['users','roles','permissions','properties','bookings','payments','expenses','tickets','notifications','activity_log','settings'];
    db()->query('SELECT 1');
    $report['db'] = 'ok';
    foreach ($tables as $t) {
        try { db()->query("SELECT 1 FROM `$t` LIMIT 1"); $report['tables'][$t] = 'ok'; }
        catch (Throwable $e) { $report['tables'][$t] = 'MISSING'; }
    }
} catch (Throwable $e) { $report['db'] = 'ERROR: ' . $e->getMessage(); }
json_ok($report);
