You are building a LocalBitcoins-style P2P marketplace for Monero (XMR) called LocalXMR. Implement a full-stack web application using pure PHP (server-rendered HTML), no JavaScript, no Java, secure sessions, and Monero Wallet RPC for wallet operations. The build must include User, Vendor, and Admin roles, buy/sell ads, escrow trades, disputes, and a commission system with the following fees: Trade commission (admin): 1% of the trade amount, taken from the seller upon successful release. Withdrawal fee (admin): 1% deducted from any user withdrawal initiated from the site. Deliver a production-ready codebase with clear structure, configuration, and security hardening. Keep the implementation fully functional end-to-end. Tech & Constraints Language: PHP 8.2+ only. No JavaScript anywhere (front-end is server-rendered HTML forms/pages). DB: MySQL/MariaDB via PDO with prepared statements (no ORM). Sessions: Secure PHP sessions (HTTPOnly, SameSite=Lax or Strict, Secure flag if HTTPS), session fixation prevention on login. Templating: Lightweight PHP includes/partials. No templating engines. Styles: Minimal inline CSS or server-served CSS file (no external CDNs required). No JS dependencies. Wallet: monero-wallet-rpc (custodial) with unique subaddress per user for deposits, and internal escrow account for trades. Background tasks: PHP CLI cron scripts (no JS workers) for wallet polling/settlement. Environment: .env.php config file (PHP array) with secrets and RPC creds. High-Level Features Auth & Profiles Register, Login, Logout. Roles: user, vendor, admin. Vendors can post buy and sell ads for XMR. (Regular users can trade from ads.) Email (unique), username (unique), password (bcrypt), created_at. Wallet (Custodial, Monero RPC) On user creation, generate a subaddress (account_index=0) labeled with user ID for deposits. Deposit detection via RPC polling (cron), credit internal user balance (XMR) once tx confirmations >= configurable threshold. Withdraw form: user enters external XMR address + amount; apply 1% withdrawal fee; create on-chain tx via transfer RPC; store record with txid, amount, fee, status. Admin view of wallet ledger, hot wallet balance, and recent transfers. Ads (P2P Listings) Vendors create Buy XMR or Sell XMR ads with: Title, direction (buy or sell), price per XMR (fixed), min/max amount, payment method text, terms. Status: active, paused, closed. Public Ads index with filtering by direction and simple search. Trades & Escrow Any logged-in user can start a trade against an active ad they do not own. Escrow flow (custodial): For Sell XMR ads: When a buyer starts a trade, the system locks seller’s internal balance (amount) into an escrow ledger (moves to an escrow table/account) until release/cancel. Release: Seller (or admin) releases escrow to buyer’s internal balance minus 1% trade commission (commission taken from the seller’s side at release). Commission credited to admin revenue ledger. Cancel: If both parties agree or timeout before payment, funds are returned to seller balance. Dispute: Either party can open a dispute; admins arbitrate and can release to buyer or return to seller. For Buy XMR ads (vendor buys from others), the flow mirrors above depending on who is selling; the seller side always provides escrow. Trades have secure message threads between buyer/seller (and admins if disputed). Disputes Any party can Open Dispute on a pending trade with a reason. Trade status transitions: pending → disputed → released/cancelled. Admins have a Dispute Desk: list, filter, view evidence/messages, action buttons: Release to Buyer, Return to Seller, Warn/Ban User. Fees & Accounting Admin Commission (Trade): 1% deducted from the released amount; recorded in commissions ledger with trade_id. Withdrawal Fee: 1% of requested amount; recorded in commissions with withdrawal_id. Summaries: admin dashboard shows total volume, total fees (trade vs withdraw), active disputes. Admin Panel User management: view users, roles, balances, enable/disable, reset password (admin-initiated set/reset flow). Ads management: list, pause/close. Trades management: list by status, force-release/return, open/close disputes. Wallet: hot wallet balance via RPC, system account subaddresses, fee revenue. Site settings: fees (hard-code defaults at 1% but allow change), confirmation threshold, withdrawal limits, KYC toggle (if added later). Security CSRF tokens on all state-changing POSTs. XSS-safe HTML output via htmlspecialchars helper. Rate limiting: simple IP + route counters in DB with exponential lockouts for auth and trade/dispute actions. Password hashing: password_hash() (bcrypt/argon2id) and password_verify(). Session hardening: regenerate on login, destroy on logout; cookie flags (HttpOnly, SameSite, Secure under HTTPS). RBAC gate helpers (require_role, can_view_trade, etc.). Input validation and server-side constraints. Audit logs for sensitive admin actions.