<?php

if (!function_exists('is_superadmin')) {
    function is_superadmin(): bool {
        return isset($_SESSION['user']) &&
               ($_SESSION['user']['role'] ?? '') === 'superadmin';
    }
}

if (!function_exists('current_org_scope')) {
    function current_org_scope(): ?int {
        if (is_superadmin()) {
            return null; // no restriction
        }
        return $_SESSION['user']['org_id'] ?? null;
    }
}
