<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ $title ?? 'Movex Finance' }}</title>
    <style>
        :root{--green:#6fbf2d;--dark:#12301f;--light:#f5f8f3;--line:#dfe8dc;--muted:#68776c;--danger:#b42318;--warn:#946200;--blue:#135fb8;}
        *{box-sizing:border-box}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--light);color:#18251d}a{color:inherit;text-decoration:none}.app{display:flex;min-height:100vh}.sidebar{width:270px;background:#fff;border-right:1px solid var(--line);padding:22px;position:sticky;top:0;height:100vh;overflow:auto}.brand{display:flex;gap:10px;align-items:center;margin-bottom:24px}.logo{width:42px;height:42px;border-radius:12px;background:linear-gradient(135deg,var(--green),#d7ff8f);display:grid;place-items:center;font-weight:900;color:var(--dark)}.brand h1{font-size:18px;margin:0}.brand p{font-size:12px;margin:3px 0 0;color:var(--muted)}.nav-title{font-size:11px;color:var(--muted);text-transform:uppercase;margin:20px 0 8px;font-weight:700}.nav a,.logout-btn{display:block;padding:10px 12px;border-radius:10px;margin-bottom:6px;color:#243528;background:transparent;border:0;width:100%;text-align:left;font-size:14px;cursor:pointer}.nav a:hover,.logout-btn:hover{background:#eef8e7}.main{flex:1;padding:26px;min-width:0}.topbar{display:flex;justify-content:space-between;gap:20px;align-items:center;margin-bottom:22px}.topbar h2{margin:0;font-size:25px}.topbar p{margin:6px 0 0;color:var(--muted)}.user-pill{background:#fff;border:1px solid var(--line);padding:10px 14px;border-radius:999px;font-size:13px}.grid{display:grid;gap:16px}.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}.card{background:#fff;border:1px solid var(--line);border-radius:18px;padding:18px;box-shadow:0 12px 35px rgba(14,38,22,.05);margin-bottom:16px}.stat .label{color:var(--muted);font-size:13px}.stat .value{font-size:25px;font-weight:800;margin-top:8px}.section-title{font-size:18px;font-weight:800;margin:0 0 14px}.form-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.field label{display:block;font-size:13px;font-weight:700;margin-bottom:6px}.field input,.field select,.field textarea{width:100%;border:1px solid #cfdacb;border-radius:10px;padding:10px 12px;background:#fff;font-size:14px}.field textarea{min-height:90px}.btn{border:0;border-radius:10px;padding:10px 14px;font-weight:800;cursor:pointer;background:var(--dark);color:#fff;display:inline-block}.btn-light{background:#eef8e7;color:var(--dark)}.btn-danger{background:var(--danger)}.btn-small{font-size:12px;padding:7px 10px}.table-wrap{overflow:auto;border-radius:14px;border:1px solid var(--line)}table{width:100%;border-collapse:collapse;background:#fff;min-width:760px}th,td{text-align:left;padding:11px 12px;border-bottom:1px solid var(--line);font-size:13px;vertical-align:top}th{background:#f0f7ec;font-size:12px;text-transform:uppercase;color:#4e604f}.badge{display:inline-block;padding:4px 8px;border-radius:999px;background:#eef8e7;font-size:12px;font-weight:800}.badge.warn{background:#fff4d6;color:var(--warn)}.badge.danger{background:#ffe8e6;color:var(--danger)}.badge.blue{background:#e7f0ff;color:var(--blue)}.alert{padding:12px 14px;border-radius:12px;margin-bottom:14px}.alert-success{background:#e9f8df;border:1px solid #c8eebb}.alert-error{background:#fff0ef;border:1px solid #ffc3bf}.muted{color:var(--muted)}.actions{display:flex;gap:8px;flex-wrap:wrap}.auth-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#f7fbf5,#e9f8df)}.auth-card{width:100%;max-width:520px}.auth-card .brand{justify-content:center;text-align:left}.footer-note{font-size:12px;color:var(--muted);margin-top:12px}.mobile-menu{display:none}
        @media(max-width:1000px){.app{display:block}.sidebar{width:auto;height:auto;position:relative}.main{padding:18px}.grid-4,.grid-3,.grid-2,.form-grid{grid-template-columns:1fr}.topbar{display:block}.user-pill{margin-top:12px;display:inline-block}table{min-width:900px}}
    </style>
</head>
<body>
@if(auth()->check())
<div class="app">
    <aside class="sidebar">
        <div class="brand">
            <div class="logo">₦</div>
            <div><h1>Movex Finance</h1><p>Accounts and finance portal</p></div>
        </div>
        <nav class="nav">
            @if(auth()->user()->isAdmin())
                <div class="nav-title">Admin</div>
                <a href="{{ route('admin.dashboard') }}">Dashboard</a>
                <a href="{{ route('admin.accounts') }}">Chart of Accounts</a>
                <a href="{{ route('admin.contacts') }}">Contacts</a>
                <a href="{{ route('admin.banks') }}">Bank Accounts</a>
                <a href="{{ route('admin.invoices') }}">Invoices / Receivables</a>
                <a href="{{ route('admin.bills') }}">Bills / Payables</a>
                <a href="{{ route('admin.claims') }}">Expense Claims</a>
                <a href="{{ route('admin.advances') }}">Cash Advances</a>
                <a href="{{ route('admin.journals') }}">Journal Entries</a>
                <a href="{{ route('admin.budgets') }}">Budgets</a>
                <a href="{{ route('admin.payroll') }}">Payroll</a>
                <a href="{{ route('admin.taxes') }}">Taxes</a>
                <a href="{{ route('admin.reports') }}">Reports</a>
                <a href="{{ route('admin.users') }}">Users</a>
                <a href="{{ route('admin.audit') }}">Audit Logs</a>
            @else
                <div class="nav-title">User Portal</div>
                <a href="{{ route('user.dashboard') }}">Dashboard</a>
                <a href="{{ route('user.claims') }}">Expense Claims</a>
                <a href="{{ route('user.advances') }}">Cash Advances</a>
                <a href="{{ route('user.profile') }}">Profile</a>
            @endif
            <div class="nav-title">Session</div>
            <form method="POST" action="{{ route('logout') }}">@csrf<button class="logout-btn" type="submit">Logout</button></form>
        </nav>
    </aside>
    <main class="main">
        <div class="topbar">
            <div><h2>{{ $pageTitle ?? 'Dashboard' }}</h2><p>{{ $pageSubtitle ?? 'Finance and accounting management' }}</p></div>
            <div class="user-pill">{{ auth()->user()->name }} · {{ strtoupper(auth()->user()->role) }}</div>
        </div>
        @include('partials.flash')
        @yield('content')
    </main>
</div>
@else
    @yield('content')
@endif
</body>
</html>
