<?php
require_once __DIR__.'/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
require_once __DIR__.'/../../engine/Logger.php';
$ctx = Kernel::handle(['auth' => 'admin']);
$admin = $ctx['user']; // admin session array
$u     = $admin;          // alias for backward compat
try {
    $st = db()->prepare("SELECT * FROM sdpay_aml_reports ORDER BY created_at DESC LIMIT 50");
    $st->execute();
    echo json_encode(['ok'=>true,'data'=>$st->fetchAll()], JSON_UNESCAPED_UNICODE);
} catch(Throwable $e){http_response_code(500);echo json_encode(['error' => 'server_error', 'message' => 'خطأ مؤقت — حاول مرة أخرى'], JSON_UNESCAPED_UNICODE);}
