.global-activity-bar {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 6000;
    display: flex;
    gap: 8px;
    align-items: center;
}

.global-activity-button,
.user-bar .global-activity-button {
    position: relative;
    display: grid;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 1px solid var(--ui-border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--ui-surface) 92%, transparent);
    color: var(--ui-text) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
    backdrop-filter: blur(10px);
}

.global-activity-button:hover { background: var(--ui-surface-2); transform: translateY(-1px); }
.global-activity-button svg { width: 22px; height: 22px; fill: currentColor; }
.global-activity-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    border: 2px solid var(--ui-bg);
    border-radius: 999px;
    background: var(--ui-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
}

.live-toast-stack {
    position: fixed;
    top: 72px;
    right: 16px;
    z-index: 100200;
    display: grid;
    width: min(380px, calc(100vw - 32px));
    gap: 10px;
    pointer-events: none;
}
.live-toast {
    display: grid;
    grid-template-columns: 38px minmax(0,1fr) 28px;
    gap: 10px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--ui-border);
    border-left: 4px solid var(--ui-info);
    border-radius: 14px;
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: var(--ui-shadow);
    opacity: 0;
    transform: translateX(24px);
    transition: .2s ease;
    pointer-events: auto;
}
.live-toast.is-visible { opacity: 1; transform: translateX(0); }
.live-toast.is-success { border-left-color: var(--ui-success); }
.live-toast.is-warning { border-left-color: var(--ui-warning); }
.live-toast.is-error { border-left-color: var(--ui-danger); }
.live-toast-icon { display:grid; width:34px; height:34px; place-items:center; border-radius:50%; background:var(--ui-surface-3); font-weight:900; }
.live-toast strong { display:block; margin-bottom:3px; }
.live-toast p { margin:0; color:var(--ui-muted); line-height:1.35; overflow-wrap:anywhere; }
.live-toast-close { min-height:28px; width:28px; margin:0; padding:0; background:transparent; color:var(--ui-muted)!important; }

.activity-popover {
    position: fixed;
    top: 66px;
    right: 14px;
    z-index: 7000;
    display: none;
    width: min(390px, calc(100vw - 28px));
    max-height: min(620px, calc(100vh - 86px));
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: 18px;
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: var(--ui-shadow);
}
.activity-popover.is-open { display:flex; flex-direction:column; }
.activity-popover-header { display:flex; align-items:center; justify-content:space-between; padding:16px; border-bottom:1px solid var(--ui-border); }
.activity-popover-header h3 { margin:0; text-align:left; }
.activity-popover-content { overflow:auto; padding:10px; }
.activity-item { padding:12px; border-radius:12px; cursor:pointer; }
.activity-item:hover { background:var(--ui-surface-2); }
.activity-item + .activity-item { border-top:1px solid var(--ui-border); }
.activity-item small { display:block; margin-top:4px; }

.chat-window {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 8000;
    display: none;
    width: min(420px, calc(100vw - 24px));
    height: min(650px, calc(100vh - 92px));
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: 20px;
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: 0 26px 70px rgba(0,0,0,.48);
}
.chat-window.is-open { display:grid; grid-template-rows:auto minmax(0,1fr) auto; }
.chat-header { display:flex; gap:10px; align-items:center; padding:14px 16px; border-bottom:1px solid var(--ui-border); }
.chat-header-title { min-width:0; flex:1; }
.chat-header-title strong,.chat-header-title small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-header button { min-height:34px; margin:0; padding:6px 10px; }
.chat-body { min-height:0; display:grid; grid-template-columns:140px minmax(0,1fr); }
.chat-sidebar { overflow:auto; border-right:1px solid var(--ui-border); background:var(--ui-surface-3); }
.chat-list-button { position:relative; width:100%; min-height:auto; margin:0; padding:12px; border:0; border-radius:0; justify-content:flex-start; background:transparent; color:var(--ui-text)!important; text-align:left; }
.chat-list-button:hover,.chat-list-button.is-active { background:var(--ui-surface-2); transform:none; }
.chat-list-button span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-messages { display:flex; flex-direction:column; min-width:0; min-height:0; }
.chat-message-list { flex:1; overflow:auto; padding:14px; display:flex; flex-direction:column; gap:8px; }
.chat-bubble { max-width:82%; padding:9px 11px; border-radius:15px 15px 15px 4px; background:var(--ui-surface-3); color:var(--ui-text); overflow-wrap:anywhere; }
.chat-bubble.is-own { align-self:flex-end; border-radius:15px 15px 4px 15px; background:var(--ui-accent); color:#fff; }
.chat-bubble small { display:block; margin-top:4px; color:inherit; opacity:.72; }
.chat-empty { margin:auto; padding:20px; color:var(--ui-muted); text-align:center; }
.chat-composer { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:7px; padding:10px; border-top:1px solid var(--ui-border); }
.chat-composer textarea { width:100%; min-height:42px; max-height:110px; resize:none; }
.chat-composer button { min-height:42px; margin:0; padding:9px 11px; }
.emoji-row { display:none; position:absolute; right:64px; bottom:70px; max-width:260px; padding:8px; border:1px solid var(--ui-border); border-radius:12px; background:var(--ui-surface); box-shadow:var(--ui-shadow); }
.emoji-row.is-open { display:flex; flex-wrap:wrap; gap:4px; }
.emoji-row button { min-height:32px; margin:0; padding:4px; background:transparent; }
.chat-new-user { width:100%; margin:0 0 8px; }

@media (max-width: 640px) {
    .global-activity-bar { top:8px; right:8px; }
    .chat-window { right:6px; bottom:6px; width:calc(100vw - 12px); height:calc(100vh - 72px); }
    .chat-body { grid-template-columns:112px minmax(0,1fr); }
}

/* V16: globales Benutzermenü */
body.mat112-global-shell:not(.dashboard-page){padding-top:max(68px,env(safe-area-inset-top))!important}
.global-user-button{display:inline-flex;width:auto;max-width:min(260px,50vw);height:44px;min-height:44px;margin:0;padding:0 13px;align-items:center;justify-content:center;gap:8px;border:1px solid var(--ui-border);border-radius:14px;background:color-mix(in srgb,var(--ui-surface) 94%,transparent);color:var(--ui-text)!important;box-shadow:0 10px 30px rgba(0,0,0,.24);font-weight:750;cursor:pointer;backdrop-filter:blur(10px)}
.global-user-button:hover,.global-user-button[aria-expanded="true"]{border-color:var(--ui-accent);background:var(--ui-surface-2);transform:translateY(-1px)}
.global-user-button svg{display:block;width:22px;height:22px;flex:0 0 22px;fill:currentColor}.global-user-button span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.global-user-popover{position:fixed;top:66px;right:14px;z-index:7100;display:none;width:min(260px,calc(100vw - 28px));overflow:visible;border:1px solid var(--ui-border);border-radius:16px;background:var(--ui-surface);color:var(--ui-text);box-shadow:var(--ui-shadow)}
.global-user-popover.is-open{display:block}.global-user-heading{padding:14px 16px;border-bottom:1px solid var(--ui-border)}.global-user-heading strong,.global-user-heading small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.global-user-heading small{margin-top:3px;color:var(--ui-muted)}
.global-user-popover a{display:block;padding:12px 16px;border-bottom:1px solid var(--ui-border);background:transparent;color:var(--ui-text)!important;text-decoration:none}.global-user-popover a:hover{background:var(--ui-surface-2)}.global-user-popover a:last-child{border-bottom:0}.global-user-popover .global-user-logout{color:var(--ui-danger)!important}
html[data-theme="light"] .global-user-button,html[data-theme="light"] .global-user-popover{box-shadow:0 14px 34px rgba(35,49,76,.16)}
@media(max-width:700px){body.mat112-global-shell:not(.dashboard-page){padding-top:max(60px,env(safe-area-inset-top))!important}.global-activity-bar{top:8px;right:8px}.global-user-button{width:44px;padding:0}.global-user-button span{display:none}.global-user-popover{top:60px;right:8px}}
.chat-mail-link{display:block;margin-top:8px;padding:7px 9px;border:1px solid currentColor;border-radius:9px;color:inherit!important;text-align:center;text-decoration:none;font-weight:800;opacity:.9}.chat-mail-link:hover{opacity:1;background:rgba(255,255,255,.12)}

/* V18: robustes Benutzersymbol ohne externe Schrift oder seitenabhängiges SVG. */
.global-user-button .global-user-avatar{
    position:relative!important;
    display:block!important;
    width:22px!important;
    height:22px!important;
    min-width:22px!important;
    flex:0 0 22px!important;
    overflow:hidden!important;
    border:0!important;
    border-radius:50%!important;
    background:transparent!important;
    box-shadow:none!important;
    transform:none!important;
}
.global-user-button .global-user-avatar::before{
    content:"";
    position:absolute;
    top:2px;
    left:7px;
    width:8px;
    height:8px;
    border-radius:50%;
    background:currentColor;
}
.global-user-button .global-user-avatar::after{
    content:"";
    position:absolute;
    left:3px;
    bottom:1px;
    width:16px;
    height:9px;
    border-radius:9px 9px 4px 4px;
    background:currentColor;
}


/* =====================================================
   V20 GLOBAL APP SHELL – seitenunabhängig
   Die Bedienelemente dürfen niemals durch Modul-CSS (z. B. Rechnungen,
   Kalender, Technik) umgestaltet werden.
===================================================== */
body.mat112-global-shell .global-activity-bar {
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    margin: 0 !important;
    padding: 0 !important;
}
body.mat112-global-shell .global-activity-button,
body.mat112-global-shell .global-user-button {
    box-sizing: border-box !important;
    flex: 0 0 auto !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    border: 1px solid var(--ui-border) !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--ui-surface) 94%, transparent) !important;
    color: var(--ui-text) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,.24) !important;
    font: inherit !important;
    font-weight: 750 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    transform: none;
}
body.mat112-global-shell .global-activity-button {
    display: grid !important;
    width: 44px !important;
    min-width: 44px !important;
    padding: 0 !important;
    place-items: center !important;
}
body.mat112-global-shell .global-user-button {
    display: inline-flex !important;
    width: auto !important;
    min-width: 44px !important;
    max-width: min(260px, 50vw) !important;
    padding: 0 13px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}
body.mat112-global-shell .global-activity-button:hover,
body.mat112-global-shell .global-activity-button:focus-visible,
body.mat112-global-shell .global-user-button:hover,
body.mat112-global-shell .global-user-button:focus-visible,
body.mat112-global-shell .global-user-button[aria-expanded="true"] {
    border-color: var(--ui-accent) !important;
    background: var(--ui-surface-2) !important;
    color: var(--ui-text) !important;
    transform: translateY(-1px) !important;
}
body.mat112-global-shell .global-activity-button svg {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    margin: 0 !important;
    padding: 0 !important;
    fill: currentColor !important;
}
body.mat112-global-shell .global-activity-badge {
    display: grid !important;
    width: auto !important;
    min-width: 21px !important;
    height: 21px !important;
    min-height: 21px !important;
    margin: 0 !important;
    padding: 0 5px !important;
    place-items: center !important;
    border: 2px solid var(--ui-bg) !important;
    border-radius: 999px !important;
    background: var(--ui-accent) !important;
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    line-height: 17px !important;
}

/* Globale Benachrichtigungen: identisch auf jeder Seite. */
body.mat112-global-shell .activity-popover,
body.mat112-global-shell .global-user-popover {
    box-sizing: border-box !important;
    border: 1px solid var(--ui-border) !important;
    background: var(--ui-surface) !important;
    color: var(--ui-text) !important;
    box-shadow: var(--ui-shadow) !important;
}
body.mat112-global-shell .activity-popover * ,
body.mat112-global-shell .global-user-popover * {
    box-sizing: border-box;
}
body.mat112-global-shell .activity-popover-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin: 0 !important;
    padding: 14px 16px !important;
    border-bottom: 1px solid var(--ui-border) !important;
    background: transparent !important;
}
body.mat112-global-shell .activity-popover-header h3 {
    margin: 0 !important;
    padding: 0 !important;
    color: var(--ui-text) !important;
    font-size: 1.05rem !important;
    line-height: 1.2 !important;
    text-align: left !important;
}
body.mat112-global-shell .activity-popover-close {
    display: inline-grid !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    place-items: center !important;
    border: 1px solid var(--ui-border) !important;
    border-radius: 10px !important;
    background: var(--ui-surface-2) !important;
    color: var(--ui-text) !important;
    font-size: 20px !important;
    line-height: 1 !important;
}
body.mat112-global-shell .activity-popover-content {
    display: block !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    overflow: auto !important;
}
body.mat112-global-shell .activity-item {
    display: block !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 12px 13px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--ui-border) !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--ui-text) !important;
    text-align: left !important;
    text-decoration: none !important;
    transform: none !important;
}
body.mat112-global-shell .activity-item:last-child { border-bottom: 0 !important; }
body.mat112-global-shell .activity-item:hover { background: var(--ui-surface-2) !important; }
body.mat112-global-shell .activity-item strong {
    display: block !important;
    color: var(--ui-text) !important;
    font-size: .94rem !important;
    line-height: 1.35 !important;
    overflow-wrap: anywhere !important;
}
body.mat112-global-shell .activity-item small {
    display: block !important;
    margin-top: 5px !important;
    color: var(--ui-muted) !important;
    font-size: .78rem !important;
}

/* Chat-Controls sind ebenfalls immun gegen Seiten-CSS. */
body.mat112-global-shell .chat-window button {
    width: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    font: inherit !important;
}
body.mat112-global-shell .chat-window .chat-list-button {
    width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: var(--ui-text) !important;
    transform: none !important;
}
body.mat112-global-shell .chat-window .chat-list-button:hover,
body.mat112-global-shell .chat-window .chat-list-button.is-active {
    background: var(--ui-surface-2) !important;
}

@media (max-width: 700px) {
    body.mat112-global-shell .global-activity-bar {
        top: max(8px, env(safe-area-inset-top)) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        gap: 6px !important;
        max-width: calc(100vw - 16px) !important;
    }
    body.mat112-global-shell .global-activity-button,
    body.mat112-global-shell .global-user-button {
        width: 42px !important;
        min-width: 42px !important;
        height: 42px !important;
        min-height: 42px !important;
        padding: 0 !important;
        border-radius: 12px !important;
    }
    body.mat112-global-shell .global-user-button span { display: none !important; }
    body.mat112-global-shell .activity-popover {
        top: calc(max(8px, env(safe-area-inset-top)) + 50px) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        left: max(8px, env(safe-area-inset-left)) !important;
        width: auto !important;
        max-height: calc(100dvh - 78px) !important;
    }
    body.mat112-global-shell .global-user-popover {
        top: calc(max(8px, env(safe-area-inset-top)) + 50px) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        width: min(280px, calc(100vw - 16px)) !important;
    }
}


/* V21 – eine einzige globale Kopfzeile und einheitliche Benachrichtigungen */
.mat112-legacy-user-bar{display:none!important}
body.mat112-global-shell.dashboard-page{padding-top:max(68px,env(safe-area-inset-top))!important}
body.mat112-global-shell .global-activity-bar{top:14px!important;right:14px!important;left:auto!important;position:fixed!important;z-index:6000!important}
body.mat112-global-shell .activity-popover{top:66px!important;right:14px!important;left:auto!important}
.activity-popover-actions{display:flex;align-items:center;gap:7px}.activity-popover-actions button{width:auto!important;min-height:34px!important;margin:0!important;padding:6px 9px!important;border:1px solid var(--ui-border)!important;border-radius:9px!important;background:var(--ui-surface-2)!important;color:var(--ui-text)!important;font-size:.82rem!important}.activity-popover-close{width:34px!important;padding:0!important;font-size:1.25rem!important}
.activity-item{display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;gap:8px!important;align-items:center!important;margin:0!important;padding:0!important;border-radius:12px!important;overflow:hidden!important}.activity-item+.activity-item{border-top:1px solid var(--ui-border)!important}.activity-item.is-unread{background:color-mix(in srgb,var(--ui-accent) 10%,var(--ui-surface))!important}.activity-item-main{display:block!important;min-width:0!important;padding:12px!important;background:transparent!important;color:var(--ui-text)!important;text-decoration:none!important}.activity-item-main:hover{background:var(--ui-surface-2)!important}.activity-item-main strong,.activity-item-main small{display:block!important}.activity-item-main small{margin-top:4px!important;color:var(--ui-muted)!important}.activity-item-read{width:auto!important;min-height:32px!important;margin:0 10px 0 0!important;padding:5px 8px!important;border:1px solid var(--ui-border)!important;border-radius:8px!important;background:var(--ui-surface-2)!important;color:var(--ui-text)!important;font-size:.78rem!important}
@media(max-width:700px){body.mat112-global-shell.dashboard-page{padding-top:max(60px,env(safe-area-inset-top))!important}body.mat112-global-shell .global-activity-bar{top:8px!important;right:8px!important;gap:5px!important}body.mat112-global-shell .activity-popover{top:60px!important;right:8px!important;width:calc(100vw - 16px)!important}.activity-mark-all{font-size:.76rem!important}}

/* =====================================================
   V28 – Chat-Lesebestätigung
===================================================== */
.chat-bubble-meta{display:flex!important;align-items:center;justify-content:flex-start;gap:6px;margin-top:5px;position:relative}
.chat-bubble.is-own .chat-bubble-meta{justify-content:flex-end}
.chat-read-receipt{position:relative!important;display:inline-flex!important;align-items:center!important;justify-content:center!important;width:auto!important;min-width:24px!important;min-height:22px!important;height:22px!important;margin:0!important;padding:0 3px!important;border:0!important;border-radius:5px!important;background:transparent!important;color:inherit!important;font:inherit!important;font-size:.82rem!important;font-weight:800!important;line-height:1!important;letter-spacing:-.12em!important;cursor:pointer!important;opacity:.78}
.chat-read-receipt.is-read{opacity:1}
.chat-read-receipt::after{content:attr(data-receipt-label);position:absolute;z-index:15;right:0;bottom:calc(100% + 7px);width:max-content;max-width:min(260px,70vw);padding:7px 9px;border:1px solid var(--ui-border,#444);border-radius:8px;background:var(--ui-surface,#191919);color:var(--ui-text,#fff);font-size:.76rem;font-weight:600;letter-spacing:0;line-height:1.25;white-space:normal;box-shadow:0 8px 24px rgba(0,0,0,.35);opacity:0;visibility:hidden;transform:translateY(3px);transition:.12s ease;pointer-events:none}
.chat-read-receipt:hover::after,.chat-read-receipt:focus-visible::after,.chat-read-receipt.is-open::after{opacity:1;visibility:visible;transform:none}
.chat-bubble-text{white-space:pre-wrap;overflow-wrap:anywhere}
@media(max-width:700px){.chat-read-receipt{min-width:30px!important;min-height:28px!important;height:28px!important}.chat-read-receipt::after{right:-4px;max-width:min(260px,82vw)}}
/* V33: Der kleine Präsenzpunkt bleibt auch in der kompakten Mobilansicht sichtbar. */
@media(max-width:700px){body.mat112-global-shell .global-user-button .presence-dot{display:inline-block!important;min-width:9px!important;width:9px!important;height:9px!important;overflow:visible!important}}
