<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="color-scheme" content="dark">
    <title>@yield('page_title', $title ?? 'Die Kaffeeliste')</title>
    @php
        $layoutAuth = $auth ?? (function_exists('app_auth_user') ? app_auth_user() : null);
        $layoutLicense = $tenantLicense ?? ['features' => []];
        $layoutThemeSettings = $tenantSettings ?? (function_exists('app_tenant_settings_defaults') ? app_tenant_settings_defaults() : []);
        if (!isset($tenantSettings) && is_array($layoutAuth) && function_exists('app_pdo') && function_exists('app_tenant_settings')) {
            try {
                $layoutThemeSettings = app_tenant_settings(app_pdo(), (string) ($layoutAuth['tenant_id'] ?? ''));
            } catch (Throwable $ignored) {
            }
        }
        $layoutPath = parse_url((string) ($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH);
        $layoutPath = is_string($layoutPath) ? rtrim($layoutPath, '/') : '/';
        $layoutNavItems = function_exists('app_tenant_navigation_items')
            ? app_tenant_navigation_items($layoutAuth, $layoutLicense)
            : [];
        $layoutNavGroups = function_exists('app_tenant_navigation_groups')
            ? app_tenant_navigation_groups($layoutNavItems)
            : [];
        $layoutGuestItems = [
            ['href' => '/', 'label' => 'Start'],
            ['href' => '/login/', 'label' => 'Anmeldung'],
            ['href' => '/admin/login/', 'label' => 'Admin'],
        ];
        $layoutPrimaryNavItems = $layoutNavItems !== [] ? $layoutNavItems : $layoutGuestItems;
        $layoutHeaderNavItems = $layoutPrimaryNavItems;
        if (is_array($layoutAuth)) {
            $layoutHeaderNavItems = [];
            foreach ($layoutPrimaryNavItems as $item) {
                if (in_array((string) ($item['key'] ?? ''), ['dashboard', 'ledger', 'payments'], true)) {
                    $layoutHeaderNavItems[] = $item;
                }
            }
        }
        $layoutCurrentLabel = 'Start';
        foreach ($layoutPrimaryNavItems as $item) {
            $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
            $itemHref = $itemHref === '' ? '/' : $itemHref;
            if ($layoutPath === $itemHref) {
                $layoutCurrentLabel = (string) ($item['label'] ?? $layoutCurrentLabel);
                break;
            }
        }
        if ($layoutPath === '/profile') {
            $layoutCurrentLabel = 'Persönliche Einstellungen';
        }
        $layoutAccountItems = function_exists('app_tenant_account_items')
            ? app_tenant_account_items($layoutAuth)
            : [];
        $layoutThemeCss = function_exists('app_tenant_theme_root_css')
            ? app_tenant_theme_root_css($layoutThemeSettings)
            : '';
        if (is_array($layoutAuth)) {
            $layoutMobilePrimaryNavItems = array_slice($layoutHeaderNavItems, 0, 3);
        } else {
            $layoutMobilePrimaryNavItems = array_slice($layoutPrimaryNavItems, 0, 2);
        }
        $layoutMobileDrawerPrimaryItems = [];
        foreach ($layoutHeaderNavItems as $item) {
            $itemKey = (string) ($item['key'] ?? '');
            $isAlreadyPrimary = false;
            foreach ($layoutMobilePrimaryNavItems as $primaryItem) {
                if ((string) ($primaryItem['key'] ?? '') === $itemKey) {
                    $isAlreadyPrimary = true;
                    break;
                }
            }
            if (!$isAlreadyPrimary) {
                $layoutMobileDrawerPrimaryItems[] = $item;
            }
        }
        $layoutMobileHasDrawer = $layoutMobileDrawerPrimaryItems !== [] || $layoutNavGroups !== [] || is_array($layoutAuth);
        $layoutMobileNavColumns = count($layoutMobilePrimaryNavItems) + ($layoutMobileHasDrawer ? 1 : 0);
        if ($layoutMobileNavColumns < 3) {
            $layoutMobileNavColumns = 3;
        }
    @endphp
    @php
        $resolvedLayoutMode = trim((string) $__env->yieldContent('layout_mode', 'app'));
    @endphp
    <style>
        :root {
            {!! $layoutThemeCss !!}
            --line: rgba(143, 158, 191, 0.16);
            --line-strong: rgba(174, 189, 223, 0.26);
            --shadow: 0 24px 64px rgba(1, 6, 18, 0.36);
            --shadow-soft: 0 16px 34px rgba(1, 6, 18, 0.2);
            --radius-xl: 20px;
            --radius-lg: 14px;
            --sidebar-width: 292px;
            --content-width: 1260px;
            --surface-0: #05070d;
            --surface-1: rgba(8, 12, 22, 0.84);
            --surface-2: rgba(13, 18, 31, 0.92);
            --surface-3: rgba(17, 24, 40, 0.96);
            --surface-soft: rgba(255, 255, 255, 0.04);
            --text-strong: #f4f7ff;
            --text-soft: rgba(219, 228, 248, 0.74);
            --text-faint: rgba(190, 202, 226, 0.52);
        }

        * { box-sizing: border-box; }
        html { scroll-behavior: smooth; }
        body {
            margin: 0;
            min-height: 100vh;
            color: var(--text-strong);
            background:
                radial-gradient(circle at top center, rgba(88, 122, 255, 0.2), transparent 26%),
                radial-gradient(circle at 18% 18%, rgba(var(--brand-rgb), 0.16), transparent 22%),
                linear-gradient(180deg, #05070d 0%, #0a0f1a 48%, #0d1320 100%);
            font-family: "Aptos", "Segoe UI", sans-serif;
            line-height: 1.55;
        }

        h1, h2, h3, h4, .hero__title, .brand__title {
            font-family: "Inter Tight", "Aptos", "Segoe UI", sans-serif;
            letter-spacing: -0.04em;
        }

        a { color: inherit; text-decoration: none; }
        a:hover { text-decoration: none; }
        img { max-width: 100%; }

        .app-shell {
            width: min(var(--content-width), calc(100% - 28px));
            margin: 14px auto;
            min-height: calc(100vh - 28px);
            display: grid;
            gap: 14px;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 14px;
            min-width: 0;
        }

        .brand__mark {
            width: 38px;
            height: 38px;
            border-radius: 10px;
            display: grid;
            place-items: center;
            font-weight: 700;
            color: #fff;
            background: linear-gradient(135deg, #587aff 0%, #243a91 100%);
            box-shadow: none;
        }

        .brand__text { display: grid; gap: 3px; min-width: 0; }
        .brand__title { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -0.03em; }
        .brand__subtitle { margin: 0; color: var(--text-soft); font-size: 0.88rem; }
        .brand--link { color: inherit; text-decoration: none; }
        .brand--link:hover { text-decoration: none; }

        .site-shell {
            min-height: 100vh;
            padding: 0 0 24px;
            overflow-x: clip;
        }

        .site-header,
        .app-footer {
            width: 100%;
        }

        .site-main {
            width: min(var(--content-width), calc(100% - 28px));
            margin: 0 auto;
        }

        .site-header {
            position: sticky;
            top: 0;
            z-index: 30;
            width: 100%;
            margin-left: 0;
            margin-bottom: 24px;
        }

        .site-header__inner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            width: 100%;
            min-height: 74px;
            margin: 0;
            padding: 0 24px;
            border: 0;
            border-bottom: 1px solid var(--line);
            border-radius: 0;
            background: rgba(8, 10, 18, 0.82);
            box-shadow: var(--shadow);
            backdrop-filter: blur(18px);
        }

        .top-nav {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            min-width: 0;
        }

        .top-nav__link {
            display: inline-flex;
            align-items: center;
            min-height: 34px;
            padding: 0 0.34rem;
            border-radius: 6px;
            border: 1px solid transparent;
            color: var(--text-soft);
            font-size: 0.96rem;
            font-weight: 600;
            white-space: nowrap;
        }

        .top-nav__link:hover {
            text-decoration: none;
            color: var(--text-strong);
            background: rgba(255, 255, 255, 0.05);
            border-color: rgba(255, 255, 255, 0.08);
        }

        .top-nav__link.is-active {
            color: var(--text-strong);
            background: rgba(255, 255, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.12);
        }

        .site-actions {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 10px;
            flex-wrap: wrap;
        }

        .site-actions__toggle {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            min-height: 38px;
            padding: 0.45rem 0.82rem;
            border-radius: 10px;
            border: 1px solid var(--line-strong);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-strong);
            font: inherit;
            font-weight: 700;
            cursor: pointer;
        }

        .site-actions__toggle::before {
            content: "";
            display: block;
            width: 18px;
            height: 2px;
            border-radius: 999px;
            background: currentColor;
            box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
        }

        .sidebar-meta,
        .header-meta {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
        }

        .badge,
        .pill {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            border-radius: 999px;
            border: 1px solid var(--line);
            background: var(--surface-soft);
            padding: 0.42rem 0.75rem;
            font-size: 0.82rem;
            font-weight: 600;
            color: var(--text-strong);
        }

        .badge--solid { background: linear-gradient(135deg, #587aff 0%, #243a91 100%); color: #fff; border-color: transparent; }

        .sidebar-nav { display: grid; gap: 6px; align-content: start; }

        .sidebar-nav__link {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 0.76rem 0.92rem;
            border-radius: 14px;
            border: 1px solid rgba(44, 32, 23, 0.08);
            background: rgba(255, 255, 255, 0.72);
            color: var(--text);
            font-size: 0.92rem;
            font-weight: 700;
            box-shadow: none;
        }

        .sidebar-nav__link::after {
            content: "›";
            font-size: 1rem;
            color: var(--muted);
        }

        .sidebar-nav__link:hover {
            text-decoration: none;
            border-color: rgba(var(--brand-rgb), 0.22);
            background: rgba(255, 255, 255, 0.92);
        }

        .sidebar-nav__link.is-active {
            background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
            color: #fff;
            border-color: transparent;
        }

        .sidebar-nav__link.is-active::after { color: rgba(255, 255, 255, 0.88); }

        .sidebar-footer {
            display: grid;
            gap: 10px;
            align-content: end;
        }

        .sidebar-note {
            padding: 12px 14px;
            border-radius: 14px;
            background: rgba(var(--brand-rgb), 0.06);
            border: 1px solid rgba(var(--brand-rgb), 0.1);
            color: var(--brand-strong);
            font-size: 0.92rem;
        }

        .sidebar-note strong {
            display: block;
            margin-bottom: 4px;
        }

        .app-body {
            min-width: 0;
            display: grid;
            gap: 18px;
        }

        .mobile-bottom-nav {
            display: none;
        }

        .mobile-bottom-nav__bar {
            display: grid;
            gap: 8px;
            align-items: stretch;
        }

        .mobile-bottom-nav__link,
        .mobile-bottom-nav__more {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 4px;
            min-height: 56px;
            padding: 8px 6px 7px;
            border-radius: 16px;
            border: 1px solid var(--line);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-soft);
            font-weight: 600;
            font-size: 0.74rem;
            line-height: 1.15;
            text-align: center;
            cursor: pointer;
        }

        .mobile-bottom-nav__link:hover,
        .mobile-bottom-nav__more:hover {
            text-decoration: none;
            color: var(--text-strong);
            border-color: rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.06);
        }

        .mobile-bottom-nav__link.is-active {
            color: #fff;
            border-color: transparent;
            background: linear-gradient(135deg, #587aff 0%, #243a91 100%);
        }

        .mobile-bottom-nav__label {
            display: block;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mobile-bottom-nav__meta {
            display: block;
            color: var(--text-faint);
            font-size: 0.62rem;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
        }

        .mobile-drawer {
            position: fixed;
            inset: 0;
            display: none;
            z-index: 70;
        }

        .mobile-drawer.is-open {
            display: block;
        }

        .mobile-drawer__scrim {
            position: absolute;
            inset: 0;
            border: 0;
            background: rgba(4, 10, 18, 0.62);
            backdrop-filter: blur(8px);
            cursor: pointer;
        }

        .mobile-drawer__panel {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            width: min(100vw, 420px);
            max-width: 100%;
            padding: 18px 16px calc(26px + env(safe-area-inset-bottom));
            border-left: 1px solid var(--line);
            background: linear-gradient(180deg, rgba(13, 18, 31, 0.99), rgba(8, 10, 18, 0.98));
            box-shadow: var(--shadow);
            display: grid;
            grid-template-rows: auto 1fr auto;
            gap: 16px;
            overflow: auto;
        }

        .mobile-drawer__header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 12px;
        }

        .mobile-drawer__title {
            margin: 0;
            font-size: 1.08rem;
            font-weight: 800;
            letter-spacing: -0.03em;
        }

        .mobile-drawer__copy {
            margin: 4px 0 0;
            color: var(--text-soft);
            font-size: 0.92rem;
        }

        .mobile-drawer__close {
            min-width: 40px;
            min-height: 40px;
            padding: 0.45rem 0.75rem;
            border-radius: 999px;
        }

        .mobile-drawer__sections {
            display: grid;
            gap: 14px;
            overflow: auto;
            padding-right: 2px;
        }

        .mobile-drawer__section {
            display: grid;
            gap: 8px;
        }

        .mobile-drawer__label {
            font-size: 0.74rem;
            font-weight: 800;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--text-faint);
        }

        .mobile-drawer__links {
            display: grid;
            gap: 8px;
        }

        .mobile-drawer__link {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 0.8rem 0.95rem;
            border-radius: 14px;
            border: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.04);
            color: var(--text-strong);
            font-size: 0.93rem;
            font-weight: 700;
        }

        .mobile-drawer__link::after {
            content: "›";
            color: var(--text-faint);
            font-size: 1rem;
        }

        .mobile-drawer__link:hover {
            text-decoration: none;
            border-color: rgba(255, 255, 255, 0.14);
            background: rgba(255, 255, 255, 0.06);
        }

        .mobile-drawer__link.is-active {
            color: #fff;
            border-color: transparent;
            background: linear-gradient(135deg, #587aff 0%, #243a91 100%);
        }

        .mobile-drawer__link.is-active::after {
            color: rgba(255, 255, 255, 0.88);
        }

        .mobile-drawer__empty {
            padding: 12px 14px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.06);
            color: var(--text-soft);
            font-size: 0.92rem;
        }

        .mobile-drawer__footer {
            display: grid;
            gap: 12px;
            padding-top: 6px;
            border-top: 1px solid var(--line);
        }

        .button,
        button,
        input[type="submit"] {
            appearance: none;
            border: 0;
            border-radius: 10px;
            padding: 0.72rem 1rem;
            background: linear-gradient(135deg, #587aff 0%, #243a91 100%);
            color: #fff;
            font: inherit;
            font-weight: 700;
            cursor: pointer;
            box-shadow: 0 12px 24px rgba(36, 58, 145, 0.22);
        }

        .button--ghost {
            background: rgba(255, 255, 255, 0.03);
            color: var(--text-strong);
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: none;
        }

        .app-main { padding: 0 0 6px; }

        .hero {
            display: grid;
            gap: 16px;
            margin-bottom: 28px;
            padding: 20px;
            border: 1px solid var(--line);
            border-radius: 18px;
            background: linear-gradient(135deg, rgba(14, 20, 34, 0.98), rgba(10, 15, 26, 0.96));
            box-shadow: var(--shadow);
        }

        .hero--split {
            grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
            align-items: stretch;
        }

        .hero__content,
        .hero__aside {
            display: grid;
            gap: 18px;
        }

        .hero__kicker {
            margin: 0 0 12px;
            text-transform: uppercase;
            letter-spacing: 0.15em;
            font-size: 0.8rem;
            color: #8aa0d0;
            font-weight: 700;
        }

        .hero__title {
            margin: 0;
            font-size: clamp(2rem, 4vw, 3.6rem);
            line-height: 1.05;
            letter-spacing: -0.03em;
        }

        .hero__lead {
            margin: 0;
            max-width: 68ch;
            color: var(--text-soft);
            font-size: 1.02rem;
        }

        .hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
        .hero__meta { display: flex; flex-wrap: wrap; gap: 10px; }
        .grid { display: grid; gap: 18px; }
        .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

        .card,
        .panel,
        .form-panel,
        .table-card {
            border: 1px solid var(--line);
            border-radius: 14px;
            background: var(--surface-2);
            box-shadow: var(--shadow);
            padding: 16px;
        }

        .card__eyebrow {
            margin: 0 0 10px;
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: #8aa0d0;
            font-weight: 700;
        }

        .metric { display: grid; gap: 8px; }
        .metric__value {
            font-size: clamp(1.6rem, 2.5vw, 2.4rem);
            font-weight: 800;
            letter-spacing: -0.03em;
        }

        .metric__label,
        .muted { color: var(--text-soft); }

        .list-reset { margin: 0; padding: 0; list-style: none; }
        .list-reset li + li { margin-top: 12px; }
        .stack { display: grid; gap: 14px; }

        .feature-list { display: grid; gap: 12px; }

        .feature-list__item {
            display: flex;
            gap: 12px;
            align-items: flex-start;
            padding: 12px 14px;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.06);
        }

        .feature-list__badge {
            flex: 0 0 auto;
            width: 34px;
            height: 34px;
            border-radius: 12px;
            display: grid;
            place-items: center;
            background: rgba(88, 122, 255, 0.12);
            color: #d9e2ff;
            font-weight: 800;
        }

        .feature-list__title {
            margin: 0 0 4px;
            font-weight: 700;
        }

        .feature-list__copy {
            margin: 0;
            color: var(--text-soft);
            font-size: 0.94rem;
        }

        .split {
            display: grid;
            gap: 14px;
            grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
        }

        .auth-summary__card {
            padding: 16px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.06);
        }

        .tenant-grid { display: grid; gap: 12px; }

        .tenant-row {
            display: flex;
            justify-content: space-between;
            gap: 12px;
            align-items: center;
            padding: 12px 14px;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.06);
        }

        .tenant-row__meta { display: grid; gap: 4px; }
        .tenant-row__title { margin: 0; font-weight: 700; }
        .tenant-row__copy { margin: 0; color: var(--text-soft); font-size: 0.92rem; }

        .callout {
            padding: 14px 16px;
            border-radius: 14px;
            background: rgba(88, 122, 255, 0.08);
            border: 1px solid rgba(88, 122, 255, 0.14);
            color: var(--text-strong);
        }

        .callout strong {
            display: block;
            margin-bottom: 4px;
        }

        .metric--compact { padding: 18px 20px; }
        .toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
        .toolbar .badge { background: rgba(255, 255, 255, 0.05); }

        .table-card { overflow: hidden; padding: 0; }

        .table-card__header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            padding: 22px 22px 12px;
        }

        .table-card__body {
            padding: 0 22px 22px;
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            min-width: 680px;
        }

        th,
        td {
            padding: 0.95rem 0.8rem;
            border-bottom: 1px solid rgba(31, 41, 51, 0.08);
            text-align: left;
            vertical-align: top;
        }

        th {
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.08em;
            color: var(--text-soft);
            font-weight: 700;
            background: rgba(255, 255, 255, 0.03);
        }

        tr:last-child td { border-bottom: 0; }

        .status {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 0.38rem 0.65rem;
            border-radius: 999px;
            background: rgba(88, 122, 255, 0.12);
            color: #d9e2ff;
            font-weight: 700;
            font-size: 0.82rem;
        }

        .status--warning { background: rgba(224, 154, 70, 0.14); color: #ffd7a1; }
        .status--danger { background: rgba(195, 82, 82, 0.16); color: #ffd1d1; }

        .form-grid { display: grid; gap: 16px; }
        .field { display: grid; gap: 8px; }
        label { font-size: 0.9rem; font-weight: 700; }

        input,
        select,
        textarea {
            width: 100%;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.04);
            padding: 0.85rem 0.95rem;
            font: inherit;
            color: var(--text-strong);
        }

        select {
            color-scheme: dark;
            background-color: rgba(13, 18, 31, 0.96);
        }

        select option,
        select optgroup {
            background: rgba(13, 18, 31, 0.98);
            color: var(--text-strong);
        }

        textarea { min-height: 120px; resize: vertical; }

        .note {
            padding: 14px 16px;
            border-radius: 16px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-soft);
        }

        .timeline { display: grid; gap: 14px; }
        .timeline--tight { gap: 10px; }

        .timeline__item {
            display: grid;
            gap: 6px;
            padding: 14px 16px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.06);
        }

        .timeline__title { margin: 0; font-weight: 700; }
        .timeline__meta { margin: 0; color: var(--text-soft); font-size: 0.92rem; }

        .app-footer { padding: 6px 0 12px; }

        .app-footer__inner {
            display: flex;
            justify-content: space-between;
            gap: 16px;
            flex-wrap: wrap;
            width: min(var(--content-width), calc(100% - 28px));
            margin: 0 auto;
            border-top: 1px solid var(--line);
            padding-top: 14px;
            color: var(--text-faint);
            font-size: 0.88rem;
        }

        .marketing-shell {
            min-height: 100vh;
            padding: 0 0 92px;
            gap: 12px;
            overflow-x: clip;
        }

        .marketing-main {
            width: min(1240px, calc(100% - 48px));
            margin: 0 auto;
        }

        .marketing-bar {
            position: sticky;
            top: 0;
            z-index: 30;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 14px;
            height: 88px;
            min-height: 88px;
            width: 100%;
            margin-left: 0;
            margin-bottom: 20px;
            padding: 0 18px;
            border: 0;
            border-bottom: 1px solid rgba(137, 154, 188, 0.18);
            border-radius: 0;
            background: rgba(8, 10, 18, 0.82);
            box-shadow: none;
            backdrop-filter: blur(16px);
        }

        .marketing-nav {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-wrap: wrap;
        }

        .marketing-bar .brand {
            gap: 8px;
            flex: 0 0 auto;
        }

        .marketing-bar .brand__mark {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            font-size: 1rem;
            box-shadow: none;
        }

        .marketing-bar .brand__text {
            gap: 1px;
        }

        .marketing-bar .brand__title {
            font-size: 1.08rem;
            line-height: 1;
        }

        .marketing-bar .brand__subtitle {
            display: none;
        }

        .marketing-nav__link {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-height: 36px;
            padding: 0 0.3rem;
            border-radius: 6px;
            border: 1px solid transparent;
            color: rgba(231, 238, 255, 0.8);
            font-size: 1rem;
            font-weight: 600;
        }

        .marketing-nav__link:hover {
            color: #f4f7ff;
            text-decoration: none;
            background: rgba(255, 255, 255, 0.06);
            border-color: rgba(201, 214, 255, 0.12);
        }

        .marketing-actions {
            display: flex;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .marketing-actions .button {
            min-height: 38px;
            padding: 0.42rem 0.8rem;
            border-radius: 8px;
            font-size: 0.94rem;
        }

        .marketing-actions .button--ghost,
        .marketing-mobile__footer .button--ghost {
            color: #f4f7ff;
            border-color: rgba(201, 214, 255, 0.16);
        }

        .marketing-mobile {
            display: none;
            position: relative;
        }

        .marketing-mobile[open] { z-index: 40; }

        .marketing-mobile__toggle {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            list-style: none;
            cursor: pointer;
            min-width: 38px;
            min-height: 38px;
            padding: 0.24rem 0.46rem;
            border-radius: 8px;
            border: 1px solid rgba(201, 214, 255, 0.14);
            background: rgba(255, 255, 255, 0.04);
            color: #f4f7ff;
        }

        .marketing-mobile__toggle::-webkit-details-marker { display: none; }

        .marketing-mobile__toggle::before {
            content: "";
            display: block;
            width: 16px;
            height: 2px;
            border-radius: 999px;
            background: currentColor;
            box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
        }

        .marketing-mobile__panel {
            position: absolute;
            right: 0;
            top: calc(100% + 10px);
            width: min(280px, calc(100% - 24px));
            padding: 14px;
            border-radius: 16px;
            border: 1px solid rgba(163, 183, 255, 0.14);
            background: rgba(8, 10, 18, 0.96);
            box-shadow: 0 18px 36px rgba(1, 5, 13, 0.45);
        }

        .marketing-mobile__stack {
            display: grid;
            gap: 8px;
        }

        .marketing-mobile__stack .marketing-nav__link {
            justify-content: flex-start;
            padding: 0.55rem 0.7rem;
            background: rgba(255, 255, 255, 0.04);
            border-color: rgba(201, 214, 255, 0.1);
        }

        .marketing-mobile__footer {
            margin-top: 12px;
            display: flex;
            justify-content: flex-end;
        }

        .marketing-main {
            display: grid;
            gap: 18px;
        }

        .marketing-footer {
            position: fixed;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 25;
            margin-top: 0;
            padding: 10px 24px;
            border-top: 1px solid rgba(137, 154, 188, 0.14);
            background: rgba(8, 10, 18, 0.88);
            backdrop-filter: blur(18px);
            color: rgba(209, 217, 235, 0.68);
            font-size: 0.92rem;
        }

        .marketing-footer__inner {
            display: flex;
            justify-content: space-between;
            gap: 16px;
            flex-wrap: wrap;
            width: min(1240px, calc(100% - 48px));
            margin: 0 auto;
        }

        @media (max-width: 1180px) {
            .site-shell {
                padding: 0 0 104px;
            }

            .site-header__inner {
                width: 100%;
                min-height: 68px;
                padding: 0 12px;
                align-items: center;
            }

            .top-nav { display: none; }
            .site-actions { display: none; }
            .app-shell {
                width: calc(100% - 16px);
                margin: 8px auto;
                min-height: calc(100vh - 16px);
            }

            .mobile-bottom-nav {
                display: block;
                position: fixed;
                left: 0;
                right: 0;
                bottom: 0;
                z-index: 50;
                padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
                border-top: 1px solid rgba(137, 154, 188, 0.14);
                background: rgba(8, 10, 18, 0.9);
                backdrop-filter: blur(18px);
            }

            .mobile-bottom-nav__bar {
                grid-template-columns: repeat(var(--mobile-nav-columns, 4), minmax(0, 1fr));
            }

            body.mobile-drawer-open {
                overflow: hidden;
            }

            .mobile-drawer__panel {
                width: min(100vw, 420px);
                padding-left: 14px;
                padding-right: 14px;
            }

            .grid--2,
            .grid--3,
            .grid--4,
            .split,
            .hero--split { grid-template-columns: 1fr; }
            .hero,
            .card,
            .panel,
            .form-panel { padding: 16px; }
            .table-card { padding: 0; }
            table { min-width: 0; }
            .marketing-shell { padding: 0 0 88px; }
            .marketing-main {
                width: calc(100% - 16px);
            }
            .marketing-bar {
                height: 72px;
                min-height: 72px;
                margin-bottom: 16px;
                padding: 0 10px;
            }
            .marketing-nav,
            .marketing-actions { display: none; }
            .marketing-mobile { display: block; }
            .marketing-footer {
                padding: 10px 10px;
            }
            .marketing-footer__inner {
                width: 100%;
            }
            .site-main,
            .app-footer__inner {
                width: calc(100% - 16px);
            }
        }
        @media (max-width: 980px) {
            .app-body { gap: 14px; }
        }
    </style>
    @yield('page_styles')
</head>
<body class="@yield('body_class')">
    @if ($resolvedLayoutMode === 'marketing')
        <div class="marketing-shell">
            <header class="marketing-bar">
                <div class="brand">
                    <div class="brand__mark">K</div>
                    <div class="brand__text">
                        <h1 class="brand__title">Die Kaffeeliste</h1>
                    </div>
                </div>

                <nav class="marketing-nav" aria-label="Marketing-Navigation">
                    <a href="/" class="marketing-nav__link">Start</a>
                    <a href="/login/" class="marketing-nav__link">Anmeldung</a>
                    <a href="/admin/login/" class="marketing-nav__link">Admin</a>
                </nav>

                <div class="marketing-actions">
                    <a class="button button--ghost" href="/login/">Anmelden</a>
                </div>

                <details class="marketing-mobile">
                    <summary class="marketing-mobile__toggle" aria-label="Menü"></summary>
                    <div class="marketing-mobile__panel">
                        <nav class="marketing-mobile__stack" aria-label="Mobile Marketing-Navigation">
                            <a href="/" class="marketing-nav__link">Start</a>
                            <a href="/login/" class="marketing-nav__link">Anmeldung</a>
                            <a href="/admin/login/" class="marketing-nav__link">Admin</a>
                        </nav>
                        <div class="marketing-mobile__footer">
                            <a class="button button--ghost" href="/login/">Anmelden</a>
                        </div>
                    </div>
                </details>
            </header>

            <main class="marketing-main">
                @yield('content')
            </main>

            <footer class="marketing-footer">
                <div class="marketing-footer__inner">
                    <span>Die Kaffeeliste</span>
                    <span>Ein ruhiger Einstieg für Teams</span>
                </div>
            </footer>
        </div>
    @else
    <div class="site-shell">
        <header class="site-header">
            <div class="site-header__inner">
                <a href="{{ is_array($layoutAuth) ? '/dashboard/' : '/' }}" class="brand brand--link">
                    <div class="brand__mark">K</div>
                    <div class="brand__text">
                        <h1 class="brand__title">Die Kaffeeliste</h1>
                        <p class="brand__subtitle">
                            @if (is_array($layoutAuth))
                                {{ $layoutCurrentLabel }}
                            @else
                                Für Teams gemacht.
                            @endif
                        </p>
                    </div>
                </a>

                <nav class="top-nav" aria-label="Hauptnavigation">
                    @foreach ($layoutHeaderNavItems as $item)
                        @php
                            $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                            $itemHref = $itemHref === '' ? '/' : $itemHref;
                            $isActive = $layoutPath === $itemHref;
                        @endphp
                        <a href="{{ $item['href'] ?? '/' }}" class="top-nav__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>{{ $item['label'] ?? 'Link' }}</a>
                    @endforeach
                    @foreach ($layoutNavGroups as $group)
                        <details class="top-nav__group">
                            <summary class="top-nav__toggle">{{ $group['label'] ?? 'Mehr' }}</summary>
                            <div class="top-nav__panel">
                                <div class="top-nav__label">{{ $group['label'] ?? 'Mehr' }}</div>
                                @foreach (($group['items'] ?? []) as $item)
                                    @php
                                        $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                                        $itemHref = $itemHref === '' ? '/' : $itemHref;
                                        $isActive = $layoutPath === $itemHref;
                                    @endphp
                                    <a href="{{ $item['href'] ?? '/' }}" class="top-nav__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>{{ $item['label'] ?? 'Link' }}</a>
                                @endforeach
                            </div>
                        </details>
                    @endforeach
                </nav>

                <div class="site-actions">
                    @if (is_array($layoutAuth))
                        <details class="top-nav__group">
                            <summary class="top-nav__toggle">Konto</summary>
                            <div class="top-nav__panel">
                                <div class="top-nav__label">Konto</div>
                                @foreach ($layoutAccountItems as $item)
                                    @php
                                        $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                                        $itemHref = $itemHref === '' ? '/' : $itemHref;
                                        $isActive = $layoutPath === $itemHref;
                                    @endphp
                                    <a href="{{ $item['href'] ?? '/' }}" class="top-nav__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>{{ $item['label'] ?? 'Link' }}</a>
                                @endforeach
                                <form method="post" action="/logout/">
                                    <button type="submit" class="button button--ghost" style="width: 100%;">Abmelden</button>
                                </form>
                            </div>
                        </details>
                    @else
                        <a class="button button--ghost" href="/login/">Anmelden</a>
                    @endif
                </div>
            </div>
        </header>

        <main class="site-main app-main">
                @yield('content')
            </main>

            <footer class="app-footer">
                <div class="app-footer__inner">
                    <span>Die Kaffeeliste</span>
                    <span>Klare Bereiche mit Navigation oben</span>
                </div>
            </footer>

            <div class="mobile-bottom-nav" style="--mobile-nav-columns: {{ $layoutMobileNavColumns }};">
                <nav class="mobile-bottom-nav__bar" aria-label="Mobile Navigation">
                    @foreach ($layoutMobilePrimaryNavItems as $item)
                        @php
                            $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                            $itemHref = $itemHref === '' ? '/' : $itemHref;
                            $isActive = $layoutPath === $itemHref;
                        @endphp
                        <a href="{{ $item['href'] ?? '/' }}" class="mobile-bottom-nav__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>
                            <span class="mobile-bottom-nav__label">{{ $item['label'] ?? 'Link' }}</span>
                        </a>
                    @endforeach

                    @if ($layoutMobileHasDrawer)
                        <button type="button" class="mobile-bottom-nav__more" data-mobile-drawer-open>
                            <span class="mobile-bottom-nav__label">Menü</span>
                            <span class="mobile-bottom-nav__meta">Bereiche</span>
                        </button>
                    @endif
                </nav>
            </div>

            @if ($layoutMobileHasDrawer)
                <div class="mobile-drawer" data-mobile-drawer>
                    <button type="button" class="mobile-drawer__scrim" aria-label="Menü schließen" data-mobile-drawer-close></button>
                    <aside class="mobile-drawer__panel" role="dialog" aria-label="Menü">
                        <div class="mobile-drawer__header">
                            <div>
                                <p class="mobile-drawer__title">Menü</p>
                                <p class="mobile-drawer__copy">
                                    @if (is_array($layoutAuth))
                                        {{ $layoutAuth['tenant_name'] ?? 'Tenant' }} · {{ $layoutCurrentLabel }}
                                    @else
                                        Zusätzliche Links und Zugangsmöglichkeiten
                                    @endif
                                </p>
                            </div>
                            <button type="button" class="button button--ghost mobile-drawer__close" data-mobile-drawer-close aria-label="Schließen">×</button>
                        </div>

                        <div class="mobile-drawer__sections">
                            @php
                                $layoutDrawerCoreItems = is_array($layoutAuth) ? $layoutHeaderNavItems : $layoutPrimaryNavItems;
                            @endphp
                            @if ($layoutDrawerCoreItems !== [])
                                <section class="mobile-drawer__section">
                                    <div class="mobile-drawer__label">Kernnavigation</div>
                                    <div class="mobile-drawer__links">
                                        @foreach ($layoutDrawerCoreItems as $item)
                                            @php
                                                $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                                                $itemHref = $itemHref === '' ? '/' : $itemHref;
                                                $isActive = $layoutPath === $itemHref;
                                            @endphp
                                            <a href="{{ $item['href'] ?? '/' }}" class="mobile-drawer__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>{{ $item['label'] ?? 'Link' }}</a>
                                        @endforeach
                                    </div>
                                </section>
                            @endif

                            @foreach ($layoutNavGroups as $group)
                                <section class="mobile-drawer__section">
                                    <div class="mobile-drawer__label">{{ $group['label'] ?? 'Mehr' }}</div>
                                    <div class="mobile-drawer__links">
                                        @foreach (($group['items'] ?? []) as $item)
                                            @php
                                                $itemHref = rtrim((string) ($item['href'] ?? '/'), '/');
                                                $itemHref = $itemHref === '' ? '/' : $itemHref;
                                                $isActive = $layoutPath === $itemHref;
                                            @endphp
                                            <a href="{{ $item['href'] ?? '/' }}" class="mobile-drawer__link {{ $isActive ? 'is-active' : '' }}" @if ($isActive) aria-current="page" @endif>{{ $item['label'] ?? 'Link' }}</a>
                                        @endforeach
                                    </div>
                                </section>
                            @endforeach

                            <section class="mobile-drawer__section">
                                <div class="mobile-drawer__label">Konto</div>
                                @if (is_array($layoutAuth))
                                    <div class="mobile-drawer__links">
                                        <a class="mobile-drawer__link {{ $layoutPath === '/profile' ? 'is-active' : '' }}" href="/profile/" @if ($layoutPath === '/profile') aria-current="page" @endif>Persönliche Einstellungen</a>
                                    </div>
                                @else
                                    <div class="mobile-drawer__links">
                                        <a class="mobile-drawer__link" href="/login/">Anmelden</a>
                                        <a class="mobile-drawer__link" href="/admin/login/">Verwaltung</a>
                                    </div>
                                @endif
                            </section>
                        </div>

                        <div class="mobile-drawer__footer">
                            @if (is_array($layoutAuth))
                                <form method="post" action="/logout/">
                                    <button type="submit" class="button button--ghost" style="width: 100%;">Abmelden</button>
                                </form>
                            @endif
                        </div>
                    </aside>
                </div>
            @endif
    </div>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const detailGroups = document.querySelectorAll('.top-nav__group');
            const drawer = document.querySelector('[data-mobile-drawer]');
            const drawerOpeners = document.querySelectorAll('[data-mobile-drawer-open]');
            const drawerClosers = document.querySelectorAll('[data-mobile-drawer-close]');

            function closeOthers(current) {
                detailGroups.forEach(function (other) {
                    if (other !== current) {
                        other.open = false;
                    }
                });
            }

            detailGroups.forEach(function (detail) {
                const summary = detail.querySelector('summary');
                if (summary) {
                    summary.addEventListener('click', function () {
                        if (!detail.open) {
                            closeOthers(detail);
                        }
                    });
                }

                detail.addEventListener('toggle', function () {
                    if (detail.open) {
                        closeOthers(detail);
                    }
                });
            });

            function closeDrawer() {
                if (drawer) {
                    drawer.classList.remove('is-open');
                    document.body.classList.remove('mobile-drawer-open');
                }
            }

            document.querySelectorAll('.top-nav__panel a, .mobile-drawer__link').forEach(function (link) {
                link.addEventListener('click', function () {
                    detailGroups.forEach(function (detail) {
                        detail.open = false;
                    });
                    closeDrawer();
                });
            });

            drawerOpeners.forEach(function (button) {
                button.addEventListener('click', function () {
                    detailGroups.forEach(function (detail) {
                        detail.open = false;
                    });
                    if (drawer) {
                        drawer.classList.add('is-open');
                        document.body.classList.add('mobile-drawer-open');
                    }
                });
            });

            drawerClosers.forEach(function (button) {
                button.addEventListener('click', function () {
                    closeDrawer();
                });
            });
        });
    </script>
    @endif
</body>
</html>
