html:has(.app-shell),
body:has(.app-shell) {
    height: 100%;
}

body:has(.app-shell) {
    overflow: hidden;
}

.app-shell {
    height: 100%;
    max-height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
}

.exloop-local-env-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
    padding: 8px 28px;
    font-size: 0.8125rem;
    line-height: 1.35;
    border-bottom: 1px solid transparent;
}

.exloop-local-env-banner strong {
    font-weight: 700;
}

.exloop-local-env-banner-hint {
    opacity: 0.92;
}

.exloop-local-env-banner--feature-preview {
    background: #e8f3ec;
    color: #1f4d32;
    border-bottom-color: #b7d7c2;
}

.exloop-local-env-banner--canonical-main {
    background: #eef2f7;
    color: #243447;
    border-bottom-color: #c5d0de;
}

.exloop-local-env-banner--other-local {
    background: #f7f1e8;
    color: #5c4520;
    border-bottom-color: #e0d0b4;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    min-height: 0;
    border-bottom: 1px solid #e6e8ec;
    background: #ffffff;
    position: relative;
    z-index: 40;
    flex-shrink: 0;
}

.app-header-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    line-height: 1.25;
    flex-shrink: 0;
}

.app-header-brand-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.app-header-logo {
    display: block;
    height: 50px;
    width: auto;
    max-width: 210px;
    object-fit: contain;
    flex-shrink: 0;
}

.app-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.25;
}

.app-header .dev-label {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.35;
    padding: 2px 8px;
    letter-spacing: 0.02em;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    min-width: 0;
}

.app-header-v-divider {
    width: 1px;
    height: 30px;
    background: #e6e8ec;
    flex-shrink: 0;
}

/* Business unit switcher */
.app-header-bu-wrap {
    position: relative;
    min-width: 0;
}

.app-header-bu-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px 0 10px;
    background: #eef3ff;
    border: 1px solid #dce7ff;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
    max-width: 260px;
}

.app-header-bu-switcher:hover:not(:disabled) {
    background: #dce7ff;
}

.app-header-bu-switcher:focus-visible {
    outline: 2px solid #3b6fee;
    outline-offset: 2px;
}

.app-header-bu-switcher.is-open {
    background: #dce7ff;
    border-color: #3b6fee;
}

.app-header-bu-switcher.is-static,
.app-header-bu-switcher:disabled.is-static {
    cursor: default;
    opacity: 1;
}

.app-header-bu-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: #ffffff;
    color: #3b6fee;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-header-bu-text {
    text-align: left;
    line-height: 1.2;
    min-width: 0;
}

.app-header-bu-label {
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #2e5ce0;
}

.app-header-bu-value {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #14161a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 168px;
}

.app-header-bu-chevron {
    color: #2e5ce0;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.app-header-bu-switcher.is-open .app-header-bu-chevron {
    transform: rotate(180deg);
}

.app-header-bu-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    width: 296px;
    max-width: min(296px, calc(100vw - 24px));
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(20, 22, 26, 0.12), 0 2px 6px rgba(20, 22, 26, 0.06);
    padding: 8px;
    z-index: 50;
}

.app-header-bu-menu-header {
    padding: 8px 10px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9aa1ac;
}

.app-header-bu-menu-list {
    max-height: 280px;
    overflow-y: auto;
}

.app-header-bu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: #14161a;
}

.app-header-bu-item:hover:not(:disabled) {
    background: #f5f6f8;
}

.app-header-bu-item:disabled {
    cursor: default;
}

.app-header-bu-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #eef3ff;
    color: #2e5ce0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-header-bu-item.is-active .app-header-bu-item-icon {
    background: #3b6fee;
    color: #ffffff;
}

.app-header-bu-item-body {
    flex: 1;
    min-width: 0;
}

.app-header-bu-item-name {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: #14161a;
}

.app-header-bu-item-meta {
    display: block;
    font-size: 11.5px;
    color: #6b7280;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-bu-item-check {
    color: #3b6fee;
    flex-shrink: 0;
}

.app-header-bu-menu-footer {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid #eff1f4;
}

.app-header-bu-manage {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #3a3f47;
    text-decoration: none;
    box-sizing: border-box;
}

.app-header-bu-manage:hover {
    background: #f5f6f8;
}

/* Tasks / Settings */
.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.app-header-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    background: #ffffff;
    border: 1px solid #e6e8ec;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #14161a;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(20, 22, 26, 0.06);
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.app-header-action-btn:hover {
    background: #f5f6f8;
    border-color: #d8dbe1;
}

.app-header-action-btn:focus-visible {
    outline: 2px solid #3b6fee;
    outline-offset: 2px;
}

.app-header-task-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e1483c;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.app-header-tasks-icon,
.app-header-settings-icon {
    flex-shrink: 0;
}

/* User identity */
.app-header-user-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: 10px;
    border: 1px solid transparent;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    max-width: 280px;
}

.app-header-user-block:hover {
    background: #f5f6f8;
    border-color: #e6e8ec;
}

.app-header-user-block:focus-visible {
    outline: 2px solid #3b6fee;
    outline-offset: 2px;
}

.app-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b 0%, #ec4899 55%, #7c3aed 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px #e6e8ec;
}

.app-header-user-text {
    line-height: 1.28;
    min-width: 0;
}

.app-header-user-name {
    display: block;
    font-size: 14.5px;
    font-weight: 700;
    color: #14161a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header-user-meta {
    display: block;
    font-size: 12.5px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}

.app-header-user-caret {
    color: #9aa1ac;
    flex-shrink: 0;
}

/* Legacy class hooks (kept for any stray references) */
.app-header-account {
    display: contents;
}

.app-header-organisation,
.app-header-workspace,
.app-header-company,
.app-header-business-unit,
.app-header-user,
.app-header-user-email {
    display: none;
}

.app-header-logout-form {
    display: inline;
    margin: 0;
}

@media (max-width: 860px) {
    .app-header {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .app-header-bu-value {
        max-width: 100px;
    }

    .app-header-user-meta {
        display: none;
    }

    .app-header-tasks-label,
    .app-header-settings-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .app-header-action-btn {
        padding: 0 10px;
    }

    .app-header-user-block {
        max-width: 180px;
    }
}

@media (max-width: 640px) {
    .app-header-right {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }

    .app-header-bu-menu {
        left: 0;
        right: auto;
    }

    .app-header-v-divider {
        display: none;
    }
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    min-height: auto;
    font-size: 0.85rem;
    border-radius: 8px;
    gap: 0.35rem;
}

.btn-sm.btn-icon > img,
.btn-sm.btn-icon > img {
    width: 16px;
    height: 16px;
}

.app-body {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
}

.app-body--no-sidebar {
    grid-template-columns: minmax(0, 1fr);
}

.app-sidebar {
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 0;
    align-self: stretch;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.25s ease;
    width: 100%;
}

@media (min-width: 901px) {
    body.sidebar-context-open .app-body {
        grid-template-columns: 450px minmax(0, 1fr);
    }
}

.app-main {
    padding: 1rem 1.25rem 1.5rem;
    display: grid;
    gap: 1rem;
    align-content: start;
    width: 100%;
    min-width: 0;
    min-height: 0;
    max-width: none;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/*
 * Minimal scrollbars (Facebook-style):
 * Idle track/thumb stay transparent so they blend into the container background.
 * On hover/focus-within, a thin rounded thumb appears; the track stays invisible.
 */
:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
) {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
):is(:hover, :focus-within) {
    scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar-track,
:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar-corner {
    background: transparent;
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
):is(:hover, :focus-within)::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.28);
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar-thumb:hover {
    background-color: rgba(15, 23, 42, 0.42);
}

:is(
    .app-main,
    .app-sidebar .sidebar-panel-content-navigation,
    .app-sidebar .sidebar-context-rail,
    .app-sidebar .sidebar-context-main .context-intelligence-scroll,
    .timeline-activity-list,
    #project-timeline-main #pt-panel-timeline:not([hidden])
)::-webkit-scrollbar-thumb:active {
    background-color: rgba(15, 23, 42, 0.5);
}

.empty-state {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 0.9rem;
    background: #f9fafb;
}

.dev-diagnostics {
    margin: 0 1rem 1rem 1rem;
    padding: 1rem;
    border: 1px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: 8px;
}

.page-header {
    display: grid;
    gap: 0.35rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .app-header {
        padding: 12px 16px;
        gap: 12px;
    }
}

@media (max-width: 900px) {
    .app-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .app-sidebar {
        border-right: 0;
        border-bottom: 1px solid #e5e7eb;
        max-height: 55vh;
        overflow-y: auto;
    }

    body.sidebar-context-open .app-body {
        grid-template-columns: 1fr;
    }
}

@media print {
    html:has(.app-shell),
    body:has(.app-shell) {
        height: auto !important;
        overflow: visible !important;
    }

    .app-shell {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }

    .app-body {
        display: block !important;
        overflow: visible !important;
    }

    .app-sidebar {
        max-height: none !important;
        overflow: visible !important;
    }

    .app-main {
        overflow: visible !important;
    }
}
