.comms-workspace-filters { display:flex; flex-wrap:wrap; align-items:end; gap:var(--halo-3); margin-bottom:var(--halo-4); }
.comms-workspace-filters > strong, .comms-workspace-filters > .halo-switch { align-self:center; }
.comms-workspace-filters > small { flex-basis:100%; }
.comms-workspace-filters [role="alert"] { color:var(--halo-ink-critical); }
    .comms-workspace-filters small { color:var(--halo-text-secondary); }

    .comms-hub {
        display: flex;
        gap: 14px;
        height: max(460px, calc(100dvh - 300px));
        min-height: 0;
        max-height: none;
        overflow: hidden;
    }

    .comms-workspace-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "title routing status";
        align-items: center;
        gap: 14px;
        margin-bottom: 12px;
        padding: 0 0 var(--halo-2);
        border: 0;
        background: transparent;
    }

    .comms-workspace-header__title {
        grid-area: title;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        min-width: 0;
    }

    .comms-workspace-header__back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        width: fit-content;
        color: var(--halo-text-secondary);
        font-size: var(--halo-text-sm);
        font-weight: 700;
        line-height: 1.2;
        text-decoration: none;
        transition: color var(--halo-duration-1) var(--halo-ease-out);
    }

    .comms-workspace-header__back:hover,
    .comms-workspace-header__back:focus-visible {
        color: var(--halo-ink-brand);
    }

    .comms-workspace-header__title h1 {
        margin: 0;
        color: var(--halo-text);
        font-family: var(--halo-font-display);
        font-size: var(--halo-text-page);
        font-weight: 600;
        letter-spacing: -0.025em;
        line-height: 1.2;
    }

    .comms-workspace-header__title > span {
        overflow: hidden;
        color: var(--halo-text-tertiary);
        font-size: var(--halo-text-sm);
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .comms-workspace-header__status {
        grid-area: status;
        display: flex;
        justify-content: flex-end;
        align-items: flex-start;
        padding-top: 4px;
        min-width: 12px;
    }

    .comms-routing {
        grid-area: routing;
        align-self: center;
        min-width: 0;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .comms-routing__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 8px;
    }

    .comms-routing__head > div {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .comms-routing__eyebrow,
    .comms-routing__type,
    .comms-routing__count {
        color: var(--halo-text-secondary);
        font-size: var(--halo-text-caption);
        font-weight: 600;
        letter-spacing: 0;
    }

    .comms-routing__head strong {
        color: var(--halo-text);
        font-size: var(--halo-text-body);
        line-height: 1.2;
    }

    .comms-routing__count {
        flex: 0 0 auto;
        padding: 4px 8px;
        border-radius: var(--halo-radius-pill);
        background: var(--halo-tint-info);
        color: var(--halo-ink-info);
    }

    .comms-routing__grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 8px;
    }

    .comms-routing__item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 144px;
        gap: 10px;
        align-items: center;
        min-height: 56px;
        padding: 9px 10px;
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-lg);
        background: var(--halo-surface);
        animation: comms-row-in var(--halo-duration-3) var(--halo-ease-out) both;
        animation-delay: calc(var(--halo-row, 0) * 30ms + 60ms);
    }

    .comms-routing__item:nth-child(1) { --halo-row: 0; }
    .comms-routing__item:nth-child(2) { --halo-row: 1; }
    .comms-routing__item:nth-child(3) { --halo-row: 2; }
    .comms-routing__item:nth-child(4) { --halo-row: 3; }
    .comms-routing__item:nth-child(5) { --halo-row: 4; }
    .comms-routing__item:nth-child(6) { --halo-row: 5; }
    .comms-routing__item:nth-child(7) { --halo-row: 6; }
    .comms-routing__item:nth-child(8) { --halo-row: 7; }
    .comms-routing__item:nth-child(9) { --halo-row: 8; }
    .comms-routing__item:nth-child(10) { --halo-row: 9; }
    .comms-routing__item:nth-child(11) { --halo-row: 10; }
    .comms-routing__item:nth-child(n+12) { --halo-row: 11; }

    .comms-routing__identity {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .comms-routing__identity strong {
        overflow: hidden;
        color: var(--halo-text);
        font-size: var(--halo-text-body);
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .comms-routing__identity small {
        overflow: hidden;
        color: var(--halo-text-secondary);
        font-size: var(--halo-text-caption);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .comms-routing__status-shell {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
        height: 34px;
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-pill);
        background: var(--halo-surface);
        transition: background-color var(--halo-duration-1) var(--halo-ease-out), border-color var(--halo-duration-1) var(--halo-ease-out), box-shadow var(--halo-duration-1) var(--halo-ease-out);
    }

    .comms-routing__status-dot {
        position: absolute;
        left: 10px;
        width: 9px;
        height: 9px;
        border-radius: var(--halo-radius-pill);
        background: var(--halo-text-secondary);
        box-shadow: none;
        pointer-events: none;
    }

    .comms-routing__status {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: var(--halo-radius-pill);
        background: transparent;
        color: var(--halo-text);
        font-size: var(--halo-text-sm);
        font-weight: 600;
        outline: none;
        padding: 0 8px 0 28px;
        cursor: pointer;
    }

    .comms-routing__status-shell--available {
        border-color: transparent;
        background: var(--halo-soft-green);
        box-shadow: none;
    }

    .comms-routing__status-shell--available .comms-routing__status,
    .comms-routing__status-shell--available .comms-routing__status-dot {
        background: var(--halo-fill-green);
        box-shadow: none;
    }

    .comms-routing__status-shell--available .comms-routing__status-dot {
        background: var(--halo-ink-success);
        box-shadow: none;
    }

    .comms-routing__status-shell--busy {
        border-color: transparent;
        background: var(--halo-soft-red);
        box-shadow: none;
    }

    .comms-routing__status-shell--busy .comms-routing__status {
        color: var(--halo-soft-red-ink);
    }

    .comms-routing__status-shell--busy .comms-routing__status-dot {
        background: var(--halo-fill-red);
        box-shadow: none;
    }

    .comms-routing__status-shell--away {
        border-color: transparent;
        background: var(--halo-soft-yellow);
        box-shadow: none;
    }

    .comms-routing__status-shell--away .comms-routing__status {
        color: var(--halo-soft-yellow-ink);
    }

    .comms-routing__status-shell--away .comms-routing__status-dot {
        background: var(--halo-fill-yellow);
        box-shadow: none;
    }

    .comms-routing__status-shell--offline {
        border-color: var(--halo-input-border);
        background: var(--halo-surface-sunken);
    }

    .comms-routing__status-shell--offline .comms-routing__status {
        color: var(--halo-text-secondary);
    }

    .comms-routing__status-shell--offline .comms-routing__status-dot {
        background: var(--halo-text-secondary);
        box-shadow: none;
    }

    .comms-routing__empty {
        min-height: 42px;
        display: flex;
        align-items: center;
        padding: 0 12px;
        border: 1px dashed var(--halo-hairline);
        border-radius: var(--halo-radius-lg);
        color: var(--halo-text-tertiary);
        font-size: var(--halo-text-sm);
        font-weight: 700;
        background: var(--halo-surface-sunken);
    }

    .comms-hub__list-panel {
        width: 38%;
        min-width: min(340px, 100%);
        max-width: 480px;
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .comms-hub__list-card {
        background: var(--halo-surface-sunken);
        border: 0;
        border-radius: var(--halo-radius-2xl);
        box-shadow: none;
        padding-top: var(--halo-3);
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    /* Shared segmented tabs; only Hub geometry belongs here. */
    .comms-hub__segmented-control { margin: 0 var(--halo-4); flex-shrink: 0; }
    .comms-hub__segmented-control .halo-worktab { flex: 1; justify-content: center; min-width: 0; padding-inline: var(--halo-2); gap: var(--halo-1); }

    .comms-hub__seg-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: var(--halo-radius-pill);
        background: var(--halo-action-brand);
        color: var(--halo-on-action);
        font-size: 0.625rem;
        font-weight: 700;
        line-height: 1;
    }

    .halo-worktab--active .comms-hub__seg-badge {
        background: var(--halo-action-brand);
    }

    .comms-hub__seg-badge--risk,
    .halo-worktab--active .comms-hub__seg-badge--risk {
        background: var(--halo-fill-yellow);
        color: var(--halo-on-fill-yellow);
    }

    .comms-hub__webchat-alert {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 10px 16px 0;
        padding: 9px 12px;
        border: 0;
        border-radius: var(--halo-radius-md);
        background: var(--halo-soft-yellow);
        color: var(--halo-soft-yellow-ink);
        font-size: var(--halo-text-sm);
        font-weight: 600;
    }

    .comms-hub__webchat-alert :is(.mud-icon-root, .halo-icon) {
        color: var(--halo-ink-warning);
    }

    .comms-hub__search {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 10px 16px 4px;
        padding: 0 12px;
        min-height: 40px;
        border: 0;
        border-radius:var(--halo-radius-control);
        background: var(--halo-surface);
        box-shadow: none;
    }

    .comms-hub__search-icon {
        color: var(--halo-text-tertiary);
        flex-shrink: 0;
    }

    .comms-hub__search-input {
        flex: 1;
        min-width: 0;
        border: none;
        background: transparent;
        color: var(--halo-text);
        font: inherit;
        font-size: var(--halo-text-sm);
        outline: none;
    }

    .comms-hub__search-input::placeholder {
        color: var(--halo-text-tertiary);
    }

    .comms-hub__search-input::-webkit-search-cancel-button {
        -webkit-appearance: none;
        appearance: none;
    }

    .comms-hub__search-clear {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--halo-text-tertiary);
        cursor: pointer;
        flex-shrink: 0;
        transition: background-color var(--halo-duration-1) var(--halo-ease-out), color var(--halo-duration-1) var(--halo-ease-out);
    }

    .comms-hub__search-clear:hover {
        background: var(--halo-surface-sunken);
        color: var(--halo-ink-brand);
    }

    .comms-hub__tab-content {
        padding: 10px 10px 16px;
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    .comms-hub__detail-panel {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .comms-hub__detail-card {
        background: var(--halo-surface);
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-2xl);
        box-shadow: none;
        padding: 20px;
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }

    .comms-hub__empty-detail {
        flex: 1;
        min-height: 400px;
        box-shadow: none;
        background: var(--halo-surface);
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-2xl);
    }

    .comms-hub__skeleton-tabs {
        display: flex;
        gap: 16px;
        padding: 16px 20px;
        border-bottom: 1px solid var(--halo-hairline);
    }

    .comms-hub__skeleton-list {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .comms-hub__skeleton-item {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 12px 0;
    }

    .comms-hub__skeleton-detail {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    /* ─── SignalR highlight animation (Task 12.7) ─── */
    @keyframes comms-hub-highlight {
        0% { background-color: var(--halo-soft-blue); }
        100% { background-color: transparent; }
    }

    .comms-hub-item-highlight {
        animation: comms-hub-highlight var(--halo-duration-3) var(--halo-ease-out);
    }

    @media (max-width: 1180px) {
        .comms-workspace-header {
            grid-template-columns: minmax(0, 1fr) auto;
            grid-template-areas:
                "title status"
                "routing routing";
            gap: 12px;
            padding: 0 0 var(--halo-4);
        }

        .comms-hub {
            height: max(460px, calc(100dvh - 340px));
            max-height: none;
        }
    }

    @media (max-width: 768px) {
        .comms-workspace-header {
            grid-template-columns: minmax(0, 1fr) auto;
        }

        .comms-routing__item {
            grid-template-columns: minmax(0, 1fr);
        }

        .comms-routing__status-shell {
            max-width: 180px;
        }

        .comms-hub {
            flex-direction: column;
            height: auto;
            max-height: none;
            overflow: visible;
        }

        .comms-hub__list-panel {
            width: 100%;
            max-width: none;
            min-height: 300px;
            max-height: 42dvh;
            border-right: none;
            border-bottom: none;
        }

        .comms-hub__list-card {
            border-radius: var(--halo-radius-lg);
        }

        .comms-hub__detail-panel {
            min-height: 460px;
        }

        .comms-hub__detail-card,
        .comms-hub__empty-detail {
            border-radius: var(--halo-radius-lg);
        }
    }

    /* ── Collapsible routing control: one header pill + popover, scales to any
       number of queues instead of an unbounded grid in the header. ── */
    .comms-routing-menu {
        grid-area: routing;
        position: relative;
        justify-self: end;
        align-self: center;
    }

    .comms-routing-trigger {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 40px;
        padding: 0 12px 0 14px;
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-pill);
        background: var(--halo-surface);
        color: var(--halo-text);
        font-size: var(--halo-text-sm);
        font-weight: 600;
        cursor: pointer;
        list-style: none;
        white-space: nowrap;
        transition: border-color var(--halo-duration-1) var(--halo-ease-out), box-shadow var(--halo-duration-1) var(--halo-ease-out), background-color var(--halo-duration-1) var(--halo-ease-out);
    }

    .comms-routing-trigger::-webkit-details-marker {
        display: none;
    }

    .comms-routing-trigger:hover {
        border-color: var(--halo-hairline-strong);
        background: var(--halo-surface-sunken);
    }

    .comms-routing-trigger:focus-visible {
        outline: none;
        border-color: var(--halo-ink-brand);
        box-shadow: var(--halo-focus-ring);
    }

    .comms-routing-trigger__dot {
        width: 9px;
        height: 9px;
        border-radius: 50%;
        background: var(--halo-text-tertiary);
        flex: 0 0 auto;
    }

    .comms-routing-trigger--available .comms-routing-trigger__dot {
        background: var(--halo-ink-success);
    }

    .comms-routing-trigger--mixed .comms-routing-trigger__dot {
        background: var(--halo-ink-warning);
    }

    .comms-routing-trigger__count {
        color: var(--halo-text-secondary);
        font-family: var(--halo-font-mono);
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }

    .comms-routing-trigger__caret {
        color: var(--halo-text-tertiary);
        transition: transform var(--halo-duration-2) var(--halo-ease-spring);
    }

    .comms-routing-menu[open] .comms-routing-trigger__caret {
        transform: rotate(180deg);
    }

    .comms-routing-panel {
        position: absolute;
        top: calc(100% + 8px);
        right: 0;
        z-index: 1000;
        width: min(420px, 92vw);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-lg);
        background: var(--halo-surface);
        box-shadow: var(--halo-shadow-3);
        transform-origin: top;
        animation: comms-routing-pop var(--halo-duration-4) var(--halo-ease-spring) both,
                   comms-routing-fade var(--halo-duration-2) var(--halo-ease-out) both;
    }

    @keyframes comms-routing-pop {
        from { transform: translateY(-8px) scale(.96); }
        to { transform: none; }
    }

    @keyframes comms-routing-fade {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes comms-row-in {
        from { opacity: 0; transform: translateY(6px); }
        to { opacity: 1; transform: none; }
    }

    .comms-routing-panel__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--halo-hairline);
    }

    .comms-routing-panel__head strong {
        font-size: var(--halo-text-body);
        color: var(--halo-text);
    }

    .comms-routing-panel__bulk {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: var(--halo-text-caption);
        color: var(--halo-text-tertiary);
    }

    .comms-routing-panel__bulk button {
        padding: 3px 8px;
        border: 1px solid var(--halo-hairline);
        border-radius: var(--halo-radius-pill);
        background: var(--halo-surface-sunken);
        color: var(--halo-text-secondary);
        font-size: var(--halo-text-caption);
        font-weight: 600;
        cursor: pointer;
        transition: background-color var(--halo-duration-1) var(--halo-ease-out), border-color var(--halo-duration-1) var(--halo-ease-out), color var(--halo-duration-1) var(--halo-ease-out);
    }

    .comms-routing-panel__bulk button:hover {
        border-color: var(--halo-ink-brand);
        color: var(--halo-ink-brand);
        background: var(--halo-tint-brand);
    }

    .comms-routing__error {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 12px;
        border: 0;
        border-radius: var(--halo-radius-lg);
        background: var(--halo-tint-warning);
        color: var(--halo-ink-warning);
        font-size: var(--halo-text-sm);
        font-weight: 700;
        line-height: 1.35;
    }

    .comms-routing__error :is(.mud-icon-root, .halo-icon) {
        flex: 0 0 auto;
        margin-top: 1px;
    }

    .comms-routing-panel__search {
        display: flex;
        align-items: center;
        gap: 6px;
        height: 34px;
        padding: 0 10px;
        border: 1px solid var(--halo-hairline);
        border-radius:var(--halo-radius-control);
        color: var(--halo-text-tertiary);
    }

    .comms-routing-panel__search input {
        flex: 1;
        min-width: 0;
        border: 0;
        outline: none;
        background: transparent;
        font-size: var(--halo-text-sm);
        color: var(--halo-text);
    }

    .comms-routing-panel__list {
        display: flex;
        flex-direction: column;
        gap: 6px;
        /* Fixed height of ~3 cards; the rest scroll inside the list so the
           header and "Set all" stay pinned. */
        max-height: 312px;
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--halo-hairline-strong) transparent;
    }

    .comms-routing-panel__list::-webkit-scrollbar {
        width: 8px;
    }

    .comms-routing-panel__list::-webkit-scrollbar-thumb {
        background: var(--halo-hairline-strong);
        border-radius: var(--halo-radius-pill);
    }

    .comms-routing-panel__list::-webkit-scrollbar-track {
        background: transparent;
    }

    @media (max-width: 767px) {
        .comms-routing-menu {
            justify-self: stretch;
        }

        .comms-routing-trigger {
            width: 100%;
            justify-content: flex-start;
        }

        .comms-routing-panel {
            right: auto;
            left: 0;
            width: 100%;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .comms-hub-item-highlight,
        .comms-routing-panel,
        .comms-routing__item {
            animation: none !important;
        }

        .comms-routing-trigger__caret { transition: none; }
    }
