<?php
// Opens the page: <head>, sidebar/offcanvas nav, quiet top bar, opens <main>.
// Every page controller sets $pageTitle (and optionally $currentPage) before
// requiring this file.
require_once __DIR__ . '/../auth.php';
$pageTitle = $pageTitle ?? 'Dashboard';
$currentPage = $currentPage ?? '';
$user = current_user();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>月账 · Monthly Ledger — <?= e($pageTitle) ?></title>
<meta name="theme-color" content="#5a5bd8">
<link rel="icon" href="assets/icons/favicon.ico" sizes="any">
<link rel="icon" type="image/png" sizes="192x192" href="assets/icons/icon-192.png?v=<?= e(asset_version('assets/icons/icon-192.png')) ?>">
<link rel="apple-touch-icon" href="assets/icons/apple-touch-icon.png?v=<?= e(asset_version('assets/icons/apple-touch-icon.png')) ?>">
<link rel="manifest" href="manifest.json?v=<?= e(asset_version('manifest.json')) ?>">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="Monthly Ledger">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css">
<link rel="stylesheet" href="assets/css/app.css?v=<?= e(asset_version('assets/css/app.css')) ?>">
</head>
<body>

<?php require __DIR__ . '/nav.php'; ?>

<div class="app-main">

  <header class="topbar">
    <div class="container-xxl">
      <div class="topbar-inner">
        <button class="icon-btn d-lg-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#menu" aria-label="Open menu">
          <i class="bi bi-list fs-4"></i>
        </button>
        <div>
          <?php if ($user): ?>
          <div class="sec-sub" id="greeting"><?= e(greeting_phrase()) ?>, <?= e($user['display_name']) ?></div>
          <?php endif; ?>
          <div class="fw-semibold"><?= e($pageTitle) ?></div>
        </div>
        <?php if ($user): ?>
        <div class="ms-auto d-flex align-items-center gap-2">
          <span class="avatar" aria-hidden="true"><?= e(mb_strtoupper(mb_substr($user['display_name'], 0, 1))) ?></span>
        </div>
        <?php endif; ?>
      </div>
    </div>
  </header>

  <main class="container-xxl py-3 py-lg-4">
