<?php
function app_head(string $title): void { ?>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title><?= htmlspecialchars($title) ?> | Verdant Meridian</title><link rel="stylesheet" href="<?= APP_BASE ?>/app.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"></head><body><div class="loading-overlay" id="appLoader"><div class="loader-card"><div class="loader-orbit"></div>Preparing your workspace</div></div>
<?php }
function app_open(string $page, string $title): void { $name=$_SESSION['user_name']??'Account';$first=explode(' ',$name)[0];$base=APP_BASE; ?>
<div class="app"><aside class="sidebar"><a class="wordmark" href="<?= $base ?>/"><span class="mark">V</span><span>Verdant Meridian</span></a><div class="nav-label">WORKSPACE</div><a class="side-link <?= $page==='dashboard'?'active':'' ?>" href="<?= $base ?>/dashboard"><i class="bi bi-grid-1x2"></i><span>Overview</span></a><a class="side-link <?= $page==='portfolio'?'active':'' ?>" href="<?= $base ?>/portfolio"><i class="bi bi-pie-chart"></i><span>Portfolio</span></a><a class="side-link <?= $page==='investments'?'active':'' ?>" href="<?= $base ?>/investments"><i class="bi bi-graph-up-arrow"></i><span>Investments</span></a><a class="side-link <?= $page==='transactions'?'active':'' ?>" href="<?= $base ?>/transactions"><i class="bi bi-receipt"></i><span>Transactions</span></a><div class="nav-label">ACCOUNT</div><a class="side-link <?= $page==='deposit'?'active':'' ?>" href="<?= $base ?>/deposit"><i class="bi bi-arrow-down-left-circle"></i><span>Deposit</span></a><a class="side-link <?= $page==='withdraw'?'active':'' ?>" href="<?= $base ?>/withdraw"><i class="bi bi-arrow-up-right-circle"></i><span>Withdraw</span></a><a class="side-link <?= $page==='profile'?'active':'' ?>" href="<?= $base ?>/profile"><i class="bi bi-person-gear"></i><span>Profile & security</span></a><a class="side-link" href="<?= $base ?>/transactions"><i class="bi bi-bell"></i><span>Notifications</span></a><a class="side-link" href="<?= $base ?>/profile"><i class="bi bi-life-preserver"></i><span>Support</span></a><div class="side-footer"><a class="side-link" href="<?= $base ?>/logout.php"><i class="bi bi-box-arrow-left"></i><span>Log out</span></a></div></aside><main class="main-app"><header class="topbar"><button class="menu-toggle" type="button" aria-label="Open navigation" aria-expanded="false"><i class="bi bi-list"></i></button><div><div class="crumb">Workspace / <?= htmlspecialchars($title) ?></div><h1><?= htmlspecialchars($title) ?></h1></div><div class="account-chip"><div class="avatar"><?= htmlspecialchars(strtoupper(substr($first,0,1))) ?></div><div><b><?= htmlspecialchars($first) ?></b><small>Personal account</small></div></div></header><div class="content">
<?php }
function app_close(): void { echo '</div></main></div><script src="' . APP_BASE . '/app.js"></script></body></html>'; }
function require_user(): void { if(session_status()!==PHP_SESSION_ACTIVE)session_start();if(!isset($_SESSION['user_id'])){header('Location: '.APP_BASE.'/login');exit;} }