.app-shell {
    min-height: 100vh;
}

.sidebar {
    display: none;
}

.main-panel {
    min-height: 100vh;
    padding-bottom: 6.25rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0.75rem var(--space-4);
    background: var(--topbar-bg, var(--color-primary));
    border-bottom: 1px solid var(--topbar-border, rgba(255, 255, 255, 0.2));
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
    min-height: 3.85rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.topbar-brand-mark {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 0.65rem;
    background: transparent;
    color: var(--logo-color);
    overflow: hidden;
    flex-shrink: 0;
}

.topbar-logo,
.sidebar-logo {
    width: 100%;
    height: 100%;
    color: var(--logo-color);
}

.topbar-brand-copy {
    display: grid;
    gap: 0;
}

.topbar-brand-title {
    margin: 0;
    color: var(--topbar-text, #ffffff);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    line-height: 1.2;
}

.topbar-brand-subtitle {
    margin: 0;
    color: var(--topbar-subtext, rgba(255, 255, 255, 0.86));
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    display: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.topbar-actions .btn {
    gap: 0.45rem;
    color: var(--topbar-text, #ffffff);
    border-color: var(--topbar-button-border, rgba(255, 255, 255, 0.28));
    background: transparent;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.topbar-username {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--topbar-text, #ffffff);
}

.topbar-role {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--topbar-subtext, rgba(255, 255, 255, 0.86));
}

.icon-button,
.avatar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 1px solid var(--topbar-button-border, rgba(255, 255, 255, 0.28));
    border-radius: 999px;
    background: var(--topbar-button-bg, rgba(255, 255, 255, 0.12));
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.icon-button {
    cursor: pointer;
}

.notification-button {
    position: relative;
}

.notification-button.is-empty .notification-counter {
    display: none;
}

.icon-bell {
    color: var(--topbar-text, #ffffff);
}

.notification-button.has-unread .icon-bell {
    color: var(--topbar-text, #ffffff);
}

.notification-counter {
    position: absolute;
    top: -0.3rem;
    right: -0.3rem;
    min-width: 1rem;
    height: 1rem;
    padding: 0 0.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--color-danger);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 1;
}

.icon-button:hover {
    background: var(--topbar-button-hover-bg, rgba(255, 255, 255, 0.2));
}

.avatar-button:hover {
    background: var(--topbar-button-hover-bg, rgba(255, 255, 255, 0.2));
}

.avatar-placeholder {
    display: grid;
    width: 1.6rem;
    height: 1.6rem;
    place-items: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--topbar-text, #ffffff);
    background: var(--topbar-bg, var(--color-primary));
    border-radius: 999px;
}

.page-content {
    padding: 1.15rem var(--space-4) var(--space-5);
    scroll-margin-top: 5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: 1.25rem;
}


.page-header h2 {
    margin-bottom: 0.75rem;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.page-title-accent {
    width: 2px;
    height: 1.2rem;
    border-radius: 999px;
    background: var(--color-primary);
    flex-shrink: 0;
}

.page-title-icon {
    display: inline-grid;
    place-items: center;
    width: 1.15rem;
    height: 1.15rem;
    color: var(--color-primary);
    flex-shrink: 0;
}

.page-title-icon .nav-icon-svg {
    width: 1.05rem;
    height: 1.05rem;
}

.page-title-row h2 {
    margin-bottom: 0;
}

.page-header .eyebrow {
    margin-bottom: 0.5rem;
}

.page-eyebrow-row {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    margin-bottom: 0.5rem;
}

.page-eyebrow-row .eyebrow {
    margin-bottom: 0;
}

.page-eyebrow-icon {
    display: inline-grid;
    place-items: center;
    width: 0.95rem;
    height: 0.95rem;
    color: var(--color-primary);
    flex-shrink: 0;
}

.page-eyebrow-icon .nav-icon-svg {
    width: 0.92rem;
    height: 0.92rem;
}

.page-header .muted {
    margin: 0;
    max-width: 58ch;
}


.page-header--stack {
    align-items: flex-start;
}

.page-actions {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

.dashboard-metric-grid {
    gap: var(--space-5);
    row-gap: var(--space-5);
}

.summary-grid.compact {
    gap: var(--space-3);
    row-gap: var(--space-3);
}

.table-shell {
    display: none;
}

.table-shell--always {
    display: block;
}

.worker-card-stack {
    display: grid;
    gap: var(--space-4);
}

.parent-work-mobile-list {
    margin-top: var(--space-4);
}

.parent-work-mobile-item .card-header {
    margin-bottom: var(--space-3);
}

.parent-work-mobile-meta {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.parent-work-mobile-meta p {
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

.mobile-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    padding: 0.35rem 0.5rem;
    background: var(--mobile-nav-bg);
    border-top: 1px solid var(--color-border);
    border-right: none;
    border-bottom: none;
    border-left: none;
    border-radius: 0;
    box-shadow: 0 -8px 18px rgba(16, 24, 40, 0.12);
}

/* Apply safe-area bottom padding only on iOS WebKit to avoid nav lift on other platforms. */
@supports (-webkit-touch-callout: none) {
    .mobile-nav {
        padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
    }
}

.mobile-nav.mobile-nav--worker {
    grid-template-columns: repeat(5, 1fr);
}

.mobile-nav a {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.2rem;
    min-height: 2.55rem;
    padding: 0.35rem 0.25rem;
    color: var(--mobile-nav-icon);
    text-align: center;
    border-radius: 0.7rem;
}

.mobile-nav a.active {
    color: var(--mobile-nav-icon-active);
    background: var(--color-primary-soft);
}

.mobile-tab-icon {
    display: inline-grid;
    width: 1.45rem;
    height: 1.45rem;
    place-items: center;
}

.mobile-tab-label {
    font-size: 0.72rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    color: currentColor;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.worker-card-stack--always {
    display: grid;
}

.nav-icon-svg {
    width: 1.1rem;
    height: 1.1rem;
    color: currentColor;
    fill: none;
    stroke: currentColor;
    stroke-width: var(--icon-stroke-width);
    filter: var(--icon-glow);
}

.nav-icon-svg--filled {
    fill: currentColor;
    stroke: none;
}

.mobile-nav .nav-icon-svg {
    width: 1.42rem;
    height: 1.42rem;
}

.mobile-nav details.mobile-nav-more {
    position: static;
}

.mobile-nav details.mobile-nav-more > summary {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.2rem;
    min-height: 2.55rem;
    padding: 0.35rem 0.25rem;
    color: var(--mobile-nav-icon);
    text-align: center;
    border-radius: 0.7rem;
    cursor: pointer;
    list-style: none;
}

.mobile-nav details.mobile-nav-more > summary::marker {
    display: none;
}

.mobile-nav details.mobile-nav-more > summary::-webkit-details-marker {
    display: none;
}

.mobile-nav details.mobile-nav-more[open] > summary,
.mobile-nav details.mobile-nav-more.is-active > summary {
    color: var(--mobile-nav-icon-active);
    background: var(--color-primary-soft);
}

.mobile-more-icon-glyph {
    font-size: 1.25rem;
    letter-spacing: 0.02em;
    line-height: 1;
    font-weight: 700;
}

.mobile-nav .mobile-more-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.32);
    z-index: 71;
}

.mobile-nav .mobile-more-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-admin-nav-height, 62px);
    z-index: 72;
    background: #ffffff;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    box-shadow: 0 -10px 28px rgba(16, 24, 40, 0.18);
    padding: 0.55rem 0.6rem 0.75rem;
    display: none;
    gap: 0.2rem;
}

.mobile-nav details.mobile-nav-more[open] .mobile-more-backdrop,
.mobile-nav details.mobile-nav-more[open] .mobile-more-sheet {
    display: grid;
}

.mobile-more-sheet-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0 0.4rem;
    color: var(--color-muted);
    font-size: 0.8rem;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mobile-nav .mobile-more-sheet a {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    min-height: 2.15rem;
    padding: 0.38rem 0.45rem;
    border-radius: 0.6rem;
    color: var(--color-text);
}

.mobile-nav .mobile-more-sheet a:hover {
    background: var(--color-surface-soft);
}

.mobile-more-icon {
    display: inline-grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    color: var(--color-muted);
}

.mobile-nav .mobile-more-sheet .nav-icon-svg {
    width: 1rem;
    height: 1rem;
}

@media (max-width: 768px) {
    .mobile-summary-scroll {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        margin-bottom: var(--space-3);
        width: 100%;
    }

    .mobile-summary-scroll::-webkit-scrollbar {
        display: none;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.45rem;
        width: auto;
        min-width: max-content;
        margin: 0;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact .summary-metric {
        flex: 0 0 auto;
        width: clamp(10.6rem, 67vw, 13.2rem);
        min-height: 7.2rem;
        padding: 0.52rem 0.58rem;
        gap: 0.28rem;
        scroll-snap-align: start;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact .summary-metric-label {
        font-size: 0.61rem;
        letter-spacing: 0.04em;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact .summary-metric-value {
        font-size: 1.05rem;
        letter-spacing: -0.02em;
        line-height: 1.08;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact .summary-metric .muted {
        font-size: 0.71rem;
        line-height: 1.22;
    }

    .mobile-summary-scroll .summary-grid--tasks-compact .summary-metric .muted {
        overflow-wrap: anywhere;
    }

    body:not(.role-worker).ns-tasks.page-task-centre .tasks-tabs {
        margin-top: 0;
        margin-bottom: var(--space-3);
    }

    body:not(.role-worker) {
        --mobile-admin-nav-height: 62px;
        height: 100dvh;
        overflow: hidden;
        padding-bottom: 0;
        box-sizing: border-box;
    }

    body:not(.role-worker) .app-shell {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    body:not(.role-worker) .main-panel {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        overflow: hidden;
        padding-bottom: 0;
    }

    body:not(.role-worker) .topbar {
        position: relative;
        top: auto;
        flex-shrink: 0;
    }

    body:not(.role-worker) .page-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding-bottom: calc(var(--mobile-admin-nav-height) + env(safe-area-inset-bottom) + 1.25rem);
        scroll-padding-bottom: calc(var(--mobile-admin-nav-height) + env(safe-area-inset-bottom) + 1.25rem);
    }

    body:not(.role-worker) .page-content :is(input, select, textarea, button, summary, a, [tabindex]):focus,
    body:not(.role-worker) .page-content :is(input, select, textarea, button, summary, a, [tabindex]):focus-visible {
        scroll-margin-bottom: calc(var(--mobile-admin-nav-height) + env(safe-area-inset-bottom) + 0.75rem);
    }

    body:not(.role-worker) .mobile-nav:not(.mobile-nav--worker) {
        position: fixed;
        inset: auto 0 0 0;
        min-height: var(--mobile-admin-nav-height);
        width: 100%;
        z-index: 60;
        overflow: visible;
        background: #ffffff;
        opacity: 1;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    @supports (-webkit-touch-callout: none) {
        body:not(.role-worker) .mobile-nav:not(.mobile-nav--worker) {
            padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
        }
    }
}

@media (min-width: 900px) {
    :root {
        --desktop-topbar-height: 4.6rem;
    }

    .app-shell {
        display: grid;
        grid-template-columns: 220px 1fr;
    }

    .sidebar {
        position: sticky;
        top: var(--desktop-topbar-height);
        display: flex;
        flex-direction: column;
        height: calc(100vh - var(--desktop-topbar-height));
        padding: 1.05rem 0.85rem 0.9rem;
        background: var(--sidebar-bg);
        color: var(--sidebar-text);
        border-right: 1px solid rgba(255, 255, 255, 0.06);
        box-shadow: 2px 0 8px rgba(16, 24, 40, 0.08);
        overflow: hidden;
    }

    .brand {
        display: none;
    }

    .brand-mark {
        display: none;
    }

    .side-nav {
        display: flex;
        flex-direction: column;
        gap: 0.1rem;
        flex: 1;
    }

    .side-nav a {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        padding: 0.6rem 0.75rem;
        color: var(--sidebar-icon);
        border-radius: 0.9rem;
        font-weight: var(--font-weight-semibold);
        font-size: var(--font-size-sm);
        line-height: 1.2;
        transition: color 0.16s ease, background-color 0.16s ease, transform 0.16s ease;
    }

    .nav-icon {
        display: inline-grid;
        place-items: center;
        width: 1.3rem;
        height: 1.3rem;
        line-height: 1;
        flex-shrink: 0;
    }

    .side-nav .nav-icon-svg {
        width: 1.28rem;
        height: 1.28rem;
    }

    .side-nav a:hover {
        color: var(--sidebar-icon-hover);
        background: var(--sidebar-hover-bg);
    }

    .side-nav a.active {
        color: var(--sidebar-icon-active);
        background: var(--sidebar-active-bg);
        box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
    }

    .sidebar-footer {
        margin-top: auto;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        padding: 0.65rem 0.3rem 0;
    }

    .sidebar-version {
        margin: 0;
        color: #99a8c1;
        font-size: var(--font-size-xs);
        font-weight: var(--font-weight-medium);
    }

    .sidebar--light {
        color: #1f2d4d;
        border-right: 1px solid rgba(15, 23, 42, 0.08);
        box-shadow: 4px 0 16px rgba(15, 23, 42, 0.1);
    }

    .sidebar--light .side-nav a {
        color: var(--sidebar-icon);
    }

    .sidebar--light .side-nav a:hover {
        color: var(--sidebar-icon-hover);
        background: var(--sidebar-hover-bg);
    }

    .sidebar--light .side-nav a.active {
        color: var(--sidebar-icon-active);
        background: var(--sidebar-active-bg);
    }

    .sidebar--light .sidebar-footer {
        border-top-color: rgba(15, 23, 42, 0.09);
    }

    .sidebar--light .sidebar-version {
        color: #51627f;
    }

    .topbar {
        min-height: var(--desktop-topbar-height);
        padding: 0.9rem 1.45rem;
        width: calc(100% + 220px);
        margin-left: -220px;
        left: 0;
        right: 0;
        z-index: 20;
        background: var(--color-surface, #ffffff);
        border-bottom: 1px solid var(--color-border, rgba(15, 23, 42, 0.1));
    }

    .topbar-brand-mark {
        width: 2.45rem;
        height: 2.45rem;
        border-radius: 0.85rem;
        color: var(--color-primary);
    }

    .topbar-brand-title {
        font-size: 1.02rem;
        color: var(--color-text, #0f172a);
    }

    .topbar-brand-subtitle {
        display: block;
        color: var(--color-text-muted, #64748b);
    }

    .topbar-user-info {
        display: flex;
    }

    .topbar-username {
        color: var(--color-text, #0f172a);
    }

    .topbar-role {
        color: var(--color-text-muted, #64748b);
    }

    .icon-button,
    .avatar-button {
        border: 1px solid var(--color-border, rgba(15, 23, 42, 0.14));
        background: transparent;
    }

    .icon-bell,
    .notification-button.has-unread .icon-bell {
        color: var(--color-text-muted, #64748b);
    }

    .icon-button:hover {
        background: var(--color-surface-alt, rgba(15, 23, 42, 0.05));
    }

    .topbar-actions {
        gap: 0.9rem;
    }

    .topbar-actions .btn {
        color: var(--color-text, #0f172a);
        border-color: var(--color-border, rgba(15, 23, 42, 0.2));
        background: transparent;
    }

    .avatar-placeholder {
        color: #ffffff;
        background: var(--color-primary);
    }

    .main-panel {
        padding-bottom: 0;
    }

    .page-content {
        padding: 1.45rem 1.6rem var(--space-6);
    }

    .dashboard-grid,
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-grid--detail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-shell {
        display: block;
    }

    .worker-card-stack {
        display: none;
    }

    .worker-card-stack.worker-card-stack--always {
        display: grid;
    }

    .parent-work-mobile-list {
        display: none;
    }

    .mobile-nav {
        display: none;
    }
}

@media (min-width: 1200px) {
    .dashboard-grid,
    .summary-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .summary-grid--detail {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Small screens — extra compact */
@media (max-width: 420px) {
    .topbar {
        padding: var(--space-3);
    }

    .topbar-user-info {
        display: none;
    }

    .page-content {
        padding: var(--space-3);
    }

    /* Keep bottom navigation anchored to viewport edges on small screens.
       Do not inset this nav, otherwise it appears to float and leaves a strip below. */
    .mobile-nav {
        right: 0;
        bottom: 0;
        left: 0;
        border-radius: 0;
    }
}
