:root {
    --lh-workspace-sidebar-expanded: 232px;
    --lh-workspace-sidebar-collapsed: 72px;
    --lh-workspace-sidebar-width: var(--lh-workspace-sidebar-expanded);
}

html.lh-sidebar-collapsed-pref {
    --lh-workspace-sidebar-width: var(--lh-workspace-sidebar-collapsed);
}

#workspace-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    body.lh-authenticated-workspace {
        padding-top: 0 !important;
        padding-left: var(--lh-workspace-sidebar-width);
        transition: padding-left 160ms ease;
    }

    body.lh-authenticated-workspace #main-navbar {
        display: none !important;
    }

    #workspace-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        display: flex;
        width: var(--lh-workspace-sidebar-width);
        min-width: var(--lh-workspace-sidebar-width);
        flex-direction: column;
        overflow: hidden;
        border-right: 1px solid var(--lh-border, #dbe3ee);
        background: var(--lh-bg-sidebar, #fbfcfe);
        color: #334155;
        box-shadow: none;
        transition: width 160ms ease, min-width 160ms ease;
    }

    .lh-sidebar__header {
        display: flex;
        min-height: 70px;
        align-items: center;
        justify-content: space-between;
        gap: 0.625rem;
        padding: 0.7rem 0.8rem;
        border-bottom: 1px solid var(--lh-border, #edf1f6);
    }

    .lh-sidebar__brand {
        display: inline-flex;
        min-width: 0;
        align-items: center;
        overflow: hidden;
    }

    .lh-sidebar__brand-full {
        display: block;
        width: auto;
        height: 50px;
        max-width: 182px;
        object-fit: contain;
        object-position: left center;
    }

    .lh-sidebar__brand-mark {
        display: none;
        width: 34px;
        height: 34px;
        object-fit: contain;
    }

    .lh-sidebar__collapse {
        display: inline-flex;
        width: 34px;
        height: 34px;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        border: 1px solid #d8e0ea;
        border-radius: 0.42rem;
        color: #64748b;
        background: #ffffff;
        transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    }

    .lh-sidebar__collapse:hover {
        border-color: #b9c6d6;
        background: #f8fafc;
        color: #1e293b;
    }

    .lh-sidebar__collapse:focus-visible,
    .lh-sidebar__link:focus-visible,
    .lh-sidebar__button:focus-visible,
    .lh-sidebar__account-action:focus-visible {
        outline: 3px solid rgba(36, 88, 166, 0.18);
        outline-offset: 1px;
    }

    .lh-sidebar__collapse-icon {
        transition: transform 160ms ease;
    }

    .lh-sidebar__scroll {
        min-height: 0;
        flex: 1 1 auto;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 0 0.62rem 0.8rem;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    .lh-sidebar__scroll > .lh-sidebar__section:first-child {
        padding-top: 0.8rem;
    }

    .lh-sidebar__section + .lh-sidebar__section {
        margin-top: 0.8rem;
        padding-top: 0.8rem;
        border-top: 1px solid #eef2f7;
    }

    .lh-sidebar__section-label {
        padding: 0 0.62rem 0.35rem;
        color: var(--lh-text-subtle, #627086);
        font-size: 0.625rem;
        font-weight: 800;
        letter-spacing: 0.09em;
        line-height: 0.85rem;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .lh-sidebar__nav {
        display: flex;
        flex-direction: column;
        gap: 0.18rem;
    }

    .lh-sidebar__link,
    .lh-sidebar__button {
        display: flex;
        width: 100%;
        min-height: 38px;
        align-items: center;
        gap: 0.68rem;
        border: 1px solid transparent;
        border-radius: 0.45rem;
        padding: 0.48rem 0.62rem;
        color: #475569;
        font-size: 0.76rem;
        font-weight: 700;
        line-height: 1rem;
        text-align: left;
        transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
        white-space: nowrap;
    }

    .lh-sidebar__button {
        cursor: pointer;
    }

    .lh-sidebar__link:hover,
    .lh-sidebar__button:hover {
        background: #f5f8fc;
        border-color: #e7edf5;
        color: #163b6d;
    }

    .lh-sidebar__link[aria-current="page"],
    .lh-sidebar__button[aria-current="page"] {
        border-color: #cbdcf2;
        background: #eef5ff;
        color: #1d4f91;
    }

    .lh-sidebar__icon {
        width: 17px;
        height: 17px;
        flex: 0 0 auto;
        color: #708198;
        transition: color 120ms ease;
    }

    .lh-sidebar__link:hover .lh-sidebar__icon,
    .lh-sidebar__button:hover .lh-sidebar__icon,
    .lh-sidebar__link[aria-current="page"] .lh-sidebar__icon,
    .lh-sidebar__button[aria-current="page"] .lh-sidebar__icon {
        color: currentColor;
    }

    .lh-sidebar__label {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .lh-sidebar__bottom {
        flex: 0 0 auto;
        border-top: 1px solid var(--lh-border, #e7edf4);
        background: var(--lh-bg-sidebar, #fbfcfe);
        padding: 0.65rem 0.62rem 0.7rem;
    }

    .lh-sidebar__account {
        display: flex;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        align-items: center;
        gap: 0.82rem;
        margin-top: 0.6rem;
        padding: 0.48rem 0.62rem;
        border: 1px solid transparent;
        border-radius: 0.45rem;
        background: transparent;
        color: #334155;
        text-align: left;
        cursor: pointer;
        transition: background-color 120ms ease, color 120ms ease;
    }

    .lh-sidebar__account:hover {
        background: #f5f8fc;
        color: #163b6d;
    }

    .lh-sidebar__account:focus-visible {
        outline: 3px solid rgba(36, 88, 166, 0.18);
        outline-offset: 1px;
    }

    .lh-sidebar__account-mark {
        display: inline-flex;
        width: 17px;
        height: 17px;
        flex: 0 0 17px;
        align-items: center;
        justify-content: center;
        color: #708198;
    }

    .lh-sidebar__account-mark svg {
        width: 17px;
        height: 17px;
    }

    .lh-sidebar__account:hover .lh-sidebar__account-mark {
        color: currentColor;
    }

    .lh-sidebar__account-copy {
        display: flex;
        min-width: 0;
        flex: 1 1 auto;
        flex-direction: column;
        justify-content: center;
    }

    .lh-sidebar__account-name,
    .lh-sidebar__account-email {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .lh-sidebar__account-name {
        color: #0f172a;
        font-size: 0.72rem;
        font-weight: 800;
        line-height: 0.95rem;
    }

    .lh-sidebar__account-email {
        margin-top: 0.08rem;
        color: var(--lh-text-subtle, #627086);
        font-size: 0.625rem;
        font-weight: 600;
        line-height: 0.82rem;
    }

    .lh-sidebar__account-action {
        display: flex;
        width: 100%;
        min-height: 36px;
        align-items: center;
        gap: 0.65rem;
        margin-top: 0.18rem;
        padding: 0.44rem 0.62rem;
        border: 1px solid transparent;
        border-radius: 0.42rem;
        color: #b4232c;
        font-size: 0.72rem;
        font-weight: 800;
        text-align: left;
        transition: background-color 120ms ease;
    }

    .lh-sidebar__account-action:hover {
        background: #fff1f2;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__brand-full,
    html.lh-sidebar-collapsed-pref .lh-sidebar__section-label,
    html.lh-sidebar-collapsed-pref .lh-sidebar__label,
    html.lh-sidebar-collapsed-pref .lh-sidebar__account-copy {
        display: none;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__brand-mark {
        display: block;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__header {
        justify-content: center;
        padding-inline: 0.5rem;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__collapse {
        position: absolute;
        top: 51px;
        left: 53px;
        width: 26px;
        height: 26px;
        border-radius: 999px;
        background: #ffffff;
        box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__collapse-icon {
        transform: rotate(180deg);
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__link,
    html.lh-sidebar-collapsed-pref .lh-sidebar__button,
    html.lh-sidebar-collapsed-pref .lh-sidebar__account,
    html.lh-sidebar-collapsed-pref .lh-sidebar__account-action {
        justify-content: center;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__link,
    html.lh-sidebar-collapsed-pref .lh-sidebar__button,
    html.lh-sidebar-collapsed-pref .lh-sidebar__account-action {
        padding-inline: 0.45rem;
    }

    html.lh-sidebar-collapsed-pref .lh-sidebar__account {
        padding-inline: 0.45rem;
    }
}

/* Medium desktop widths keep the invoice workspace usable by forcing the rail.
   The user's saved expanded/collapsed preference resumes at >=1280px. */
@media (min-width: 1024px) and (max-width: 1279px) {
    :root,
    html.lh-sidebar-collapsed-pref {
        --lh-workspace-sidebar-width: var(--lh-workspace-sidebar-collapsed);
    }

    .lh-sidebar__brand-full,
    .lh-sidebar__section-label,
    .lh-sidebar__label,
    .lh-sidebar__account-copy {
        display: none !important;
    }

    .lh-sidebar__brand-mark {
        display: block !important;
    }

    .lh-sidebar__header,
    .lh-sidebar__link,
    .lh-sidebar__button,
    .lh-sidebar__account,
    .lh-sidebar__account-action {
        justify-content: center;
    }

    .lh-sidebar__header {
        padding-inline: 0.5rem;
    }

    .lh-sidebar__link,
    .lh-sidebar__button,
    .lh-sidebar__account-action {
        padding-inline: 0.45rem;
    }

    .lh-sidebar__account {
        padding-inline: 0.45rem;
    }

    .lh-sidebar__collapse {
        display: none;
    }
}

/* Current workspace activity lives in the navigation rail instead of creating
   a second persistent floating stack. The newest activity may expand into the
   global activity panel; older/minimized work remains here. */
@media (min-width: 1024px) {
    .lh-sidebar__activity-section[hidden] { display: none !important; }
    .lh-sidebar__activity-toggle { position: relative; --lh-activity-signal: 36, 88, 166; }
    .lh-sidebar__activity-icon { position: relative; display: inline-flex; flex: 0 0 17px; align-items: center; justify-content: center; }
    .lh-sidebar__activity-badge {
        display: none;
        position: absolute;
        top: -5px;
        right: -6px;
        width: 10px;
        height: 10px;
        border: 2px solid var(--lh-bg-sidebar, #fbfcfe);
        border-radius: 50%;
        background: #2458a6;
        box-sizing: border-box;
    }
    .lh-sidebar__activity-toggle[data-activity-tone="error"] { --lh-activity-signal: 190, 18, 60; }
    .lh-sidebar__activity-toggle[data-activity-tone="complete"] { --lh-activity-signal: 23, 133, 94; }
    .lh-sidebar__activity-toggle[data-activity-tone="cancelled"] { --lh-activity-signal: 100, 116, 139; }
    .lh-sidebar__activity-toggle[data-activity-tone="error"] .lh-sidebar__activity-badge { background: #be123c; }
    .lh-sidebar__activity-toggle[data-activity-tone="complete"] .lh-sidebar__activity-badge { background: #17855e; }
    .lh-sidebar__activity-toggle[data-activity-tone="cancelled"] .lh-sidebar__activity-badge { background: #64748b; }
    html.lh-sidebar-collapsed-pref .lh-sidebar__activity-badge { display: block; }
    .lh-sidebar__activity-toggle.is-activity-pulsing .lh-sidebar__activity-badge { animation: lh-activity-badge-pulse 850ms ease-out 2; }
    .lh-sidebar__activity-toggle.is-activity-arriving { animation: lh-activity-arrival 540ms ease-out 1; }
    .lh-sidebar__activity-chevron {
        width: 14px;
        height: 14px;
        margin-left: auto;
        flex: 0 0 auto;
        color: #7b8ba1;
        transition: transform 160ms ease;
    }
    .lh-sidebar__activity-toggle[aria-expanded="false"] .lh-sidebar__activity-chevron { transform: rotate(-90deg); }
    .lh-sidebar__activity-list {
        display: flex;
        flex-direction: column;
        gap: 0.22rem;
        padding: 0.22rem 0 0;
    }
    .lh-sidebar__activity-list[hidden] { display: none !important; }
    .lh-sidebar__activity-item {
        display: flex;
        width: 100%;
        min-width: 0;
        align-items: center;
        gap: 0.48rem;
        min-height: 34px;
        padding: 0.38rem 0.5rem 0.38rem 0.62rem;
        border: 1px solid #d7e4f4;
        border-left: 3px solid #2458a6;
        border-radius: 0.42rem;
        background: #ffffff;
        color: #334155;
        text-align: left;
        cursor: pointer;
        transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
    }
    .lh-sidebar__activity-item:hover { background: #f8fbff; color: #173f76; }
    .lh-sidebar__activity-item.is-complete { border-color: #b9e7d4; border-left-color: #17855e; }
    .lh-sidebar__activity-item.is-error { border-color: #fecdd3; border-left-color: #be123c; }
    .lh-sidebar__activity-item.is-cancelled { border-color: #cbd5e1; border-left-color: #64748b; }
    .lh-sidebar__activity-item.is-expanded { background: #eef5ff; border-color: #bfd4ef; }
    .lh-sidebar__activity-item .lh-activity-list-dot {
        width: 7px;
        height: 7px;
        flex: 0 0 7px;
        border-radius: 999px;
        background: #2458a6;
    }
    .lh-sidebar__activity-item.is-complete .lh-activity-list-dot { background: #17855e; }
    .lh-sidebar__activity-item.is-error .lh-activity-list-dot { background: #be123c; }
    .lh-sidebar__activity-item.is-cancelled .lh-activity-list-dot { background: #64748b; }
    .lh-sidebar__activity-item .lh-activity-list-copy { min-width: 0; display: flex; flex: 1 1 auto; flex-direction: column; }
    .lh-sidebar__activity-item .lh-activity-list-name,
    .lh-sidebar__activity-item .lh-activity-list-state { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .lh-sidebar__activity-item .lh-activity-list-name { font-size: 0.66rem; line-height: 0.85rem; font-weight: 800; color: #334155; }
    .lh-sidebar__activity-item .lh-activity-list-state { margin-top: 0.05rem; font-size: 0.625rem; line-height: 0.82rem; font-weight: 600; color: #718096; }

    html.lh-sidebar-collapsed-pref .lh-sidebar__activity-chevron,
    html.lh-sidebar-collapsed-pref .lh-sidebar__activity-list,
    html.lh-sidebar-collapsed-pref .lh-sidebar__activity-toggle .lh-sidebar__label {
        display: none !important;
    }

    @media (max-width: 1279px) {
        .lh-sidebar__activity-chevron,
        .lh-sidebar__activity-list,
        .lh-sidebar__activity-toggle .lh-sidebar__label { display: none !important; }
    }
}

@keyframes lh-activity-badge-pulse {
    50% { box-shadow: 0 0 0 5px rgba(var(--lh-activity-signal), .18); transform: scale(1.18); }
}

@keyframes lh-activity-arrival {
    45% { background: #e9f2ff; box-shadow: 0 0 0 5px rgba(36, 88, 166, .15); }
}

@media (prefers-reduced-motion: reduce) {
    .lh-sidebar__activity-toggle.is-activity-pulsing .lh-sidebar__activity-badge,
    .lh-sidebar__activity-toggle.is-activity-arriving { animation: none !important; }
}
