:root {
    --ec-shell-sidebar-width: 260px;
    --ec-shell-sidebar-collapsed-width: 72px;
    --ec-shell-gap: 14px;
    --ec-shell-topbar-height: 56px;
    --ec-shell-blue: #185FA5;
    --ec-shell-blue-dark: #0C447C;
    --ec-shell-blue-light: #EAF1F9;
    --ec-shell-text: #1F2937;
    --ec-shell-text-muted: #667085;
}

body.ec-shell,
body.ec-public-shell {
    min-height: 100vh;
    background:
        radial-gradient(1100px 700px at -5% 0%, rgba(24, 95, 165, 0.16) 0%, transparent 60%),
        radial-gradient(800px 600px at 15% 100%, rgba(12, 68, 124, 0.14) 0%, transparent 60%),
        radial-gradient(900px 500px at 105% 15%, rgba(190, 210, 235, 0.55) 0%, transparent 60%),
        #F3F6FA;
    background-attachment: fixed;
}

.ec-layout {
    min-height: 100vh;
    background: transparent;
}

.ec-main.content-wrapper {
    min-height: calc(100vh - var(--ec-shell-topbar-height) - var(--ec-shell-gap));
    margin-top: 0 !important;
    margin-left: calc(var(--ec-shell-sidebar-width) + (var(--ec-shell-gap) * 2)) !important;
    padding: calc(var(--ec-shell-topbar-height) + 1.5rem) 2rem 2rem;
    background: transparent !important;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ec-public-shell .ec-main.content-wrapper {
    margin-left: 0 !important;
}

/* Globale Kopfleiste */
.ec-topbar.main-header {
    position: fixed;
    top: var(--ec-shell-gap);
    right: var(--ec-shell-gap);
    left: calc(var(--ec-shell-sidebar-width) + (var(--ec-shell-gap) * 2));
    z-index: 1030;
    height: var(--ec-shell-topbar-height);
    min-height: var(--ec-shell-topbar-height);
    margin-left: 0 !important;
    padding: 0 1rem;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.48);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        inset 0 -1px 0 rgba(255, 255, 255, 0.35),
        0 10px 30px -14px rgba(20, 50, 90, 0.25);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ec-public-shell .ec-topbar.main-header {
    left: var(--ec-shell-gap);
}

.ec-topbar-leading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ec-topbar.main-header.ec-topbar-environment {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    color: #FFF;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 12px 30px -14px rgba(68, 10, 10, 0.55);
}

.ec-topbar.main-header.ec-topbar-environment-test {
    background: linear-gradient(135deg, #9F1D1D 0%, #C62828 55%, #B42318 100%);
}

.ec-topbar.main-header.ec-topbar-environment-live {
    background: linear-gradient(135deg, #146C43 0%, #198754 55%, #157347 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 12px 30px -14px rgba(8, 72, 44, 0.5);
}

.ec-topbar-environment .ec-topbar-leading {
    min-width: 0;
    justify-self: start;
}

.ec-environment-indicator {
    min-width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #FFF;
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

.ec-environment-heading {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.045em;
}

.ec-environment-subline {
    margin-top: 0.2rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
    font-weight: 500;
}

.ec-topbar-environment .ec-topbar-actions {
    max-width: 100%;
    margin-left: 0;
    justify-self: end;
}

.ec-topbar-environment .ec-menu-btn,
.ec-topbar-environment .ec-topbar-action {
    color: #FFF;
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.ec-topbar-environment .ec-topbar-home,
.ec-topbar-environment .ec-topbar-action i {
    color: #FFF;
}

.ec-topbar-environment .ec-menu-btn:hover,
.ec-topbar-environment .ec-topbar-action:hover {
    color: #FFF;
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.2);
}

.ec-topbar-environment .ec-topbar-home:hover {
    color: #FFF;
}

.ec-topbar-environment .ec-menu-btn:focus-visible,
.ec-topbar-environment .ec-topbar-action:focus-visible,
.ec-topbar-environment .ec-topbar-home:focus-visible {
    outline-color: #FFF;
}

.ec-menu-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 12px;
    color: var(--ec-shell-blue-dark);
    background: rgba(255, 255, 255, 0.4);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 2px 6px -2px rgba(20, 50, 90, 0.2);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.ec-menu-btn:hover {
    color: var(--ec-shell-blue);
    background: rgba(255, 255, 255, 0.75);
}

.ec-menu-btn:focus-visible,
.ec-topbar-action:focus-visible,
.ec-topbar-home:focus-visible {
    outline: 2px solid var(--ec-shell-blue);
    outline-offset: 2px;
}

.ec-menu-btn i {
    font-size: 20px;
}

.ec-topbar-home {
    min-width: 0;
    color: var(--ec-shell-text-muted);
    text-decoration: none;
    white-space: nowrap;
}

.ec-topbar-home:hover {
    color: var(--ec-shell-blue-dark);
    text-decoration: none;
}

.ec-topbar-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.ec-topbar-actions {
    min-width: 0;
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    overflow: hidden;
}

.ec-topbar-action {
    min-width: 36px;
    height: 36px;
    padding: 0 0.65rem;
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: 11px;
    color: var(--ec-shell-text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.ec-topbar-action:hover {
    color: var(--ec-shell-blue-dark);
    text-decoration: none;
    border-color: rgba(255, 255, 255, 0.75);
    background: rgba(255, 255, 255, 0.55);
}

.ec-topbar-action i {
    flex: 0 0 auto;
    font-size: 15px;
    color: var(--ec-shell-blue);
}

.ec-topbar-action-label {
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
}

.ec-topbar-icon-action {
    flex: 0 0 36px;
    padding: 0;
}

.ec-topbar .navbar-search-block {
    height: 100%;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.94);
}

/* Schwebende Seitennavigation */
.ec-sidebar.main-sidebar {
    position: fixed !important;
    top: var(--ec-shell-gap) !important;
    right: auto;
    bottom: var(--ec-shell-gap);
    left: var(--ec-shell-gap) !important;
    z-index: 1040;
    width: var(--ec-shell-sidebar-width) !important;
    min-height: 0 !important;
    height: auto !important;
    margin-left: 0 !important;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 26px;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.3) 55%, rgba(255, 255, 255, 0.43) 100%) !important;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.95),
        inset -1px -1px 0 rgba(255, 255, 255, 0.35),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15),
        0 24px 60px -24px rgba(20, 50, 90, 0.35),
        0 4px 14px -4px rgba(20, 50, 90, 0.1) !important;
    backdrop-filter: blur(40px) saturate(190%);
    -webkit-backdrop-filter: blur(40px) saturate(190%);
    transition:
        width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ec-sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    width: auto !important;
    height: auto !important;
    margin-left: 0 !important;
    border-radius: inherit;
    background:
        radial-gradient(120% 60% at 0 0, rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0) 55%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 30%);
    pointer-events: none;
}

.ec-sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 6%),
        linear-gradient(270deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0) 6%);
    mix-blend-mode: screen;
    pointer-events: none;
}

.ec-sidebar > * {
    position: relative;
    z-index: 1;
}

.ec-brand {
    min-height: 54px;
    padding: 4px 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ec-shell-blue-dark);
    text-decoration: none;
    white-space: nowrap;
}

.ec-brand:hover {
    color: var(--ec-shell-blue-dark);
    text-decoration: none;
}

.ec-brand-logo {
    width: 38px;
    height: 42px;
    flex: 0 0 38px;
    object-fit: contain;
}

.ec-brand-name {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.ec-brand-name span {
    color: var(--ec-shell-blue);
}

.ec-sidebar .ec-sidebar-content.sidebar {
    min-height: 0;
    height: auto;
    padding: 0;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    overflow: hidden;
}

.ec-user {
    min-width: 0;
    padding: 10px 6px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 1px 0 rgba(12, 68, 124, 0.06);
    white-space: nowrap;
}

.ec-avatar-link {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(234, 241, 249, 0.7));
    box-shadow: inset 0 1px 0 #FFF, 0 3px 8px -2px rgba(20, 50, 90, 0.2);
    overflow: hidden;
}

.ec-avatar {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.ec-user-details {
    min-width: 0;
    line-height: 1.25;
}

.ec-user-name {
    max-width: 172px;
    display: block;
    overflow: hidden;
    color: var(--ec-shell-text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
}

.ec-user-name:hover {
    color: var(--ec-shell-blue-dark);
    text-decoration: none;
}

.ec-nav {
    min-height: 0;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-color: rgba(24, 95, 165, 0.28) transparent;
    scrollbar-width: thin;
}

.ec-nav::-webkit-scrollbar {
    width: 6px;
}

.ec-nav::-webkit-scrollbar-track {
    background: transparent;
}

.ec-nav::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(24, 95, 165, 0.28);
}

.ec-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(24, 95, 165, 0.42);
}

.ec-nav > .nav {
    min-height: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
}

.ec-nav > .nav > .nav-item {
    flex: 0 0 auto;
}

.ec-nav-footer {
    min-height: 0;
    margin-top: 8px;
    padding-top: 10px;
    flex: 0 0 auto;
    overflow: visible;
    border-top: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 -1px 0 rgba(12, 68, 124, 0.05);
}

.ec-nav-footer[hidden] {
    display: none !important;
}

.ec-nav-footer > .nav {
    min-height: 0;
    flex: 0 0 auto;
}

.ec-nav .nav-item {
    width: 100%;
    list-style: none;
}

.ec-nav .nav-link {
    min-height: 42px;
    margin: 0;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--ec-shell-text) !important;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-nav .nav-link:hover {
    border-color: rgba(255, 255, 255, 0.65);
    color: var(--ec-shell-blue-dark) !important;
    background: rgba(255, 255, 255, 0.42);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ec-nav .nav-link.active,
.ec-nav .nav-item.current > .nav-link,
.ec-nav .nav-item.current_ancestor > .nav-link {
    border-color: rgba(255, 255, 255, 0.95);
    color: var(--ec-shell-blue-dark) !important;
    font-weight: 700;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.88) 0%, rgba(255, 255, 255, 0.58) 100%) !important;
    box-shadow:
        inset 0 1px 0 #FFF,
        inset 0 -1px 0 rgba(255, 255, 255, 0.4),
        0 8px 20px -10px rgba(20, 50, 90, 0.45),
        0 1px 3px rgba(20, 50, 90, 0.06);
}

.ec-nav .nav-link:focus-visible {
    outline: 2px solid var(--ec-shell-blue);
    outline-offset: 2px;
}

.ec-nav .nav-icon {
    width: 22px !important;
    margin: 0 !important;
    flex: 0 0 22px;
    color: var(--ec-shell-blue);
    font-size: 18px !important;
    text-align: center;
}

.ec-nav .nav-link p {
    min-width: 0;
    width: auto;
    margin: 0;
    display: flex;
    flex: 1;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ec-nav .nav-link .right {
    position: static !important;
    top: auto !important;
    right: auto !important;
    margin-left: auto;
    color: var(--ec-shell-text-muted);
    transition: transform 0.2s ease;
}

.ec-nav .nav-item.menu-open > .nav-link .right,
.ec-nav .nav-item.current_ancestor:not(.menu-closed) > .nav-link .right {
    transform: rotate(-90deg);
}

.ec-nav .nav-treeview {
    margin: 4px 0 2px 14px;
    padding: 2px 0 2px 8px;
    display: none;
    border-left: 1px solid rgba(24, 95, 165, 0.16);
}

.ec-nav .nav-item.menu-open > .nav-treeview,
.ec-nav .nav-item.current_ancestor:not(.menu-closed) > .nav-treeview {
    display: block;
}

.ec-nav .nav-treeview .nav-link {
    min-height: 36px;
    padding-top: 7px;
    padding-bottom: 7px;
    font-size: 13px;
}

#ecNav > .nav > .ec-nav-footer-start {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.7);
}

.ec-nav .nav-link[href$="/logout"] .nav-icon {
    color: var(--ec-shell-text-muted);
}

/* Desktop: eingeklappte Navigation */
body.ec-sidebar-collapsed .ec-sidebar {
    width: var(--ec-shell-sidebar-collapsed-width) !important;
}

body.ec-sidebar-collapsed .ec-main.content-wrapper {
    margin-left: calc(var(--ec-shell-sidebar-collapsed-width) + (var(--ec-shell-gap) * 2)) !important;
}

body.ec-sidebar-collapsed .ec-topbar.main-header {
    left: calc(var(--ec-shell-sidebar-collapsed-width) + (var(--ec-shell-gap) * 2));
}

body.ec-sidebar-collapsed .ec-brand {
    padding-right: 0;
    padding-left: 0;
    justify-content: center;
}

body.ec-sidebar-collapsed .ec-brand-name,
body.ec-sidebar-collapsed .ec-user-details,
body.ec-sidebar-collapsed .ec-nav .nav-link p,
body.ec-sidebar-collapsed .ec-nav .nav-treeview {
    display: none !important;
}

body.ec-sidebar-collapsed .ec-user {
    padding-right: 0;
    padding-left: 0;
    justify-content: center;
}

body.ec-sidebar-collapsed .ec-nav .nav-link {
    padding-right: 0;
    padding-left: 0;
    justify-content: center;
}

body.ec-sidebar-collapsed .ec-nav .nav-icon {
    margin: 0 !important;
}

body.ec-sidebar-collapsed .main-footer {
    margin-left: calc(var(--ec-shell-sidebar-collapsed-width) + (var(--ec-shell-gap) * 2)) !important;
}

.ec-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(12, 68, 124, 0.18);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.ec-backdrop[hidden] {
    display: none !important;
}

body.ec-shell .main-footer,
body.ec-public-shell .main-footer {
    margin-left: calc(var(--ec-shell-sidebar-width) + (var(--ec-shell-gap) * 2)) !important;
    padding: 1rem 2rem 1.5rem;
    border-top: 0;
    color: var(--ec-shell-text-muted);
    background: transparent;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.ec-public-shell .main-footer {
    margin-left: 0 !important;
}

@media (max-width: 1550px) {
    .ec-topbar-action-label {
        display: none;
    }

    .ec-topbar-action {
        flex: 0 0 36px;
        padding: 0;
    }
}

@media (max-width: 1199.98px) {
    .ec-topbar.main-header.ec-topbar-environment {
        display: flex;
    }

    .ec-topbar-environment .ec-topbar-leading,
    .ec-topbar-environment .ec-topbar-actions {
        flex: 0 1 auto;
    }

    .ec-environment-indicator {
        min-width: 0;
        flex: 1 1 auto;
    }

    .ec-environment-subline {
        display: none;
    }
}

@media (max-width: 900px) {
    .ec-main.content-wrapper,
    body.ec-sidebar-collapsed .ec-main.content-wrapper {
        margin-left: 0 !important;
        padding: calc(var(--ec-shell-topbar-height) + 1.5rem) 1rem 1.5rem;
    }

    .ec-topbar.main-header,
    body.ec-sidebar-collapsed .ec-topbar.main-header {
        right: var(--ec-shell-gap);
        left: var(--ec-shell-gap);
    }

    .ec-sidebar.main-sidebar,
    body.ec-sidebar-collapsed .ec-sidebar.main-sidebar {
        width: min(var(--ec-shell-sidebar-width), calc(100vw - (var(--ec-shell-gap) * 2))) !important;
        transform: translateX(calc(-100% - (var(--ec-shell-gap) * 2)));
    }

    body.ec-sidebar-collapsed .ec-brand-name,
    body.ec-sidebar-collapsed .ec-user-details,
    body.ec-sidebar-collapsed .ec-nav .nav-link p {
        display: flex !important;
    }

    body.ec-sidebar-collapsed .ec-user-details {
        display: block !important;
    }

    body.ec-sidebar-collapsed .ec-brand,
    body.ec-sidebar-collapsed .ec-user,
    body.ec-sidebar-collapsed .ec-nav .nav-link {
        justify-content: flex-start;
    }

    body.ec-sidebar-collapsed .ec-brand {
        padding-right: 8px;
        padding-left: 8px;
    }

    body.ec-sidebar-collapsed .ec-user {
        padding-right: 6px;
        padding-left: 6px;
    }

    body.ec-sidebar-collapsed .ec-nav .nav-link {
        padding-right: 11px;
        padding-left: 11px;
    }

    body.ec-sidebar-open {
        overflow: hidden;
    }

    body.ec-sidebar-open .ec-sidebar.main-sidebar {
        transform: translateX(0);
    }

    body.ec-shell .main-footer,
    body.ec-public-shell .main-footer,
    body.ec-sidebar-collapsed .main-footer {
        margin-left: 0 !important;
        padding-right: 1rem;
        padding-left: 1rem;
    }
}

@media (max-width: 575.98px) {
    .ec-topbar.main-header {
        gap: 0.5rem;
        padding-right: 0.65rem;
        padding-left: 0.65rem;
    }

    .ec-topbar-title {
        max-width: 132px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .ec-topbar-actions .ec-topbar-action:not(.ec-topbar-icon-action):not(:first-child) {
        display: none;
    }

    .ec-topbar-environment .ec-topbar-title,
    .ec-topbar-environment .ec-topbar-actions .ec-topbar-action:not(.ec-topbar-icon-action) {
        display: none;
    }

    .ec-public-shell .ec-topbar-environment .ec-topbar-leading {
        display: none;
    }

    .ec-environment-heading {
        font-size: 0.72rem;
        letter-spacing: 0.025em;
    }

    body.ec-public-shell .ec-topbar-actions {
        margin-left: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ec-sidebar,
    .ec-main,
    .ec-topbar,
    .main-footer {
        transition: none !important;
    }
}

@media print {
    .ec-topbar,
    .ec-sidebar,
    .ec-backdrop {
        display: none !important;
    }

    .ec-main.content-wrapper,
    body.ec-shell .main-footer,
    body.ec-public-shell .main-footer {
        margin: 0 !important;
        padding: 0 !important;
    }
}
